summaryrefslogtreecommitdiffstats
path: root/src/java/com/sun/gluegen/JavaMethodBindingEmitter.java
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-01-12 17:57:27 +0100
committerMichael Bien <[email protected]>2010-01-12 17:57:27 +0100
commitb138169c1f85a7914304ae793efb9cabfbfd5da2 (patch)
tree065d968fe603a9a55c33208cdac8183bde8336a8 /src/java/com/sun/gluegen/JavaMethodBindingEmitter.java
parent266ab5707d5f6b9e1cf935e6258badd6ba9f2639 (diff)
fixed emitted code for buffer-array mixing.
removed workaround in BufferFactory since it is no longer needed. small code cleanup (generator java 5 migration).
Diffstat (limited to 'src/java/com/sun/gluegen/JavaMethodBindingEmitter.java')
-rw-r--r--src/java/com/sun/gluegen/JavaMethodBindingEmitter.java20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/java/com/sun/gluegen/JavaMethodBindingEmitter.java b/src/java/com/sun/gluegen/JavaMethodBindingEmitter.java
index bf9d3ae..a813348 100644
--- a/src/java/com/sun/gluegen/JavaMethodBindingEmitter.java
+++ b/src/java/com/sun/gluegen/JavaMethodBindingEmitter.java
@@ -392,8 +392,8 @@ public class JavaMethodBindingEmitter extends FunctionEmitter
writer.println(';');
} else {
MethodBinding mBinding = getBinding();
- writer.println();
writer.println(" {");
+ writer.println();
if (isUnimplemented) {
writer.println(" throw new " + getUnsupportedExceptionType() + "(\"Unimplemented\");");
} else {
@@ -449,7 +449,21 @@ public class JavaMethodBindingEmitter extends FunctionEmitter
} else {
if(firstBuffer) {
firstBuffer = false;
- writer.println(" boolean _direct = BufferFactory.isDirect(" + getArgumentName(i) + ");");
+ writer.print(" boolean _direct = ");
+ for (int j = i; j < binding.getNumArguments(); j++) {
+ JavaType buff = binding.getJavaArgumentType(j);
+
+ if(buff.isNIOBuffer()) {
+ if(i!=j) { // not the first one
+ writer.println();
+ writer.print(" ||");
+ }
+ writer.print(getArgumentName(j)+" != null && BufferFactory.isDirect(" + getArgumentName(j) + ")");
+ }
+
+ }
+ writer.println(";");
+
} else {
writer.println(" if (" + getArgumentName(i) + " != null && _direct != BufferFactory.isDirect(" + getArgumentName(i) + "))");
writer.println(" throw new " + getRuntimeExceptionType() +
@@ -634,7 +648,7 @@ public class JavaMethodBindingEmitter extends FunctionEmitter
} else if (type.isArrayOfCompoundTypeWrappers()) {
writer.print(getArgumentName(i) + COMPOUND_ARRAY_SUFFIX);
} else if(type.isNIOPointerBuffer()) {
- writer.print(getArgumentName(i) + ".getBuffer()");
+ writer.print(getArgumentName(i)+"!=null?"+getArgumentName(i) + ".getBuffer():null");
} else {
writer.print(getArgumentName(i));
}