diff options
author | Kenneth Russel <[email protected]> | 2005-07-22 18:29:56 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2005-07-22 18:29:56 +0000 |
commit | ebd2c94e33c643ad6102e76f22d1624e9b986737 (patch) | |
tree | 05e44db841b94ce9dd9eebcafa124f8ad9b840a9 | |
parent | b277014b8c7bec589d8b085bd6a7638c13ffa507 (diff) |
Added new IgnoreExtension directive to the GLEmitter which allows a
block of functions and #defines associated with a particular extension
to be ignored in one shot.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JSR-231@335 232f8b59-042b-4e1e-8c03-345bb8c30851
-rw-r--r-- | make/build.xml | 4 | ||||
-rw-r--r-- | make/gl-common.cfg | 5 | ||||
-rw-r--r-- | src/net/java/games/gluegen/GlueEmitterControls.java | 4 | ||||
-rw-r--r-- | src/net/java/games/gluegen/GlueGen.java | 7 | ||||
-rw-r--r-- | src/net/java/games/gluegen/opengl/BuildStaticGLInfo.java | 1 | ||||
-rw-r--r-- | src/net/java/games/gluegen/opengl/GLEmitter.java | 50 | ||||
-rw-r--r-- | src/net/java/games/gluegen/pcpp/PCPP.java | 26 |
7 files changed, 80 insertions, 17 deletions
diff --git a/make/build.xml b/make/build.xml index f707e43d7..a375ca764 100644 --- a/make/build.xml +++ b/make/build.xml @@ -261,7 +261,7 @@ <property name="java.includes.dir.platform" value="${java.includes.dir.win32}" /> <property name="java.lib.dir.platform" value="${java.lib.dir.win32}" /> <property name="java.excludes.platform" value="${java.excludes.win32}" /> - <property name="stub.includes.fileset.platform.params" value="${stub.includes.dir}/win32/** ${stub.includes.dir}/common/**" /> + <property name="stub.includes.fileset.platform.params" value="${stub.includes.dir}/win32/** ${stub.includes.dir}/common/** ${stub.includes.dir}/opengl/**" /> <!-- Set Javadoc properties. --> <property name="javadoc.dev.packagenames.platform" value="${javadoc.dev.packagenames.win32}" /> @@ -363,7 +363,7 @@ <property name="java.includes.dir.platform" value="${java.includes.dir.macosx}" /> <property name="java.lib.dir.platform" value="${java.lib.dir.macosx}" /> <property name="java.excludes.platform" value="${java.excludes.macosx}" /> - <property name="stub.includes.fileset.platform.params" value="${stub.includes.dir}/macosx/** ${stub.includes.dir}/common/**" /> + <property name="stub.includes.fileset.platform.params" value="${stub.includes.dir}/macosx/** ${stub.includes.dir}/common/** ${stub.includes.dir}/opengl/**" /> <!-- Set Javadoc properties. --> <property name="javadoc.dev.packagenames.platform" value="${javadoc.dev.packagenames.macosx}" /> diff --git a/make/gl-common.cfg b/make/gl-common.cfg index 292871e27..48d3a4092 100644 --- a/make/gl-common.cfg +++ b/make/gl-common.cfg @@ -10,6 +10,11 @@ Import java.util.* Import net.java.games.jogl.* Import net.java.games.jogl.impl.* +# Inform the glue code generator of the association between #defines +# and functions and the extensions in which they are defined +GLHeader GL/gl.h +GLHeader GL/glext.h + # Generate "flattened" NIO variants for routines taking C primitive # pointers that aren't of type void* NioMode ALL_POINTERS 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 // //////////// |