aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-04-24 18:13:36 +0200
committerMichael Bien <[email protected]>2010-04-24 18:13:36 +0200
commit0b98f807fc0c3cefacaa238f157b4a61874d6e2b (patch)
treecab65d51a7e48df857b217debef34b087e86a4ea /src
parent337bfec89c176975b99227c72c9d8690f9d34e0c (diff)
Refactored ProcAddressTable generation.
- ProcAddressTable is now the common superclass for all tables - Removed ProcAddressHelpers and added FunctionAddressResolver extension mechanism
Diffstat (limited to 'src')
-rw-r--r--src/java/com/jogamp/gluegen/runtime/opengl/GLProcAddressResolver.java61
-rw-r--r--src/java/com/sun/gluegen/opengl/GLEmitter.java10
2 files changed, 66 insertions, 5 deletions
diff --git a/src/java/com/jogamp/gluegen/runtime/opengl/GLProcAddressResolver.java b/src/java/com/jogamp/gluegen/runtime/opengl/GLProcAddressResolver.java
new file mode 100644
index 000000000..ebe4d2685
--- /dev/null
+++ b/src/java/com/jogamp/gluegen/runtime/opengl/GLProcAddressResolver.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2010, Michael Bien
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of JogAmp nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Michael Bien BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Created on Saturday, April 24 2010 16:44
+ */
+package com.jogamp.gluegen.runtime.opengl;
+
+import com.jogamp.common.os.DynamicLookupHelper;
+import com.jogamp.gluegen.runtime.FunctionAddressResolver;
+
+/**
+ * @author Sven Gothel
+ * @author Michael Bien
+ */
+public class GLProcAddressResolver implements FunctionAddressResolver {
+
+
+ public long resolve(String name, DynamicLookupHelper lookup) {
+
+ int permutations = GLExtensionNames.getFuncNamePermutationNumber(name);
+
+ for (int i = 0; i < permutations; i++) {
+ String funcName = GLExtensionNames.getFuncNamePermutation(name, i);
+ try {
+ return lookup.dynamicLookupFunction(funcName);
+ } catch (Exception e) {
+// if (DEBUG) {
+// dout.println(e);
+// e.printStackTrace();
+// }
+ }
+ }
+
+ throw new RuntimeException("unresolveable function name: "+name);
+ }
+}
diff --git a/src/java/com/sun/gluegen/opengl/GLEmitter.java b/src/java/com/sun/gluegen/opengl/GLEmitter.java
index 006287e02..b5df6ff2d 100644
--- a/src/java/com/sun/gluegen/opengl/GLEmitter.java
+++ b/src/java/com/sun/gluegen/opengl/GLEmitter.java
@@ -419,17 +419,17 @@ public class GLEmitter extends ProcAddressEmitter {
w.println(" * it was statically linked.");
w.println(" */");
w.println(" public long getAddressFor(String functionNameUsr) {");
- w.println(" String functionNameBase = com.jogamp.gluegen.runtime.opengl.GLExtensionNames.normalizeVEN(com.jogamp.gluegen.runtime.opengl.GLExtensionNames.normalizeARB(functionNameUsr, true), true);");
- w.println(" String addressFieldNameBase = " + getProcAddressConfig().gluegenRuntimePackage() + ".ProcAddressHelper.PROCADDRESS_VAR_PREFIX + functionNameBase;");
+ w.println(" String functionNameBase = "+GLExtensionNames.class.getName()+".normalizeVEN(com.jogamp.gluegen.runtime.opengl.GLExtensionNames.normalizeARB(functionNameUsr, true), true);");
+ w.println(" String addressFieldNameBase = PROCADDRESS_VAR_PREFIX + functionNameBase;");
w.println(" java.lang.reflect.Field addressField = null;");
- w.println(" int funcNamePermNum = com.jogamp.gluegen.runtime.opengl.GLExtensionNames.getFuncNamePermutationNumber(functionNameBase);");
+ w.println(" int funcNamePermNum = "+GLExtensionNames.class.getName()+".getFuncNamePermutationNumber(functionNameBase);");
w.println(" for(int i = 0; null==addressField && i < funcNamePermNum; i++) {");
- w.println(" String addressFieldName = com.jogamp.gluegen.runtime.opengl.GLExtensionNames.getFuncNamePermutation(addressFieldNameBase, i);");
+ w.println(" String addressFieldName = "+GLExtensionNames.class.getName()+".getFuncNamePermutation(addressFieldNameBase, i);");
w.println(" try {");
w.println(" addressField = getClass().getField(addressFieldName);");
w.println(" } catch (Exception e) { }");
w.println(" }");
- w.println("");
+ w.println();
w.println(" if(null==addressField) {");
w.println(" // The user is calling a bogus function or one which is not");
w.println(" // runtime linked");