From 1610dbb4e4d1a1ecf31eb837a47e0f5be04afdac Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 20 Mar 2013 02:15:53 +0100 Subject: Fix intptr_t*, uintptr_t*, ptrdiff_t* and size_t* mapping, map them to PointerBuffer, since referenced memory-size is arch dependent Added extensive PointerBuffer unit tests w/ new mapping in generated test class. --- src/java/com/jogamp/gluegen/JavaEmitter.java | 7 ++++--- src/java/com/jogamp/gluegen/package.html | 8 +++++++- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'src/java') diff --git a/src/java/com/jogamp/gluegen/JavaEmitter.java b/src/java/com/jogamp/gluegen/JavaEmitter.java index df6f00a..1a6c313 100644 --- a/src/java/com/jogamp/gluegen/JavaEmitter.java +++ b/src/java/com/jogamp/gluegen/JavaEmitter.java @@ -1245,7 +1245,7 @@ public class JavaEmitter implements GlueEmitter { // t is [], we need to get targetType = t.asArray().getElementType(); } - + // Handle Types of form pointer-to-type or array-of-type, like // char* or int[]; these are expanded out into Java primitive // arrays, NIO buffers, or both in expandMethodBinding @@ -1253,8 +1253,9 @@ public class JavaEmitter implements GlueEmitter { if (targetType.isVoid()) { return JavaType.createForCVoidPointer(); } else if (targetType.isInt()) { - // size_t and intptr_t is always a PointerBuffer since size is arch dependent - if ("size_t".equals(targetType.getName()) || "intptr_t".equals(targetType.getName())) { + final SizeThunk targetSizeThunk = targetType.getSize(); + if( null != targetSizeThunk && SizeThunk.POINTER == targetSizeThunk ) { + // Map intptr_t*, uintptr_t*, ptrdiff_t* and size_t* to PointerBuffer, since referenced memory-size is arch dependent return JavaType.forNIOPointerBufferClass(); } switch ((int) targetType.getSize(curMachDesc)) { diff --git a/src/java/com/jogamp/gluegen/package.html b/src/java/com/jogamp/gluegen/package.html index 7ea9d51..2b4f1fa 100644 --- a/src/java/com/jogamp/gluegen/package.html +++ b/src/java/com/jogamp/gluegen/package.html @@ -37,7 +37,13 @@

Warning: Try to avoid unspecified bit sized types, especially long, since it differs on Unix and Windows!
- Note 1: Type long will result in broken code on Windows, since we don't differentiate the OS and it's bit size is ambiguous. + Notes: +

    +
  1. Type long will result in broken code on Windows, since we don't differentiate the OS and it's bit size is ambiguous.
  2. +
  3. Anonymous void-pointer void* are mapped to NIO Buffer.
  4. +
  5. Pointers to pointer-size types like intptr_t*, uintptr_t*, ptrdiff_t* and size_t* are mapped to PointerBuffer, + to reflect the architecture depending storage size.
  6. +

GlueGen Internal Alignment for Compound Data

-- cgit v1.2.3