From ae26bd0aac4a98c26aceb95584988defae970dde 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/opengl/BuildStaticGLInfo.java | 40 ++++++++++++++++------ 1 file changed, 30 insertions(+), 10 deletions(-) (limited to 'src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java') diff --git a/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java b/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java index 4226f4612..f5193dcdf 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() + ">"); } } } -- cgit v1.2.3 From 3efa8c6f680a873f126b82a74538d883fb9438cc 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/gluegen/opengl/BuildStaticGLInfo.java') diff --git a/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java b/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java index f5193dcdf..0ede95e88 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 47319dab5b769a5a685bc329c8e5a37a710e1687 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/opengl/BuildStaticGLInfo.java | 2 +- src/java/com/sun/gluegen/opengl/GLEmitter.java | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java') diff --git a/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java b/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java index 0ede95e88..a31a98760 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 9e3202658..935706bd2 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 a3ce5e8e3bfae850a638c0b40679ed885bceea82 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/gluegen/opengl/BuildStaticGLInfo.java') diff --git a/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java b/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java index a31a98760..a6c0cfc97 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 4e8c0c369..9352bcba2 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 935706bd2..ffe1ed61c 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 5e8bada0d..8f5258e0b 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