diff options
author | Sven Gothel <[email protected]> | 2010-11-14 23:31:42 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2010-11-14 23:31:42 +0100 |
commit | ffb589a35abf34f313312617e065b444c5f705b3 (patch) | |
tree | 0235e93050ebf5c7885c13b56ec0e435427f5728 /src | |
parent | ff239e4eff0bbf28f925a4dffb15638f3dfd51be (diff) |
Fix size_t, uintptr_t and uint32_t, uint64_t: suppress 'unsigned' in 'toString()' ; Added type tests.
For size_t and uintptr_t this actually generated invalid C code.
Added type tests for those.
Diffstat (limited to 'src')
5 files changed, 66 insertions, 5 deletions
diff --git a/src/java/com/jogamp/gluegen/cgram/HeaderParser.g b/src/java/com/jogamp/gluegen/cgram/HeaderParser.g index acb6dde..a0d2a83 100644 --- a/src/java/com/jogamp/gluegen/cgram/HeaderParser.g +++ b/src/java/com/jogamp/gluegen/cgram/HeaderParser.g @@ -507,14 +507,14 @@ typeSpecifier[int attributes] returns [Type t] { | "__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 */ } + | "uint32_t" { t = new IntType("uint32_t", SizeThunk.INT, true, cvAttrs, true); /* 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 */ } + | "uint64_t" { t = new IntType("uint64_t", SizeThunk.INT64, true, cvAttrs, true); /* 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 */ } + | "size_t" { t = new IntType("size_t", SizeThunk.POINTER, true, cvAttrs, true); /* TS: always unsigned */ } + | "uintptr_t" { t = new IntType("uintptr_t", SizeThunk.POINTER, true, cvAttrs, true); /* TS: always unsigned */ } | t = structSpecifier[cvAttrs] ( attributeDecl )* | t = unionSpecifier [cvAttrs] ( attributeDecl )* | t = enumSpecifier [cvAttrs] diff --git a/src/java/com/jogamp/gluegen/cgram/types/IntType.java b/src/java/com/jogamp/gluegen/cgram/types/IntType.java index c72fde4..b85c7fc 100644 --- a/src/java/com/jogamp/gluegen/cgram/types/IntType.java +++ b/src/java/com/jogamp/gluegen/cgram/types/IntType.java @@ -48,7 +48,7 @@ public class IntType extends PrimitiveType implements Cloneable { this(name, size, unsigned, cvAttributes, false); } - private IntType(String name, SizeThunk size, boolean unsigned, int cvAttributes, boolean typedefedUnsigned) { + public IntType(String name, SizeThunk size, boolean unsigned, int cvAttributes, boolean typedefedUnsigned) { super(name, size, cvAttributes); this.unsigned = unsigned; this.typedefedUnsigned = typedefedUnsigned; 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 2b570ff..1cbc6a6 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java @@ -94,6 +94,7 @@ public class BaseClass { String[] strings = null; int[] iarray = null; int iarray_offset = 0; + long l = 0; result = binding.arrayTestInt32(context, ib); result = binding.arrayTestInt32(context, iarray, iarray_offset); @@ -135,6 +136,17 @@ public class BaseClass { long cfg=0; cfg = binding.typeTestAnonSingle(cfg); pb = binding.typeTestAnonPointer(pb); + + i = binding.typeTestInt32T(i, i); + i = binding.typeTestUInt32T(i, i); + l = binding.typeTestInt64T(l, l); + l = binding.typeTestUInt64T(l, l); + + i = binding.typeTestWCharT(i, i); + l = binding.typeTestSizeT(l, l); + l = binding.typeTestPtrDiffT(l, l); + l = binding.typeTestIntPtrT(l, l); + l = binding.typeTestUIntPtrT(l, l); } /** 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 d74cfc6..6cf42b5 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c @@ -172,3 +172,41 @@ MYAPI MYAPIConfig * MYAPIENTRY typeTestAnonPointer(const MYAPIConfig * a) { return result; } +MYAPI int32_t MYAPIENTRY typeTestInt32T(const int32_t i1, int32_t i2) { + return i1 + i2; +} + +MYAPI uint32_t MYAPIENTRY typeTestUInt32T(const uint32_t ui1, uint32_t ui2) { + return ui1 + ui2; +} + +MYAPI int64_t MYAPIENTRY typeTestInt64T(const int64_t i1, int64_t i2) { + return i1 + i2; +} + +MYAPI uint64_t MYAPIENTRY typeTestUInt64T(const uint64_t ui1, uint64_t ui2) { + return ui1 + ui2; +} + + +MYAPI wchar_t MYAPIENTRY typeTestWCharT(const wchar_t c1, wchar_t c2) { + return c1 + c2; +} + +MYAPI size_t MYAPIENTRY typeTestSizeT(const size_t size1, size_t size2) { + return size1 + size2; +} + +MYAPI ptrdiff_t MYAPIENTRY typeTestPtrDiffT(const ptrdiff_t ptr1, ptrdiff_t ptr2) { + return ptr1 + ptr2; +} + +MYAPI intptr_t MYAPIENTRY typeTestIntPtrT(const intptr_t ptr1, intptr_t ptr2) { + return ptr1 + ptr2; +} + +MYAPI uintptr_t MYAPIENTRY typeTestUIntPtrT(const uintptr_t ptr1, uintptr_t ptr2) { + return ptr1 + ptr2; +} + + 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 bd526e6..6230c51 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h @@ -102,6 +102,17 @@ MYAPI MYAPIConfig * MYAPIENTRY typeTestAnonPointer(const MYAPIConfig * a); size_t unsigned_size_t_1; ptrdiff_t a_signed_pointer_t_1; +MYAPI int32_t MYAPIENTRY typeTestInt32T(const int32_t i1, int32_t i2); +MYAPI uint32_t MYAPIENTRY typeTestUInt32T(const uint32_t ui1, uint32_t ui2); +MYAPI int64_t MYAPIENTRY typeTestInt64T(const int64_t i1, int64_t i2); +MYAPI uint64_t MYAPIENTRY typeTestUInt64T(const uint64_t ui1, uint64_t ui2); + +MYAPI wchar_t MYAPIENTRY typeTestWCharT(const wchar_t c1, wchar_t c2); +MYAPI size_t MYAPIENTRY typeTestSizeT(const size_t size1, size_t size2); +MYAPI ptrdiff_t MYAPIENTRY typeTestPtrDiffT(const ptrdiff_t ptr1, ptrdiff_t ptr2); +MYAPI intptr_t MYAPIENTRY typeTestIntPtrT(const intptr_t ptr1, intptr_t ptr2); +MYAPI uintptr_t MYAPIENTRY typeTestUIntPtrT(const uintptr_t ptr1, uintptr_t ptr2); + #ifdef __GLUEGEN__ #warning "Hello GlueGen" #else |