diff options
author | Sven Gothel <[email protected]> | 2014-07-03 16:06:47 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-07-03 16:06:47 +0200 |
commit | df9ff7f340a5ab4e07efc613f5f264eeae63d4c7 (patch) | |
tree | 239ae276b82024b140428e6c0fe5d739fdd686a4 /src/java/com/jogamp/gluegen/cgram | |
parent | eb47aaba63e3b1bf55f274a0f338f1010a017ae4 (diff) |
Code Clean-Up based on our Recommended Settings (jogamp-scripting c47bc86ae2ee268a1f38c5580d11f93d7f8d6e74)
Code Clean-Up based on our Recommended Settings (jogamp-scripting c47bc86ae2ee268a1f38c5580d11f93d7f8d6e74)
- Change non static accesses to static members using declaring type
- Change indirect accesses to static members to direct accesses (accesses through subtypes)
- Add final modifier to private fields
- Add final modifier to method parameters
- Add final modifier to local variables
- Remove unnecessary casts
- Remove unnecessary '$NON-NLS$' tags
- Remove trailing white spaces on all lines
Diffstat (limited to 'src/java/com/jogamp/gluegen/cgram')
28 files changed, 272 insertions, 272 deletions
diff --git a/src/java/com/jogamp/gluegen/cgram/CSymbolTable.java b/src/java/com/jogamp/gluegen/cgram/CSymbolTable.java index ec2f979..6e00a72 100644 --- a/src/java/com/jogamp/gluegen/cgram/CSymbolTable.java +++ b/src/java/com/jogamp/gluegen/cgram/CSymbolTable.java @@ -8,10 +8,10 @@ import java.util.Enumeration; public class CSymbolTable { /** holds list of scopes */ - private Vector<String> scopeStack; + private final Vector<String> scopeStack; /** table where all defined names are mapped to TNode tree nodes */ - private Hashtable<String, TNode> symTable; + private final Hashtable<String, TNode> symTable; public CSymbolTable() { scopeStack = new Vector<String>(10); @@ -21,7 +21,7 @@ public class CSymbolTable { /** push a new scope onto the scope stack. */ - public void pushScope(String s) { + public void pushScope(final String s) { //System.out.println("push scope:" + s); scopeStack.addElement(s); } @@ -30,7 +30,7 @@ public class CSymbolTable { */ public void popScope() { //System.out.println("pop scope"); - int size = scopeStack.size(); + final int size = scopeStack.size(); if(size > 0) scopeStack.removeElementAt(size - 1); } @@ -38,9 +38,9 @@ public class CSymbolTable { /** return the current scope as a string */ public String currentScopeAsString() { - StringBuilder buf = new StringBuilder(100); + final StringBuilder buf = new StringBuilder(100); boolean first = true; - Enumeration<String> e = scopeStack.elements(); + final Enumeration<String> e = scopeStack.elements(); while(e.hasMoreElements()) { if(first) first = false; @@ -54,15 +54,15 @@ public class CSymbolTable { /** given a name for a type, append it with the current scope. */ - public String addCurrentScopeToName(String name) { - String currScope = currentScopeAsString(); + public String addCurrentScopeToName(final String name) { + final String currScope = currentScopeAsString(); return addScopeToName(currScope, name); } /** given a name for a type, append it with the given scope. MBZ */ - public String addScopeToName(String scope, String name) { + public String addScopeToName(final String scope, final String name) { if(scope == null || scope.length() > 0) return scope + "::" + name; else @@ -70,8 +70,8 @@ public class CSymbolTable { } /** remove one level of scope from name MBZ*/ - public String removeOneLevelScope(String scopeName) { - int index = scopeName.lastIndexOf("::"); + public String removeOneLevelScope(final String scopeName) { + final int index = scopeName.lastIndexOf("::"); if (index > 0) { return scopeName.substring(0,index); } @@ -83,13 +83,13 @@ public class CSymbolTable { /** add a node to the table with it's key as the current scope and the name */ - public TNode add(String name, TNode node) { + public TNode add(final String name, final TNode node) { return symTable.put(addCurrentScopeToName(name),node); } /** lookup a fully scoped name in the symbol table */ - public TNode lookupScopedName(String scopedName) { + public TNode lookupScopedName(final String scopedName) { return symTable.get(scopedName); } @@ -97,7 +97,7 @@ public class CSymbolTable { the current scope. MBZ -- if not found, pop scopes and look again */ - public TNode lookupNameInCurrentScope(String name) { + public TNode lookupNameInCurrentScope(final String name) { String scope = currentScopeAsString(); String scopedName; TNode tnode = null; @@ -116,11 +116,11 @@ public class CSymbolTable { /** convert this table to a string */ @Override public String toString() { - StringBuilder buff = new StringBuilder(300); + final StringBuilder buff = new StringBuilder(300); buff.append("CSymbolTable { \nCurrentScope: " + currentScopeAsString() + "\nDefinedSymbols:\n"); - Enumeration<String> ke = symTable.keys(); - Enumeration<TNode> ve = symTable.elements(); + final Enumeration<String> ke = symTable.keys(); + final Enumeration<TNode> ve = symTable.elements(); while(ke.hasMoreElements()) { buff.append(ke.nextElement().toString()); buff.append(" (").append(TNode.getNameForType(ve.nextElement().getType())).append(")\n"); diff --git a/src/java/com/jogamp/gluegen/cgram/CToken.java b/src/java/com/jogamp/gluegen/cgram/CToken.java index 78fc7f7..9e04c15 100644 --- a/src/java/com/jogamp/gluegen/cgram/CToken.java +++ b/src/java/com/jogamp/gluegen/cgram/CToken.java @@ -9,7 +9,7 @@ public class CToken extends antlr.CommonToken { return source; } - public void setSource(String src) + public void setSource(final String src) { source = src; } @@ -19,7 +19,7 @@ public class CToken extends antlr.CommonToken { return tokenNumber; } - public void setTokenNumber(int i) + public void setTokenNumber(final int i) { tokenNumber = i; } diff --git a/src/java/com/jogamp/gluegen/cgram/Define.java b/src/java/com/jogamp/gluegen/cgram/Define.java index 1b23346..797cf6f 100644 --- a/src/java/com/jogamp/gluegen/cgram/Define.java +++ b/src/java/com/jogamp/gluegen/cgram/Define.java @@ -43,10 +43,10 @@ package com.jogamp.gluegen.cgram; in string form.) */ public class Define { - private String name; - private String value; + private final String name; + private final String value; - public Define(String name, String value) { + public Define(final String name, final String value) { this.name = name; this.value = value; } diff --git a/src/java/com/jogamp/gluegen/cgram/LineObject.java b/src/java/com/jogamp/gluegen/cgram/LineObject.java index 31489fc..aee083f 100644 --- a/src/java/com/jogamp/gluegen/cgram/LineObject.java +++ b/src/java/com/jogamp/gluegen/cgram/LineObject.java @@ -14,7 +14,7 @@ class LineObject { super(); } - public LineObject( LineObject lobj ) + public LineObject( final LineObject lobj ) { parent = lobj.getParent(); source = lobj.getSource(); @@ -25,12 +25,12 @@ class LineObject { treatAsC = lobj.getTreatAsC(); } - public LineObject( String src) + public LineObject( final String src) { source = src; } - public void setSource(String src) + public void setSource(final String src) { source = src; } @@ -40,7 +40,7 @@ class LineObject { return source; } - public void setParent(LineObject par) + public void setParent(final LineObject par) { parent = par; } @@ -50,7 +50,7 @@ class LineObject { return parent; } - public void setLine(int l) + public void setLine(final int l) { line = l; } @@ -65,7 +65,7 @@ class LineObject { line++; } - public void setEnteringFile(boolean v) + public void setEnteringFile(final boolean v) { enteringFile = v; } @@ -75,7 +75,7 @@ class LineObject { return enteringFile; } - public void setReturningToFile(boolean v) + public void setReturningToFile(final boolean v) { returningToFile = v; } @@ -85,7 +85,7 @@ class LineObject { return returningToFile; } - public void setSystemHeader(boolean v) + public void setSystemHeader(final boolean v) { systemHeader = v; } @@ -95,7 +95,7 @@ class LineObject { return systemHeader; } - public void setTreatAsC(boolean v) + public void setTreatAsC(final boolean v) { treatAsC = v; } diff --git a/src/java/com/jogamp/gluegen/cgram/PreprocessorInfoChannel.java b/src/java/com/jogamp/gluegen/cgram/PreprocessorInfoChannel.java index 3bc8056..3ab565f 100644 --- a/src/java/com/jogamp/gluegen/cgram/PreprocessorInfoChannel.java +++ b/src/java/com/jogamp/gluegen/cgram/PreprocessorInfoChannel.java @@ -8,14 +8,14 @@ public class PreprocessorInfoChannel int firstValidTokenNumber = 0; int maxTokenNumber = 0; - public void addLineForTokenNumber( Object line, Integer toknum ) + public void addLineForTokenNumber( final Object line, final Integer toknum ) { if ( lineLists.containsKey( toknum ) ) { - Vector<Object> lines = lineLists.get( toknum ); + final Vector<Object> lines = lineLists.get( toknum ); lines.addElement(line); } else { - Vector<Object> lines = new Vector<Object>(); + final Vector<Object> lines = new Vector<Object>(); lines.addElement(line); lineLists.put(toknum, lines); if ( maxTokenNumber < toknum.intValue() ) { @@ -29,16 +29,16 @@ public class PreprocessorInfoChannel return maxTokenNumber; } - public Vector<Object> extractLinesPrecedingTokenNumber( Integer toknum ) + public Vector<Object> extractLinesPrecedingTokenNumber( final Integer toknum ) { - Vector<Object> lines = new Vector<Object>(); + final Vector<Object> lines = new Vector<Object>(); if (toknum == null) return lines; for (int i = firstValidTokenNumber; i < toknum.intValue(); i++){ - Integer inti = new Integer(i); + final Integer inti = new Integer(i); if ( lineLists.containsKey( inti ) ) { - Vector<Object> tokenLineVector = lineLists.get( inti ); + final Vector<Object> tokenLineVector = lineLists.get( inti ); if ( tokenLineVector != null) { - Enumeration<Object> tokenLines = tokenLineVector.elements(); + final Enumeration<Object> tokenLines = tokenLineVector.elements(); while ( tokenLines.hasMoreElements() ) { lines.addElement( tokenLines.nextElement() ); } @@ -53,13 +53,13 @@ public class PreprocessorInfoChannel @Override public String toString() { - StringBuilder sb = new StringBuilder("PreprocessorInfoChannel:\n"); + final StringBuilder sb = new StringBuilder("PreprocessorInfoChannel:\n"); for (int i = 0; i <= maxTokenNumber + 1; i++){ - Integer inti = new Integer(i); + final Integer inti = new Integer(i); if ( lineLists.containsKey( inti ) ) { - Vector<Object> tokenLineVector = lineLists.get( inti ); + final Vector<Object> tokenLineVector = lineLists.get( inti ); if ( tokenLineVector != null) { - Enumeration<Object> tokenLines = tokenLineVector.elements(); + final Enumeration<Object> tokenLines = tokenLineVector.elements(); while ( tokenLines.hasMoreElements() ) { sb.append(inti + ":" + tokenLines.nextElement() + '\n'); } diff --git a/src/java/com/jogamp/gluegen/cgram/TNode.java b/src/java/com/jogamp/gluegen/cgram/TNode.java index 2840d01..a564c54 100644 --- a/src/java/com/jogamp/gluegen/cgram/TNode.java +++ b/src/java/com/jogamp/gluegen/cgram/TNode.java @@ -46,14 +46,14 @@ public class TNode extends CommonAST { /** Set the token vocabulary to a tokentypes class generated by antlr. */ - public static void setTokenVocabulary(String s) { + public static void setTokenVocabulary(final String s) { tokenVocabulary = s; } @Override -public void initialize(Token token) { - CToken tok = (CToken) token; +public void initialize(final Token token) { + final CToken tok = (CToken) token; setText(tok.getText()); setType(tok.getType()); setLineNum(tok.getLine()); @@ -61,8 +61,8 @@ public void initialize(Token token) { setAttribute("tokenNumber", new Integer(tok.getTokenNumber())); } @Override -public void initialize(AST tr) { - TNode t = (TNode) tr; +public void initialize(final AST tr) { + final TNode t = (TNode) tr; setText(t.getText()); setType(t.getType()); setLineNum(t.getLineNum()); @@ -77,7 +77,7 @@ public void initialize(AST tr) { /** Set the token type for this node */ @Override - public void setType(int ttype_) { + public void setType(final int ttype_) { ttype = ttype_; } @@ -89,7 +89,7 @@ public void initialize(AST tr) { /** Set the marker value for this node. This property is a general-use boolean marker. */ - public void setMarker(boolean marker_) { + public void setMarker(final boolean marker_) { marker = marker_; } @@ -103,7 +103,7 @@ public void initialize(AST tr) { /** set an attribute in the attribute table. */ - public void setAttribute(String attrName, Object value) { + public void setAttribute(final String attrName, final Object value) { if(attributes == null) attributes = new Hashtable<String, Object>(7); attributes.put(attrName,value); @@ -112,7 +112,7 @@ public void initialize(AST tr) { /** lookup the attribute name in the attribute table. If the value does not exist, it returns null. */ - public Object getAttribute(String attrName) { + public Object getAttribute(final String attrName) { if(attributes == null) return null; else @@ -145,7 +145,7 @@ public void initialize(AST tr) { } /** Set the line number for this node */ - public void setLineNum(int lineNum_) { + public void setLineNum(final int lineNum_) { lineNum = lineNum_; } @@ -155,13 +155,13 @@ public void initialize(AST tr) { /** Set the token text for this node */ @Override - public void setText(String text_) { + public void setText(final String text_) { text = text_; } /** Returns the text for this node and all children */ public String getAllChildrenText() { - StringBuilder buf = new StringBuilder(); + final StringBuilder buf = new StringBuilder(); buf.append(getText()); for (TNode node = (TNode) getFirstChild(); node != null; node = (TNode) node.getNextSibling()) { buf.append(node.getText()); @@ -171,7 +171,7 @@ public void initialize(AST tr) { /** return the last child of this node, or null if there is none */ public TNode getLastChild() { - TNode down = (TNode)getFirstChild(); + final TNode down = (TNode)getFirstChild(); if(down != null) return down.getLastSibling(); else @@ -181,7 +181,7 @@ public void initialize(AST tr) { /** return the last sibling of this node, which is this if the next sibling is null */ public TNode getLastSibling() { - TNode next = (TNode)getNextSibling(); + final TNode next = (TNode)getNextSibling(); if(next != null) return next.getLastSibling(); else @@ -191,7 +191,7 @@ public void initialize(AST tr) { /** return the first sibling of this node, which is this if the prev sibling is null */ public TNode getFirstSibling() { - TNode prev = left; + final TNode prev = left; if(prev != null) return prev.getFirstSibling(); else @@ -210,12 +210,12 @@ public void initialize(AST tr) { if node is null, nothing happens. If the node has siblings, then they are added in as well. */ - public void addSibling(AST node) { + public void addSibling(final AST node) { if(node == null) return; - TNode next = (TNode)right; + final TNode next = (TNode)right; right = (TNode)node; ((TNode)node).left = this; - TNode nodeLastSib = ((TNode)node).getLastSibling(); + final TNode nodeLastSib = ((TNode)node).getLastSibling(); nodeLastSib.right = next; if(next != null) next.left = nodeLastSib; @@ -237,9 +237,9 @@ public void initialize(AST tr) { /** remove this node from the tree, resetting sibling and parent pointers as necessary. This method maintains double-linking */ public void removeSelf() { - TNode parent = up; - TNode prev = left; - TNode next = (TNode)right; + final TNode parent = up; + final TNode prev = left; + final TNode next = (TNode)right; if(parent != null) { parent.down = next; @@ -263,7 +263,7 @@ public void initialize(AST tr) { } /** set the def node for this node */ - public void setDefNode(TNode n) { + public void setDefNode(final TNode n) { defNode = n; } @@ -273,7 +273,7 @@ public void initialize(AST tr) { Marker value is not copied! */ public TNode deepCopy() { - TNode copy = new TNode(); + final TNode copy = new TNode(); copy.ttype = ttype; copy.text = text; copy.lineNum = lineNum; @@ -292,7 +292,7 @@ public void initialize(AST tr) { New tree is doubleLinked, with no parent or left siblings. defNode is not copied */ public TNode deepCopyWithRightSiblings() { - TNode copy = new TNode(); + final TNode copy = new TNode(); copy.ttype = ttype; copy.text = text; copy.lineNum = lineNum; @@ -311,15 +311,15 @@ public void initialize(AST tr) { /** return a short string representation of the node */ @Override public String toString() { - StringBuilder str = new StringBuilder( getNameForType(getType()) + + final StringBuilder str = new StringBuilder( getNameForType(getType()) + "[" + getText() + ", " + "]"); if(this.getLineNum() != 0) str.append(" line:" + (this.getLineNum() ) ); - Enumeration<String> keys = (this.getAttributesTable().keys()); + final Enumeration<String> keys = (this.getAttributesTable().keys()); while (keys.hasMoreElements()) { - String key = keys.nextElement(); + final String key = keys.nextElement(); str.append(" " + key + ":" + (this.getAttribute(key))); } @@ -328,7 +328,7 @@ public void initialize(AST tr) { /** print given tree to System.out */ - public static void printTree(AST t) { + public static void printTree(final AST t) { if (t == null) return; printASTNode(t,0); System.out.print("\n"); @@ -336,7 +336,7 @@ public void initialize(AST tr) { /** protected method that does the work of printing */ - protected static void printASTNode(AST t, int indent) { + protected static void printASTNode(final AST t, final int indent) { AST child1, next; child1 = t.getFirstChild(); @@ -347,7 +347,7 @@ public void initialize(AST tr) { if(child1 != null) System.out.print("("); - String s = t.getText(); + final String s = t.getText(); if(s != null && s.length() > 0) { System.out.print(getNameForType(t.getType())); System.out.print(": \"" + s + "\""); @@ -357,12 +357,12 @@ public void initialize(AST tr) { if(((TNode)t).getLineNum() != 0) System.out.print(" line:" + ((TNode)t).getLineNum() ); - Enumeration<String> keys = ((TNode)t).getAttributesTable().keys(); + final Enumeration<String> keys = ((TNode)t).getAttributesTable().keys(); while (keys.hasMoreElements()) { - String key = keys.nextElement(); + final String key = keys.nextElement(); System.out.print(" " + key + ":" + ((TNode)t).getAttribute(key)); } - TNode def = ((TNode)t).getDefNode(); + final TNode def = ((TNode)t).getDefNode(); if(def != null) System.out.print("[" + getNameForType(def.getType()) + "]"); @@ -385,13 +385,13 @@ public void initialize(AST tr) { /** converts an int tree token type to a name. Does this by reflecting on nsdidl.IDLTreeTokenTypes, and is dependent on how ANTLR 2.00 outputs that class. */ - public static String getNameForType(int t) { + public static String getNameForType(final int t) { try{ - Class<?> c = Class.forName(tokenVocabulary); - Field[] fields = c.getDeclaredFields(); + final Class<?> c = Class.forName(tokenVocabulary); + final Field[] fields = c.getDeclaredFields(); if(t-2 < fields.length) return fields[t-2].getName(); - } catch (Exception e) { System.out.println(e); } + } catch (final Exception e) { System.out.println(e); } return "unfoundtype: " + t; } @@ -399,12 +399,12 @@ public void initialize(AST tr) { /** set up reverse links between this node and its first child and its first sibling, and link those as well */ public void doubleLink() { - TNode right = (TNode)getNextSibling(); + final TNode right = (TNode)getNextSibling(); if(right != null) { right.left = this; right.doubleLink(); } - TNode down = (TNode)getFirstChild(); + final TNode down = (TNode)getFirstChild(); if(down != null) { down.up = this; down.doubleLink(); @@ -413,7 +413,7 @@ public void initialize(AST tr) { /** find first parent of the given type, return null on failure */ - public TNode parentOfType(int type) { + public TNode parentOfType(final int type) { if(up == null) { if(left == null) return null; @@ -427,8 +427,8 @@ public void initialize(AST tr) { /** find the first child of the node of the given type, return null on failure */ - public TNode firstChildOfType(int type) { - TNode down = (TNode)getFirstChild(); + public TNode firstChildOfType(final int type) { + final TNode down = (TNode)getFirstChild(); if(down == null) return null; if(down.getType() == type) @@ -438,8 +438,8 @@ public void initialize(AST tr) { /** find the first sibling of the node of the given type, return null on failure */ - public TNode firstSiblingOfType(int type) { - TNode right = (TNode)getNextSibling(); + public TNode firstSiblingOfType(final int type) { + final TNode right = (TNode)getNextSibling(); if(right == null) return null; if(right.getType() == type) diff --git a/src/java/com/jogamp/gluegen/cgram/TNodeFactory.java b/src/java/com/jogamp/gluegen/cgram/TNodeFactory.java index ff2f1b0..f964438 100644 --- a/src/java/com/jogamp/gluegen/cgram/TNodeFactory.java +++ b/src/java/com/jogamp/gluegen/cgram/TNodeFactory.java @@ -15,8 +15,8 @@ public class TNodeFactory extends ASTFactory { /** Create a new AST node from type and text */ @Override - public AST create(int ttype, String text) { - AST ast = new TNode(); + public AST create(final int ttype, final String text) { + final AST ast = new TNode(); ast.setType(ttype); ast.setText(text); return ast; @@ -24,8 +24,8 @@ public class TNodeFactory extends ASTFactory { /** Create a new AST node from an existing AST node */ @Override - public AST create(AST ast) { - AST newast = new TNode(); + public AST create(final AST ast) { + final AST newast = new TNode(); newast.setType(ast.getType()); newast.setText(ast.getText()); return newast; diff --git a/src/java/com/jogamp/gluegen/cgram/types/ArrayType.java b/src/java/com/jogamp/gluegen/cgram/types/ArrayType.java index 401944b..d867b40 100644 --- a/src/java/com/jogamp/gluegen/cgram/types/ArrayType.java +++ b/src/java/com/jogamp/gluegen/cgram/types/ArrayType.java @@ -50,24 +50,24 @@ public class ArrayType extends MemoryLayoutType implements Cloneable { private final int length; private String computedName; - public ArrayType(Type elementType, SizeThunk sizeInBytes, int length, int cvAttributes) { + public ArrayType(final Type elementType, final SizeThunk sizeInBytes, final int length, final int cvAttributes) { super(elementType.getName() + " *", sizeInBytes, cvAttributes); this.elementType = elementType; this.length = length; } @Override - public boolean equals(Object arg) { + public boolean equals(final Object arg) { if (arg == this) return true; if (arg == null || (!(arg instanceof ArrayType))) { return false; } - ArrayType t = (ArrayType) arg; + final ArrayType t = (ArrayType) arg; return (super.equals(arg) && elementType.equals(t.elementType) && (length == t.length)); } @Override - public String getName(boolean includeCVAttrs) { + public String getName(final boolean includeCVAttrs) { // Lazy computation of name due to lazy setting of compound type // names during parsing // Note: don't think cvAttributes can be set for array types (unlike pointer types) @@ -97,7 +97,7 @@ public class ArrayType extends MemoryLayoutType implements Cloneable { /** Recompute the size of this array if necessary. This needs to be done when the base element type is a compound type after layouting. */ void recomputeSize() { - ArrayType arrayElementType = getElementType().asArray(); + final ArrayType arrayElementType = getElementType().asArray(); if (arrayElementType != null) { arrayElementType.recomputeSize(); } @@ -109,8 +109,8 @@ public class ArrayType extends MemoryLayoutType implements Cloneable { return toString(null); } - public String toString(String variableName) { - StringBuilder buf = new StringBuilder(); + public String toString(final String variableName) { + final StringBuilder buf = new StringBuilder(); if(elementType.isConst()) { buf.append("const "); } @@ -126,13 +126,13 @@ public class ArrayType extends MemoryLayoutType implements Cloneable { } @Override - public void visit(TypeVisitor arg) { + public void visit(final TypeVisitor arg) { super.visit(arg); elementType.visit(arg); } @Override - Type newCVVariant(int cvAttributes) { + Type newCVVariant(final int cvAttributes) { return new ArrayType(elementType, getSize(), length, cvAttributes); } } diff --git a/src/java/com/jogamp/gluegen/cgram/types/BitType.java b/src/java/com/jogamp/gluegen/cgram/types/BitType.java index 4862749..2644551 100644 --- a/src/java/com/jogamp/gluegen/cgram/types/BitType.java +++ b/src/java/com/jogamp/gluegen/cgram/types/BitType.java @@ -43,11 +43,11 @@ package com.jogamp.gluegen.cgram.types; /** Represents a bitfield in a struct. */ public class BitType extends IntType implements Cloneable { - private IntType underlyingType; - private int sizeInBits; - private int offset; + private final IntType underlyingType; + private final int sizeInBits; + private final int offset; - public BitType(IntType underlyingType, int sizeInBits, int lsbOffset, int cvAttributes) { + public BitType(final IntType underlyingType, final int sizeInBits, final int lsbOffset, final int cvAttributes) { super(underlyingType.getName(), underlyingType.getSize(), underlyingType.isUnsigned(), cvAttributes); this.underlyingType = underlyingType; this.sizeInBits = sizeInBits; @@ -55,12 +55,12 @@ public class BitType extends IntType implements Cloneable { } @Override - public boolean equals(Object arg) { + public boolean equals(final Object arg) { if (arg == this) return true; if (arg == null || (!(arg instanceof BitType))) { return false; } - BitType t = (BitType) arg; + final BitType t = (BitType) arg; return (super.equals(arg) && underlyingType.equals(t.underlyingType) && (sizeInBits == t.sizeInBits) && (offset == t.offset)); } @@ -80,13 +80,13 @@ public class BitType extends IntType implements Cloneable { } @Override - public void visit(TypeVisitor arg) { + public void visit(final TypeVisitor arg) { super.visit(arg); underlyingType.visit(arg); } @Override - Type newCVVariant(int cvAttributes) { + Type newCVVariant(final int cvAttributes) { return new BitType(underlyingType, sizeInBits, offset, cvAttributes); } } diff --git a/src/java/com/jogamp/gluegen/cgram/types/CompoundType.java b/src/java/com/jogamp/gluegen/cgram/types/CompoundType.java index 803cb50..9716f54 100644 --- a/src/java/com/jogamp/gluegen/cgram/types/CompoundType.java +++ b/src/java/com/jogamp/gluegen/cgram/types/CompoundType.java @@ -55,12 +55,12 @@ public abstract class CompoundType extends MemoryLayoutType implements Cloneable private boolean computedHashcode; private int hashcode; - CompoundType(String name, SizeThunk size, int cvAttributes, String structName) { + CompoundType(final String name, final SizeThunk size, final int cvAttributes, final String structName) { super(name, size, cvAttributes); this.structName = structName; } - public static CompoundType create(String name, SizeThunk size, CompoundTypeKind kind, int cvAttributes) { + public static CompoundType create(final String name, final SizeThunk size, final CompoundTypeKind kind, final int cvAttributes) { switch (kind) { case STRUCT: return new StructType(name, size, cvAttributes); @@ -73,7 +73,7 @@ public abstract class CompoundType extends MemoryLayoutType implements Cloneable @Override public Object clone() { - CompoundType n = (CompoundType) super.clone(); + final CompoundType n = (CompoundType) super.clone(); if(null!=this.fields) { n.fields = new ArrayList<Field>(this.fields); } @@ -99,12 +99,12 @@ public abstract class CompoundType extends MemoryLayoutType implements Cloneable } @Override - public boolean equals(Object arg) { + public boolean equals(final Object arg) { if (arg == this) return true; if (arg == null || !(arg instanceof CompoundType)) { return false; } - CompoundType t = (CompoundType) arg; + final CompoundType t = (CompoundType) arg; return super.equals(arg) && ((structName == null ? t.structName == null : structName.equals(t.structName)) || (structName != null && structName.equals(t.structName))) && @@ -119,12 +119,12 @@ public abstract class CompoundType extends MemoryLayoutType implements Cloneable /** Sets the struct name of this CompoundType, i.e. the "foo" in the construct "struct foo { ... };". */ - public void setStructName(String structName) { + public void setStructName(final String structName) { this.structName = structName; } @Override - public void setSize(SizeThunk size) { + public void setSize(final SizeThunk size) { super.setSize(size); } @@ -132,7 +132,7 @@ public abstract class CompoundType extends MemoryLayoutType implements Cloneable public CompoundType asCompound() { return this; } ArrayList<Field> getFields() { return fields; } - void setFields(ArrayList<Field> fields) { this.fields = fields; } + void setFields(final ArrayList<Field> fields) { this.fields = fields; } /** Returns the number of fields in this type. */ public int getNumFields() { @@ -140,12 +140,12 @@ public abstract class CompoundType extends MemoryLayoutType implements Cloneable } /** Returns the <i>i</i>th field of this type. */ - public Field getField(int i) { + public Field getField(final int i) { return fields.get(i); } /** Adds a field to this type. */ - public void addField(Field f) { + public void addField(final Field f) { if (bodyParsed) { throw new RuntimeException("Body of this CompoundType has already been parsed; should not be adding more fields"); } @@ -168,7 +168,7 @@ public abstract class CompoundType extends MemoryLayoutType implements Cloneable @Override public String toString() { - String cvAttributesString = getCVAttributesString(); + final String cvAttributesString = getCVAttributesString(); if (getName() != null) { return cvAttributesString + getName(); } else if (getStructName() != null) { @@ -179,16 +179,16 @@ public abstract class CompoundType extends MemoryLayoutType implements Cloneable } @Override - public void visit(TypeVisitor arg) { + public void visit(final TypeVisitor arg) { if (visiting) { return; } try { visiting = true; super.visit(arg); - int n = getNumFields(); + final int n = getNumFields(); for (int i = 0; i < n; i++) { - Field f = getField(i); + final Field f = getField(i); f.getType().visit(arg); } } finally { @@ -206,10 +206,10 @@ public abstract class CompoundType extends MemoryLayoutType implements Cloneable try { visiting = true; - String kind = (isStruct() ? "struct {" : "union {"); - StringBuilder res = new StringBuilder(); + final String kind = (isStruct() ? "struct {" : "union {"); + final StringBuilder res = new StringBuilder(); res.append(kind); - int n = getNumFields(); + final int n = getNumFields(); for (int i = 0; i < n; i++) { res.append(" "); res.append(getField(i)); diff --git a/src/java/com/jogamp/gluegen/cgram/types/CompoundTypeKind.java b/src/java/com/jogamp/gluegen/cgram/types/CompoundTypeKind.java index 62d8d42..d218bb4 100644 --- a/src/java/com/jogamp/gluegen/cgram/types/CompoundTypeKind.java +++ b/src/java/com/jogamp/gluegen/cgram/types/CompoundTypeKind.java @@ -35,7 +35,7 @@ public enum CompoundTypeKind { public final int id; - CompoundTypeKind(int id){ + CompoundTypeKind(final int id){ this.id = id; } } diff --git a/src/java/com/jogamp/gluegen/cgram/types/DoubleType.java b/src/java/com/jogamp/gluegen/cgram/types/DoubleType.java index 278b3d8..de42522 100644 --- a/src/java/com/jogamp/gluegen/cgram/types/DoubleType.java +++ b/src/java/com/jogamp/gluegen/cgram/types/DoubleType.java @@ -42,12 +42,12 @@ package com.jogamp.gluegen.cgram.types; /** Represents a double-word floating-point type (C type "double".) */ public class DoubleType extends PrimitiveType implements Cloneable { - public DoubleType(String name, SizeThunk size, int cvAttributes) { + public DoubleType(final String name, final SizeThunk size, final int cvAttributes) { super(name, size, cvAttributes); } @Override - public boolean equals(Object arg) { + public boolean equals(final Object arg) { if (arg == this) { return true; } @@ -63,7 +63,7 @@ public class DoubleType extends PrimitiveType implements Cloneable { } @Override - Type newCVVariant(int cvAttributes) { + Type newCVVariant(final int cvAttributes) { return new DoubleType(getName(), getSize(), cvAttributes); } } diff --git a/src/java/com/jogamp/gluegen/cgram/types/EnumType.java b/src/java/com/jogamp/gluegen/cgram/types/EnumType.java index d02388b..0b1193b 100644 --- a/src/java/com/jogamp/gluegen/cgram/types/EnumType.java +++ b/src/java/com/jogamp/gluegen/cgram/types/EnumType.java @@ -54,7 +54,7 @@ public class EnumType extends IntType implements Cloneable { String name; long value; - Enum(String name, long value) { + Enum(final String name, final long value) { this.name = name; this.value = value; } @@ -70,24 +70,24 @@ public class EnumType extends IntType implements Cloneable { private ArrayList<Enum> enums; - public EnumType(String name) { + public EnumType(final String name) { super(name, SizeThunk.LONG, false, CVAttributes.CONST); this.underlyingType = new IntType(name, SizeThunk.LONG, false, CVAttributes.CONST); } - public EnumType(String name, SizeThunk enumSizeInBytes) { + public EnumType(final String name, final SizeThunk enumSizeInBytes) { super(name, enumSizeInBytes, false, CVAttributes.CONST); this.underlyingType = new IntType(name, enumSizeInBytes, false, CVAttributes.CONST); } - protected EnumType(String name, IntType underlyingType, int cvAttributes) { + protected EnumType(final String name, final IntType underlyingType, final int cvAttributes) { super(name, underlyingType.getSize(), underlyingType.isUnsigned(), cvAttributes); this.underlyingType = underlyingType; } @Override public Object clone() { - EnumType n = (EnumType) super.clone(); + final EnumType n = (EnumType) super.clone(); if(null!=this.underlyingType) { n.underlyingType = (IntType) this.underlyingType.clone(); } @@ -98,14 +98,14 @@ public class EnumType extends IntType implements Cloneable { } @Override - public boolean equals(Object arg) { + public boolean equals(final Object arg) { if (arg == this) { return true; } if (arg == null || (!(arg instanceof EnumType))) { return false; } - EnumType t = (EnumType) arg; + final EnumType t = (EnumType) arg; return (super.equals(arg) && underlyingType.equals(t.underlyingType) && listsEqual(enums, t.enums)); @@ -116,7 +116,7 @@ public class EnumType extends IntType implements Cloneable { return this; } - public void addEnum(String name, long val) { + public void addEnum(final String name, final long val) { if (enums == null) { enums = new ArrayList<Enum>(); } @@ -129,19 +129,19 @@ public class EnumType extends IntType implements Cloneable { } /** Fetch <i>i</i>th (0..getNumEnumerates() - 1) name */ - public String getEnumName(int i) { + public String getEnumName(final int i) { return (enums.get(i)).getName(); } /** Fetch <i>i</i>th (0..getNumEnumerates() - 1) value */ - public long getEnumValue(int i) { + public long getEnumValue(final int i) { return (enums.get(i)).getValue(); } /** Fetch the value of the enumerate with the given name. */ - public long getEnumValue(String name) { + public long getEnumValue(final String name) { for (int i = 0; i < enums.size(); ++i) { - Enum n = (enums.get(i)); + final Enum n = (enums.get(i)); if (n.getName().equals(name)) { return n.getValue(); } @@ -152,7 +152,7 @@ public class EnumType extends IntType implements Cloneable { } /** Does this enum type contain an enumerate with the given name? */ - public boolean containsEnumerate(String name) { + public boolean containsEnumerate(final String name) { for (int i = 0; i < enums.size(); ++i) { if ((enums.get(i)).getName().equals(name)) { return true; @@ -164,9 +164,9 @@ public class EnumType extends IntType implements Cloneable { /** Remove the enumerate with the given name. Returns true if it was found * and removed; false if it was not found. */ - public boolean removeEnumerate(String name) { + public boolean removeEnumerate(final String name) { for (int i = 0; i < enums.size(); ++i) { - Enum e = enums.get(i); + final Enum e = enums.get(i); if (e.getName().equals(name)) { enums.remove(e); return true; @@ -176,14 +176,14 @@ public class EnumType extends IntType implements Cloneable { } @Override - public void visit(TypeVisitor arg) { + public void visit(final TypeVisitor arg) { super.visit(arg); underlyingType.visit(arg); } @Override - Type newCVVariant(int cvAttributes) { - EnumType t = new EnumType(getName(), underlyingType, cvAttributes); + Type newCVVariant(final int cvAttributes) { + final EnumType t = new EnumType(getName(), underlyingType, cvAttributes); t.enums = enums; return t; } diff --git a/src/java/com/jogamp/gluegen/cgram/types/Field.java b/src/java/com/jogamp/gluegen/cgram/types/Field.java index 1c4b4fa..afaeade 100644 --- a/src/java/com/jogamp/gluegen/cgram/types/Field.java +++ b/src/java/com/jogamp/gluegen/cgram/types/Field.java @@ -44,11 +44,11 @@ import com.jogamp.common.os.MachineDescription; /** Represents a field in a struct or union. */ public class Field { - private String name; - private Type type; + private final String name; + private final Type type; private SizeThunk offset; - public Field(String name, Type type, SizeThunk offset) { + public Field(final String name, final Type type, final SizeThunk offset) { this.name = name; this.type = type; this.offset = offset; @@ -60,12 +60,12 @@ public class Field { } @Override - public boolean equals(Object arg) { + public boolean equals(final Object arg) { if (arg == null || (!(arg instanceof Field))) { return false; } - Field f = (Field) arg; + final Field f = (Field) arg; // Note: don't know how to examine offset any more since it's // implemented in terms of code and they're not canonicalized return (((name != null && name.equals(f.name)) || @@ -84,10 +84,10 @@ public class Field { /** Offset, in bytes, of this field in the containing data structure given the specified MachineDescription. */ - public long getOffset(MachineDescription machDesc) { return offset.computeSize(machDesc); } + public long getOffset(final MachineDescription machDesc) { return offset.computeSize(machDesc); } /** Sets the offset of this field in the containing data structure. */ - public void setOffset(SizeThunk offset) { this.offset = offset; } + public void setOffset(final SizeThunk offset) { this.offset = offset; } @Override public String toString() { @@ -99,7 +99,7 @@ public class Field { } return "" + getType() + " " + getName() + ";"; } else { - FunctionType ft = getType().asPointer().getTargetType().asFunction(); + final FunctionType ft = getType().asPointer().getTargetType().asFunction(); // FIXME: pick up calling convention? return ft.toString(getName(), null, false, true) + ";"; } diff --git a/src/java/com/jogamp/gluegen/cgram/types/FloatType.java b/src/java/com/jogamp/gluegen/cgram/types/FloatType.java index ef1b4b9..d8b0b13 100644 --- a/src/java/com/jogamp/gluegen/cgram/types/FloatType.java +++ b/src/java/com/jogamp/gluegen/cgram/types/FloatType.java @@ -43,12 +43,12 @@ package com.jogamp.gluegen.cgram.types; /** Represents a single-word floating-point type (C type "float".) */ public class FloatType extends PrimitiveType implements Cloneable { - public FloatType(String name, SizeThunk size, int cvAttributes) { + public FloatType(final String name, final SizeThunk size, final int cvAttributes) { super(name, size, cvAttributes); } @Override - public boolean equals(Object arg) { + public boolean equals(final Object arg) { if (arg == this) { return true; } @@ -62,7 +62,7 @@ public class FloatType extends PrimitiveType implements Cloneable { public FloatType asFloat() { return this; } @Override - Type newCVVariant(int cvAttributes) { + Type newCVVariant(final int cvAttributes) { return new FloatType(getName(), getSize(), cvAttributes); } } diff --git a/src/java/com/jogamp/gluegen/cgram/types/FunctionSymbol.java b/src/java/com/jogamp/gluegen/cgram/types/FunctionSymbol.java index c4802e7..d41f2fd 100644 --- a/src/java/com/jogamp/gluegen/cgram/types/FunctionSymbol.java +++ b/src/java/com/jogamp/gluegen/cgram/types/FunctionSymbol.java @@ -53,10 +53,10 @@ package com.jogamp.gluegen.cgram.types; **/ public class FunctionSymbol { - private String name; - private FunctionType type; + private final String name; + private final FunctionType type; - public FunctionSymbol(String name, FunctionType type) { + public FunctionSymbol(final String name, final FunctionType type) { this.name = name; this.type = type; } @@ -82,18 +82,18 @@ public class FunctionSymbol { /** Returns the name of the <i>i</i>th argument. May return null if no argument names were available during parsing. */ - public String getArgumentName(int i) { + public String getArgumentName(final int i) { return type.getArgumentName(i); } /** Returns the type of the <i>i</i>th argument. */ - public Type getArgumentType(int i) { + public Type getArgumentType(final int i) { return type.getArgumentType(i); } /** Add an argument's name and type. Use null for unknown argument names. */ - public void addArgument(Type argumentType, String argumentName) { + public void addArgument(final Type argumentType, final String argumentName) { type.addArgument(argumentType, argumentName); } @@ -103,7 +103,7 @@ public class FunctionSymbol { } /** Helper routine for emitting native javadoc tags */ - public String toString(boolean emitNativeTag) { + public String toString(final boolean emitNativeTag) { return getType().toString(getName(), emitNativeTag); } @@ -116,7 +116,7 @@ public class FunctionSymbol { } @Override - public boolean equals(Object arg) { + public boolean equals(final Object arg) { if (arg == this) { return true; } @@ -138,7 +138,7 @@ public class FunctionSymbol { * Compares the function type as well, since {@link #equals(Object)} * and {@link #hashCode()} won't. */ - public boolean isCompletelyEqual(Object arg) { + public boolean isCompletelyEqual(final Object arg) { if( !this.equals(arg) ) { return false; } diff --git a/src/java/com/jogamp/gluegen/cgram/types/FunctionType.java b/src/java/com/jogamp/gluegen/cgram/types/FunctionType.java index 7672744..4b39a34 100644 --- a/src/java/com/jogamp/gluegen/cgram/types/FunctionType.java +++ b/src/java/com/jogamp/gluegen/cgram/types/FunctionType.java @@ -49,14 +49,14 @@ public class FunctionType extends Type implements Cloneable { private ArrayList<Type> argumentTypes; private ArrayList<String> argumentNames; - public FunctionType(String name, SizeThunk size, Type returnType, int cvAttributes) { + public FunctionType(final String name, final SizeThunk size, final Type returnType, final int cvAttributes) { super(name, size, cvAttributes); this.returnType = returnType; } @Override public Object clone() { - FunctionType n = (FunctionType) super.clone(); + final FunctionType n = (FunctionType) super.clone(); if(null!=this.argumentTypes) { n.argumentTypes = new ArrayList<Type>(this.argumentTypes); } @@ -67,14 +67,14 @@ public class FunctionType extends Type implements Cloneable { } @Override - public boolean equals(Object arg) { + public boolean equals(final Object arg) { if (arg == this) { return true; } if (arg == null || (!(arg instanceof FunctionType))) { return false; } - FunctionType t = (FunctionType) arg; + final FunctionType t = (FunctionType) arg; return (super.equals(arg) && returnType.equals(t.returnType) && listsEqual(argumentTypes, t.argumentTypes)); @@ -96,19 +96,19 @@ public class FunctionType extends Type implements Cloneable { /** Returns the name of the <i>i</i>th argument. May return null if no argument names were available during parsing. */ - public String getArgumentName(int i) { + public String getArgumentName(final int i) { return argumentNames.get(i); } /** Returns the type of the <i>i</i>th argument. */ - public Type getArgumentType(int i) { + public Type getArgumentType(final int i) { return argumentTypes.get(i); } /** * Add an argument's name and type. Use null for unknown argument names. */ - public void addArgument(Type argumentType, String argumentName) { + public void addArgument(final Type argumentType, final String argumentName) { if (argumentTypes == null) { argumentTypes = new ArrayList<Type>(); argumentNames = new ArrayList<String>(); @@ -117,7 +117,7 @@ public class FunctionType extends Type implements Cloneable { argumentNames.add(argumentName); } - public void setArgumentName(int i, String name) { + public void setArgumentName(final int i, final String name) { argumentNames.set(i, name); } @@ -159,18 +159,18 @@ public class FunctionType extends Type implements Cloneable { res.append(")"); } res.append("("); - int n = getNumArguments(); + final int n = getNumArguments(); for (int i = 0; i < n; i++) { - Type t = getArgumentType(i); + final Type t = getArgumentType(i); if (t.isFunctionPointer()) { - Type targetType = t.asPointer().getTargetType(); - FunctionType ft = targetType.asFunction(); + final Type targetType = t.asPointer().getTargetType(); + final FunctionType ft = targetType.asFunction(); res.append(ft.toString(getArgumentName(i), callingConvention, false, true)); } else if (t.isArray()) { res.append(t.asArray().toString(getArgumentName(i))); } else { res.append(t); - String argumentName = getArgumentName(i); + final String argumentName = getArgumentName(i); if (argumentName != null) { res.append(" "); res.append(argumentName); @@ -185,17 +185,17 @@ public class FunctionType extends Type implements Cloneable { } @Override - public void visit(TypeVisitor arg) { + public void visit(final TypeVisitor arg) { super.visit(arg); returnType.visit(arg); - int n = getNumArguments(); + final int n = getNumArguments(); for (int i = 0; i < n; i++) { getArgumentType(i).visit(arg); } } @Override - Type newCVVariant(int cvAttributes) { + Type newCVVariant(final int cvAttributes) { // Functions don't have const/volatile attributes return this; } diff --git a/src/java/com/jogamp/gluegen/cgram/types/IntType.java b/src/java/com/jogamp/gluegen/cgram/types/IntType.java index 6eeb997..3f8dddc 100644 --- a/src/java/com/jogamp/gluegen/cgram/types/IntType.java +++ b/src/java/com/jogamp/gluegen/cgram/types/IntType.java @@ -41,33 +41,33 @@ package com.jogamp.gluegen.cgram.types; public class IntType extends PrimitiveType implements Cloneable { - private boolean unsigned; + private final boolean unsigned; private boolean typedefedUnsigned; - public IntType(String name, SizeThunk size, boolean unsigned, int cvAttributes) { + public IntType(final String name, final SizeThunk size, final boolean unsigned, final int cvAttributes) { this(name, size, unsigned, cvAttributes, false); } - public IntType(String name, SizeThunk size, boolean unsigned, int cvAttributes, boolean typedefedUnsigned) { + public IntType(final String name, final SizeThunk size, final boolean unsigned, final int cvAttributes, final boolean typedefedUnsigned) { super(name, size, cvAttributes); this.unsigned = unsigned; this.typedefedUnsigned = typedefedUnsigned; } @Override - public boolean equals(Object arg) { + public boolean equals(final Object arg) { if (arg == this) { return true; } if (arg == null || (!(arg instanceof IntType))) { return false; } - IntType t = (IntType) arg; + final IntType t = (IntType) arg; return (super.equals(arg) && (unsigned == t.unsigned)); } @Override - public void setName(String name) { + public void setName(final String name) { super.setName(name); typedefedUnsigned = unsigned; } @@ -93,7 +93,7 @@ public class IntType extends PrimitiveType implements Cloneable { } @Override - Type newCVVariant(int cvAttributes) { + Type newCVVariant(final int cvAttributes) { return new IntType(getName(), getSize(), isUnsigned(), cvAttributes, typedefedUnsigned); } } diff --git a/src/java/com/jogamp/gluegen/cgram/types/MemoryLayoutType.java b/src/java/com/jogamp/gluegen/cgram/types/MemoryLayoutType.java index df0d23e..25d2d1d 100644 --- a/src/java/com/jogamp/gluegen/cgram/types/MemoryLayoutType.java +++ b/src/java/com/jogamp/gluegen/cgram/types/MemoryLayoutType.java @@ -30,7 +30,7 @@ package com.jogamp.gluegen.cgram.types; public abstract class MemoryLayoutType extends Type { private boolean isLayouted; - protected MemoryLayoutType(String name, SizeThunk size, int cvAttributes) { + protected MemoryLayoutType(final String name, final SizeThunk size, final int cvAttributes) { super(name, size, cvAttributes); isLayouted = false; } diff --git a/src/java/com/jogamp/gluegen/cgram/types/PointerType.java b/src/java/com/jogamp/gluegen/cgram/types/PointerType.java index 5f19202..d1dfb17 100644 --- a/src/java/com/jogamp/gluegen/cgram/types/PointerType.java +++ b/src/java/com/jogamp/gluegen/cgram/types/PointerType.java @@ -45,13 +45,13 @@ public class PointerType extends Type implements Cloneable { private String computedName; private boolean hasTypedefedName; - public PointerType(SizeThunk size, Type targetType, int cvAttributes) { + public PointerType(final SizeThunk size, final Type targetType, final int cvAttributes) { // can pass null for the final name parameter because the PointerType's getName() // completely replaces superclass behavior this(size, targetType, cvAttributes, false, null); } - private PointerType(SizeThunk size, Type targetType, int cvAttributes, boolean hasTypedefedName, String typedefedName) { + private PointerType(final SizeThunk size, final Type targetType, final int cvAttributes, final boolean hasTypedefedName, final String typedefedName) { super(targetType.getName() + " *", size, cvAttributes); this.hasTypedefedName = false; this.targetType = targetType; @@ -66,14 +66,14 @@ public class PointerType extends Type implements Cloneable { } @Override - public boolean equals(Object arg) { + public boolean equals(final Object arg) { if (arg == this) { return true; } if (arg == null || (!(arg instanceof PointerType))) { return false; } - PointerType t = (PointerType) arg; + final PointerType t = (PointerType) arg; // Note we ignore the name of this type (which might be a typedef // name) for comparison purposes because this is what allows // e.g. a newly-fabricated type "PIXELFORMATDESCRIPTOR *" to be @@ -84,13 +84,13 @@ public class PointerType extends Type implements Cloneable { } @Override - public void setName(String name) { + public void setName(final String name) { super.setName(name); hasTypedefedName = true; } @Override - public String getName(boolean includeCVAttrs) { + public String getName(final boolean includeCVAttrs) { if (hasTypedefedName) { return super.getName(includeCVAttrs); } else { @@ -150,7 +150,7 @@ public class PointerType extends Type implements Cloneable { /** For use only when printing function pointers. Calling convention string (i.e., "__stdcall") is optional and is generally only needed on Windows. */ - public String toString(String functionName, String callingConvention) { + public String toString(final String functionName, final String callingConvention) { if (!targetType.isFunction()) { throw new RuntimeException("<Internal error or misuse> This method is only for use when printing function pointers"); } @@ -158,13 +158,13 @@ public class PointerType extends Type implements Cloneable { } @Override - public void visit(TypeVisitor arg) { + public void visit(final TypeVisitor arg) { super.visit(arg); targetType.visit(arg); } @Override - Type newCVVariant(int cvAttributes) { + Type newCVVariant(final int cvAttributes) { return new PointerType(getSize(), targetType, cvAttributes, hasTypedefedName, (hasTypedefedName ? getName() : null)); } } diff --git a/src/java/com/jogamp/gluegen/cgram/types/PrimitiveType.java b/src/java/com/jogamp/gluegen/cgram/types/PrimitiveType.java index 9d108df..8a86337 100644 --- a/src/java/com/jogamp/gluegen/cgram/types/PrimitiveType.java +++ b/src/java/com/jogamp/gluegen/cgram/types/PrimitiveType.java @@ -41,7 +41,7 @@ package com.jogamp.gluegen.cgram.types; public abstract class PrimitiveType extends Type implements Cloneable { - protected PrimitiveType(String name, SizeThunk size, int cvAttributes) { + protected PrimitiveType(final String name, final SizeThunk size, final int cvAttributes) { super(name, size, cvAttributes); } diff --git a/src/java/com/jogamp/gluegen/cgram/types/SizeThunk.java b/src/java/com/jogamp/gluegen/cgram/types/SizeThunk.java index 021fa90..c13e5d5 100644 --- a/src/java/com/jogamp/gluegen/cgram/types/SizeThunk.java +++ b/src/java/com/jogamp/gluegen/cgram/types/SizeThunk.java @@ -48,16 +48,16 @@ import com.jogamp.common.os.MachineDescription; 32-bit and 64-bit) from the same internal representation of the various types involved. */ public abstract class SizeThunk implements Cloneable { - private boolean fixedNativeSize; + private final boolean fixedNativeSize; // Private constructor because there are only a few of these - private SizeThunk(boolean fixedNativeSize) { this.fixedNativeSize = fixedNativeSize; } + private SizeThunk(final boolean fixedNativeSize) { this.fixedNativeSize = fixedNativeSize; } @Override public Object clone() { try { return super.clone(); - } catch (CloneNotSupportedException ex) { + } catch (final CloneNotSupportedException ex) { throw new InternalError(); } } @@ -69,99 +69,99 @@ public abstract class SizeThunk implements Cloneable { public static final SizeThunk INT8 = new SizeThunk(true) { @Override - public long computeSize(MachineDescription machDesc) { + public long computeSize(final MachineDescription machDesc) { return machDesc.int8SizeInBytes(); } @Override - public long computeAlignment(MachineDescription machDesc) { + public long computeAlignment(final MachineDescription machDesc) { return machDesc.int8AlignmentInBytes(); } }; public static final SizeThunk INT16 = new SizeThunk(true) { @Override - public long computeSize(MachineDescription machDesc) { + public long computeSize(final MachineDescription machDesc) { return machDesc.int16SizeInBytes(); } @Override - public long computeAlignment(MachineDescription machDesc) { + public long computeAlignment(final MachineDescription machDesc) { return machDesc.int16AlignmentInBytes(); } }; public static final SizeThunk INT32 = new SizeThunk(true) { @Override - public long computeSize(MachineDescription machDesc) { + public long computeSize(final MachineDescription machDesc) { return machDesc.int32SizeInBytes(); } @Override - public long computeAlignment(MachineDescription machDesc) { + public long computeAlignment(final MachineDescription machDesc) { return machDesc.int32AlignmentInBytes(); } }; public static final SizeThunk INTxx = new SizeThunk(false) { @Override - public long computeSize(MachineDescription machDesc) { + public long computeSize(final MachineDescription machDesc) { return machDesc.intSizeInBytes(); } @Override - public long computeAlignment(MachineDescription machDesc) { + public long computeAlignment(final MachineDescription machDesc) { return machDesc.intAlignmentInBytes(); } }; public static final SizeThunk LONG = new SizeThunk(false) { @Override - public long computeSize(MachineDescription machDesc) { + public long computeSize(final MachineDescription machDesc) { return machDesc.longSizeInBytes(); } @Override - public long computeAlignment(MachineDescription machDesc) { + public long computeAlignment(final MachineDescription machDesc) { return machDesc.longAlignmentInBytes(); } }; public static final SizeThunk INT64 = new SizeThunk(true) { @Override - public long computeSize(MachineDescription machDesc) { + public long computeSize(final MachineDescription machDesc) { return machDesc.int64SizeInBytes(); } @Override - public long computeAlignment(MachineDescription machDesc) { + public long computeAlignment(final MachineDescription machDesc) { return machDesc.int64AlignmentInBytes(); } }; public static final SizeThunk FLOAT = new SizeThunk(true) { @Override - public long computeSize(MachineDescription machDesc) { + public long computeSize(final MachineDescription machDesc) { return machDesc.floatSizeInBytes(); } @Override - public long computeAlignment(MachineDescription machDesc) { + public long computeAlignment(final MachineDescription machDesc) { return machDesc.floatAlignmentInBytes(); } }; public static final SizeThunk DOUBLE = new SizeThunk(true) { @Override - public long computeSize(MachineDescription machDesc) { + public long computeSize(final MachineDescription machDesc) { return machDesc.doubleSizeInBytes(); } @Override - public long computeAlignment(MachineDescription machDesc) { + public long computeAlignment(final MachineDescription machDesc) { return machDesc.doubleAlignmentInBytes(); } }; public static final SizeThunk POINTER = new SizeThunk(false) { @Override - public long computeSize(MachineDescription machDesc) { + public long computeSize(final MachineDescription machDesc) { return machDesc.pointerSizeInBytes(); } @Override - public long computeAlignment(MachineDescription machDesc) { + public long computeAlignment(final MachineDescription machDesc) { return machDesc.pointerAlignmentInBytes(); } }; @@ -172,11 +172,11 @@ public abstract class SizeThunk implements Cloneable { final SizeThunk thunk2) { return new SizeThunk(false) { @Override - public long computeSize(MachineDescription machDesc) { + public long computeSize(final MachineDescription machDesc) { return thunk1.computeSize(machDesc) + thunk2.computeSize(machDesc); } @Override - public long computeAlignment(MachineDescription machDesc) { + public long computeAlignment(final MachineDescription machDesc) { final long thunk1A = thunk1.computeAlignment(machDesc); final long thunk2A = thunk2.computeAlignment(machDesc); return ( thunk1A > thunk2A ) ? thunk1A : thunk2A ; @@ -188,11 +188,11 @@ public abstract class SizeThunk implements Cloneable { final SizeThunk thunk2) { return new SizeThunk(false) { @Override - public long computeSize(MachineDescription machDesc) { + public long computeSize(final MachineDescription machDesc) { return thunk1.computeSize(machDesc) * thunk2.computeSize(machDesc); } @Override - public long computeAlignment(MachineDescription machDesc) { + public long computeAlignment(final MachineDescription machDesc) { final long thunk1A = thunk1.computeAlignment(machDesc); final long thunk2A = thunk2.computeAlignment(machDesc); return ( thunk1A > thunk2A ) ? thunk1A : thunk2A ; @@ -204,7 +204,7 @@ public abstract class SizeThunk implements Cloneable { final SizeThunk alignmentThunk) { return new SizeThunk(false) { @Override - public long computeSize(MachineDescription machDesc) { + public long computeSize(final MachineDescription machDesc) { // x % 2n == x & (2n - 1) // remainder = net_size & ( alignment - 1 ) // padding = alignment - remainder ; @@ -219,7 +219,7 @@ public abstract class SizeThunk implements Cloneable { } @Override - public long computeAlignment(MachineDescription machDesc) { + public long computeAlignment(final MachineDescription machDesc) { final long thunk1A = offsetThunk.computeAlignment(machDesc); final long thunk2A = alignmentThunk.computeAlignment(machDesc); return ( thunk1A > thunk2A ) ? thunk1A : thunk2A ; @@ -231,11 +231,11 @@ public abstract class SizeThunk implements Cloneable { final SizeThunk thunk2) { return new SizeThunk(false) { @Override - public long computeSize(MachineDescription machDesc) { + public long computeSize(final MachineDescription machDesc) { return Math.max(thunk1.computeSize(machDesc), thunk2.computeSize(machDesc)); } @Override - public long computeAlignment(MachineDescription machDesc) { + public long computeAlignment(final MachineDescription machDesc) { final long thunk1A = thunk1.computeAlignment(machDesc); final long thunk2A = thunk2.computeAlignment(machDesc); return ( thunk1A > thunk2A ) ? thunk1A : thunk2A ; @@ -246,11 +246,11 @@ public abstract class SizeThunk implements Cloneable { public static SizeThunk constant(final int constant) { return new SizeThunk(false) { @Override - public long computeSize(MachineDescription machDesc) { + public long computeSize(final MachineDescription machDesc) { return constant; } @Override - public long computeAlignment(MachineDescription machDesc) { + public long computeAlignment(final MachineDescription machDesc) { return 1; // no alignment for constants } }; diff --git a/src/java/com/jogamp/gluegen/cgram/types/StructLayout.java b/src/java/com/jogamp/gluegen/cgram/types/StructLayout.java index dfcb722..e3ed7c2 100644 --- a/src/java/com/jogamp/gluegen/cgram/types/StructLayout.java +++ b/src/java/com/jogamp/gluegen/cgram/types/StructLayout.java @@ -53,11 +53,11 @@ import com.jogamp.gluegen.GlueGen; public class StructLayout { private final int baseOffset; - protected StructLayout(int baseOffset) { + protected StructLayout(final int baseOffset) { this.baseOffset = baseOffset; } - public void layout(CompoundType t) { + public void layout(final CompoundType t) { /** * - 1) align offset for the new data type, * - 2) add the aligned size of the new data type @@ -103,7 +103,7 @@ public class StructLayout { } else if (ft.isArray()) { final ArrayType arrayType = ft.asArray(); if(!arrayType.isLayouted()) { - CompoundType compoundElementType = arrayType.getBaseElementType().asCompound(); + final CompoundType compoundElementType = arrayType.getBaseElementType().asCompound(); if (compoundElementType != null) { if(!compoundElementType.isLayouted()) { StructLayout.layout(0, compoundElementType); @@ -144,11 +144,11 @@ public class StructLayout { t.setLayouted(); } - public static StructLayout create(int baseOffset) { + public static StructLayout create(final int baseOffset) { return new StructLayout(baseOffset); } - public static void layout(int baseOffset, CompoundType t) { + public static void layout(final int baseOffset, final CompoundType t) { create(baseOffset).layout(t); } } diff --git a/src/java/com/jogamp/gluegen/cgram/types/StructType.java b/src/java/com/jogamp/gluegen/cgram/types/StructType.java index da58a5f..27099e9 100644 --- a/src/java/com/jogamp/gluegen/cgram/types/StructType.java +++ b/src/java/com/jogamp/gluegen/cgram/types/StructType.java @@ -29,16 +29,16 @@ package com.jogamp.gluegen.cgram.types; public class StructType extends CompoundType { - public StructType(String name, SizeThunk size, int cvAttributes) { + public StructType(final String name, final SizeThunk size, final int cvAttributes) { this(name, size, cvAttributes, null); } - StructType(String name, SizeThunk size, int cvAttributes, String structName) { + StructType(final String name, final SizeThunk size, final int cvAttributes, final String structName) { super (name, size, cvAttributes, structName); } @Override - public boolean equals(Object arg) { + public boolean equals(final Object arg) { if (arg == null || !(arg instanceof StructType)) { return false; } @@ -51,8 +51,8 @@ public class StructType extends CompoundType { public final boolean isUnion() { return false; } @Override - Type newCVVariant(int cvAttributes) { - StructType t = new StructType(getName(), getSize(), cvAttributes, getStructName()); + Type newCVVariant(final int cvAttributes) { + final StructType t = new StructType(getName(), getSize(), cvAttributes, getStructName()); t.setFields(getFields()); return t; } diff --git a/src/java/com/jogamp/gluegen/cgram/types/Type.java b/src/java/com/jogamp/gluegen/cgram/types/Type.java index 45d610d..32f48a6 100644 --- a/src/java/com/jogamp/gluegen/cgram/types/Type.java +++ b/src/java/com/jogamp/gluegen/cgram/types/Type.java @@ -56,7 +56,7 @@ public abstract class Type implements Cloneable { private int typedefedCVAttributes; private boolean hasTypedefName; - protected Type(String name, SizeThunk size, int cvAttributes) { + protected Type(final String name, final SizeThunk size, final int cvAttributes) { setName(name); this.size = size; this.cvAttributes = cvAttributes; @@ -67,7 +67,7 @@ public abstract class Type implements Cloneable { public Object clone() { try { return super.clone(); - } catch (CloneNotSupportedException ex) { + } catch (final CloneNotSupportedException ex) { throw new InternalError(); } } @@ -80,7 +80,7 @@ public abstract class Type implements Cloneable { /** Returns the name of this type, optionally including const/volatile attributes. The returned string is suitable for use as a type specifier. */ - public String getName(boolean includeCVAttrs) { + public String getName(final boolean includeCVAttrs) { if (!includeCVAttrs) { return name; } @@ -113,7 +113,7 @@ public abstract class Type implements Cloneable { long _mdSize = -1; try { _mdSize = size.computeSize(MachineDescription.StaticConfig.X86_64_UNIX.md); - } catch (Exception e) {} + } catch (final Exception e) {} mdSize = _mdSize; } sb.append("[fixed ").append(size.hasFixedNativeSize()).append(", lnx64 ").append(mdSize).append("]"); @@ -166,7 +166,7 @@ public abstract class Type implements Cloneable { } /** Set the name of this type; used for handling typedefs. */ - public void setName(String name) { + public void setName(final String name) { if (name == null) { this.name = name; } else { @@ -181,15 +181,15 @@ public abstract class Type implements Cloneable { /** SizeThunk which computes size of this type in bytes. */ public SizeThunk getSize() { return size; } /** Size of this type in bytes according to the given MachineDescription. */ - public long getSize(MachineDescription machDesc) { - SizeThunk thunk = getSize(); + public long getSize(final MachineDescription machDesc) { + final SizeThunk thunk = getSize(); if (thunk == null) { throw new RuntimeException("No size set for type \"" + getName() + "\""); } return thunk.computeSize(machDesc); } /** Set the size of this type; only available for CompoundTypes. */ - void setSize(SizeThunk size) { this.size = size; } + void setSize(final SizeThunk size) { this.size = size; } /** Casts this to a BitType or returns null if not a BitType. */ public BitType asBit() { return null; } @@ -255,7 +255,7 @@ public abstract class Type implements Cloneable { } if (cvAttributes != 0) { - String nameWithAttribs = name + cvAttributes; + final String nameWithAttribs = name + cvAttributes; return nameWithAttribs.hashCode(); } return name.hashCode(); @@ -265,7 +265,7 @@ public abstract class Type implements Cloneable { * Equality test for Types. */ @Override - public boolean equals(Object arg) { + public boolean equals(final Object arg) { if (arg == this) { return true; } @@ -289,7 +289,7 @@ public abstract class Type implements Cloneable { /** Visit this type and all of the component types of this one; for example, the return type and argument types of a FunctionType. */ - public void visit(TypeVisitor visitor) { + public void visit(final TypeVisitor visitor) { visitor.visitType(this); } @@ -308,7 +308,7 @@ public abstract class Type implements Cloneable { /** Return a variant of this type matching the given const/volatile attributes. May return this object if the attributes match. */ - public final Type getCVVariant(int cvAttributes) { + public final Type getCVVariant(final int cvAttributes) { if (this.cvAttributes == cvAttributes) { return this; } @@ -329,7 +329,7 @@ public abstract class Type implements Cloneable { type represents (i.e., "void **" returns 2). Returns 0 if this type is not a pointer type. */ public int pointerDepth() { - PointerType pt = asPointer(); + final PointerType pt = asPointer(); if (pt == null) { return 0; } @@ -340,7 +340,7 @@ public abstract class Type implements Cloneable { type represents (i.e., "char[][]" returns 2). Returns 0 if this type is not an array type. */ public int arrayDimension() { - ArrayType arrayType = asArray(); + final ArrayType arrayType = asArray(); if (arrayType == null) { return 0; } @@ -359,7 +359,7 @@ public abstract class Type implements Cloneable { } /** Helper routine for list equality comparison */ - static <C> boolean listsEqual(List<C> a, List<C> b) { + static <C> boolean listsEqual(final List<C> a, final List<C> b) { return ((a == null && b == null) || (a != null && b != null && a.equals(b))); } } diff --git a/src/java/com/jogamp/gluegen/cgram/types/TypeDictionary.java b/src/java/com/jogamp/gluegen/cgram/types/TypeDictionary.java index 3994c12..f6409db 100644 --- a/src/java/com/jogamp/gluegen/cgram/types/TypeDictionary.java +++ b/src/java/com/jogamp/gluegen/cgram/types/TypeDictionary.java @@ -46,10 +46,10 @@ import java.util.*; public class TypeDictionary { /** Mapping from type name to type.*/ - private HashMap<String, Type> map = new HashMap<String, Type>(); + private final HashMap<String, Type> map = new HashMap<String, Type>(); /** Reverse mapping; created lazily from the regular map */ - private HashMap<Set<Type>, String> reverseMap = new HashMap<Set<Type>, String>(); + private final HashMap<Set<Type>, String> reverseMap = new HashMap<Set<Type>, String>(); /** Has a type been added/removed since the last time the reverse map was * calculated? */ @@ -60,14 +60,14 @@ public class TypeDictionary { * @param name the name to which the type is defined * @param type the type that can be referred to by the specified name. */ - public Type put(String name, Type type) { + public Type put(final String name, final Type type) { reverseMapOutOfDate = true; return map.put(name, type); } /** Get the type corresponding to the given name. Returns null if no type * was found corresponding to the given name. */ - public Type get(String name) { + public Type get(final String name) { return map.get(name); } @@ -87,7 +87,7 @@ public class TypeDictionary { // } /** Remove the mapping from the specified name to its associated type.*/ - public Type remove(String name) { + public Type remove(final String name) { reverseMapOutOfDate = true; return map.remove(name); } @@ -103,11 +103,11 @@ public class TypeDictionary { return map.entrySet(); } - public boolean containsKey(String key) { + public boolean containsKey(final String key) { return map.containsKey(key); } - public boolean containsValue(Type value) { + public boolean containsValue(final Type value) { return map.containsValue(value); } diff --git a/src/java/com/jogamp/gluegen/cgram/types/UnionType.java b/src/java/com/jogamp/gluegen/cgram/types/UnionType.java index 36b4fdb..99d2fed 100644 --- a/src/java/com/jogamp/gluegen/cgram/types/UnionType.java +++ b/src/java/com/jogamp/gluegen/cgram/types/UnionType.java @@ -29,16 +29,16 @@ package com.jogamp.gluegen.cgram.types; public class UnionType extends CompoundType { - public UnionType(String name, SizeThunk size, int cvAttributes) { + public UnionType(final String name, final SizeThunk size, final int cvAttributes) { this(name, size, cvAttributes, null); } - UnionType(String name, SizeThunk size, int cvAttributes, String structName) { + UnionType(final String name, final SizeThunk size, final int cvAttributes, final String structName) { super (name, size, cvAttributes, structName); } @Override - public boolean equals(Object arg) { + public boolean equals(final Object arg) { if (arg == null || !(arg instanceof UnionType)) { return false; } @@ -51,8 +51,8 @@ public class UnionType extends CompoundType { public final boolean isUnion() { return true; } @Override - Type newCVVariant(int cvAttributes) { - UnionType t = new UnionType(getName(), getSize(), cvAttributes, getStructName()); + Type newCVVariant(final int cvAttributes) { + final UnionType t = new UnionType(getName(), getSize(), cvAttributes, getStructName()); t.setFields(getFields()); return t; } diff --git a/src/java/com/jogamp/gluegen/cgram/types/VoidType.java b/src/java/com/jogamp/gluegen/cgram/types/VoidType.java index afde0d2..2e1f069 100644 --- a/src/java/com/jogamp/gluegen/cgram/types/VoidType.java +++ b/src/java/com/jogamp/gluegen/cgram/types/VoidType.java @@ -41,11 +41,11 @@ package com.jogamp.gluegen.cgram.types; public class VoidType extends Type implements Cloneable { - public VoidType(int cvAttributes) { + public VoidType(final int cvAttributes) { this("void", cvAttributes); } - private VoidType(String name, int cvAttributes) { + private VoidType(final String name, final int cvAttributes) { super(name, null, cvAttributes); } @@ -55,7 +55,7 @@ public class VoidType extends Type implements Cloneable { } @Override - Type newCVVariant(int cvAttributes) { + Type newCVVariant(final int cvAttributes) { return new VoidType(getName(), cvAttributes); } } |