From f607cdf272dffbd45e6389c5715a9596e85c2a90 Mon Sep 17 00:00:00 2001
From: sg215889
Date: Tue, 28 Jul 2009 17:23:24 -0700
Subject: Fix: Add sun.arch.data.model to determine 32bit arch
---
src/java/com/sun/gluegen/runtime/CPU.java | 90 +++++++++++++++-------
.../sun/gluegen/test/TestPointerBufferEndian.java | 3 +-
.../sun/gluegen/test/TestStructAccessorEndian.java | 3 +-
3 files changed, 65 insertions(+), 31 deletions(-)
(limited to 'src/java/com/sun')
diff --git a/src/java/com/sun/gluegen/runtime/CPU.java b/src/java/com/sun/gluegen/runtime/CPU.java
index 0456e9f..c7e6bc1 100755
--- a/src/java/com/sun/gluegen/runtime/CPU.java
+++ b/src/java/com/sun/gluegen/runtime/CPU.java
@@ -47,35 +47,67 @@ public class CPU {
private static boolean is32Bit;
static {
- // We don't seem to need an AccessController.doPrivileged() block
- // here as these system properties are visible even to unsigned
- // applets
- // Note: this code is replicated in StructLayout.java
- String os = System.getProperty("os.name").toLowerCase();
- String cpu = System.getProperty("os.arch").toLowerCase();
- if ((os.startsWith("windows") && cpu.equals("x86")) ||
- (os.startsWith("windows") && cpu.equals("arm")) ||
- (os.startsWith("linux") && cpu.equals("i386")) ||
- (os.startsWith("linux") && cpu.equals("x86")) ||
- (os.startsWith("mac os") && cpu.equals("ppc")) ||
- (os.startsWith("mac os") && cpu.equals("i386")) ||
- (os.startsWith("darwin") && cpu.equals("ppc")) ||
- (os.startsWith("darwin") && cpu.equals("i386")) ||
- (os.startsWith("sunos") && cpu.equals("sparc")) ||
- (os.startsWith("sunos") && cpu.equals("x86")) ||
- (os.startsWith("freebsd") && cpu.equals("i386")) ||
- (os.startsWith("hp-ux") && cpu.equals("pa_risc2.0"))) {
- is32Bit = true;
- } else if ((os.startsWith("windows") && cpu.equals("amd64")) ||
- (os.startsWith("linux") && cpu.equals("amd64")) ||
- (os.startsWith("linux") && cpu.equals("x86_64")) ||
- (os.startsWith("linux") && cpu.equals("ia64")) ||
- (os.startsWith("mac os") && cpu.equals("x86_64")) ||
- (os.startsWith("darwin") && cpu.equals("x86_64")) ||
- (os.startsWith("sunos") && cpu.equals("sparcv9")) ||
- (os.startsWith("sunos") && cpu.equals("amd64"))) {
- } else {
- throw new RuntimeException("Please port CPU detection (32/64 bit) to your platform (" + os + "/" + cpu + ")");
+ boolean done=false;
+
+ // Try to use Sun's sun.arch.data.model first ..
+ int bits = 0;
+ try {
+ String bitS =
+ (String) AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return System.getProperty("sun.arch.data.model");
+ }
+ });
+ if(null!=bitS && bitS.length()>0) {
+ bits = Integer.parseInt(bitS);
+ is32Bit = ( 32 == bits );
+ done = true ;
+ }
+ } catch (NumberFormatException nfe) {}
+
+ if(!done) {
+ // We don't seem to need an AccessController.doPrivileged() block
+ // here as these system properties are visible even to unsigned
+ // applets
+ // Note: this code is replicated in StructLayout.java
+ String os = System.getProperty("os.name").toLowerCase();
+ String cpu = System.getProperty("os.arch").toLowerCase();
+
+ if(!done) {
+ if ((os.startsWith("windows") && cpu.equals("x86")) ||
+ (os.startsWith("windows") && cpu.equals("arm")) ||
+ (os.startsWith("linux") && cpu.equals("i386")) ||
+ (os.startsWith("linux") && cpu.equals("x86")) ||
+ (os.startsWith("mac os") && cpu.equals("ppc")) ||
+ (os.startsWith("mac os") && cpu.equals("i386")) ||
+ (os.startsWith("darwin") && cpu.equals("ppc")) ||
+ (os.startsWith("darwin") && cpu.equals("i386")) ||
+ (os.startsWith("sunos") && cpu.equals("sparc")) ||
+ (os.startsWith("sunos") && cpu.equals("x86")) ||
+ (os.startsWith("freebsd") && cpu.equals("i386")) ||
+ (os.startsWith("hp-ux") && cpu.equals("pa_risc2.0"))) {
+ is32Bit = true;
+ done = true;
+ }
+ }
+
+ if(!done) {
+ if ((os.startsWith("windows") && cpu.equals("amd64")) ||
+ (os.startsWith("linux") && cpu.equals("amd64")) ||
+ (os.startsWith("linux") && cpu.equals("x86_64")) ||
+ (os.startsWith("linux") && cpu.equals("ia64")) ||
+ (os.startsWith("mac os") && cpu.equals("x86_64")) ||
+ (os.startsWith("darwin") && cpu.equals("x86_64")) ||
+ (os.startsWith("sunos") && cpu.equals("sparcv9")) ||
+ (os.startsWith("sunos") && cpu.equals("amd64"))) {
+ is32Bit = false;
+ done = true;
+ }
+ }
+
+ if(!done) {
+ throw new RuntimeException("Please port CPU detection (32/64 bit) to your platform (" + os + "/" + cpu + ")");
+ }
}
}
diff --git a/src/java/com/sun/gluegen/test/TestPointerBufferEndian.java b/src/java/com/sun/gluegen/test/TestPointerBufferEndian.java
index 1c180bd..cd375af 100644
--- a/src/java/com/sun/gluegen/test/TestPointerBufferEndian.java
+++ b/src/java/com/sun/gluegen/test/TestPointerBufferEndian.java
@@ -8,9 +8,10 @@ public class TestPointerBufferEndian {
public static void main (String[] args) {
boolean direct = args.length>0 && args[0].equals("-direct");
boolean ok = true;
+ String bits = System.getProperty("sun.arch.data.model");
String os = System.getProperty("os.name");
String cpu = System.getProperty("os.arch");
- System.out.println("OS: <"+os+"> CPU: <"+cpu+">");
+ System.out.println("OS: <"+os+"> CPU: <"+cpu+"> Bits: <"+bits+">");
System.out.println("CPU is: "+ (CPU.is32Bit()?"32":"64") + " bit");
System.out.println("Buffer is in: "+ (BufferFactory.isLittleEndian()?"little":"big") + " endian");
PointerBuffer ptr = direct ? PointerBuffer.allocateDirect(3) : PointerBuffer.allocate(3);
diff --git a/src/java/com/sun/gluegen/test/TestStructAccessorEndian.java b/src/java/com/sun/gluegen/test/TestStructAccessorEndian.java
index 4f05256..fa28cb6 100644
--- a/src/java/com/sun/gluegen/test/TestStructAccessorEndian.java
+++ b/src/java/com/sun/gluegen/test/TestStructAccessorEndian.java
@@ -7,9 +7,10 @@ import java.nio.*;
public class TestStructAccessorEndian {
public static void main (String args[]) {
boolean ok = true;
+ String bits = System.getProperty("sun.arch.data.model");
String os = System.getProperty("os.name");
String cpu = System.getProperty("os.arch");
- System.out.println("OS: <"+os+"> CPU: <"+cpu+">");
+ System.out.println("OS: <"+os+"> CPU: <"+cpu+"> Bits: <"+bits+">");
System.out.println("CPU is: "+ (CPU.is32Bit()?"32":"64") + " bit");
System.out.println("Buffer is in: "+ (BufferFactory.isLittleEndian()?"little":"big") + " endian");
ByteBuffer tst = BufferFactory.newDirectByteBuffer(BufferFactory.SIZEOF_LONG * 3);
--
cgit v1.2.3
From abea54842158e588112f6e35d1ba3c5f069dfc29 Mon Sep 17 00:00:00 2001
From: sg215889
Date: Tue, 28 Jul 2009 18:57:07 -0700
Subject: Fix: Native CPU 32/64 bit detection; Tested on CVM/J2SE
---
make/build.xml | 23 +++++++++++---------
make/make.gluegen.all.linux-x86.sh | 13 +++++------
make/make.gluegen.all.linux-x86_64.sh | 12 +++++------
src/java/com/sun/gluegen/runtime/CPU.java | 25 ++++++++++------------
.../com/sun/gluegen/runtime/NativeLibrary.java | 2 +-
.../sun/gluegen/test/TestPointerBufferEndian.java | 5 +++--
.../sun/gluegen/test/TestStructAccessorEndian.java | 5 +++--
src/native/common/CPU.c | 10 +++++++++
8 files changed, 54 insertions(+), 41 deletions(-)
create mode 100644 src/native/common/CPU.c
(limited to 'src/java/com/sun')
diff --git a/make/build.xml b/make/build.xml
index cc538ae..51aaf3d 100755
--- a/make/build.xml
+++ b/make/build.xml
@@ -240,7 +240,7 @@
-
+
@@ -263,7 +263,7 @@
-
+
@@ -286,7 +286,7 @@
-
+
@@ -294,7 +294,7 @@
-
+
@@ -302,7 +302,7 @@
-
+
@@ -310,7 +310,7 @@
-
+
@@ -318,7 +318,7 @@
-
+
@@ -340,7 +340,7 @@
-
+
@@ -356,7 +356,9 @@
-
+
+
+
-
+
+
diff --git a/make/make.gluegen.all.linux-x86.sh b/make/make.gluegen.all.linux-x86.sh
index 58c4215..87352c3 100644
--- a/make/make.gluegen.all.linux-x86.sh
+++ b/make/make.gluegen.all.linux-x86.sh
@@ -3,12 +3,13 @@
. ../../setenv-build-jogl-x86.sh
# -Dc.compiler.debug=true
+# -Dgluegen.cpptasks.detected.os=true \
+# -DisUnix=true \
+# -DisLinux=true \
+# -DisLinuxX86=true \
+# -DisX11=true \
-ant -v \
+ant \
-Drootrel.build=build-x86 \
- -Dgluegen.cpptasks.detected.os=true \
- -DisUnix=true \
- -DisLinux=true \
- -DisLinuxX86=true \
- -DisX11=true \
+ -Dos.arch=x86 \
$* 2>&1 | tee make.gluegen.all.linux-x86.log
diff --git a/make/make.gluegen.all.linux-x86_64.sh b/make/make.gluegen.all.linux-x86_64.sh
index a787c57..98ef4ed 100644
--- a/make/make.gluegen.all.linux-x86_64.sh
+++ b/make/make.gluegen.all.linux-x86_64.sh
@@ -3,12 +3,12 @@
. ../../setenv-build-jogl-x86_64.sh
# -Dc.compiler.debug=true
+# -Dgluegen.cpptasks.detected.os=true \
+# -DisUnix=true \
+# -DisLinux=true \
+# -DisLinuxAMD64=true \
+# -DisX11=true \
-ant -v \
+ant \
-Drootrel.build=build-x86_64 \
- -Dgluegen.cpptasks.detected.os=true \
- -DisUnix=true \
- -DisLinux=true \
- -DisLinuxAMD64=true \
- -DisX11=true \
$* 2>&1 | tee make.gluegen.all.linux-x86_64.log
diff --git a/src/java/com/sun/gluegen/runtime/CPU.java b/src/java/com/sun/gluegen/runtime/CPU.java
index c7e6bc1..ee6c9f5 100755
--- a/src/java/com/sun/gluegen/runtime/CPU.java
+++ b/src/java/com/sun/gluegen/runtime/CPU.java
@@ -38,6 +38,7 @@
*/
package com.sun.gluegen.runtime;
+import java.security.*;
/** Provides information to autogenerated struct accessors about what
kind of data model (32- or 64-bit) is being used by the currently
@@ -47,23 +48,16 @@ public class CPU {
private static boolean is32Bit;
static {
+ NativeLibrary.ensureNativeLibLoaded();
+
boolean done=false;
// Try to use Sun's sun.arch.data.model first ..
- int bits = 0;
- try {
- String bitS =
- (String) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return System.getProperty("sun.arch.data.model");
- }
- });
- if(null!=bitS && bitS.length()>0) {
- bits = Integer.parseInt(bitS);
- is32Bit = ( 32 == bits );
- done = true ;
- }
- } catch (NumberFormatException nfe) {}
+ int bits = getPointerSizeInBits();
+ if ( 32 == bits || 64 == bits ) {
+ is32Bit = ( 32 == bits );
+ done = true ;
+ }
if(!done) {
// We don't seem to need an AccessController.doPrivileged() block
@@ -114,4 +108,7 @@ public class CPU {
public static boolean is32Bit() {
return is32Bit;
}
+
+ public static native int getPointerSizeInBits();
+
}
diff --git a/src/java/com/sun/gluegen/runtime/NativeLibrary.java b/src/java/com/sun/gluegen/runtime/NativeLibrary.java
index 22063a5..c4c9f25 100755
--- a/src/java/com/sun/gluegen/runtime/NativeLibrary.java
+++ b/src/java/com/sun/gluegen/runtime/NativeLibrary.java
@@ -412,7 +412,7 @@ public class NativeLibrary {
}
private static volatile boolean loadedDynLinkNativeLib;
- private static void ensureNativeLibLoaded() {
+ static void ensureNativeLibLoaded() {
if (!loadedDynLinkNativeLib) {
synchronized (NativeLibrary.class) {
if (!loadedDynLinkNativeLib) {
diff --git a/src/java/com/sun/gluegen/test/TestPointerBufferEndian.java b/src/java/com/sun/gluegen/test/TestPointerBufferEndian.java
index cd375af..ba77eed 100644
--- a/src/java/com/sun/gluegen/test/TestPointerBufferEndian.java
+++ b/src/java/com/sun/gluegen/test/TestPointerBufferEndian.java
@@ -8,10 +8,11 @@ public class TestPointerBufferEndian {
public static void main (String[] args) {
boolean direct = args.length>0 && args[0].equals("-direct");
boolean ok = true;
- String bits = System.getProperty("sun.arch.data.model");
+ int bitsPtr = CPU.getPointerSizeInBits();
+ String bitsProp = System.getProperty("sun.arch.data.model");
String os = System.getProperty("os.name");
String cpu = System.getProperty("os.arch");
- System.out.println("OS: <"+os+"> CPU: <"+cpu+"> Bits: <"+bits+">");
+ System.out.println("OS: <"+os+"> CPU: <"+cpu+"> Bits: <"+bitsPtr+"/"+bitsProp+">");
System.out.println("CPU is: "+ (CPU.is32Bit()?"32":"64") + " bit");
System.out.println("Buffer is in: "+ (BufferFactory.isLittleEndian()?"little":"big") + " endian");
PointerBuffer ptr = direct ? PointerBuffer.allocateDirect(3) : PointerBuffer.allocate(3);
diff --git a/src/java/com/sun/gluegen/test/TestStructAccessorEndian.java b/src/java/com/sun/gluegen/test/TestStructAccessorEndian.java
index fa28cb6..dc53a10 100644
--- a/src/java/com/sun/gluegen/test/TestStructAccessorEndian.java
+++ b/src/java/com/sun/gluegen/test/TestStructAccessorEndian.java
@@ -7,10 +7,11 @@ import java.nio.*;
public class TestStructAccessorEndian {
public static void main (String args[]) {
boolean ok = true;
- String bits = System.getProperty("sun.arch.data.model");
+ int bitsPtr = CPU.getPointerSizeInBits();
+ String bitsProp = System.getProperty("sun.arch.data.model");
String os = System.getProperty("os.name");
String cpu = System.getProperty("os.arch");
- System.out.println("OS: <"+os+"> CPU: <"+cpu+"> Bits: <"+bits+">");
+ System.out.println("OS: <"+os+"> CPU: <"+cpu+"> Bits: <"+bitsPtr+"/"+bitsProp+">");
System.out.println("CPU is: "+ (CPU.is32Bit()?"32":"64") + " bit");
System.out.println("Buffer is in: "+ (BufferFactory.isLittleEndian()?"little":"big") + " endian");
ByteBuffer tst = BufferFactory.newDirectByteBuffer(BufferFactory.SIZEOF_LONG * 3);
diff --git a/src/native/common/CPU.c b/src/native/common/CPU.c
new file mode 100644
index 0000000..8c4135c
--- /dev/null
+++ b/src/native/common/CPU.c
@@ -0,0 +1,10 @@
+
+#include
+
+#include
+
+JNIEXPORT jint JNICALL
+Java_com_sun_gluegen_runtime_CPU_getPointerSizeInBits(JNIEnv *env, jclass _unused) {
+ return sizeof(void *) * 8;
+}
+
--
cgit v1.2.3
From e9468e9aa2bd6d893bb1e0b9058da0ee9a824576 Mon Sep 17 00:00:00 2001
From: sg215889
Date: Wed, 29 Jul 2009 05:15:45 -0700
Subject: ExtendedInterfaceSymbols -> ExtendedInterfaceSymbolsIgnore; Allow
cobination of ExtendedInterfaceSymbolsIgnore and ExtendedInterfaceSymbolsOnly
---
src/java/com/sun/gluegen/JavaConfiguration.java | 34 ++++++++++++-------------
1 file changed, 17 insertions(+), 17 deletions(-)
(limited to 'src/java/com/sun')
diff --git a/src/java/com/sun/gluegen/JavaConfiguration.java b/src/java/com/sun/gluegen/JavaConfiguration.java
index 5693150..a1fe732 100644
--- a/src/java/com/sun/gluegen/JavaConfiguration.java
+++ b/src/java/com/sun/gluegen/JavaConfiguration.java
@@ -117,8 +117,8 @@ public class JavaConfiguration {
* converted to String args; value is List of Integer argument indices
*/
private Map/*>*/ argumentsAreString = new HashMap();
- private Set/**/ extendedIntfSymbols = new HashSet();
- private boolean extendedIntfSymbolsOnly=false;
+ private Set/**/ extendedIntfSymbolsIgnore = new HashSet();
+ private Set/**/ extendedIntfSymbolsOnly = new HashSet();
private Set/**/ ignores = new HashSet();
private Map/**/ ignoreMap = new HashMap();
private Set/**/ ignoreNots = new HashSet();
@@ -577,10 +577,6 @@ public class JavaConfiguration {
return (String) parentClass.get(className);
}
- public boolean extendedIntfSymbolsOnly() {
- return extendedIntfSymbolsOnly;
- }
-
public static final boolean DEBUG_IGNORES = false;
public static boolean dumpedIgnores = false;
@@ -593,7 +589,7 @@ public class JavaConfiguration {
public void dumpIgnores() {
System.err.println("Extended Intf: ");
- for (Iterator iter = extendedIntfSymbols.iterator(); iter.hasNext(); ) {
+ for (Iterator iter = extendedIntfSymbolsIgnore.iterator(); iter.hasNext(); ) {
System.err.println("\t"+(String)iter.next());
}
System.err.println("Ignores (All): ");
@@ -609,7 +605,7 @@ public class JavaConfiguration {
dumpIgnoresOnce();
}
// Simple case; the entire symbol is in the interface ignore table.
- if (extendedIntfSymbols.contains(symbol)) {
+ if (extendedIntfSymbolsIgnore.contains(symbol)) {
if(DEBUG_IGNORES) {
System.err.println("Ignore Intf: "+symbol);
}
@@ -628,8 +624,8 @@ public class JavaConfiguration {
dumpIgnoresOnce();
}
- if (extendedIntfSymbolsOnly) {
- if(!extendedIntfSymbols.contains(symbol)) {
+ if (!extendedIntfSymbolsOnly.isEmpty()) {
+ if(!extendedIntfSymbolsOnly.contains(symbol)) {
if(DEBUG_IGNORES) {
System.err.println("Ignore Impl !extended: " + symbol);
}
@@ -849,11 +845,10 @@ public class JavaConfiguration {
// because ReturnedArrayLength changes them.
} else if (cmd.equalsIgnoreCase("ArgumentIsString")) {
readArgumentIsString(tok, filename, lineNo);
- } else if (cmd.equalsIgnoreCase("ExtendedInterfaceSymbols")) {
- readExtendedInterfaceSymbols(tok, filename, lineNo);
+ } else if (cmd.equalsIgnoreCase("ExtendedInterfaceSymbolsIgnore")) {
+ readExtendedInterfaceSymbols(tok, filename, lineNo, false);
} else if (cmd.equalsIgnoreCase("ExtendedInterfaceSymbolsOnly")) {
- extendedIntfSymbolsOnly=true;
- readExtendedInterfaceSymbols(tok, filename, lineNo);
+ readExtendedInterfaceSymbols(tok, filename, lineNo, true);
} else if (cmd.equalsIgnoreCase("Ignore")) {
readIgnore(tok, filename, lineNo);
} else if (cmd.equalsIgnoreCase("Unignore")) {
@@ -1056,7 +1051,7 @@ public class JavaConfiguration {
}
}
- protected void readExtendedInterfaceSymbols(StringTokenizer tok, String filename, int lineNo) {
+ protected void readExtendedInterfaceSymbols(StringTokenizer tok, String filename, int lineNo, boolean onlyList) {
File javaFile;
BufferedReader javaReader;
try {
@@ -1080,8 +1075,13 @@ public class JavaConfiguration {
return;
}
- extendedIntfSymbols.addAll(parser.getParsedEnumNames());
- extendedIntfSymbols.addAll(parser.getParsedFunctionNames());
+ if(onlyList) {
+ extendedIntfSymbolsOnly.addAll(parser.getParsedEnumNames());
+ extendedIntfSymbolsOnly.addAll(parser.getParsedFunctionNames());
+ } else {
+ extendedIntfSymbolsIgnore.addAll(parser.getParsedEnumNames());
+ extendedIntfSymbolsIgnore.addAll(parser.getParsedFunctionNames());
+ }
}
protected void readIgnore(StringTokenizer tok, String filename, int lineNo) {
--
cgit v1.2.3
From 6182c1a3d45478301702e6cf8e98e950f4165110 Mon Sep 17 00:00:00 2001
From: sg215889
Date: Wed, 29 Jul 2009 05:18:57 -0700
Subject: Add GL2GL3 synthetic methods for OpenGL Composable Pipeline
---
src/java/com/sun/gluegen/opengl/BuildComposablePipeline.java | 2 ++
1 file changed, 2 insertions(+)
(limited to 'src/java/com/sun')
diff --git a/src/java/com/sun/gluegen/opengl/BuildComposablePipeline.java b/src/java/com/sun/gluegen/opengl/BuildComposablePipeline.java
index 89176f5..1698b18 100644
--- a/src/java/com/sun/gluegen/opengl/BuildComposablePipeline.java
+++ b/src/java/com/sun/gluegen/opengl/BuildComposablePipeline.java
@@ -619,6 +619,7 @@ public class BuildComposablePipeline
emitGLIsMethod(output, "GLES2");
emitGLIsMethod(output, "GL2ES1");
emitGLIsMethod(output, "GL2ES2");
+ emitGLIsMethod(output, "GL2GL3");
output.println(" public boolean isGLES() {");
output.println(" return isGLES2() || isGLES1();");
output.println(" }");
@@ -648,6 +649,7 @@ public class BuildComposablePipeline
emitGLGetMethod(output, "GLES2");
emitGLGetMethod(output, "GL2ES1");
emitGLGetMethod(output, "GL2ES2");
+ emitGLGetMethod(output, "GL2GL3");
output.println(" public GLProfile getGLProfile() {");
output.println(" return "+getDownstreamObjectName()+".getGLProfile();");
output.println(" }");
--
cgit v1.2.3
From 0b877723ff1f226899edadd1697ee387df31ab45 Mon Sep 17 00:00:00 2001
From: Sven Gothel
Date: Fri, 31 Jul 2009 11:53:08 -0700
Subject: Fix array element type name and const qualifier
---
.../com/sun/gluegen/CMethodBindingEmitter.java | 28 +++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
(limited to 'src/java/com/sun')
diff --git a/src/java/com/sun/gluegen/CMethodBindingEmitter.java b/src/java/com/sun/gluegen/CMethodBindingEmitter.java
index 2085477..02680d0 100644
--- a/src/java/com/sun/gluegen/CMethodBindingEmitter.java
+++ b/src/java/com/sun/gluegen/CMethodBindingEmitter.java
@@ -691,11 +691,12 @@ public class CMethodBindingEmitter extends FunctionEmitter
"Could not copy data for type \"" + cArgType +
"\"; currently only pointer types supported.");
}
- PointerType cArgElementType = cArgPtrType.getTargetType().asPointer();
+ PointerType cArgElementType = cArgPtrType.getTargetType().asPointer();
emitMalloc(
writer,
convName+"_copy",
cArgElementType.getName(),
+ isConstPtrPtr(cArgPtrType),
arrayLenName,
"Could not allocate buffer for copying data in argument \\\""+binding.getArgumentName(i)+"\\\"");
@@ -757,6 +758,7 @@ public class CMethodBindingEmitter extends FunctionEmitter
writer,
convName+"_copy[_copyIndex]",
cArgElementType.getTargetType().getName(), // assumes cArgPtrType is ptr-to-ptr-to-primitive !!
+ isConstPtrPtr(cArgPtrType),
"(*env)->GetArrayLength(env, _tmpObj)",
"Could not allocate buffer during copying of data in argument \\\""+binding.getArgumentName(i)+"\\\"");
// FIXME: copy the data (use matched Get/ReleasePrimitiveArrayCritical() calls)
@@ -982,6 +984,9 @@ public class CMethodBindingEmitter extends FunctionEmitter
} else {
writer.print("(");
Type cArgType = binding.getCSymbol().getArgumentType(i);
+ if (isConstPtrPtr(cArgType)) {
+ writer.print("const ");
+ }
writer.print(cArgType.getName());
writer.print(") ");
if (binding.getCArgumentType(i).isPointer() && binding.getJavaArgumentType(i).isPrimitive()) {
@@ -1277,12 +1282,16 @@ public class CMethodBindingEmitter extends FunctionEmitter
private void emitMalloc(PrintWriter writer,
String targetVarName,
String elementTypeString,
+ boolean elementTypeIsConst,
String numElementsExpression,
String mallocFailureErrorString)
{
writer.print(" ");
writer.print(targetVarName);
writer.print(" = (");
+ if(elementTypeIsConst) {
+ writer.print("const ");
+ }
writer.print(elementTypeString);
writer.print(" *) malloc(");
writer.print(numElementsExpression);
@@ -1467,9 +1476,22 @@ public class CMethodBindingEmitter extends FunctionEmitter
// incoming data has been properly laid out in memory to match the C
// memory model
if (javaType.isStringArray()) {
- writer.print(" const char **");
+ String cElementTypeName = "char *";
+ PointerType cPtrType = cType.asPointer();
+ if (cPtrType != null) {
+ cElementTypeName = cPtrType.getTargetType().asPointer().getName();
+ }
+ if (isConstPtrPtr(cType)) {
+ writer.print(" const "+cElementTypeName+" *");
+ } else {
+ writer.print(" "+cElementTypeName+" *");
+ }
} else {
- writer.print(" " + ptrTypeString);
+ if (isConstPtrPtr(cType)) {
+ writer.print(" const " + ptrTypeString);
+ } else {
+ writer.print(" " + ptrTypeString);
+ }
}
writer.print(" ");
writer.print(cVariableName);
--
cgit v1.2.3
From ddfed940a721e41ecbad85e2ed7b35725c072c94 Mon Sep 17 00:00:00 2001
From: Sven Gothel
Date: Sat, 1 Aug 2009 01:46:36 -0700
Subject: refine Trace/Debug output
---
.../com/sun/gluegen/opengl/BuildComposablePipeline.java | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
(limited to 'src/java/com/sun')
diff --git a/src/java/com/sun/gluegen/opengl/BuildComposablePipeline.java b/src/java/com/sun/gluegen/opengl/BuildComposablePipeline.java
index 1698b18..d62a685 100644
--- a/src/java/com/sun/gluegen/opengl/BuildComposablePipeline.java
+++ b/src/java/com/sun/gluegen/opengl/BuildComposablePipeline.java
@@ -746,9 +746,9 @@ public class BuildComposablePipeline
output.println(" * ");
output.println("");
if(null!=prologNameOpt) {
- output.println(" drawable.setGL( new "+className+"( drawable.getGL().getGL2ES2(), new "+prologNameOpt+"( drawable.getGL().getGL2ES2() ) ) );");
+ output.println(" GL gl = drawable.setGL( new "+className+"( drawable.getGL().getGL2ES2(), new "+prologNameOpt+"( drawable.getGL().getGL2ES2() ) ) );");
} else {
- output.println(" drawable.setGL( new "+className+"( drawable.getGL().getGL2ES2() ) );");
+ output.println(" GL gl = drawable.setGL( new "+className+"( drawable.getGL().getGL2ES2() ) );");
}
output.println("
");
output.println("*/");
@@ -898,7 +898,7 @@ public class BuildComposablePipeline
output.println(" Sample code which installs this pipeline:
");
output.println();
output.println("");
- output.println(" drawable.setGL(new DebugGL(drawable.getGL()));");
+ output.println(" GL gl = drawable.setGL(new DebugGL(drawable.getGL()));");
output.println("
");
output.println("*/");
}
@@ -1036,7 +1036,7 @@ public class BuildComposablePipeline
output.println(" before and after each OpenGL method call. Sample code which installs this pipeline: ");
output.println();
output.println("");
- output.println(" drawable.setGL(new TraceGL(drawable.getGL(), System.err));");
+ output.println(" GL gl = drawable.setGL(new TraceGL(drawable.getGL(), System.err));");
output.println("
");
output.println("*/");
}
@@ -1057,7 +1057,7 @@ public class BuildComposablePipeline
output.println("printIndent();");
}
- output.print(" println(");
+ output.print(" print(");
printFunctionCallString(output, m);
output.println(");");
}
@@ -1095,10 +1095,10 @@ public class BuildComposablePipeline
} else if(params[i].equals(int.class)) {
output.print("+\"<"+params[i].getName()+"> 0x\"+Integer.toHexString(arg"+i+").toUpperCase()");
} else {
- output.print("+\"<"+params[i].getName()+">\"+arg"+i);
+ output.print("+\"<"+params[i].getName()+"> \"+arg"+i);
}
if ( i < params.length-1) {
- output.print("+\",\"");
+ output.print("+\", \"");
}
}
output.print("+\")\"");
--
cgit v1.2.3
From dc2efba17781c35adddf6591d48c71e3ed0d62ac Mon Sep 17 00:00:00 2001
From: Sven Gothel
Date: Sat, 1 Aug 2009 02:31:15 -0700
Subject: Retain interface order in Custom Pipeline
---
.../gluegen/opengl/BuildComposablePipeline.java | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
(limited to 'src/java/com/sun')
diff --git a/src/java/com/sun/gluegen/opengl/BuildComposablePipeline.java b/src/java/com/sun/gluegen/opengl/BuildComposablePipeline.java
index d62a685..b52047b 100644
--- a/src/java/com/sun/gluegen/opengl/BuildComposablePipeline.java
+++ b/src/java/com/sun/gluegen/opengl/BuildComposablePipeline.java
@@ -330,15 +330,29 @@ public class BuildComposablePipeline
PrintWriter output = new PrintWriter(new BufferedWriter(new FileWriter(file)));
+ List baseInterfaces = Arrays.asList(baseInterfaceClass.getInterfaces());
HashSet clazzList = new HashSet();
clazzList.add(baseInterfaceClass);
- clazzList.addAll(Arrays.asList(baseInterfaceClass.getInterfaces()));
+ clazzList.addAll(baseInterfaces);
+ int ifNamesNumber = clazzList.size();
- String[] ifNames = new String[clazzList.size()];
+ // keep original order ..
+ clazzList.clear();
+ String[] ifNames = new String[ifNamesNumber];
{
int i=0;
- for (Iterator iter=clazzList.iterator(); iter.hasNext(); ) {
- ifNames[i++] = new String(((Class)iter.next()).getName());
+
+ for (Iterator iter=baseInterfaces.iterator(); iter.hasNext(); ) {
+ Class ifClass = (Class)iter.next();
+ if(!clazzList.contains(ifClass)) {
+ ifNames[i++] = new String(ifClass.getName());
+ clazzList.add(ifClass);
+ }
+ }
+
+ if(null!=baseInterfaceClass && !clazzList.contains(baseInterfaceClass)) {
+ ifNames[i++] = new String(baseInterfaceClass.getName());
+ clazzList.add(baseInterfaceClass);
}
}
--
cgit v1.2.3
From edaf82f5a86cd3e239072608e5299a9553ece32c Mon Sep 17 00:00:00 2001
From: Sven Gothel
Date: Sun, 2 Aug 2009 17:25:30 -0700
Subject: OpenGL: Add comment: Part of
---
src/java/com/sun/gluegen/opengl/GLConfiguration.java | 7 +++++++
src/java/com/sun/gluegen/opengl/GLEmitter.java | 20 +++++++++++++++++---
.../gluegen/opengl/GLJavaMethodBindingEmitter.java | 17 +++++++++++++++++
3 files changed, 41 insertions(+), 3 deletions(-)
(limited to 'src/java/com/sun')
diff --git a/src/java/com/sun/gluegen/opengl/GLConfiguration.java b/src/java/com/sun/gluegen/opengl/GLConfiguration.java
index 3013848..923dcf5 100755
--- a/src/java/com/sun/gluegen/opengl/GLConfiguration.java
+++ b/src/java/com/sun/gluegen/opengl/GLConfiguration.java
@@ -202,6 +202,13 @@ public class GLConfiguration extends ProcAddressConfiguration {
super.dumpIgnores();
}
+ protected String getExtension(String symbol) {
+ if (glInfo != null) {
+ return glInfo.getExtension(symbol);
+ }
+ return null;
+ }
+
protected boolean shouldIgnoreExtension(String symbol, boolean criteria) {
if (criteria && glInfo != null) {
String extension = glInfo.getExtension(symbol);
diff --git a/src/java/com/sun/gluegen/opengl/GLEmitter.java b/src/java/com/sun/gluegen/opengl/GLEmitter.java
index fff9d7e..83e688e 100644
--- a/src/java/com/sun/gluegen/opengl/GLEmitter.java
+++ b/src/java/com/sun/gluegen/opengl/GLEmitter.java
@@ -305,6 +305,21 @@ public class GLEmitter extends ProcAddressEmitter
return bufferObjectMethodBindings.containsKey(binding);
}
+ public void emitDefine(String name, String value, String optionalComment) throws Exception {
+ String extensionName = getGLConfig().getExtension(name);
+ StringBuffer newComment = new StringBuffer();
+ if(null!=extensionName) {
+ newComment.append("Part of "+extensionName+"
");
+ } else {
+ newComment.append("Part of unknown extension
");
+ }
+ if(null!=optionalComment) {
+ newComment.append(" ");
+ newComment.append(optionalComment);
+ }
+ super.emitDefine(name, value, newComment.toString());
+ }
+
//----------------------------------------------------------------------
// Internals only below this point
//
@@ -319,10 +334,9 @@ public class GLEmitter extends ProcAddressEmitter
for (Iterator iter = superEmitters.iterator(); iter.hasNext(); ) {
JavaMethodBindingEmitter emitter = (JavaMethodBindingEmitter) iter.next();
if (emitter instanceof ProcAddressJavaMethodBindingEmitter) {
- emitters.add(new GLJavaMethodBindingEmitter((ProcAddressJavaMethodBindingEmitter) emitter, this, bufferObjectVariant));
- } else {
- emitters.add(emitter);
+ emitter = new GLJavaMethodBindingEmitter((ProcAddressJavaMethodBindingEmitter) emitter, this, bufferObjectVariant);
}
+ emitters.add(emitter);
}
}
diff --git a/src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java b/src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java
index c6a0309..b952272 100755
--- a/src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java
+++ b/src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java
@@ -52,6 +52,7 @@ import com.sun.gluegen.procaddress.*;
public class GLJavaMethodBindingEmitter extends ProcAddressJavaMethodBindingEmitter {
protected boolean bufferObjectVariant;
protected GLEmitter glEmitter;
+ protected CommentEmitter glCommentEmitter = new GLCommentEmitter();
public GLJavaMethodBindingEmitter(JavaMethodBindingEmitter methodToWrap,
boolean callThroughProcAddress,
@@ -66,6 +67,7 @@ public class GLJavaMethodBindingEmitter extends ProcAddressJavaMethodBindingEmit
emitter);
this.bufferObjectVariant = bufferObjectVariant;
this.glEmitter=emitter;
+ setCommentEmitter(glCommentEmitter);
}
public GLJavaMethodBindingEmitter(ProcAddressJavaMethodBindingEmitter methodToWrap,
@@ -74,6 +76,7 @@ public class GLJavaMethodBindingEmitter extends ProcAddressJavaMethodBindingEmit
super(methodToWrap);
this.bufferObjectVariant = bufferObjectVariant;
this.glEmitter=emitter;
+ setCommentEmitter(glCommentEmitter);
}
public GLJavaMethodBindingEmitter(GLJavaMethodBindingEmitter methodToWrap) {
@@ -100,4 +103,18 @@ public class GLJavaMethodBindingEmitter extends ProcAddressJavaMethodBindingEmit
return name;
}
+
+ protected class GLCommentEmitter
+ extends JavaMethodBindingEmitter.DefaultCommentEmitter
+ {
+ protected void emitBindingCSignature(MethodBinding binding, PrintWriter writer) {
+ super.emitBindingCSignature(binding, writer);
+ String extensionName = glEmitter.getGLConfig().getExtension(binding.getCSymbol().getName());
+ if(null!=extensionName) {
+ writer.print("
Part of "+extensionName+"
");
+ } else {
+ writer.print("
Part of unknown extension
");
+ }
+ }
+ }
}
--
cgit v1.2.3
From aac675e3ae8be73d3e498cc8f1062a20839f8482 Mon Sep 17 00:00:00 2001
From: Sven Gothel
Date: Wed, 5 Aug 2009 07:31:49 -0700
Subject: Cleanup for a better OpenGL 3.2 integration, for subsuming
extensions: - Allow RenameExtensionIntoCore generate duplicate names,
ie those will not be generated. - Add proper comment showing the
extension of the symbol. - Fail if no 'GLHeader' is specified, but we are
processing a GL/ProcAddress config - Fail if a GL function is not part of
an extension
MethodBinding, ConstantDefinition cleanup:
- getName() returns the renamed name
- getOrigName() returns the original
- getAliasedNames() returns the aliased ones
MethodBinding:
- Change: equals() operates on renamed name
- Add: hashCode() function - same criteria as equals()
Impact:
- All config options etc shall trigger with the renamed name,
but ignore, rename etc.
- Generated Java impl. uses the renamed base name as well
Change: emitDefine() uses the ConstantDefinition
Add: JavaConfiguration: dumpRenames()
Change JavaConfiguration.shouldIgnoreInInterface/Impl():
- respect the renamed symbol name as well
Change JavaEmitter.emitFunctions():
- only emit a generated MethodBinding once,
therefor store emitted method bindings in a HashSet
Fix BuildStaticGLInfo:
- Allow white space at the end of #ifndef and #define
- Trim strings
- Allow 'const' qualifier in function pattern
Fix GLEmitter:
- Fail if no 'GLHeader' is specified, but a RenameIntoCore option ..
- Don't emit marker defines, marking an extension (ie not part of an extension)
Fix GLJavaMethodBindingEmitter:
- Fail if a GL function is not part of an extension
Fix PCPP:
- Pass constant type qualifiers for hex-constants: 'l' 'L' ...
Fix ProcAddressEmitter:
- Operate on the aliased/renamed name for querying ProcAddress usage
and generating code.
---
.../com/sun/gluegen/CMethodBindingEmitter.java | 2 +-
src/java/com/sun/gluegen/ConstantDefinition.java | 28 ++++++-
src/java/com/sun/gluegen/DebugEmitter.java | 4 +-
src/java/com/sun/gluegen/GlueEmitter.java | 2 +-
src/java/com/sun/gluegen/GlueGen.java | 4 +-
src/java/com/sun/gluegen/JavaConfiguration.java | 16 +++-
src/java/com/sun/gluegen/JavaEmitter.java | 46 ++++++++---
.../com/sun/gluegen/JavaMethodBindingEmitter.java | 6 +-
src/java/com/sun/gluegen/MethodBinding.java | 54 +++++++++++--
.../gluegen/nativesig/NativeSignatureEmitter.java | 4 +-
.../NativeSignatureJavaMethodBindingEmitter.java | 4 +-
.../com/sun/gluegen/opengl/BuildStaticGLInfo.java | 40 +++++++---
.../com/sun/gluegen/opengl/GLConfiguration.java | 11 +--
src/java/com/sun/gluegen/opengl/GLEmitter.java | 92 +++++++++++++++-------
.../gluegen/opengl/GLJavaMethodBindingEmitter.java | 19 +++--
src/java/com/sun/gluegen/pcpp/PCPP.java | 26 ++++--
.../ProcAddressCMethodBindingEmitter.java | 8 --
.../gluegen/procaddress/ProcAddressEmitter.java | 27 +++----
18 files changed, 277 insertions(+), 116 deletions(-)
(limited to 'src/java/com/sun')
diff --git a/src/java/com/sun/gluegen/CMethodBindingEmitter.java b/src/java/com/sun/gluegen/CMethodBindingEmitter.java
index 02680d0..af632c3 100644
--- a/src/java/com/sun/gluegen/CMethodBindingEmitter.java
+++ b/src/java/com/sun/gluegen/CMethodBindingEmitter.java
@@ -155,7 +155,7 @@ public class CMethodBindingEmitter extends FunctionEmitter
public final MethodBinding getBinding() { return binding; }
public String getName() {
- return binding.getRenamedMethodName();
+ return binding.getName();
}
/**
diff --git a/src/java/com/sun/gluegen/ConstantDefinition.java b/src/java/com/sun/gluegen/ConstantDefinition.java
index e06903b..60f5cef 100644
--- a/src/java/com/sun/gluegen/ConstantDefinition.java
+++ b/src/java/com/sun/gluegen/ConstantDefinition.java
@@ -38,6 +38,8 @@ import java.util.*;
/** Represents the definition of a constant which was provided either
via a #define statement or through an enum definition. */
public class ConstantDefinition {
+ private String origName;
+ private HashSet aliasedNames;
private String name;
private String value;
private String enumName;
@@ -46,9 +48,11 @@ public class ConstantDefinition {
public ConstantDefinition(String name,
String value,
String enumName) {
+ this.origName = name;
this.name = name;
this.value = value;
this.enumName = enumName;
+ this.aliasedNames=new HashSet();
}
public boolean equals(ConstantDefinition other) {
@@ -72,7 +76,29 @@ public class ConstantDefinition {
return name.hashCode();
}
- public String getName() { return name; }
+ /** Supports renaming in Java binding. */
+ public void rename(String name) {
+ if(null!=name) {
+ this.name = name;
+ aliasedNames.add(origName);
+ }
+ }
+
+ public void addAliasedName(String name) {
+ aliasedNames.add(name);
+ }
+ public Collection getAliasedNames() {
+ return aliasedNames;
+ }
+
+ public String getOrigName() {
+ return origName;
+ }
+
+ public String getName() {
+ return name;
+ }
+
public String getValue() { return value; }
/** Returns null if this definition was not part of an
enumeration, or if the enum was anonymous. */
diff --git a/src/java/com/sun/gluegen/DebugEmitter.java b/src/java/com/sun/gluegen/DebugEmitter.java
index 40d6c2d..34586a1 100644
--- a/src/java/com/sun/gluegen/DebugEmitter.java
+++ b/src/java/com/sun/gluegen/DebugEmitter.java
@@ -58,7 +58,9 @@ public class DebugEmitter implements GlueEmitter {
System.out.println("----- END EMISSION OF GLUE CODE -----");
}
public void beginDefines() {}
- public void emitDefine(String name, String value, String optionalComment) {
+ public void emitDefine(ConstantDefinition def, String optionalComment) {
+ String name = def.getName();
+ String value = def.getValue();
System.out.println("#define " + name + " " + value +
(optionalComment != null ? ("// " + optionalComment) : ""));
}
diff --git a/src/java/com/sun/gluegen/GlueEmitter.java b/src/java/com/sun/gluegen/GlueEmitter.java
index e21bc87..2738411 100644
--- a/src/java/com/sun/gluegen/GlueEmitter.java
+++ b/src/java/com/sun/gluegen/GlueEmitter.java
@@ -88,7 +88,7 @@ public interface GlueEmitter {
* emit that string as a comment providing extra information about the
* define.
*/
- public void emitDefine(String name, String value, String optionalComment) throws Exception;
+ public void emitDefine(ConstantDefinition def, String optionalComment) throws Exception;
public void endDefines() throws Exception;
public void beginFunctions(TypeDictionary typedefDictionary,
diff --git a/src/java/com/sun/gluegen/GlueGen.java b/src/java/com/sun/gluegen/GlueGen.java
index 5d61fdb..9221c3a 100644
--- a/src/java/com/sun/gluegen/GlueGen.java
+++ b/src/java/com/sun/gluegen/GlueGen.java
@@ -266,9 +266,7 @@ public class GlueGen implements GlueEmitterControls {
comment += "
\n" + enumName;
}
}
- emit.emitDefine(def.getName(),
- def.getValue(),
- comment);
+ emit.emitDefine(def, comment);
}
}
emit.endDefines();
diff --git a/src/java/com/sun/gluegen/JavaConfiguration.java b/src/java/com/sun/gluegen/JavaConfiguration.java
index a1fe732..636cef8 100644
--- a/src/java/com/sun/gluegen/JavaConfiguration.java
+++ b/src/java/com/sun/gluegen/JavaConfiguration.java
@@ -598,14 +598,23 @@ public class JavaConfiguration {
}
}
+ public void dumpRenames() {
+ System.err.println("Symbol Renames: ");
+ for (Iterator iter = javaSymbolRenames.keySet().iterator(); iter.hasNext(); ) {
+ String key = (String)iter.next();
+ System.err.println("\t"+key+" -> "+javaSymbolRenames.get(key));
+ }
+ }
+
/** Returns true if this #define, function, struct, or field within
a struct should be ignored during glue code generation. */
public boolean shouldIgnoreInInterface(String symbol) {
if(DEBUG_IGNORES) {
dumpIgnoresOnce();
}
- // Simple case; the entire symbol is in the interface ignore table.
- if (extendedIntfSymbolsIgnore.contains(symbol)) {
+ // Simple case; the entire symbol (orig or renamed) is in the interface ignore table
+ if (extendedIntfSymbolsIgnore.contains(symbol) ||
+ extendedIntfSymbolsIgnore.contains(getJavaSymbolRename(symbol))) {
if(DEBUG_IGNORES) {
System.err.println("Ignore Intf: "+symbol);
}
@@ -625,7 +634,8 @@ public class JavaConfiguration {
}
if (!extendedIntfSymbolsOnly.isEmpty()) {
- if(!extendedIntfSymbolsOnly.contains(symbol)) {
+ if(!extendedIntfSymbolsOnly.contains(symbol) &&
+ !extendedIntfSymbolsOnly.contains(getJavaSymbolRename(symbol))) {
if(DEBUG_IGNORES) {
System.err.println("Ignore Impl !extended: " + symbol);
}
diff --git a/src/java/com/sun/gluegen/JavaEmitter.java b/src/java/com/sun/gluegen/JavaEmitter.java
index 603881c..1667ed6 100644
--- a/src/java/com/sun/gluegen/JavaEmitter.java
+++ b/src/java/com/sun/gluegen/JavaEmitter.java
@@ -126,11 +126,7 @@ public class JavaEmitter implements GlueEmitter {
for (Iterator iter = constants.iterator(); iter.hasNext(); ) {
ConstantDefinition def = (ConstantDefinition) iter.next();
String rename = cfg.getJavaSymbolRename(def.getName());
- if (rename != null) {
- ConstantDefinition newDef = new ConstantDefinition(rename, def.getValue(), def.getEnumName());
- newDef.addAlias(def.getName());
- def = newDef;
- }
+ def.rename(cfg.getJavaSymbolRename(def.getName()));
newConstants.add(def);
}
constants = newConstants;
@@ -301,7 +297,7 @@ public class JavaEmitter implements GlueEmitter {
"\" cannot be assigned to a int, long, float, or double");
}
- public void emitDefine(String name, String value, String optionalComment) throws Exception
+ public void emitDefine(ConstantDefinition def, String optionalComment) throws Exception
{
if (cfg.allStatic() || cfg.emitInterface()) {
// TODO: Some defines (e.g., GL_DOUBLE_EXT in gl.h) are defined in terms
@@ -313,6 +309,8 @@ public class JavaEmitter implements GlueEmitter {
// currently only emits only numeric defines -- if it handled #define'd
// objects it would make a bigger difference.
+ String name = def.getName();
+ String value = def.getValue();
if (!cfg.shouldIgnoreInInterface(name)) {
String type = getJavaType(name, value);
if (optionalComment != null && optionalComment.length() != 0) {
@@ -377,6 +375,7 @@ public class JavaEmitter implements GlueEmitter {
});
// Bind all the C funcs to Java methods
+ HashSet/**/ methodBindingSet = new HashSet();
ArrayList/**/ methodBindingEmitters = new ArrayList(2*funcsToBind.size());
for (Iterator iter = funcsToBind.iterator(); iter.hasNext(); ) {
FunctionSymbol cFunc = (FunctionSymbol) iter.next();
@@ -385,7 +384,7 @@ public class JavaEmitter implements GlueEmitter {
continue; // don't generate bindings for this symbol
}
- List allBindings = generateMethodBindingEmitters(cFunc);
+ List allBindings = generateMethodBindingEmitters(methodBindingSet, cFunc);
methodBindingEmitters.addAll(allBindings);
}
@@ -669,14 +668,14 @@ public class JavaEmitter implements GlueEmitter {
* Generate all appropriate Java bindings for the specified C function
* symbols.
*/
- protected List generateMethodBindingEmitters(FunctionSymbol sym) throws Exception {
+ protected List generateMethodBindingEmitters(HashSet/**/ methodBindingSet, FunctionSymbol sym) throws Exception {
ArrayList/**/ allEmitters = new ArrayList();
try {
// Get Java binding for the function
MethodBinding mb = bindFunction(sym, null, null, machDesc64);
-
+
// JavaTypes representing C pointers in the initial
// MethodBinding have not been lowered yet to concrete types
List bindings = expandMethodBinding(mb);
@@ -684,6 +683,11 @@ public class JavaEmitter implements GlueEmitter {
for (Iterator iter = bindings.iterator(); iter.hasNext(); ) {
MethodBinding binding = (MethodBinding) iter.next();
+ if(!methodBindingSet.add(binding)) {
+ // skip .. already exisiting binding ..
+ continue;
+ }
+
if (cfg.allStatic() && binding.hasContainingType()) {
// This should not currently happen since structs are emitted using a different mechanism
throw new IllegalArgumentException("Cannot create binding in AllStatic mode because method has containing type: \"" +
@@ -1146,6 +1150,28 @@ public class JavaEmitter implements GlueEmitter {
}
public void endStructs() throws Exception {}
+ public static int addStrings2Buffer(StringBuffer buf, String sep, String first, Collection col) {
+ int num = 0;
+ if(null==buf) buf=new StringBuffer();
+
+ Iterator iter=col.iterator();
+ if(null!=first) {
+ buf.append(first);
+ if( iter.hasNext() ) {
+ buf.append(sep);
+ }
+ num++;
+ }
+ while( iter.hasNext() ) {
+ buf.append((String)iter.next());
+ if( iter.hasNext() ) {
+ buf.append(sep);
+ }
+ num++;
+ }
+ return num;
+ }
+
//----------------------------------------------------------------------
// Internals only below this point
//
@@ -1643,7 +1669,7 @@ public class JavaEmitter implements GlueEmitter {
MethodBinding binding = new MethodBinding(sym, containingType, containingCType);
- binding.setRenamedMethodName(cfg.getJavaSymbolRename(sym.getName()));
+ binding.renameMethodName(cfg.getJavaSymbolRename(sym.getName()));
if (cfg.returnsString(binding.getName())) {
PointerType prt = sym.getReturnType().asPointer();
diff --git a/src/java/com/sun/gluegen/JavaMethodBindingEmitter.java b/src/java/com/sun/gluegen/JavaMethodBindingEmitter.java
index 9fa232d..558c184 100644
--- a/src/java/com/sun/gluegen/JavaMethodBindingEmitter.java
+++ b/src/java/com/sun/gluegen/JavaMethodBindingEmitter.java
@@ -157,7 +157,7 @@ public class JavaMethodBindingEmitter extends FunctionEmitter
public boolean isForIndirectBufferAndArrayImplementation() { return forIndirectBufferAndArrayImplementation; }
public String getName() {
- return binding.getRenamedMethodName();
+ return binding.getName();
}
protected String getArgumentName(int i) {
@@ -370,9 +370,9 @@ public class JavaMethodBindingEmitter extends FunctionEmitter
protected String getImplMethodName(boolean direct) {
if (direct) {
- return binding.getRenamedMethodName() + "0";
+ return binding.getName() + "0";
} else {
- return binding.getRenamedMethodName() + "1";
+ return binding.getName() + "1";
}
}
diff --git a/src/java/com/sun/gluegen/MethodBinding.java b/src/java/com/sun/gluegen/MethodBinding.java
index 5431874..228f581 100644
--- a/src/java/com/sun/gluegen/MethodBinding.java
+++ b/src/java/com/sun/gluegen/MethodBinding.java
@@ -51,6 +51,7 @@ public class MethodBinding {
private FunctionSymbol sym;
private String renamedMethodName;
+ private HashSet aliasedNames;
private JavaType javaReturnType;
private List javaArgumentTypes;
private boolean computedSignatureProperties;
@@ -76,6 +77,8 @@ public class MethodBinding {
this.sym = bindingToCopy.sym;
this.renamedMethodName = bindingToCopy.renamedMethodName;
+ this.aliasedNames=new HashSet();
+ this.aliasedNames.addAll(bindingToCopy.aliasedNames);
this.containingType = bindingToCopy.containingType;
this.containingCType = bindingToCopy.containingCType;
this.javaReturnType = bindingToCopy.javaReturnType;
@@ -96,6 +99,7 @@ public class MethodBinding {
/** Constructor for calling a C function. */
public MethodBinding(FunctionSymbol sym) {
this.sym = sym;
+ this.aliasedNames=new HashSet();
}
/** Constructor for calling a function pointer contained in a
@@ -104,6 +108,7 @@ public class MethodBinding {
this.sym = sym;
this.containingType = containingType;
this.containingCType = containingCType;
+ this.aliasedNames=new HashSet();
}
public void setJavaReturnType(JavaType type) {
@@ -156,11 +161,11 @@ public class MethodBinding {
return "arg" + i;
}
- public String getName() {
+ public String getOrigName() {
return sym.getName();
}
- public String getRenamedMethodName() {
+ public String getName() {
// Defaults to same as C symbol unless renamed
if (renamedMethodName != null) {
return renamedMethodName;
@@ -169,8 +174,19 @@ public class MethodBinding {
}
/** Supports renaming C function in Java binding. */
- public void setRenamedMethodName(String name) {
- renamedMethodName = name;
+ public void renameMethodName(String name) {
+ if(null!=name) {
+ renamedMethodName = name;
+ aliasedNames.add(sym.getName());
+ }
+ }
+
+ public void addAliasedName(String name) {
+ aliasedNames.add(name);
+ }
+
+ public Collection getAliasedNames() {
+ return aliasedNames;
}
/** Creates a new MethodBinding replacing the specified Java
@@ -451,9 +467,10 @@ public class MethodBinding {
}
MethodBinding other = (MethodBinding)obj;
- if (!(sym.equals(other.sym))) { return false; }
+ if ( !getName().equals(other.getName()) ||
+ !sym.getType().equals(other.sym.getType()) ) { return false; }
if (!(javaReturnType.equals(other.getJavaReturnType()))) { return false; }
- if (containingType != null &&
+ if (containingCType != null &&
other.getContainingCType() != null &&
(!(containingCType.equals(other.getContainingCType())))) {
return false;
@@ -473,14 +490,35 @@ public class MethodBinding {
return true;
}
- // FIXME!! Implement hashCode() to match equals(Object)
+ public int hashCode() {
+ StringBuffer buf = new StringBuffer(200);
+ buf.append(getName());
+ buf.append(sym.getType().getName(true));
+ buf.append(getJavaReturnType().getName());
+ if (containingCType != null) {
+ buf.append(containingCType.getName(true));
+ }
+
+ for (int i = 0; i < getNumArguments(); i++) {
+ JavaType type = getJavaArgumentType(i);
+ if (type.isVoid()) {
+ // Make sure this is the only param to the method; if it isn't,
+ // there's something wrong with our parsing of the headers.
+ assert(getNumArguments() == 1);
+ continue;
+ }
+
+ buf.append(type.getName());
+ }
+ return buf.toString().hashCode();
+ }
/** Returns the signature of this binding. */
public String toString() {
StringBuffer buf = new StringBuffer(200);
buf.append(getJavaReturnType().getName());
buf.append(" ");
- buf.append(getRenamedMethodName());
+ buf.append(getName());
buf.append("(");
boolean needComma = false;
for (int i = 0; i < getNumArguments(); i++) {
diff --git a/src/java/com/sun/gluegen/nativesig/NativeSignatureEmitter.java b/src/java/com/sun/gluegen/nativesig/NativeSignatureEmitter.java
index 4fe81af..314a9bb 100755
--- a/src/java/com/sun/gluegen/nativesig/NativeSignatureEmitter.java
+++ b/src/java/com/sun/gluegen/nativesig/NativeSignatureEmitter.java
@@ -50,9 +50,9 @@ import com.sun.gluegen.procaddress.*;
/** Emitter producing NativeSignature attributes. */
public class NativeSignatureEmitter extends GLEmitter {
- protected List generateMethodBindingEmitters(FunctionSymbol sym) throws Exception {
+ protected List generateMethodBindingEmitters(HashSet/**/ methodBindingSet, FunctionSymbol sym) throws Exception {
// Allow superclass to do most of the work for us
- List res = super.generateMethodBindingEmitters(sym);
+ List res = super.generateMethodBindingEmitters(methodBindingSet, sym);
// Filter out all non-JavaMethodBindingEmitters
for (Iterator iter = res.iterator(); iter.hasNext(); ) {
diff --git a/src/java/com/sun/gluegen/nativesig/NativeSignatureJavaMethodBindingEmitter.java b/src/java/com/sun/gluegen/nativesig/NativeSignatureJavaMethodBindingEmitter.java
index 12a6c0e..63d95fe 100755
--- a/src/java/com/sun/gluegen/nativesig/NativeSignatureJavaMethodBindingEmitter.java
+++ b/src/java/com/sun/gluegen/nativesig/NativeSignatureJavaMethodBindingEmitter.java
@@ -474,9 +474,9 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding
protected String getImplMethodName(boolean direct) {
String name = null;
if (direct) {
- name = binding.getRenamedMethodName() + "$0";
+ name = binding.getName() + "$0";
} else {
- name = binding.getRenamedMethodName() + "$1";
+ name = binding.getName() + "$1";
}
if (bufferObjectVariant) {
return name + "BufObj";
diff --git a/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java b/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java
index 4226f46..f5193dc 100644
--- a/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java
+++ b/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java
@@ -91,17 +91,23 @@ import java.util.regex.*;
public class BuildStaticGLInfo
{
// Handles function pointer
+ protected static int funcIdentifierGroup = 9;
protected static Pattern funcPattern =
- Pattern.compile("^(GLAPI|GL_API|GL_APICALL|EGLAPI|extern)?(\\s*)(\\w+)(\\*)?(\\s+)(GLAPIENTRY|GL_APIENTRY|APIENTRY|EGLAPIENTRY|WINAPI)?(\\s*)([ew]?gl\\w+)\\s?(\\(.*)");
+ Pattern.compile("^(GLAPI|GL_API|GL_APICALL|EGLAPI|extern)?(\\s*)(const\\s+)?(\\w+)(\\s*\\*)?(\\s+)(GLAPIENTRY|GL_APIENTRY|APIENTRY|EGLAPIENTRY|WINAPI)?(\\s*)([ew]?gl\\w+)\\s?(\\(.*)");
+
protected static Pattern associationPattern =
- Pattern.compile("\\#ifndef ([EW]?GL[X]?_[A-Za-z0-9_]+)");
+ Pattern.compile("\\#ifndef ([EW]?GL[X]?_[A-Za-z0-9_]+)\\s*");
+
+ protected static int defineIdentifierGroup = 1;
protected static Pattern definePattern =
- Pattern.compile("\\#define ([EW]?GL[X]?_[A-Za-z0-9_]+)\\s*([A-Za-z0-9_]+)");
+ Pattern.compile("\\#define ([EW]?GL[X]?_[A-Za-z0-9_]+)\\s*([A-Za-z0-9_]+)\\s*");
+
// Maps function / #define names to the names of the extensions they're declared in
protected Map declarationToExtensionMap = new HashMap();
// Maps extension names to Set of identifiers (both #defines and
// function names) this extension declares
protected Map/**/ extensionToDeclarationMap = new HashMap();
+ protected boolean debug = false;
/**
* The first argument is the package to which the StaticGLInfo class
@@ -113,6 +119,7 @@ public class BuildStaticGLInfo
{
if (args.length > 0 && args[0].equals("-test")) {
BuildStaticGLInfo builder = new BuildStaticGLInfo();
+ builder.setDebug(true);
String[] newArgs = new String[args.length - 1];
System.arraycopy(args, 1, newArgs, 0, args.length - 1);
builder.parse(newArgs);
@@ -157,6 +164,9 @@ public class BuildStaticGLInfo
}
}
+ public void setDebug(boolean v) {
+ debug = v;
+ }
/** Parses the supplied C header files and adds the function
associations contained therein to the internal map. */
@@ -173,14 +183,20 @@ public class BuildStaticGLInfo
String line, activeAssociation = null;
Matcher m = null;
while ((line = reader.readLine()) != null) {
+ int type = 0; // 1-define, 2-function
// see if we're inside a #ifndef GL_XXX block and matching a function
if (activeAssociation != null) {
String identifier = null;
if ((m = funcPattern.matcher(line)).matches()) {
- identifier = m.group(8);
+ identifier = m.group(funcIdentifierGroup).trim();
+ type =2;
} else if ((m = definePattern.matcher(line)).matches()) {
- identifier = m.group(1);
+ identifier = m.group(defineIdentifierGroup).trim();
+ type =1;
} else if (line.startsWith("#endif")) {
+ if(debug) {
+ System.err.println("END ASSOCIATION BLOCK: <" + activeAssociation + ">");
+ }
activeAssociation = null;
}
if ((identifier != null) &&
@@ -188,13 +204,17 @@ public class BuildStaticGLInfo
// Handles #ifndef GL_... #define GL_...
!identifier.equals(activeAssociation)) {
addAssociation(identifier, activeAssociation);
- // System.err.println(" ADDING ASSOCIATION: " + identifier + " " + activeAssociation);
+ if(debug) {
+ System.err.println(" ADDING ASSOCIATION: <" + identifier + "> <" + activeAssociation + "> ; type "+type);
+ }
}
} else if ((m = associationPattern.matcher(line)).matches()) {
// found a new #ifndef GL_XXX block
- activeAssociation = m.group(1);
+ activeAssociation = m.group(1).trim();
- // System.err.println("FOUND NEW ASSOCIATION BLOCK: " + activeAssociation);
+ if(debug) {
+ System.err.println("BEGIN ASSOCIATION BLOCK: <" + activeAssociation + ">");
+ }
}
}
reader.close();
@@ -204,12 +224,12 @@ public class BuildStaticGLInfo
for (Iterator i1 = extensionToDeclarationMap.keySet().iterator(); i1.hasNext(); ) {
String name = (String) i1.next();
Set decls = (Set) extensionToDeclarationMap.get(name);
- System.out.println(name + ":");
+ System.out.println("<"+name+"> :");
List l = new ArrayList();
l.addAll(decls);
Collections.sort(l);
for (Iterator i2 = l.iterator(); i2.hasNext(); ) {
- System.out.println(" " + (String) i2.next());
+ System.out.println(" <" + (String) i2.next() + ">");
}
}
}
diff --git a/src/java/com/sun/gluegen/opengl/GLConfiguration.java b/src/java/com/sun/gluegen/opengl/GLConfiguration.java
index 923dcf5..4e8c0c3 100755
--- a/src/java/com/sun/gluegen/opengl/GLConfiguration.java
+++ b/src/java/com/sun/gluegen/opengl/GLConfiguration.java
@@ -202,13 +202,6 @@ public class GLConfiguration extends ProcAddressConfiguration {
super.dumpIgnores();
}
- protected String getExtension(String symbol) {
- if (glInfo != null) {
- return glInfo.getExtension(symbol);
- }
- return null;
- }
-
protected boolean shouldIgnoreExtension(String symbol, boolean criteria) {
if (criteria && glInfo != null) {
String extension = glInfo.getExtension(symbol);
@@ -216,14 +209,14 @@ public class GLConfiguration extends ProcAddressConfiguration {
ignoredExtensions.contains(extension)) {
return true;
}
- boolean isGLFunc = GLExtensionNames.isGLFunction(symbol);
boolean isGLEnum = GLExtensionNames.isGLEnumeration(symbol);
+ boolean isGLFunc = GLExtensionNames.isGLFunction(symbol);
if(isGLFunc || isGLEnum) {
if(GLExtensionNames.isExtensionVEN(symbol, isGLFunc)) {
String extSuffix = GLExtensionNames.getExtensionSuffix(symbol, isGLFunc);
if( getDropUniqVendorExtensions(extSuffix) ) {
if(DEBUG_IGNORES) {
- System.err.println("Ignore UniqVendorEXT: "+symbol);
+ System.err.println("Ignore UniqVendorEXT: "+symbol+", vendor "+extSuffix);
}
return true;
}
diff --git a/src/java/com/sun/gluegen/opengl/GLEmitter.java b/src/java/com/sun/gluegen/opengl/GLEmitter.java
index 83e688e..9e32026 100644
--- a/src/java/com/sun/gluegen/opengl/GLEmitter.java
+++ b/src/java/com/sun/gluegen/opengl/GLEmitter.java
@@ -85,9 +85,15 @@ public class GLEmitter extends ProcAddressEmitter
// renaming mechanisms that are built elsewhere.
GLConfiguration config = getGLConfig();
+ Set extensionsRenamedIntoCore = config.getExtensionsRenamedIntoCore();
BuildStaticGLInfo glInfo = config.getGLInfo();
- for (Iterator iter = config.getExtensionsRenamedIntoCore().iterator();
- iter.hasNext(); ) {
+ if(null==glInfo) {
+ if(extensionsRenamedIntoCore.size()>0) {
+ throw new RuntimeException("ExtensionRenamedIntoCore (num: "+extensionsRenamedIntoCore.size()+"), but no GLHeader");
+ }
+ return;
+ }
+ for (Iterator iter = extensionsRenamedIntoCore.iterator(); iter.hasNext(); ) {
String extension = (String) iter.next();
Set/**/ declarations = glInfo.getDeclarations(extension);
if (declarations != null) {
@@ -305,19 +311,68 @@ public class GLEmitter extends ProcAddressEmitter
return bufferObjectMethodBindings.containsKey(binding);
}
- public void emitDefine(String name, String value, String optionalComment) throws Exception {
- String extensionName = getGLConfig().getExtension(name);
+ public void emitDefine(ConstantDefinition def, String optionalComment) throws Exception {
+ BuildStaticGLInfo glInfo = getGLConfig().getGLInfo();
+ if(null==glInfo) {
+ throw new Exception("No GLInfo for: "+def);
+ }
+ String symbolRenamed = def.getName();
StringBuffer newComment = new StringBuffer();
- if(null!=extensionName) {
- newComment.append("Part of "+extensionName+"
");
- } else {
- newComment.append("Part of unknown extension
");
+ newComment.append("Part of ");
+ if(0==addExtensionsOfSymbols2Buffer(newComment, ", ", symbolRenamed, def.getAliasedNames())) {
+ // Note: All GL enums must be contained within an extension marker !
+ // #ifndef GL_EXT_lala
+ // #define GL_EXT_lala 1
+ // ...
+ // #endif
+ if(JavaConfiguration.DEBUG_IGNORES) {
+ StringBuffer sb = new StringBuffer();
+ JavaEmitter.addStrings2Buffer(sb, ", ", symbolRenamed, def.getAliasedNames());
+ System.err.println("Dropping marker: "+sb.toString());
+ }
+ return;
}
+ newComment.append("
");
+
if(null!=optionalComment) {
newComment.append(" ");
newComment.append(optionalComment);
}
- super.emitDefine(name, value, newComment.toString());
+
+ super.emitDefine(def, newComment.toString());
+ }
+
+ public int addExtensionsOfSymbols2Buffer(StringBuffer buf, String sep, String first, Collection col) {
+ BuildStaticGLInfo glInfo = getGLConfig().getGLInfo();
+ if(null==glInfo) {
+ throw new RuntimeException("No GLInfo for: "+first);
+ }
+ int num = 0;
+ if(null==buf) buf=new StringBuffer();
+ String extensionName;
+
+ Iterator iter=col.iterator();
+ if(null!=first) {
+ extensionName = glInfo.getExtension(first);
+ if(null!=extensionName) {
+ buf.append(extensionName);
+ if( iter.hasNext() ) {
+ buf.append(sep);
+ }
+ num++;
+ }
+ }
+ while( iter.hasNext() ) {
+ extensionName = glInfo.getExtension((String)iter.next());
+ if(null!=extensionName) {
+ buf.append(extensionName);
+ if( iter.hasNext() ) {
+ buf.append(sep);
+ }
+ num++;
+ }
+ }
+ return num;
}
//----------------------------------------------------------------------
@@ -399,23 +454,4 @@ public class GLEmitter extends ProcAddressEmitter
w.flush();
w.close();
}
-
- protected void emitProcAddressTableEntryForSymbol(FunctionSymbol cFunc)
- {
- emitProcAddressTableEntryForString(cFunc.getName());
- }
-
- protected void emitProcAddressTableEntryForString(String str)
- {
- // Deal gracefully with forced proc address generation in the face
- // of having the function pointer typedef in the header file too
- if (emittedTableEntries.contains(str))
- return;
- emittedTableEntries.add(str);
- tableWriter.print(" public long ");
- tableWriter.print(PROCADDRESS_VAR_PREFIX);
- tableWriter.print(str);
- tableWriter.println(";");
- }
-
}
diff --git a/src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java b/src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java
index b952272..5e8bada 100755
--- a/src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java
+++ b/src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java
@@ -109,12 +109,21 @@ public class GLJavaMethodBindingEmitter extends ProcAddressJavaMethodBindingEmit
{
protected void emitBindingCSignature(MethodBinding binding, PrintWriter writer) {
super.emitBindingCSignature(binding, writer);
- String extensionName = glEmitter.getGLConfig().getExtension(binding.getCSymbol().getName());
- if(null!=extensionName) {
- writer.print("
Part of "+extensionName+"
");
- } else {
- writer.print("
Part of unknown extension
");
+
+ String symbolRenamed = binding.getName();
+ StringBuffer newComment = new StringBuffer();
+ newComment.append("Part of ");
+ if(0==glEmitter.addExtensionsOfSymbols2Buffer(newComment, ", ", symbolRenamed, binding.getAliasedNames())) {
+ StringBuffer sb = new StringBuffer();
+ JavaEmitter.addStrings2Buffer(sb, ", ", symbolRenamed, binding.getAliasedNames());
+ RuntimeException ex = new RuntimeException("Couldn't find extension to: "+binding+" ; "+sb.toString());
+ ex.printStackTrace();
+ glEmitter.getGLConfig().getGLInfo().dump();
+ // glEmitter.getGLConfig().dumpRenames();
+ throw ex;
}
+ newComment.append("
");
+ writer.print(newComment.toString());
}
}
}
diff --git a/src/java/com/sun/gluegen/pcpp/PCPP.java b/src/java/com/sun/gluegen/pcpp/PCPP.java
index 4523032..7303c04 100644
--- a/src/java/com/sun/gluegen/pcpp/PCPP.java
+++ b/src/java/com/sun/gluegen/pcpp/PCPP.java
@@ -436,8 +436,10 @@ public class PCPP {
System.err.println("WARNING: \"" + name + "\" redefined from \"" +
oldDef + "\" to \"" + value + "\"");
}
+ debugPrint(true, "#define " + name + " ["+oldDef+" ] -> "+value + " CONST");
//System.out.println("//---DEFINED: " + name + " to \"" + value + "\"");
} else {
+ debugPrint(true, "#define " + name + " -> "+value + " SYMB");
// Value is a symbolic constant like "#define FOO BAR".
// Try to look up the symbol's value
String newValue = resolveDefine(value, true);
@@ -501,15 +503,25 @@ public class PCPP {
}
private boolean checkHex(String s) {
- for (int i = 2; i < s.length(); i++) {
- char c = s.charAt(i);
+ char c='\0';
+ int i;
+ for (i = 2; i < s.length(); i++) {
+ c = s.charAt(i);
if (!((c >= '0' && c <= '9') ||
(c >= 'a' && c <= 'f') ||
(c >= 'A' && c <= 'F'))) {
- return false;
+ break;
}
}
- return true;
+ if(i==s.length()) {
+ return true;
+ } else if(i==s.length()-1) {
+ // Const qualifier ..
+ return c == 'l' || c == 'L' ||
+ c == 'f' || c == 'F' ||
+ c == 'u' || c == 'U' ;
+ }
+ return false;
}
private boolean checkDecimal(String s) {
@@ -553,7 +565,7 @@ public class PCPP {
String symbolName = nextWord();
debugPrint(true, (isIfdef ? "#ifdef " : "#ifndef ") + symbolName);
boolean symbolIsDefined = defineMap.get(symbolName) != null;
- //debugPrint(true, "HANDLE_IFDEF: ifdef(" + symbolName + ") = " + symbolIsDefined );
+ debugPrint(true, (isIfdef ? "#ifdef " : "#ifndef ") + symbolName + "(defined: "+symbolIsDefined+")");
pushEnableBit(enabled() && symbolIsDefined == isIfdef);
}
@@ -808,7 +820,7 @@ public class PCPP {
private void pushEnableBit(boolean enabled) {
enabledBits.add(new Boolean(enabled));
++debugPrintIndentLevel;
- //debugPrint(false, "PUSH_ENABLED, NOW: " + enabled());
+ debugPrint(false, "PUSH_ENABLED, NOW: " + enabled());
}
private void popEnableBit() {
@@ -818,7 +830,7 @@ public class PCPP {
}
enabledBits.remove(enabledBits.size() - 1);
--debugPrintIndentLevel;
- //debugPrint(false, "POP_ENABLED, NOW: " + enabled());
+ debugPrint(false, "POP_ENABLED, NOW: " + enabled());
}
private boolean enabled() {
diff --git a/src/java/com/sun/gluegen/procaddress/ProcAddressCMethodBindingEmitter.java b/src/java/com/sun/gluegen/procaddress/ProcAddressCMethodBindingEmitter.java
index b7aadc9..54263a5 100755
--- a/src/java/com/sun/gluegen/procaddress/ProcAddressCMethodBindingEmitter.java
+++ b/src/java/com/sun/gluegen/procaddress/ProcAddressCMethodBindingEmitter.java
@@ -66,14 +66,6 @@ public class ProcAddressCMethodBindingEmitter extends CMethodBindingEmitter {
return super.getName();
}
}
-
- public String getRenamedMethodName() {
- if (callThroughProcAddress) {
- return ProcAddressEmitter.WRAP_PREFIX + super.getRenamedMethodName();
- } else {
- return super.getRenamedMethodName();
- }
- }
},
methodToWrap.getDefaultOutput(),
methodToWrap.getJavaPackageName(),
diff --git a/src/java/com/sun/gluegen/procaddress/ProcAddressEmitter.java b/src/java/com/sun/gluegen/procaddress/ProcAddressEmitter.java
index 8f849ac..871dc5e 100755
--- a/src/java/com/sun/gluegen/procaddress/ProcAddressEmitter.java
+++ b/src/java/com/sun/gluegen/procaddress/ProcAddressEmitter.java
@@ -102,23 +102,21 @@ public class ProcAddressEmitter extends JavaEmitter
return new ProcAddressConfiguration();
}
- protected List generateMethodBindingEmitters(FunctionSymbol sym) throws Exception
- {
- return generateMethodBindingEmittersImpl(sym);
+ protected List generateMethodBindingEmitters(HashSet/**/ methodBindingSet, FunctionSymbol sym) throws Exception {
+ return generateMethodBindingEmittersImpl(methodBindingSet, sym);
}
protected boolean needsModifiedEmitters(FunctionSymbol sym) {
if (!needsProcAddressWrapper(sym) ||
- getConfig().isUnimplemented(sym.getName())) {
+ getConfig().isUnimplemented(getAliasedSymName(sym))) {
return false;
}
return true;
}
- private List generateMethodBindingEmittersImpl(FunctionSymbol sym) throws Exception
- {
- List defaultEmitters = super.generateMethodBindingEmitters(sym);
+ private List generateMethodBindingEmittersImpl(HashSet/**/ methodBindingSet, FunctionSymbol sym) throws Exception {
+ List defaultEmitters = super.generateMethodBindingEmitters(methodBindingSet, sym);
// if the superclass didn't generate any bindings for the symbol, let's
// honor that (for example, the superclass might have caught an Ignore
@@ -140,7 +138,7 @@ public class ProcAddressEmitter extends JavaEmitter
if (needsProcAddressWrapper(sym)) {
if (getProcAddressConfig().emitProcAddressTable()) {
// emit an entry in the GL proc address table for this method.
- emitProcAddressTableEntryForSymbol(sym);
+ emitProcAddressTableEntryForString(getAliasedSymName(sym));
}
}
@@ -254,9 +252,15 @@ public class ProcAddressEmitter extends JavaEmitter
emitters.add(res);
}
+ private String getAliasedSymName(FunctionSymbol sym) {
+ String symName = getConfig().getJavaSymbolRename(sym.getName());
+ if(null==symName) symName=sym.getName();
+ return symName;
+ }
+
protected boolean needsProcAddressWrapper(FunctionSymbol sym)
{
- String symName = sym.getName();
+ String symName = getAliasedSymName(sym);
ProcAddressConfiguration config = getProcAddressConfig();
@@ -378,11 +382,6 @@ public class ProcAddressEmitter extends JavaEmitter
w.close();
}
- protected void emitProcAddressTableEntryForSymbol(FunctionSymbol cFunc)
- {
- emitProcAddressTableEntryForString(cFunc.getName());
- }
-
protected void emitProcAddressTableEntryForString(String str)
{
// Deal gracefully with forced proc address generation in the face
--
cgit v1.2.3
From 55cf5a4f224c87542b65d820b851f66d371c4062 Mon Sep 17 00:00:00 2001
From: Sven Gothel
Date: Wed, 5 Aug 2009 08:42:25 -0700
Subject: Fix: Add unsigned qualifier, CGL and GLU
---
src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
(limited to 'src/java/com/sun')
diff --git a/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java b/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java
index f5193dc..0ede95e 100644
--- a/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java
+++ b/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java
@@ -91,16 +91,16 @@ import java.util.regex.*;
public class BuildStaticGLInfo
{
// Handles function pointer
- protected static int funcIdentifierGroup = 9;
+ protected static int funcIdentifierGroup = 10;
protected static Pattern funcPattern =
- Pattern.compile("^(GLAPI|GL_API|GL_APICALL|EGLAPI|extern)?(\\s*)(const\\s+)?(\\w+)(\\s*\\*)?(\\s+)(GLAPIENTRY|GL_APIENTRY|APIENTRY|EGLAPIENTRY|WINAPI)?(\\s*)([ew]?gl\\w+)\\s?(\\(.*)");
+ Pattern.compile("^(GLAPI|GL_API|GL_APICALL|EGLAPI|extern)?(\\s*)((unsigned|const)\\s+)?(\\w+)(\\s*\\*)?(\\s+)(GLAPIENTRY|GL_APIENTRY|APIENTRY|EGLAPIENTRY|WINAPI)?(\\s*)([ew]?gl\\w+)\\s?(\\(.*)");
protected static Pattern associationPattern =
- Pattern.compile("\\#ifndef ([EW]?GL[X]?_[A-Za-z0-9_]+)\\s*");
+ Pattern.compile("\\#ifndef ([CEW]?GL[XU]?_[A-Za-z0-9_]+)\\s*");
protected static int defineIdentifierGroup = 1;
protected static Pattern definePattern =
- Pattern.compile("\\#define ([EW]?GL[X]?_[A-Za-z0-9_]+)\\s*([A-Za-z0-9_]+)\\s*");
+ Pattern.compile("\\#define ([CEW]?GL[XU]?_[A-Za-z0-9_]+)\\s*([A-Za-z0-9_]+)\\s*");
// Maps function / #define names to the names of the extensions they're declared in
protected Map declarationToExtensionMap = new HashMap();
--
cgit v1.2.3
From 814050670c7b523d0cdd049c89abf657a230c866 Mon Sep 17 00:00:00 2001
From: Sven Gothel
Date: Wed, 5 Aug 2009 09:57:37 -0700
Subject: Fix: Allow all constanst defined by enums; Add PFD_ defines.
---
src/java/com/sun/gluegen/ConstantDefinition.java | 5 +++++
src/java/com/sun/gluegen/GlueGen.java | 4 ++--
src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java | 2 +-
src/java/com/sun/gluegen/opengl/GLEmitter.java | 11 ++++++++++-
4 files changed, 18 insertions(+), 4 deletions(-)
(limited to 'src/java/com/sun')
diff --git a/src/java/com/sun/gluegen/ConstantDefinition.java b/src/java/com/sun/gluegen/ConstantDefinition.java
index 60f5cef..44ce8e0 100644
--- a/src/java/com/sun/gluegen/ConstantDefinition.java
+++ b/src/java/com/sun/gluegen/ConstantDefinition.java
@@ -42,15 +42,18 @@ public class ConstantDefinition {
private HashSet aliasedNames;
private String name;
private String value;
+ private boolean isEnum;
private String enumName;
private Set/**/ aliases;
public ConstantDefinition(String name,
String value,
+ boolean isEnum,
String enumName) {
this.origName = name;
this.name = name;
this.value = value;
+ this.isEnum = isEnum;
this.enumName = enumName;
this.aliasedNames=new HashSet();
}
@@ -104,6 +107,8 @@ public class ConstantDefinition {
enumeration, or if the enum was anonymous. */
public String getEnumName() { return enumName; }
+ public boolean isEnum() { return isEnum; }
+
public Set/**/ getAliases() {
return aliases;
}
diff --git a/src/java/com/sun/gluegen/GlueGen.java b/src/java/com/sun/gluegen/GlueGen.java
index 9221c3a..3804795 100644
--- a/src/java/com/sun/gluegen/GlueGen.java
+++ b/src/java/com/sun/gluegen/GlueGen.java
@@ -227,12 +227,12 @@ public class GlueGen implements GlueEmitterControls {
for (int i = 0; i < enumeration.getNumEnumerates(); ++i) {
String enumElementName = enumeration.getEnumName(i);
String value = String.valueOf(enumeration.getEnumValue(i));
- constants.add(new ConstantDefinition(enumElementName, value, enumName));
+ constants.add(new ConstantDefinition(enumElementName, value, true, enumName));
}
}
for (Iterator iter = lexer.getDefines().iterator(); iter.hasNext(); ) {
Define def = (Define) iter.next();
- constants.add(new ConstantDefinition(def.getName(), def.getValue(), null));
+ constants.add(new ConstantDefinition(def.getName(), def.getValue(), false, null));
}
functions = headerParser.getParsedFunctions();
diff --git a/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java b/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java
index 0ede95e..a31a987 100644
--- a/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java
+++ b/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java
@@ -100,7 +100,7 @@ public class BuildStaticGLInfo
protected static int defineIdentifierGroup = 1;
protected static Pattern definePattern =
- Pattern.compile("\\#define ([CEW]?GL[XU]?_[A-Za-z0-9_]+)\\s*([A-Za-z0-9_]+)\\s*");
+ Pattern.compile("\\#define (([CEW]?GL[XU]?|PFD)_[A-Za-z0-9_]+)\\s*([A-Za-z0-9_]+)\\s*");
// Maps function / #define names to the names of the extensions they're declared in
protected Map declarationToExtensionMap = new HashMap();
diff --git a/src/java/com/sun/gluegen/opengl/GLEmitter.java b/src/java/com/sun/gluegen/opengl/GLEmitter.java
index 9e32026..935706b 100644
--- a/src/java/com/sun/gluegen/opengl/GLEmitter.java
+++ b/src/java/com/sun/gluegen/opengl/GLEmitter.java
@@ -320,7 +320,15 @@ public class GLEmitter extends ProcAddressEmitter
StringBuffer newComment = new StringBuffer();
newComment.append("Part of ");
if(0==addExtensionsOfSymbols2Buffer(newComment, ", ", symbolRenamed, def.getAliasedNames())) {
- // Note: All GL enums must be contained within an extension marker !
+ if(def.isEnum()) {
+ String enumName = def.getEnumName();
+ if(null!=enumName) {
+ newComment.append(enumName);
+ } else {
+ newComment.append("ENUM");
+ }
+ } else {
+ // Note: All GL defines must be contained within an extension marker !
// #ifndef GL_EXT_lala
// #define GL_EXT_lala 1
// ...
@@ -331,6 +339,7 @@ public class GLEmitter extends ProcAddressEmitter
System.err.println("Dropping marker: "+sb.toString());
}
return;
+ }
}
newComment.append("
");
--
cgit v1.2.3
From 7dc9c5601d5689dcbc003ca51cfe826942ea3e6b Mon Sep 17 00:00:00 2001
From: Sven Gothel
Date: Wed, 5 Aug 2009 10:29:26 -0700
Subject: Fix: Remove PFD_ defines. Add GL Option: AllowNonGLExtensions
to allow non GL extensions to be passed. Allow ifndef/define pattern to have
any characters at the end
---
.../com/sun/gluegen/opengl/BuildStaticGLInfo.java | 4 ++--
.../com/sun/gluegen/opengl/GLConfiguration.java | 14 +++++++++++-
src/java/com/sun/gluegen/opengl/GLEmitter.java | 26 +++++++++++++---------
.../gluegen/opengl/GLJavaMethodBindingEmitter.java | 18 +++++++++------
4 files changed, 41 insertions(+), 21 deletions(-)
(limited to 'src/java/com/sun')
diff --git a/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java b/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java
index a31a987..a6c0cfc 100644
--- a/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java
+++ b/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java
@@ -96,11 +96,11 @@ public class BuildStaticGLInfo
Pattern.compile("^(GLAPI|GL_API|GL_APICALL|EGLAPI|extern)?(\\s*)((unsigned|const)\\s+)?(\\w+)(\\s*\\*)?(\\s+)(GLAPIENTRY|GL_APIENTRY|APIENTRY|EGLAPIENTRY|WINAPI)?(\\s*)([ew]?gl\\w+)\\s?(\\(.*)");
protected static Pattern associationPattern =
- Pattern.compile("\\#ifndef ([CEW]?GL[XU]?_[A-Za-z0-9_]+)\\s*");
+ Pattern.compile("\\#ifndef ([CEW]?GL[XU]?_[A-Za-z0-9_]+)(.*)");
protected static int defineIdentifierGroup = 1;
protected static Pattern definePattern =
- Pattern.compile("\\#define (([CEW]?GL[XU]?|PFD)_[A-Za-z0-9_]+)\\s*([A-Za-z0-9_]+)\\s*");
+ Pattern.compile("\\#define ([CEW]?GL[XU]?_[A-Za-z0-9_]+)\\s*([A-Za-z0-9_]+)(.*)");
// Maps function / #define names to the names of the extensions they're declared in
protected Map declarationToExtensionMap = new HashMap();
diff --git a/src/java/com/sun/gluegen/opengl/GLConfiguration.java b/src/java/com/sun/gluegen/opengl/GLConfiguration.java
index 4e8c0c3..9352bcb 100755
--- a/src/java/com/sun/gluegen/opengl/GLConfiguration.java
+++ b/src/java/com/sun/gluegen/opengl/GLConfiguration.java
@@ -59,7 +59,8 @@ public class GLConfiguration extends ProcAddressConfiguration {
// This directive is off by default but can help automatically
// indicate which extensions have been folded into the core OpenGL
// namespace, and if not, then why not
- private boolean autoUnifyExtensions;
+ private boolean autoUnifyExtensions=false;
+ private boolean allowNonGLExtensions=false;
public GLConfiguration(GLEmitter emitter) {
super();
@@ -82,6 +83,10 @@ public class GLConfiguration extends ProcAddressConfiguration {
String sym = readString("RenameExtensionIntoCore", tok, filename, lineNo);
extensionsRenamedIntoCore.add(sym);
}
+ else if (cmd.equalsIgnoreCase("AllowNonGLExtensions"))
+ {
+ allowNonGLExtensions = readBoolean("AllowNonGLExtensions", tok, filename, lineNo).booleanValue();
+ }
else if (cmd.equalsIgnoreCase("AutoUnifyExtensions"))
{
autoUnifyExtensions = readBoolean("AutoUnifyExtensions", tok, filename, lineNo).booleanValue();
@@ -249,6 +254,13 @@ public class GLConfiguration extends ProcAddressConfiguration {
return autoUnifyExtensions;
}
+ /** If true, accept all non encapsulated defines and functions,
+ * as it is mandatory for GL declarations. */
+ public boolean getAllowNonGLExtensions() {
+ return allowNonGLExtensions;
+ }
+
+
/** shall the non unified (uniq) vendor extensions be dropped ? */
public boolean getDropUniqVendorExtensions(String extName) {
return dropUniqVendorExtensions.contains(extName);
diff --git a/src/java/com/sun/gluegen/opengl/GLEmitter.java b/src/java/com/sun/gluegen/opengl/GLEmitter.java
index 935706b..ffe1ed6 100644
--- a/src/java/com/sun/gluegen/opengl/GLEmitter.java
+++ b/src/java/com/sun/gluegen/opengl/GLEmitter.java
@@ -325,20 +325,24 @@ public class GLEmitter extends ProcAddressEmitter
if(null!=enumName) {
newComment.append(enumName);
} else {
- newComment.append("ENUM");
+ newComment.append("CORE ENUM");
}
} else {
- // Note: All GL defines must be contained within an extension marker !
- // #ifndef GL_EXT_lala
- // #define GL_EXT_lala 1
- // ...
- // #endif
- if(JavaConfiguration.DEBUG_IGNORES) {
- StringBuffer sb = new StringBuffer();
- JavaEmitter.addStrings2Buffer(sb, ", ", symbolRenamed, def.getAliasedNames());
- System.err.println("Dropping marker: "+sb.toString());
+ if(getGLConfig().getAllowNonGLExtensions()) {
+ newComment.append("CORE DEF");
+ } else {
+ // Note: All GL defines must be contained within an extension marker !
+ // #ifndef GL_EXT_lala
+ // #define GL_EXT_lala 1
+ // ...
+ // #endif
+ if(JavaConfiguration.DEBUG_IGNORES) {
+ StringBuffer sb = new StringBuffer();
+ JavaEmitter.addStrings2Buffer(sb, ", ", symbolRenamed, def.getAliasedNames());
+ System.err.println("Dropping marker: "+sb.toString());
+ }
+ return;
}
- return;
}
}
newComment.append("");
diff --git a/src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java b/src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java
index 5e8bada..8f5258e 100755
--- a/src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java
+++ b/src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java
@@ -114,13 +114,17 @@ public class GLJavaMethodBindingEmitter extends ProcAddressJavaMethodBindingEmit
StringBuffer newComment = new StringBuffer();
newComment.append("Part of ");
if(0==glEmitter.addExtensionsOfSymbols2Buffer(newComment, ", ", symbolRenamed, binding.getAliasedNames())) {
- StringBuffer sb = new StringBuffer();
- JavaEmitter.addStrings2Buffer(sb, ", ", symbolRenamed, binding.getAliasedNames());
- RuntimeException ex = new RuntimeException("Couldn't find extension to: "+binding+" ; "+sb.toString());
- ex.printStackTrace();
- glEmitter.getGLConfig().getGLInfo().dump();
- // glEmitter.getGLConfig().dumpRenames();
- throw ex;
+ if(glEmitter.getGLConfig().getAllowNonGLExtensions()) {
+ newComment.append("CORE FUNC");
+ } else {
+ StringBuffer sb = new StringBuffer();
+ JavaEmitter.addStrings2Buffer(sb, ", ", symbolRenamed, binding.getAliasedNames());
+ RuntimeException ex = new RuntimeException("Couldn't find extension to: "+binding+" ; "+sb.toString());
+ ex.printStackTrace();
+ glEmitter.getGLConfig().getGLInfo().dump();
+ // glEmitter.getGLConfig().dumpRenames();
+ throw ex;
+ }
}
newComment.append("
");
writer.print(newComment.toString());
--
cgit v1.2.3
From 5f8e46324f245c99080d2c340cd4fb2ec9c4fa8d Mon Sep 17 00:00:00 2001
From: Sven Gothel
Date: Wed, 5 Aug 2009 14:32:38 -0700
Subject: Add
in comment
---
src/java/com/sun/gluegen/opengl/GLEmitter.java | 2 +-
src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
(limited to 'src/java/com/sun')
diff --git a/src/java/com/sun/gluegen/opengl/GLEmitter.java b/src/java/com/sun/gluegen/opengl/GLEmitter.java
index ffe1ed6..4ca2e69 100644
--- a/src/java/com/sun/gluegen/opengl/GLEmitter.java
+++ b/src/java/com/sun/gluegen/opengl/GLEmitter.java
@@ -348,7 +348,7 @@ public class GLEmitter extends ProcAddressEmitter
newComment.append("");
if(null!=optionalComment) {
- newComment.append(" ");
+ newComment.append("
");
newComment.append(optionalComment);
}
diff --git a/src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java b/src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java
index 8f5258e..662e75b 100755
--- a/src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java
+++ b/src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java
@@ -112,7 +112,7 @@ public class GLJavaMethodBindingEmitter extends ProcAddressJavaMethodBindingEmit
String symbolRenamed = binding.getName();
StringBuffer newComment = new StringBuffer();
- newComment.append("Part of ");
+ newComment.append("
Part of ");
if(0==glEmitter.addExtensionsOfSymbols2Buffer(newComment, ", ", symbolRenamed, binding.getAliasedNames())) {
if(glEmitter.getGLConfig().getAllowNonGLExtensions()) {
newComment.append("CORE FUNC");
--
cgit v1.2.3