aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/games
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/java/games')
-rw-r--r--src/net/java/games/gluegen/GlueEmitterControls.java4
-rw-r--r--src/net/java/games/gluegen/GlueGen.java7
-rw-r--r--src/net/java/games/gluegen/opengl/BuildStaticGLInfo.java1
-rw-r--r--src/net/java/games/gluegen/opengl/GLEmitter.java50
-rw-r--r--src/net/java/games/gluegen/pcpp/PCPP.java26
5 files changed, 73 insertions, 15 deletions
diff --git a/src/net/java/games/gluegen/GlueEmitterControls.java b/src/net/java/games/gluegen/GlueEmitterControls.java
index 15df83654..4f5d3a8d3 100644
--- a/src/net/java/games/gluegen/GlueEmitterControls.java
+++ b/src/net/java/games/gluegen/GlueEmitterControls.java
@@ -46,4 +46,8 @@ public interface GlueEmitterControls {
/** Requests emission of an accessor for a struct that will not be
referenced by any functions or other structs. */
public void forceStructEmission(String typedefName);
+
+ /** Finds the full path name of the specified header file based on
+ the include directories specified on the command line. */
+ public String findHeaderFile(String headerFileName);
}
diff --git a/src/net/java/games/gluegen/GlueGen.java b/src/net/java/games/gluegen/GlueGen.java
index 442f6405b..dd810572d 100644
--- a/src/net/java/games/gluegen/GlueGen.java
+++ b/src/net/java/games/gluegen/GlueGen.java
@@ -52,11 +52,16 @@ import net.java.games.gluegen.pcpp.*;
public class GlueGen implements GlueEmitterControls {
private java.util.List forcedStructNames = new ArrayList();
+ private PCPP preprocessor;
public void forceStructEmission(String typedefName) {
forcedStructNames.add(typedefName);
}
+ public String findHeaderFile(String headerFileName) {
+ return preprocessor.findFile(headerFileName);
+ }
+
public void run(String[] args) {
try {
Reader reader = null;
@@ -99,7 +104,7 @@ public class GlueGen implements GlueEmitterControls {
}
}
- final PCPP preprocessor = new PCPP(includePaths);
+ preprocessor = new PCPP(includePaths);
PipedInputStream ppIn = new PipedInputStream();
final PipedOutputStream ppOut = new PipedOutputStream(ppIn);
preprocessor.setOut(ppOut);
diff --git a/src/net/java/games/gluegen/opengl/BuildStaticGLInfo.java b/src/net/java/games/gluegen/opengl/BuildStaticGLInfo.java
index 46e268075..867197e03 100644
--- a/src/net/java/games/gluegen/opengl/BuildStaticGLInfo.java
+++ b/src/net/java/games/gluegen/opengl/BuildStaticGLInfo.java
@@ -197,6 +197,7 @@ public class BuildStaticGLInfo
//System.err.println("FOUND NEW ASSOCIATION BLOCK: " + activeAssociation);
}
}
+ reader.close();
}
public void dump() {
diff --git a/src/net/java/games/gluegen/opengl/GLEmitter.java b/src/net/java/games/gluegen/opengl/GLEmitter.java
index f36d7b1ac..b0c88e954 100644
--- a/src/net/java/games/gluegen/opengl/GLEmitter.java
+++ b/src/net/java/games/gluegen/opengl/GLEmitter.java
@@ -61,6 +61,12 @@ public class GLEmitter extends JavaEmitter
private String tableClassName;
private int numProcAddressEntries;
+ public void beginEmission(GlueEmitterControls controls) throws IOException
+ {
+ getGLConfig().parseGLHeaders(controls);
+ super.beginEmission(controls);
+ }
+
public void beginFunctions(TypeDictionary typedefDictionary,
TypeDictionary structDictionary,
Map canonMap) throws Exception
@@ -361,6 +367,10 @@ public class GLEmitter extends JavaEmitter
private String contextVariableName = "context";
private String defaultGetProcAddressTableExpr = ".getGLProcAddressTable()";
private String getProcAddressTableExpr;
+ // The following data members support ignoring an entire extension at a time
+ private List/*<String>*/ glHeaders = new ArrayList();
+ private Set/*<String>*/ ignoredExtensions = new HashSet();
+ private BuildStaticGLInfo glInfo;
protected void dispatch(String cmd, StringTokenizer tok, File file, String filename, int lineNo) throws IOException {
if (cmd.equalsIgnoreCase("EmitProcAddressTable"))
@@ -394,6 +404,16 @@ public class GLEmitter extends JavaEmitter
{
getProcAddressTableExpr = readGetProcAddressTableExpr(tok, filename, lineNo);
}
+ else if (cmd.equalsIgnoreCase("IgnoreExtension"))
+ {
+ String sym = readString("IgnoreExtension", tok, filename, lineNo);
+ ignoredExtensions.add(sym);
+ }
+ else if (cmd.equalsIgnoreCase("GLHeader"))
+ {
+ String sym = readString("GLHeader", tok, filename, lineNo);
+ glHeaders.add(sym);
+ }
else
{
super.dispatch(cmd,tok,file,filename,lineNo);
@@ -422,6 +442,34 @@ public class GLEmitter extends JavaEmitter
}
return getProcAddressTableExpr;
}
+
+ public boolean shouldIgnore(String symbol) {
+ // Check ignored extensions based on our knowledge of the static GL info
+ if (glInfo != null) {
+ String extension = glInfo.getExtension(symbol);
+ if (extension != null &&
+ ignoredExtensions.contains(extension)) {
+ return true;
+ }
+ }
+
+ return super.shouldIgnore(symbol);
+ }
+
+ /** Parses any GL headers specified in the configuration file for
+ the purpose of being able to ignore an extension at a time. */
+ public void parseGLHeaders(GlueEmitterControls controls) throws IOException {
+ if (!glHeaders.isEmpty()) {
+ glInfo = new BuildStaticGLInfo();
+ for (Iterator iter = glHeaders.iterator(); iter.hasNext(); ) {
+ String file = (String) iter.next();
+ String fullPath = controls.findHeaderFile(file);
+ if (fullPath == null) {
+ throw new IOException("Unable to locate header file \"" + file + "\"");
+ }
+ glInfo.parse(fullPath);
+ }
+ }
+ }
} // end class GLConfiguration
}
-
diff --git a/src/net/java/games/gluegen/pcpp/PCPP.java b/src/net/java/games/gluegen/pcpp/PCPP.java
index 0990bb155..51fa8f9bf 100644
--- a/src/net/java/games/gluegen/pcpp/PCPP.java
+++ b/src/net/java/games/gluegen/pcpp/PCPP.java
@@ -125,6 +125,19 @@ public class PCPP {
}
}
+ public String findFile(String filename) {
+ String sep = File.separator;
+ for (Iterator iter = includePaths.iterator(); iter.hasNext(); ) {
+ String inclPath = (String) iter.next();
+ String fullPath = inclPath + sep + filename;
+ File file = new File(fullPath);
+ if (file.exists()) {
+ return fullPath;
+ }
+ }
+ return null;
+ }
+
//----------------------------------------------------------------------
// Internals only below this point
//
@@ -748,19 +761,6 @@ public class PCPP {
}
}
- private String findFile(String filename) {
- String sep = System.getProperty("file.separator");
- for (Iterator iter = includePaths.iterator(); iter.hasNext(); ) {
- String inclPath = (String) iter.next();
- String fullPath = inclPath + sep + filename;
- File file = new File(fullPath);
- if (file.exists()) {
- return fullPath;
- }
- }
- return null;
- }
-
////////////
// Output //
////////////