diff options
author | Michael Bien <[email protected]> | 2009-12-02 00:14:46 +0100 |
---|---|---|
committer | Michael Bien <[email protected]> | 2009-12-02 00:14:46 +0100 |
commit | 44f869b292f858cf9ad8c893ae30d39fadda1102 (patch) | |
tree | 1495adbc03ba4a67cfec146997a95f184dcd9462 /src | |
parent | ee26483627005ddd4316124dc76cf0c2d049d45f (diff) |
continued with code cleanup in com.sun.gluegen.cgram and com.sun.gluegen.opengl packages.
Diffstat (limited to 'src')
4 files changed, 92 insertions, 109 deletions
diff --git a/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java b/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java index a6c0cfc97..8653b076e 100644 --- a/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java +++ b/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java @@ -103,10 +103,11 @@ public class BuildStaticGLInfo 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(); + protected Map<String, String> declarationToExtensionMap = new HashMap<String, String>(); + // Maps extension names to Set of identifiers (both #defines and // function names) this extension declares - protected Map/*<String, Set<String>*/ extensionToDeclarationMap = new HashMap(); + protected Map<String, Set<String>> extensionToDeclarationMap = new HashMap<String, Set<String>>(); protected boolean debug = false; /** @@ -221,28 +222,27 @@ public class BuildStaticGLInfo } public void dump() { - for (Iterator i1 = extensionToDeclarationMap.keySet().iterator(); i1.hasNext(); ) { - String name = (String) i1.next(); - Set decls = (Set) extensionToDeclarationMap.get(name); + for (String name : extensionToDeclarationMap.keySet()) { + Set<String> decls = extensionToDeclarationMap.get(name); System.out.println("<"+name+"> :"); - List l = new ArrayList(); + List<String> l = new ArrayList<String>(); l.addAll(decls); Collections.sort(l); - for (Iterator i2 = l.iterator(); i2.hasNext(); ) { - System.out.println(" <" + (String) i2.next() + ">"); + for (String str : l) { + System.out.println(" <" + str + ">"); } } } public String getExtension(String identifier) { - return (String) declarationToExtensionMap.get(identifier); + return declarationToExtensionMap.get(identifier); } - public Set/*<String>*/ getDeclarations(String extension) { - return (Set) extensionToDeclarationMap.get(extension); + public Set<String> getDeclarations(String extension) { + return extensionToDeclarationMap.get(extension); } - public Set/*<String>*/ getExtensions() { + public Set<String> getExtensions() { return extensionToDeclarationMap.keySet(); } @@ -298,8 +298,7 @@ public class BuildStaticGLInfo // Compute max capacity int maxCapacity = 0; - for (Iterator iter = declarationToExtensionMap.keySet().iterator(); iter.hasNext(); ) { - String name = (String) iter.next(); + for (String name : declarationToExtensionMap.keySet()) { if (!name.startsWith("GL")) { ++maxCapacity; } @@ -307,18 +306,17 @@ public class BuildStaticGLInfo output.println(" funcToAssocMap = new HashMap(" + maxCapacity + "); // approximate max capacity"); output.println(" String group;"); - ArrayList sets = new ArrayList(extensionToDeclarationMap.keySet()); + ArrayList<String> sets = new ArrayList<String>(extensionToDeclarationMap.keySet()); Collections.sort(sets); - for (Iterator iter = sets.iterator(); iter.hasNext(); ) { - String groupName = (String) iter.next(); - Set funcs = (Set) extensionToDeclarationMap.get(groupName); - List l = new ArrayList(); + for (String groupName : sets) { + Set<String> funcs = extensionToDeclarationMap.get(groupName); + List<String> l = new ArrayList<String>(); l.addAll(funcs); Collections.sort(l); - Iterator funcIter = l.iterator(); + Iterator<String> funcIter = l.iterator(); boolean printedHeader = false; while (funcIter.hasNext()) { - String funcName = (String)funcIter.next(); + String funcName = funcIter.next(); if (!funcName.startsWith("GL")) { if (!printedHeader) { output.println(); @@ -343,9 +341,9 @@ public class BuildStaticGLInfo protected void addAssociation(String identifier, String association) { declarationToExtensionMap.put(identifier, association); - Set/*<String>*/ identifiers = (Set) extensionToDeclarationMap.get(association); + Set<String> identifiers = extensionToDeclarationMap.get(association); if (identifiers == null) { - identifiers = new HashSet/*<String>*/(); + identifiers = new HashSet<String>(); extensionToDeclarationMap.put(association, identifiers); } identifiers.add(identifier); diff --git a/src/java/com/sun/gluegen/opengl/GLConfiguration.java b/src/java/com/sun/gluegen/opengl/GLConfiguration.java index 9352bcba2..5e7ef7a89 100755 --- a/src/java/com/sun/gluegen/opengl/GLConfiguration.java +++ b/src/java/com/sun/gluegen/opengl/GLConfiguration.java @@ -48,14 +48,14 @@ import com.sun.gluegen.runtime.opengl.GLExtensionNames; public class GLConfiguration extends ProcAddressConfiguration { // 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 Set/*<String>*/ extensionsRenamedIntoCore = new HashSet(); + private List<String> glHeaders = new ArrayList<String>(); + private Set<String> ignoredExtensions = new HashSet<String>(); + private Set<String> extensionsRenamedIntoCore = new HashSet<String>(); private BuildStaticGLInfo glInfo; // Maps function names to the kind of buffer object it deals with - private Map/*<String,GLEmitter.BufferObjectKind>*/ bufferObjectKinds = new HashMap(); + private Map<String,GLEmitter.BufferObjectKind> bufferObjectKinds = new HashMap<String,GLEmitter.BufferObjectKind>(); private GLEmitter emitter; - private Set/*String*/ dropUniqVendorExtensions = new HashSet(); + private Set<String> dropUniqVendorExtensions = new HashSet<String>(); // 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 @@ -72,44 +72,30 @@ public class GLConfiguration extends ProcAddressConfiguration { } } - protected void dispatch(String cmd, StringTokenizer tok, File file, String filename, int lineNo) throws IOException { - if (cmd.equalsIgnoreCase("IgnoreExtension")) - { - String sym = readString("IgnoreExtension", tok, filename, lineNo); - ignoredExtensions.add(sym); - } - else if (cmd.equalsIgnoreCase("RenameExtensionIntoCore")) - { - 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(); - } - else if (cmd.equalsIgnoreCase("GLHeader")) - { - String sym = readString("GLHeader", tok, filename, lineNo); - glHeaders.add(sym); - } - else if (cmd.equalsIgnoreCase("BufferObjectKind")) - { - readBufferObjectKind(tok, filename, lineNo); - } - else if (cmd.equalsIgnoreCase("DropUniqVendorExtensions")) - { - String sym = readString("DropUniqVendorExtensions", tok, filename, lineNo); - dropUniqVendorExtensions.add(sym); - } - else - { - super.dispatch(cmd,tok,file,filename,lineNo); - } - } + @Override + protected void dispatch(String cmd, StringTokenizer tok, File file, String filename, int lineNo) throws IOException { + if (cmd.equalsIgnoreCase("IgnoreExtension")) { + String sym = readString("IgnoreExtension", tok, filename, lineNo); + ignoredExtensions.add(sym); + } else if (cmd.equalsIgnoreCase("RenameExtensionIntoCore")) { + 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(); + } else if (cmd.equalsIgnoreCase("GLHeader")) { + String sym = readString("GLHeader", tok, filename, lineNo); + glHeaders.add(sym); + } else if (cmd.equalsIgnoreCase("BufferObjectKind")) { + readBufferObjectKind(tok, filename, lineNo); + } else if (cmd.equalsIgnoreCase("DropUniqVendorExtensions")) { + String sym = readString("DropUniqVendorExtensions", tok, filename, lineNo); + dropUniqVendorExtensions.add(sym); + } else { + super.dispatch(cmd, tok, file, filename, lineNo); + } + } protected void readBufferObjectKind(StringTokenizer tok, String filename, int lineNo) { try { @@ -140,12 +126,10 @@ public class GLConfiguration extends ProcAddressConfiguration { /** Overrides javaPrologueForMethod in superclass and automatically generates prologue code for functions associated with buffer objects. */ - public List/*<String>*/ javaPrologueForMethod(MethodBinding binding, - boolean forImplementingMethodCall, - boolean eraseBufferAndArrayTypes) { - List/*<String>*/ res = super.javaPrologueForMethod(binding, - forImplementingMethodCall, - eraseBufferAndArrayTypes); + @Override + public List<String> javaPrologueForMethod(MethodBinding binding, boolean forImplementingMethodCall, boolean eraseBufferAndArrayTypes) { + + List<String> res = super.javaPrologueForMethod(binding, forImplementingMethodCall, eraseBufferAndArrayTypes); GLEmitter.BufferObjectKind kind = getBufferObjectKind(binding.getName()); if (kind != null) { // Need to generate appropriate prologue based on both buffer @@ -154,7 +138,7 @@ public class GLConfiguration extends ProcAddressConfiguration { // // NOTE we MUST NOT mutate the array returned from the super // call! - ArrayList res2 = new ArrayList(); + ArrayList<String> res2 = new ArrayList<String>(); if (res != null) { res2.addAll(res); } @@ -187,8 +171,8 @@ public class GLConfiguration extends ProcAddressConfiguration { // Must also filter out bogus rangeCheck directives for VBO/PBO // variants if (emitter.isBufferObjectMethodBinding(binding)) { - for (Iterator iter = res.iterator(); iter.hasNext(); ) { - String line = (String) iter.next(); + for (Iterator<String> iter = res.iterator(); iter.hasNext(); ) { + String line = iter.next(); if (line.indexOf("BufferFactory.rangeCheck") >= 0) { iter.remove(); } @@ -199,10 +183,11 @@ public class GLConfiguration extends ProcAddressConfiguration { return res; } + @Override public void dumpIgnores() { System.err.println("GL Ignored extensions: "); - for (Iterator iter = ignoredExtensions.iterator(); iter.hasNext(); ) { - System.err.println("\t"+(String)iter.next()); + for (String str : ignoredExtensions) { + System.err.println("\t"+str); } super.dumpIgnores(); } @@ -231,6 +216,7 @@ public class GLConfiguration extends ProcAddressConfiguration { return false; } + @Override public boolean shouldIgnoreInInterface(String symbol) { return shouldIgnoreInInterface(symbol, true); } @@ -239,6 +225,7 @@ public class GLConfiguration extends ProcAddressConfiguration { return shouldIgnoreExtension(symbol, checkEXT) || super.shouldIgnoreInInterface(symbol); } + @Override public boolean shouldIgnoreInImpl(String symbol) { return shouldIgnoreInImpl(symbol, true); } @@ -268,8 +255,8 @@ public class GLConfiguration extends ProcAddressConfiguration { /** Returns the kind of buffer object this function deals with, or null if none. */ - public GLEmitter.BufferObjectKind getBufferObjectKind(String name) { - return (GLEmitter.BufferObjectKind) bufferObjectKinds.get(name); + GLEmitter.BufferObjectKind getBufferObjectKind(String name) { + return bufferObjectKinds.get(name); } public boolean isBufferObjectFunction(String name) { @@ -281,8 +268,7 @@ public class GLConfiguration extends ProcAddressConfiguration { 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(); + for (String file : glHeaders) { String fullPath = controls.findHeaderFile(file); if (fullPath == null) { throw new IOException("Unable to locate header file \"" + file + "\""); @@ -303,7 +289,7 @@ public class GLConfiguration extends ProcAddressConfiguration { constant definitions and functions renamed into the core namespace; for example, glGenFramebuffersEXT to glGenFramebuffers and GL_FRAMEBUFFER_EXT to GL_FRAMEBUFFER. */ - public Set/*<String>*/ getExtensionsRenamedIntoCore() { + public Set<String> getExtensionsRenamedIntoCore() { return extensionsRenamedIntoCore; } } diff --git a/src/java/com/sun/gluegen/opengl/GLEmitter.java b/src/java/com/sun/gluegen/opengl/GLEmitter.java index 4ca2e698b..ff307c432 100644 --- a/src/java/com/sun/gluegen/opengl/GLEmitter.java +++ b/src/java/com/sun/gluegen/opengl/GLEmitter.java @@ -45,20 +45,20 @@ import java.util.*; import com.sun.gluegen.*; import com.sun.gluegen.cgram.types.*; import com.sun.gluegen.procaddress.*; -import com.sun.gluegen.runtime.*; import com.sun.gluegen.runtime.opengl.GLExtensionNames; /** * A subclass of ProcAddressEmitter with special OpenGL-specific * configuration abilities. */ -public class GLEmitter extends ProcAddressEmitter -{ +public class GLEmitter extends ProcAddressEmitter { + // Keeps track of which MethodBindings were created for handling // Buffer Object variants. Used as a Set rather than a Map. - private Map/*<MethodBinding>*/ bufferObjectMethodBindings = new IdentityHashMap(); + private Map<MethodBinding, MethodBinding> bufferObjectMethodBindings = new IdentityHashMap<MethodBinding, MethodBinding>(); static class BufferObjectKind { + private BufferObjectKind() {} static final BufferObjectKind UNPACK_PIXEL = new BufferObjectKind(); @@ -67,8 +67,8 @@ public class GLEmitter extends ProcAddressEmitter static final BufferObjectKind ELEMENT = new BufferObjectKind(); } - public void beginEmission(GlueEmitterControls controls) throws IOException - { + @Override + public void beginEmission(GlueEmitterControls controls) throws IOException { getGLConfig().parseGLHeaders(controls); renameExtensionsIntoCore(); if (getGLConfig().getAutoUnifyExtensions()) { @@ -85,7 +85,7 @@ public class GLEmitter extends ProcAddressEmitter // renaming mechanisms that are built elsewhere. GLConfiguration config = getGLConfig(); - Set extensionsRenamedIntoCore = config.getExtensionsRenamedIntoCore(); + Set<String> extensionsRenamedIntoCore = config.getExtensionsRenamedIntoCore(); BuildStaticGLInfo glInfo = config.getGLInfo(); if(null==glInfo) { if(extensionsRenamedIntoCore.size()>0) { @@ -93,9 +93,8 @@ public class GLEmitter extends ProcAddressEmitter } return; } - for (Iterator iter = extensionsRenamedIntoCore.iterator(); iter.hasNext(); ) { - String extension = (String) iter.next(); - Set/*<String>*/ declarations = glInfo.getDeclarations(extension); + for (String extension : extensionsRenamedIntoCore) { + Set<String> declarations = glInfo.getDeclarations(extension); if (declarations != null) { for (Iterator i2 = declarations.iterator(); i2.hasNext(); ) { String decl = (String) i2.next(); @@ -116,21 +115,21 @@ public class GLEmitter extends ProcAddressEmitter } class ExtensionUnifier implements SymbolFilter { - private List/*<ConstantDefinition>*/ constants; - private List/*<FunctionSymbol>*/ functions; + private List<ConstantDefinition> constants; + private List<FunctionSymbol> functions; - public void filterSymbols(List/*<ConstantDefinition>*/ constants, - List/*<FunctionSymbol>*/ functions) { + public void filterSymbols(List<ConstantDefinition> constants, + List<FunctionSymbol> functions) { this.constants = constants; this.functions = functions; doWork(); } - public List/*<ConstantDefinition>*/ getConstants() { + public List<ConstantDefinition> getConstants() { return constants; } - public List/*<FunctionSymbol>*/ getFunctions() { + public List<FunctionSymbol> getFunctions() { return functions; } @@ -140,8 +139,8 @@ public class GLEmitter extends ProcAddressEmitter return; } // Try to retain a "good" ordering for these symbols - Map/*<String, ConstantDefinition>*/ constantMap = new LinkedHashMap(); - Map/*<String, FunctionSymbol>*/ functionMap = new LinkedHashMap(); + Map<String, ConstantDefinition> constantMap = new LinkedHashMap(); + Map<String, FunctionSymbol> functionMap = new LinkedHashMap(); for (Iterator iter = constants.iterator(); iter.hasNext(); ) { ConstantDefinition def = (ConstantDefinition) iter.next(); constantMap.put(def.getName(), def); @@ -158,10 +157,10 @@ public class GLEmitter extends ProcAddressEmitter // that doesn't support the core version of these APIs, the runtime // will take care of looking up the extension version of these entry // points. - Set/*<String>*/ extensionNames = glInfo.getExtensions(); + Set<String> extensionNames = glInfo.getExtensions(); for (Iterator iter1 = extensionNames.iterator(); iter1.hasNext(); ) { String extension = (String) iter1.next(); - Set/*<String>*/ declarations = glInfo.getDeclarations(extension); + Set<String> declarations = glInfo.getDeclarations(extension); boolean isExtension = true; boolean shouldUnify = true; String cause = null; @@ -253,14 +252,14 @@ public class GLEmitter extends ProcAddressEmitter (i.e., mutators for argument names). We also would need to inform the CMethodBindingEmitter that it is overloaded in this case (though we default to true currently). */ - protected List/*<MethodBinding>*/ expandMethodBinding(MethodBinding binding) { - List/*<MethodBinding>*/ bindings = super.expandMethodBinding(binding); + protected List<MethodBinding> expandMethodBinding(MethodBinding binding) { + List<MethodBinding> bindings = super.expandMethodBinding(binding); if (!getGLConfig().isBufferObjectFunction(binding.getName())) { return bindings; } - List/*<MethodBinding>*/ newBindings = new ArrayList(); + List<MethodBinding> newBindings = new ArrayList(); newBindings.addAll(bindings); // Need to expand each one of the generated bindings to take a diff --git a/src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java b/src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java index 662e75b51..33f94fb19 100755 --- a/src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java +++ b/src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java @@ -40,7 +40,6 @@ package com.sun.gluegen.opengl; import java.io.*; -import java.util.*; import com.sun.gluegen.*; import com.sun.gluegen.cgram.types.*; import com.sun.gluegen.procaddress.*; @@ -83,6 +82,7 @@ public class GLJavaMethodBindingEmitter extends ProcAddressJavaMethodBindingEmit this(methodToWrap, methodToWrap.glEmitter, methodToWrap.bufferObjectVariant); } + @Override protected String getArgumentName(int i) { String name = super.getArgumentName(i); @@ -104,9 +104,9 @@ public class GLJavaMethodBindingEmitter extends ProcAddressJavaMethodBindingEmit return name; } - protected class GLCommentEmitter - extends JavaMethodBindingEmitter.DefaultCommentEmitter - { + protected class GLCommentEmitter extends JavaMethodBindingEmitter.DefaultCommentEmitter { + + @Override protected void emitBindingCSignature(MethodBinding binding, PrintWriter writer) { super.emitBindingCSignature(binding, writer); |