summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathieu Féry <[email protected]>2023-08-03 13:30:20 +0200
committerMathieu Féry <[email protected]>2023-08-03 13:31:54 +0200
commit9bf13be7d8a144be18dd313e8ed7658f25b9c1d0 (patch)
tree4ef25799129ce48362a7c5e597d21cbbe84170d4
parentfe21c87b24842d67df686b7c48fa36ed65a9afc9 (diff)
feat(arrayAccessor): Allow to use ReturnedArrayLength with getter associated with field with name in PascalCase or camelCase
-rw-r--r--src/java/com/jogamp/gluegen/JavaEmitter.java19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/java/com/jogamp/gluegen/JavaEmitter.java b/src/java/com/jogamp/gluegen/JavaEmitter.java
index 576e9bc..8310cda 100644
--- a/src/java/com/jogamp/gluegen/JavaEmitter.java
+++ b/src/java/com/jogamp/gluegen/JavaEmitter.java
@@ -1852,11 +1852,22 @@ public class JavaEmitter implements GlueEmitter {
if( !_constElemCount ) {
// check for const length field
if( elemCountExpr.startsWith("get") && elemCountExpr.endsWith("()") ) {
- final String lenFieldName = CodeGenUtils.decapitalizeString( elemCountExpr.substring(3, elemCountExpr.length()-2) );
- final Field lenField = structCType.getField(lenFieldName);
- if( null != lenField ) {
- _constElemCount = lenField.getType().isConst();
+ final String baseLenFieldName = elemCountExpr.substring(3, elemCountExpr.length()-2);
+ String lenFieldName = CodeGenUtils.decapitalizeString( baseLenFieldName );
+ Field lenField = structCType.getField(lenFieldName);
+ if( null == lenField ) {
+ lenFieldName = baseLenFieldName;
+ lenField = structCType.getField(lenFieldName);
}
+ if( null == lenField ) {
+ throw new GlueGenException("Unable to creating array accessors for field \"" +
+ fqStructFieldName + "\", because elemCountExpr specify following getter \"" +
+ elemCountExpr + "\" and host structure doesn't contain following field \"" +
+ CodeGenUtils.decapitalizeString( baseLenFieldName ) + "\" or \"" +
+ baseLenFieldName + "\"",
+ fieldType.getASTLocusTag());
+ }
+ _constElemCount = lenField.getType().isConst();
LOG.log(INFO, structCType.getASTLocusTag(),
unit.className+": elemCountExpr "+elemCountExpr+", lenFieldName "+lenFieldName+" -> "+lenField.toString()+", isConst "+_constElemCount);
}