summaryrefslogtreecommitdiffstats
path: root/src/java/com/sun/gluegen
diff options
context:
space:
mode:
authorsg215889 <[email protected]>2009-07-13 14:31:05 -0700
committersg215889 <[email protected]>2009-07-13 14:31:05 -0700
commitc19b868e5fbdd123477e13c8da6bc37ece1103ff (patch)
tree3742c46569610b5bc4d350e19ca449ce285218ee /src/java/com/sun/gluegen
parent35cad1e103bb30737b4feacf554219b795358eec (diff)
Add missing changes
Diffstat (limited to 'src/java/com/sun/gluegen')
-rw-r--r--src/java/com/sun/gluegen/JavaEmitter.java4
-rw-r--r--src/java/com/sun/gluegen/JavaMethodBindingEmitter.java6
-rw-r--r--src/java/com/sun/gluegen/JavaType.java15
3 files changed, 20 insertions, 5 deletions
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);
}