summaryrefslogtreecommitdiffstats
path: root/src/net/java/games/gluegen/JavaConfiguration.java
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2004-04-21 01:36:13 +0000
committerKenneth Russel <[email protected]>2004-04-21 01:36:13 +0000
commit0f2fa98495ce75434fc011e7ba2976c78edd38d0 (patch)
treeb0c3040900b1c1c9de052b960753ad2eaaa273b9 /src/net/java/games/gluegen/JavaConfiguration.java
parent2ee2b7b51e3e82553e7dc17fe1a04e8cec5be8bf (diff)
Fixed Issue 28: All functions that take arrays as parameters should also take buffers
Fixed Issue 36: glSelectBuffer/glFeedbackBuffer need direct buffers git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@112 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/net/java/games/gluegen/JavaConfiguration.java')
-rw-r--r--src/net/java/games/gluegen/JavaConfiguration.java85
1 files changed, 83 insertions, 2 deletions
diff --git a/src/net/java/games/gluegen/JavaConfiguration.java b/src/net/java/games/gluegen/JavaConfiguration.java
index cdf2f091e..f72664a67 100644
--- a/src/net/java/games/gluegen/JavaConfiguration.java
+++ b/src/net/java/games/gluegen/JavaConfiguration.java
@@ -97,6 +97,14 @@ public class JavaConfiguration {
private Set/*<Pattern>*/ ignoreNots = new HashSet();
private Set/*<Pattern>*/ unimplemented = new HashSet();
private Set/*<String>*/ nioOnly = new HashSet();
+ /** See {@link #nioMode} */
+ public static final int NIO_MODE_VOID_ONLY = 1;
+ /** See {@link #nioMode} */
+ public static final int NIO_MODE_ALL_POINTERS = 2;
+ private int nioMode = NIO_MODE_VOID_ONLY;
+ private Set/*<String>*/ noNio = new HashSet();
+ private Set/*<String>*/ forcedNio = new HashSet();
+ private boolean flattenNIOVariants = true;
private Set/*<String>*/ manuallyImplement = new HashSet();
private Map/*<String,List<String>>*/ customJavaCode = new HashMap();
private Map/*<String,List<String>>*/ classJavadoc = new HashMap();
@@ -306,12 +314,46 @@ public class JavaConfiguration {
}
/** Returns true if the given function should only create a java.nio
- variant, and no array variants, for <code>void*</code>
- pointers. */
+ variant, and no array variants, for <code>void*</code> and other
+ C primitive pointers. */
public boolean nioOnly(String functionName) {
return nioOnly.contains(functionName);
}
+ /** Returns true if the user requested that the given function
+ should only create array variants, and no java.nio variant, for
+ <code>void*</code> and other C primitive pointers, overriding
+ the NIO mode default. */
+ public boolean noNio(String functionName) {
+ return noNio.contains(functionName);
+ }
+
+ /** Returns true if the user requested that the given function
+ should create a java.nio variant for the given function's
+ <code>void*</code> and other C primitive pointers, overriding
+ the NIO mode default. */
+ public boolean forcedNio(String functionName) {
+ return forcedNio.contains(functionName);
+ }
+
+ /** Returns the default NIO generation mode for C primitive pointer
+ arguments. NIO_MODE_VOID_ONLY is the default and specifies
+ that only void* arguments will have java.nio variants generated
+ for them. NIO_MODE_ALL_POINTERS specifies that all C
+ primitive arguments will have java.nio variants generated. */
+ public int nioMode() {
+ return nioMode;
+ }
+
+ /** Returns true if, for the plethora of java.nio variants generated
+ for primitive C pointer types, the emitter should flatten the
+ output down to two variants: one taking only Java primitive
+ arrays as arguments, and one taking only java.nio.Buffers as
+ arguments. */
+ public boolean flattenNIOVariants() {
+ return flattenNIOVariants;
+ }
+
/** Returns true if the glue code for the given function will be
manually implemented by the end user. */
public boolean manuallyImplement(String functionName) {
@@ -587,6 +629,14 @@ public class JavaConfiguration {
// because readClassJavadoc changes them.
} else if (cmd.equalsIgnoreCase("NioOnly")) {
nioOnly.add(readString("NioOnly", tok, filename, lineNo));
+ } else if (cmd.equalsIgnoreCase("NoNio")) {
+ noNio.add(readString("NoNio", tok, filename, lineNo));
+ } else if (cmd.equalsIgnoreCase("ForcedNio")) {
+ forcedNio.add(readString("ForcedNio", tok, filename, lineNo));
+ } else if (cmd.equalsIgnoreCase("NioMode")) {
+ readNioMode(tok, filename, lineNo);
+ } else if (cmd.equalsIgnoreCase("FlattenNIOVariants")) {
+ flattenNIOVariants = readBoolean("FlattenNIOVariants", tok, filename, lineNo).booleanValue();
} else if (cmd.equalsIgnoreCase("EmitStruct")) {
forcedStructs.add(readString("EmitStruct", tok, filename, lineNo));
} else if (cmd.equalsIgnoreCase("MirrorExpandedBindingArgs")) {
@@ -799,6 +849,37 @@ public class JavaConfiguration {
}
/**
+ * Sets the default NIO generation mode for C primitive
+ * pointers. Options are VOID_ONLY or ALL_POINTERS. When the mode is
+ * set to VOID_ONLY, java.nio variants of methods are only generated
+ * for C primitive pointers of type <code>void*</code>. All other
+ * pointers are translated by default into Java primitive arrays.
+ * When the mode is set to ALL_POINTERS, C primitive pointers of
+ * other types (i.e., <code>int*</code>) will have java.nio variants
+ * generated for them (i.e., <code>IntBuffer</code> as opposed to
+ * merely <code>int[]</code>). This default mode can be overridden
+ * with the NioOnly and NoNio directives. The default for this mode
+ * is currently VOID_ONLY.
+ */
+ protected void readNioMode(StringTokenizer tok, String filename, int lineNo) {
+ try {
+ String mode = tok.nextToken();
+ if (mode.equalsIgnoreCase("VOID_ONLY")) {
+ nioMode = NIO_MODE_VOID_ONLY;
+ } else if (mode.equalsIgnoreCase("ALL_POINTERS")) {
+ nioMode = NIO_MODE_ALL_POINTERS;
+ } else {
+ throw new RuntimeException("Error parsing \"NioMode\" command at line " + lineNo +
+ " in file \"" + filename + "\"; expected VOID_ONLY or ALL_POINTERS");
+ }
+ } catch (NoSuchElementException e) {
+ throw new RuntimeException(
+ "Error parsing \"NioMode\" command at line " + lineNo +
+ " in file \"" + filename + "\"", e);
+ }
+ }
+
+ /**
* When void* arguments in the C function prototypes are encountered, the
* emitter will try to expand the binding and create Java entry points for
* all possible array types. If there are 2 or more void* arguments in the C