From 7865b355bd52958f4b27e42b500e83c52255ef37 Mon Sep 17 00:00:00 2001
From: Sven Gothel
+ *
- *
+ * GlueGen Data Type Mapping
* Gluegen has build-in types (terminal symbols) for:
*
*
- *
+ *
- * type java native-x32 native-x64 type signed
- * __int32 32bit 32bit 32bit integer signed or unsigned
- * int32_t 32bit 32bit 32bit integer signed
- * uint32_t 32bit 32bit 32bit integer unsigned
- * __int64 64bit 64bit 64bit integer signed or unsigned
- * int64_t 64bit 64bit 64bit integer signed
- * uint64_t 64bit 64bit 64bit integer unsigned
- * ptrdiff_t 64bit 32bit 64bit integer signed
- * size_t 64bit 32bit 64bit integer unsigned type java native-x32 native-x64 type signed origin
+ *
+ * __int32 32bit 32bit 32bit integer signed or unsigned windows
+ * int32_t 32bit 32bit 32bit integer signed stdint.h
+ * wchar_t 32bit 32bit 32bit integer signed stddef.h
+ * uint32_t 32bit 32bit 32bit integer unsigned stdint.h
+ * __int64 64bit 64bit 64bit integer signed or unsigned windows
+ * int64_t 64bit 64bit 64bit integer signed stdint.h
+ * uint64_t 64bit 64bit 64bit integer unsigned stdint.h
+ * ptrdiff_t 64bit 32bit 64bit integer signed stddef.h
+ * intptr_t 64bit 32bit 64bit integer signed stdint.h
+ * size_t 64bit 32bit 64bit integer unsigned stddef.h
+ * uintptr_t 64bit 32bit 64bit integer unsigned stdint.h
+ *
+ #include <gluegen_stdint.h> + #include <gluegen_stddef.h> + + uint64_t test64; + size_t size1; + ptrdiff_t ptr1; + *+ *
-I
:+ * gluegen/make/stub_includes/platform + *+ *
includeRefid
element:+ * gluegen/make/stub_includes/gluegen + *+ *
+ *
+ #define __GLUEGEN__ 2 + *+ * */ + public class GlueGen implements GlueEmitterControls { static{ @@ -117,6 +153,7 @@ public class GlueGen implements GlueEmitterControls { } preprocessor = new PCPP(includePaths, debug, copyPCPPOutput2Stderr); + preprocessor.addDefine("__GLUEGEN__", "2"); preprocessor.setOut(outStream); preprocessor.run(reader, filename); diff --git a/src/java/com/jogamp/gluegen/cgram/GnuCParser.g b/src/java/com/jogamp/gluegen/cgram/GnuCParser.g index f795702..58d3171 100644 --- a/src/java/com/jogamp/gluegen/cgram/GnuCParser.g +++ b/src/java/com/jogamp/gluegen/cgram/GnuCParser.g @@ -315,12 +315,15 @@ typeSpecifier [int specCount] returns [int retSpecCount] | "unsigned" | "__int32" | "int32_t" + | "wchar_t" | "uint32_t" | "__int64" | "int64_t" | "uint64_t" | "ptrdiff_t" + | "intptr_t" | "size_t" + | "uintptr_t" | structOrUnionSpecifier ( options{warnWhenFollowAmbig=false;}: attributeDecl )* | enumSpecifier | { specCount==0 }? typedefName diff --git a/src/java/com/jogamp/gluegen/cgram/GnuCTreeParser.g b/src/java/com/jogamp/gluegen/cgram/GnuCTreeParser.g index 82792f3..1beeb7d 100644 --- a/src/java/com/jogamp/gluegen/cgram/GnuCTreeParser.g +++ b/src/java/com/jogamp/gluegen/cgram/GnuCTreeParser.g @@ -183,6 +183,17 @@ typeSpecifier | "double" | "signed" | "unsigned" + | "__int32" + | "int32_t" + | "wchar_t" + | "uint32_t" + | "__int64" + | "int64_t" + | "uint64_t" + | "ptrdiff_t" + | "intptr_t" + | "size_t" + | "uintptr_t" | structSpecifier ( attributeDecl )* | unionSpecifier ( attributeDecl )* | enumSpecifier diff --git a/src/java/com/jogamp/gluegen/cgram/HeaderParser.g b/src/java/com/jogamp/gluegen/cgram/HeaderParser.g index fa6455f..acb6dde 100644 --- a/src/java/com/jogamp/gluegen/cgram/HeaderParser.g +++ b/src/java/com/jogamp/gluegen/cgram/HeaderParser.g @@ -506,12 +506,15 @@ typeSpecifier[int attributes] returns [Type t] { | "double" { t = new DoubleType("double", SizeThunk.DOUBLE, cvAttrs); } | "__int32" { t = new IntType("__int32", SizeThunk.INT, unsigned, cvAttrs); } | "int32_t" { t = new IntType("int32_t", SizeThunk.INT, false, cvAttrs); /* TS: always signed */ } + | "wchar_t" { t = new IntType("wchar_t", SizeThunk.INT, false, cvAttrs); /* TS: always signed */ } | "uint32_t" { t = new IntType("uint32_t", SizeThunk.INT, true, cvAttrs); /* TS: always unsigned */ } | "__int64" { t = new IntType("__int64", SizeThunk.INT64, unsigned, cvAttrs); } | "int64_t" { t = new IntType("int64_t", SizeThunk.INT64, false, cvAttrs); /* TS: always signed */ } | "uint64_t" { t = new IntType("uint64_t", SizeThunk.INT64, true, cvAttrs); /* TS: always unsigned */ } | "ptrdiff_t" { t = new IntType("ptrdiff_t", SizeThunk.POINTER, false, cvAttrs); /* TS: always signed */ } + | "intptr_t" { t = new IntType("intptr_t", SizeThunk.POINTER, false, cvAttrs); /* TS: always signed */ } | "size_t" { t = new IntType("size_t", SizeThunk.POINTER, true, cvAttrs); /* TS: always unsigned */ } + | "uintptr_t" { t = new IntType("uintptr_t", SizeThunk.POINTER, true, cvAttrs); /* TS: always unsigned */ } | t = structSpecifier[cvAttrs] ( attributeDecl )* | t = unionSpecifier [cvAttrs] ( attributeDecl )* | t = enumSpecifier [cvAttrs] diff --git a/src/java/com/jogamp/gluegen/cgram/StdCParser.g b/src/java/com/jogamp/gluegen/cgram/StdCParser.g index 015c3e0..231e371 100644 --- a/src/java/com/jogamp/gluegen/cgram/StdCParser.g +++ b/src/java/com/jogamp/gluegen/cgram/StdCParser.g @@ -265,6 +265,17 @@ typeSpecifier [int specCount] returns [int retSpecCount] | "double" | "signed" | "unsigned" + | "__int32" + | "int32_t" + | "wchar_t" + | "uint32_t" + | "__int64" + | "int64_t" + | "uint64_t" + | "ptrdiff_t" + | "intptr_t" + | "size_t" + | "uintptr_t" | structOrUnionSpecifier | enumSpecifier | { specCount == 0 }? typedefName diff --git a/src/java/com/jogamp/gluegen/pcpp/PCPP.java b/src/java/com/jogamp/gluegen/pcpp/PCPP.java index f34a707..45a92df 100644 --- a/src/java/com/jogamp/gluegen/pcpp/PCPP.java +++ b/src/java/com/jogamp/gluegen/pcpp/PCPP.java @@ -517,6 +517,16 @@ public class PCPP { while (nextToken(true) != StreamTokenizer.TT_EOL) { values.add(curTokenAsString()); } + addDefine(name, macroDefinition, values); + } + + public void addDefine(String name, String value) { + List