diff options
author | sg215889 <[email protected]> | 2009-07-13 14:31:05 -0700 |
---|---|---|
committer | sg215889 <[email protected]> | 2009-07-13 14:31:05 -0700 |
commit | c19b868e5fbdd123477e13c8da6bc37ece1103ff (patch) | |
tree | 3742c46569610b5bc4d350e19ca449ce285218ee | |
parent | 35cad1e103bb30737b4feacf554219b795358eec (diff) |
Add missing changes
-rwxr-xr-x | make/build.xml | 2 | ||||
-rw-r--r-- | src/java/com/sun/gluegen/JavaEmitter.java | 4 | ||||
-rw-r--r-- | src/java/com/sun/gluegen/JavaMethodBindingEmitter.java | 6 | ||||
-rw-r--r-- | src/java/com/sun/gluegen/JavaType.java | 15 |
4 files changed, 22 insertions, 5 deletions
diff --git a/make/build.xml b/make/build.xml index f4d7289..4537582 100755 --- a/make/build.xml +++ b/make/build.xml @@ -50,11 +50,13 @@ <target name="setup.javase" unless="isCDCFP"> <copy file="../src/java/com/sun/gluegen/runtime/BufferFactory.java.javase" tofile="../${rootrel.build}/gensrc/java/com/sun/gluegen/runtime/BufferFactory.java" /> <copy file="../src/java/com/sun/gluegen/runtime/StructAccessor.java.javase" tofile="../${rootrel.build}/gensrc/java/com/sun/gluegen/runtime/StructAccessor.java" /> + <copy file="../src/java/com/sun/gluegen/runtime/PointerBuffer.java.javase" tofile="../${rootrel.build}/gensrc/java/com/sun/gluegen/runtime/PointerBuffer.java" /> </target> <target name="setup.javame.cdc.fp" if="isCDCFP"> <copy file="../src/java/com/sun/gluegen/runtime/BufferFactory.java.javame_cdc_fp" tofile="../${rootrel.build}/gensrc/java/com/sun/gluegen/runtime/BufferFactory.java" /> <copy file="../src/java/com/sun/gluegen/runtime/StructAccessor.java.javame_cdc_fp" tofile="../${rootrel.build}/gensrc/java/com/sun/gluegen/runtime/StructAccessor.java" /> + <copy file="../src/java/com/sun/gluegen/runtime/PointerBuffer.java.javame_cdc_fp" tofile="../${rootrel.build}/gensrc/java/com/sun/gluegen/runtime/PointerBuffer.java" /> </target> <target name="init" depends="load.user.properties,setup-excludes-1,setup-excludes-2,init.javame.cdc.fp"> diff --git a/src/java/com/sun/gluegen/JavaEmitter.java b/src/java/com/sun/gluegen/JavaEmitter.java index ffd273f..603881c 100644 --- a/src/java/com/sun/gluegen/JavaEmitter.java +++ b/src/java/com/sun/gluegen/JavaEmitter.java @@ -1741,7 +1741,7 @@ public class JavaEmitter implements GlueEmitter { if (convertToArrays) { result = result.replaceJavaArgumentType(i, javaType(ArrayTypes.longArrayClass)); } else { - result = result.replaceJavaArgumentType(i, JavaType.forNIOLongBufferClass()); + result = result.replaceJavaArgumentType(i, JavaType.forNIOPointerBufferClass()); } } else if (t.isCFloatPointerType()) { arrayPossible = true; @@ -1775,7 +1775,7 @@ public class JavaEmitter implements GlueEmitter { } else if (t.isCInt32PointerType()) { result = result.replaceJavaArgumentType(-1, JavaType.forNIOIntBufferClass()); } else if (t.isCInt64PointerType()) { - result = result.replaceJavaArgumentType(-1, JavaType.forNIOLongBufferClass()); + result = result.replaceJavaArgumentType(-1, JavaType.forNIOPointerBufferClass()); } else if (t.isCFloatPointerType()) { result = result.replaceJavaArgumentType(-1, JavaType.forNIOFloatBufferClass()); } else if (t.isCDoublePointerType()) { diff --git a/src/java/com/sun/gluegen/JavaMethodBindingEmitter.java b/src/java/com/sun/gluegen/JavaMethodBindingEmitter.java index d7fa7c4..9fa232d 100644 --- a/src/java/com/sun/gluegen/JavaMethodBindingEmitter.java +++ b/src/java/com/sun/gluegen/JavaMethodBindingEmitter.java @@ -640,6 +640,8 @@ public class JavaMethodBindingEmitter extends FunctionEmitter writer.print("BufferFactory.getArray(" + getArgumentName(i) + ")"); } else if (type.isArrayOfCompoundTypeWrappers()) { writer.print(getArgumentName(i) + COMPOUND_ARRAY_SUFFIX); + } else if(type.isNIOPointerBuffer()) { + writer.print(getArgumentName(i) + ".getBuffer()"); } else { writer.print(getArgumentName(i)); } @@ -755,11 +757,11 @@ public class JavaMethodBindingEmitter extends FunctionEmitter if (!returnType.isNIOByteBuffer()) { // See whether we have to expand pointers to longs if (getBinding().getCReturnType().pointerDepth() >= 2) { - if (!returnType.isNIOLongBuffer()) { + if (!returnType.isNIOPointerBuffer()) { 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);"); + writer.println(" return PointerBuffer.wrapNative2Java(_res, false);"); } else { String returnTypeName = returnType.getName().substring("java.nio.".length()); writer.println(" return _res.as" + returnTypeName + "();"); diff --git a/src/java/com/sun/gluegen/JavaType.java b/src/java/com/sun/gluegen/JavaType.java index 1f795ef..5e30810 100644 --- a/src/java/com/sun/gluegen/JavaType.java +++ b/src/java/com/sun/gluegen/JavaType.java @@ -70,6 +70,7 @@ public class JavaType { private static JavaType nioShortBufferType; private static JavaType nioIntBufferType; private static JavaType nioLongBufferType; + private static JavaType nioPointerBufferType; private static JavaType nioFloatBufferType; private static JavaType nioDoubleBufferType; private static JavaType nioByteBufferArrayType; @@ -191,6 +192,13 @@ public class JavaType { return nioLongBufferType; } + public static JavaType forNIOPointerBufferClass() + { + if(nioPointerBufferType == null) + nioPointerBufferType = createForClass(com.sun.gluegen.runtime.PointerBuffer.class); + return nioPointerBufferType; + } + public static JavaType forNIOFloatBufferClass() { if (nioFloatBufferType == null) { nioFloatBufferType = createForClass(java.nio.FloatBuffer.class); @@ -323,7 +331,7 @@ public class JavaType { } public boolean isNIOBuffer() { - return (clazz != null && java.nio.Buffer.class.isAssignableFrom(clazz)); + return clazz != null && ((java.nio.Buffer.class).isAssignableFrom(clazz) || isNIOPointerBuffer()); } public boolean isNIOByteBuffer() { @@ -343,6 +351,11 @@ public class JavaType { return (clazz == java.nio.LongBuffer.class); } + public boolean isNIOPointerBuffer() + { + return clazz == (com.sun.gluegen.runtime.PointerBuffer.class); + } + public boolean isString() { return (clazz == java.lang.String.class); } |