@@ -2573,25 +2573,43 @@ boolean variable(Context context, DeclarationList declList) throws ParserExcepti
25732573 if (context .namespace != null && context .javaName == null ) {
25742574 decl .text += "@Namespace(\" " + context .namespace + "\" ) " ;
25752575 }
2576- if (metadcl != null && metadcl .cppName != null && metadcl .cppName .length () > 0 ) {
2577- decl .text += metadcl .indices == 0
2576+ final boolean hasMetadcl = metadcl != null && metadcl .cppName != null && metadcl .cppName .length () > 0 ;
2577+ String nameAnnotation = "" ;
2578+ if (hasMetadcl ) {
2579+ nameAnnotation = metadcl .indices == 0
25782580 ? "@Name(\" " + metadcl .cppName + "." + shortName + "\" ) "
25792581 : "@Name({\" " + metadcl .cppName + "\" , \" ." + shortName + "\" }) " ;
2580- dcl .type .annotations = dcl .type .annotations .replaceAll ("@Name\\ (.*\\ ) " , "" );
25812582 javaName = metadcl .javaName + "_" + shortName ;
25822583 }
2584+ final boolean beanify = context .beanify && indices .isEmpty ();
2585+ String capitalizedJavaName = null ;
2586+ if (beanify ) {
2587+ if (!hasMetadcl ) {
2588+ nameAnnotation = "@Name(\" " + shortName + "\" ) " ;
2589+ }
2590+ capitalizedJavaName = javaName .substring (0 , 1 ).toUpperCase () + javaName .substring (1 );
2591+ javaName = "get" + capitalizedJavaName ;
2592+ }
2593+ if (hasMetadcl || beanify ) {
2594+ dcl .type .annotations = dcl .type .annotations .replaceAll ("@Name\\ (.*\\ ) " , "" );
2595+ decl .text += nameAnnotation ;
2596+ }
2597+ dcl .type .annotations = dcl .type .annotations .replace ("@ByVal " , "@ByRef " );
25832598 final boolean hasSetter = !(dcl .type .constValue && dcl .indirections == 0 ) && !dcl .constPointer && !dcl .type .constExpr && !context .immutable ;
2584- if (!hasSetter ) {
2599+ if (!hasSetter || beanify ) {
25852600 decl .text += "@MemberGetter " ;
25862601 }
2587- decl .text += modifiers + dcl .type .annotations .replace ("@ByVal " , "@ByRef " )
2588- + dcl .type .javaName + " " + javaName + "(" + indices + ");" ;
2602+ decl .text += modifiers + dcl .type .annotations + dcl .type .javaName + " " + javaName + "(" + indices + ");" ;
25892603 if (hasSetter ) {
25902604 if (indices .length () > 0 ) {
25912605 indices += ", " ;
25922606 }
2593- String javaTypeWithoutAnnotations = dcl .type .javaName .substring (dcl .type .javaName .lastIndexOf (" " ) + 1 );
2594- decl .text += " " + modifiers + setterType + javaName + "(" + indices + javaTypeWithoutAnnotations + " setter);" ;
2607+ if (beanify ) {
2608+ decl .text += "\n " + nameAnnotation + "@MemberSetter " + modifiers + setterType + "set" + capitalizedJavaName + "(" + indices + dcl .type .annotations + dcl .type .javaName + " setter);" ;
2609+ } else {
2610+ String javaTypeWithoutAnnotations = dcl .type .javaName .substring (dcl .type .javaName .lastIndexOf (" " ) + 1 );
2611+ decl .text += " " + nameAnnotation + modifiers + setterType + javaName + "(" + indices + javaTypeWithoutAnnotations + " setter);" ;
2612+ }
25952613 }
25962614 decl .text += "\n " ;
25972615 if ((dcl .type .constValue || dcl .constPointer || dcl .type .constExpr ) && dcl .type .staticMember && indices .length () == 0 ) {
@@ -3313,6 +3331,8 @@ boolean group(Context context, DeclarationList declList) throws ParserException
33133331 ctx .virtualize = true ;
33143332 if (info .immutable )
33153333 ctx .immutable = true ;
3334+ if (info .beanify )
3335+ ctx .beanify = true ;
33163336 }
33173337 ctx .baseType = base .cppName ;
33183338
0 commit comments