summaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/gluegen/JavaConfiguration.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/com/jogamp/gluegen/JavaConfiguration.java')
-rw-r--r--src/java/com/jogamp/gluegen/JavaConfiguration.java38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/java/com/jogamp/gluegen/JavaConfiguration.java b/src/java/com/jogamp/gluegen/JavaConfiguration.java
index f392525..3241d83 100644
--- a/src/java/com/jogamp/gluegen/JavaConfiguration.java
+++ b/src/java/com/jogamp/gluegen/JavaConfiguration.java
@@ -165,6 +165,7 @@ public class JavaConfiguration {
private final Set<String> manuallyImplement = new HashSet<String>();
private final Map<String, String> delegatedImplementation = new HashMap<String, String>();
private final Map<String, List<String>> customJavaCode = new HashMap<String, List<String>>();
+ private final Map<String, List<String>> customJNICode = 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>>();
private final Map<String, String> structPackages = new HashMap<String, String>();
@@ -601,6 +602,19 @@ public class JavaConfiguration {
return res;
}
+ /** Returns a list of Strings containing user-implemented JNI code for
+ the given Java type name (not fully-qualified, only the class
+ name); returns either null or an empty list if there is no
+ custom code for the class. */
+ public List<String> customJNICodeForClass(final String className) {
+ List<String> res = customJNICode.get(className);
+ if (res == null) {
+ res = new ArrayList<String>();
+ customJNICode.put(className, res);
+ }
+ return res;
+ }
+
public List<String> javadocForMethod(final String methodName) {
List<String> res = methodJavadoc.get(methodName);
if (res == null) {
@@ -1330,6 +1344,10 @@ public class JavaConfiguration {
} else if (cmd.equalsIgnoreCase("CustomCCode")) {
readCustomCCode(tok, filename, lineNo);
// Warning: make sure delimiters are reset at the top of this loop
+ // because readCustomJNICode changes them.
+ } else if (cmd.equalsIgnoreCase("CustomJNICode")) {
+ readCustomJNICode(tok, filename, lineNo);
+ // Warning: make sure delimiters are reset at the top of this loop
// because readCustomCCode changes them.
} else if (cmd.equalsIgnoreCase("MethodJavadoc")) {
readMethodJavadoc(tok, filename, lineNo);
@@ -1697,6 +1715,26 @@ public class JavaConfiguration {
}
}
+ protected void readCustomJNICode(final StringTokenizer tok, final String filename, final int lineNo) {
+ try {
+ final String tokenClassName = tok.nextToken();
+ try {
+ final String restOfLine = tok.nextToken("\n\r\f");
+ addCustomJNICode(tokenClassName, restOfLine);
+ } catch (final NoSuchElementException e) {
+ addCustomJNICode(tokenClassName, "");
+ }
+ } catch (final NoSuchElementException e) {
+ throw new RuntimeException("Error parsing \"CustomJNICode\" command at line " + lineNo +
+ " in file \"" + filename + "\"", e);
+ }
+ }
+
+ protected void addCustomJNICode(final String className, final String code) {
+ final List<String> codeList = customJNICodeForClass(className);
+ codeList.add(code);
+ }
+
protected void readMethodJavadoc(final StringTokenizer tok, final String filename, final int lineNo) {
try {
final String tokenClassName = tok.nextToken();