diff options
Diffstat (limited to 'src')
17 files changed, 843 insertions, 513 deletions
diff --git a/src/java/com/jogamp/gluegen/runtime/NativeLibrary.java b/src/java/com/jogamp/gluegen/runtime/NativeLibrary.java index c48cf89..7de75a3 100755 --- a/src/java/com/jogamp/gluegen/runtime/NativeLibrary.java +++ b/src/java/com/jogamp/gluegen/runtime/NativeLibrary.java @@ -57,7 +57,7 @@ import java.util.*; ProcAddressTable glue code generation style without additional supporting code needed in the generated library. */ -public class NativeLibrary { +public class NativeLibrary implements DynamicLookupHelper { private static final int WINDOWS = 1; private static final int UNIX = 2; private static final int MACOSX = 3; @@ -202,10 +202,10 @@ public class NativeLibrary { } /** Looks up the given function name in this native library. */ - public long lookupFunction(String functionName) { + public long dynamicLookupFunction(String funcName) { if (libraryHandle == 0) throw new RuntimeException("Library is not open"); - return dynLink.lookupSymbol(libraryHandle, functionName); + return dynLink.lookupSymbol(libraryHandle, funcName); } /** Retrieves the low-level library handle from this NativeLibrary diff --git a/src/java/com/sun/gluegen/CMethodBindingEmitter.java b/src/java/com/sun/gluegen/CMethodBindingEmitter.java index 91e3f99..c91e992 100644 --- a/src/java/com/sun/gluegen/CMethodBindingEmitter.java +++ b/src/java/com/sun/gluegen/CMethodBindingEmitter.java @@ -103,16 +103,6 @@ public class CMethodBindingEmitter extends FunctionEmitter */ private MessageFormat returnValueLengthExpression = null; - // Note: the VC++ 6.0 compiler emits hundreds of warnings when the - // (necessary) null-checking code is enabled. This appears to just - // be a compiler bug, but would be good to track down exactly why it - // is happening. When the null checking is enabled for just the - // GetPrimitiveArrayCritical calls, there are five warnings - // generated for several thousand new if tests added to the code. - // Which ones are the ones at fault? The line numbers for the - // warnings are incorrect. - private static final boolean EMIT_NULL_CHECKS = true; - protected static final String STRING_CHARS_PREFIX = "_strchars_"; // We need this in order to compute sizes of certain types @@ -369,6 +359,9 @@ public class CMethodBindingEmitter extends FunctionEmitter if (javaArgType.isPrimitiveArray() || javaArgType.isNIOBuffer()) { writer.print(", jint " + byteOffsetArgName(i)); + if(forIndirectBufferAndArrayImplementation) { + writer.print(", jboolean " + isNIOArgName(i)); + } } else if (javaArgType.isNIOBufferArray()) { writer.print(", jintArray " + byteOffsetArrayArgName(i)); @@ -383,12 +376,10 @@ public class CMethodBindingEmitter extends FunctionEmitter // writer.println("printf(\" - - - - "+ getName() + getImplSuffix() +" - - - -\\n\");"); emitBodyVariableDeclarations(writer); emitBodyUserVariableDeclarations(writer); - emitBodyVariablePreCallSetup(writer, false); - emitBodyVariablePreCallSetup(writer, true); + emitBodyVariablePreCallSetup(writer); emitBodyCallCFunction(writer); emitBodyUserVariableAssignments(writer); - emitBodyVariablePostCallCleanup(writer, true); - emitBodyVariablePostCallCleanup(writer, false); + emitBodyVariablePostCallCleanup(writer); emitBodyReturnResult(writer); writer.println("}"); writer.println(); @@ -548,22 +539,21 @@ public class CMethodBindingEmitter extends FunctionEmitter * emitBodyVariableDeclarations(), PRIOR TO calling the actual C * function. */ - protected void emitBodyVariablePreCallSetup(PrintWriter writer, boolean emittingPrimitiveArrayCritical) { + protected void emitBodyVariablePreCallSetup(PrintWriter writer) { - if (!emittingPrimitiveArrayCritical) { - // Convert all Buffers to pointers first so we don't have to - // call ReleasePrimitiveArrayCritical for any arrays if any - // incoming buffers aren't direct - if (binding.hasContainingType()) { + // Convert all Buffers to pointers first so we don't have to + // call ReleasePrimitiveArrayCritical for any arrays if any + // incoming buffers aren't direct + if (binding.hasContainingType()) { emitPointerConversion(writer, binding, binding.getContainingType(), binding.getContainingCType(), JavaMethodBindingEmitter.javaThisArgumentName(), CMethodBindingEmitter.cThisArgumentName(), null); - } + } - for (int i = 0; i < binding.getNumArguments(); i++) { + for (int i = 0; i < binding.getNumArguments(); i++) { JavaType type = binding.getJavaArgumentType(i); if (type.isJNIEnv() || binding.isArgumentThisPointer(i)) { continue; @@ -577,7 +567,6 @@ public class CMethodBindingEmitter extends FunctionEmitter pointerConversionArgumentName(javaArgName), byteOffsetArgName(i)); } - } } // Convert all arrays to pointers, and get UTF-8 versions of jstring args @@ -594,19 +583,7 @@ public class CMethodBindingEmitter extends FunctionEmitter javaArgType.isArrayOfCompoundTypeWrappers()) { boolean needsDataCopy = javaArgTypeNeedsDataCopy(javaArgType); - // We only defer the emission of GetPrimitiveArrayCritical - // calls that won't be matched up until after the function - // we're calling - if ((!needsDataCopy && !emittingPrimitiveArrayCritical) || - (needsDataCopy && emittingPrimitiveArrayCritical)) { - continue; - } - - if (EMIT_NULL_CHECKS) { - writer.print(" if ("); - writer.print(javaArgName); - writer.println(" != NULL) {"); - } + writer.println(" if ( NULL != " + javaArgName + " ) {"); Type cArgType = binding.getCArgumentType(i); String cArgTypeName = cArgType.getName(); @@ -622,12 +599,10 @@ public class CMethodBindingEmitter extends FunctionEmitter cArgTypeName = "jstring *"; } writer.print(cArgTypeName); - writer.print(") (((char*) (*env)->GetPrimitiveArrayCritical(env, "); - writer.print(javaArgName); - writer.println(", NULL)) + " + byteOffsetArgName(i) + ");"); -//if(cargtypename is void*) -// _ptrX = ((char*)convName + index1*sizeof(thisArgsJavaType)); - + writer.print(") (((char*) ( JNI_TRUE == " + isNIOArgName(i) + " ? "); + writer.print(" (*env)->GetDirectBufferAddress(env, " + javaArgName + ") : "); + writer.print(" (*env)->GetPrimitiveArrayCritical(env, " + javaArgName + ", NULL) ) ) + "); + writer.println(byteOffsetArgName(i) + ");"); } else { // Handle the case where the array elements are of a type that needs a // data copy operation to convert from the java memory model to the C @@ -761,14 +736,9 @@ public class CMethodBindingEmitter extends FunctionEmitter writer.println(); } // end of data copy - if (EMIT_NULL_CHECKS) { - writer.println(" }"); - } - } else if (javaArgType.isString()) { - if (!emittingPrimitiveArrayCritical) { - continue; - } + writer.println(" }"); + } else if (javaArgType.isString()) { emitGetStringChars(writer, javaArgName, STRING_CHARS_PREFIX + javaArgName, isUTF8Type(binding.getCArgumentType(i)), @@ -782,7 +752,7 @@ public class CMethodBindingEmitter extends FunctionEmitter * Code to clean up any variables that were declared in * emitBodyVariableDeclarations(), AFTER calling the actual C function. */ - protected void emitBodyVariablePostCallCleanup(PrintWriter writer, boolean emittingPrimitiveArrayCritical) { + protected void emitBodyVariablePostCallCleanup(PrintWriter writer) { // Release primitive arrays and temporary UTF8 strings if necessary for (int i = 0; i < binding.getNumArguments(); i++) { @@ -799,27 +769,16 @@ public class CMethodBindingEmitter extends FunctionEmitter javaArgType.isArrayOfCompoundTypeWrappers()) { boolean needsDataCopy = javaArgTypeNeedsDataCopy(javaArgType); - if ((!needsDataCopy && !emittingPrimitiveArrayCritical) || - (needsDataCopy && emittingPrimitiveArrayCritical)) { - continue; - } - - if (EMIT_NULL_CHECKS) { - writer.print(" if ("); - writer.print(javaArgName); - writer.println(" != NULL) {"); - } - String convName = pointerConversionArgumentName(javaArgName); if (!needsDataCopy) { + writer.println(" if ( NULL != " + javaArgName + " && JNI_FALSE == " + isNIOArgName(i) + " ) {"); + // Release array - writer.print(" (*env)->ReleasePrimitiveArrayCritical(env, "); - writer.print(javaArgName); - writer.print(", "); - writer.print(convName); - writer.println(", 0);"); + writer.print(" (*env)->ReleasePrimitiveArrayCritical(env, " + javaArgName + ", " + convName + ", 0);"); } else { + writer.println(" if ( NULL != " + javaArgName + " ) {"); + // clean up the case where the array elements are of a type that needed // a data copy operation to convert from the java memory model to the // C memory model (e.g., int[][], String[], etc) @@ -909,19 +868,10 @@ public class CMethodBindingEmitter extends FunctionEmitter writer.println(");"); } // end of cleaning up copied data - if (EMIT_NULL_CHECKS) { - writer.println(" }"); - } - } else if (javaArgType.isString()) { - if (emittingPrimitiveArrayCritical) { - continue; - } + writer.println(" }"); - if (EMIT_NULL_CHECKS) { - writer.print(" if ("); - writer.print(javaArgName); - writer.println(" != NULL) {"); - } + } else if (javaArgType.isString()) { + writer.println(" if ( NULL != " + javaArgName + " ) {"); if (isUTF8Type(cArgType)) { writer.print(" (*env)->ReleaseStringUTFChars(env, "); @@ -933,9 +883,7 @@ public class CMethodBindingEmitter extends FunctionEmitter writer.println(" free((void*) " + STRING_CHARS_PREFIX + javaArgName + ");"); } - if (EMIT_NULL_CHECKS) { - writer.println(" }"); - } + writer.println(" }"); } } } @@ -1038,7 +986,7 @@ public class CMethodBindingEmitter extends FunctionEmitter writer.println("_res;"); } else if (javaReturnType.isNIOBuffer() || javaReturnType.isCompoundTypeWrapper()) { - writer.println(" if (_res == NULL) return NULL;"); + writer.println(" if (NULL == _res) return NULL;"); writer.print(" return (*env)->NewDirectByteBuffer(env, _res, "); // See whether capacity has been specified if (returnValueCapacityExpression != null) { @@ -1065,11 +1013,11 @@ public class CMethodBindingEmitter extends FunctionEmitter } writer.println(");"); } else if (javaReturnType.isString()) { - writer.print(" if (_res == NULL) return NULL;"); + writer.println(" if (NULL == _res) return NULL;"); writer.println(" return (*env)->NewStringUTF(env, _res);"); } else if (javaReturnType.isArrayOfCompoundTypeWrappers() || (javaReturnType.isArray() && javaReturnType.isNIOByteBufferArray())) { - writer.println(" if (_res == NULL) return NULL;"); + writer.println(" if (NULL == _res) return NULL;"); if (returnValueLengthExpression == null) { throw new RuntimeException("Error while generating C code: no length specified for array returned from function " + binding); @@ -1163,6 +1111,9 @@ public class CMethodBindingEmitter extends FunctionEmitter // extra arguments if (type.isNIOBuffer()) { jniMangle(Integer.TYPE, buf, false); + if(forIndirectBufferAndArrayImplementation) { + jniMangle(Boolean.TYPE, buf, false); + } } else if (type.isNIOBufferArray()) { int[] intArrayType = new int[0]; c = intArrayType.getClass(); @@ -1239,9 +1190,7 @@ public class CMethodBindingEmitter extends FunctionEmitter } private void emitOutOfMemoryCheck(PrintWriter writer, String varName, String errorMessage) { - writer.print(" if ("); - writer.print(varName); - writer.println(" == NULL) {"); + writer.println(" if ( NULL == " + varName + " ) {"); writer.println(" (*env)->ThrowNew(env, (*env)->FindClass(env, \"java/lang/OutOfMemoryError\"),"); writer.print(" \"" + errorMessage); writer.print(" in native dispatcher for \\\""); @@ -1274,11 +1223,7 @@ public class CMethodBindingEmitter extends FunctionEmitter writer.print(elementTypeString); writer.println("));"); // Catch memory allocation failure - if (EMIT_NULL_CHECKS) { - emitOutOfMemoryCheck( - writer, targetVarName, - mallocFailureErrorString); - } + emitOutOfMemoryCheck( writer, targetVarName, mallocFailureErrorString); } private void emitCalloc(PrintWriter writer, @@ -1296,11 +1241,7 @@ public class CMethodBindingEmitter extends FunctionEmitter writer.print(elementTypeString); writer.println("));"); // Catch memory allocation failure - if (EMIT_NULL_CHECKS) { - emitOutOfMemoryCheck( - writer, targetVarName, - mallocFailureErrorString); - } + emitOutOfMemoryCheck( writer, targetVarName, mallocFailureErrorString); } private void emitGetStringChars(PrintWriter writer, @@ -1308,11 +1249,8 @@ public class CMethodBindingEmitter extends FunctionEmitter String receivingVarName, boolean isUTF8, boolean emitElseClause) { - if (EMIT_NULL_CHECKS) { - writer.print(" if ("); - writer.print(sourceVarName); - writer.println(" != NULL) {"); - } + writer.println(" if ( NULL != " + sourceVarName + " ) {"); + if (isUTF8) { writer.print(" "); writer.print(receivingVarName); @@ -1321,11 +1259,7 @@ public class CMethodBindingEmitter extends FunctionEmitter writer.println(", (jboolean*)NULL);"); // Catch memory allocation failure in the event that the VM didn't pin // the String and failed to allocate a copy - if (EMIT_NULL_CHECKS) { - emitOutOfMemoryCheck( - writer, receivingVarName, - "Failed to get UTF-8 chars for argument \\\""+sourceVarName+"\\\""); - } + emitOutOfMemoryCheck( writer, receivingVarName, "Failed to get UTF-8 chars for argument \\\""+sourceVarName+"\\\""); } else { // The UTF-16 case is basically Windows specific. Unix platforms // tend to use only the UTF-8 encoding. On Windows the problem @@ -1341,17 +1275,15 @@ public class CMethodBindingEmitter extends FunctionEmitter "Could not allocate temporary buffer for copying string argument \\\""+sourceVarName+"\\\""); writer.println(" (*env)->GetStringRegion(env, " + sourceVarName + ", 0, (*env)->GetStringLength(env, " + sourceVarName + "), " + receivingVarName + ");"); } - if (EMIT_NULL_CHECKS) { - writer.print(" }"); - if (emitElseClause) { - writer.print(" else {"); - writer.print(" "); - writer.print(receivingVarName); - writer.println(" = NULL;"); - writer.println(" }"); - } else { - writer.println(); - } + writer.print(" }"); + if (emitElseClause) { + writer.print(" else {"); + writer.print(" "); + writer.print(receivingVarName); + writer.println(" = NULL;"); + writer.println(" }"); + } else { + writer.println(); } } @@ -1361,12 +1293,8 @@ public class CMethodBindingEmitter extends FunctionEmitter String receivingVarName, String byteOffsetVarName, boolean emitElseClause) { - if (EMIT_NULL_CHECKS) { - writer.print(" if ("); - writer.print(sourceVarName); - writer.println(" != NULL) {"); - writer.print(" "); - } + writer.println(" if ( NULL != " + sourceVarName + " ) {"); + writer.print(" "); writer.print(" "); writer.print(receivingVarName); @@ -1377,17 +1305,15 @@ public class CMethodBindingEmitter extends FunctionEmitter writer.print(sourceVarName); writer.println(")) + " + ((byteOffsetVarName != null) ? byteOffsetVarName : "0") + ");"); - if (EMIT_NULL_CHECKS) { - writer.print(" }"); - if (emitElseClause) { - writer.println(" else {"); - writer.print(" "); - writer.print(receivingVarName); - writer.println(" = NULL;"); - writer.println(" }"); - } else { - writer.println(); - } + writer.print(" }"); + if (emitElseClause) { + writer.println(" else {"); + writer.print(" "); + writer.print(receivingVarName); + writer.println(" = NULL;"); + writer.println(" }"); + } else { + writer.println(); } } @@ -1504,6 +1430,14 @@ public class CMethodBindingEmitter extends FunctionEmitter return s + "_byte_offset"; } + protected String isNIOArgName(int i) { + return isNIOArgName(binding.getArgumentName(i)); + } + + protected String isNIOArgName(String s) { + return s + "_is_nio"; + } + protected String byteOffsetArrayArgName(int i) { return binding.getArgumentName(i) + "_byte_offset_array"; } 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 +} diff --git a/src/java/com/sun/gluegen/JavaMethodBindingEmitter.java b/src/java/com/sun/gluegen/JavaMethodBindingEmitter.java index 2d7a8b2..da5484b 100644 --- a/src/java/com/sun/gluegen/JavaMethodBindingEmitter.java +++ b/src/java/com/sun/gluegen/JavaMethodBindingEmitter.java @@ -293,11 +293,7 @@ public class JavaMethodBindingEmitter extends FunctionEmitter protected void emitName(PrintWriter writer) { if (forImplementingMethodCall) { - if (forIndirectBufferAndArrayImplementation) { - writer.print(getImplMethodName(false)); - } else { - writer.print(getImplMethodName(true)); - } + writer.print(getImplMethodName()); } else { writer.print(getName()); } @@ -348,6 +344,9 @@ public class JavaMethodBindingEmitter extends FunctionEmitter if (forDirectBufferImplementation || forIndirectBufferAndArrayImplementation) { if (type.isNIOBuffer()) { writer.print(", int " + byteOffsetArgName(i)); + if(!directNIOOnly) { + writer.print(", boolean " + isNIOArgName(i)); + } } else if (type.isNIOBufferArray()) { writer.print(", int[] " + byteOffsetArrayArgName(i)); @@ -356,6 +355,9 @@ public class JavaMethodBindingEmitter extends FunctionEmitter // Add offset argument after each primitive array if (type.isPrimitiveArray()) { + if(directNIOOnly) { + throw new RuntimeException("NIODirectOnly "+binding+" is set, but "+getArgumentName(i)+" is a primitive array"); + } writer.print(", int " + offsetArgName(i)); } } @@ -363,12 +365,8 @@ public class JavaMethodBindingEmitter extends FunctionEmitter } - protected String getImplMethodName(boolean direct) { - if (direct) { - return binding.getName() + "0"; - } else { - return binding.getName() + "1"; - } + protected String getImplMethodName() { + return binding.getName() + ( directNIOOnly ? "0" : "1" ); } protected String byteOffsetArgName(int i) { @@ -379,6 +377,14 @@ public class JavaMethodBindingEmitter extends FunctionEmitter return s + "_byte_offset"; } + protected String isNIOArgName(int i) { + return isNIOArgName(binding.getArgumentName(i)); + } + + protected String isNIOArgName(String s) { + return s + "_is_direct"; + } + protected String byteOffsetArrayArgName(int i) { return getArgumentName(i) + "_byte_offset_array"; } @@ -428,7 +434,6 @@ public class JavaMethodBindingEmitter extends FunctionEmitter protected void emitArrayLengthAndNIOBufferChecks(MethodBinding binding, PrintWriter writer) { - boolean firstBuffer = true; // Check lengths of any incoming arrays if necessary for (int i = 0; i < binding.getNumArguments(); i++) { Type type = binding.getCArgumentType(i); @@ -439,6 +444,8 @@ public class JavaMethodBindingEmitter extends FunctionEmitter writer.println(" throw new " + getRuntimeExceptionType() + "(\"Length of array \\\"" + getArgumentName(i) + "\\\" was less than the required " + arrayType.getLength() + "\");"); + // FIXME: What is this ??? Until resolved - throw an exception ! + throw new RuntimeException("????? "+binding+": binding.getCArgumentType("+i+").isArray(): "+type); } else { JavaType javaType = binding.getJavaArgumentType(i); if (javaType.isNIOBuffer()) { @@ -447,29 +454,8 @@ public class JavaMethodBindingEmitter extends FunctionEmitter writer.println(" throw new " + getRuntimeExceptionType() + "(\"Argument \\\"" + getArgumentName(i) + "\\\" was not a direct buffer\");"); } else { - if(firstBuffer) { - firstBuffer = false; - 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() + - "(\"Argument \\\"" + getArgumentName(i) + - "\\\" : Buffers passed to this method must all be either direct or indirect\");"); - } + writer.print(" boolean " + isNIOArgName(i) + " = "); + writer.println(getArgumentName(i) + " != null && BufferFactory.isDirect(" + getArgumentName(i) + ");"); } } else if (javaType.isNIOBufferArray()) { // All buffers passed down in an array of NIO buffers must be direct @@ -521,11 +507,11 @@ public class JavaMethodBindingEmitter extends FunctionEmitter } } - protected void emitCall(MethodBinding binding, PrintWriter writer, boolean direct) { - writer.print(getImplMethodName(direct)); + protected void emitCall(MethodBinding binding, PrintWriter writer) { + writer.print(getImplMethodName()); writer.print("("); - emitCallArguments(binding, writer, direct); - writer.print(")"); + emitCallArguments(binding, writer); + writer.print(");"); } @@ -550,13 +536,6 @@ public class JavaMethodBindingEmitter extends FunctionEmitter } } - if (binding.signatureCanUseIndirectNIO() && !directNIOOnly) { - // Must generate two calls for this gated on whether the NIO - // buffers coming in are all direct or indirect - writer.println("if (_direct) {"); - writer.print (" "); - } - if (needsResultAssignment) { writer.print(" _res = "); } else { @@ -566,43 +545,9 @@ public class JavaMethodBindingEmitter extends FunctionEmitter } } - if (binding.signatureUsesJavaPrimitiveArrays() && - !binding.signatureCanUseIndirectNIO()) { - // FIXME: what happens with a C function of the form - // void foo(int* arg0, void* arg1); - // ? - - // Only one call being made in this body, going to indirect - // buffer / array entry point - emitCall(binding, writer, false); - writer.print(";"); - writer.println(); - } else { - emitCall(binding, writer, true); - writer.print(";"); - } + emitCall(binding, writer); + writer.println(); - if (binding.signatureCanUseIndirectNIO() && !directNIOOnly) { - // Must generate two calls for this gated on whether the NIO - // buffers coming in are all direct or indirect - writer.println(); - writer.println(" } else {"); - writer.print (" "); - if (needsResultAssignment) { - writer.print(" _res = "); - } else { - writer.print(" "); - if (!returnType.isVoid()) { - writer.print("return "); - } - } - emitCall(binding, writer, false); - writer.print(";"); - writer.println(); - writer.println(" }"); - } else { - writer.println(); - } emitPostCallCleanup(binding, writer); emitPrologueOrEpilogue(epilogue, writer); if (needsResultAssignment) { @@ -610,7 +555,7 @@ public class JavaMethodBindingEmitter extends FunctionEmitter } } - protected int emitCallArguments(MethodBinding binding, PrintWriter writer, boolean direct) { + protected int emitCallArguments(MethodBinding binding, PrintWriter writer) { boolean needComma = false; int numArgsEmitted = 0; @@ -643,14 +588,25 @@ public class JavaMethodBindingEmitter extends FunctionEmitter writer.print("(("); } - if (type.isNIOBuffer() && !direct) { - writer.print("BufferFactory.getArray(" + getArgumentName(i) + ")"); + if (type.isNIOBuffer()) { + if(type.isNIOPointerBuffer()) { + if (directNIOOnly) { + writer.print( getArgumentName(i)+ " != null ? " + getArgumentName(i) + ".getBuffer() : null"); + } else { + writer.print( isNIOArgName(i) + " ? ( " + getArgumentName(i)+ " != null ? " + getArgumentName(i) + ".getBuffer() : null )"); + writer.print( " : BufferFactory.getArray(" + getArgumentName(i) + ")" ); + } + } else { + if (directNIOOnly) { + writer.print( getArgumentName(i) ); + } else { + writer.print( isNIOArgName(i) + " ? " + getArgumentName(i) + " : BufferFactory.getArray(" + getArgumentName(i) + ")" ); + } + } } else if (type.isArrayOfCompoundTypeWrappers()) { - writer.print(getArgumentName(i) + COMPOUND_ARRAY_SUFFIX); - } else if(type.isNIOPointerBuffer()) { - writer.print(getArgumentName(i)+"!=null?"+getArgumentName(i) + ".getBuffer():null"); + writer.print(getArgumentName(i) + COMPOUND_ARRAY_SUFFIX); } else { - writer.print(getArgumentName(i)); + writer.print(getArgumentName(i)); } if (type.isCompoundTypeWrapper()) { @@ -658,18 +614,17 @@ public class JavaMethodBindingEmitter extends FunctionEmitter writer.print(getArgumentName(i)); writer.print(".getBuffer())"); } + if (type.isNIOBuffer()) { - if (direct) { - writer.print(", BufferFactory.getDirectBufferByteOffset(" + getArgumentName(i) + ")"); + if (directNIOOnly) { + writer.print( ", BufferFactory.getDirectBufferByteOffset(" + getArgumentName(i) + ")"); } else { - writer.print(", BufferFactory.getIndirectBufferByteOffset(" + getArgumentName(i) + ")"); + writer.print( ", " + isNIOArgName(i) + " ? BufferFactory.getDirectBufferByteOffset(" + getArgumentName(i) + ")"); + writer.print( " : BufferFactory.getIndirectBufferByteOffset(" + getArgumentName(i) + ")"); } } else if (type.isNIOBufferArray()) { writer.print(", " + byteOffsetArrayArgName(i)); - } - - // Add Array offset parameter for primitive arrays - if (type.isPrimitiveArray()) { + } else if (type.isPrimitiveArray()) { if(type.isFloatArray()) { writer.print(", BufferFactory.SIZEOF_FLOAT * "); } else if(type.isDoubleArray()) { @@ -690,6 +645,17 @@ public class JavaMethodBindingEmitter extends FunctionEmitter writer.print(offsetArgName(i)); } + if (type.isNIOBuffer()) { + if (!directNIOOnly) { + writer.print( ", " + isNIOArgName(i) ); + } + } else if (type.isPrimitiveArray()) { + if (directNIOOnly) { + throw new RuntimeException("NIODirectOnly "+binding+" is set, but "+getArgumentName(i)+" is a primitive array"); + } + writer.print( ", false"); + } + needComma = true; ++numArgsEmitted; } diff --git a/src/java/com/sun/gluegen/MethodBinding.java b/src/java/com/sun/gluegen/MethodBinding.java index dae381b..5805be1 100644 --- a/src/java/com/sun/gluegen/MethodBinding.java +++ b/src/java/com/sun/gluegen/MethodBinding.java @@ -81,7 +81,7 @@ public class MethodBinding { this.containingType = bindingToCopy.containingType; this.containingCType = bindingToCopy.containingCType; this.javaReturnType = bindingToCopy.javaReturnType; - this.javaArgumentTypes = new ArrayList<JavaType>(bindingToCopy.javaArgumentTypes); + this.javaArgumentTypes = ( null != bindingToCopy.javaArgumentTypes ) ? new ArrayList<JavaType>(bindingToCopy.javaArgumentTypes) : null; this.computedSignatureProperties = bindingToCopy.computedSignatureProperties; this.argumentsUseNIO = bindingToCopy.argumentsUseNIO; this.signatureUsesNIO = bindingToCopy.signatureUsesNIO; diff --git a/src/java/com/sun/gluegen/procaddress/ProcAddressCMethodBindingEmitter.java b/src/java/com/sun/gluegen/procaddress/ProcAddressCMethodBindingEmitter.java index 54263a5..b7fac1b 100755 --- a/src/java/com/sun/gluegen/procaddress/ProcAddressCMethodBindingEmitter.java +++ b/src/java/com/sun/gluegen/procaddress/ProcAddressCMethodBindingEmitter.java @@ -140,12 +140,10 @@ public class ProcAddressCMethodBindingEmitter extends CMethodBindingEmitter { super.emitBodyVariableDeclarations(writer); } - protected void emitBodyVariablePreCallSetup(PrintWriter writer, - boolean emittingPrimitiveArrayCritical) { - super.emitBodyVariablePreCallSetup(writer, emittingPrimitiveArrayCritical); + protected void emitBodyVariablePreCallSetup(PrintWriter writer) { + super.emitBodyVariablePreCallSetup(writer); if (callThroughProcAddress) { - if (!emittingPrimitiveArrayCritical) { // set the function pointer to the value of the passed-in procAddress FunctionSymbol cSym = getBinding().getCSymbol(); String funcPointerTypedefName = emitter.getFunctionPointerTypedefName(cSym); @@ -162,7 +160,6 @@ public class ProcAddressCMethodBindingEmitter extends CMethodBindingEmitter { writer.println(") (intptr_t) procAddress;"); writer.println(" assert(" + ptrVarName + " != NULL);"); - } } } diff --git a/src/java/com/sun/gluegen/procaddress/ProcAddressJavaMethodBindingEmitter.java b/src/java/com/sun/gluegen/procaddress/ProcAddressJavaMethodBindingEmitter.java index f6ae58e..2dda752 100755 --- a/src/java/com/sun/gluegen/procaddress/ProcAddressJavaMethodBindingEmitter.java +++ b/src/java/com/sun/gluegen/procaddress/ProcAddressJavaMethodBindingEmitter.java @@ -110,8 +110,8 @@ public class ProcAddressJavaMethodBindingEmitter extends JavaMethodBindingEmitte return numEmitted; } - protected String getImplMethodName(boolean direct) { - String name = super.getImplMethodName(direct); + protected String getImplMethodName() { + String name = super.getImplMethodName(); if (callThroughProcAddress) { return ProcAddressEmitter.WRAP_PREFIX + name; } @@ -131,8 +131,8 @@ public class ProcAddressJavaMethodBindingEmitter extends JavaMethodBindingEmitte } } - protected int emitCallArguments(MethodBinding binding, PrintWriter writer, boolean indirect) { - int numEmitted = super.emitCallArguments(binding, writer, indirect); + protected int emitCallArguments(MethodBinding binding, PrintWriter writer) { + int numEmitted = super.emitCallArguments(binding, writer); if (callThroughProcAddress) { if (numEmitted > 0) { writer.print(", "); diff --git a/src/junit/com/jogamp/gluegen/test/junit/BaseTest1.java b/src/junit/com/jogamp/gluegen/test/junit/BaseTest1.java new file mode 100644 index 0000000..ddf2906 --- /dev/null +++ b/src/junit/com/jogamp/gluegen/test/junit/BaseTest1.java @@ -0,0 +1,250 @@ +/* + * Copyright (c) 2010 Sven Gothel. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name Sven Gothel or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + */ + +package com.jogamp.gluegen.test.junit; + +import com.jogamp.gluegen.runtime.BufferFactory; +import com.jogamp.gluegen.runtime.PointerBuffer; +import java.nio.*; +import java.io.File; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.net.URISyntaxException; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import static java.lang.System.*; +import static com.jogamp.gluegen.test.junit.BuildEnvironment.*; + +/** + * @author Michael Bien + * @author Sven Gothel + */ +public class BaseTest1 { + + /** + * Verifies the existence and creation of the generated class. + */ + public void testClassExist(String name) throws Exception { + String ifName = "com.jogamp.gluegen.test.junit.Binding"+name; + String implName = "com.jogamp.gluegen.test.junit.impl.Binding"+name+"Impl"; + + Class<?> clazzIf = Class.forName(ifName); + Class<?> clazzImpl = Class.forName(implName); + + Assert.assertNotNull(ifName+" does not exist", clazzIf); + Assert.assertNotNull(implName+" does not exist", clazzImpl); + + Assert.assertEquals((int)1, clazzIf.getDeclaredField("CONSTANT_ONE").get(null)); + + Object obj = clazzImpl.newInstance(); + Assert.assertTrue("Not of type "+ifName, clazzIf.isAssignableFrom(obj.getClass())); + Assert.assertTrue("Not of type com.jogamp.gluegen.test.junit.BindingTest1", (obj instanceof com.jogamp.gluegen.test.junit.BindingTest1)); + } + + /** + * Verifies if all generated method signatures are completed, + * ie a compilation only coverage test without functional tests. + */ + public void chapter__TestCoverageSignature(BindingTest1 binding) throws Exception { + int i; + long result; + long context = 0; + ByteBuffer bb=null; + PointerBuffer pb=null; + LongBuffer lb=null; + long[] larray = null; + int array_offset = 0; + String str=null; + String[] strings = null; + IntBuffer ib = null; + int[] iarray = null; + int iarray_offset = 0; + + result = binding.arrayTest(context, pb); + result = binding.arrayTest(context, larray, array_offset); + result = binding.arrayTestNioOnly(context, pb); + + result = binding.bufferTest(bb); + result = binding.bufferTestNioOnly(bb); + + result = binding.doubleTest(context, bb, pb, bb, pb); + result = binding.doubleTest(context, bb, larray, array_offset, bb, larray, array_offset); + result = binding.doubleTestNioOnly(context, bb, pb, bb, pb); + + result = binding.mixedTest(context, bb, pb); + result = binding.mixedTest(context, bb, larray, array_offset); + result = binding.mixedTestNioOnly(context, bb, pb); + + result = binding.nopTest(); + + i = binding.strToInt(str); + str = binding.intToStr(i); + + i = binding.stringArrayRead(strings, i); + + i = binding.intArrayRead(ib, i); + i = binding.intArrayRead(iarray, iarray_offset, i); + + } + + /** + * Verifies if all methods / signatures are properly generated, + * can be invoked and functions. + * This is a compilation (coverage) and runtime time (semantic) test. + * This covers indirect primitive arrays and direct NIO buffers. + */ + public void chapter03TestCoverageFunctionalityDirectNIOAndPrimitiveArray(BindingTest1 binding) throws Exception { + int i; + long result; + + long context = 1; + ByteBuffer bb1 = BufferFactory.newDirectByteBuffer(BufferFactory.SIZEOF_LONG); + LongBuffer bb1L = bb1.asLongBuffer(); + bb1L.put(0, 10); + + ByteBuffer bb2 = BufferFactory.newDirectByteBuffer(BufferFactory.SIZEOF_LONG); + LongBuffer bb2L = bb2.asLongBuffer(); + bb2L.put(0, 100); + + PointerBuffer pb1 = PointerBuffer.allocateDirect(BindingTest1.ARRAY_SIZE); + for(i=0; i<BindingTest1.ARRAY_SIZE; i++) { + pb1.put(i, 1000); + } + PointerBuffer pb2 = PointerBuffer.allocateDirect(BindingTest1.ARRAY_SIZE); + for(i=0; i<BindingTest1.ARRAY_SIZE; i++) { + pb2.put(i, 10000); + } + + long[] larray1 = new long[BindingTest1.ARRAY_SIZE]; + int array1_offset = 0; + for(i=0; i<BindingTest1.ARRAY_SIZE; i++) { + larray1[i]= 1000; + } + + long[] larray2 = new long[BindingTest1.ARRAY_SIZE]; + int array2_offset = 0; + for(i=0; i<BindingTest1.ARRAY_SIZE; i++) { + larray2[i]= 10000; + } + + result = binding.arrayTest(context, pb1); + Assert.assertTrue("Wrong result: "+result, 1+8000==result); + + result = binding.arrayTest(context, larray1, array1_offset); + Assert.assertTrue("Wrong result: "+result, 1+8000==result); + + result = binding.arrayTestNioOnly(context, pb1); + Assert.assertTrue("Wrong result: "+result, 1+8000==result); + + result = binding.bufferTest(bb1); + Assert.assertTrue("Wrong result: "+result, 10==result); + + result = binding.bufferTestNioOnly(bb1); + Assert.assertTrue("Wrong result: "+result, 10==result); + + result = binding.doubleTest(context, bb1, pb1, bb2, pb2); + Assert.assertTrue("Wrong result: "+result, 1+10+8000+100+80000==result); + + result = binding.doubleTest(context, bb1, larray1, array1_offset, bb2, larray2, array2_offset); + Assert.assertTrue("Wrong result: "+result, 1+10+8000+100+80000==result); + + result = binding.doubleTestNioOnly(context, bb1, pb1, bb2, pb2); + Assert.assertTrue("Wrong result: "+result, 1+10+8000+100+80000==result); + + result = binding.mixedTest(context, bb1, pb1); + Assert.assertTrue("Wrong result: "+result, 1+10+8000==result); + + result = binding.mixedTest(context, bb1, larray1, array1_offset); + Assert.assertTrue("Wrong result: "+result, 1+10+8000==result); + + result = binding.mixedTestNioOnly(context, bb1, pb1); + Assert.assertTrue("Wrong result: "+result, 1+10+8000==result); + + result = binding.nopTest(); + Assert.assertTrue("Wrong result: "+result, 42==result); + + i = binding.strToInt("42"); + Assert.assertTrue("Wrong result: "+i, 42==i); + + String str = binding.intToStr(42); + Assert.assertTrue("Wrong result: "+str, str.equals("42")); + + i = binding.stringArrayRead(new String[] { "1234", "5678", "9a" }, 3); + Assert.assertTrue("Wrong result: "+i, 10==i); + + ByteBuffer bb3 = BufferFactory.newDirectByteBuffer(BufferFactory.SIZEOF_INT * 3); + IntBuffer ib = bb3.asIntBuffer(); + ib.put(0, 1); + ib.put(1, 2); + ib.put(2, 3); + + int[] iarray = new int[] { 1, 2, 3 }; + int iarray_offset = 0; + + i = binding.intArrayRead(ib, 3); + Assert.assertTrue("Wrong result: "+i, 6==i); + + i = binding.intArrayRead(iarray, 0, 3); + Assert.assertTrue("Wrong result: "+i, 6==i); + } + + /** + * This covers indirect primitive arrays and indirect NIO buffers. + */ + public void chapter04TestSomeFunctionsAllIndirect(BindingTest1 binding) throws Exception { + int i; + long result; + + IntBuffer ib = IntBuffer.allocate(3); + ib.put(0, 1); + ib.put(1, 2); + ib.put(2, 3); + + int[] iarray = new int[] { 1, 2, 3 }; + int iarray_offset = 0; + + i = binding.intArrayRead(ib, 3); + Assert.assertTrue("Wrong result: "+i, 6==i); + + i = binding.intArrayRead(iarray, 0, 3); + Assert.assertTrue("Wrong result: "+i, 6==i); + } + +} diff --git a/src/junit/com/jogamp/gluegen/test/junit/Test1.java b/src/junit/com/jogamp/gluegen/test/junit/Test1.java deleted file mode 100644 index bbb7a0a..0000000 --- a/src/junit/com/jogamp/gluegen/test/junit/Test1.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 2010 Sven Gothel. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name Sven Gothel or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - */ - -package com.jogamp.gluegen.test.junit; - -import com.jogamp.gluegen.test.junit.impl.BindingTest1Impl; - -import com.jogamp.gluegen.runtime.BufferFactory; -import com.jogamp.gluegen.runtime.PointerBuffer; -import java.nio.*; -import java.io.File; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.net.URISyntaxException; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import static java.lang.System.*; -import static com.jogamp.gluegen.test.junit.BuildEnvironment.*; - -/** - * @author Michael Bien - * @author Sven Gothel - */ -public class Test1 { - - /** - * Verifies loading of the new library. - */ - @Test - public void chapter01TestLoadLibrary() throws Exception { - String nativesPath = testOutput + "/build/natives"; - System.load(nativesPath + "/libtest1.so"); - } - - /** - * Verifies the existence and creation of the generated class. - */ - @Test - public void chapter01TestClassExist() throws Exception { - Class<?> clazzIf = Class.forName("com.jogamp.gluegen.test.junit.BindingTest1"); - Class<?> clazzImpl = Class.forName("com.jogamp.gluegen.test.junit.impl.BindingTest1Impl"); - - Assert.assertNotNull("com.jogamp.gluegen.test.junit.BindingTest1 does not exist", clazzIf); - Assert.assertNotNull("com.jogamp.gluegen.test.junit.impl.BindingTest1Impl does not exist", clazzImpl); - - Assert.assertEquals((int)1, clazzIf.getDeclaredField("CONSTANT_ONE").get(null)); - - Object obj = clazzImpl.newInstance(); - Assert.assertTrue("Not of type com.jogamp.gluegen.test.junit.BindingTest1", (obj instanceof com.jogamp.gluegen.test.junit.BindingTest1)); - - BindingTest1 bindingTest1 = (BindingTest1) obj; - Assert.assertTrue("nopTest1 failed", 42==bindingTest1.nopTest()); - } - - /** - * Verifies if all methods / signatures are properly generated, - * and can be invoked. - * Gluegen Coverage test. - * This is a compilation and runtime time test. - */ - @Test - public void chapter01TestCoverage() throws Exception { - int dummy; - - int array_size = 10; - long context = 0; - ByteBuffer bb1 = BufferFactory.newDirectByteBuffer(PointerBuffer.elementSize() * array_size); - ByteBuffer bb2 = BufferFactory.newDirectByteBuffer(PointerBuffer.elementSize() * array_size); - - PointerBuffer pb1 = PointerBuffer.allocateDirect(array_size); - PointerBuffer pb2 = PointerBuffer.allocateDirect(array_size); - - long[] larray1 = new long[array_size]; - int array1_offset = 0; - - long[] larray2 = new long[array_size]; - int array2_offset = 0; - - BindingTest1 binding = new BindingTest1Impl(); - - /** Interface to C language function: <br> <code> int arrayTest(long context, foo * array); </code> */ - dummy = binding.arrayTest(context, pb1); - Assert.assertTrue(42==dummy); - - /** Interface to C language function: <br> <code> int arrayTest(long context, foo * array); </code> */ - dummy = binding.arrayTest(context, larray1, array1_offset); - Assert.assertTrue(42==dummy); - - /** Interface to C language function: <br> <code> int bufferTest(void * object); </code> */ - dummy = binding.bufferTest(bb1); - Assert.assertTrue(42==dummy); - - /** Interface to C language function: <br> <code> int doubleTest(long context, void * object1, foo * array1, void * object2, foo * array2); </code> */ - dummy = binding.doubleTest(context, bb1, pb1, bb2, pb2); - Assert.assertTrue(42==dummy); - - /** Interface to C language function: <br> <code> int doubleTest(long context, void * object1, foo * array1, void * object2, foo * array2); </code> */ - dummy = binding.doubleTest(context, bb1, larray1, array1_offset, bb2, larray2, array2_offset); - Assert.assertTrue(42==dummy); - - /** Interface to C language function: <br> <code> int mixedTest(long context, void * object, foo * array); </code> */ - dummy = binding.mixedTest(context, bb1, pb1); - Assert.assertTrue(42==dummy); - - /** Interface to C language function: <br> <code> int mixedTest(long context, void * object, foo * array); </code> */ - dummy = binding.mixedTest(context, bb1, larray1, array1_offset); - Assert.assertTrue(42==dummy); - - /** Interface to C language function: <br> <code> int nopTest(); </code> */ - dummy = binding.nopTest(); - Assert.assertTrue(42==dummy); - } - -} diff --git a/src/junit/com/jogamp/gluegen/test/junit/Test1p1JavaEmitter.java b/src/junit/com/jogamp/gluegen/test/junit/Test1p1JavaEmitter.java new file mode 100644 index 0000000..0438a76 --- /dev/null +++ b/src/junit/com/jogamp/gluegen/test/junit/Test1p1JavaEmitter.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2010 Sven Gothel. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name Sven Gothel or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + */ + +package com.jogamp.gluegen.test.junit; + +import com.jogamp.gluegen.test.junit.impl.BindingTest1p1Impl; + +import com.jogamp.gluegen.runtime.BufferFactory; +import com.jogamp.gluegen.runtime.PointerBuffer; +import java.nio.*; +import java.io.File; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.net.URISyntaxException; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import static java.lang.System.*; +import static com.jogamp.gluegen.test.junit.BuildEnvironment.*; + +/** + * @author Michael Bien + * @author Sven Gothel + */ +public class Test1p1JavaEmitter extends BaseTest1 { + + /** + * Verifies loading of the new library. + */ + @Test + public void chapter01TestLoadLibrary() throws Exception { + String nativesPath = testOutput + "/build/natives"; + System.load(nativesPath + "/libtest1p1.so"); + } + + /** + * Verifies the existence and creation of the generated class. + */ + @Test + public void chapter02TestClassExist() throws Exception { + testClassExist("Test1p1"); + } + + /** + * Verifies if all generated method signatures are completed, + * ie a compilation only coverage test without functional tests. + */ + public void chapter__TestCoverageSignature() throws Exception { + chapter__TestCoverageSignature(new BindingTest1p1Impl()); + } + + /** + * Verifies if all methods / signatures are properly generated, + * can be invoked and functions. + * This is a compilation (coverage) and runtime time (semantic) test. + * This covers indirect primitive arrays and direct NIO buffers. + */ + @Test + public void chapter03TestCoverageFunctionalityDirectNIOAndPrimitiveArray() throws Exception { + chapter03TestCoverageFunctionalityDirectNIOAndPrimitiveArray(new BindingTest1p1Impl()); + } + + /** + * This covers indirect primitive arrays and indirect NIO buffers. + */ + @Test + public void chapter04TestSomeFunctionsAllIndirect() throws Exception { + chapter04TestSomeFunctionsAllIndirect(new BindingTest1p1Impl()); + } + +} diff --git a/src/junit/com/jogamp/gluegen/test/junit/Test1p2ProcAddressEmitter.java b/src/junit/com/jogamp/gluegen/test/junit/Test1p2ProcAddressEmitter.java new file mode 100644 index 0000000..53ea5c8 --- /dev/null +++ b/src/junit/com/jogamp/gluegen/test/junit/Test1p2ProcAddressEmitter.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2010 Sven Gothel. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name Sven Gothel or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + */ + +package com.jogamp.gluegen.test.junit; + +import com.jogamp.gluegen.test.junit.impl.BindingTest1p2Impl; + +import com.jogamp.gluegen.runtime.BufferFactory; +import com.jogamp.gluegen.runtime.PointerBuffer; +import com.jogamp.gluegen.runtime.NativeLibrary; +import com.jogamp.gluegen.runtime.DynamicLookupHelper; +import java.nio.*; +import java.io.File; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.net.URISyntaxException; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import static java.lang.System.*; +import static com.jogamp.gluegen.test.junit.BuildEnvironment.*; + +/** + * @author Michael Bien + * @author Sven Gothel + */ +public class Test1p2ProcAddressEmitter extends BaseTest1 { + + DynamicLookupHelper dynamicLookupHelper; + + /** + * Verifies loading of the new library. + */ + @Test + public void chapter01TestLoadLibrary() throws Exception { + System.loadLibrary("test1p2"); + dynamicLookupHelper = NativeLibrary.open("test1p2", getClass().getClassLoader(), true); + Assert.assertNotNull("NativeLibrary.open(test1p2) failed", dynamicLookupHelper); + + BindingTest1p2Impl.resetProcAddressTable(dynamicLookupHelper); + } + + /** + * Verifies the existence and creation of the generated class. + */ + @Test + public void chapter02TestClassExist() throws Exception { + testClassExist("Test1p2"); + } + + /** + * Verifies if all generated method signatures are completed, + * ie a compilation only coverage test without functional tests. + */ + public void chapter__TestCoverageSignature() throws Exception { + chapter__TestCoverageSignature(new BindingTest1p2Impl()); + } + + /** + * Verifies if all methods / signatures are properly generated, + * can be invoked and functions. + * This is a compilation (coverage) and runtime time (semantic) test. + * This covers indirect primitive arrays and direct NIO buffers. + */ + @Test + public void chapter03TestCoverageFunctionalityDirectNIOAndPrimitiveArray() throws Exception { + chapter03TestCoverageFunctionalityDirectNIOAndPrimitiveArray(new BindingTest1p2Impl()); + } + + /** + * This covers indirect primitive arrays and indirect NIO buffers. + */ + @Test + public void chapter04TestSomeFunctionsAllIndirect() throws Exception { + chapter04TestSomeFunctionsAllIndirect(new BindingTest1p2Impl()); + } + + public static void main(String[] args) { + Test1p2ProcAddressEmitter test = new Test1p2ProcAddressEmitter(); + try { + test.chapter01TestLoadLibrary(); + test.chapter02TestClassExist(); + test.chapter03TestCoverageFunctionalityDirectNIOAndPrimitiveArray(); + test.chapter04TestSomeFunctionsAllIndirect(); + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/src/junit/com/jogamp/gluegen/test/junit/test1-common.cfg b/src/junit/com/jogamp/gluegen/test/junit/test1-common.cfg new file mode 100644 index 0000000..d775424 --- /dev/null +++ b/src/junit/com/jogamp/gluegen/test/junit/test1-common.cfg @@ -0,0 +1,18 @@ + +NIODirectOnly arrayTestNioOnly +NIODirectOnly bufferTestNioOnly +NIODirectOnly mixedTestNioOnly +NIODirectOnly doubleTestNioOnly + +ReturnsString intToStr +ArgumentIsString strToInt 0 +ArgumentIsString stringArrayRead 0 + +CustomCCode #include "test1.h" + +# Imports needed by all glue code +Import java.nio.* +Import java.util.* + + + diff --git a/src/junit/com/jogamp/gluegen/test/junit/test1-gluegen.cfg b/src/junit/com/jogamp/gluegen/test/junit/test1-gluegen.cfg index 291e6cc..9d0f856 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/test1-gluegen.cfg +++ b/src/junit/com/jogamp/gluegen/test/junit/test1-gluegen.cfg @@ -1,35 +1,9 @@ Package com.jogamp.gluegen.test.junit JavaClass BindingTest1 -Style InterfaceAndImpl +Style InterfaceOnly JavaOutputDir classes -NativeOutputDir native -# Use a ProcAddressTable so we dynamically look up the routines -#ProcAddressNameExpr PFN $UPPERCASE({0}) PROC -#EmitProcAddressTable true -#ProcAddressTableClassName BindingTest1ProcAddressTable -#GetProcAddressTableExpr _table +Include test1-common.cfg -# Force all of the methods to be emitted using dynamic linking so we -# don't need to link against any emulation library on the desktop or -# depend on the presence of an import library for a particular device -#ForceProcAddressGen __ALL__ - -# Also force the calling conventions of the locally generated function -# pointer typedefs for these routines to MYAPIENTRY -#LocalProcAddressCallingConvention __ALL__ MYAPIENTRY - -#EmitProcAddressTable true -#ProcAddressTableClassName CLProcAddressTable -#GetProcAddressTableExpr addressTable -#ProcAddressNameExpr $UpperCase(arg) -#ForceProcAddressGen clGetGLContextInfoKHR - -CustomCCode #include "test1.h" - -# Imports needed by all glue code -Import java.nio.* -Import java.util.* -Import com.jogamp.gluegen.test.junit.BindingTest1 diff --git a/src/junit/com/jogamp/gluegen/test/junit/test1.c b/src/junit/com/jogamp/gluegen/test/junit/test1.c index 6b63f90..31c5f40 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/test1.c +++ b/src/junit/com/jogamp/gluegen/test/junit/test1.c @@ -1,21 +1,101 @@ #include "test1.h" +#include <assert.h> +#include <stdlib.h> -int nopTest() { +foo nopTest() { return 42; } -int arrayTest(long context, foo * array) { - return 42; +foo arrayTest(long context, foo * array) { + foo r=0; + int i; + assert(NULL!=array); + // printf("array test - %p\n", array); + for(i=0; i<ARRAY_SIZE; i++) { + r+=array[i]; + } + return r+context; } -int bufferTest(void * object) { - return 42; +foo bufferTest(void * object) { + assert(NULL!=object); + return *((foo *)object); } -int mixedTest(long context, void * object, foo * array){ - return 42; +foo mixedTest(long context, void * object, foo * array){ + assert(NULL!=object); + assert(NULL!=array); + return arrayTest(context, array) + bufferTest(object); } -int doubleTest(long context, void * object1, foo * array1, void * object2, foo * array2) { - return 42; +foo doubleTest(long context, void * object1, foo * array1, void * object2, foo * array2) { + assert(NULL!=object1); + assert(NULL!=array1); + assert(NULL!=object2); + assert(NULL!=array2); + return arrayTest(context, array1) + + arrayTest( 0, array2) + + bufferTest(object1) + + bufferTest(object2); +} + +foo arrayTestNioOnly(long context, foo * array ) { + return arrayTest(context, array); +} + +foo bufferTestNioOnly(void * object) { + return bufferTest(object); +} + +foo mixedTestNioOnly(long context, void * object, foo * array ) { + return mixedTest(context, object, array); +} + +foo doubleTestNioOnly(long context, void * object1, foo * array1, void * object2, foo * array2 ) { + return doubleTest(context, object1, array1, object2, array2); +} + +int strToInt(const char * str) { + return atoi(str); } + +const char * intToStr(int i) { + static char singleton[200]; + snprintf(singleton, sizeof(singleton)-1, "%d", i); + return singleton; +} + +int stringArrayRead(const char * * strings, int num) { + int i=0, l=0; + if(NULL!=strings) { + for(i=0; i<num; i++) { + if(NULL!=strings[i]) { + l+=strlen(strings[i]); + } + } + } + return l; +} + +int intArrayRead(const int * ints, int num) { + int i=0, s=0; + if(NULL!=ints) { + for(i=0; i<num; i++) { + s+=ints[i]; + } + } + return s; +} + +/** +int intArrayWrite(int * * ints, int num) { + int i=0, s=0; + if(NULL!=ints) { + for(i=0; i<num; i++) { + *(ints[i]) = *(ints[i]) + 1; + s+=*(ints[i]); + } + } + return s; +} */ + diff --git a/src/junit/com/jogamp/gluegen/test/junit/test1.h b/src/junit/com/jogamp/gluegen/test/junit/test1.h index 776bc0a..38b4911 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/test1.h +++ b/src/junit/com/jogamp/gluegen/test/junit/test1.h @@ -9,16 +9,49 @@ #define MYAPI #define CONSTANT_ONE 1 +#define ARRAY_SIZE 8 typedef unsigned long foo; -MYAPI int MYAPIENTRY nopTest(); +/** Returns 42 */ +MYAPI foo MYAPIENTRY nopTest(); -MYAPI int MYAPIENTRY arrayTest(long context, foo * array ); +/** Returns Sum(array) + context */ +MYAPI foo MYAPIENTRY arrayTest(long context, foo * array ); -MYAPI int MYAPIENTRY bufferTest(void * object); +/** Returns *((foo *)object) */ +MYAPI foo MYAPIENTRY bufferTest(void * object); -MYAPI int MYAPIENTRY mixedTest(long context, void * object, foo * array ); +/** Returns Sum(array) + context + *((foo *)object) */ +MYAPI foo MYAPIENTRY mixedTest(long context, void * object, foo * array ); -MYAPI int MYAPIENTRY doubleTest(long context, void * object1, foo * array1, void * object2, foo * array2 ); +/** Returns Sum(array1) + Sum(array2) + context + *((foo *)object1) + *((foo *)object2) */ +MYAPI foo MYAPIENTRY doubleTest(long context, void * object1, foo * array1, void * object2, foo * array2 ); + +/** Returns Sum(array) + context */ +MYAPI foo MYAPIENTRY arrayTestNioOnly(long context, foo * array ); + +/** Returns *((foo *)object) */ +MYAPI foo MYAPIENTRY bufferTestNioOnly(void * object); + +/** Returns Sum(array) + context + *((foo *)object) */ +MYAPI foo MYAPIENTRY mixedTestNioOnly(long context, void * object, foo * array ); + +/** Returns Sum(array1) + Sum(array2) + context + *((foo *)object1) + *((foo *)object2) */ +MYAPI foo MYAPIENTRY doubleTestNioOnly(long context, void * object1, foo * array1, void * object2, foo * array2 ); + +/** Returns atoi(str) */ +MYAPI int MYAPIENTRY strToInt(const char* str); + +/** Returns itoa(i) - not thread safe */ +MYAPI const char * MYAPIENTRY intToStr(int i); + +/** Returns the length of all strings */ +MYAPI int MYAPIENTRY stringArrayRead(const char * * strings, int num); + +/** Returns the sum of all integers */ +MYAPI int MYAPIENTRY intArrayRead(const int * ints, int num); + +/** Increases the elements by 1, and returns the sum +MYAPI int MYAPIENTRY intArrayWrite(int * * ints, int num); */ diff --git a/src/junit/com/jogamp/gluegen/test/junit/test1p1-gluegen.cfg b/src/junit/com/jogamp/gluegen/test/junit/test1p1-gluegen.cfg new file mode 100644 index 0000000..78e4d8a --- /dev/null +++ b/src/junit/com/jogamp/gluegen/test/junit/test1p1-gluegen.cfg @@ -0,0 +1,14 @@ +Package com.jogamp.gluegen.test.junit +JavaClass BindingTest1p1 +Style InterfaceAndImpl +JavaOutputDir classes +NativeOutputDir native + +Extends BindingTest1p1 BindingTest1 + +Include test1-common.cfg + +Import com.jogamp.gluegen.test.junit.BindingTest1 +Import com.jogamp.gluegen.test.junit.BindingTest1p1 + + diff --git a/src/junit/com/jogamp/gluegen/test/junit/test1p2-gluegen.cfg b/src/junit/com/jogamp/gluegen/test/junit/test1p2-gluegen.cfg new file mode 100644 index 0000000..1ec1b6d --- /dev/null +++ b/src/junit/com/jogamp/gluegen/test/junit/test1p2-gluegen.cfg @@ -0,0 +1,36 @@ +Package com.jogamp.gluegen.test.junit +JavaClass BindingTest1p2 +Style InterfaceAndImpl +JavaOutputDir classes +NativeOutputDir native + +Extends BindingTest1p2 BindingTest1 + +# Use a ProcAddressTable so we dynamically look up the routines +EmitProcAddressTable true +ProcAddressTableClassName BindingTest1p2ProcAddressTable +GetProcAddressTableExpr _table +ProcAddressNameExpr PFN $UPPERCASE({0}) PROC + +# Force all of the methods to be emitted using dynamic linking so we +# don't need to link against any emulation library on the desktop or +# depend on the presence of an import library for a particular device +ForceProcAddressGen __ALL__ + +# Also force the calling conventions of the locally generated function +# pointer typedefs for these routines to MYAPIENTRY +LocalProcAddressCallingConvention __ALL__ MYAPIENTRY + +Include test1-common.cfg +Include ../../../../../../../make/config/intptr.cfg + +Import com.jogamp.gluegen.test.junit.BindingTest1 +Import com.jogamp.gluegen.test.junit.BindingTest1p2 +Import com.jogamp.gluegen.runtime.* + +CustomJavaCode BindingTest1p2Impl private static BindingTest1p2ProcAddressTable _table = new BindingTest1p2ProcAddressTable(); +CustomJavaCode BindingTest1p2Impl public static void resetProcAddressTable(DynamicLookupHelper lookup) { +CustomJavaCode BindingTest1p2Impl ProcAddressHelper.resetProcAddressTable(_table, lookup); +CustomJavaCode BindingTest1p2Impl } + + |