summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/Implementation/native-size/NativeSizeAlignment-linux-x86_32.log101
-rw-r--r--doc/Implementation/native-size/NativeSizeAlignment-linux-x86_64.log99
-rw-r--r--doc/Implementation/native-size/NativeSizeAlignment-win32.log99
-rw-r--r--doc/Implementation/native-size/NativeSizeAlignment-win64.log97
-rwxr-xr-xmake/scripts/java-win32.bat16
-rwxr-xr-xmake/scripts/java-win64.bat17
-rwxr-xr-xmake/scripts/runtest-x32.bat4
-rwxr-xr-xmake/scripts/runtest-x64.bat4
-rw-r--r--src/java/com/jogamp/common/nio/StructAccessor.java65
-rw-r--r--src/java/com/jogamp/common/os/MachineDescription.java294
-rw-r--r--src/java/com/jogamp/common/os/Platform.java40
-rw-r--r--src/java/com/jogamp/gluegen/DebugEmitter.java3
-rw-r--r--src/java/com/jogamp/gluegen/GlueEmitter.java20
-rw-r--r--src/java/com/jogamp/gluegen/GlueGen.java5
-rw-r--r--src/java/com/jogamp/gluegen/JavaEmitter.java378
-rwxr-xr-xsrc/java/com/jogamp/gluegen/runtime/types/SizeThunk.java35
-rw-r--r--src/java/jogamp/common/os/MachineDescriptionRuntime.java94
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java108
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/test1-common.cfg1
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/test1.c89
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/test1.h23
21 files changed, 1121 insertions, 471 deletions
diff --git a/doc/Implementation/native-size/NativeSizeAlignment-linux-x86_32.log b/doc/Implementation/native-size/NativeSizeAlignment-linux-x86_32.log
new file mode 100644
index 0000000..531ff8a
--- /dev/null
+++ b/doc/Implementation/native-size/NativeSizeAlignment-linux-x86_32.log
@@ -0,0 +1,101 @@
+LD_LIBRARY_PATH=../build-x86/obj:../build-x86/test/build/natives:: java -Djogamp.debug.TraceLock -Djava.library.path=../build-x86/obj:../build-x86/test/build/natives: -classpath lib/junit.jar:/opt-share/apache-ant/lib/ant.jar:/opt-share/apache-ant/lib/ant-junit.jar:/opt-share/apache-ant/lib/ant-launcher.jar:../build-x86/gluegen-rt.jar:../build-x86/gluegen.jar:../build-x86/test/build/classes com.jogamp.gluegen.test.junit.generation.Test1p1JavaEmitter
+JUnit version 4.8.2
+.......static md: MachineDescriptionStatic: X86_32_UNIX(1): MachineDescription: runtimeValidated false, littleEndian true, 32Bit true, primitive size / alignment:
+ int8 1 / 1, int16 2 / 2
+ int 4 / 4, long 4 / 4
+ int32 4 / 4, int64 8 / 4
+ float 4 / 4, double 8 / 4, ldouble 12 / 4
+ pointer 4 / 4, page 4096
+runtime md: MachineDescription: runtimeValidated true, littleEndian true, 32Bit true, primitive size / alignment:
+ int8 1 / 1, int16 2 / 2
+ int 4 / 4, long 4 / 4
+ int32 4 / 4, int64 8 / 4
+ float 4 / 4, double 8 / 4, ldouble 12 / 4
+ pointer 4 / 4, page 4096
+compatible static/runtime: true
+TK_ComplicatedSubSet: sizeof(): 52
+TK_ComplicatedSubSet: bits1-s offset: 0
+TK_ComplicatedSubSet: id-s offset: 4
+TK_ComplicatedSubSet: bits2-s offset: 8
+TK_ComplicatedSubSet: long0-s offset: 12
+TK_ComplicatedSubSet: bits3-s offset: 20
+TK_ComplicatedSubSet: real0-s offset: 24
+TK_ComplicatedSubSet: bits4-s offset: 32
+TK_ComplicatedSubSet: real1-s offset: 36
+TK_ComplicatedSubSet: bits5-s offset: 40
+TK_ComplicatedSubSet: longX-s offset: 44
+TK_ComplicatedSubSet: bits6-s offset: 48
+TK_ComplicatedSuperSet: sizeof(): 116
+TK_ComplicatedSuperSet: bits1-s offset: 0
+TK_ComplicatedSuperSet: sub1-s offset: 4
+TK_ComplicatedSuperSet: bits2-s offset: 56
+TK_ComplicatedSuperSet: sub2-s offset: 60
+TK_ComplicatedSuperSet: bits3-s offset: 112
+createComplicatedSuperSet:
+TK_ComplicatedSuperSet [
+ cs.b1 0xA0
+ cs.sub1.b1 0xA1
+ cs.sub1.id 0x12345678
+ cs.sub1.b2 0xA2
+ cs.sub1.long0 0x9ABCDEF0
+ cs.sub1.b3 0xA3
+ cs.sub1.real0 3.14159 0X1.921FB54442D18P+1
+ cs.sub1.b4 0xA4
+ cs.sub1.real1 256.123 0X1.001F9AP+8
+ cs.sub1.b5 0xA5
+ cs.sub1.longX 0xDEADBEEF
+ cs.sub1.b6 0xA6
+ cs.b2 0xB0
+ cs.sub2.b1 0xB1
+ cs.sub2.id 0x12345678
+ cs.sub2.b2 0xB2
+ cs.sub2.long0 0x9ABCDEF0
+ cs.sub2.b3 0xB3
+ cs.sub2.real0 3.14159 0X1.921FB54442D18P+1
+ cs.sub2.b4 0xB4
+ cs.sub2.real1 256.123 0X1.001F9AP+8
+ cs.sub2.b5 0xB5
+ cs.sub2.longX 0xDEADBEEF
+ cs.sub2.b6 0xB6
+ cs.b3 0xC0
+]
+
+hasInitValues res 1:
+TK_ComplicatedSuperSet [
+ cs.b1 0xA0
+ cs.sub1.b1 0xA1
+ cs.sub1.id 0x12345678
+ cs.sub1.b2 0xA2
+ cs.sub1.long0 0x9ABCDEF0
+ cs.sub1.b3 0xA3
+ cs.sub1.real0 3.14159 0X1.921FB54442D18P+1
+ cs.sub1.b4 0xA4
+ cs.sub1.real1 256.123 0X1.001F9AP+8
+ cs.sub1.b5 0xA5
+ cs.sub1.longX 0xDEADBEEF
+ cs.sub1.b6 0xA6
+ cs.b2 0xB0
+ cs.sub2.b1 0xB1
+ cs.sub2.id 0x12345678
+ cs.sub2.b2 0xB2
+ cs.sub2.long0 0x9ABCDEF0
+ cs.sub2.b3 0xB3
+ cs.sub2.real0 3.14159 0X1.921FB54442D18P+1
+ cs.sub2.b4 0xB4
+ cs.sub2.real1 256.123 0X1.001F9AP+8
+ cs.sub2.b5 0xB5
+ cs.sub2.longX 0xDEADBEEF
+ cs.sub2.b6 0xB6
+ cs.b3 0xC0
+]
+
+0x123456789abcdef0 == 0x9abcdef09abcdef0
+0x9abcdef0 == 0x9abcdef0
+0x123456789abcdef0 == 0xaf10570e9abcdef0
+0x9abcdef0 == 0x9abcdef0
+
+Time: 0.037
+
+OK (7 tests)
+
+
diff --git a/doc/Implementation/native-size/NativeSizeAlignment-linux-x86_64.log b/doc/Implementation/native-size/NativeSizeAlignment-linux-x86_64.log
new file mode 100644
index 0000000..72fccf8
--- /dev/null
+++ b/doc/Implementation/native-size/NativeSizeAlignment-linux-x86_64.log
@@ -0,0 +1,99 @@
+LD_LIBRARY_PATH=../build-x86_64/obj:../build-x86_64/test/build/natives:: java -Djogamp.debug.TraceLock -Djava.library.path=../build-x86_64/obj:../build-x86_64/test/build/natives: -classpath lib/junit.jar:/opt-share/apache-ant/lib/ant.jar:/opt-share/apache-ant/lib/ant-junit.jar:/opt-share/apache-ant/lib/ant-launcher.jar:../build-x86_64/gluegen-rt.jar:../build-x86_64/gluegen.jar:../build-x86_64/test/build/classes com.jogamp.gluegen.test.junit.generation.Test1p1JavaEmitter
+JUnit version 4.8.2
+.......static md: MachineDescriptionStatic: X86_64_UNIX(2): MachineDescription: runtimeValidated false, littleEndian true, 32Bit false, primitive size / alignment:
+ int8 1 / 1, int16 2 / 2
+ int 4 / 4, long 8 / 8
+ int32 4 / 4, int64 8 / 8
+ float 4 / 4, double 8 / 8, ldouble 16 / 16
+ pointer 8 / 8, page 4096
+runtime md: MachineDescription: runtimeValidated true, littleEndian true, 32Bit false, primitive size / alignment:
+ int8 1 / 1, int16 2 / 2
+ int 4 / 4, long 8 / 8
+ int32 4 / 4, int64 8 / 8
+ float 4 / 4, double 8 / 8, ldouble 16 / 16
+ pointer 8 / 8, page 4096
+compatible static/runtime: true
+TK_ComplicatedSubSet: sizeof(): 72
+TK_ComplicatedSubSet: bits1-s offset: 0
+TK_ComplicatedSubSet: id-s offset: 4
+TK_ComplicatedSubSet: bits2-s offset: 8
+TK_ComplicatedSubSet: long0-s offset: 16
+TK_ComplicatedSubSet: bits3-s offset: 24
+TK_ComplicatedSubSet: real0-s offset: 32
+TK_ComplicatedSubSet: bits4-s offset: 40
+TK_ComplicatedSubSet: real1-s offset: 44
+TK_ComplicatedSubSet: bits5-s offset: 48
+TK_ComplicatedSubSet: longX-s offset: 56
+TK_ComplicatedSubSet: bits6-s offset: 64
+TK_ComplicatedSuperSet: sizeof(): 168
+TK_ComplicatedSuperSet: bits1-s offset: 0
+TK_ComplicatedSuperSet: sub1-s offset: 8
+TK_ComplicatedSuperSet: bits2-s offset: 80
+TK_ComplicatedSuperSet: sub2-s offset: 88
+TK_ComplicatedSuperSet: bits3-s offset: 160
+createComplicatedSuperSet:
+TK_ComplicatedSuperSet [
+ cs.b1 0xA0
+ cs.sub1.b1 0xA1
+ cs.sub1.id 0x12345678
+ cs.sub1.b2 0xA2
+ cs.sub1.long0 0x123456789ABCDEF0
+ cs.sub1.b3 0xA3
+ cs.sub1.real0 3.14159 0X1.921FB54442D18P+1
+ cs.sub1.b4 0xA4
+ cs.sub1.real1 256.123 0X1.001F9AP+8
+ cs.sub1.b5 0xA5
+ cs.sub1.longX 0xDEADBEEF
+ cs.sub1.b6 0xA6
+ cs.b2 0xB0
+ cs.sub2.b1 0xB1
+ cs.sub2.id 0x12345678
+ cs.sub2.b2 0xB2
+ cs.sub2.long0 0x123456789ABCDEF0
+ cs.sub2.b3 0xB3
+ cs.sub2.real0 3.14159 0X1.921FB54442D18P+1
+ cs.sub2.b4 0xB4
+ cs.sub2.real1 256.123 0X1.001F9AP+8
+ cs.sub2.b5 0xB5
+ cs.sub2.longX 0xDEADBEEF
+ cs.sub2.b6 0xB6
+ cs.b3 0xC0
+]
+
+hasInitValues res 1:
+TK_ComplicatedSuperSet [
+ cs.b1 0xA0
+ cs.sub1.b1 0xA1
+ cs.sub1.id 0x12345678
+ cs.sub1.b2 0xA2
+ cs.sub1.long0 0x123456789ABCDEF0
+ cs.sub1.b3 0xA3
+ cs.sub1.real0 3.14159 0X1.921FB54442D18P+1
+ cs.sub1.b4 0xA4
+ cs.sub1.real1 256.123 0X1.001F9AP+8
+ cs.sub1.b5 0xA5
+ cs.sub1.longX 0xDEADBEEF
+ cs.sub1.b6 0xA6
+ cs.b2 0xB0
+ cs.sub2.b1 0xB1
+ cs.sub2.id 0x12345678
+ cs.sub2.b2 0xB2
+ cs.sub2.long0 0x123456789ABCDEF0
+ cs.sub2.b3 0xB3
+ cs.sub2.real0 3.14159 0X1.921FB54442D18P+1
+ cs.sub2.b4 0xB4
+ cs.sub2.real1 256.123 0X1.001F9AP+8
+ cs.sub2.b5 0xB5
+ cs.sub2.longX 0xDEADBEEF
+ cs.sub2.b6 0xB6
+ cs.b3 0xC0
+]
+
+0x123456789abcdef0 == 0x123456789abcdef0
+0x123456789abcdef0 == 0x123456789abcdef0
+
+Time: 0.038
+
+OK (7 tests)
+
+
diff --git a/doc/Implementation/native-size/NativeSizeAlignment-win32.log b/doc/Implementation/native-size/NativeSizeAlignment-win32.log
new file mode 100644
index 0000000..d2ccfe5
--- /dev/null
+++ b/doc/Implementation/native-size/NativeSizeAlignment-win32.log
@@ -0,0 +1,99 @@
+JUnit version 4.8.2
+.......static md: MachineDescriptionStatic: X86_32_WINDOWS(3): MachineDescription: runtimeValidated false, littleEndian true, 32Bit true, primitive size / alignment:
+ int8 1 / 1, int16 2 / 2
+ int 4 / 4, long 4 / 4
+ int32 4 / 4, int64 8 / 8
+ float 4 / 4, double 8 / 8, ldouble 12 / 4
+ pointer 4 / 4, page 4096
+runtime md: MachineDescription: runtimeValidated true, littleEndian true, 32Bit true, primitive size / alignment:
+ int8 1 / 1, int16 2 / 2
+ int 4 / 4, long 4 / 4
+ int32 4 / 4, int64 8 / 8
+ float 4 / 4, double 8 / 8, ldouble 12 / 4
+ pointer 4 / 4, page 4096
+compatible static/runtime: true
+0x123456789abcdef0 == 0x9abcdef09abcdef0
+0x9abcdef0 == 0x9abcdef0
+0x123456789abcdef0 == 0x708c12949abcdef0
+0x9abcdef0 == 0x9abcdef0
+
+Time: 0.044
+
+OK (7 tests)
+
+TK_ComplicatedSubSet: sizeof(): 64
+TK_ComplicatedSubSet: bits1-s offset: 0
+TK_ComplicatedSubSet: id-s offset: 4
+TK_ComplicatedSubSet: bits2-s offset: 8
+TK_ComplicatedSubSet: long0-s offset: 16
+TK_ComplicatedSubSet: bits3-s offset: 24
+TK_ComplicatedSubSet: real0-s offset: 32
+TK_ComplicatedSubSet: bits4-s offset: 40
+TK_ComplicatedSubSet: real1-s offset: 44
+TK_ComplicatedSubSet: bits5-s offset: 48
+TK_ComplicatedSubSet: longX-s offset: 52
+TK_ComplicatedSubSet: bits6-s offset: 56
+TK_ComplicatedSuperSet: sizeof(): 152
+TK_ComplicatedSuperSet: bits1-s offset: 0
+TK_ComplicatedSuperSet: sub1-s offset: 8
+TK_ComplicatedSuperSet: bits2-s offset: 72
+TK_ComplicatedSuperSet: sub2-s offset: 80
+TK_ComplicatedSuperSet: bits3-s offset: 144
+createComplicatedSuperSet:
+TK_ComplicatedSuperSet [
+ cs.b1 0xA0
+ cs.sub1.b1 0xA1
+ cs.sub1.id 0x12345678
+ cs.sub1.b2 0xA2
+ cs.sub1.long0 0x9ABCDEF0
+ cs.sub1.b3 0xA3
+ cs.sub1.real0 3.14159 0X1.921FB5P+1
+ cs.sub1.b4 0xA4
+ cs.sub1.real1 256.123 0X1.001F9AP+8
+ cs.sub1.b5 0xA5
+ cs.sub1.longX 0xDEADBEEF
+ cs.sub1.b6 0xA6
+ cs.b2 0xB0
+ cs.sub2.b1 0xB1
+ cs.sub2.id 0x12345678
+ cs.sub2.b2 0xB2
+ cs.sub2.long0 0x9ABCDEF0
+ cs.sub2.b3 0xB3
+ cs.sub2.real0 3.14159 0X1.921FB5P+1
+ cs.sub2.b4 0xB4
+ cs.sub2.real1 256.123 0X1.001F9AP+8
+ cs.sub2.b5 0xB5
+ cs.sub2.longX 0xDEADBEEF
+ cs.sub2.b6 0xB6
+ cs.b3 0xC0
+]
+
+hasInitValues res 1:
+TK_ComplicatedSuperSet [
+ cs.b1 0xA0
+ cs.sub1.b1 0xA1
+ cs.sub1.id 0x12345678
+ cs.sub1.b2 0xA2
+ cs.sub1.long0 0x9ABCDEF0
+ cs.sub1.b3 0xA3
+ cs.sub1.real0 3.14159 0X1.921FB5P+1
+ cs.sub1.b4 0xA4
+ cs.sub1.real1 256.123 0X1.001F9AP+8
+ cs.sub1.b5 0xA5
+ cs.sub1.longX 0xDEADBEEF
+ cs.sub1.b6 0xA6
+ cs.b2 0xB0
+ cs.sub2.b1 0xB1
+ cs.sub2.id 0x12345678
+ cs.sub2.b2 0xB2
+ cs.sub2.long0 0x9ABCDEF0
+ cs.sub2.b3 0xB3
+ cs.sub2.real0 3.14159 0X1.921FB5P+1
+ cs.sub2.b4 0xB4
+ cs.sub2.real1 256.123 0X1.001F9AP+8
+ cs.sub2.b5 0xB5
+ cs.sub2.longX 0xDEADBEEF
+ cs.sub2.b6 0xB6
+ cs.b3 0xC0
+]
+
diff --git a/doc/Implementation/native-size/NativeSizeAlignment-win64.log b/doc/Implementation/native-size/NativeSizeAlignment-win64.log
new file mode 100644
index 0000000..69c3e6f
--- /dev/null
+++ b/doc/Implementation/native-size/NativeSizeAlignment-win64.log
@@ -0,0 +1,97 @@
+JUnit version 4.8.2
+.......static md: MachineDescriptionStatic: X86_64_WINDOWS(4): MachineDescription: runtimeValidated false, littleEndian true, 32Bit false, primitive size / alignment:
+ int8 1 / 1, int16 2 / 2
+ int 4 / 4, long 4 / 4
+ int32 4 / 4, int64 8 / 8
+ float 4 / 4, double 8 / 8, ldouble 16 / 16
+ pointer 8 / 8, page 4096
+runtime md: MachineDescription: runtimeValidated true, littleEndian true, 32Bit false, primitive size / alignment:
+ int8 1 / 1, int16 2 / 2
+ int 4 / 4, long 4 / 4
+ int32 4 / 4, int64 8 / 8
+ float 4 / 4, double 8 / 8, ldouble 16 / 16
+ pointer 8 / 8, page 4096
+compatible static/runtime: true
+0x123456789abcdef0 == 0x123456789abcdef0
+0x123456789abcdef0 == 0x123456789abcdef0
+
+Time: 0.033
+
+OK (7 tests)
+
+TK_ComplicatedSubSet: sizeof(): 64
+TK_ComplicatedSubSet: bits1-s offset: 0
+TK_ComplicatedSubSet: id-s offset: 4
+TK_ComplicatedSubSet: bits2-s offset: 8
+TK_ComplicatedSubSet: long0-s offset: 16
+TK_ComplicatedSubSet: bits3-s offset: 24
+TK_ComplicatedSubSet: real0-s offset: 32
+TK_ComplicatedSubSet: bits4-s offset: 40
+TK_ComplicatedSubSet: real1-s offset: 44
+TK_ComplicatedSubSet: bits5-s offset: 48
+TK_ComplicatedSubSet: longX-s offset: 52
+TK_ComplicatedSubSet: bits6-s offset: 56
+TK_ComplicatedSuperSet: sizeof(): 152
+TK_ComplicatedSuperSet: bits1-s offset: 0
+TK_ComplicatedSuperSet: sub1-s offset: 8
+TK_ComplicatedSuperSet: bits2-s offset: 72
+TK_ComplicatedSuperSet: sub2-s offset: 80
+TK_ComplicatedSuperSet: bits3-s offset: 144
+createComplicatedSuperSet:
+TK_ComplicatedSuperSet [
+ cs.b1 0xA0
+ cs.sub1.b1 0xA1
+ cs.sub1.id 0x12345678
+ cs.sub1.b2 0xA2
+ cs.sub1.long0 0x9ABCDEF0
+ cs.sub1.b3 0xA3
+ cs.sub1.real0 3.14159 0X1.921FB5P+1
+ cs.sub1.b4 0xA4
+ cs.sub1.real1 256.123 0X1.001F9AP+8
+ cs.sub1.b5 0xA5
+ cs.sub1.longX 0xDEADBEEF
+ cs.sub1.b6 0xA6
+ cs.b2 0xB0
+ cs.sub2.b1 0xB1
+ cs.sub2.id 0x12345678
+ cs.sub2.b2 0xB2
+ cs.sub2.long0 0x9ABCDEF0
+ cs.sub2.b3 0xB3
+ cs.sub2.real0 3.14159 0X1.921FB5P+1
+ cs.sub2.b4 0xB4
+ cs.sub2.real1 256.123 0X1.001F9AP+8
+ cs.sub2.b5 0xB5
+ cs.sub2.longX 0xDEADBEEF
+ cs.sub2.b6 0xB6
+ cs.b3 0xC0
+]
+
+hasInitValues res 1:
+TK_ComplicatedSuperSet [
+ cs.b1 0xA0
+ cs.sub1.b1 0xA1
+ cs.sub1.id 0x12345678
+ cs.sub1.b2 0xA2
+ cs.sub1.long0 0x9ABCDEF0
+ cs.sub1.b3 0xA3
+ cs.sub1.real0 3.14159 0X1.921FB5P+1
+ cs.sub1.b4 0xA4
+ cs.sub1.real1 256.123 0X1.001F9AP+8
+ cs.sub1.b5 0xA5
+ cs.sub1.longX 0xDEADBEEF
+ cs.sub1.b6 0xA6
+ cs.b2 0xB0
+ cs.sub2.b1 0xB1
+ cs.sub2.id 0x12345678
+ cs.sub2.b2 0xB2
+ cs.sub2.long0 0x9ABCDEF0
+ cs.sub2.b3 0xB3
+ cs.sub2.real0 3.14159 0X1.921FB5P+1
+ cs.sub2.b4 0xB4
+ cs.sub2.real1 256.123 0X1.001F9AP+8
+ cs.sub2.b5 0xB5
+ cs.sub2.longX 0xDEADBEEF
+ cs.sub2.b6 0xB6
+ cs.b3 0xC0
+]
+
diff --git a/make/scripts/java-win32.bat b/make/scripts/java-win32.bat
new file mode 100755
index 0000000..1e2c0f2
--- /dev/null
+++ b/make/scripts/java-win32.bat
@@ -0,0 +1,16 @@
+
+set BLD_SUB=build-win32
+set J2RE_HOME=c:\jre1.6.0_26_x32
+set JAVA_HOME=c:\jdk1.6.0_26_x32
+set ANT_PATH=C:\apache-ant-1.8.2
+
+set BLD_DIR=..\%BLD_SUB%
+set LIB_DIR=..\%BLD_SUB%\obj;..\%BLD_SUB%\test\build\natives
+
+set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%LIB_DIR%;%PATH%
+
+set CP_ALL=.;%BLD_DIR%\gluegen-rt.jar;%BLD_DIR%\test\build\gluegen-test.jar;lib\junit.jar;%ANT_PATH%\lib\ant.jar;%ANT_PATH%\lib\ant-junit.jar
+
+echo CP_ALL %CP_ALL%
+
+%J2RE_HOME%\bin\java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" "-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" %1 %2 %3 %4 %5 %6 %7 %8 %9 > java-win32.log 2>&1
diff --git a/make/scripts/java-win64.bat b/make/scripts/java-win64.bat
new file mode 100755
index 0000000..d518073
--- /dev/null
+++ b/make/scripts/java-win64.bat
@@ -0,0 +1,17 @@
+
+set BLD_SUB=build-win64
+set J2RE_HOME=c:\jre1.6.0_26_x64
+set JAVA_HOME=c:\jdk1.6.0_26_x64
+set ANT_PATH=C:\apache-ant-1.8.2
+
+set BLD_DIR=..\%BLD_SUB%
+set LIB_DIR=..\%BLD_SUB%\obj;..\%BLD_SUB%\test\build\natives
+
+set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%LIB_DIR%;%PATH%
+
+set CP_ALL=.;%BLD_DIR%\gluegen-rt.jar;%BLD_DIR%\test\build\gluegen-test.jar;lib\junit.jar;%ANT_PATH%\lib\ant.jar;%ANT_PATH%\lib\ant-junit.jar
+
+echo CP_ALL %CP_ALL%
+
+%J2RE_HOME%\bin\java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" "-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" %1 %2 %3 %4 %5 %6 %7 %8 %9 > java-win64.log 2>&1
+
diff --git a/make/scripts/runtest-x32.bat b/make/scripts/runtest-x32.bat
new file mode 100755
index 0000000..b09ce73
--- /dev/null
+++ b/make/scripts/runtest-x32.bat
@@ -0,0 +1,4 @@
+REM scripts\java-win32.bat com.jogamp.common.GlueGenVersion
+REM scripts\java-win32.bat com.jogamp.common.util.TestVersionInfo
+scripts\java-win32.bat com.jogamp.gluegen.test.junit.generation.Test1p1JavaEmitter
+
diff --git a/make/scripts/runtest-x64.bat b/make/scripts/runtest-x64.bat
new file mode 100755
index 0000000..f437ef7
--- /dev/null
+++ b/make/scripts/runtest-x64.bat
@@ -0,0 +1,4 @@
+REM scripts\java-win64.bat com.jogamp.common.GlueGenVersion
+REM scripts\java-win64.bat com.jogamp.common.util.TestVersionInfo
+scripts\java-win64.bat com.jogamp.gluegen.test.junit.generation.Test1p1JavaEmitter
+
diff --git a/src/java/com/jogamp/common/nio/StructAccessor.java b/src/java/com/jogamp/common/nio/StructAccessor.java
index 5c0e70a..41da290 100644
--- a/src/java/com/jogamp/common/nio/StructAccessor.java
+++ b/src/java/com/jogamp/common/nio/StructAccessor.java
@@ -113,6 +113,37 @@ public class StructAccessor {
bb.putInt(byteOffset, v);
}
+ /** Retrieves the int at the specified byteOffset. */
+ public final int getIntAt(int byteOffset, int nativeSizeInBytes) {
+ switch(nativeSizeInBytes) {
+ case 2:
+ return (int) bb.getShort(byteOffset) & 0x0000FFFF ;
+ case 4:
+ return bb.getInt(byteOffset);
+ case 8:
+ return (int) ( bb.getLong(byteOffset) & 0x00000000FFFFFFFFL ) ;
+ default:
+ throw new InternalError("invalid nativeSizeInBytes "+nativeSizeInBytes);
+ }
+ }
+
+ /** Puts a int at the specified byteOffset. */
+ public final void setIntAt(int byteOffset, int v, int nativeSizeInBytes) {
+ switch(nativeSizeInBytes) {
+ case 2:
+ bb.putShort(byteOffset, (short) ( v & 0x0000FFFF ) );
+ break;
+ case 4:
+ bb.putInt(byteOffset, v);
+ break;
+ case 8:
+ bb.putLong(byteOffset, (long)v & 0x00000000FFFFFFFFL );
+ break;
+ default:
+ throw new InternalError("invalid nativeSizeInBytes "+nativeSizeInBytes);
+ }
+ }
+
/** Retrieves the float at the specified byteOffset. */
public final float getFloatAt(int byteOffset) {
return bb.getFloat(byteOffset);
@@ -133,20 +164,42 @@ public class StructAccessor {
bb.putDouble(byteOffset, v);
}
- /**
- * Retrieves the long at the specified byteOffset.
- */
+ /** Retrieves the long at the specified byteOffset. */
public final long getLongAt(int byteOffset) {
return bb.getLong(byteOffset);
}
- /**
- * Puts a long at the specified byteOffset.
- */
+ /** Puts a long at the specified byteOffset. */
public final void setLongAt(int byteOffset, long v) {
bb.putLong(byteOffset, v);
}
+ /** Retrieves the long at the specified byteOffset. */
+ public final long getLongAt(int byteOffset, int nativeSizeInBytes) {
+ switch(nativeSizeInBytes) {
+ case 4:
+ return (long) bb.getInt(byteOffset) & 0x00000000FFFFFFFFL;
+ case 8:
+ return bb.getLong(byteOffset);
+ default:
+ throw new InternalError("invalid nativeSizeInBytes "+nativeSizeInBytes);
+ }
+ }
+
+ /** Puts a long at the specified byteOffset. */
+ public final void setLongAt(int byteOffset, long v, int nativeSizeInBytes) {
+ switch(nativeSizeInBytes) {
+ case 4:
+ bb.putInt(byteOffset, (int) ( v & 0x00000000FFFFFFFFL ) );
+ break;
+ case 8:
+ bb.putLong(byteOffset, v);
+ break;
+ default:
+ throw new InternalError("invalid nativeSizeInBytes "+nativeSizeInBytes);
+ }
+ }
+
public final void setBytesAt(int byteOffset, byte[] v) {
for (int i = 0; i < v.length; i++) {
bb.put(byteOffset++, v[i]);
diff --git a/src/java/com/jogamp/common/os/MachineDescription.java b/src/java/com/jogamp/common/os/MachineDescription.java
index 7534917..43f2975 100644
--- a/src/java/com/jogamp/common/os/MachineDescription.java
+++ b/src/java/com/jogamp/common/os/MachineDescription.java
@@ -40,77 +40,93 @@
package com.jogamp.common.os;
-import java.nio.ByteBuffer;
-import java.nio.IntBuffer;
-import java.nio.ShortBuffer;
-
-import com.jogamp.common.nio.Buffers;
-
/**
* For alignment and size see {@link com.jogamp.gluegen}
*/
public class MachineDescription {
- /* arch os int, long, float, doubl, ldoubl, ptr, page */
- final static int[] size_armeabi = { 4, 4, 4, 8, 8, 4, 4096 };
- final static int[] size_x86_32_unix = { 4, 4, 4, 8, 12, 4, 4096 };
- final static int[] size_x86_32_windows = { 4, 4, 4, 8, 12, 4, 4096 };
- final static int[] size_x86_64_unix = { 4, 8, 4, 8, 16, 8, 4096 };
- final static int[] size_x86_64_windows = { 4, 4, 4, 8, 16, 8, 4096 };
+ public enum ID {
+ /** {@link Platform.CPUType#ARM} EABI Little Endian */
+ ARMle_EABI(Platform.CPUType.ARM),
+ /** {@link Platform.CPUType#X86_32} Little Endian Unix */
+ X86_32_UNIX(Platform.CPUType.X86_32),
+ /** {@link Platform.CPUType#X86_64} Little Endian Unix */
+ X86_64_UNIX(Platform.CPUType.X86_64),
+ /** {@link Platform.CPUType#X86_32} Little Endian Windows */
+ X86_32_WINDOWS(Platform.CPUType.X86_32),
+ /** {@link Platform.CPUType#X86_64} Little Endian Windows */
+ X86_64_WINDOWS(Platform.CPUType.X86_64);
+
+ public final Platform.CPUType cpu;
+
+ ID(Platform.CPUType cpu){
+ this.cpu = cpu;
+ }
+ }
+
+ /* arch os int, long, float, doubl, ldoubl, ptr, page */
+ private final static int[] size_armeabi = { 4, 4, 4, 8, 8, 4, 4096 };
+ private final static int[] size_x86_32_unix = { 4, 4, 4, 8, 12, 4, 4096 };
+ private final static int[] size_x86_32_windows = { 4, 4, 4, 8, 12, 4, 4096 };
+ private final static int[] size_x86_64_unix = { 4, 8, 4, 8, 16, 8, 4096 };
+ private final static int[] size_x86_64_windows = { 4, 4, 4, 8, 16, 8, 4096 };
- /* arch os i8, i16, i32, i64, int, long, float, doubl, ldoubl, ptr */
- final static int[] align_armeabi = { 1, 2, 4, 8, 4, 4, 4, 8, 8, 4 };
- final static int[] align_x86_32_unix = { 1, 2, 4, 4, 4, 4, 4, 4, 4, 4 };
- final static int[] align_x86_32_windows = { 1, 2, 4, 8, 4, 4, 4, 8, 4, 4 };
- final static int[] align_x86_64_unix = { 1, 2, 4, 8, 4, 8, 4, 8, 16, 8 };
- final static int[] align_x86_64_windows = { 1, 2, 4, 8, 4, 4, 4, 8, 16, 8 };
+ /* arch os i8, i16, i32, i64, int, long, float, doubl, ldoubl, ptr */
+ private final static int[] align_armeabi = { 1, 2, 4, 8, 4, 4, 4, 8, 8, 4 };
+ private final static int[] align_x86_32_unix = { 1, 2, 4, 4, 4, 4, 4, 4, 4, 4 };
+ private final static int[] align_x86_32_windows = { 1, 2, 4, 8, 4, 4, 4, 8, 4, 4 };
+ private final static int[] align_x86_64_unix = { 1, 2, 4, 8, 4, 8, 4, 8, 16, 8 };
+ private final static int[] align_x86_64_windows = { 1, 2, 4, 8, 4, 4, 4, 8, 16, 8 };
- public enum Config {
- ARM_EABI(size_armeabi, align_armeabi),
- X86_32_UNIX(size_x86_32_unix, align_x86_32_unix),
- X86_64_UNIX(size_x86_64_unix, align_x86_64_unix),
- X86_32_WINDOWS(size_x86_32_windows, align_x86_32_windows),
- X86_64_WINDOWS(size_x86_64_windows, align_x86_64_windows);
+ public enum StaticConfig {
+ /** {@link MachineDescription.ID#ARMle_EABI } */
+ ARMle_EABI(ID.ARMle_EABI, true, size_armeabi, align_armeabi),
+ /** {@link MachineDescription.ID#X86_32_UNIX } */
+ X86_32_UNIX(ID.X86_32_UNIX, true, size_x86_32_unix, align_x86_32_unix),
+ /** {@link MachineDescription.ID#X86_64_UNIX } */
+ X86_64_UNIX(ID.X86_64_UNIX, true, size_x86_64_unix, align_x86_64_unix),
+ /** {@link MachineDescription.ID#X86_32_WINDOWS } */
+ X86_32_WINDOWS(ID.X86_32_WINDOWS, true, size_x86_32_windows, align_x86_32_windows),
+ /** {@link MachineDescription.ID#X86_64_WINDOWS } */
+ X86_64_WINDOWS(ID.X86_64_WINDOWS, true, size_x86_64_windows, align_x86_64_windows);
- public final int intSizeInBytes;
- public final int longSizeInBytes;
- public final int floatSizeInBytes;
- public final int doubleSizeInBytes;
- public final int ldoubleSizeInBytes;
- public final int pointerSizeInBytes;
- public final int pageSizeInBytes;
+ public final ID id;
+ public final MachineDescription md;
- public final int int8AlignmentInBytes;
- public final int int16AlignmentInBytes;
- public final int int32AlignmentInBytes;
- public final int int64AlignmentInBytes;
- public final int intAlignmentInBytes;
- public final int longAlignmentInBytes;
- public final int floatAlignmentInBytes;
- public final int doubleAlignmentInBytes;
- public final int ldoubleAlignmentInBytes;
- public final int pointerAlignmentInBytes;
+ StaticConfig(ID id, boolean littleEndian, int[] sizes, int[] alignments) {
+ this.id = id;
+ int i=0, j=0;
+ this.md = new MachineDescription(false, littleEndian,
+ sizes[i++],
+ sizes[i++],
+ sizes[i++],
+ sizes[i++],
+ sizes[i++],
+ sizes[i++],
+ sizes[i++],
+ alignments[j++],
+ alignments[j++],
+ alignments[j++],
+ alignments[j++],
+ alignments[j++],
+ alignments[j++],
+ alignments[j++],
+ alignments[j++],
+ alignments[j++],
+ alignments[j++]);
+ }
- Config(int[] sizes, int[] alignments) {
- int i=0;
- intSizeInBytes = sizes[i++];
- longSizeInBytes = sizes[i++];;
- floatSizeInBytes = sizes[i++];;
- doubleSizeInBytes = sizes[i++];;
- ldoubleSizeInBytes = sizes[i++];;
- pointerSizeInBytes = sizes[i++];;
- pageSizeInBytes = sizes[i++];;
-
- i=0;
- int8AlignmentInBytes = alignments[i++];
- int16AlignmentInBytes = alignments[i++];
- int32AlignmentInBytes = alignments[i++];
- int64AlignmentInBytes = alignments[i++];
- intAlignmentInBytes = alignments[i++];
- longAlignmentInBytes = alignments[i++];
- floatAlignmentInBytes = alignments[i++];
- doubleAlignmentInBytes = alignments[i++];
- ldoubleAlignmentInBytes = alignments[i++];
- pointerAlignmentInBytes = alignments[i++];
+ public StringBuilder toString(StringBuilder sb) {
+ if(null==sb) {
+ sb = new StringBuilder();
+ }
+ sb.append("MachineDescriptionStatic: ").append(this.name()).append("(").append(this.ordinal()).append("): ");
+ md.toString(sb);
+ return sb;
+ }
+
+ @Override
+ public String toString() {
+ return toString(null).toString();
}
}
@@ -144,72 +160,6 @@ public class MachineDescription {
final private int ldoubleAlignmentInBytes;
final private int pointerAlignmentInBytes;
- public static boolean queryIsLittleEndian() {
- ByteBuffer tst_b = Buffers.newDirectByteBuffer(Buffers.SIZEOF_INT); // 32bit in native order
- IntBuffer tst_i = tst_b.asIntBuffer();
- ShortBuffer tst_s = tst_b.asShortBuffer();
- tst_i.put(0, 0x0A0B0C0D);
- return 0x0C0D == tst_s.get(0);
- }
-
- public static MachineDescription createStaticArmEABI() {
- return new MachineDescription(false, queryIsLittleEndian(), Config.ARM_EABI);
- }
- public static MachineDescription createStaticUnix32() {
- return new MachineDescription(false, queryIsLittleEndian(), Config.X86_32_UNIX);
- }
- public static MachineDescription createStaticUnix64() {
- return new MachineDescription(false, queryIsLittleEndian(), Config.X86_64_UNIX);
- }
- public static MachineDescription createStaticWindows32() {
- return new MachineDescription(false, queryIsLittleEndian(), Config.X86_32_WINDOWS);
- }
- public static MachineDescription createStaticWindows64() {
- return new MachineDescription(false, queryIsLittleEndian(), Config.X86_64_WINDOWS);
- }
- public static MachineDescription createStatic(boolean is32BitByCPUArch) {
- if(is32BitByCPUArch) {
- if(Platform.getCPUFamily() == Platform.CPUFamily.ARM) {
- return createStaticArmEABI();
- } else if(Platform.getOSType() == Platform.OSType.WINDOWS) {
- return createStaticWindows32();
- }
- return createStaticUnix32();
- } else {
- if(Platform.getOSType() == Platform.OSType.WINDOWS) {
- return createStaticWindows64();
- }
- return createStaticUnix64();
- }
- }
-
- public MachineDescription(boolean runtimeValidated,
- boolean littleEndian,
- Config config) {
- this.runtimeValidated = runtimeValidated;
- this.littleEndian = littleEndian;
-
- this.intSizeInBytes = config.intSizeInBytes;
- this.longSizeInBytes = config.longSizeInBytes;
- this.floatSizeInBytes = config.floatSizeInBytes;
- this.doubleSizeInBytes = config.doubleSizeInBytes;
- this.ldoubleSizeInBytes = config.ldoubleSizeInBytes;
- this.pointerSizeInBytes = config.pointerSizeInBytes;
- this.pageSizeInBytes = config.pageSizeInBytes;
- this.is32Bit = 4 == config.pointerSizeInBytes;
-
- this.int8AlignmentInBytes = config.int8AlignmentInBytes;
- this.int16AlignmentInBytes = config.int16AlignmentInBytes;
- this.int32AlignmentInBytes = config.int32AlignmentInBytes;
- this.int64AlignmentInBytes = config.int64AlignmentInBytes;
- this.intAlignmentInBytes = config.intAlignmentInBytes;
- this.longAlignmentInBytes = config.longAlignmentInBytes;
- this.floatAlignmentInBytes = config.floatAlignmentInBytes;
- this.doubleAlignmentInBytes = config.doubleAlignmentInBytes;
- this.ldoubleAlignmentInBytes = config.ldoubleAlignmentInBytes;
- this.pointerAlignmentInBytes = config.pointerAlignmentInBytes;
- }
-
public MachineDescription(boolean runtimeValidated,
boolean littleEndian,
@@ -319,29 +269,75 @@ public class MachineDescription {
public int pageAlignedSize(int size) {
return pageCount(size) * pageSizeInBytes;
}
+
+ /**
+ * Checks whether two size objects are equal. Two instances
+ * of <code>MachineDescription</code> are considered equal if all components
+ * match but {@link #runtimeValidated}, {@link #isRuntimeValidated()}.
+ * @return <code>true</code> if the two MachineDescription are equal;
+ * otherwise <code>false</code>.
+ */
+ public final boolean equals(Object obj) {
+ if (this == obj) { return true; }
+ if ( !(obj instanceof MachineDescription) ) { return false; }
+ final MachineDescription md = (MachineDescription) obj;
+
+ return pageSizeInBytes == md.pageSizeInBytes &&
+ compatible(md);
+ }
+
+ /**
+ * Checks whether two size objects are equal. Two instances
+ * of <code>MachineDescription</code> are considered equal if all components
+ * match but {@link #isRuntimeValidated()} and {@link #pageSizeInBytes()}.
+ * @return <code>true</code> if the two MachineDescription are equal;
+ * otherwise <code>false</code>.
+ */
+ public final boolean compatible(MachineDescription md) {
+ return littleEndian == md.littleEndian &&
+
+ intSizeInBytes == md.intSizeInBytes &&
+ longSizeInBytes == md.longSizeInBytes &&
+ floatSizeInBytes == md.floatSizeInBytes &&
+ doubleSizeInBytes == md.doubleSizeInBytes &&
+ ldoubleSizeInBytes == md.ldoubleSizeInBytes &&
+ pointerSizeInBytes == md.pointerSizeInBytes &&
+ is32Bit == md.is32Bit &&
+
+ int8AlignmentInBytes == md.int8AlignmentInBytes &&
+ int16AlignmentInBytes == md.int16AlignmentInBytes &&
+ int32AlignmentInBytes == md.int32AlignmentInBytes &&
+ int64AlignmentInBytes == md.int64AlignmentInBytes &&
+ intAlignmentInBytes == md.intAlignmentInBytes &&
+ longAlignmentInBytes == md.longAlignmentInBytes &&
+ floatAlignmentInBytes == md.floatAlignmentInBytes &&
+ doubleAlignmentInBytes == md.doubleAlignmentInBytes &&
+ ldoubleAlignmentInBytes == md.ldoubleAlignmentInBytes &&
+ pointerAlignmentInBytes == md.pointerAlignmentInBytes ;
+ }
- public StringBuilder toString(StringBuilder sb) {
- if(null==sb) {
- sb = new StringBuilder();
- }
- sb.append("MachineDescription: runtimeValidated ").append(isRuntimeValidated()).append(", littleEndian ").append(isLittleEndian()).append(", 32Bit ").append(is32Bit()).append(", primitive size / alignment:").append(Platform.getNewline());
- sb.append(" int8 ").append(int8SizeInBytes) .append(" / ").append(int8AlignmentInBytes);
- sb.append(", int16 ").append(int16SizeInBytes) .append(" / ").append(int16AlignmentInBytes).append(Platform.getNewline());
- sb.append(" int ").append(intSizeInBytes) .append(" / ").append(intAlignmentInBytes);
- sb.append(", long ").append(longSizeInBytes) .append(" / ").append(longAlignmentInBytes).append(Platform.getNewline());
- sb.append(" int32 ").append(int32SizeInBytes) .append(" / ").append(int32AlignmentInBytes);
- sb.append(", int64 ").append(int64SizeInBytes) .append(" / ").append(int64AlignmentInBytes).append(Platform.getNewline());
- sb.append(" float ").append(floatSizeInBytes) .append(" / ").append(floatAlignmentInBytes);
- sb.append(", double ").append(doubleSizeInBytes) .append(" / ").append(doubleAlignmentInBytes);
- sb.append(", ldouble ").append(ldoubleSizeInBytes).append(" / ").append(ldoubleAlignmentInBytes).append(Platform.getNewline());
- sb.append(" pointer ").append(pointerSizeInBytes).append(" / ").append(pointerAlignmentInBytes);
- sb.append(", page ").append(pageSizeInBytes);
- return sb;
+ public StringBuilder toString(StringBuilder sb) {
+ if(null==sb) {
+ sb = new StringBuilder();
}
+ sb.append("MachineDescription: runtimeValidated ").append(isRuntimeValidated()).append(", littleEndian ").append(isLittleEndian()).append(", 32Bit ").append(is32Bit()).append(", primitive size / alignment:").append(Platform.getNewline());
+ sb.append(" int8 ").append(int8SizeInBytes) .append(" / ").append(int8AlignmentInBytes);
+ sb.append(", int16 ").append(int16SizeInBytes) .append(" / ").append(int16AlignmentInBytes).append(Platform.getNewline());
+ sb.append(" int ").append(intSizeInBytes) .append(" / ").append(intAlignmentInBytes);
+ sb.append(", long ").append(longSizeInBytes) .append(" / ").append(longAlignmentInBytes).append(Platform.getNewline());
+ sb.append(" int32 ").append(int32SizeInBytes) .append(" / ").append(int32AlignmentInBytes);
+ sb.append(", int64 ").append(int64SizeInBytes) .append(" / ").append(int64AlignmentInBytes).append(Platform.getNewline());
+ sb.append(" float ").append(floatSizeInBytes) .append(" / ").append(floatAlignmentInBytes);
+ sb.append(", double ").append(doubleSizeInBytes) .append(" / ").append(doubleAlignmentInBytes);
+ sb.append(", ldouble ").append(ldoubleSizeInBytes).append(" / ").append(ldoubleAlignmentInBytes).append(Platform.getNewline());
+ sb.append(" pointer ").append(pointerSizeInBytes).append(" / ").append(pointerAlignmentInBytes);
+ sb.append(", page ").append(pageSizeInBytes);
+ return sb;
+ }
- @Override
- public String toString() {
- return toString(null).toString();
- }
+ @Override
+ public String toString() {
+ return toString(null).toString();
+ }
}
diff --git a/src/java/com/jogamp/common/os/Platform.java b/src/java/com/jogamp/common/os/Platform.java
index 85567a8..4db5b09 100644
--- a/src/java/com/jogamp/common/os/Platform.java
+++ b/src/java/com/jogamp/common/os/Platform.java
@@ -28,9 +28,14 @@
package com.jogamp.common.os;
+import java.nio.ByteBuffer;
+import java.nio.IntBuffer;
+import java.nio.ShortBuffer;
import java.security.AccessController;
import java.security.PrivilegedAction;
+import com.jogamp.common.nio.Buffers;
+
import jogamp.common.os.MachineDescriptionRuntime;
/**
@@ -41,6 +46,7 @@ import jogamp.common.os.MachineDescriptionRuntime;
public class Platform {
public static final boolean JAVA_SE;
+ public static final boolean LITTLE_ENDIAN;
public static final String OS;
public static final String OS_lower;
public static final String OS_VERSION;
@@ -139,6 +145,8 @@ public class Platform {
JAVA_SE = initIsJavaSE();
+ LITTLE_ENDIAN = queryIsLittleEndianImpl();
+
if( ARCH_lower.equals("x86") ||
ARCH_lower.equals("i386") ||
ARCH_lower.equals("i486") ||
@@ -171,13 +179,34 @@ public class Platform {
}
OS_TYPE = getOSTypeImpl();
- machineDescription = MachineDescriptionRuntime.getMachineDescription(getIs32BitByCPUArchImpl());
+ MachineDescription md = MachineDescriptionRuntime.getRuntime();
+ if(null == md) {
+ MachineDescription.StaticConfig smd = MachineDescriptionRuntime.getStatic();
+ md = smd.md;
+ System.err.println("Warning: Using static MachineDescription: "+smd);
+ } else {
+ MachineDescription.StaticConfig smd = MachineDescriptionRuntime.getStatic();
+ if(!md.compatible(smd.md)) {
+ throw new RuntimeException("Incompatible MachineDescriptions:"+Platform.NEWLINE+
+ " Static "+smd+Platform.NEWLINE+
+ " Runtime "+md);
+ }
+ }
+ machineDescription = md;
is32Bit = machineDescription.is32Bit();
}
private Platform() {}
- private static boolean getIs32BitByCPUArchImpl() throws RuntimeException {
+ private static boolean queryIsLittleEndianImpl() {
+ ByteBuffer tst_b = Buffers.newDirectByteBuffer(Buffers.SIZEOF_INT); // 32bit in native order
+ IntBuffer tst_i = tst_b.asIntBuffer();
+ ShortBuffer tst_s = tst_b.asShortBuffer();
+ tst_i.put(0, 0x0A0B0C0D);
+ return 0x0C0D == tst_s.get(0);
+ }
+
+ public static boolean isCPUArch32Bit() throws RuntimeException {
switch( CPU_ARCH ) {
case X86_32:
case ARM:
@@ -257,6 +286,13 @@ public class Platform {
}
/**
+ * Returns true if this machine is little endian, otherwise false.
+ */
+ public static boolean isLittleEndian() {
+ return LITTLE_ENDIAN;
+ }
+
+ /**
* Returns the OS name.
*/
public static String getOS() {
diff --git a/src/java/com/jogamp/gluegen/DebugEmitter.java b/src/java/com/jogamp/gluegen/DebugEmitter.java
index 6afc55c..ce6ae69 100644
--- a/src/java/com/jogamp/gluegen/DebugEmitter.java
+++ b/src/java/com/jogamp/gluegen/DebugEmitter.java
@@ -52,9 +52,6 @@ public class DebugEmitter implements GlueEmitter {
public void readConfigurationFile(String filename) {}
- public void setMachineDescription(MachineDescription md32,
- MachineDescription md64) {}
-
public void beginEmission(GlueEmitterControls controls) {
System.out.println("----- BEGIN EMISSION OF GLUE CODE -----");
}
diff --git a/src/java/com/jogamp/gluegen/GlueEmitter.java b/src/java/com/jogamp/gluegen/GlueEmitter.java
index ac1065b..99bf31d 100644
--- a/src/java/com/jogamp/gluegen/GlueEmitter.java
+++ b/src/java/com/jogamp/gluegen/GlueEmitter.java
@@ -54,26 +54,6 @@ public interface GlueEmitter {
public void readConfigurationFile(String filename) throws Exception;
- /** Sets the description of the underlying hardware. "md32"
- specifies the description of a 32-bit version of the underlying
- CPU architecture. "md64" specifies the description of a 64-bit
- version of the underlying CPU architecture. At least one must be
- specified. When both are specified, the bulk of the glue code is
- generated using the 32-bit machine description, but structs are
- laid out twice and the base class delegates between the 32-bit
- and 64-bit implementation at run time. This allows Java code
- which can access both 32-bit and 64-bit versions of the data
- structures to be included in the same jar file. <P>
-
- It is up to the end user to provide the appropriate opaque
- definitions to ensure that types of varying size (longs and
- pointers in particular) are exposed to Java in such a way that
- changing the machine description does not cause different shared
- glue code to be generated for the 32- and 64-bit ports.
- */
- public void setMachineDescription(MachineDescription md32,
- MachineDescription md64);
-
/**
* Begin the emission of glue code. This might include opening files,
* emitting class headers, etc.
diff --git a/src/java/com/jogamp/gluegen/GlueGen.java b/src/java/com/jogamp/gluegen/GlueGen.java
index c0e87ee..744d526 100644
--- a/src/java/com/jogamp/gluegen/GlueGen.java
+++ b/src/java/com/jogamp/gluegen/GlueGen.java
@@ -188,11 +188,6 @@ public class GlueGen implements GlueEmitterControls {
}
}
- // Provide MachineDescriptions to emitter
- final MachineDescription md32 = MachineDescription.createStaticUnix32();
- final MachineDescription md64 = MachineDescription.createStaticUnix64();
- emit.setMachineDescription(md32, md64);
-
// Repackage the enum and #define statements from the parser into a common format
// so that SymbolFilters can operate upon both identically
constants = new ArrayList<ConstantDefinition>();
diff --git a/src/java/com/jogamp/gluegen/JavaEmitter.java b/src/java/com/jogamp/gluegen/JavaEmitter.java
index dfa7594..c68fae8 100644
--- a/src/java/com/jogamp/gluegen/JavaEmitter.java
+++ b/src/java/com/jogamp/gluegen/JavaEmitter.java
@@ -60,6 +60,8 @@ import com.jogamp.gluegen.runtime.types.Type;
import java.nio.Buffer;
import java.util.logging.Logger;
+import jogamp.common.os.MachineDescriptionRuntime;
+
import static java.util.logging.Level.*;
import static com.jogamp.gluegen.JavaEmitter.MethodAccess.*;
@@ -97,9 +99,9 @@ public class JavaEmitter implements GlueEmitter {
private PrintWriter javaWriter; // Emits either interface or, in AllStatic mode, everything
private PrintWriter javaImplWriter; // Only used in non-AllStatic modes for impl class
private PrintWriter cWriter;
- private MachineDescription machDesc32;
- private MachineDescription machDesc64;
-
+ private final MachineDescription machDescJava = MachineDescription.StaticConfig.X86_64_UNIX.md;
+ private final MachineDescription.StaticConfig[] machDescTargetConfigs = MachineDescription.StaticConfig.values();
+
protected final static Logger LOG = Logger.getLogger(JavaEmitter.class.getPackage().getName());
public void readConfigurationFile(String filename) throws Exception {
@@ -107,16 +109,6 @@ public class JavaEmitter implements GlueEmitter {
cfg.read(filename);
}
- public void setMachineDescription(MachineDescription md32, MachineDescription md64) {
-
- if ((md32 == null) && (md64 == null)) {
- throw new RuntimeException("Must specify at least one MachineDescription");
- }
-
- machDesc32 = md32;
- machDesc64 = md64;
- }
-
class ConstantRenamer implements SymbolFilter {
private List<ConstantDefinition> constants;
@@ -615,7 +607,7 @@ public class JavaEmitter implements GlueEmitter {
cfg.allStatic(),
(binding.needsNIOWrappingOrUnwrapping() || hasPrologueOrEpilogue),
!cfg.nioDirectOnly(binding.getName()),
- machDesc64);
+ machDescJava);
prepCEmitter(binding, cEmitter);
allEmitters.add(cEmitter);
}
@@ -663,7 +655,7 @@ public class JavaEmitter implements GlueEmitter {
try {
// Get Java binding for the function
- MethodBinding mb = bindFunction(sym, null, null, machDesc64);
+ MethodBinding mb = bindFunction(sym, null, null, machDescJava);
// JavaTypes representing C pointers in the initial
// MethodBinding have not been lowered yet to concrete types
@@ -771,19 +763,6 @@ public class JavaEmitter implements GlueEmitter {
}
public void emitStruct(CompoundType structType, String alternateName) throws Exception {
- // Emit abstract base class delegating to 32-bit or 64-bit implementations
- emitStructImpl(structType, alternateName, machDesc32, machDesc64, true, false);
- // Emit concrete implementing class for each variant
- emitStructImpl(structType, alternateName, machDesc32, machDesc64, false, true);
- emitStructImpl(structType, alternateName, machDesc32, machDesc64, false, false);
- }
-
- public void emitStructImpl(CompoundType structType,
- String alternateName,
- MachineDescription md32,
- MachineDescription md64,
- boolean doBaseClass,
- boolean do32Bit) throws Exception {
String name = structType.getName();
if (name == null && alternateName != null) {
name = alternateName;
@@ -805,50 +784,31 @@ public class JavaEmitter implements GlueEmitter {
}
String containingTypeName = containingType.getName();
- if ((md32 == null) || (md64 == null)) {
- throw new RuntimeException("Must supply both 32- and 64-bit MachineDescriptions to emitStructImpl");
- }
- String suffix = "";
-
- // The "external" MachineDescription is the one used to determine
- // the sizes of the primitive types seen in the public API. For
- // example, if a C long is an element of a struct, it is the size
+ // machDescJava global MachineDescription is the one used to determine
+ // the sizes of the primitive types seen in the public API in Java.
+ // For example, if a C long is an element of a struct, it is the size
// of a Java int on a 32-bit machine but the size of a Java long
// on a 64-bit machine. To support both of these sizes with the
// same API, the abstract base class must take and return a Java
// long from the setter and getter for this field. However the
// implementation on a 32-bit platform must downcast this to an
- // int and set only an int's worth of data in the struct. The
- // "internal" MachineDescription is the one used to determine how
+ // int and set only an int's worth of data in the struct.
+ //
+ // The machDescTarget MachineDescription is the one used to determine how
// much data to set in or get from the struct and exactly from
// where it comes.
//
- // Note that the 64-bit MachineDescription is always used as the
- // external MachineDescription.
-
- MachineDescription extMachDesc = md64;
- MachineDescription intMachDesc = null;
-
- if (!doBaseClass) {
- if (do32Bit) {
- intMachDesc = md32;
- suffix = "32";
- } else {
- intMachDesc = md64;
- suffix = "64";
- }
- }
+ // Note that machDescJava MachineDescription is always 64bit unix,
+ // which complies w/ Java types.
boolean needsNativeCode = false;
// Native code for calls through function pointers gets emitted
// into the abstract base class; Java code which accesses fields
// gets emitted into the concrete classes
- if (doBaseClass) {
- for (int i = 0; i < structType.getNumFields(); i++) {
- if (structType.getField(i).getType().isFunctionPointer()) {
- needsNativeCode = true;
- break;
- }
+ for (int i = 0; i < structType.getNumFields(); i++) {
+ if (structType.getField(i).getType().isFunctionPointer()) {
+ needsNativeCode = true;
+ break;
}
}
@@ -859,7 +819,7 @@ public class JavaEmitter implements GlueEmitter {
writer = openFile(
cfg.javaOutputDir() + File.separator +
CodeGenUtils.packageAsPath(structClassPkg) +
- File.separator + containingTypeName + suffix + ".java");
+ File.separator + containingTypeName + ".java");
CodeGenUtils.emitAutogeneratedWarning(writer, this);
if (needsNativeCode) {
String nRoot = cfg.nativeOutputDir();
@@ -883,6 +843,7 @@ public class JavaEmitter implements GlueEmitter {
writer.println("import " + cfg.gluegenRuntimePackage() + ".*;");
writer.println("import " + DynamicLookupHelper.class.getPackage().getName() + ".*;");
writer.println("import " + Buffers.class.getPackage().getName() + ".*;");
+ writer.println("import " + MachineDescriptionRuntime.class.getName() + ";");
writer.println();
List<String> imports = cfg.imports();
for (String str : imports) {
@@ -895,10 +856,7 @@ public class JavaEmitter implements GlueEmitter {
for (String doc : javadoc) {
writer.println(doc);
}
- writer.print((doBaseClass ? "public " : "") + (doBaseClass ? "abstract " : "") + "class " + containingTypeName + suffix + " ");
- if (!doBaseClass) {
- writer.print("extends " + containingTypeName + " ");
- }
+ writer.print("public class " + containingTypeName + " ");
boolean firstIteration = true;
List<String> userSpecifiedInterfaces = cfg.implementedInterfaces(containingTypeName);
for (String userInterface : userSpecifiedInterfaces) {
@@ -911,67 +869,95 @@ public class JavaEmitter implements GlueEmitter {
}
writer.println("{");
writer.println();
- if (doBaseClass) {
- writer.println(" StructAccessor accessor;");
- writer.println();
- }
+ writer.println(" StructAccessor accessor;");
+ writer.println();
+ writer.println(" private static final int mdIdx = MachineDescriptionRuntime.getStatic().ordinal();");
+ writer.println();
+ // generate all offset and size arrays
+ generateOffsetAndSizeArrays(writer, containingTypeName, structType, null); /* w/o offset */
+ for (int i = 0; i < structType.getNumFields(); i++) {
+ final Field field = structType.getField(i);
+ final Type fieldType = field.getType();
+
+ if (!cfg.shouldIgnoreInInterface(name + " " + field.getName())) {
+ final String renamed = cfg.getJavaSymbolRename(field.getName());
+ final String fieldName = renamed==null ? field.getName() : renamed;
+ if (fieldType.isFunctionPointer()) {
+ // no offset/size for function pointer ..
+ } else if (fieldType.isCompound()) {
+ // FIXME: will need to support this at least in order to
+ // handle the union in jawt_Win32DrawingSurfaceInfo (fabricate
+ // a name?)
+ if (fieldType.getName() == null) {
+ throw new RuntimeException("Anonymous structs as fields not supported yet (field \"" +
+ field + "\" in type \"" + name + "\")");
+ }
+
+ generateOffsetAndSizeArrays(writer, fieldName, fieldType, field);
+ } else if (fieldType.isArray()) {
+ Type baseElementType = field.getType().asArray().getBaseElementType();
+
+ if(!baseElementType.isPrimitive())
+ break;
+
+ generateOffsetAndSizeArrays(writer, fieldName, null, field); /* w/o size */
+ } else {
+ JavaType externalJavaType = null;
+ try {
+ externalJavaType = typeToJavaType(fieldType, false, machDescJava);
+ } catch (Exception e) {
+ System.err.println("Error occurred while creating accessor for field \"" +
+ field.getName() + "\" in type \"" + name + "\"");
+ throw(e);
+ }
+ if (externalJavaType.isPrimitive()) {
+ // Primitive type
+ generateOffsetAndSizeArrays(writer, fieldName, null, field); /* w/o size */
+ } else {
+ // FIXME
+ LOG.log(WARNING, "Complicated fields (field \"{0}\" of type \"{1}\") not implemented yet", new Object[]{field, name});
+ // throw new RuntimeException("Complicated fields (field \"" + field + "\" of type \"" + t +
+ // "\") not implemented yet");
+ }
+ }
+ }
+ }
+ writer.println();
writer.println(" public static int size() {");
- if (doBaseClass) {
- writer.println(" if (Platform.is32Bit()) {");
- writer.println(" return " + containingTypeName + "32" + ".size();");
- writer.println(" } else {");
- writer.println(" return " + containingTypeName + "64" + ".size();");
- writer.println(" }");
- } else {
- writer.println(" return " + structType.getSize(intMachDesc) + ";");
- }
+ writer.println(" return "+containingTypeName+"_size[mdIdx];");
writer.println(" }");
writer.println();
- if (doBaseClass) {
- writer.println(" public static " + containingTypeName + " create() {");
- writer.println(" return create(Buffers.newDirectByteBuffer(size()));");
- writer.println(" }");
- writer.println();
- writer.println(" public static " + containingTypeName + " create(java.nio.ByteBuffer buf) {");
- writer.println(" if (Platform.is32Bit()) {");
- writer.println(" return new " + containingTypeName + "32(buf);");
- writer.println(" } else {");
- writer.println(" return new " + containingTypeName + "64(buf);");
- writer.println(" }");
- writer.println(" }");
- writer.println();
- writer.println(" " + containingTypeName + "(java.nio.ByteBuffer buf) {");
- writer.println(" accessor = new StructAccessor(buf);");
- writer.println(" }");
- writer.println();
- writer.println(" public java.nio.ByteBuffer getBuffer() {");
- writer.println(" return accessor.getBuffer();");
- writer.println(" }");
- } else {
- writer.println(" " + containingTypeName + suffix + "(java.nio.ByteBuffer buf) {");
- writer.println(" super(buf);");
- writer.println(" }");
- writer.println();
- }
- for (int i = 0; i < structType.getNumFields(); i++) {
+ writer.println(" public static " + containingTypeName + " create() {");
+ writer.println(" return create(Buffers.newDirectByteBuffer(size()));");
+ writer.println(" }");
+ writer.println();
+ writer.println(" public static " + containingTypeName + " create(java.nio.ByteBuffer buf) {");
+ writer.println(" return new " + containingTypeName + "(buf);");
+ writer.println(" }");
+ writer.println();
+ writer.println(" " + containingTypeName + "(java.nio.ByteBuffer buf) {");
+ writer.println(" accessor = new StructAccessor(buf);");
+ writer.println(" }");
+ writer.println();
+ writer.println(" public java.nio.ByteBuffer getBuffer() {");
+ writer.println(" return accessor.getBuffer();");
+ writer.println(" }");
- Field field = structType.getField(i);
- Type fieldType = field.getType();
+ for (int i = 0; i < structType.getNumFields(); i++) {
+ final Field field = structType.getField(i);
+ final Type fieldType = field.getType();
if (!cfg.shouldIgnoreInInterface(name + " " + field.getName())) {
-
- String renamed = cfg.getJavaSymbolRename(field.getName());
- String fieldName = renamed==null ? field.getName() : renamed;
+ final String renamed = cfg.getJavaSymbolRename(field.getName());
+ final String fieldName = renamed==null ? field.getName() : renamed;
if (fieldType.isFunctionPointer()) {
-
- if (doBaseClass) {
try {
// Emit method call and associated native code
FunctionType funcType = fieldType.asPointer().getTargetType().asFunction();
FunctionSymbol funcSym = new FunctionSymbol(fieldName, funcType);
- MethodBinding binding = bindFunction(funcSym, containingType, containingCType, machDesc64);
+ MethodBinding binding = bindFunction(funcSym, containingType, containingCType, machDescJava);
binding.findThisPointer(); // FIXME: need to provide option to disable this on per-function basis
writer.println();
@@ -1024,14 +1010,13 @@ public class JavaEmitter implements GlueEmitter {
false,
true,
false, // FIXME: should unify this with the general emission code
- machDesc64);
+ machDescJava);
prepCEmitter(binding, cEmitter);
cEmitter.emit();
} catch (Exception e) {
System.err.println("While processing field " + field + " of type " + name + ":");
throw(e);
}
- }
} else if (fieldType.isCompound()) {
// FIXME: will need to support this at least in order to
// handle the union in jawt_Win32DrawingSurfaceInfo (fabricate
@@ -1042,15 +1027,11 @@ public class JavaEmitter implements GlueEmitter {
}
writer.println();
- generateGetterSignature(writer, doBaseClass, fieldType.getName(), capitalizeString(fieldName));
- if (doBaseClass) {
- writer.println(";");
- } else {
- writer.println(" {");
- writer.println(" return " + fieldType.getName() + ".create(accessor.slice(" +
- field.getOffset(intMachDesc) + ", " + fieldType.getSize(intMachDesc) + "));");
- writer.println(" }");
- }
+ generateGetterSignature(writer, false, fieldType.getName(), capitalizeString(fieldName));
+ writer.println(" {");
+ writer.println(" return " + fieldType.getName() + ".create( accessor.slice( " +
+ fieldName+"_offset[mdIdx], "+fieldName+"_size[mdIdx] ) );");
+ writer.println(" }");
} else if (fieldType.isArray()) {
@@ -1059,110 +1040,70 @@ public class JavaEmitter implements GlueEmitter {
if(!baseElementType.isPrimitive())
break;
- String paramType = typeToJavaType(baseElementType, false, extMachDesc).getName();
+ String paramType = typeToJavaType(baseElementType, false, machDescJava).getName();
String capitalized = capitalizeString(fieldName);
- final int byteOffset = doBaseClass ? -1 : (int) field.getOffset(intMachDesc);
-
// Setter
writer.println();
- generateSetterSignature(writer, doBaseClass, containingTypeName, capitalized, paramType+"[]");
- if (doBaseClass) {
- writer.println(";");
- } else {
- writer.println(" {");
- writer.print (" accessor.set" + capitalizeString(paramType) + "sAt(" + byteOffset + ", ");
- writer.println("val);");
- writer.println(" return this;");
- writer.println(" }");
- }
+ generateSetterSignature(writer, false, containingTypeName, capitalized, paramType+"[]");
+ writer.println(" {");
+ writer.print (" accessor.set" + capitalizeString(paramType) + "sAt(" + fieldName+"_offset[mdIdx], val);");
+ writer.println(" return this;");
+ writer.println(" }");
writer.println();
// Getter
- generateGetterSignature(writer, doBaseClass, paramType+"[]", capitalized);
- if (doBaseClass) {
- writer.println(";");
- } else {
- writer.println(" {");
- writer.print (" return ");
- writer.println("accessor.get" + capitalizeString(paramType) + "sAt(" + byteOffset + ", new " +paramType+"["+fieldType.asArray().getLength()+"]);");
- writer.println(" }");
- }
-
+ generateGetterSignature(writer, false, paramType+"[]", capitalized);
+ writer.println(" {");
+ writer.print (" return accessor.get" + capitalizeString(paramType) + "sAt(" + fieldName+"_offset[mdIdx], new " +paramType+"["+fieldType.asArray().getLength()+"]);");
+ writer.println(" }");
} else {
- JavaType internalJavaType = null;
- JavaType externalJavaType = null;
-
+ JavaType javaType = null;
+
try {
- externalJavaType = typeToJavaType(fieldType, false, extMachDesc);
- if (!doBaseClass) {
- internalJavaType = typeToJavaType(fieldType, false, intMachDesc);
- }
+ javaType = typeToJavaType(fieldType, false, machDescJava);
} catch (Exception e) {
System.err.println("Error occurred while creating accessor for field \"" +
field.getName() + "\" in type \"" + name + "\"");
throw(e);
}
- if (externalJavaType.isPrimitive()) {
+ if (javaType.isPrimitive()) {
// Primitive type
- String externalJavaTypeName = null;
- String internalJavaTypeName = null;
- externalJavaTypeName = externalJavaType.getName();
- if (!doBaseClass) {
- internalJavaTypeName = internalJavaType.getName();
- }
+ final boolean fieldTypeNativeSizeFixed = fieldType.getSize().hasFixedNativeSize() || isOpaque(fieldType) ;
+ String javaTypeName = javaType.getName();
if (isOpaque(fieldType)) {
- externalJavaTypeName = compatiblePrimitiveJavaTypeName(fieldType, externalJavaType, extMachDesc);
- if (!doBaseClass) {
- internalJavaTypeName = compatiblePrimitiveJavaTypeName(fieldType, internalJavaType, intMachDesc);
- }
- }
- String capitalized = null;
- if (!doBaseClass) {
- capitalized = capitalizeString(internalJavaTypeName);
+ javaTypeName = compatiblePrimitiveJavaTypeName(fieldType, javaType, machDescJava);
}
- final int byteOffset = doBaseClass ? -1 : (int) field.getOffset(intMachDesc);
+ String capJavaTypeName = capitalizeString(javaTypeName);
+
writer.println();
- String capitalizedFieldName = capitalizeString(fieldName);
+ String capFieldName = capitalizeString(fieldName);
// Setter
- generateSetterSignature(writer, doBaseClass, containingTypeName, capitalizedFieldName, externalJavaTypeName);
- if (doBaseClass) {
- writer.println(";");
+ generateSetterSignature(writer, false, containingTypeName, capFieldName, javaTypeName);
+ writer.println(" {");
+ if( fieldTypeNativeSizeFixed ) {
+ writer.println(" accessor.set" + capJavaTypeName + "At(" + fieldName+"_offset[mdIdx], val);");
} else {
- writer.println(" {");
- writer.print (" accessor.set" + capitalized + "At(" + byteOffset + ", ");
- if (!externalJavaTypeName.equals(internalJavaTypeName)) {
- writer.print("(" + internalJavaTypeName + ") ");
- }
- writer.println("val);");
- writer.println(" return this;");
- writer.println(" }");
+ writer.println(" accessor.set" + capJavaTypeName + "At(" + fieldName+"_offset[mdIdx], val, MachineDescriptionRuntime.getStatic().md."+javaTypeName+"SizeInBytes());");
}
+ writer.println(" return this;");
+ writer.println(" }");
writer.println();
+
// Getter
- generateGetterSignature(writer, doBaseClass, externalJavaTypeName, capitalizedFieldName);
- if (doBaseClass) {
- writer.println(";");
+ generateGetterSignature(writer, false, javaTypeName, capFieldName);
+ writer.println(" {");
+ writer.print (" return ");
+ if( fieldTypeNativeSizeFixed ) {
+ writer.println("accessor.get" + capJavaTypeName + "At(" + fieldName+"_offset[mdIdx]);");
} else {
- writer.println(" {");
- writer.print (" return ");
- if (!externalJavaTypeName.equals(internalJavaTypeName)) {
- writer.print("(" + externalJavaTypeName + ") ");
- }
- writer.println("accessor.get" + capitalized + "At(" + byteOffset + ");");
- writer.println(" }");
- }
- } else {
- // FIXME
- LOG.log(WARNING, "Complicated fields (field \"{0}\" of type \"{1}\") not implemented yet", new Object[]{field, name});
- // throw new RuntimeException("Complicated fields (field \"" + field + "\" of type \"" + t +
- // "\") not implemented yet");
+ writer.println("accessor.get" + capJavaTypeName + "At(" + fieldName+"_offset[mdIdx], MachineDescriptionRuntime.getStatic().md."+javaTypeName+"SizeInBytes());");
+ }
+ writer.println(" }");
}
}
}
}
- if (doBaseClass) {
- emitCustomJavaCode(writer, containingTypeName);
- }
+ emitCustomJavaCode(writer, containingTypeName);
writer.println("}");
writer.flush();
writer.close();
@@ -1201,14 +1142,39 @@ public class JavaEmitter implements GlueEmitter {
// Internals only below this point
//
- private void generateGetterSignature(PrintWriter writer, boolean baseClass, String returnTypeName, String capitalizedFieldName) {
- writer.print(" public " + (baseClass ? "abstract " : "") + returnTypeName + " get" + capitalizedFieldName + "()");
- }
+ private void generateGetterSignature(PrintWriter writer, boolean abstractMethod, String returnTypeName, String capitalizedFieldName) {
+ writer.print(" public " + (abstractMethod ? "abstract " : "") + returnTypeName + " get" + capitalizedFieldName + "()");
+ }
- private void generateSetterSignature(PrintWriter writer, boolean baseClass, String returnTypeName, String capitalizedFieldName, String paramTypeName) {
- writer.print(" public " + (baseClass ? "abstract " : "") + returnTypeName + " set" + capitalizedFieldName + "(" + paramTypeName + " val)");
- }
+ private void generateSetterSignature(PrintWriter writer, boolean abstractMethod, String returnTypeName, String capitalizedFieldName, String paramTypeName) {
+ writer.print(" public " + (abstractMethod ? "abstract " : "") + returnTypeName + " set" + capitalizedFieldName + "(" + paramTypeName + " val)");
+ }
+ private void generateOffsetAndSizeArrays(PrintWriter writer, String fieldName, Type fieldType, Field field) {
+ if(null != field) {
+ writer.print(" private static final int[] "+fieldName+"_offset = new int[] { ");
+ for( int i=0; i < machDescTargetConfigs.length; i++ ) {
+ if(0<i) {
+ writer.print(", ");
+ }
+ writer.print(field.getOffset(machDescTargetConfigs[i].md) +
+ " /* " + machDescTargetConfigs[i].name() + " */");
+ }
+ writer.println(" };");
+ }
+ if(null!=fieldType) {
+ writer.print(" private static final int[] "+fieldName+"_size = new int[] { ");
+ for( int i=0; i < machDescTargetConfigs.length; i++ ) {
+ if(0<i) {
+ writer.print(", ");
+ }
+ writer.print(fieldType.getSize(machDescTargetConfigs[i].md) +
+ " /* " + machDescTargetConfigs[i].name() + " */");
+ }
+ writer.println(" };");
+ }
+ }
+
private JavaType typeToJavaType(Type cType, boolean outgoingArgument, MachineDescription curMachDesc) {
// Recognize JNIEnv* case up front
PointerType opt = cType.asPointer();
diff --git a/src/java/com/jogamp/gluegen/runtime/types/SizeThunk.java b/src/java/com/jogamp/gluegen/runtime/types/SizeThunk.java
index b9d4eda..3b36957 100755
--- a/src/java/com/jogamp/gluegen/runtime/types/SizeThunk.java
+++ b/src/java/com/jogamp/gluegen/runtime/types/SizeThunk.java
@@ -47,10 +47,11 @@ import com.jogamp.common.os.MachineDescription;
generating glue code for two different CPU architectures (e.g.,
32-bit and 64-bit) from the same internal representation of the
various types involved. */
-
public abstract class SizeThunk implements Cloneable {
+ private boolean fixedNativeSize;
+
// Private constructor because there are only a few of these
- private SizeThunk() {}
+ private SizeThunk(boolean fixedNativeSize) { this.fixedNativeSize = fixedNativeSize; }
public Object clone() {
try {
@@ -59,11 +60,13 @@ public abstract class SizeThunk implements Cloneable {
throw new InternalError();
}
}
+
+ public final boolean hasFixedNativeSize() { return fixedNativeSize; }
public abstract long computeSize(MachineDescription machDesc);
public abstract long computeAlignment(MachineDescription machDesc);
- public static final SizeThunk INT8 = new SizeThunk() {
+ public static final SizeThunk INT8 = new SizeThunk(true) {
public long computeSize(MachineDescription machDesc) {
return machDesc.int8SizeInBytes();
}
@@ -72,7 +75,7 @@ public abstract class SizeThunk implements Cloneable {
}
};
- public static final SizeThunk INT16 = new SizeThunk() {
+ public static final SizeThunk INT16 = new SizeThunk(true) {
public long computeSize(MachineDescription machDesc) {
return machDesc.int16SizeInBytes();
}
@@ -81,7 +84,7 @@ public abstract class SizeThunk implements Cloneable {
}
};
- public static final SizeThunk INT32 = new SizeThunk() {
+ public static final SizeThunk INT32 = new SizeThunk(true) {
public long computeSize(MachineDescription machDesc) {
return machDesc.int32SizeInBytes();
}
@@ -90,7 +93,7 @@ public abstract class SizeThunk implements Cloneable {
}
};
- public static final SizeThunk INTxx = new SizeThunk() {
+ public static final SizeThunk INTxx = new SizeThunk(false) {
public long computeSize(MachineDescription machDesc) {
return machDesc.intSizeInBytes();
}
@@ -99,7 +102,7 @@ public abstract class SizeThunk implements Cloneable {
}
};
- public static final SizeThunk LONG = new SizeThunk() {
+ public static final SizeThunk LONG = new SizeThunk(false) {
public long computeSize(MachineDescription machDesc) {
return machDesc.longSizeInBytes();
}
@@ -108,7 +111,7 @@ public abstract class SizeThunk implements Cloneable {
}
};
- public static final SizeThunk INT64 = new SizeThunk() {
+ public static final SizeThunk INT64 = new SizeThunk(true) {
public long computeSize(MachineDescription machDesc) {
return machDesc.int64SizeInBytes();
}
@@ -117,7 +120,7 @@ public abstract class SizeThunk implements Cloneable {
}
};
- public static final SizeThunk FLOAT = new SizeThunk() {
+ public static final SizeThunk FLOAT = new SizeThunk(true) {
public long computeSize(MachineDescription machDesc) {
return machDesc.floatSizeInBytes();
}
@@ -126,7 +129,7 @@ public abstract class SizeThunk implements Cloneable {
}
};
- public static final SizeThunk DOUBLE = new SizeThunk() {
+ public static final SizeThunk DOUBLE = new SizeThunk(true) {
public long computeSize(MachineDescription machDesc) {
return machDesc.doubleSizeInBytes();
}
@@ -135,7 +138,7 @@ public abstract class SizeThunk implements Cloneable {
}
};
- public static final SizeThunk POINTER = new SizeThunk() {
+ public static final SizeThunk POINTER = new SizeThunk(false) {
public long computeSize(MachineDescription machDesc) {
return machDesc.pointerSizeInBytes();
}
@@ -148,7 +151,7 @@ public abstract class SizeThunk implements Cloneable {
// arithmetic on these values
public static SizeThunk add(final SizeThunk thunk1,
final SizeThunk thunk2) {
- return new SizeThunk() {
+ return new SizeThunk(false) {
public long computeSize(MachineDescription machDesc) {
return thunk1.computeSize(machDesc) + thunk2.computeSize(machDesc);
}
@@ -162,7 +165,7 @@ public abstract class SizeThunk implements Cloneable {
public static SizeThunk mul(final SizeThunk thunk1,
final SizeThunk thunk2) {
- return new SizeThunk() {
+ return new SizeThunk(false) {
public long computeSize(MachineDescription machDesc) {
return thunk1.computeSize(machDesc) * thunk2.computeSize(machDesc);
}
@@ -176,7 +179,7 @@ public abstract class SizeThunk implements Cloneable {
public static SizeThunk align(final SizeThunk offsetThunk,
final SizeThunk alignmentThunk) {
- return new SizeThunk() {
+ return new SizeThunk(false) {
public long computeSize(MachineDescription machDesc) {
// x % 2n == x & (2n - 1)
// remainder = net_size & ( alignment - 1 )
@@ -201,7 +204,7 @@ public abstract class SizeThunk implements Cloneable {
public static SizeThunk max(final SizeThunk thunk1,
final SizeThunk thunk2) {
- return new SizeThunk() {
+ return new SizeThunk(false) {
public long computeSize(MachineDescription machDesc) {
return Math.max(thunk1.computeSize(machDesc), thunk2.computeSize(machDesc));
}
@@ -214,7 +217,7 @@ public abstract class SizeThunk implements Cloneable {
}
public static SizeThunk constant(final int constant) {
- return new SizeThunk() {
+ return new SizeThunk(false) {
public long computeSize(MachineDescription machDesc) {
return constant;
}
diff --git a/src/java/jogamp/common/os/MachineDescriptionRuntime.java b/src/java/jogamp/common/os/MachineDescriptionRuntime.java
index a5ecc1d..bf49105 100644
--- a/src/java/jogamp/common/os/MachineDescriptionRuntime.java
+++ b/src/java/jogamp/common/os/MachineDescriptionRuntime.java
@@ -28,64 +28,96 @@
package jogamp.common.os;
-import com.jogamp.common.nio.Buffers;
import com.jogamp.common.os.MachineDescription;
import com.jogamp.common.os.NativeLibrary;
import com.jogamp.common.os.Platform;
-
-import java.nio.ByteBuffer;
-import java.nio.IntBuffer;
-import java.nio.ShortBuffer;
+import com.jogamp.common.os.MachineDescription.StaticConfig;
/**
* Runtime MachineDescription
*/
public class MachineDescriptionRuntime {
- public static MachineDescription getMachineDescription(boolean is32BitByCPUArch) {
- boolean libsLoaded = true;
+ static volatile boolean smdQueried = false;
+ static MachineDescription.StaticConfig smd = null;
+
+ public static MachineDescription.StaticConfig getStatic() {
+ if(!smdQueried) {
+ synchronized(MachineDescription.class) { // volatile dbl-checked-locking OK
+ if(!smdQueried) {
+ smd = getStaticImpl();
+ smdQueried=true;
+ }
+ }
+ }
+ return smd;
+ }
+ private static MachineDescription.StaticConfig getStaticImpl() {
+ if(Platform.isCPUArch32Bit()) {
+ if(Platform.getCPUFamily() == Platform.CPUFamily.ARM && Platform.isLittleEndian()) {
+ return StaticConfig.ARMle_EABI;
+ } else if(Platform.getOSType() == Platform.OSType.WINDOWS) {
+ return StaticConfig.X86_32_WINDOWS;
+ }
+ return StaticConfig.X86_32_UNIX;
+ } else {
+ if(Platform.getOSType() == Platform.OSType.WINDOWS) {
+ return StaticConfig.X86_64_WINDOWS;
+ }
+ return StaticConfig.X86_64_UNIX;
+ }
+ }
+
+ static volatile boolean rmdQueried = false;
+ static MachineDescription rmd = null;
+
+ public static MachineDescription getRuntime() {
+ if(!rmdQueried) {
+ synchronized(MachineDescription.class) { // volatile dbl-checked-locking OK
+ if(!rmdQueried) {
+ rmd = getRuntimeImpl();
+ rmdQueried=true;
+ }
+ }
+ }
+ return rmd;
+ }
+ private static MachineDescription getRuntimeImpl() {
try {
NativeLibrary.ensureNativeLibLoaded();
} catch (UnsatisfiedLinkError err) {
- libsLoaded = false;
+ return null;
}
- if(libsLoaded) {
- int pointerSizeInBytes = getPointerSizeInBytesImpl();
- switch(pointerSizeInBytes) {
- case 4:
- case 8:
- break;
- default:
- throw new RuntimeException("Unsupported pointer size "+pointerSizeInBytes+"bytes, please implement.");
- }
-
- final long pageSizeL = getPageSizeInBytesImpl();
- if(Integer.MAX_VALUE < pageSizeL) {
- throw new InternalError("PageSize exceeds integer value: " + pageSizeL);
- }
-
- return getMachineDescriptionImpl(pointerSizeInBytes, (int) pageSizeL);
- } else {
- return MachineDescription.createStatic(is32BitByCPUArch);
+ int pointerSizeInBytes = getPointerSizeInBytesImpl();
+ switch(pointerSizeInBytes) {
+ case 4:
+ case 8:
+ break;
+ default:
+ throw new RuntimeException("Unsupported pointer size "+pointerSizeInBytes+"bytes, please implement.");
}
- }
- private static MachineDescription getMachineDescriptionImpl(int pointerSize, int pageSize) {
+ final long pageSizeL = getPageSizeInBytesImpl();
+ if(Integer.MAX_VALUE < pageSizeL) {
+ throw new InternalError("PageSize exceeds integer value: " + pageSizeL);
+ }
+
// size: int, long, float, double, pointer, pageSize
// alignment: int8, int16, int32, int64, int, long, float, double, pointer
return new MachineDescription(
- true /* runtime validated */, MachineDescription.queryIsLittleEndian(),
+ true /* runtime validated */, Platform.isLittleEndian(),
getSizeOfIntImpl(), getSizeOfLongImpl(),
- getSizeOfFloatImpl(), getSizeOfDoubleImpl(), getSizeOfLongDoubleImpl(), pointerSize, pageSize,
+ getSizeOfFloatImpl(), getSizeOfDoubleImpl(), getSizeOfLongDoubleImpl(),
+ pointerSizeInBytes, (int)pageSizeL,
getAlignmentInt8Impl(), getAlignmentInt16Impl(), getAlignmentInt32Impl(), getAlignmentInt64Impl(),
getAlignmentIntImpl(), getAlignmentLongImpl(),
getAlignmentFloatImpl(), getAlignmentDoubleImpl(), getAlignmentLongDoubleImpl(),
getAlignmentPointerImpl());
}
-
+
private static native int getPointerSizeInBytesImpl();
private static native long getPageSizeInBytesImpl();
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 df3df83..e73aca6 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java
@@ -30,12 +30,15 @@ package com.jogamp.gluegen.test.junit.generation;
import com.jogamp.common.nio.Buffers;
import com.jogamp.common.nio.PointerBuffer;
+import com.jogamp.common.os.MachineDescription;
import com.jogamp.common.os.Platform;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.IntBuffer;
import java.nio.LongBuffer;
+import jogamp.common.os.MachineDescriptionRuntime;
+
import org.junit.Assert;
@@ -553,33 +556,90 @@ public class BaseClass {
}
public void chapter09TestCompoundAndAlignment(Bindingtest1 binding) throws Exception {
- TK_ComplicatedSuperSet cs = binding.createComplicatedSuperSet();
- Assert.assertEquals((byte)0xA0, cs.getBits1());
-
- TK_ComplicatedSubSet sub1 = cs.getSub1();
- Assert.assertEquals((byte)0xA1, sub1.getBits1());
- Assert.assertEquals(0x12345678, sub1.getId());
- Assert.assertEquals((byte)0xA2, sub1.getBits2());
- Assert.assertEquals(0x123456789abcdef0L, sub1.getLong0());
- Assert.assertEquals((byte)0xA3, sub1.getBits3());
- Assert.assertEquals(3.1415926535897932384626433832795, sub1.getReal0(), 0.0);
- Assert.assertEquals((byte)0xA4, sub1.getBits4());
-
- Assert.assertEquals((byte)0xB0, cs.getBits2());
-
- TK_ComplicatedSubSet sub2 = cs.getSub2();
- Assert.assertEquals((byte)0xB1, sub2.getBits1());
- Assert.assertEquals(0x12345678, sub2.getId());
- Assert.assertEquals((byte)0xB2, sub2.getBits2());
- Assert.assertEquals(0x123456789abcdef0L, sub2.getLong0());
- Assert.assertEquals((byte)0xB3, sub2.getBits3());
- Assert.assertEquals(3.1415926535897932384626433832795, sub2.getReal0(), 0.0);
- Assert.assertEquals((byte)0xB4, sub2.getBits4());
- Assert.assertEquals((byte)0xC0, cs.getBits3());
+ MachineDescription.StaticConfig smd = MachineDescriptionRuntime.getStatic();
+ MachineDescription md = MachineDescriptionRuntime.getRuntime();
- binding.destroyComplicatedSuperSet(cs);
+ System.err.println("static md: "+smd);
+ System.err.println("runtime md: "+md);
+ System.err.println("compatible static/runtime: "+md.compatible(smd.md));
+ {
+ TK_ComplicatedSuperSet cs = binding.createComplicatedSuperSet();
+ Assert.assertEquals((byte)0xA0, cs.getBits1());
+
+ TK_ComplicatedSubSet sub1 = cs.getSub1();
+ Assert.assertEquals((byte)0xA1, sub1.getBits1());
+ Assert.assertEquals(0x12345678, sub1.getId());
+ Assert.assertEquals((byte)0xA2, sub1.getBits2());
+ Assert.assertEquals(0x123456789abcdef0L, sub1.getLong0());
+ Assert.assertEquals((byte)0xA3, sub1.getBits3());
+ Assert.assertEquals(3.1415926535897932384626433832795, sub1.getReal0(), 0.0);
+ Assert.assertEquals((byte)0xA4, sub1.getBits4());
+ Assert.assertEquals(256.12345f, sub1.getReal1(), 0.0);
+ Assert.assertEquals((byte)0xA5, sub1.getBits5());
+ Assert.assertEquals((long)0xdeadbeefL, sub1.getLongX());
+ Assert.assertEquals((byte)0xA6, sub1.getBits6());
+
+ Assert.assertEquals((byte)0xB0, cs.getBits2());
+
+ TK_ComplicatedSubSet sub2 = cs.getSub2();
+ Assert.assertEquals((byte)0xB1, sub2.getBits1());
+ Assert.assertEquals(0x12345678, sub2.getId());
+ Assert.assertEquals((byte)0xB2, sub2.getBits2());
+ Assert.assertEquals(0x123456789abcdef0L, sub2.getLong0());
+ Assert.assertEquals((byte)0xB3, sub2.getBits3());
+ Assert.assertEquals(3.1415926535897932384626433832795, sub2.getReal0(), 0.0);
+ Assert.assertEquals((byte)0xB4, sub2.getBits4());
+ Assert.assertEquals(256.12345f, sub2.getReal1(), 0.0);
+ Assert.assertEquals((byte)0xB5, sub2.getBits5());
+ Assert.assertEquals((long)0xdeadbeefL, sub2.getLongX());
+ Assert.assertEquals((byte)0xB6, sub2.getBits6());
+
+ Assert.assertEquals((byte)0xC0, cs.getBits3());
+
+ binding.destroyComplicatedSuperSet(cs);
+ }
+
+ /********************************************************************************/
+
+ {
+ TK_ComplicatedSuperSet cs = TK_ComplicatedSuperSet.create();
+ cs.setBits1((byte)0xA0);
+
+ TK_ComplicatedSubSet sub1 = cs.getSub1();
+ sub1.setBits1((byte)0xA1);
+ sub1.setId(0x12345678);
+ sub1.setBits2((byte)0xA2);
+ sub1.setLong0(0x123456789abcdef0L);
+ sub1.setBits3((byte)0xA3);
+ sub1.setReal0(3.1415926535897932384626433832795);
+ sub1.setBits4((byte)0xA4);
+ sub1.setReal1(256.12345f);
+ sub1.setBits5((byte)0xA5);
+ sub1.setLongX((long)0xdeadbeefL);
+ sub1.setBits6((byte)0xA6);
+
+ cs.setBits2((byte)0xB0);
+
+ TK_ComplicatedSubSet sub2 = cs.getSub2();
+ sub2.setBits1((byte)0xB1);
+ sub2.setId(0x12345678);
+ sub2.setBits2((byte)0xB2);
+ sub2.setLong0(0x123456789abcdef0L);
+ sub2.setBits3((byte)0xB3);
+ sub2.setReal0(3.1415926535897932384626433832795);
+ sub2.setBits4((byte)0xB4);
+ sub2.setReal1(256.12345f);
+ sub2.setBits5((byte)0xB5);
+ sub2.setLongX((long)0xdeadbeefL);
+ sub2.setBits6((byte)0xB6);
+
+ cs.setBits3((byte)0xC0);
+
+ Assert.assertTrue(binding.hasInitValues(cs));
+ }
+
/********************************************************************************/
TK_Surface surface = binding.createSurface();
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test1-common.cfg b/src/junit/com/jogamp/gluegen/test/junit/generation/test1-common.cfg
index c6e5415..17890eb 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1-common.cfg
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1-common.cfg
@@ -22,6 +22,7 @@ ReturnValueCapacity typeTestAnonPointer ARRAY_SIZE * sizeof(MYAPIConfig)
#
# typedef struct __MYAPIConfig * MYAPIConfig;
Opaque long MYAPIConfig
+Opaque boolean Bool
CustomCCode #include "test1.h"
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c
index 6d3117a..2d7aa71 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c
@@ -6,6 +6,8 @@
#include <stdio.h>
#include <string.h>
+#define DEBUG 1
+
MYAPI foo MYAPIENTRY nopTest() {
return 42;
}
@@ -279,6 +281,40 @@ MYAPI void MYAPIENTRY destroySurface(TK_Surface * surface) {
free(surface);
}
+static void dumpTK_ComplicatedSuperSet(TK_ComplicatedSuperSet * s) {
+ fprintf(stderr, "TK_ComplicatedSuperSet [\n");
+ fprintf(stderr, " cs.b1 0x%X\n", s->bits1);
+
+ fprintf(stderr, " cs.sub1.b1 0x%X\n", s->sub1.bits1);
+ fprintf(stderr, " cs.sub1.id 0x%X\n", s->sub1.id);
+ fprintf(stderr, " cs.sub1.b2 0x%X\n", s->sub1.bits2);
+ fprintf(stderr, " cs.sub1.long0 0x%lX\n", s->sub1.long0);
+ fprintf(stderr, " cs.sub1.b3 0x%X\n", s->sub1.bits3);
+ fprintf(stderr, " cs.sub1.real0 %G %A\n", s->sub1.real0, s->sub1.real0);
+ fprintf(stderr, " cs.sub1.b4 0x%X\n", s->sub1.bits4);
+ fprintf(stderr, " cs.sub1.real1 %G %A\n", (double)s->sub1.real1, (double)s->sub1.real1);
+ fprintf(stderr, " cs.sub1.b5 0x%X\n", s->sub1.bits5);
+ fprintf(stderr, " cs.sub1.longX 0x%lX\n", (int64_t)s->sub1.longX);
+ fprintf(stderr, " cs.sub1.b6 0x%X\n", s->sub1.bits6);
+
+ fprintf(stderr, " cs.b2 0x%X\n", s->bits2);
+
+ fprintf(stderr, " cs.sub2.b1 0x%X\n", s->sub2.bits1);
+ fprintf(stderr, " cs.sub2.id 0x%X\n", s->sub2.id);
+ fprintf(stderr, " cs.sub2.b2 0x%X\n", s->sub2.bits2);
+ fprintf(stderr, " cs.sub2.long0 0x%lX\n", s->sub2.long0);
+ fprintf(stderr, " cs.sub2.b3 0x%X\n", s->sub2.bits3);
+ fprintf(stderr, " cs.sub2.real0 %G %A\n", s->sub2.real0, s->sub2.real0);
+ fprintf(stderr, " cs.sub2.b4 0x%X\n", s->sub2.bits4);
+ fprintf(stderr, " cs.sub2.real1 %G %A\n", (double)s->sub2.real1, (double)s->sub2.real1);
+ fprintf(stderr, " cs.sub2.b5 0x%X\n", s->sub2.bits5);
+ fprintf(stderr, " cs.sub2.longX 0x%lX\n", (int64_t)s->sub2.longX);
+ fprintf(stderr, " cs.sub2.b6 0x%X\n", s->sub2.bits6);
+
+ fprintf(stderr, " cs.b3 0x%X\n", s->bits3);
+ fprintf(stderr, "]\n\n");
+}
+
MYAPI TK_ComplicatedSuperSet * MYAPIENTRY createComplicatedSuperSet() {
TK_ComplicatedSuperSet * s = calloc(1, sizeof(TK_ComplicatedSuperSet));
@@ -288,16 +324,24 @@ MYAPI TK_ComplicatedSuperSet * MYAPIENTRY createComplicatedSuperSet() {
s->sub1.bits2 = 0xA2U;
s->sub1.long0 = 0x123456789abcdef0UL;
s->sub1.bits3 = 0xA3U;
- s->sub1.real0 = 3.1415926535897932384626433832795L;
+ s->sub1.real0 = 3.1415926535897932384626433832795;
s->sub1.bits4 = 0xA4U;
+ s->sub1.real1 = 256.12345f;
+ s->sub1.bits5 = 0xA5U;
+ s->sub1.longX = (long) 0xdeadbeefU;
+ s->sub1.bits6 = 0xA6U;
s->bits2 = 0xB0U;
s->sub2.bits1 = 0xB1U;
s->sub2.id = 0x12345678U;
s->sub2.bits2 = 0xB2U;
s->sub2.long0 = 0x123456789abcdef0UL;
s->sub2.bits3 = 0xB3U;
- s->sub2.real0 = 3.1415926535897932384626433832795L;
+ s->sub2.real0 = 3.1415926535897932384626433832795;
s->sub2.bits4 = 0xB4U;
+ s->sub2.real1 = 256.12345f;
+ s->sub2.bits5 = 0xB5U;
+ s->sub2.longX = (long) 0xdeadbeefU;
+ s->sub2.bits6 = 0xB6U;
s->bits3 = 0xC0U;
fprintf(stderr, "TK_ComplicatedSubSet: sizeof(): %ld\n", (long) sizeof(TK_ComplicatedSubSet));
@@ -308,6 +352,10 @@ MYAPI TK_ComplicatedSuperSet * MYAPIENTRY createComplicatedSuperSet() {
fprintf(stderr, "TK_ComplicatedSubSet: bits3-s offset: %ld\n", (long) ((void *)(&s->sub1.bits3) - (void *)(&s->sub1)) );
fprintf(stderr, "TK_ComplicatedSubSet: real0-s offset: %ld\n", (long) ((void *)(&s->sub1.real0) - (void *)(&s->sub1)) );
fprintf(stderr, "TK_ComplicatedSubSet: bits4-s offset: %ld\n", (long) ((void *)(&s->sub1.bits4) - (void *)(&s->sub1)) );
+ fprintf(stderr, "TK_ComplicatedSubSet: real1-s offset: %ld\n", (long) ((void *)(&s->sub1.real1) - (void *)(&s->sub1)) );
+ fprintf(stderr, "TK_ComplicatedSubSet: bits5-s offset: %ld\n", (long) ((void *)(&s->sub1.bits5) - (void *)(&s->sub1)) );
+ fprintf(stderr, "TK_ComplicatedSubSet: longX-s offset: %ld\n", (long) ((void *)(&s->sub1.longX) - (void *)(&s->sub1)) );
+ fprintf(stderr, "TK_ComplicatedSubSet: bits6-s offset: %ld\n", (long) ((void *)(&s->sub1.bits6) - (void *)(&s->sub1)) );
fprintf(stderr, "TK_ComplicatedSuperSet: sizeof(): %ld\n", (long) sizeof(TK_ComplicatedSuperSet));
fprintf(stderr, "TK_ComplicatedSuperSet: bits1-s offset: %ld\n", (long) ((void *)(&s->bits1) - (void *)(s)) );
@@ -316,9 +364,46 @@ MYAPI TK_ComplicatedSuperSet * MYAPIENTRY createComplicatedSuperSet() {
fprintf(stderr, "TK_ComplicatedSuperSet: sub2-s offset: %ld\n", (long) ((void *)(&s->sub2) - (void *)(s)) );
fprintf(stderr, "TK_ComplicatedSuperSet: bits3-s offset: %ld\n", (long) ((void *)(&s->bits3) - (void *)(s)) );
+ #ifdef DEBUG
+ fprintf(stderr, "createComplicatedSuperSet:\n");
+ dumpTK_ComplicatedSuperSet(s);
+ #endif
return s;
}
+MYAPI Bool MYAPIENTRY hasInitValues(TK_ComplicatedSuperSet * s) {
+ Bool b = s->bits1 == 0xA0U &&
+ s->sub1.bits1 == 0xA1U &&
+ s->sub1.id == 0x12345678U &&
+ s->sub1.bits2 == 0xA2U &&
+ s->sub1.long0 == 0x123456789abcdef0UL &&
+ s->sub1.bits3 == 0xA3U &&
+ s->sub1.real0 == 3.1415926535897932384626433832795 &&
+ s->sub1.bits4 == 0xA4U &&
+ s->sub1.real1 == 256.12345f &&
+ s->sub1.bits5 == 0xA5U &&
+ s->sub1.longX == (long) 0xdeadbeefU &&
+ s->sub1.bits6 == 0xA6U &&
+ s->bits2 == 0xB0U &&
+ s->sub2.bits1 == 0xB1U &&
+ s->sub2.id == 0x12345678U &&
+ s->sub2.bits2 == 0xB2U &&
+ s->sub2.long0 == 0x123456789abcdef0UL &&
+ s->sub2.bits3 == 0xB3U &&
+ s->sub2.real0 == 3.1415926535897932384626433832795 &&
+ s->sub2.bits4 == 0xB4U &&
+ s->sub2.real1 == 256.12345f &&
+ s->sub2.bits5 == 0xB5U &&
+ s->sub2.longX == (long) 0xdeadbeefU &&
+ s->sub2.bits6 == 0xB6U &&
+ s->bits3 == 0xC0U ;
+ #ifdef DEBUG
+ fprintf(stderr, "hasInitValues res %d:\n", b);
+ dumpTK_ComplicatedSuperSet(s);
+ #endif
+ return b;
+}
+
MYAPI void MYAPIENTRY destroyComplicatedSuperSet(TK_ComplicatedSuperSet * s) {
free(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 041a8d2..3e20307 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h
@@ -26,6 +26,7 @@
#include <gluegen_stdint.h>
#include <gluegen_stddef.h>
+typedef int Bool;
typedef uint64_t foo;
/** Returns 42 */
@@ -150,16 +151,23 @@ typedef struct tk_Surface {
} TK_Surface;
typedef struct {
- int8_t bits1; // +1
+ uint8_t bits1; // +1
// +3 (p64)
int32_t id; // +4
- int8_t bits2; // +1
+ uint8_t bits2; // +1
// +7 (p64)
int64_t long0; // +8
- int8_t bits3; // +1
+ uint8_t bits3; // +1
// +7 (p64)
double real0; // +8
- int8_t bits4; // +1
+ uint8_t bits4; // +1
+ // +3 (p64)
+ float real1; // +4
+ uint8_t bits5; // +1
+ // +7 (p64) / +3 (windows andx 32bit)
+ long longX; // +8 / +4 (windows andx 32bit)
+ uint8_t bits6; // +1
+
// +7 (p64) (for next struct ..)
// 24 net
@@ -168,13 +176,13 @@ typedef struct {
} TK_ComplicatedSubSet;
typedef struct {
- int8_t bits1; // + 1
+ uint8_t bits1; // + 1
// + 7 (p64)
TK_ComplicatedSubSet sub1; // +48 (64bit)
- int8_t bits2; // + 1
+ uint8_t bits2; // + 1
// + 7 (p64)
TK_ComplicatedSubSet sub2; // +48 (64bit)
- int8_t bits3; // + 1
+ uint8_t bits3; // + 1
// + 7 (p64)
// 51 net
@@ -186,4 +194,5 @@ MYAPI TK_Surface * MYAPIENTRY createSurface();
MYAPI void MYAPIENTRY destroySurface(TK_Surface * surface);
MYAPI TK_ComplicatedSuperSet * MYAPIENTRY createComplicatedSuperSet();
+MYAPI Bool MYAPIENTRY hasInitValues(TK_ComplicatedSuperSet * s);
MYAPI void MYAPIENTRY destroyComplicatedSuperSet(TK_ComplicatedSuperSet * s);