diff options
author | Sven Gothel <[email protected]> | 2010-03-30 01:53:58 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2010-03-30 01:53:58 +0200 |
commit | 7220416bcef3140883d3966d921442feae3107c4 (patch) | |
tree | 89355f1f5cd3256b3cb721a924d585de9acea672 /src/java/com/jogamp | |
parent | 69fe372b874d913e2d1c27f1d103e1fced668ecf (diff) |
http://www.jogamp.org/bugzilla/show_bug.cgi?id=389
32bit/64bit values and arrays are misrepresented
- PointerBuffer is used to map 64bit integer values,
which is illegal due to the latest PointerBuffer changes,
where the underlying ByteBuffer is either 32bit wide
or 64bit wide (in respect to the pointer size).
The PointerBuffer semantic itself is correct,
but no more suitable to represent 64bit values and arrays.
A Int64Buffer (LongBuffer does not exist in CDC/CVM patch)
should be used instead.
- Determine use of Int64Buffer and PointerBuffer
Assuming the 1st step being solved, it has to determined
for which cases gluegen shall map a type to a PointerBuffer.
All pointer pointer types, regardless of a Opaque mapping, ie:
+++
typedef struct __MYAPIConfig * MYAPIConfig;
Opaque long MYAPIConfig
void foo(MYAPIConfig * ptrarray);
+++
The argument 'ptrarray' must be represented as a PointerBuffer
otherwise data is misrepresented in case:
- 32bit machines _and_
- array semantics - more than one value is being used
Impl:
java/com/sun/gluegen/JavaEmitter.java:
- Checks ptr-ptr for Opaque values
- Returns PointerBuffer mapping for ptr-ptr types
- Allow PointerBuffer being mapped as String[]
Very elaborated tests .. :)
++++++++++++
Misc Changes:
- Added <Type>.put(<Type>Buffer src) for Int64Buffer/PointerBuffer
Diffstat (limited to 'src/java/com/jogamp')
-rw-r--r-- | src/java/com/jogamp/gluegen/runtime/Int64Buffer.java | 14 | ||||
-rw-r--r-- | src/java/com/jogamp/gluegen/runtime/PointerBuffer.java | 14 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/java/com/jogamp/gluegen/runtime/Int64Buffer.java b/src/java/com/jogamp/gluegen/runtime/Int64Buffer.java index 5f7cc33..98d0834 100644 --- a/src/java/com/jogamp/gluegen/runtime/Int64Buffer.java +++ b/src/java/com/jogamp/gluegen/runtime/Int64Buffer.java @@ -152,4 +152,18 @@ public abstract class Int64Buffer { public abstract Int64Buffer put(long value); + public Int64Buffer put(Int64Buffer src) { + if (remaining() < src.remaining()) { + throw new IndexOutOfBoundsException(); + } + while (src.hasRemaining()) { + put(src.get()); + } + return this; + } + + public String toString() { + return "Int64Buffer[capacity "+capacity+", position "+position+", elementSize "+elementSize()+", ByteBuffer.capacity "+bb.capacity()+"]"; + } + } diff --git a/src/java/com/jogamp/gluegen/runtime/PointerBuffer.java b/src/java/com/jogamp/gluegen/runtime/PointerBuffer.java index a89dace..0adbb36 100644 --- a/src/java/com/jogamp/gluegen/runtime/PointerBuffer.java +++ b/src/java/com/jogamp/gluegen/runtime/PointerBuffer.java @@ -156,4 +156,18 @@ public abstract class PointerBuffer { public abstract PointerBuffer put(long value); + public PointerBuffer put(PointerBuffer src) { + if (remaining() < src.remaining()) { + throw new IndexOutOfBoundsException(); + } + while (src.hasRemaining()) { + put(src.get()); + } + return this; + } + + public String toString() { + return "PointerBuffer[capacity "+capacity+", position "+position+", elementSize "+elementSize()+", ByteBuffer.capacity "+bb.capacity()+"]"; + } + } |