diff options
author | Sven Gothel <[email protected]> | 2014-06-17 03:12:28 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-06-17 03:12:28 +0200 |
commit | afb698ac3846713e5000226de9e28a9b06bf6f9a (patch) | |
tree | 83f795d0d9023ac022fe9b7af35f819125b79f17 /src | |
parent | c3054a01990e55ab35756ea23ab7d7c05f24dd37 (diff) | |
parent | 5d802fb8dd4004039d4597253712d24fffb90a36 (diff) |
Merge remote-tracking branch 'hharrison/antlr-move'
Diffstat (limited to 'src')
14 files changed, 29 insertions, 39 deletions
diff --git a/src/java/com/jogamp/gluegen/DebugEmitter.java b/src/java/com/jogamp/gluegen/DebugEmitter.java index 781188e..8773f1b 100644 --- a/src/java/com/jogamp/gluegen/DebugEmitter.java +++ b/src/java/com/jogamp/gluegen/DebugEmitter.java @@ -41,7 +41,6 @@ package com.jogamp.gluegen; import java.util.*; -import com.jogamp.common.os.MachineDescription; import com.jogamp.gluegen.cgram.types.*; /** Debug emitter which prints the parsing results to standard output. */ diff --git a/src/java/com/jogamp/gluegen/FunctionEmitter.java b/src/java/com/jogamp/gluegen/FunctionEmitter.java index 8bb2ca5..01a0e12 100644 --- a/src/java/com/jogamp/gluegen/FunctionEmitter.java +++ b/src/java/com/jogamp/gluegen/FunctionEmitter.java @@ -47,7 +47,7 @@ public abstract class FunctionEmitter { public static final EmissionModifier STATIC = new EmissionModifier("static"); private boolean isInterfaceVal; - private ArrayList<EmissionModifier> modifiers = new ArrayList<EmissionModifier>(); + private final ArrayList<EmissionModifier> modifiers; private CommentEmitter commentEmitter = null; private PrintWriter defaultOutput; @@ -56,6 +56,7 @@ public abstract class FunctionEmitter { */ public FunctionEmitter(PrintWriter defaultOutput, boolean isInterface) { assert(defaultOutput != null); + this.modifiers = new ArrayList<EmissionModifier>(); this.defaultOutput = defaultOutput; this.isInterfaceVal = isInterface; } @@ -63,9 +64,8 @@ public abstract class FunctionEmitter { /** * Makes this FunctionEmitter a copy of the passed one. */ - @SuppressWarnings("unchecked") public FunctionEmitter(FunctionEmitter arg) { - modifiers = (ArrayList<EmissionModifier>)arg.modifiers.clone(); + modifiers = new ArrayList<EmissionModifier>(arg.modifiers); commentEmitter = arg.commentEmitter; defaultOutput = arg.defaultOutput; isInterfaceVal = arg.isInterfaceVal; @@ -169,7 +169,6 @@ public abstract class FunctionEmitter { } protected int emitModifiers(PrintWriter writer) { - PrintWriter w = getDefaultOutput(); int numEmitted = 0; for (Iterator<EmissionModifier> it = getModifiers(); it.hasNext(); ) { writer.print(it.next()); diff --git a/src/java/com/jogamp/gluegen/GlueEmitter.java b/src/java/com/jogamp/gluegen/GlueEmitter.java index bd5a7f3..bb46cf5 100644 --- a/src/java/com/jogamp/gluegen/GlueEmitter.java +++ b/src/java/com/jogamp/gluegen/GlueEmitter.java @@ -41,7 +41,6 @@ package com.jogamp.gluegen; import java.util.*; -import com.jogamp.common.os.MachineDescription; import com.jogamp.gluegen.cgram.types.*; /** Specifies the interface by which GlueGen requests glue code to be diff --git a/src/java/com/jogamp/gluegen/GlueGen.java b/src/java/com/jogamp/gluegen/GlueGen.java index 54e510d..891878b 100644 --- a/src/java/com/jogamp/gluegen/GlueGen.java +++ b/src/java/com/jogamp/gluegen/GlueGen.java @@ -190,8 +190,7 @@ public class GlueGen implements GlueEmitterControls { // Repackage the enum and #define statements from the parser into a common format // so that SymbolFilters can operate upon both identically constants = new ArrayList<ConstantDefinition>(); - for (Object elem : headerParser.getEnums()) { - EnumType enumeration = (EnumType) elem; + for (EnumType enumeration : headerParser.getEnums()) { String enumName = enumeration.getName(); if (enumName.equals("<anonymous>")) { enumName = null; diff --git a/src/java/com/jogamp/gluegen/cgram/CToken.java b/src/java/com/jogamp/gluegen/cgram/CToken.java index cfa88fc..78fc7f7 100644 --- a/src/java/com/jogamp/gluegen/cgram/CToken.java +++ b/src/java/com/jogamp/gluegen/cgram/CToken.java @@ -1,7 +1,5 @@ package com.jogamp.gluegen.cgram; -import antlr.CommonToken; - public class CToken extends antlr.CommonToken { String source = ""; int tokenNumber; diff --git a/src/java/com/jogamp/gluegen/cgram/TNodeFactory.java b/src/java/com/jogamp/gluegen/cgram/TNodeFactory.java index ccbd233..ff2f1b0 100644 --- a/src/java/com/jogamp/gluegen/cgram/TNodeFactory.java +++ b/src/java/com/jogamp/gluegen/cgram/TNodeFactory.java @@ -1,6 +1,5 @@ package com.jogamp.gluegen.cgram; -import antlr.Token; import antlr.ASTFactory; import antlr.collections.AST; diff --git a/src/java/com/jogamp/gluegen/jgram/Test.java b/src/java/com/jogamp/gluegen/jgram/Test.java index 8baff02..19d2110 100644 --- a/src/java/com/jogamp/gluegen/jgram/Test.java +++ b/src/java/com/jogamp/gluegen/jgram/Test.java @@ -1,13 +1,11 @@ package com.jogamp.gluegen.jgram; -import java.util.*; - -import java.io.*; -// import antlr.collections.AST; -import antlr.collections.impl.*; -import antlr.debug.misc.*; -import antlr.*; -// import java.awt.event.*; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.Reader; +import java.util.Iterator; +import java.util.Set; class Test { @@ -74,16 +72,16 @@ class Test { // start parsing at the compilationUnit rule parser.compilationUnit(); - Set set = parser.getParsedEnumNames(); + Set<String> set = parser.getParsedEnumNames(); System.out.println("Enums"); - for(Iterator iter = set.iterator(); iter.hasNext(); ) { - String s = (String) iter.next(); + for(Iterator<String> iter = set.iterator(); iter.hasNext(); ) { + String s = iter.next(); System.out.println(s); } System.out.println("Functions"); set = parser.getParsedFunctionNames(); - for(Iterator iter = set.iterator(); iter.hasNext(); ) { - String s = (String) iter.next(); + for(Iterator<String> iter = set.iterator(); iter.hasNext(); ) { + String s = iter.next(); System.out.println(s); } diff --git a/src/java/com/jogamp/gluegen/procaddress/ProcAddressJavaMethodBindingEmitter.java b/src/java/com/jogamp/gluegen/procaddress/ProcAddressJavaMethodBindingEmitter.java index 236627c..f28c50d 100644 --- a/src/java/com/jogamp/gluegen/procaddress/ProcAddressJavaMethodBindingEmitter.java +++ b/src/java/com/jogamp/gluegen/procaddress/ProcAddressJavaMethodBindingEmitter.java @@ -42,7 +42,6 @@ import com.jogamp.gluegen.MethodBinding; import com.jogamp.gluegen.FunctionEmitter; import com.jogamp.gluegen.JavaMethodBindingEmitter; import java.io.*; -import com.jogamp.gluegen.*; /** A specialization of JavaMethodBindingEmitter with knowledge of how to call through a function pointer. */ diff --git a/src/java/com/jogamp/gluegen/cgram/GnuCEmitter.g b/src/main/antlr/com/jogamp/gluegen/cgram/GnuCEmitter.g index 38ded36..38ded36 100644 --- a/src/java/com/jogamp/gluegen/cgram/GnuCEmitter.g +++ b/src/main/antlr/com/jogamp/gluegen/cgram/GnuCEmitter.g diff --git a/src/java/com/jogamp/gluegen/cgram/GnuCParser.g b/src/main/antlr/com/jogamp/gluegen/cgram/GnuCParser.g index e8ca8c5..e8ca8c5 100644 --- a/src/java/com/jogamp/gluegen/cgram/GnuCParser.g +++ b/src/main/antlr/com/jogamp/gluegen/cgram/GnuCParser.g diff --git a/src/java/com/jogamp/gluegen/cgram/GnuCTreeParser.g b/src/main/antlr/com/jogamp/gluegen/cgram/GnuCTreeParser.g index dbe2f98..dbe2f98 100644 --- a/src/java/com/jogamp/gluegen/cgram/GnuCTreeParser.g +++ b/src/main/antlr/com/jogamp/gluegen/cgram/GnuCTreeParser.g diff --git a/src/java/com/jogamp/gluegen/cgram/HeaderParser.g b/src/main/antlr/com/jogamp/gluegen/cgram/HeaderParser.g index 0b4d5ec..75cf413 100644 --- a/src/java/com/jogamp/gluegen/cgram/HeaderParser.g +++ b/src/main/antlr/com/jogamp/gluegen/cgram/HeaderParser.g @@ -100,7 +100,7 @@ options { /** Pre-define the list of EnumTypes for this HeaderParser. Must be done before parsing. */ - public void setEnums(List/*<EnumType>*/ enumTypes) { + public void setEnums(List<EnumType> enumTypes) { // FIXME: Need to take the input set of EnumTypes, extract all // the enumerates from each EnumType, and fill in the enumHash // so that each enumerate maps to the enumType to which it @@ -109,8 +109,8 @@ options { } /** Returns the EnumTypes this HeaderParser processed. */ - public List/*<EnumType>*/ getEnums() { - return new ArrayList(enumHash.values()); + public List<EnumType> getEnums() { + return new ArrayList<EnumType>(enumHash.values()); } /** Clears the list of functions this HeaderParser has parsed. @@ -121,7 +121,7 @@ options { } /** Returns the list of FunctionSymbols this HeaderParser has parsed. */ - public List getParsedFunctions() { + public List<FunctionSymbol> getParsedFunctions() { return functions; } @@ -241,9 +241,9 @@ options { private List parameters; private TypeDictionary typedefDictionary; private TypeDictionary structDictionary; - private List/*<FunctionSymbol>*/ functions = new ArrayList(); + private List<FunctionSymbol> functions = new ArrayList<FunctionSymbol>(); // hash from name of an enumerated value to the EnumType to which it belongs - private HashMap/*<String,EnumType>*/ enumHash = new HashMap(); + private HashMap<String, EnumType> enumHash = new HashMap<String, EnumType>(); // Storage class specifiers private static final int AUTO = 1 << 0; @@ -317,9 +317,9 @@ options { returns an existing one if it has already been created. */ private EnumType getEnumType(String enumTypeName) { EnumType enumType = null; - Iterator it = enumHash.values().iterator(); + Iterator<EnumType> it = enumHash.values().iterator(); while (it.hasNext()) { - EnumType potentialMatch = (EnumType)it.next(); + EnumType potentialMatch = it.next(); if (potentialMatch.getName().equals(enumTypeName)) { enumType = potentialMatch; break; @@ -652,7 +652,7 @@ enumerator[EnumType enumeration, long defaultValue] returns [long newDefaultValu if (eVal != null) { String vTxt = eVal.getAllChildrenText(); if (enumHash.containsKey(vTxt)) { - EnumType oldEnumType = (EnumType) enumHash.get(vTxt); + EnumType oldEnumType = enumHash.get(vTxt); value = oldEnumType.getEnumValue(vTxt); } else { try { @@ -669,7 +669,7 @@ enumerator[EnumType enumeration, long defaultValue] returns [long newDefaultValu newDefaultValue = value+1; String eTxt = eName.getText(); if (enumHash.containsKey(eTxt)) { - EnumType oldEnumType = (EnumType) enumHash.get(eTxt); + EnumType oldEnumType = enumHash.get(eTxt); long oldValue = oldEnumType.getEnumValue(eTxt); System.err.println("WARNING: redefinition of enumerated value '" + eTxt + "';" + " existing definition is in enumeration '" + oldEnumType.getName() + diff --git a/src/java/com/jogamp/gluegen/cgram/StdCParser.g b/src/main/antlr/com/jogamp/gluegen/cgram/StdCParser.g index 7b34656..7b34656 100644 --- a/src/java/com/jogamp/gluegen/cgram/StdCParser.g +++ b/src/main/antlr/com/jogamp/gluegen/cgram/StdCParser.g diff --git a/src/java/com/jogamp/gluegen/jgram/JavaParser.g b/src/main/antlr/com/jogamp/gluegen/jgram/JavaParser.g index 18f2970..f67579e 100644 --- a/src/java/com/jogamp/gluegen/jgram/JavaParser.g +++ b/src/main/antlr/com/jogamp/gluegen/jgram/JavaParser.g @@ -155,7 +155,7 @@ tokens { } /** Returns the EnumTypes this HeaderParser processed. */ - public Set getParsedEnumNames() { + public Set<String> getParsedEnumNames() { return enumNames; } @@ -167,13 +167,13 @@ tokens { } /** Returns the list of FunctionSymbols this HeaderParser has parsed. */ - public Set getParsedFunctionNames() { + public Set<String> getParsedFunctionNames() { return functionNames; } - private Set/*<String>*/ functionNames = new HashSet(); + private Set<String> functionNames = new HashSet<String>(); // hash from name of an enumerated value to the EnumType to which it belongs - private Set/*<String>*/ enumNames = new HashSet(); + private Set<String> enumNames = new HashSet<String>(); private int blockDepth = 0; } |