From 0f2fa98495ce75434fc011e7ba2976c78edd38d0 Mon Sep 17 00:00:00 2001 From: Kenneth Russel Date: Wed, 21 Apr 2004 01:36:13 +0000 Subject: 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 --- src/net/java/games/gluegen/JavaConfiguration.java | 85 ++++++++++++++++++++++- 1 file changed, 83 insertions(+), 2 deletions(-) (limited to 'src/net/java/games/gluegen/JavaConfiguration.java') 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/**/ ignoreNots = new HashSet(); private Set/**/ unimplemented = new HashSet(); private Set/**/ 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/**/ noNio = new HashSet(); + private Set/**/ forcedNio = new HashSet(); + private boolean flattenNIOVariants = true; private Set/**/ manuallyImplement = new HashSet(); private Map/*>*/ customJavaCode = new HashMap(); private Map/*>*/ 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 void* - pointers. */ + variant, and no array variants, for void* 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 + void* 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 + void* 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")) { @@ -798,6 +848,37 @@ public class JavaConfiguration { codeList.add(code); } + /** + * 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 void*. 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., int*) will have java.nio variants + * generated for them (i.e., IntBuffer as opposed to + * merely int[]). 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 -- cgit v1.2.3