diff options
author | Sven Gothel <[email protected]> | 2009-08-05 07:31:49 -0700 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2009-08-05 07:31:49 -0700 |
commit | ae26bd0aac4a98c26aceb95584988defae970dde (patch) | |
tree | c25739c22fb1774722737982aea0bed66ba11167 /src/java/com/sun/gluegen/opengl/GLEmitter.java | |
parent | 48465d43cf58d98758639f4064cc5eb3ee86bee8 (diff) |
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.
Diffstat (limited to 'src/java/com/sun/gluegen/opengl/GLEmitter.java')
-rw-r--r-- | src/java/com/sun/gluegen/opengl/GLEmitter.java | 92 |
1 files changed, 64 insertions, 28 deletions
diff --git a/src/java/com/sun/gluegen/opengl/GLEmitter.java b/src/java/com/sun/gluegen/opengl/GLEmitter.java index 83e688eec..9e3202658 100644 --- a/src/java/com/sun/gluegen/opengl/GLEmitter.java +++ b/src/java/com/sun/gluegen/opengl/GLEmitter.java @@ -85,9 +85,15 @@ public class GLEmitter extends ProcAddressEmitter // renaming mechanisms that are built elsewhere. GLConfiguration config = getGLConfig(); + Set extensionsRenamedIntoCore = config.getExtensionsRenamedIntoCore(); BuildStaticGLInfo glInfo = config.getGLInfo(); - for (Iterator iter = config.getExtensionsRenamedIntoCore().iterator(); - iter.hasNext(); ) { + if(null==glInfo) { + if(extensionsRenamedIntoCore.size()>0) { + throw new RuntimeException("ExtensionRenamedIntoCore (num: "+extensionsRenamedIntoCore.size()+"), but no GLHeader"); + } + return; + } + for (Iterator iter = extensionsRenamedIntoCore.iterator(); iter.hasNext(); ) { String extension = (String) iter.next(); Set/*<String>*/ declarations = glInfo.getDeclarations(extension); if (declarations != null) { @@ -305,19 +311,68 @@ public class GLEmitter extends ProcAddressEmitter return bufferObjectMethodBindings.containsKey(binding); } - public void emitDefine(String name, String value, String optionalComment) throws Exception { - String extensionName = getGLConfig().getExtension(name); + public void emitDefine(ConstantDefinition def, String optionalComment) throws Exception { + BuildStaticGLInfo glInfo = getGLConfig().getGLInfo(); + if(null==glInfo) { + throw new Exception("No GLInfo for: "+def); + } + String symbolRenamed = def.getName(); StringBuffer newComment = new StringBuffer(); - if(null!=extensionName) { - newComment.append("Part of <code>"+extensionName+"</code>"); - } else { - newComment.append("Part of <code>unknown extension</code>"); + newComment.append("Part of <code>"); + if(0==addExtensionsOfSymbols2Buffer(newComment, ", ", symbolRenamed, def.getAliasedNames())) { + // Note: All GL enums 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; } + newComment.append("</code>"); + if(null!=optionalComment) { newComment.append(" "); newComment.append(optionalComment); } - super.emitDefine(name, value, newComment.toString()); + + super.emitDefine(def, newComment.toString()); + } + + public int addExtensionsOfSymbols2Buffer(StringBuffer buf, String sep, String first, Collection col) { + BuildStaticGLInfo glInfo = getGLConfig().getGLInfo(); + if(null==glInfo) { + throw new RuntimeException("No GLInfo for: "+first); + } + int num = 0; + if(null==buf) buf=new StringBuffer(); + String extensionName; + + Iterator iter=col.iterator(); + if(null!=first) { + extensionName = glInfo.getExtension(first); + if(null!=extensionName) { + buf.append(extensionName); + if( iter.hasNext() ) { + buf.append(sep); + } + num++; + } + } + while( iter.hasNext() ) { + extensionName = glInfo.getExtension((String)iter.next()); + if(null!=extensionName) { + buf.append(extensionName); + if( iter.hasNext() ) { + buf.append(sep); + } + num++; + } + } + return num; } //---------------------------------------------------------------------- @@ -399,23 +454,4 @@ public class GLEmitter extends ProcAddressEmitter w.flush(); w.close(); } - - protected void emitProcAddressTableEntryForSymbol(FunctionSymbol cFunc) - { - emitProcAddressTableEntryForString(cFunc.getName()); - } - - protected void emitProcAddressTableEntryForString(String str) - { - // Deal gracefully with forced proc address generation in the face - // of having the function pointer typedef in the header file too - if (emittedTableEntries.contains(str)) - return; - emittedTableEntries.add(str); - tableWriter.print(" public long "); - tableWriter.print(PROCADDRESS_VAR_PREFIX); - tableWriter.print(str); - tableWriter.println(";"); - } - } |