From 8b127c4c1dd26fcb1756805ddb83729203161f78 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 16 Jun 2023 02:16:20 +0200 Subject: GlueGen Struct [5]: Revised Struct Mapping + Documentation GlueGen Revised Struct Mapping (esp pointer to array or single element), Struct String Charset, .. and Documentation - Documentation: - Added README.md Let's have a proper face for the git repo - Added doc/GlueGen_Mapping.md (and its html conversion doc/GlueGen_Mapping.html) Created a new document covering application and implementation details suitable for users/devs. - Added doc/JogAmpMacOSVersions.md conversion to doc/JogAmpMacOSVersions.html - Updated www/index.html - Use *CodeUnit instead of PrintWriter, representing a Java or C code unit covering a set of functions and structs. The CCodeUnit also handles common code shared by its unit across functions etc. - Dropping 'static initializer', as its no more required due to simplified `JVMUtil_NewDirectByteBufferCopy()` variant. - Revised Struct Mapping: - Pure Java implementation to map primitive and struct fields within a struct by utilizing ElementBuffer. Only 'Function Pointer' fields within a struct require native code. Exposes `static boolean usesNativeCode()` to query whether native code is used/required. - Transparent native memory address API Expose `long getDirectBufferAddress()` and `static TK_Struct derefPointer(long addr)`, allowing to - pass the native struct-pointer with native code - reconstruct the struct from a native struct-pointer - have a fully functional `TK_Struct.derefPointer(struct.getDirectBufferAddress())` cycle. - Add 'boolean isNull() to query whether a pointer (array) is NULL - *Changed* array get/set method for more flexibility alike `System.arraycopy(src, srcPos, dest, destPos, len)`, where 'src' is being dropped for the getter and 'dest' is being dropped for the setter as both objects are reflected by the struct instance. - *Changed* `getArrayLength()` -> `getElemCount()` for clarity - Considering all ConstElemCount values with config 'ReturnedArrayLength ' to be owned by native code -> NativeOwnership -> Not changing the underlying memory region! JavaOwnership is considered for all pointer-arrays not of NativeOwnership. Hence any setter on a NativeOwnership pointer-array will fail with non-matching elem-count. - Add 'release()' for JavaOwnership pointer-arrays, allowing to release the Java owned native memory incl. null-ing pointer and setElemCount(0). - Support setter for 'const *' w/ JavaOwnership, i.e. pointer to const value of a primitive or struct, setter and getter using pointer to array or single element in general. - Added Config `ImmutableAccess symbol` to disable all setter for whole struct or a field - Added Config `MaxOneElement symbol` to restrict a pointer to maximum one element and unset initial value (zero elements) - Added Config `ReturnsStringOnly symbol` to restrict mapping only to a Java String, dropping the ByteBuffer variant for 'char' - String mapping default is UTF-8 and can be read and set via [get|set]Charset(..) per class. - Dynamic string length retrieval in case no `ReturnedArrayLength` has been configured has changed from `strlen()` to `strnlen(aptr, max_len)` to be on the safe site. The maximum length default is 8192 bytes and can be read and set via [get|set]MaxStrnlen(..) per class. FIXME: strnlen(..) using EOS byte non-functional for non 8-bit codecs like UTF-8, US-ASCII. This is due to e.g. UTF-16 doesn't use an EOS byte, but interprets it as part of a code point. - TODO: Perhaps a few more unit tests - TODO: Allow plain 'int' to be mapped in structs IFF their size is same for all MachineDescriptions used. Currently this is the case -> 4 bytes like int32_t. --- .../gluegen/test/junit/generation/BaseClass.java | 1080 ++++++++++++++------ .../test/junit/generation/Test1p1JavaEmitter.java | 17 +- .../generation/Test1p2DynamicLibraryBundle.java | 18 +- .../generation/Test1p2ProcAddressEmitter.java | 17 +- .../gluegen/test/junit/generation/test1-common.cfg | 333 +++++- .../jogamp/gluegen/test/junit/generation/test1.c | 486 +++++++-- .../jogamp/gluegen/test/junit/generation/test1.h | 357 ++++++- .../jogamp/gluegen/test/junit/generation/test2.c | 20 + .../jogamp/gluegen/test/junit/generation/test2.cfg | 52 + .../jogamp/gluegen/test/junit/generation/test2.h | 37 + 10 files changed, 1897 insertions(+), 520 deletions(-) create mode 100644 src/junit/com/jogamp/gluegen/test/junit/generation/test2.c create mode 100644 src/junit/com/jogamp/gluegen/test/junit/generation/test2.cfg create mode 100644 src/junit/com/jogamp/gluegen/test/junit/generation/test2.h (limited to 'src/junit/com/jogamp/gluegen') diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java index 34cd925..ed23f54 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java @@ -40,6 +40,7 @@ import java.nio.ByteOrder; import java.nio.FloatBuffer; import java.nio.IntBuffer; import java.nio.LongBuffer; +import java.nio.charset.Charset; import java.util.Arrays; import jogamp.common.os.MachineDataInfoRuntime; @@ -1252,7 +1253,7 @@ public class BaseClass extends SingletonJunitCase { Assert.assertEquals(2, surface.getClipSize()); - final TK_Dimension[] allclips = surface.getClips(0, new TK_Dimension[surface.getClipSize()]); + final TK_Dimension[] allclips = surface.getClips(0, new TK_Dimension[surface.getClipSize()], 0, surface.getClipSize()); for(int i=0; i exception + } catch(final Exception _e) { e = _e; } + Assert.assertNotNull(e); + System.err.println("Expected exception: "+e); + } - // field: int32ArrayFixedLen - // CType['int32_t *', size [fixed false, lnx64 12], [array*1]], with array length of 3 + Assert.assertEquals(3, TK_Field.getConstInt32PointerConstLenElemCount()); + Assert.assertEquals(false, model.isConstInt32PointerConstLenNull()); { - final int size = TK_ModelConst.getInt32ArrayFixedLenArrayLength(); - final int[] all = model.getInt32ArrayFixedLen(0, new int[size]); - final IntBuffer allB = model.getInt32ArrayFixedLen(); + final int size = TK_Field.getConstInt32PointerConstLenElemCount(); + Assert.assertEquals(3, size); + final int[] all = model.getConstInt32PointerConstLen(0, new int[size], 0, size); + final IntBuffer allB = model.getConstInt32PointerConstLen(); + Assert.assertEquals(size, all.length); Assert.assertEquals(size, allB.limit()); for(int i=0; i exception + } catch(final Exception _e) { e1 = _e; } + Assert.assertNotNull(e1); + System.err.println("Expected exception-1: "+e1); + + Exception e2 = null; + try { + @SuppressWarnings("unused") + final int[] ia = model.getConstInt32PointerVariaLen(0, new int[0], 0, 0); // NULL -> exception + } catch(final Exception _e) { e2 = _e; } + Assert.assertNotNull(e2); + System.err.println("Expected exception-2: "+e2); } - // field: int32PointerCustomLen - // field: CType['int32_t *', size [fixed false, lnx64 8], [pointer*1]], with array length of getInt32PointerCustomLenVal() { - final int size = model.getInt32PointerCustomLenVal(); - final IntBuffer all = model.getInt32PointerCustomLen(); - Assert.assertEquals(size, all.limit()); + final int size = model.getConstInt32PointerCustomLenElemCount(); + Assert.assertEquals(4, size); + Assert.assertEquals(false, model.isConstInt32PointerCustomLenNull()); + final int[] all = model.getConstInt32PointerCustomLen(0, new int[size], 0, size); + final IntBuffer allB = model.getConstInt32PointerCustomLen(); + Assert.assertEquals(size, all.length); + Assert.assertEquals(size, allB.limit()); for(int i=0; i4*4 */ + /** Primitive.ConstValue.int32.Pointer - write access */ + @SuppressWarnings("unused") + private void chapter12_03bTestTKFieldConstValueInt32WriteAccess(final TK_Field model) { + Assert.assertEquals(0, model.getConstInt32PointerMaxOneElemElemCount()); + Assert.assertEquals(true, model.isConstInt32PointerMaxOneElemNull()); + model.setConstInt32PointerMaxOneElem(110); + Assert.assertEquals(1, model.getConstInt32PointerMaxOneElemElemCount()); + Assert.assertEquals(false, model.isConstInt32PointerMaxOneElemNull()); + Assert.assertEquals(110, model.getConstInt32PointerMaxOneElem()); + model.releaseConstInt32PointerMaxOneElem(); + Assert.assertEquals(0, model.getConstInt32PointerMaxOneElemElemCount()); + Assert.assertEquals(true, model.isConstInt32PointerMaxOneElemNull()); + + Assert.assertEquals(3, TK_Field.getConstInt32PointerConstLenElemCount()); + Assert.assertEquals(false, model.isConstInt32PointerConstLenNull()); { - Assert.assertEquals(4*4, TK_ModelConst.getMat4x4ArrayLength()); - final FloatBuffer mat4x4 = model.getMat4x4(); - Assert.assertEquals(4*4, mat4x4.limit()); - for(int i=0; i<4; i++) { - final float[] vec4 = model.getMat4x4(i*4, new float[4]); - for(int j=0; j<4; j++) { - Assert.assertEquals(i*4+j, mat4x4.get(i*4+j), EPSILON); - Assert.assertEquals(i*4+j, vec4[j], EPSILON); + // write 1 via IntBuffer reference get + // FIXME: Sort of violates the contract + { + final IntBuffer ib = model.getConstInt32PointerConstLen(); + Assert.assertEquals(3, ib.limit()); + for(int i=0; i<3; ++i) { + ib.put(i, 120+i); + } + } + // verify 1 + { + final int size = TK_Field.getConstInt32PointerConstLenElemCount(); + Assert.assertEquals(3, size); + final int[] all = model.getConstInt32PointerConstLen(0, new int[size], 0, size); + final IntBuffer allB = model.getConstInt32PointerConstLen(); + Assert.assertEquals(size, all.length); + Assert.assertEquals(size, allB.limit()); + for(int i=0; i exception + } catch(final Exception _e) { e1 = _e; } + Assert.assertNotNull(e1); + System.err.println("Expected exception-1: "+e1); + + Exception e2 = null; + try { + @SuppressWarnings("unused") + final int[] ia = model.getConstInt32PointerVariaLen(0, new int[0], 0, 0); // NULL -> exception + } catch(final Exception _e) { e2 = _e; } + Assert.assertNotNull(e2); + System.err.println("Expected exception-2: "+e2); + } + { + // write 1 via int[] set, also actually allocating initial memory + { + final int[] ia = { 220, 221, 222, 223, 224 }; + model.setConstInt32PointerVariaLen(ia, 0, 0, ia.length); + } + // verify 1 + { + final int size = model.getConstInt32PointerVariaLenElemCount(); + Assert.assertEquals(5, size); + final int[] all = model.getConstInt32PointerVariaLen(0, new int[size], 0, size); + final IntBuffer allB = model.getConstInt32PointerVariaLen(); + Assert.assertEquals(size, all.length); + Assert.assertEquals(size, allB.limit()); + for(int i=0; i exception + } catch(final Exception _e) { e = _e; } + Assert.assertNotNull(e); + System.err.println("Expected exception: "+e); } - final long surfaceContext = model.getCtx(); - assertAPTR(0x123456789abcdef0L, surfaceContext); - - model.setCtx(surfaceContext); - assertAPTR(surfaceContext, model.getCtx()); - + Assert.assertEquals(3, TK_Field.getVariaInt32PointerConstLenElemCount()); + Assert.assertEquals(false, model.isVariaInt32PointerConstLenNull()); { - Assert.assertEquals(12, TK_ModelConst.getModelNameArrayFixedLenArrayLength()); - - final ByteBuffer bb = model.getModelNameArrayFixedLen(); - Assert.assertEquals(12, bb.limit()); - - final String exp = "Hello Array"; - final String has = model.getModelNameArrayFixedLenAsString(); - // System.err.println("exp '"+exp+"'"); - System.err.println("has '"+has+"'"); - // dumpStringChars("exp", exp); - dumpStringChars("has", has); - Assert.assertEquals(11, has.length()); // w/o EOS - Assert.assertEquals(exp, has); + final int size = TK_Field.getVariaInt32PointerConstLenElemCount(); + Assert.assertEquals(3, size); + final int[] all = model.getVariaInt32PointerConstLen(0, new int[size], 0, size); + final IntBuffer allB = model.getVariaInt32PointerConstLen(); + Assert.assertEquals(size, all.length); + Assert.assertEquals(size, allB.limit()); + for(int i=0; i exception + } catch(final Exception _e) { e1 = _e; } + Assert.assertNotNull(e1); + System.err.println("Expected exception-1: "+e1); + + Exception e2 = null; + try { + @SuppressWarnings("unused") + final int[] ia = model.getVariaInt32PointerVariaLen(0, new int[0], 0, 0); // NULL -> exception + } catch(final Exception _e) { e2 = _e; } + Assert.assertNotNull(e2); + System.err.println("Expected exception-2: "+e2); } - binding.destroyModelConst(model); - } - private void dumpStringChars(final String prefix, final String s) { - final int len = s.length(); - for(int i=0; i4*4 */ + Assert.assertEquals(0, model.getVariaInt32PointerVariaLenElemCount()); + Assert.assertEquals(true, model.isVariaInt32PointerVariaLenNull()); { - model.setMat4x4(0*4, new float[] { 11, 12, 13, 14 } ); - model.setMat4x4(1*4, new float[] { 21, 22, 23, 24 } ); - model.setMat4x4(2*4, new float[] { 31, 32, 33, 34 } ); - model.setMat4x4(3*4, new float[] { 41, 42, 43, 44 } ); - - Assert.assertEquals(4*4, TK_ModelMutable.getMat4x4ArrayLength()); - final FloatBuffer mat4x4 = model.getMat4x4(); - Assert.assertEquals(4*4, mat4x4.limit()); - for(int i=0; i<4; i++) { - final float[] vec4 = model.getMat4x4(i*4, new float[4]); - for(int j=0; j<4; j++) { - Assert.assertEquals((i+1)*10+(j+1), mat4x4.get(i*4+j), EPSILON); - Assert.assertEquals((i+1)*10+(j+1), vec4[j], EPSILON); - } - } + Exception e1 = null; + try { + @SuppressWarnings("unused") + final IntBuffer ib = model.getVariaInt32PointerVariaLen(); // NULL -> exception + } catch(final Exception _e) { e1 = _e; } + Assert.assertNotNull(e1); + System.err.println("Expected exception-1: "+e1); + + Exception e2 = null; + try { + @SuppressWarnings("unused") + final int[] ia = model.getVariaInt32PointerVariaLen(0, new int[0], 0, 0); // NULL -> exception + } catch(final Exception _e) { e2 = _e; } + Assert.assertNotNull(e2); + System.err.println("Expected exception-2: "+e2); } - - // field: structArrayFixedLen - // field: CType['TK_Dimension *', size [fixed false, lnx64 48], [array*1]], with array length of 3 { - final int size = TK_ModelMutable.getStructArrayFixedLenArrayLength(); + // write 1 via int[] set, also actually allocating initial memory + { + final int[] ia = { 220, 221, 222, 223, 224 }; + model.setVariaInt32PointerVariaLen(ia, 0, 0, ia.length); + } + // verify 1 { + final int size = model.getVariaInt32PointerVariaLenElemCount(); + Assert.assertEquals(5, size); + final int[] all = model.getVariaInt32PointerVariaLen(0, new int[size], 0, size); + final IntBuffer allB = model.getVariaInt32PointerVariaLen(); + Assert.assertEquals(size, all.length); + Assert.assertEquals(size, allB.limit()); for(int i=0; i identical! { - final TK_Dimension d = model.getStructPointerOneElem(); - d.setX(1); - d.setY(2); - d.setWidth(3); - d.setHeight(4); + final TK_Field model1 = TK_Field.derefPointer(addr0); + final ByteBuffer bb1 = model1.getBuffer(); + Assert.assertNotNull(bb1); + Assert.assertEquals(TK_Field.size(), bb1.limit()); + + final long addr1 = model1.getDirectBufferAddress(); + Assert.assertNotEquals(0, addr1); } - { - final TK_Dimension one = model.getStructPointerOneElem(); - Assert.assertEquals(1, one.getX()); - Assert.assertEquals(2, one.getY()); - Assert.assertEquals(3, one.getWidth()); - Assert.assertEquals(4, one.getHeight()); + } + + chapter12_03aTestTKFieldConstValueInt32ReadAccess(model0); + chapter12_03bTestTKFieldConstValueInt32WriteAccess(model0); + chapter12_04aTestTKFieldVariaValueInt32ReadAccess(model0); + chapter12_04bTestTKFieldVariaValueInt32WriteAccess(model0); + chapter12_05aTestTKFieldStruct(model0); + chapter12_10aTestTKFieldConstStringReadAccess(model0); + chapter12_11aTestTKFieldConstStringOnlyReadAccess(model0); + chapter12_11bTestTKFieldConstStringOnlyWriteAccess(model0); + + binding.destroyTKField(model0); + } + @SuppressWarnings("unused") + private void dumpStringChars(final String prefix, final String s) { + final int len = s.length(); + for(int i=0; iconstIntxxArrayConstOneElem[0] = 88; + s->constIntxxArrayConstLen[0] = 1; + s->constIntxxArrayConstLen[1] = 2; + s->constIntxxArrayConstLen[2] = 3; + s->constIntxxPointerConstOneElem = calloc(1, sizeof(int)); + s->constIntxxPointerConstOneElem[0] = 10; + s->constIntxxPointerMaxOneElem = NULL; + s->constIntxxPointerConstLen = calloc(3, sizeof(int)); + s->constIntxxPointerConstLen[0] = 21; + s->constIntxxPointerConstLen[1] = 22; + s->constIntxxPointerConstLen[2] = 23; + s->constIntxxPointerVariaLen = NULL; + s->constIntxxPointerCustomLen = calloc(4, sizeof(int)); + s->constIntxxPointerCustomLen[0] = 31; + s->constIntxxPointerCustomLen[1] = 32; + s->constIntxxPointerCustomLen[2] = 33; + s->constIntxxPointerCustomLen[3] = 34; + s->constIntxxPointerCustomLenElemCount = 4; + + // Primitive.VariaValue.intxx 2A + 5P = 7 + s->variaIntxxArrayConstOneElem[0] = 88; + s->variaIntxxArrayConstLen[0] = 1; + s->variaIntxxArrayConstLen[1] = 2; + s->variaIntxxArrayConstLen[2] = 3; + s->variaIntxxPointerConstOneElem = calloc(1, sizeof(int)); + s->variaIntxxPointerConstOneElem[0] = 10; + s->variaIntxxPointerMaxOneElem = NULL; + s->variaIntxxPointerConstLen = calloc(3, sizeof(int)); + s->variaIntxxPointerConstLen[0] = 21; + s->variaIntxxPointerConstLen[1] = 22; + s->variaIntxxPointerConstLen[2] = 23; + s->variaIntxxPointerVariaLen = NULL; + s->variaIntxxPointerCustomLen = calloc(4, sizeof(int)); + s->variaIntxxPointerCustomLen[0] = 31; + s->variaIntxxPointerCustomLen[1] = 32; + s->variaIntxxPointerCustomLen[2] = 33; + s->variaIntxxPointerCustomLen[3] = 34; + s->variaIntxxPointerCustomLenElemCount = 4; + + // Primitive.ConstValue.int32 2A + 5P = 7 + s->constInt32ArrayConstOneElem[0] = 88; + s->constInt32ArrayConstLen[0] = 1; + s->constInt32ArrayConstLen[1] = 2; + s->constInt32ArrayConstLen[2] = 3; + s->constInt32PointerConstOneElem = calloc(1, sizeof(int32_t)); + s->constInt32PointerConstOneElem[0] = 10; + s->constInt32PointerMaxOneElem = NULL; + s->constInt32PointerConstLen = calloc(3, sizeof(int32_t)); + s->constInt32PointerConstLen[0] = 21; + s->constInt32PointerConstLen[1] = 22; + s->constInt32PointerConstLen[2] = 23; + s->constInt32PointerVariaLen = NULL; + s->constInt32PointerCustomLen = calloc(4, sizeof(int32_t)); + s->constInt32PointerCustomLen[0] = 31; + s->constInt32PointerCustomLen[1] = 32; + s->constInt32PointerCustomLen[2] = 33; + s->constInt32PointerCustomLen[3] = 34; + s->constInt32PointerCustomLenElemCount = 4; + + // Primitive.VariaValue.int32 2A + 5P = 7 + s->variaInt32ArrayConstOneElem[0] = 88; + s->variaInt32ArrayConstLen[0] = 1; + s->variaInt32ArrayConstLen[1] = 2; + s->variaInt32ArrayConstLen[2] = 3; + s->variaInt32PointerConstOneElem = calloc(1, sizeof(int32_t)); + s->variaInt32PointerConstOneElem[0] = 10; + s->variaInt32PointerMaxOneElem = NULL; + s->variaInt32PointerConstLen = calloc(3, sizeof(int32_t)); + s->variaInt32PointerConstLen[0] = 21; + s->variaInt32PointerConstLen[1] = 22; + s->variaInt32PointerConstLen[2] = 23; + s->variaInt32PointerVariaLen = NULL; + s->variaInt32PointerCustomLen = calloc(4, sizeof(int32_t)); + s->variaInt32PointerCustomLen[0] = 31; + s->variaInt32PointerCustomLen[1] = 32; + s->variaInt32PointerCustomLen[2] = 33; + s->variaInt32PointerCustomLen[3] = 34; + s->variaInt32PointerCustomLenElemCount = 4; + + // Struct.ConstValue.TK_Dimension 2A + 5P = 7 + s->constStructArrayConstOneElem[0].x = 51; + s->constStructArrayConstOneElem[0].y = 52; + s->constStructArrayConstOneElem[0].width = 53; + s->constStructArrayConstOneElem[0].height = 54; + s->constStructArrayConstLen[0].x = 61; + s->constStructArrayConstLen[0].y = 62; + s->constStructArrayConstLen[0].width = 63; + s->constStructArrayConstLen[0].height = 64; + s->constStructArrayConstLen[1].x = 71; + s->constStructArrayConstLen[1].y = 72; + s->constStructArrayConstLen[1].width = 73; + s->constStructArrayConstLen[1].height = 74; + s->constStructArrayConstLen[2].x = 81; + s->constStructArrayConstLen[2].y = 82; + s->constStructArrayConstLen[2].width = 83; + s->constStructArrayConstLen[2].height = 84; + s->constStructPointerConstOneElem = calloc(1, sizeof(TK_Dimension)); + s->constStructPointerConstOneElem[0].x = 91; + s->constStructPointerConstOneElem[0].y = 92; + s->constStructPointerConstOneElem[0].width = 93; + s->constStructPointerConstOneElem[0].height = 94; + s->constStructPointerMaxOneElem = NULL; + s->constStructPointerConstLen = calloc(3, sizeof(TK_Dimension)); + s->constStructPointerConstLen[0].x = 101; + s->constStructPointerConstLen[0].y = 102; + s->constStructPointerConstLen[0].width = 103; + s->constStructPointerConstLen[0].height = 104; + s->constStructPointerConstLen[1].x = 111; + s->constStructPointerConstLen[1].y = 112; + s->constStructPointerConstLen[1].width = 113; + s->constStructPointerConstLen[1].height = 114; + s->constStructPointerConstLen[2].x = 121; + s->constStructPointerConstLen[2].y = 123; + s->constStructPointerConstLen[2].width = 124; + s->constStructPointerConstLen[2].height = 125; + s->constStructPointerVariaLen = NULL; + s->constStructPointerCustomLen = calloc(4, sizeof(TK_Dimension)); + s->constStructPointerCustomLen[0].x = 131; + s->constStructPointerCustomLen[0].y = 132; + s->constStructPointerCustomLen[0].width = 133; + s->constStructPointerCustomLen[0].height = 134; + s->constStructPointerCustomLen[1].x = 141; + s->constStructPointerCustomLen[1].y = 142; + s->constStructPointerCustomLen[1].width = 143; + s->constStructPointerCustomLen[1].height = 144; + s->constStructPointerCustomLen[2].x = 151; + s->constStructPointerCustomLen[2].y = 152; + s->constStructPointerCustomLen[2].width = 153; + s->constStructPointerCustomLen[2].height = 154; + s->constStructPointerCustomLen[3].x = 161; + s->constStructPointerCustomLen[3].y = 162; + s->constStructPointerCustomLen[3].width = 163; + s->constStructPointerCustomLen[3].height = 164; + s->constStructPointerCustomLenElemCount = 4; + + // Struct.VariaValue.TK_Dimension 2A + 5P = 7 + s->variaStructArrayConstOneElem[0].x = 51; + s->variaStructArrayConstOneElem[0].y = 52; + s->variaStructArrayConstOneElem[0].width = 53; + s->variaStructArrayConstOneElem[0].height = 54; + s->variaStructArrayConstLen[0].x = 61; + s->variaStructArrayConstLen[0].y = 62; + s->variaStructArrayConstLen[0].width = 63; + s->variaStructArrayConstLen[0].height = 64; + s->variaStructArrayConstLen[1].x = 71; + s->variaStructArrayConstLen[1].y = 72; + s->variaStructArrayConstLen[1].width = 73; + s->variaStructArrayConstLen[1].height = 74; + s->variaStructArrayConstLen[2].x = 81; + s->variaStructArrayConstLen[2].y = 82; + s->variaStructArrayConstLen[2].width = 83; + s->variaStructArrayConstLen[2].height = 84; + s->variaStructPointerConstOneElem = calloc(1, sizeof(TK_Dimension)); + s->variaStructPointerConstOneElem[0].x = 91; + s->variaStructPointerConstOneElem[0].y = 92; + s->variaStructPointerConstOneElem[0].width = 93; + s->variaStructPointerConstOneElem[0].height = 94; + s->variaStructPointerMaxOneElem = NULL; + s->variaStructPointerConstLen = calloc(3, sizeof(TK_Dimension)); + s->variaStructPointerConstLen[0].x = 101; + s->variaStructPointerConstLen[0].y = 102; + s->variaStructPointerConstLen[0].width = 103; + s->variaStructPointerConstLen[0].height = 104; + s->variaStructPointerConstLen[1].x = 111; + s->variaStructPointerConstLen[1].y = 112; + s->variaStructPointerConstLen[1].width = 113; + s->variaStructPointerConstLen[1].height = 114; + s->variaStructPointerConstLen[2].x = 121; + s->variaStructPointerConstLen[2].y = 123; + s->variaStructPointerConstLen[2].width = 124; + s->variaStructPointerConstLen[2].height = 125; + s->variaStructPointerVariaLen = NULL; + s->variaStructPointerCustomLen = calloc(4, sizeof(TK_Dimension)); + s->variaStructPointerCustomLen[0].x = 131; + s->variaStructPointerCustomLen[0].y = 132; + s->variaStructPointerCustomLen[0].width = 133; + s->variaStructPointerCustomLen[0].height = 134; + s->variaStructPointerCustomLen[1].x = 141; + s->variaStructPointerCustomLen[1].y = 142; + s->variaStructPointerCustomLen[1].width = 143; + s->variaStructPointerCustomLen[1].height = 144; + s->variaStructPointerCustomLen[2].x = 151; + s->variaStructPointerCustomLen[2].y = 152; + s->variaStructPointerCustomLen[2].width = 153; + s->variaStructPointerCustomLen[2].height = 154; + s->variaStructPointerCustomLen[3].x = 161; + s->variaStructPointerCustomLen[3].y = 162; + s->variaStructPointerCustomLen[3].width = 163; + s->variaStructPointerCustomLen[3].height = 164; + s->variaStructPointerCustomLenElemCount = 4; + + // String.ConstValue 1A + 3P = 4 + strncpy(s->constCharArrayConstLen, "Hello Array1", sizeof(s->constCharArrayConstLen)); + s->constCharPointerConstLen = calloc(14+1, sizeof(char)); + strncpy(s->constCharPointerConstLen, "Hello CString1", 14+1); + s->constCharPointerVariaLen = NULL; + s->constCharPointerCustomLen = calloc(14+1, sizeof(char)); + strncpy(s->constCharPointerCustomLen, "Hello CString3", 14+1); + s->constCharPointerCustomLenElemCount = 14+1; + + // String.VariaValue 1A + 3P = 4 + strncpy(s->variaCharArrayConstLen, "Hello Array1", sizeof(s->variaCharArrayConstLen)); + s->variaCharPointerConstLen = calloc(14+1, sizeof(char)); + strncpy(s->variaCharPointerConstLen, "Hello CString1", 14+1); + s->variaCharPointerVariaLen = NULL; + s->variaCharPointerCustomLen = calloc(14+1, sizeof(char)); + strncpy(s->variaCharPointerCustomLen, "Hello CString3", 14+1); + s->variaCharPointerCustomLenElemCount = 14+1; + + // StringOnly.ConstValue 1A + 3P = 4 + strncpy(s->constStringOnlyArrayConstLen, "Hello Array1", sizeof(s->constStringOnlyArrayConstLen)); + s->constStringOnlyPointerConstLen = calloc(14+1, sizeof(char)); + strncpy(s->constStringOnlyPointerConstLen, "Hello CString1", 14+1); + s->constStringOnlyPointerVariaLen = NULL; + s->constStringOnlyPointerCustomLen = calloc(14+1, sizeof(char)); + strncpy(s->constStringOnlyPointerCustomLen, "Hello CString3", 14+1); + s->constStringOnlyPointerCustomLenElemCount = 14+1; + + // StringOnly.VariaValue 1A + 3P = 4 + strncpy(s->variaStringOnlyArrayConstLen, "Hello Array1", sizeof(s->variaStringOnlyArrayConstLen)); + s->variaStringOnlyPointerConstLen = calloc(14+1, sizeof(char)); + strncpy(s->variaStringOnlyPointerConstLen, "Hello CString1", 14+1); + s->variaStringOnlyPointerVariaLen = NULL; + s->variaStringOnlyPointerCustomLen = calloc(14+1, sizeof(char)); + strncpy(s->variaStringOnlyPointerCustomLen, "Hello CString3", 14+1); + s->variaStringOnlyPointerCustomLenElemCount = 14+1; - s->intxxArrayFixedLen[0]=1; - s->intxxArrayFixedLen[1]=2; - s->intxxArrayFixedLen[2]=3; - - s->intxxPointerCustomLen = calloc(3, sizeof(int)); - s->intxxPointerCustomLen[0] = 11; - s->intxxPointerCustomLen[1] = 12; - s->intxxPointerCustomLen[2] = 13; - s->intxxPointerCustomLenVal=3; + return s; +} - s->int32ArrayFixedLen[0] = 21; - s->int32ArrayFixedLen[1] = 22; - s->int32ArrayFixedLen[2] = 23; +static void destroyTKFieldMutable(TK_FieldMutable * s) { + assert(NULL!=s); - s->int32ArrayOneElem[0] = 30; + assert(NULL!=s->constIntxxPointerConstOneElem); + free(s->constIntxxPointerConstOneElem); + assert(NULL!=s->constIntxxPointerConstLen); + free(s->constIntxxPointerConstLen); + if( 0 < s->constIntxxPointerCustomLenElemCount && NULL!=s->constIntxxPointerCustomLen ) { + // NOTE Ownership is ambiguous + free(s->constIntxxPointerCustomLen); + } - s->int32PointerCustomLen = calloc(3, sizeof(int)); - s->int32PointerCustomLen[0] = 31; - s->int32PointerCustomLen[1] = 32; - s->int32PointerCustomLen[2] = 33; - s->int32PointerCustomLenVal=3; - - s->int32PointerOneElem = calloc(1, sizeof(int)); - s->int32PointerOneElem[0] = 41; + assert(NULL!=s->constInt32PointerConstOneElem); + free(s->constInt32PointerConstOneElem); + assert(NULL!=s->constInt32PointerConstLen); + free(s->constInt32PointerConstLen); + if( 0 < s->constInt32PointerCustomLenElemCount && NULL!=s->constInt32PointerCustomLen ) { + // NOTE Ownership is ambiguous + free(s->constInt32PointerCustomLen); + } + + assert(NULL!=s->constStructPointerConstOneElem); + free(s->constStructPointerConstOneElem); + assert(NULL!=s->constStructPointerConstLen); + free(s->constStructPointerConstLen); + if( 0 < s->constStructPointerCustomLenElemCount && NULL!=s->constStructPointerCustomLen ) { + // NOTE Ownership is ambiguous + free(s->constStructPointerCustomLen); + } + + assert(NULL!=s->constCharPointerConstLen); + free(s->constCharPointerConstLen); + if( 0 < s->constCharPointerCustomLenElemCount && NULL!=s->constCharPointerCustomLen ) { + // NOTE Ownership is ambiguous + free(s->constCharPointerCustomLen); + } - for(i=0; i<4; i++) { - for(j=0; j<4; j++) { - s->mat4x4[i][j] = i*4 + j; - } + assert(NULL!=s->constStringOnlyPointerConstLen); + free(s->constStringOnlyPointerConstLen); + if( 0 < s->constStringOnlyPointerCustomLenElemCount && NULL!=s->constStringOnlyPointerCustomLen ) { + // NOTE Ownership is ambiguous + free(s->constStringOnlyPointerCustomLen); } - s->structArrayFixedLen[0].x = 51; - s->structArrayFixedLen[0].y = 52; - s->structArrayFixedLen[0].width = 53; - s->structArrayFixedLen[0].height = 54; - s->structArrayFixedLen[1].x = 61; - s->structArrayFixedLen[1].y = 62; - s->structArrayFixedLen[1].width = 63; - s->structArrayFixedLen[1].height = 64; - s->structArrayFixedLen[2].x = 71; - s->structArrayFixedLen[2].y = 72; - s->structArrayFixedLen[2].width = 73; - s->structArrayFixedLen[2].height = 74; - - s->structArrayOneElem[0].x = 81; - s->structArrayOneElem[0].y = 82; - s->structArrayOneElem[0].width = 83; - s->structArrayOneElem[0].height = 84; - - s->structPointerCustomLen = (TK_Dimension *) calloc(3, sizeof(TK_Dimension)); - s->structPointerCustomLen[0].x = 91; - s->structPointerCustomLen[0].y = 92; - s->structPointerCustomLen[0].width = 93; - s->structPointerCustomLen[0].height = 94; - s->structPointerCustomLen[1].x = 101; - s->structPointerCustomLen[1].y = 102; - s->structPointerCustomLen[1].width = 103; - s->structPointerCustomLen[1].height = 104; - s->structPointerCustomLen[2].x = 111; - s->structPointerCustomLen[2].y = 112; - s->structPointerCustomLen[2].width = 113; - s->structPointerCustomLen[2].height = 114; - s->structPointerCustomLenVal = 3; - - s->structPointerOneElem = (TK_Dimension *) calloc(1, sizeof(TK_Dimension)); - s->structPointerOneElem[0].x = 121; - s->structPointerOneElem[0].y = 122; - s->structPointerOneElem[0].width = 123; - s->structPointerOneElem[0].height = 124; + free(s); +} - s->ctx = (void *) 0x123456789abcdef0UL; +MYAPI TK_FieldImmutable * MYAPIENTRY createTKFieldImmutable() { + return (TK_FieldImmutable*) createTKFieldMutable(); +} +MYAPI void MYAPIENTRY destroyTKFieldImmutable(TK_FieldImmutable * s) { + destroyTKFieldMutable((TK_FieldMutable*) s); +} - strncpy(s->modelNameArrayFixedLen, "Hello Array", sizeof(s->modelNameArrayFixedLen)); +MYAPI TK_StructImmutable * MYAPIENTRY createTKStructImmutable() { + return (TK_StructImmutable*) createTKFieldMutable(); +} +MYAPI void MYAPIENTRY destroyTKStructImmutable(TK_StructImmutable * s) { + destroyTKFieldMutable((TK_FieldMutable*) s); +} - s->modelNamePointerCString = calloc(13+1, sizeof(char)); - strncpy(s->modelNamePointerCString, "Hello CString", 13+1); +MYAPI TK_Field * MYAPIENTRY createTKField() { + return (TK_Field*) createTKFieldMutable(); +} +MYAPI void MYAPIENTRY destroyTKField(TK_Field * s) { + destroyTKFieldMutable((TK_FieldMutable*) s); +} - s->modelNamePointerCustomLen = calloc(13+1, sizeof(char)); - strncpy(s->modelNamePointerCustomLen, "Hello Pointer", 13+1); - s->modelNamePointerCustomLenVal = 13+1; +MYAPI TK_ModelMixed* MYAPIENTRY createTKModelMixed() { + int i, j; + TK_ModelMixed * s = calloc(1, sizeof(TK_ModelMixed)); + for(i=0; i<4; i++) { + for(j=0; j<4; j++) { + s->mat4x4[i][j] = i*4 + j; + } + } + s->ctx = (void *) 0x123456789abcdef0UL; return s; } -MYAPI void MYAPIENTRY destroyModelMutable(TK_ModelMutable * s) { +MYAPI void MYAPIENTRY destroyTKModelMixed(TK_ModelMixed * s) { assert(NULL!=s); - assert(NULL!=s->intxxPointerCustomLen); - assert(NULL!=s->int32PointerCustomLen); - assert(NULL!=s->int32PointerOneElem); - assert(NULL!=s->structPointerCustomLen); - free(s->intxxPointerCustomLen); - free(s->int32PointerCustomLen); - free(s->int32PointerOneElem); - free(s->structPointerCustomLen); - free(s->modelNamePointerCString); - free(s->modelNamePointerCustomLen); free(s); } -MYAPI TK_ModelConst * MYAPIENTRY createModelConst() { - return (TK_ModelConst *)createModelMutable(); -} -MYAPI void MYAPIENTRY destroyModelConst(TK_ModelConst * s) { - destroyModelMutable((TK_ModelMutable *)s); -} diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h index 9465cd9..89848d7 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h @@ -437,71 +437,320 @@ MYAPI void MYAPIENTRY intToRgba(int irgba, char rgbaSink[4]); MYAPI void MYAPIENTRY addInt(const int summands[2], int result[1]); MYAPI void MYAPIENTRY addByte(const char summands[2], char result[1]); -typedef struct { - const int intxxArrayFixedLen[3]; - - const int * intxxPointerCustomLen; - const int intxxPointerCustomLenVal; - - const int32_t int32ArrayFixedLen[3]; - const int32_t int32ArrayOneElem[1]; - - const int32_t * int32PointerCustomLen; - const int32_t int32PointerCustomLenVal; - - const int32_t * int32PointerOneElem; - - const float mat4x4[4][4]; +// +// TK_FieldImmutable +// - const TK_Dimension structArrayFixedLen[3]; - const TK_Dimension structArrayOneElem[1]; - - const TK_Dimension * structPointerCustomLen; - const int32_t structPointerCustomLenVal; - const TK_Dimension * structPointerOneElem; +typedef struct { + // Primitive.ConstValue.intxx 2A + 5P = 7 + const int constIntxxArrayConstOneElem[1]; + const int constIntxxArrayConstLen[3]; // [3] + const int* constIntxxPointerConstOneElem; // [1] + const int* constIntxxPointerMaxOneElem; // null + const int* constIntxxPointerConstLen; // [3] + const int* constIntxxPointerVariaLen; // null + const int* constIntxxPointerCustomLen; // [4] + int constIntxxPointerCustomLenElemCount; + + // Primitive.VariaValue.intxx 2A + 5P = 7 + int variaIntxxArrayConstOneElem[1]; + int variaIntxxArrayConstLen[3]; // [3] + int* variaIntxxPointerConstOneElem; // [1] + int* variaIntxxPointerMaxOneElem; // null + int* variaIntxxPointerConstLen; // [3] + int* variaIntxxPointerVariaLen; // null + int* variaIntxxPointerCustomLen; // [4] + int variaIntxxPointerCustomLenElemCount; + + const int32_t constInt32Element; + int32_t variaInt32Element; + + // Primitive.ConstValue.int32 2A + 5P = 7 + const int32_t constInt32ArrayConstOneElem[1]; + const int32_t constInt32ArrayConstLen[3]; + const int32_t* constInt32PointerConstOneElem; + const int32_t* constInt32PointerMaxOneElem; + const int32_t* constInt32PointerConstLen; + const int32_t* constInt32PointerVariaLen; + const int32_t* constInt32PointerCustomLen; + int32_t constInt32PointerCustomLenElemCount; + + // Primitive.VariaValue.int32 2A + 5P = 7 + int32_t variaInt32ArrayConstOneElem[1]; + int32_t variaInt32ArrayConstLen[3]; + int32_t* variaInt32PointerConstOneElem; + int32_t* variaInt32PointerMaxOneElem; + int32_t* variaInt32PointerConstLen; + int32_t* variaInt32PointerVariaLen; + int32_t* variaInt32PointerCustomLen; + int32_t variaInt32PointerCustomLenElemCount; + + // Struct.ConstValue.TK_Dimension 2A + 5P = 7 + const TK_Dimension constStructArrayConstOneElem[1]; + const TK_Dimension constStructArrayConstLen[3]; + const TK_Dimension* constStructPointerConstOneElem; + const TK_Dimension* constStructPointerMaxOneElem; + const TK_Dimension* constStructPointerConstLen; + const TK_Dimension* constStructPointerVariaLen; + const TK_Dimension* constStructPointerCustomLen; + int32_t constStructPointerCustomLenElemCount; + + // Struct.VariaValue 2A + 5P = 7 + TK_Dimension variaStructArrayConstOneElem[1]; + TK_Dimension variaStructArrayConstLen[3]; + TK_Dimension* variaStructPointerConstOneElem; + TK_Dimension* variaStructPointerMaxOneElem; + TK_Dimension* variaStructPointerConstLen; + TK_Dimension* variaStructPointerVariaLen; + TK_Dimension* variaStructPointerCustomLen; + int32_t variaStructPointerCustomLenElemCount; + + // String.ConstValue 1A + 3P = 4 + const char constCharArrayConstLen[13]; /* 'Hello Array1' len=12+1 */ + const char* constCharPointerConstLen; /* 'Hello CString1' len=14+1 */ + const char* constCharPointerVariaLen; // null + const char* constCharPointerCustomLen; /* 'Hello CString3' len=14+1 */ + int constCharPointerCustomLenElemCount; + + // String.VariaValue 1A + 3P = 4 + char variaCharArrayConstLen[13]; /* 'Hello Array1' len=12+1 */ + char* variaCharPointerConstLen; /* 'Hello CString1' len=14+1 */ + char* variaCharPointerVariaLen; /* 'Hello CString2' len=14+1 */ + char* variaCharPointerCustomLen; /* 'Hello CString3' len=14+1 */ + int variaCharPointerCustomLenElemCount; + + // StringOnly.ConstValue 1A + 3P = 4 + const char constStringOnlyArrayConstLen[13]; /* 'Hello Array1' len=12+1 */ + const char* constStringOnlyPointerConstLen; /* 'Hello CString1' len=14+1 */ + const char* constStringOnlyPointerVariaLen; /* 'Hello CString2' len=14+1 */ + const char* constStringOnlyPointerCustomLen; /* 'Hello CString3' len=14+1 */ + int constStringOnlyPointerCustomLenElemCount; + + // StringOnly.VariaValue 1A + 3P = 4 + char variaStringOnlyArrayConstLen[13]; /* 'Hello Array1' len=12+1 */ + char* variaStringOnlyPointerConstLen; /* 'Hello CString1' len=14+1 */ + char* variaStringOnlyPointerVariaLen; /* 'Hello CString2' len=14+1 */ + char* variaStringOnlyPointerCustomLen; /* 'Hello CString3' len=14+1 */ + int variaStringOnlyPointerCustomLenElemCount; + +} TK_FieldImmutable; + +MYAPI TK_FieldImmutable * MYAPIENTRY createTKFieldImmutable(); +MYAPI void MYAPIENTRY destroyTKFieldImmutable(TK_FieldImmutable * s); - TK_Context ctx; +// +// TK_StructImmutable +// - char modelNameArrayFixedLen[12]; /* 'Hello Array' len=11+1 */ - char * modelNamePointerCString; /* 'Hello CString' len=13+1 */ - const char * modelNamePointerCustomLen; /* 'Hello Pointer' len=13+1 */ - const int modelNamePointerCustomLenVal; /* 13+1 */ +typedef struct { + // Primitive.ConstValue.intxx 2A + 5P = 7 + const int constIntxxArrayConstOneElem[1]; + const int constIntxxArrayConstLen[3]; // [3] + const int* constIntxxPointerConstOneElem; // + const int* constIntxxPointerMaxOneElem; // + const int* constIntxxPointerConstLen; // [3] + const int* constIntxxPointerVariaLen; + const int* constIntxxPointerCustomLen; + int constIntxxPointerCustomLenElemCount; + + // Primitive.VariaValue.intxx 2A + 5P = 7 + int variaIntxxArrayConstOneElem[1]; + int variaIntxxArrayConstLen[3]; // [3] + int* variaIntxxPointerConstOneElem; // + int* variaIntxxPointerMaxOneElem; // + int* variaIntxxPointerConstLen; // [3] + int* variaIntxxPointerVariaLen; + int* variaIntxxPointerCustomLen; + int variaIntxxPointerCustomLenElemCount; + + const int32_t constInt32Element; + int32_t variaInt32Element; + + // Primitive.ConstValue 2A + 5P = 7 + const int32_t constInt32ArrayConstOneElem[1]; + const int32_t constInt32ArrayConstLen[3]; + const int32_t* constInt32PointerConstOneElem; + const int32_t* constInt32PointerMaxOneElem; + const int32_t* constInt32PointerConstLen; + const int32_t* constInt32PointerVariaLen; + const int32_t* constInt32PointerCustomLen; + int32_t constInt32PointerCustomLenElemCount; + + // Primitive.VariaValue 2A + 5P = 7 + int32_t variaInt32ArrayConstOneElem[1]; + int32_t variaInt32ArrayConstLen[3]; + int32_t* variaInt32PointerConstOneElem; + int32_t* variaInt32PointerMaxOneElem; + int32_t* variaInt32PointerConstLen; + int32_t* variaInt32PointerVariaLen; + int32_t* variaInt32PointerCustomLen; + int32_t variaInt32PointerCustomLenElemCount; + + // Struct.ConstValue 2A + 5P = 7 + const TK_Dimension constStructArrayConstOneElem[1]; + const TK_Dimension constStructArrayConstLen[3]; + const TK_Dimension* constStructPointerConstOneElem; + const TK_Dimension* constStructPointerMaxOneElem; + const TK_Dimension* constStructPointerConstLen; + const TK_Dimension* constStructPointerVariaLen; + const TK_Dimension* constStructPointerCustomLen; + int32_t constStructPointerCustomLenElemCount; + + // Struct.VariaValue 2A + 5P = 7 + TK_Dimension variaStructArrayConstOneElem[1]; + TK_Dimension variaStructArrayConstLen[3]; + TK_Dimension* variaStructPointerConstOneElem; + TK_Dimension* variaStructPointerMaxOneElem; + TK_Dimension* variaStructPointerConstLen; + TK_Dimension* variaStructPointerVariaLen; + TK_Dimension* variaStructPointerCustomLen; + int32_t variaStructPointerCustomLenElemCount; + + // String.ConstValue 1A + 3P = 4 + const char constCharArrayConstLen[13]; /* 'Hello Array1' len=12+1 */ + const char* constCharPointerConstLen; /* 'Hello CString1' len=14+1 */ + const char* constCharPointerVariaLen; /* 'Hello CString2' len=14+1 */ + const char* constCharPointerCustomLen; /* 'Hello CString3' len=14+1 */ + int constCharPointerCustomLenElemCount; + + // String.VariaValue 1A + 3P = 4 + char variaCharArrayConstLen[13]; /* 'Hello Array1' len=12+1 */ + char* variaCharPointerConstLen; /* 'Hello CString1' len=14+1 */ + char* variaCharPointerVariaLen; /* 'Hello CString2' len=14+1 */ + char* variaCharPointerCustomLen; /* 'Hello CString3' len=14+1 */ + int variaCharPointerCustomLenElemCount; + + // StringOnly.ConstValue 1A + 3P = 4 + const char constStringOnlyArrayConstLen[13]; /* 'Hello Array1' len=12+1 */ + const char* constStringOnlyPointerConstLen; /* 'Hello CString1' len=14+1 */ + const char* constStringOnlyPointerVariaLen; /* 'Hello CString2' len=14+1 */ + const char* constStringOnlyPointerCustomLen; /* 'Hello CString3' len=14+1 */ + int constStringOnlyPointerCustomLenElemCount; + + // StringOnly.VariaValue 1A + 3P = 4 + char variaStringOnlyArrayConstLen[13]; /* 'Hello Array1' len=12+1 */ + char* variaStringOnlyPointerConstLen; /* 'Hello CString1' len=14+1 */ + char* variaStringOnlyPointerVariaLen; /* 'Hello CString2' len=14+1 */ + char* variaStringOnlyPointerCustomLen; /* 'Hello CString3' len=14+1 */ + int variaStringOnlyPointerCustomLenElemCount; + +} TK_StructImmutable; + +MYAPI TK_StructImmutable * MYAPIENTRY createTKStructImmutable(); +MYAPI void MYAPIENTRY destroyTKStructImmutable(TK_StructImmutable * s); -} TK_ModelConst; +// +// TK_Field +// typedef struct { - int intxxArrayFixedLen[3]; - - int * intxxPointerCustomLen; - int intxxPointerCustomLenVal; + // Primitive.ConstValue.intxx 2A + 5P = 7 + const int constIntxxArrayConstOneElem[1]; + const int constIntxxArrayConstLen[3]; // [3] + const int* constIntxxPointerConstOneElem; // + const int* constIntxxPointerMaxOneElem; // + const int* constIntxxPointerConstLen; // [3] + const int* constIntxxPointerVariaLen; + const int* constIntxxPointerCustomLen; + int constIntxxPointerCustomLenElemCount; + + // Primitive.VariaValue.intxx 2A + 5P = 7 + int variaIntxxArrayConstOneElem[1]; + int variaIntxxArrayConstLen[3]; // [3] + int* variaIntxxPointerConstOneElem; // + int* variaIntxxPointerMaxOneElem; // + int* variaIntxxPointerConstLen; // [3] + int* variaIntxxPointerVariaLen; + int* variaIntxxPointerCustomLen; + int variaIntxxPointerCustomLenElemCount; + + const int32_t constInt32Element; + int32_t variaInt32Element; + + // Primitive.ConstValue 2A + 5P = 7 + const int32_t constInt32ArrayConstOneElem[1]; + const int32_t constInt32ArrayConstLen[3]; + const int32_t* constInt32PointerConstOneElem; + const int32_t* constInt32PointerMaxOneElem; + const int32_t* constInt32PointerConstLen; + const int32_t* constInt32PointerVariaLen; + const int32_t* constInt32PointerCustomLen; + int32_t constInt32PointerCustomLenElemCount; + + // Primitive.VariaValue 2A + 5P = 7 + int32_t variaInt32ArrayConstOneElem[1]; + int32_t variaInt32ArrayConstLen[3]; + int32_t* variaInt32PointerConstOneElem; + int32_t* variaInt32PointerMaxOneElem; + int32_t* variaInt32PointerConstLen; + int32_t* variaInt32PointerVariaLen; + int32_t* variaInt32PointerCustomLen; + int32_t variaInt32PointerCustomLenElemCount; + + // Struct.ConstValue 2A + 5P = 7 + const TK_Dimension constStructArrayConstOneElem[1]; + const TK_Dimension constStructArrayConstLen[3]; + const TK_Dimension* constStructPointerConstOneElem; + const TK_Dimension* constStructPointerMaxOneElem; + const TK_Dimension* constStructPointerConstLen; + const TK_Dimension* constStructPointerVariaLen; + const TK_Dimension* constStructPointerCustomLen; + int32_t constStructPointerCustomLenElemCount; + + // Struct.VariaValue 2A + 5P = 7 + TK_Dimension variaStructArrayConstOneElem[1]; + TK_Dimension variaStructArrayConstLen[3]; + TK_Dimension* variaStructPointerConstOneElem; + TK_Dimension* variaStructPointerMaxOneElem; + TK_Dimension* variaStructPointerConstLen; + TK_Dimension* variaStructPointerVariaLen; + TK_Dimension* variaStructPointerCustomLen; + int32_t variaStructPointerCustomLenElemCount; + + // String.ConstValue 1A + 3P = 4 + const char constCharArrayConstLen[13]; /* 'Hello Array1' len=12+1 */ + const char* constCharPointerConstLen; /* 'Hello CString1' len=14+1 */ + const char* constCharPointerVariaLen; /* 'Hello CString2' len=14+1 */ + const char* constCharPointerCustomLen; /* 'Hello CString3' len=14+1 */ + int constCharPointerCustomLenElemCount; + + // String.VariaValue 1A + 3P = 4 + char variaCharArrayConstLen[13]; /* 'Hello Array1' len=12+1 */ + char* variaCharPointerConstLen; /* 'Hello CString1' len=14+1 */ + char* variaCharPointerVariaLen; /* 'Hello CString2' len=14+1 */ + char* variaCharPointerCustomLen; /* 'Hello CString3' len=14+1 */ + int variaCharPointerCustomLenElemCount; + + // StringOnly.ConstValue 1A + 3P = 4 + const char constStringOnlyArrayConstLen[13]; /* 'Hello Array1' len=12+1 */ + const char* constStringOnlyPointerConstLen; /* 'Hello CString1' len=14+1 */ + const char* constStringOnlyPointerVariaLen; /* 'Hello CString2' len=14+1 */ + const char* constStringOnlyPointerCustomLen; /* 'Hello CString3' len=14+1 */ + int constStringOnlyPointerCustomLenElemCount; + + // StringOnly.VariaValue 1A + 3P = 4 + char variaStringOnlyArrayConstLen[13]; /* 'Hello Array1' len=12+1 */ + char* variaStringOnlyPointerConstLen; /* 'Hello CString1' len=14+1 */ + char* variaStringOnlyPointerVariaLen; /* 'Hello CString2' len=14+1 */ + char* variaStringOnlyPointerCustomLen; /* 'Hello CString3' len=14+1 */ + int variaStringOnlyPointerCustomLenElemCount; + +} TK_Field; + +MYAPI TK_Field * MYAPIENTRY createTKField(); +MYAPI void MYAPIENTRY destroyTKField(TK_Field * s); - int32_t int32ArrayFixedLen[3]; - int32_t int32ArrayOneElem[1]; - - int32_t * int32PointerCustomLen; - int32_t int32PointerCustomLenVal; - - int32_t * int32PointerOneElem; +// +// +// +typedef struct { float mat4x4[4][4]; - TK_Dimension structArrayFixedLen[3]; - TK_Dimension structArrayOneElem[1]; - - TK_Dimension * structPointerCustomLen; - int32_t structPointerCustomLenVal; - TK_Dimension * structPointerOneElem; - TK_Context ctx; - char modelNameArrayFixedLen[12]; /* 'Hello Array' len=11+1 */ - char * modelNamePointerCString; /* 'Hello CString' len=13+1 */ - char * modelNamePointerCustomLen; /* 'Hello Pointer' len=13+1 */ - int modelNamePointerCustomLenVal; /* 13+1 */ +} TK_ModelMixed; -} TK_ModelMutable; +MYAPI TK_ModelMixed* MYAPIENTRY createTKModelMixed(); +MYAPI void MYAPIENTRY destroyTKModelMixed(TK_ModelMixed* s); -MYAPI TK_ModelConst * MYAPIENTRY createModelConst(); -MYAPI void MYAPIENTRY destroyModelConst(TK_ModelConst * s); -MYAPI TK_ModelMutable * MYAPIENTRY createModelMutable(); -MYAPI void MYAPIENTRY destroyModelMutable(TK_ModelMutable * s); diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test2.c b/src/junit/com/jogamp/gluegen/test/junit/generation/test2.c new file mode 100644 index 0000000..3fff02c --- /dev/null +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test2.c @@ -0,0 +1,20 @@ +#include "test2.h" + +#include + +int Initialize(const T2_InitializeOptions* Options) { + fprintf(stderr, "T2 Initialize API 0x%X, product %s, version %s\n", + Options->ApiVersion, + Options->ProductName, + Options->ProductVersion); + fprintf(stderr, "- MemFuncs: alloc %p, realloc %p, release %p\n", + Options->AllocateMemoryFunction, + Options->ReallocateMemoryFunction, + Options->ReleaseMemoryFunction); + return 0; +} + +int Shutdown() { + return 0; +} + diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test2.cfg b/src/junit/com/jogamp/gluegen/test/junit/generation/test2.cfg new file mode 100644 index 0000000..3b68598 --- /dev/null +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test2.cfg @@ -0,0 +1,52 @@ +Package com.jogamp.gluegen.test.junit.generation +JavaClass BindingtestT2 +Style InterfaceAndImpl +JavaOutputDir classes +NativeOutputDir native + +# Use a ProcAddressTable so we dynamically look up the routines +EmitProcAddressTable true +ProcAddressTableClassName BindingtestT2ProcAddressTable +GetProcAddressTableExpr _table +ProcAddressNameExpr PFN $UPPERCASE({0}) PROC + +# Force all of the methods to be emitted using dynamic linking so we +# don't need to link against any emulation library on the desktop or +# depend on the presence of an import library for a particular device +ForceProcAddressGen __ALL__ + +# Also force the calling conventions of the locally generated function +# pointer typedefs for these routines to MYAPIENTRY +# LocalProcAddressCallingConvention __ALL__ MYAPIENTRY + +Opaque long T2_AllocateMemoryFunc +Opaque long T2_ReallocateMemoryFunc +Opaque long T2_ReleaseMemoryFunc + +EmitStruct T2_ThreadAffinity +StructPackage T2_ThreadAffinity com.jogamp.gluegen.test.junit.generation + +EmitStruct T2_InitializeOptions +StructPackage T2_InitializeOptions com.jogamp.gluegen.test.junit.generation +ReturnsStringOnly T2_InitializeOptions.ProductName +ReturnsStringOnly T2_InitializeOptions.ProductVersion +Opaque long T2_InitializeOptions.Reserved +ImmutableAccess long T2_InitializeOptions.Reserved +# ReturnedArrayLength T2_InitializeOptions.OverrideThreadAffinity 1 +MaxOneElement T2_InitializeOptions.OverrideThreadAffinity + +ReturnsOpaque long T2_InitializeOptions.AllocateMemoryFunction +ReturnsOpaque long T2_InitializeOptions.ReallocateMemoryFunc +ReturnsOpaque long T2_InitializeOptions.ReleaseMemoryFunc + +CustomCCode #include "test2.h" + +Import com.jogamp.gluegen.test.junit.generation.BindingtestT2 +Import com.jogamp.gluegen.test.junit.generation.T2_InitializeOptions +Import com.jogamp.gluegen.test.junit.generation.T2_ThreadAffinity + +CustomJavaCode BindingtestT2Impl private static BindingtestT2ProcAddressTable _table = new BindingtestT2ProcAddressTable(); +CustomJavaCode BindingtestT2Impl public static void resetProcAddressTable(DynamicLookupHelper lookup) { +CustomJavaCode BindingtestT2Impl _table.reset(lookup); +CustomJavaCode BindingtestT2Impl } + diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test2.h b/src/junit/com/jogamp/gluegen/test/junit/generation/test2.h new file mode 100644 index 0000000..e27e9aa --- /dev/null +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test2.h @@ -0,0 +1,37 @@ + +#include +#include + +typedef void* ( * T2_AllocateMemoryFunc)(size_t SizeInBytes, size_t Alignment); + +typedef void* ( * T2_ReallocateMemoryFunc)(void* Pointer, size_t SizeInBytes, size_t Alignment); + +typedef void ( * T2_ReleaseMemoryFunc)(void* Pointer); + +typedef struct { + int32_t ApiVersion; + uint64_t NetworkWork; + uint64_t StorageIo; + uint64_t WebSocketIo; + uint64_t P2PIo; + uint64_t HttpRequestIo; + uint64_t RTCIo; +} T2_ThreadAffinity; + +typedef struct { + int32_t ApiVersion; + T2_AllocateMemoryFunc AllocateMemoryFunction; + T2_ReallocateMemoryFunc ReallocateMemoryFunction; + T2_ReleaseMemoryFunc ReleaseMemoryFunction; + + const char* ProductName; + + const char* ProductVersion; + + void* Reserved; + + T2_ThreadAffinity* OverrideThreadAffinity; +} T2_InitializeOptions; + +extern int Initialize(const T2_InitializeOptions* Options); +extern int Shutdown(); -- cgit v1.2.3