diff options
author | Kenneth Russel <[email protected]> | 2008-12-20 09:41:40 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2008-12-20 09:41:40 +0000 |
commit | 93b0bbc573fe1aaaac0eee1c471c09cc05e4d64c (patch) | |
tree | 45332f3093835d4a4b709c81db6bc31a6067eac9 /src/java/com/sun/gluegen/JavaMethodBindingEmitter.java | |
parent | be28001c09aa922b0a7b07ebb51d50e8d41578c0 (diff) |
Fixed more bugs in glue code generation related to using opaque long
type for pointers returned in arrays: specifically, the return value
of glXChooseFBConfig. However, this fix contains an inherent memory
leak for certain C APIs because the original Buffer is not necessarily
available to be manually freed. Still, fixes remaining problems with
pbuffer support on X11 platforms.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/gluegen/branches/JOGL_2_SANDBOX@119 a78bb65f-1512-4460-ba86-f6dc96a7bf27
Diffstat (limited to 'src/java/com/sun/gluegen/JavaMethodBindingEmitter.java')
-rw-r--r-- | src/java/com/sun/gluegen/JavaMethodBindingEmitter.java | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/java/com/sun/gluegen/JavaMethodBindingEmitter.java b/src/java/com/sun/gluegen/JavaMethodBindingEmitter.java index f7680c8..ecd83ac 100644 --- a/src/java/com/sun/gluegen/JavaMethodBindingEmitter.java +++ b/src/java/com/sun/gluegen/JavaMethodBindingEmitter.java @@ -745,12 +745,22 @@ public class JavaMethodBindingEmitter extends FunctionEmitter writer.println(";"); } else if (returnType.isNIOBuffer()) { writer.println(" if (_res == null) return null;"); - writer.print(" return BufferFactory.nativeOrder(_res)"); + writer.println(" BufferFactory.nativeOrder(_res);"); if (!returnType.isNIOByteBuffer()) { - String returnTypeName = returnType.getName().substring("java.nio.".length()); - writer.print(".as" + returnTypeName + "()"); + // See whether we have to expand pointers to longs + if (getBinding().getCReturnType().pointerDepth() >= 2) { + if (!returnType.isNIOLongBuffer()) { + throw new RuntimeException("While emitting glue code for " + getName() + + ": can not legally make pointers opaque to anything but longs"); + } + writer.println(" return BufferFactory.asPointerBuffer(_res);"); + } else { + String returnTypeName = returnType.getName().substring("java.nio.".length()); + writer.println(" return _res.as" + returnTypeName + "()"); + } + } else { + writer.println(" return _res;"); } - writer.println(";"); } else if (returnType.isArrayOfCompoundTypeWrappers()) { writer.println(" if (_res == null) return null;"); writer.println(" " + getReturnTypeString(false) + " _retarray = new " + getReturnTypeString(true) + "[_res.length];"); |