gluegen: avoid a suppressed warning annotation by using the ArrayList copy constructor
clone() can't be used without warnigns and is no more efficient that the copy constructor, replace the call and kill the suppressed warning annotation. While here, mark the modifier list as private final.
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
GlueGen: Add support for 'compound call-by-value', i.e. passing and returning struct instance
'compound call-by-value' is not efficient.
However, to allow mapping APIs utilizing passing small structs as arguments and return values - this feature has been added.
+++
To return the struct value, native code needs to allocate a NIO ByteBuffer and copy the data. The stack return value can be dismissed afterwards and the NIO buffer is returned.
We include this functionality for all generated [impl] classes, native method: 'static jobject JVMUtil_NewDirectByteBufferCopy(JNIEnv *env, void * source_address, jlong capacity)'
(See: 'JavaEmitter.initClassAccessCode')
Since this code requires knowledge of java classes and methods, for which a reference needs to be acquired, a static initialization method has been introduced for all generated [impl] classes: 'private static native boolean initializeImpl();'
Per default the this method will be called in the new static initializer block of the class, which can be supressed via the configuration element: 'ManualStaticInit <class-name>'
'ManualStaticInit' can be used to issue the 'initializeImpl()' call in a custom static initializer written by the user.
However, at the time 'initializeImpl()' gets called the JNI native library must have been loaded, of course!
+++
- See tag: // FIXME: Compound call-by-value for code changes and validation of completeness
Trigger for compond call-by-value in CMethodBindingEmitter is: !cArgType.isPointer() && javaArgType.isCompoundTypeWrapper()
Trigger for compond call-by-value in JavaEmitter is: t.isCompound()
+++
Further more we do tolerate 'javaType.isCPrimitivePointerType()', i.e. adding comments for offset/size and field entries, which are all NOP.
This allows to utilize the remaining fields of the native structure.
+++
Tests: Added call-by-value to test1.[ch] binding test!
gluegen: move all antlr grammars to a top-level directory (refine commit e8bc9edd3c39170af038ab23b8cdca9ffd6f2d56): src/antlr (IMHO no need for 'main')
GlueGen: Refine compound [array] call-by-value native code injection and initialization
Follow-up of commit 9843e983a4fc71a64eb3de9cb364a1f4ffa56b3a
Only add static initialization code (java, native) and hence native code 'JVMUtil_NewDirectByteBufferCopy(..)' if either required _or_ forced via configuration.
This shall reduce possible sideffects and dead code.
Add JavaConfiguration:
/** * Returns true if the static initialization java code calling <code>initializeImpl()</code> * for the given class will be manually implemented by the end user * as requested via configuration directive <code>ManualStaticInitCall 'class-name'</code>. */ public boolean manualStaticInitCall(String clazzName);
/** * Returns true if the static initialization java code implementing <code>initializeImpl()</code> * and the native code implementing: * <pre> * static jobject JVMUtil_NewDirectByteBufferCopy(JNIEnv *env, void * source_address, jlong capacity); * </pre> * for the given class will be included in the generated code, always, * as requested via configuration directive <code>ForceStaticInitCode 'class-name'</code>. * <p> * If case above code has been generated, static class initialization is generated * to call <code>initializeImpl()</code>, see {@link #manualStaticInitCall(String)}. * </p> */ public boolean forceStaticInitCode(String clazzName);