summaryrefslogtreecommitdiffstats
path: root/src/java/com/sun/gluegen/JavaEmitter.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-03-28 01:27:01 +0100
committerSven Gothel <[email protected]>2010-03-28 01:27:01 +0100
commita41f4d504d2f8cf58114d570d23f757ab2659cfc (patch)
treeebe021734de27004c1424130b0150f0b3cc2b5bb /src/java/com/sun/gluegen/JavaEmitter.java
parent2b61964060ffb79a313030d795ad069fbbe97b88 (diff)
http://www.jogamp.org/bugzilla/show_bug.cgi?id=389
Mixed types in generated code are functioning now, even though not all permutations are generated - still. However, this patch merges the indirect object passing, wheather it is a primitive array or an indirect NIO buffer, incl. PointerBuffer. This allows the usage of only one JNI functions for all combinations. Only in case of NIODirectOnly, the simplified direct only '0' variation is created - otherwise the parametrized '1' variant. The junit tests proves the implementation and almost completes the gluegen junit tests coverage for JavaEmitter and ProcAddressEmitter. Impact/Result: - Working mixed array types - JOGL GL2 native library shrunk around 30% - Simplified gluegen code - Almost complete gluegen junit tests TODO: Complete permutations of array/NIO arguments, if desired. ++++ Misc changes: - NativeLibrary implements DynamicLookupHelper: lookupFunction() -> dynamicLookupFunction()
Diffstat (limited to 'src/java/com/sun/gluegen/JavaEmitter.java')
-rw-r--r--src/java/com/sun/gluegen/JavaEmitter.java98
1 files changed, 22 insertions, 76 deletions
diff --git a/src/java/com/sun/gluegen/JavaEmitter.java b/src/java/com/sun/gluegen/JavaEmitter.java
index df98839..b2f7578 100644
--- a/src/java/com/sun/gluegen/JavaEmitter.java
+++ b/src/java/com/sun/gluegen/JavaEmitter.java
@@ -586,36 +586,6 @@ public class JavaEmitter implements GlueEmitter {
emitter.addModifier(JavaMethodBindingEmitter.NATIVE);
emitter.setReturnedArrayLengthExpression(cfg.returnedArrayLength(binding.getName()));
allEmitters.add(emitter);
-
- // Optionally emit the entry point taking arrays which handles
- // both the public entry point taking arrays as well as the
- // indirect buffer case
- if (!cfg.nioDirectOnly(binding.getName()) &&
- binding.signatureCanUseIndirectNIO()) {
- emitter =
- new JavaMethodBindingEmitter(binding,
- writer,
- cfg.runtimeExceptionType(),
- cfg.unsupportedExceptionType(),
- false,
- cfg.tagNativeBinding(),
- true,
- false,
- true,
- false,
- true,
- false,
- false,
- cfg);
-
- emitter.addModifier(JavaMethodBindingEmitter.PRIVATE);
- if (cfg.allStatic()) {
- emitter.addModifier(JavaMethodBindingEmitter.STATIC);
- }
- emitter.addModifier(JavaMethodBindingEmitter.NATIVE);
- emitter.setReturnedArrayLengthExpression(cfg.returnedArrayLength(binding.getName()));
- allEmitters.add(emitter);
- }
}
}
@@ -656,51 +626,27 @@ public class JavaEmitter implements GlueEmitter {
}
}
- CMethodBindingEmitter cEmitter =
- new CMethodBindingEmitter(binding,
- cWriter(),
- cfg.implPackageName(),
- cfg.implClassName(),
- true, /* NOTE: we always disambiguate with a suffix now, so this is optional */
- cfg.allStatic(),
- (binding.needsNIOWrappingOrUnwrapping() || hasPrologueOrEpilogue),
- false,
- machDesc64);
- if (returnValueCapacityFormat != null) {
- cEmitter.setReturnValueCapacityExpression(returnValueCapacityFormat);
- }
- if (returnValueLengthFormat != null) {
- cEmitter.setReturnValueLengthExpression(returnValueLengthFormat);
- }
- cEmitter.setTemporaryCVariableDeclarations(cfg.temporaryCVariableDeclarations(binding.getName()));
- cEmitter.setTemporaryCVariableAssignments(cfg.temporaryCVariableAssignments(binding.getName()));
- allEmitters.add(cEmitter);
-
- // Now see if we have to emit another entry point to handle the
- // indirect buffer and array case
- if (binding.argumentsUseNIO() &&
- binding.signatureCanUseIndirectNIO() &&
- !cfg.nioDirectOnly(binding.getName())) {
- cEmitter =
+ CMethodBindingEmitter cEmitter;
+ // Generate a binding without mixed access (NIO-direct, -indirect, array)
+ cEmitter =
new CMethodBindingEmitter(binding,
cWriter(),
cfg.implPackageName(),
cfg.implClassName(),
- true, /* NOTE: we always disambiguate with a suffix now, so this is optional */
+ true, // NOTE: we always disambiguate with a suffix now, so this is optional
cfg.allStatic(),
- binding.needsNIOWrappingOrUnwrapping(),
- true,
+ (binding.needsNIOWrappingOrUnwrapping() || hasPrologueOrEpilogue),
+ !cfg.nioDirectOnly(binding.getName()),
machDesc64);
- if (returnValueCapacityFormat != null) {
+ if (returnValueCapacityFormat != null) {
cEmitter.setReturnValueCapacityExpression(returnValueCapacityFormat);
- }
- if (returnValueLengthFormat != null) {
+ }
+ if (returnValueLengthFormat != null) {
cEmitter.setReturnValueLengthExpression(returnValueLengthFormat);
- }
- cEmitter.setTemporaryCVariableDeclarations(cfg.temporaryCVariableDeclarations(binding.getName()));
- cEmitter.setTemporaryCVariableAssignments(cfg.temporaryCVariableAssignments(binding.getName()));
- allEmitters.add(cEmitter);
}
+ cEmitter.setTemporaryCVariableDeclarations(cfg.temporaryCVariableDeclarations(binding.getName()));
+ cEmitter.setTemporaryCVariableAssignments(cfg.temporaryCVariableAssignments(binding.getName()));
+ allEmitters.add(cEmitter);
}
}
@@ -746,14 +692,15 @@ public class JavaEmitter implements GlueEmitter {
// Implementation class:
// public void fooMethod(Buffer arg) {
// ... bounds checks, etc. ...
- // if (arg.isDirect()) {
- // fooMethod0(arg, computeDirectBufferByteOffset(arg));
- // } else {
- // fooMethod1(getIndirectBufferArray(arg), computeIndirectBufferByteOffset(arg));
- // }
+ //
+ // boolean arg_direct = arg != null && BufferFactory.isDirect(arg);
+ //
+ // fooMethod0(arg_direct?arg:BufferFactory.getArray(arg),
+ // arg_direct?BufferFactory.getDirectBufferByteOffset(arg):BufferFactory.getIndirectBufferByteOffset(arg),
+ // arg_direct,
+ // ... );
// }
- // private native void fooMethod0(Object arg, int arg_byte_offset);
- // private native void fooMethod1(Object arg, int arg_byte_offset);
+ // private native void fooMethod0(Object arg, int arg_byte_offset, boolean arg_is_direct, ...);
//
// Method taking primitive array argument:
// Interface class:
@@ -772,8 +719,7 @@ public class JavaEmitter implements GlueEmitter {
// fooMethod1(getIndirectBufferArray(arg), computeIndirectBufferByteOffset(arg));
// }
// }
- // private native void fooMethod0(Object arg, int arg_byte_offset);
- // private native void fooMethod1(Object arg, int arg_byte_offset);
+ // private native void fooMethod0(Object arg, int arg_byte_offset, boolean arg_is_direct, ...);
//
// Note in particular that the public entry point taking an
// array is merely a special case of the indirect buffer case.
@@ -1947,4 +1893,4 @@ public class JavaEmitter implements GlueEmitter {
return Character.toUpperCase(string.charAt(0)) + string.substring(1);
}
-} \ No newline at end of file
+}