summaryrefslogtreecommitdiffstats
path: root/src/java/com/sun/gluegen
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2008-07-21 00:12:58 +0000
committerSven Gothel <[email protected]>2008-07-21 00:12:58 +0000
commit94c2dac899efa43ed421b95c6a24805bbd3eaacd (patch)
tree17358e1500a3200ee87335c14f8ac01c8f9f7893 /src/java/com/sun/gluegen
parentf321f151a652b9722af489a82793ac2802769638 (diff)
- Renamed config: IgnoreExtendedInterfaceSymbols -> ExtendedInterfaceSymbols,
so it makes sense with 'ExtendedInterfaceSymbolsOnly' - New config: ExtendedInterfaceSymbolsOnly All symbols not in those Java base classes/interfaces are ignored! - Rewrote/cleanup of the unified names, etc. - Common UnifiedName logic, with specialisation GLUnifiedName - UnifiedName behaves as a Set - UnifiedName function mapping present at all times, and the FunctionSymbol names are mapped to one entity. - DropUniqExtensionNames is now considered within the general shouldIgnore* - GLExtensionNames added: 3DFX git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/gluegen/branches/JOGL_2_SANDBOX@104 a78bb65f-1512-4460-ba86-f6dc96a7bf27
Diffstat (limited to 'src/java/com/sun/gluegen')
-rw-r--r--src/java/com/sun/gluegen/JavaConfiguration.java94
-rw-r--r--src/java/com/sun/gluegen/JavaEmitter.java20
-rw-r--r--src/java/com/sun/gluegen/JavaMethodBindingEmitter.java11
-rw-r--r--src/java/com/sun/gluegen/UnifiedName.java216
-rwxr-xr-xsrc/java/com/sun/gluegen/opengl/GLConfiguration.java21
-rw-r--r--src/java/com/sun/gluegen/opengl/GLEmitter.java152
-rwxr-xr-xsrc/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java21
-rw-r--r--src/java/com/sun/gluegen/opengl/GLUnifiedName.java118
-rw-r--r--src/java/com/sun/gluegen/runtime/opengl/GLExtensionNames.java7
9 files changed, 459 insertions, 201 deletions
diff --git a/src/java/com/sun/gluegen/JavaConfiguration.java b/src/java/com/sun/gluegen/JavaConfiguration.java
index cfa2d8b..f0511b5 100644
--- a/src/java/com/sun/gluegen/JavaConfiguration.java
+++ b/src/java/com/sun/gluegen/JavaConfiguration.java
@@ -111,7 +111,8 @@ public class JavaConfiguration {
* converted to String args; value is List of Integer argument indices
*/
private Map/*<String,List<Integer>>*/ argumentsAreString = new HashMap();
- private Set/*<String>*/ ignoresIf = new HashSet();
+ private Set/*<String>*/ extendedIfSymbols = new HashSet();
+ private boolean extendedIfSymbolsOnly=false;
private Set/*<Pattern>*/ ignores = new HashSet();
private Map/*<String,Pattern>*/ ignoreMap = new HashMap();
private Set/*<Pattern>*/ ignoreNots = new HashSet();
@@ -138,6 +139,9 @@ public class JavaConfiguration {
private Map/*<String,String>*/ javaMethodRenames = new HashMap();
private Map/*<String,List<String>>*/ javaPrologues = new HashMap();
private Map/*<String,List<String>>*/ javaEpilogues = new HashMap();
+ protected static Map/*<FuncName>,<UnifiedName>*/ uniqNameMap = new HashMap();
+ public static Map/*<UnifiedName>*/ getUniqNameMap() { return uniqNameMap; }
+
/** Reads the configuration file.
@param filename path to file that should be read
@@ -568,24 +572,42 @@ public class JavaConfiguration {
return (String) parentClass.get(className);
}
+ public boolean extendedIfSymbolsOnly() {
+ return extendedIfSymbolsOnly;
+ }
+
+ public static final boolean DEBUG_IGNORES = false;
+ public static boolean dumpedIgnores = false;
+
+ public void dumpIgnoresOnce() {
+ if(!dumpedIgnores) {
+ dumpedIgnores = true;
+ dumpIgnores();
+ }
+ }
+
public void dumpIgnores() {
- System.err.println("Ignores (If): ");
- for (Iterator iter = ignoresIf.iterator(); iter.hasNext(); ) {
+ System.err.println("Extended If: ");
+ for (Iterator iter = extendedIfSymbols.iterator(); iter.hasNext(); ) {
System.err.println("\t"+(String)iter.next());
}
System.err.println("Ignores (All): ");
for (Iterator iter = ignores.iterator(); iter.hasNext(); ) {
- System.err.println("\t"+(String)iter.next());
+ System.err.println("\t"+iter.next());
}
}
/** 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 (ignoresIf.contains(symbol)) {
- // System.err.println("Ignore If: "+symbol);
- // dumpIgnores();
+ if (extendedIfSymbols.contains(symbol)) {
+ if(DEBUG_IGNORES) {
+ System.err.println("Ignore If: "+symbol);
+ }
return true;
}
return shouldIgnoreInImpl_Int(symbol);
@@ -597,12 +619,31 @@ public class JavaConfiguration {
private boolean shouldIgnoreInImpl_Int(String symbol) {
- // System.err.println("CHECKING IGNORE: " + symbol);
+ if(DEBUG_IGNORES) {
+ dumpIgnoresOnce();
+ }
+ if (extendedIfSymbolsOnly) {
+ String uniSymbol;
+ UnifiedName uniName = (UnifiedName) getUniqNameMap().get(symbol);
+ if(null!=uniName) {
+ uniSymbol=uniName.getUni();
+ } else {
+ uniSymbol=symbol;
+ }
+ if(!extendedIfSymbols.contains(uniSymbol)) {
+ if(DEBUG_IGNORES) {
+ System.err.println("Ignore Impl !extended: "+uniSymbol+": "+uniName);
+ }
+ return true;
+ }
+ }
+
// Simple case; the entire symbol is in the ignore table.
if (ignores.contains(symbol)) {
- // System.err.println("Ignore Impl Simple: "+symbol);
- // dumpIgnores();
+ if(DEBUG_IGNORES) {
+ System.err.println("Ignore Impl ignores: "+symbol);
+ }
return true;
}
@@ -612,7 +653,9 @@ public class JavaConfiguration {
Pattern regexp = (Pattern)iter.next();
Matcher matcher = regexp.matcher(symbol);
if (matcher.matches()) {
- // System.err.println("Ignore Impl RexEx: "+symbol);
+ if(DEBUG_IGNORES) {
+ System.err.println("Ignore Impl RexEx: "+symbol);
+ }
return true;
}
}
@@ -628,7 +671,9 @@ public class JavaConfiguration {
// Special case as this is most often likely to be the case.
// Unignores are not used very often.
if(unignores.size() == 0) {
- // System.err.println("Ignore Impl unignores==0: "+symbol);
+ if(DEBUG_IGNORES) {
+ System.err.println("Ignore Impl unignores==0: "+symbol);
+ }
return true;
}
@@ -643,7 +688,9 @@ public class JavaConfiguration {
}
if (!unignoreFound)
- // System.err.println("Ignore Impl !unignore: "+symbol);
+ if(DEBUG_IGNORES) {
+ System.err.println("Ignore Impl !unignore: "+symbol);
+ }
return true;
}
}
@@ -798,8 +845,11 @@ public class JavaConfiguration {
// because ReturnedArrayLength changes them.
} else if (cmd.equalsIgnoreCase("ArgumentIsString")) {
readArgumentIsString(tok, filename, lineNo);
- } else if (cmd.equalsIgnoreCase("IgnoreExtendedInterfaceSymbols")) {
- readIgnoreExtendedInterfaceSymbols(tok, filename, lineNo);
+ } else if (cmd.equalsIgnoreCase("ExtendedInterfaceSymbols")) {
+ readExtendedInterfaceSymbols(tok, filename, lineNo);
+ } else if (cmd.equalsIgnoreCase("ExtendedInterfaceSymbolsOnly")) {
+ extendedIfSymbolsOnly=true;
+ readExtendedInterfaceSymbols(tok, filename, lineNo);
} else if (cmd.equalsIgnoreCase("Ignore")) {
readIgnore(tok, filename, lineNo);
} else if (cmd.equalsIgnoreCase("Unignore")) {
@@ -1000,7 +1050,7 @@ public class JavaConfiguration {
}
}
- protected void readIgnoreExtendedInterfaceSymbols(StringTokenizer tok, String filename, int lineNo) {
+ protected void readExtendedInterfaceSymbols(StringTokenizer tok, String filename, int lineNo) {
File javaFile;
BufferedReader javaReader;
try {
@@ -1024,15 +1074,8 @@ public class JavaConfiguration {
return;
}
- Set set = parser.getParsedEnumNames();
- for(Iterator iter = set.iterator(); iter.hasNext(); ) {
- ignoresIf.add((String) iter.next());
- }
- System.out.println("Functions");
- set = parser.getParsedFunctionNames();
- for(Iterator iter = set.iterator(); iter.hasNext(); ) {
- ignoresIf.add((String) iter.next());
- }
+ extendedIfSymbols.addAll(parser.getParsedEnumNames());
+ extendedIfSymbols.addAll(parser.getParsedFunctionNames());
}
protected void readIgnore(StringTokenizer tok, String filename, int lineNo) {
@@ -1054,7 +1097,6 @@ public class JavaConfiguration {
Pattern pattern = (Pattern) ignoreMap.get(regex);
ignoreMap.remove(regex);
ignores.remove(pattern);
- ignoresIf.remove(pattern.toString());
// If the pattern wasn't registered before, then make sure we have a
// valid pattern instance to put into the unignores set.
diff --git a/src/java/com/sun/gluegen/JavaEmitter.java b/src/java/com/sun/gluegen/JavaEmitter.java
index ddcb636..b1c0ca3 100644
--- a/src/java/com/sun/gluegen/JavaEmitter.java
+++ b/src/java/com/sun/gluegen/JavaEmitter.java
@@ -622,7 +622,16 @@ public class JavaEmitter implements GlueEmitter {
}
protected void validateFunctionsToBind(Set/*FunctionSymbol*/ funcsSet) {
- // nothing to do ..
+ for (Iterator iter = funcsSet.iterator(); iter.hasNext(); ) {
+ FunctionSymbol fsOrig = (FunctionSymbol) iter.next();
+ String name = fsOrig.getName();
+ UnifiedName uniName = UnifiedName.getOrPut(cfg.getUniqNameMap(), name);
+ String renamedName = cfg.getJavaMethodRename(fsOrig.getName());
+ if(null!=renamedName) {
+ uniName.setUni(renamedName);
+ uniName.remapAllNames(cfg.getUniqNameMap());
+ }
+ }
}
/**
@@ -760,9 +769,18 @@ public class JavaEmitter implements GlueEmitter {
return;
}
+ if(name.startsWith("GLXHyperpipeConfig")) {
+ System.err.println("XXXX 1 GLXHyperpipeConfig");
+ }
if (cfg.shouldIgnoreInInterface(name)) {
+ if(name.startsWith("GLXHyperpipeConfig")) {
+ System.err.println("XXXX 2 GLXHyperpipeConfig .. dropped");
+ }
return;
}
+ if(name.startsWith("GLXHyperpipeConfig")) {
+ System.err.println("XXXX 3 GLXHyperpipeConfig .. taken");
+ }
Type containingCType = canonicalize(new PointerType(SizeThunk.POINTER, structType, 0));
JavaType containingType = typeToJavaType(containingCType, false, null);
diff --git a/src/java/com/sun/gluegen/JavaMethodBindingEmitter.java b/src/java/com/sun/gluegen/JavaMethodBindingEmitter.java
index 73b12d8..0b33110 100644
--- a/src/java/com/sun/gluegen/JavaMethodBindingEmitter.java
+++ b/src/java/com/sun/gluegen/JavaMethodBindingEmitter.java
@@ -781,9 +781,18 @@ public class JavaMethodBindingEmitter extends FunctionEmitter
emitEnding(emitter, writer);
}
protected void emitBeginning(FunctionEmitter emitter, PrintWriter writer) {
- writer.print("Entry point to C language function: <br> ");
+ writer.print("Entry point to C language function: ");
}
protected void emitBindingCSignature(MethodBinding binding, PrintWriter writer) {
+ UnifiedName uniName = (UnifiedName) JavaConfiguration.getUniqNameMap().get(binding.getCSymbol().getName());
+ if(null!=uniName) {
+ writer.print("- Alias for: <br> <code> ");
+ writer.print(binding.getCSymbol().getType().toString(uniName.getOrigStringList(", "), tagNativeBinding));
+ writer.print(" </code> ");
+ return ; // done
+ }
+ writer.print(": <br> ");
+
writer.print("<code> ");
writer.print(binding.getCSymbol().toString(tagNativeBinding));
writer.print(" </code> ");
diff --git a/src/java/com/sun/gluegen/UnifiedName.java b/src/java/com/sun/gluegen/UnifiedName.java
new file mode 100644
index 0000000..ec1cdb3
--- /dev/null
+++ b/src/java/com/sun/gluegen/UnifiedName.java
@@ -0,0 +1,216 @@
+/*
+ * Copyright (c) 2003-2005 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution 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 Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed or intended for use
+ * in the design, construction, operation or maintenance of any nuclear
+ * facility.
+ *
+ */
+
+package com.sun.gluegen;
+
+import java.util.*;
+
+public class UnifiedName implements Cloneable {
+
+ public UnifiedName(String name) {
+ nameUni=name;
+ nameList=new ArrayList();
+ nameSet=new HashSet();
+ add(name);
+ }
+
+ protected UnifiedName(UnifiedName un) {
+ nameUni=un.nameUni;
+ nameList=new ArrayList(un.nameList);
+ nameSet=new HashSet(un.nameSet);
+ }
+
+ public void reset() {
+ resetUni();
+ resetOriginal();
+ }
+
+ public void resetUni() {
+ nameSet.remove(nameUni);
+ nameUni=(String)nameList.get(0);
+ }
+
+ public void resetOriginal() {
+ nameList.clear();
+ nameSet.clear();
+ add(nameUni);
+ }
+
+ public void setUni(String name) {
+ if(!nameUni.equals(name)) {
+ nameUni=name;
+ add(name);
+ }
+ }
+
+ /**
+ * unique in case this name reflects only one
+ * original entry (no extension unification)
+ */
+ public boolean isUnique() {
+ return nameSet.size()==1;
+ }
+
+ public void add(String name) {
+ if (nameSet.add(name)) {
+ nameList.add(name);
+ }
+ }
+ public void addAll(Collection col) {
+ for (Iterator iter = col.iterator(); iter.hasNext(); ) {
+ Object obj = iter.next();
+ if( obj instanceof String ) {
+ add((String)obj);
+ } else {
+ throw new ClassCastException("not a String: "+obj);
+ }
+ }
+
+ }
+
+ public boolean contains(UnifiedName un) {
+ boolean res = contains(un.nameUni);
+ for (Iterator iter = un.nameList.iterator(); !res && iter.hasNext(); ) {
+ res = contains((String)iter.next());
+ }
+ return res;
+ }
+
+ public boolean contains(String name) {
+ return nameSet.contains(name);
+ }
+
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if(obj instanceof UnifiedName) {
+ UnifiedName un = (UnifiedName)obj;
+ return nameUni.equals(un.nameUni) && nameSet.equals(un.nameSet);
+ }
+ return false;
+ }
+
+ public Object clone() {
+ return new UnifiedName(this);
+ }
+
+ public int hashCode() {
+ return nameSet.hashCode();
+ }
+
+ public String getUni() { return nameUni; }
+ public List getNameList() { return nameList; }
+ public Set getNameSet() { return nameSet; }
+
+ public int size() { return nameList.size(); }
+ public String get(int i) { return (String)nameList.get(i); }
+
+ public void remapAllNames(Map map) {
+ List allNames = new ArrayList();
+ // 1st pass: collect all other x-mappings to this one
+ for (Iterator iter = nameList.iterator(); iter.hasNext(); ) {
+ UnifiedName un = (UnifiedName) map.get((String)iter.next());
+ if(null!=un && this!=un) {
+ allNames.addAll(un.getNameList());
+ }
+ }
+ addAll(allNames);
+
+ // 2nd pass: map all containing names
+ for (Iterator iter = nameList.iterator(); iter.hasNext(); ) {
+ map.put((String)iter.next(), this);
+ }
+ }
+
+ public static UnifiedName getOrPut(Map map, String name) {
+ UnifiedName un = (UnifiedName)map.get(name);
+ if(null==un) {
+ un = new UnifiedName(name);
+ un.remapAllNames(map);
+ }
+ return un;
+ }
+
+ public String getCommentString() {
+ return getCommentString(true, " ");
+ }
+ public String getCommentString(boolean encloseCommentStartEnd, String seperator) {
+ if(nameList.size()==1 && ((String)nameList.get(0)).equals(nameUni)) {
+ return new String();
+ }
+ String res = new String();
+ if(encloseCommentStartEnd) {
+ res = res.concat(" /** ");
+ }
+ res = res.concat("Alias for: <code>");
+ res = res.concat(getOrigStringList(seperator));
+ res = res.concat("</code> ");
+ if(encloseCommentStartEnd) {
+ res = res.concat("*/");
+ }
+ return res;
+ }
+ public String getOrigStringList(String seperator) {
+ String res = new String();
+ for (Iterator iter = nameList.iterator(); iter.hasNext(); ) {
+ res = res.concat((String)iter.next());
+ if(iter.hasNext()) {
+ res = res.concat(seperator);
+ }
+ }
+ return res;
+ }
+
+ public String toString() {
+ if(nameList.size()==1 && ((String)nameList.get(0)).equals(nameUni)) {
+ return nameUni;
+ }
+ String res = nameUni + " /* " ;
+ for (Iterator iter = nameList.iterator(); iter.hasNext(); ) {
+ res = res.concat((String)iter.next()+", ");
+ }
+ res = res.concat(" */");
+ return res;
+ }
+
+ protected String nameUni;
+ protected List nameList;
+ protected HashSet nameSet;
+
+}
+
diff --git a/src/java/com/sun/gluegen/opengl/GLConfiguration.java b/src/java/com/sun/gluegen/opengl/GLConfiguration.java
index 1d2e08a..7be02f5 100755
--- a/src/java/com/sun/gluegen/opengl/GLConfiguration.java
+++ b/src/java/com/sun/gluegen/opengl/GLConfiguration.java
@@ -44,6 +44,7 @@ import java.util.*;
import com.sun.gluegen.*;
import com.sun.gluegen.procaddress.*;
+import com.sun.gluegen.runtime.opengl.GLExtensionNames;
public class GLConfiguration extends ProcAddressConfiguration {
// The following data members support ignoring an entire extension at a time
@@ -180,10 +181,11 @@ public class GLConfiguration extends ProcAddressConfiguration {
}
public void dumpIgnores() {
- System.err.println("GL Ignores: ");
+ System.err.println("GL Ignored extensions: ");
for (Iterator iter = ignoredExtensions.iterator(); iter.hasNext(); ) {
System.err.println("\t"+(String)iter.next());
}
+ super.dumpIgnores();
}
protected boolean shouldIgnoreExtension(String symbol, boolean criteria) {
@@ -191,12 +193,21 @@ public class GLConfiguration extends ProcAddressConfiguration {
String extension = glInfo.getExtension(symbol);
if (extension != null &&
ignoredExtensions.contains(extension)) {
- // System.err.println("GL Ignore: "+symbol+" within extension "+extension);
- // Throwable t = new Throwable("XXX");
- // t.printStackTrace();
- // dumpIgnores();
return true;
}
+ boolean isGLFunc = GLExtensionNames.isGLFunction(symbol);
+ boolean isGLEnum = GLExtensionNames.isGLEnumeration(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);
+ }
+ return true;
+ }
+ }
+ }
}
return false;
}
diff --git a/src/java/com/sun/gluegen/opengl/GLEmitter.java b/src/java/com/sun/gluegen/opengl/GLEmitter.java
index b0b12c5..5fbb269 100644
--- a/src/java/com/sun/gluegen/opengl/GLEmitter.java
+++ b/src/java/com/sun/gluegen/opengl/GLEmitter.java
@@ -100,7 +100,7 @@ public class GLEmitter extends ProcAddressEmitter
}
if(null==obj || !(obj instanceof DefineEntry)) return false;
DefineEntry de = (DefineEntry) obj;
- return name.equals(de.name) &&
+ return name.getUni().equals(de.name.getUni()) &&
type.equals(de.type) &&
value.equals(de.value);
}
@@ -130,8 +130,8 @@ public class GLEmitter extends ProcAddressEmitter
return new String();
}
- public void addOrigName(String name) {
- this.name.addOrig(name);
+ public void add(String name) {
+ this.name.add(name);
}
public boolean isExtensionVEN() {
return name.isExtensionVEN();
@@ -152,17 +152,42 @@ public class GLEmitter extends ProcAddressEmitter
protected static boolean shouldIgnoreInInterface(GLUnifiedName name, GLConfiguration cfg) {
boolean res = cfg.shouldIgnoreInInterface(name.getUni(), name.isUnique());
- for (Iterator iter = name.getOrig().iterator(); !res && iter.hasNext(); ) {
- res = cfg.shouldIgnoreInInterface((String)iter.next(), false);
- }
+ if(JavaConfiguration.DEBUG_IGNORES) {
+ if(res) {
+ System.err.println("Ignore If Uni: "+name);
+ }
+ } /*
+ for (Iterator iter = name.getNameList().iterator(); !res && iter.hasNext(); ) {
+ String s = (String)iter.next();
+ res = cfg.shouldIgnoreInInterface(s, false);
+ if(JavaConfiguration.DEBUG_IGNORES) {
+ if(res) {
+ System.err.println("Ignore If Ext: "+name+", "+s);
+ }
+ }
+ } */
return res;
}
protected static boolean shouldIgnoreInImpl(GLUnifiedName name, GLConfiguration cfg) {
boolean res = cfg.shouldIgnoreInImpl(name.getUni(), name.isUnique());
- for (Iterator iter = name.getOrig().iterator(); !res && iter.hasNext(); ) {
- res = cfg.shouldIgnoreInImpl((String)iter.next(), false);
+ if(JavaConfiguration.DEBUG_IGNORES) {
+ if(res) {
+ System.err.println("Ignore Impl Uni: "+name);
+ }
}
+ /*
+ if(!cfg.extendedIfSymbolsOnly()) {
+ for (Iterator iter = name.getNameList().iterator(); !res && iter.hasNext(); ) {
+ String s = (String)iter.next();
+ res = cfg.shouldIgnoreInImpl(s, false);
+ if(JavaConfiguration.DEBUG_IGNORES) {
+ if(res) {
+ System.err.println("Ignore Impl Ext: "+name+", "+s);
+ }
+ }
+ }
+ } */
return res;
}
@@ -178,14 +203,16 @@ public class GLEmitter extends ProcAddressEmitter
*/
public void emitDefine(String name, String value, String optionalComment) throws Exception {
if (cfg.allStatic() || cfg.emitInterface()) {
+ // unify ARB and map names
DefineEntry deNew = new DefineEntry(name, value, optionalComment);
DefineEntry deExist = (DefineEntry) defineMap.get(deNew.name.getUni());
if(deExist!=null) {
+ // non ARB counterpart exist ..
if(deNew.equals(deExist)) {
if(deNew.getOptCommentString().length()>deExist.getOptCommentString().length()) {
deExist.optionalComment=deNew.optionalComment;
}
- deExist.addOrigName(name);
+ deExist.add(name);
return; // done ..
}
deNew.name.resetUni();
@@ -207,6 +234,7 @@ public class GLEmitter extends ProcAddressEmitter
if (cfg.allStatic() || cfg.emitInterface()) {
Iterator/*<DefineEntry>*/ deIter = null;
+ // unify VEN
deIter = defineMap.values().iterator();
while( deIter.hasNext() ) {
DefineEntry de = (DefineEntry) deIter.next();
@@ -221,7 +249,7 @@ public class GLEmitter extends ProcAddressEmitter
deExist.optionalComment=deUni.optionalComment;
}
deIter.remove();
- deExist.addOrigName(de.name.getUni());
+ deExist.add(de.name.getUni());
} else {
if( ((GLConfiguration)cfg).getDropUniqVendorExtensions(extSuffix) ) {
deIter.remove(); // remove non unified (uniq) vendor extension
@@ -239,6 +267,7 @@ public class GLEmitter extends ProcAddressEmitter
}
}
+ // add mapping and emit ..
deIter = defineMap.values().iterator();
while( deIter.hasNext() ) {
DefineEntry de = (DefineEntry) deIter.next();
@@ -339,28 +368,31 @@ public class GLEmitter extends ProcAddressEmitter
// Internals only below this point
//
- // map the uniName to the GLUnifiedName type
- protected HashMap/*<String uniNameStr, GLUnifiedName uniName>*/ funcNameMap = new HashMap();
- protected Map/*<String uniNameStr, GLUnifiedName uniName>*/ getFuncNameMap() {
- return funcNameMap;
- }
-
protected void validateFunctionsToBind(Set/*FunctionSymbol*/ funcsSet) {
+
String localCallingConvention = ((GLConfiguration)cfg).getLocalProcAddressCallingConvention4All();
if(null==localCallingConvention) {
localCallingConvention="GL_APIENTRY";
}
ArrayList newUniFuncs = new ArrayList();
- HashSet origFuncNames = new HashSet();
+
+ // 1st Pass: map function names and process ARB extensions
for (Iterator iter = funcsSet.iterator(); iter.hasNext(); ) {
FunctionSymbol fsOrig = (FunctionSymbol) iter.next();
- origFuncNames.add(fsOrig.getName());
- GLUnifiedName uniName = new GLUnifiedName(fsOrig.getName());
- if (GLEmitter.shouldIgnoreInImpl(uniName, (GLConfiguration)cfg)) {
- iter.remove(); // remove ignored function
- } else {
- if( uniName.isExtensionARB() &&
- !((GLConfiguration)cfg).skipProcAddressGen(fsOrig.getName()) ) {
+ String fname = fsOrig.getName();
+ GLUnifiedName uniName;
+ {
+ uniName = (GLUnifiedName) GLUnifiedName.getOrPut(cfg.getUniqNameMap(), fname);
+ String renamedName = cfg.getJavaMethodRename(fname);
+ if(null!=renamedName) {
+ fname = renamedName;
+ uniName.setUni(fname);
+ uniName.remapAllNames(cfg.getUniqNameMap());
+ }
+ }
+
+ if(GLExtensionNames.isExtensionARB(fname, true)) {
+ if(!((GLConfiguration)cfg).skipProcAddressGen(fname)) {
FunctionSymbol fsUni = new FunctionSymbol(uniName.getUni(), fsOrig.getType());
if(!funcsSet.contains(fsUni)) {
newUniFuncs.add(fsUni); // add new uni name
@@ -368,14 +400,11 @@ public class GLEmitter extends ProcAddressEmitter
"\n\tARB: "+fsOrig+
"\n\tUNI: "+fsUni);
} else {
- uniName.addOrig(uniName.getUni()); // the original name w/o extension
System.err.println("INFO: Dub ARB Normalized Function:"+
"\n\tARB: "+fsOrig+
"\n\tDUB: "+fsUni);
}
- if(!funcNameMap.containsKey(uniName.getUni())) {
- funcNameMap.put(uniName.getUni(), uniName);
- }
+
iter.remove(); // remove ARB function
// make the function being dynamical fetched, due to it's dynamic naming scheme
((GLConfiguration)cfg).addForceProcAddressGen(uniName.getUni());
@@ -384,44 +413,55 @@ public class GLEmitter extends ProcAddressEmitter
((GLConfiguration)cfg).addLocalProcAddressCallingConvention(uniName.getUni(), localCallingConvention);
}
}
+ if(JavaConfiguration.DEBUG_IGNORES) {
+ System.err.println("1st Pass: "+uniName);
+ }
}
funcsSet.addAll(newUniFuncs);
+ // 2nd Pass: Unify VEN extensions
for (Iterator iter = funcsSet.iterator(); iter.hasNext(); ) {
FunctionSymbol fsOrig = (FunctionSymbol) iter.next();
- GLUnifiedName uniName = new GLUnifiedName(fsOrig.getName());
- if(uniName.isExtensionVEN()) {
+ String fname = fsOrig.getName();
+ GLUnifiedName uniName = (GLUnifiedName)cfg.getUniqNameMap().get(fname);
+ if(null==uniName) {
+ throw new RuntimeException("no mapping found for: "+fname);
+ }
+
+ if(GLExtensionNames.isExtensionVEN(fname, true)) {
uniName.normalizeVEN();
- if (GLEmitter.shouldIgnoreInImpl(uniName, (GLConfiguration)cfg)) {
- System.err.println("INFO: Ignored: Remove Function:"+ uniName);
- iter.remove(); // remove ignored function
- } else {
- String extSuffix = GLExtensionNames.getExtensionSuffix(fsOrig.getName(), true);
- FunctionSymbol fsUni = new FunctionSymbol(uniName.getUni(), fsOrig.getType());
- if(funcsSet.contains(fsUni)) {
- GLUnifiedName uniNameMap = (GLUnifiedName) funcNameMap.get(uniName.getUni());
- if(null==uniNameMap) {
- funcNameMap.put(uniName.getUni(), uniName);
- uniNameMap=uniName;
- } else {
- uniNameMap.addOrig(fsOrig.getName()); // add the VEN extension name
- }
- if(origFuncNames.contains(uniName.getUni())) {
- uniNameMap.addOrig(uniName.getUni()); // the original name w/o extension
- }
- iter.remove(); // remove VEN function (already incl. as ARB)
- System.err.println("INFO: Dub VEN Function:"+
- "\n\tVEN: "+fsOrig+
- "\n\tDUB: "+fsUni);
- } else if( ((GLConfiguration)cfg).getDropUniqVendorExtensions(extSuffix) ) {
- iter.remove(); // remove non unified (uniq) vendor extension
- System.err.println("INFO: Drop uniq VEN Function: "+fsOrig.getName());
- }
+ uniName.remapAllNames(cfg.getUniqNameMap());
+ String extSuffix = GLExtensionNames.getExtensionSuffix(fname, true);
+ FunctionSymbol fsUni = new FunctionSymbol(uniName.getUni(), fsOrig.getType());
+ if(funcsSet.contains(fsUni)) {
+ iter.remove(); // remove VEN function (already incl. as ARB)
+ System.err.println("INFO: Dub VEN Function:"+
+ "\n\tVEN: "+fsOrig+
+ "\n\tDUB: "+fsUni);
+ } else if( ((GLConfiguration)cfg).getDropUniqVendorExtensions(extSuffix) ) {
+ iter.remove(); // remove non unified (uniq) vendor extension
+ System.err.println("INFO: Drop uniq VEN Function: "+fsOrig.getName());
}
}
+ if(JavaConfiguration.DEBUG_IGNORES) {
+ System.err.println("2nd Pass: "+uniName);
+ }
}
- super.validateFunctionsToBind(funcsSet);
+ // 3rd Pass: Remove all ignored functions
+ for (Iterator iter = funcsSet.iterator(); iter.hasNext(); ) {
+ FunctionSymbol fsOrig = (FunctionSymbol) iter.next();
+ GLUnifiedName uniName = (GLUnifiedName)cfg.getUniqNameMap().get(fsOrig.getName());
+ if(null==uniName) {
+ throw new RuntimeException("no mapping found for: "+fsOrig.getName());
+ }
+ if (cfg.shouldIgnoreInImpl(fsOrig.getName())) {
+ if(JavaConfiguration.DEBUG_IGNORES) {
+ System.err.println("INFO: Ignored: Remove Function:"+ uniName);
+ }
+ iter.remove(); // remove ignored function
+ }
+ }
}
diff --git a/src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java b/src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java
index 581dff0..c6a0309 100755
--- a/src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java
+++ b/src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java
@@ -66,7 +66,6 @@ public class GLJavaMethodBindingEmitter extends ProcAddressJavaMethodBindingEmit
emitter);
this.bufferObjectVariant = bufferObjectVariant;
this.glEmitter=emitter;
- setCommentEmitter(new WrappedMethodCommentEmitter());
}
public GLJavaMethodBindingEmitter(ProcAddressJavaMethodBindingEmitter methodToWrap,
@@ -75,7 +74,6 @@ public class GLJavaMethodBindingEmitter extends ProcAddressJavaMethodBindingEmit
super(methodToWrap);
this.bufferObjectVariant = bufferObjectVariant;
this.glEmitter=emitter;
- setCommentEmitter(new WrappedMethodCommentEmitter());
}
public GLJavaMethodBindingEmitter(GLJavaMethodBindingEmitter methodToWrap) {
@@ -102,23 +100,4 @@ public class GLJavaMethodBindingEmitter extends ProcAddressJavaMethodBindingEmit
return name;
}
- /** This class emits the comment for the wrapper method */
- public class WrappedMethodCommentEmitter extends ProcAddressJavaMethodBindingEmitter.WrappedMethodCommentEmitter {
- protected void emitBindingCSignature(MethodBinding binding, PrintWriter writer) {
- if(null!=glEmitter) {
- GLUnifiedName uniName = (GLUnifiedName) glEmitter.getFuncNameMap().get(binding.getCSymbol().getName());
- if(null!=uniName) {
- writer.print("- Alias for: <br> <code> ");
- writer.print(binding.getCSymbol().getType().toString(uniName.getOrigStringList(", "), tagNativeBinding));
- writer.print(" </code> ");
- return ; // done
- }
- }
- writer.print(": <br> ");
- super.emitBindingCSignature(binding, writer);
- }
- protected void emitBeginning(FunctionEmitter methodEmitter, PrintWriter writer) {
- writer.print("Entry point (through function pointer) to C language function ");
- }
- }
}
diff --git a/src/java/com/sun/gluegen/opengl/GLUnifiedName.java b/src/java/com/sun/gluegen/opengl/GLUnifiedName.java
index cf99b66..64ca302 100644
--- a/src/java/com/sun/gluegen/opengl/GLUnifiedName.java
+++ b/src/java/com/sun/gluegen/opengl/GLUnifiedName.java
@@ -38,57 +38,31 @@
package com.sun.gluegen.opengl;
import java.util.*;
-import com.sun.gluegen.runtime.*;
+import com.sun.gluegen.UnifiedName;
import com.sun.gluegen.runtime.opengl.GLExtensionNames;
-public class GLUnifiedName implements Cloneable {
+public class GLUnifiedName extends UnifiedName implements Cloneable {
public GLUnifiedName(String name) {
+ super(name);
isGLFunc = GLExtensionNames.isGLFunction(name);
isGLEnum = GLExtensionNames.isGLEnumeration(name);
- if(!isGLFunc && !isGLEnum) {
- nameUni=name;
- } else {
- nameUni=GLExtensionNames.normalizeARB(name, isGLFunc);
+ if(isGLFunc || isGLEnum) {
+ setUni(GLExtensionNames.normalizeARB(name, isGLFunc));
}
- this.nameOrig=new ArrayList();
- this.nameOrig.add(name);
}
- protected GLUnifiedName(List origs, String uni, boolean isGLFunc, boolean isGLEnum) {
- this.nameOrig=new ArrayList();
- this.nameOrig.addAll(origs);
- this.nameUni=uni;
- this.isGLFunc=isGLFunc;
- this.isGLEnum=isGLEnum;
- }
-
- public void resetUni() {
- nameUni=(String)nameOrig.get(0);
- }
- public void resetOriginal() {
- nameOrig.clear();
- nameOrig.add(nameUni);
- }
-
- public void addOrig(String name) {
- if(!nameOrig.contains(name)) {
- nameOrig.add(name);
- }
- }
-
- /**
- * unique in case this name reflects only one
- * original entry (no extension unification)
- */
- public boolean isUnique() {
- return nameOrig.size()==1;
+ protected GLUnifiedName(GLUnifiedName un) {
+ super(un);
+ this.isGLFunc=un.isGLFunc;
+ this.isGLEnum=un.isGLEnum;
}
public boolean isExtensionARB() {
boolean res = false;
if(isGLFunc||isGLEnum) {
- for (Iterator iter = nameOrig.iterator(); !res && iter.hasNext(); ) {
+ res = GLExtensionNames.isExtensionARB(nameUni, isGLFunc);
+ for (Iterator iter = nameList.iterator(); !res && iter.hasNext(); ) {
res = GLExtensionNames.isExtensionARB((String)iter.next(), isGLFunc);
}
}
@@ -97,81 +71,45 @@ public class GLUnifiedName implements Cloneable {
public void normalizeVEN() {
if(isGLFunc||isGLEnum) {
- nameUni=GLExtensionNames.normalizeVEN(nameUni, isGLFunc);
+ setUni(GLExtensionNames.normalizeVEN(nameUni, isGLFunc));
}
}
public boolean isExtensionVEN() {
boolean res = false;
if(isGLFunc||isGLEnum) {
- for (Iterator iter = nameOrig.iterator(); !res && iter.hasNext(); ) {
+ res = GLExtensionNames.isExtensionVEN(nameUni, isGLFunc);
+ for (Iterator iter = nameList.iterator(); !res && iter.hasNext(); ) {
res = GLExtensionNames.isExtensionVEN((String)iter.next(), isGLFunc);
}
}
return res;
}
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
- if(null==obj || !(obj instanceof GLUnifiedName)) return false;
- GLUnifiedName uen = (GLUnifiedName) obj;
- return nameUni.equals(uen.nameUni);
- }
-
- public String getCommentString() {
- return getCommentString(true, " ");
- }
- public String getCommentString(boolean encloseCommentStartEnd, String seperator) {
- if(nameOrig.size()==1 && ((String)nameOrig.get(0)).equals(nameUni)) {
- return new String();
- }
- String res = new String();
- if(encloseCommentStartEnd) {
- res = res.concat(" /** ");
- }
- res = res.concat("Alias for: <code>");
- res = res.concat(getOrigStringList(seperator));
- res = res.concat("</code> ");
- if(encloseCommentStartEnd) {
- res = res.concat("*/");
- }
- return res;
- }
- public String getOrigStringList(String seperator) {
- String res = new String();
- for (Iterator iter = nameOrig.iterator(); iter.hasNext(); ) {
- res = res.concat((String)iter.next());
- if(iter.hasNext()) {
- res = res.concat(seperator);
+ public boolean isExtension() {
+ boolean res = false;
+ if(isGLFunc||isGLEnum) {
+ res = GLExtensionNames.isExtension(nameUni, isGLFunc);
+ for (Iterator iter = nameList.iterator(); !res && iter.hasNext(); ) {
+ res = GLExtensionNames.isExtension((String)iter.next(), isGLFunc);
}
}
return res;
}
- public String toString() {
- if(nameOrig.size()==1 && ((String)nameOrig.get(0)).equals(nameUni)) {
- return nameUni;
- }
- String res = nameUni + " /* " ;
- for (Iterator iter = nameOrig.iterator(); iter.hasNext(); ) {
- res = res.concat((String)iter.next()+", ");
+ public static UnifiedName getOrPut(Map map, String name) {
+ GLUnifiedName un = (GLUnifiedName)map.get(name);
+ if(null==un) {
+ un = new GLUnifiedName(name);
+ un.remapAllNames(map);
}
- res = res.concat(" */");
- return res;
+ return un;
}
public Object clone() {
- return new GLUnifiedName(nameOrig, nameUni, isGLFunc, isGLEnum);
+ return new GLUnifiedName(this);
}
- public String getUni() { return nameUni; }
- public List getOrig() { return nameOrig; }
- public String getOrig(int i) { return (String)nameOrig.get(i); }
-
- private List nameOrig;
- private String nameUni;
- private boolean isGLFunc, isGLEnum;
+ protected boolean isGLFunc, isGLEnum;
}
diff --git a/src/java/com/sun/gluegen/runtime/opengl/GLExtensionNames.java b/src/java/com/sun/gluegen/runtime/opengl/GLExtensionNames.java
index cc9233d..bd9ffaf 100644
--- a/src/java/com/sun/gluegen/runtime/opengl/GLExtensionNames.java
+++ b/src/java/com/sun/gluegen/runtime/opengl/GLExtensionNames.java
@@ -50,7 +50,8 @@ public class GLExtensionNames {
// Pass-3 Emit
public static final String[] extensionsARB = { "ARB", "GL2", "OES", "OML" };
- public static final String[] extensionsVEN = { "AMD",
+ public static final String[] extensionsVEN = { "3DFX",
+ "AMD",
"APPLE",
"ATI",
"EXT",
@@ -143,6 +144,10 @@ public class GLExtensionNames {
public static final boolean isExtensionVEN(String str, boolean isGLFunc) {
return isExtension(extensionsVEN, str, isGLFunc);
}
+ public static final boolean isExtension(String str, boolean isGLFunc) {
+ return isExtension(extensionsARB, str, isGLFunc) ||
+ isExtension(extensionsVEN, str, isGLFunc);
+ }
public static final int getFuncNamePermutationNumber(String name) {
if(isExtensionARB(name, true) || isExtensionVEN(name, true)) {