diff options
-rw-r--r-- | src/classes/com/sun/gluegen/CMethodBindingEmitter.java | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/classes/com/sun/gluegen/CMethodBindingEmitter.java b/src/classes/com/sun/gluegen/CMethodBindingEmitter.java index 550d8d739..4208dfff1 100644 --- a/src/classes/com/sun/gluegen/CMethodBindingEmitter.java +++ b/src/classes/com/sun/gluegen/CMethodBindingEmitter.java @@ -1033,14 +1033,15 @@ public class CMethodBindingEmitter extends FunctionEmitter writer.println(" " + arrayRes + " = (*env)->NewObjectArray(env, " + arrayResLength + ", (*env)->FindClass(env, \"java/nio/ByteBuffer\"), NULL);"); writer.println(" for (" + arrayIdx + " = 0; " + arrayIdx + " < " + arrayResLength + "; " + arrayIdx + "++) {"); Type retType = binding.getCSymbol().getReturnType(); - Type baseType; + Type pointerType; if (retType.isPointer()) { - baseType = retType.asPointer().getTargetType().asPointer().getTargetType(); + pointerType = retType.asPointer().getTargetType(); } else { - baseType = retType.asArray().getElementType().asPointer().getTargetType(); + pointerType = retType.asArray().getElementType(); } + Type baseType = pointerType.asPointer().getTargetType(); writer.println(" (*env)->SetObjectArrayElement(env, " + arrayRes + ", " + arrayIdx + - ", (*env)->NewDirectByteBuffer(env, _res[" + arrayIdx + "], sizeof(" + baseType.getName() + ")));"); + ", (*env)->NewDirectByteBuffer(env, _res[" + arrayIdx + "], sizeof(" + pointerType.getName() + ")));"); writer.println(" }"); writer.println(" return " + arrayRes + ";"); } else if (javaReturnType.isArray()) { |