aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2008-05-29 10:02:22 +0000
committerKenneth Russel <[email protected]>2008-05-29 10:02:22 +0000
commit7a874b54d5d38f3c81a75bbe3f6abd688cb92dfa (patch)
tree9cfbc4fb0318c053fb34d358b64bd63ac1011478
parentf1e08a23facb2d718276b3fbf59b0df2b54fceb9 (diff)
Bug fixes to mangling of JNI method names when arrays of compound
types are present, and to the new CMethodBindingEmitter.isUTF8Type() git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/gluegen/trunk@80 a78bb65f-1512-4460-ba86-f6dc96a7bf27
-rw-r--r--src/java/com/sun/gluegen/CMethodBindingEmitter.java16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/java/com/sun/gluegen/CMethodBindingEmitter.java b/src/java/com/sun/gluegen/CMethodBindingEmitter.java
index 446e5ca..03b8422 100644
--- a/src/java/com/sun/gluegen/CMethodBindingEmitter.java
+++ b/src/java/com/sun/gluegen/CMethodBindingEmitter.java
@@ -525,7 +525,7 @@ public class CMethodBindingEmitter extends FunctionEmitter
protected boolean isUTF8Type(Type type) {
int i = 0;
// Try to dereference the type at most two levels
- while (!type.isInt() && (i < 2)) {
+ while (!type.isInt() && !type.isVoid() && (i < 2)) {
PointerType pt = type.asPointer();
if (pt != null) {
type = pt.getTargetType();
@@ -537,6 +537,10 @@ public class CMethodBindingEmitter extends FunctionEmitter
type = arrt.getElementType();
}
}
+ if (type.isVoid()) {
+ // Assume UTF-8 since UTF-16 is rare
+ return true;
+ }
if (!type.isInt()) {
throw new IllegalArgumentException("Type " + type + " should have been a one- or two-dimensional integer pointer or array type");
}
@@ -1188,8 +1192,8 @@ public class CMethodBindingEmitter extends FunctionEmitter
// Mangle wrappers for C structs as ByteBuffer
jniMangle(java.nio.ByteBuffer.class, buf, true);
} else if (type.isArrayOfCompoundTypeWrappers()) {
- java.nio.Buffer[] tmp = new java.nio.Buffer[0];
- // Mangle arrays of C structs as Buffer[]
+ // Mangle arrays of C structs as ByteBuffer[]
+ java.nio.ByteBuffer[] tmp = new java.nio.ByteBuffer[0];
jniMangle(tmp.getClass(), buf, true);
} else if (type.isJNIEnv()) {
// These are not exposed at the Java level
@@ -1224,7 +1228,11 @@ public class CMethodBindingEmitter extends FunctionEmitter
if (syntheticArgument) {
if (c.isArray()) {
res.append("_3");
- jniMangle(c.getComponentType(), res, false);
+ Class componentType = c.getComponentType();
+ // Handle arrays of compound type wrappers differently for
+ // convenience of the Java-level glue code generation
+ jniMangle(componentType, res,
+ (componentType == java.nio.ByteBuffer.class));
} else {
res.append("L");
res.append(c.getName().replace('.', '_'));