diff options
author | Sven Gothel <[email protected]> | 2014-06-18 01:49:08 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-06-18 01:49:08 +0200 |
commit | 1eadaf928f4f61aae4de1c8bf33c5b77bdfa882f (patch) | |
tree | fcb0256f3a4f57bc4afa48181ca9cc2ad8f28001 /src/java/com/jogamp/gluegen/JavaConfiguration.java | |
parent | 9843e983a4fc71a64eb3de9cb364a1f4ffa56b3a (diff) |
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);
Diffstat (limited to 'src/java/com/jogamp/gluegen/JavaConfiguration.java')
-rw-r--r-- | src/java/com/jogamp/gluegen/JavaConfiguration.java | 52 |
1 files changed, 42 insertions, 10 deletions
diff --git a/src/java/com/jogamp/gluegen/JavaConfiguration.java b/src/java/com/jogamp/gluegen/JavaConfiguration.java index 7cecbce..552b237 100644 --- a/src/java/com/jogamp/gluegen/JavaConfiguration.java +++ b/src/java/com/jogamp/gluegen/JavaConfiguration.java @@ -156,7 +156,8 @@ public class JavaConfiguration { private boolean forceUseNIODirectOnly4All = false; private final Set<String> useNIODirectOnly = new HashSet<String>(); private final Set<String> manuallyImplement = new HashSet<String>(); - private final Set<String> manualStaticInit = new HashSet<String>(); + private final Set<String> manualStaticInitCall = new HashSet<String>(); + private final Set<String> forceStaticInitCode = new HashSet<String>(); private final Map<String, List<String>> customJavaCode = new HashMap<String, List<String>>(); private final Map<String, List<String>> classJavadoc = new HashMap<String, List<String>>(); private final Map<String, List<String>> methodJavadoc = new HashMap<String, List<String>>(); @@ -538,10 +539,30 @@ public class JavaConfiguration { return manuallyImplement.contains(functionName); } - /** Returns true if the static initialization java code for the given class will be - manually implemented by the end user. */ - public boolean manualStaticInit(String clazzName) { - return manualStaticInit.contains(clazzName); + /** + * 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) { + return manualStaticInitCall.contains(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) { + return forceStaticInitCode.contains(clazzName); } /** Returns a list of Strings containing user-implemented code for @@ -990,8 +1011,10 @@ public class JavaConfiguration { readIgnoreField(tok, filename, lineNo); } else if (cmd.equalsIgnoreCase("ManuallyImplement")) { readManuallyImplement(tok, filename, lineNo); - } else if (cmd.equalsIgnoreCase("ManualStaticInit")) { - readManualStaticInit(tok, filename, lineNo); + } else if (cmd.equalsIgnoreCase("ManualStaticInitCall")) { + readManualStaticInitCall(tok, filename, lineNo); + } else if (cmd.equalsIgnoreCase("ForceStaticInitCode")) { + readForceStaticInitCode(tok, filename, lineNo); } else if (cmd.equalsIgnoreCase("CustomJavaCode")) { readCustomJavaCode(tok, filename, lineNo); // Warning: make sure delimiters are reset at the top of this loop @@ -1292,12 +1315,21 @@ public class JavaConfiguration { " in file \"" + filename + "\"", e); } } - protected void readManualStaticInit(StringTokenizer tok, String filename, int lineNo) { + protected void readManualStaticInitCall(StringTokenizer tok, String filename, int lineNo) { + try { + String name = tok.nextToken(); + manualStaticInitCall.add(name); + } catch (NoSuchElementException e) { + throw new RuntimeException("Error parsing \"ManualStaticInitCall\" command at line " + lineNo + + " in file \"" + filename + "\"", e); + } + } + protected void readForceStaticInitCode(StringTokenizer tok, String filename, int lineNo) { try { String name = tok.nextToken(); - manualStaticInit.add(name); + forceStaticInitCode.add(name); } catch (NoSuchElementException e) { - throw new RuntimeException("Error parsing \"ManualStaticInit\" command at line " + lineNo + + throw new RuntimeException("Error parsing \"ForceStaticInitCode\" command at line " + lineNo + " in file \"" + filename + "\"", e); } } |