diff options
author | Sven Gothel <[email protected]> | 2023-07-02 05:34:13 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-07-02 05:34:13 +0200 |
commit | e999ece8b0cd2ec440314f9a4c20812c694991ae (patch) | |
tree | 8b03b8905e5bb3709d68805a98a3f60abba99551 | |
parent | 1caceb4e72b2e99c5c458d37ebced0c51fe6bb70 (diff) |
GlueGen Struct [18]: Drop redundant 'static get*ElemCount() { return 1 }` for: isPrimitive && !isPointer && staticElemCount && maxOneElement
-rw-r--r-- | src/java/com/jogamp/gluegen/JavaEmitter.java | 6 | ||||
-rw-r--r-- | src/junit/com/jogamp/gluegen/test/junit/generation/Test2FuncPtr.java | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/src/java/com/jogamp/gluegen/JavaEmitter.java b/src/java/com/jogamp/gluegen/JavaEmitter.java index c00d2ed..64aaa8a 100644 --- a/src/java/com/jogamp/gluegen/JavaEmitter.java +++ b/src/java/com/jogamp/gluegen/JavaEmitter.java @@ -1957,8 +1957,10 @@ public class JavaEmitter implements GlueEmitter { // if( ownElemCountHandling ) { if( constElemCount ) { - generateGetterSignature(unit, staticElemCount, false, fieldName, fieldType, ownership, "int", capitalFieldName+"ElemCount", null, constElemCount, maxOneElement, elemCountExpr, GetElemCountApiDocTail); - unit.emitln(" { return "+elemCountExpr+"; }"); + if( !( isPrimitive && !isPointer && staticElemCount && maxOneElement ) ) { // drop useless `static get*ElemCount() { return 1; }` + generateGetterSignature(unit, staticElemCount, false, fieldName, fieldType, ownership, "int", capitalFieldName+"ElemCount", null, constElemCount, maxOneElement, elemCountExpr, GetElemCountApiDocTail); + unit.emitln(" { return "+elemCountExpr+"; }"); + } } else if( useGetCStringLength ) { generateGetterSignature(unit, staticElemCount, false, fieldName, fieldType, ownership, "int", capitalFieldName+"ElemCount", null, constElemCount, maxOneElement, elemCountExpr, GetElemCountApiDocTail); unit.emitln(" {"); diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test2FuncPtr.java b/src/junit/com/jogamp/gluegen/test/junit/generation/Test2FuncPtr.java index cf32eb7..915b3eb 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/Test2FuncPtr.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test2FuncPtr.java @@ -96,7 +96,7 @@ public class Test2FuncPtr extends BaseClass { Assert.assertNotEquals(0, options.getCustomFuncB1()); Assert.assertNotEquals(0, options.getCustomFuncB2()); Assert.assertEquals(1, options.getApiVersion()); - Assert.assertEquals(1, T2_InitializeOptions.getReserved1ElemCount()); + // dropped: Assert.assertEquals(1, T2_InitializeOptions.getReserved1ElemCount()); BaseClass.assertAPTR(0x0000CAFFEEBEEFL, options.getReserved1()); { options.setReserved1(0xBEEFCAFFEE0DADL); |