summaryrefslogtreecommitdiffstats
path: root/src/java/com/sun
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/com/sun')
-rw-r--r--src/java/com/sun/gluegen/cgram/types/ArrayType.java5
-rw-r--r--src/java/com/sun/gluegen/cgram/types/BitType.java4
-rw-r--r--src/java/com/sun/gluegen/cgram/types/CompoundType.java22
-rw-r--r--src/java/com/sun/gluegen/cgram/types/DoubleType.java35
-rw-r--r--src/java/com/sun/gluegen/cgram/types/EnumType.java212
-rw-r--r--src/java/com/sun/gluegen/cgram/types/Field.java3
-rw-r--r--src/java/com/sun/gluegen/cgram/types/FloatType.java3
-rw-r--r--src/java/com/sun/gluegen/cgram/types/FunctionSymbol.java150
-rw-r--r--src/java/com/sun/gluegen/cgram/types/FunctionType.java259
-rw-r--r--src/java/com/sun/gluegen/cgram/types/IntType.java72
-rw-r--r--src/java/com/sun/gluegen/cgram/types/PointerType.java188
-rw-r--r--src/java/com/sun/gluegen/cgram/types/PrimitiveType.java15
-rw-r--r--src/java/com/sun/gluegen/cgram/types/Type.java16
-rw-r--r--src/java/com/sun/gluegen/cgram/types/VoidType.java25
-rw-r--r--src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java44
-rwxr-xr-xsrc/java/com/sun/gluegen/opengl/GLConfiguration.java104
-rw-r--r--src/java/com/sun/gluegen/opengl/GLEmitter.java45
-rwxr-xr-xsrc/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java8
18 files changed, 647 insertions, 563 deletions
diff --git a/src/java/com/sun/gluegen/cgram/types/ArrayType.java b/src/java/com/sun/gluegen/cgram/types/ArrayType.java
index 0e23d35..31ec13c 100644
--- a/src/java/com/sun/gluegen/cgram/types/ArrayType.java
+++ b/src/java/com/sun/gluegen/cgram/types/ArrayType.java
@@ -55,6 +55,7 @@ public class ArrayType extends Type {
this.length = length;
}
+ @Override
public boolean equals(Object arg) {
if (arg == this) return true;
if (arg == null || (!(arg instanceof ArrayType))) {
@@ -64,6 +65,7 @@ public class ArrayType extends Type {
return (super.equals(arg) && elementType.equals(t.elementType) && (length == t.length));
}
+ @Override
public String getName(boolean includeCVAttrs) {
// Lazy computation of name due to lazy setting of compound type
// names during parsing
@@ -75,6 +77,7 @@ public class ArrayType extends Type {
return computedName;
}
+ @Override
public ArrayType asArray() { return this; }
public Type getElementType() { return elementType; }
@@ -103,6 +106,7 @@ public class ArrayType extends Type {
super.setSize(SizeThunk.mul(SizeThunk.constant(getLength()), elementType.getSize()));
}
+ @Override
public String toString() {
return toString(null);
}
@@ -120,6 +124,7 @@ public class ArrayType extends Type {
return buf.toString();
}
+ @Override
public void visit(TypeVisitor arg) {
super.visit(arg);
elementType.visit(arg);
diff --git a/src/java/com/sun/gluegen/cgram/types/BitType.java b/src/java/com/sun/gluegen/cgram/types/BitType.java
index 293eb39..b5a5337 100644
--- a/src/java/com/sun/gluegen/cgram/types/BitType.java
+++ b/src/java/com/sun/gluegen/cgram/types/BitType.java
@@ -53,6 +53,7 @@ public class BitType extends IntType {
this.offset = lsbOffset;
}
+ @Override
public boolean equals(Object arg) {
if (arg == this) return true;
if (arg == null || (!(arg instanceof BitType))) {
@@ -63,6 +64,7 @@ public class BitType extends IntType {
(sizeInBits == t.sizeInBits) && (offset == t.offset));
}
+ @Override
public BitType asBit() { return this; }
/** Size in bits of this type. */
@@ -76,11 +78,13 @@ public class BitType extends IntType {
return offset;
}
+ @Override
public void visit(TypeVisitor arg) {
super.visit(arg);
underlyingType.visit(arg);
}
+ @Override
Type newCVVariant(int cvAttributes) {
return new BitType(underlyingType, sizeInBits, offset, cvAttributes);
}
diff --git a/src/java/com/sun/gluegen/cgram/types/CompoundType.java b/src/java/com/sun/gluegen/cgram/types/CompoundType.java
index 28d7b76..9b982fd 100644
--- a/src/java/com/sun/gluegen/cgram/types/CompoundType.java
+++ b/src/java/com/sun/gluegen/cgram/types/CompoundType.java
@@ -49,7 +49,7 @@ public class CompoundType extends Type {
private CompoundTypeKind kind;
// The name "foo" in the construct "struct foo { ... }";
private String structName;
- private ArrayList fields;
+ private ArrayList<Field> fields;
private boolean visiting;
private boolean bodyParsed;
private boolean computedHashcode;
@@ -66,6 +66,7 @@ public class CompoundType extends Type {
this.structName = structName;
}
+ @Override
public int hashCode() {
if (computedHashcode) {
return hashcode;
@@ -83,16 +84,17 @@ public class CompoundType extends Type {
return hashcode;
}
+ @Override
public boolean equals(Object arg) {
if (arg == this) return true;
- if (arg == null || (!(arg instanceof CompoundType))) {
+ if (arg == null || !(arg instanceof CompoundType)) {
return false;
}
CompoundType t = (CompoundType) arg;
- return (super.equals(arg) &&
- (structName == t.structName || (structName != null && structName.equals(t.structName))) &&
- kind == t.kind &&
- listsEqual(fields, t.fields));
+ return super.equals(arg) &&
+ ((structName == null ? t.structName == null : structName.equals(t.structName)) ||
+ (structName != null && structName.equals(t.structName))) &&
+ kind == t.kind && listsEqual(fields, t.fields);
}
/** Returns the struct name of this CompoundType, i.e. the "foo" in
@@ -107,10 +109,12 @@ public class CompoundType extends Type {
this.structName = structName;
}
+ @Override
public void setSize(SizeThunk size) {
super.setSize(size);
}
+ @Override
public CompoundType asCompound() { return this; }
/** Returns the number of fields in this type. */
@@ -120,7 +124,7 @@ public class CompoundType extends Type {
/** Returns the <i>i</i>th field of this type. */
public Field getField(int i) {
- return (Field) fields.get(i);
+ return fields.get(i);
}
/** Adds a field to this type. */
@@ -129,7 +133,7 @@ public class CompoundType extends Type {
throw new RuntimeException("Body of this CompoundType has already been parsed; should not be adding more fields");
}
if (fields == null) {
- fields = new ArrayList();
+ fields = new ArrayList<Field>();
}
fields.add(f);
}
@@ -145,6 +149,7 @@ public class CompoundType extends Type {
/** Indicates whether this type was declared as a union. */
public boolean isUnion() { return (kind == CompoundTypeKind.UNION); }
+ @Override
public String toString() {
String cvAttributesString = getCVAttributesString();
if (getName() != null) {
@@ -156,6 +161,7 @@ public class CompoundType extends Type {
}
}
+ @Override
public void visit(TypeVisitor arg) {
if (visiting) {
return;
diff --git a/src/java/com/sun/gluegen/cgram/types/DoubleType.java b/src/java/com/sun/gluegen/cgram/types/DoubleType.java
index 6d6e62c..7e295cd 100644
--- a/src/java/com/sun/gluegen/cgram/types/DoubleType.java
+++ b/src/java/com/sun/gluegen/cgram/types/DoubleType.java
@@ -36,29 +36,32 @@
* Sun gratefully acknowledges that this software was originally authored
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-
package com.sun.gluegen.cgram.types;
/** Represents a double-word floating-point type (C type "double".) */
-
public class DoubleType extends PrimitiveType {
- public DoubleType(String name, SizeThunk size, int cvAttributes) {
- super(name, size, cvAttributes);
- }
- public boolean equals(Object arg) {
- if (arg == this) {
- return true;
+ public DoubleType(String name, SizeThunk size, int cvAttributes) {
+ super(name, size, cvAttributes);
}
- if (arg == null || (!(arg instanceof DoubleType))) {
- return false;
+
+ @Override
+ public boolean equals(Object arg) {
+ if (arg == this) {
+ return true;
+ }
+ if (arg == null || (!(arg instanceof DoubleType))) {
+ return false;
+ }
+ return super.equals(arg);
}
- return super.equals(arg);
- }
- public DoubleType asDouble() { return this; }
+ @Override
+ public DoubleType asDouble() {
+ return this;
+ }
- Type newCVVariant(int cvAttributes) {
- return new DoubleType(getName(), getSize(), cvAttributes);
- }
+ Type newCVVariant(int cvAttributes) {
+ return new DoubleType(getName(), getSize(), cvAttributes);
+ }
}
diff --git a/src/java/com/sun/gluegen/cgram/types/EnumType.java b/src/java/com/sun/gluegen/cgram/types/EnumType.java
index 717d389..b06ed9a 100644
--- a/src/java/com/sun/gluegen/cgram/types/EnumType.java
+++ b/src/java/com/sun/gluegen/cgram/types/EnumType.java
@@ -36,110 +36,140 @@
* Sun gratefully acknowledges that this software was originally authored
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-
package com.sun.gluegen.cgram.types;
import java.util.*;
/** Describes enumerated types. Enumerations are like ints except that
- they have a set of named values. */
-
+they have a set of named values. */
public class EnumType extends IntType {
- private IntType underlyingType;
-
- private static class Enum {
- String name;
- long value;
- Enum(String name, long value) {
- this.name = name;
- this.value = value;
+
+ private IntType underlyingType;
+
+ private static class Enum {
+
+ String name;
+ long value;
+
+ Enum(String name, long value) {
+ this.name = name;
+ this.value = value;
+ }
+
+ String getName() {
+ return name;
+ }
+
+ long getValue() {
+ return value;
+ }
}
- String getName() { return name; }
- long getValue() { return value; }
- }
- private List/*<Enum>*/ enums;
-
- public EnumType(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) {
- super(name, enumSizeInBytes, false, CVAttributes.CONST );
- this.underlyingType = new IntType(name, enumSizeInBytes, false, CVAttributes.CONST);
- }
-
- protected EnumType(String name, IntType underlyingType, int cvAttributes) {
- super(name, underlyingType.getSize(), underlyingType.isUnsigned(), cvAttributes);
- this.underlyingType = underlyingType;
- }
-
- public boolean equals(Object arg) {
- if (arg == this) return true;
- if (arg == null || (!(arg instanceof EnumType))) {
- return false;
+ private List<Enum> enums;
+
+ public EnumType(String name) {
+ super(name, SizeThunk.LONG, false, CVAttributes.CONST);
+ this.underlyingType = new IntType(name, SizeThunk.LONG, false, CVAttributes.CONST);
}
- EnumType t = (EnumType) arg;
- return (super.equals(arg) &&
- underlyingType.equals(t.underlyingType) &&
- listsEqual(enums, t.enums));
- }
- public EnumType asEnum() { return this; }
+ public EnumType(String name, SizeThunk enumSizeInBytes) {
+ super(name, enumSizeInBytes, false, CVAttributes.CONST);
+ this.underlyingType = new IntType(name, enumSizeInBytes, false, CVAttributes.CONST);
+ }
- public void addEnum(String name, long val) {
- if (enums == null) {
- enums = new ArrayList();
+ protected EnumType(String name, IntType underlyingType, int cvAttributes) {
+ super(name, underlyingType.getSize(), underlyingType.isUnsigned(), cvAttributes);
+ this.underlyingType = underlyingType;
}
- enums.add(new Enum(name, val));
- }
-
- /** Number of enumerates defined in this enum. */
- public int getNumEnumerates() { return enums.size(); }
- /** Fetch <i>i</i>th (0..getNumEnumerates() - 1) name */
- public String getEnumName(int i) { return ((Enum) enums.get(i)).getName(); }
- /** Fetch <i>i</i>th (0..getNumEnumerates() - 1) value */
- public long getEnumValue(int i) { return ((Enum) enums.get(i)).getValue(); }
- /** Fetch the value of the enumerate with the given name. */
- public long getEnumValue(String name) {
- for (int i = 0; i < enums.size(); ++i) {
- Enum n = ((Enum)enums.get(i));
- if (n.getName().equals(name)) { return n.getValue(); }
+
+ @Override
+ public boolean equals(Object arg) {
+ if (arg == this) {
+ return true;
+ }
+ if (arg == null || (!(arg instanceof EnumType))) {
+ return false;
+ }
+ EnumType t = (EnumType) arg;
+ return (super.equals(arg)
+ && underlyingType.equals(t.underlyingType)
+ && listsEqual(enums, t.enums));
}
- throw new NoSuchElementException(
- "No enumerate named \"" + name + "\" in EnumType \"" +
- getName() + "\"");
- }
- /** Does this enum type contain an enumerate with the given name? */
- public boolean containsEnumerate(String name) {
- for (int i = 0; i < enums.size(); ++i) {
- if (((Enum)enums.get(i)).getName().equals(name)) { return true; }
+
+ @Override
+ public EnumType asEnum() {
+ return this;
}
- return false;
- }
- /** 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) {
- for (int i = 0; i < enums.size(); ++i) {
- Enum e = (Enum)enums.get(i);
- if (e.getName().equals(name)) {
- enums.remove(e);
- return true;
- }
+
+ public void addEnum(String name, long val) {
+ if (enums == null) {
+ enums = new ArrayList<Enum>();
+ }
+ enums.add(new Enum(name, val));
+ }
+
+ /** Number of enumerates defined in this enum. */
+ public int getNumEnumerates() {
+ return enums.size();
+ }
+
+ /** Fetch <i>i</i>th (0..getNumEnumerates() - 1) name */
+ public String getEnumName(int i) {
+ return (enums.get(i)).getName();
+ }
+
+ /** Fetch <i>i</i>th (0..getNumEnumerates() - 1) value */
+ public long getEnumValue(int i) {
+ return (enums.get(i)).getValue();
+ }
+
+ /** Fetch the value of the enumerate with the given name. */
+ public long getEnumValue(String name) {
+ for (int i = 0; i < enums.size(); ++i) {
+ Enum n = (enums.get(i));
+ if (n.getName().equals(name)) {
+ return n.getValue();
+ }
+ }
+ throw new NoSuchElementException(
+ "No enumerate named \"" + name + "\" in EnumType \""
+ + getName() + "\"");
+ }
+
+ /** Does this enum type contain an enumerate with the given name? */
+ public boolean containsEnumerate(String name) {
+ for (int i = 0; i < enums.size(); ++i) {
+ if ((enums.get(i)).getName().equals(name)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /** 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) {
+ for (int i = 0; i < enums.size(); ++i) {
+ Enum e = enums.get(i);
+ if (e.getName().equals(name)) {
+ enums.remove(e);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public void visit(TypeVisitor arg) {
+ super.visit(arg);
+ underlyingType.visit(arg);
+ }
+
+ @Override
+ Type newCVVariant(int cvAttributes) {
+ EnumType t = new EnumType(getName(), underlyingType, cvAttributes);
+ t.enums = enums;
+ return t;
}
- return false;
- }
-
- public void visit(TypeVisitor arg) {
- super.visit(arg);
- underlyingType.visit(arg);
- }
-
- Type newCVVariant(int cvAttributes) {
- EnumType t = new EnumType(getName(), underlyingType, cvAttributes);
- t.enums = enums;
- return t;
- }
}
diff --git a/src/java/com/sun/gluegen/cgram/types/Field.java b/src/java/com/sun/gluegen/cgram/types/Field.java
index e6ec18d..dd7ecff 100644
--- a/src/java/com/sun/gluegen/cgram/types/Field.java
+++ b/src/java/com/sun/gluegen/cgram/types/Field.java
@@ -52,10 +52,12 @@ public class Field {
this.offset = offset;
}
+ @Override
public int hashCode() {
return name.hashCode();
}
+ @Override
public boolean equals(Object arg) {
if (arg == null || (!(arg instanceof Field))) {
return false;
@@ -85,6 +87,7 @@ public class Field {
/** Sets the offset of this field in the containing data structure. */
public void setOffset(SizeThunk offset) { this.offset = offset; }
+ @Override
public String toString() {
if (!getType().isFunctionPointer()) {
if (getName() == null &&
diff --git a/src/java/com/sun/gluegen/cgram/types/FloatType.java b/src/java/com/sun/gluegen/cgram/types/FloatType.java
index 7a6fa4d..91b45b4 100644
--- a/src/java/com/sun/gluegen/cgram/types/FloatType.java
+++ b/src/java/com/sun/gluegen/cgram/types/FloatType.java
@@ -46,6 +46,8 @@ public class FloatType extends PrimitiveType {
super(name, size, cvAttributes);
}
+
+ @Override
public boolean equals(Object arg) {
if (arg == this) {
return true;
@@ -56,6 +58,7 @@ public class FloatType extends PrimitiveType {
return super.equals(arg);
}
+ @Override
public FloatType asFloat() { return this; }
Type newCVVariant(int cvAttributes) {
diff --git a/src/java/com/sun/gluegen/cgram/types/FunctionSymbol.java b/src/java/com/sun/gluegen/cgram/types/FunctionSymbol.java
index 65e172f..730674a 100644
--- a/src/java/com/sun/gluegen/cgram/types/FunctionSymbol.java
+++ b/src/java/com/sun/gluegen/cgram/types/FunctionSymbol.java
@@ -36,87 +36,93 @@
* Sun gratefully acknowledges that this software was originally authored
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-
package com.sun.gluegen.cgram.types;
-import java.util.*;
-
/** Describes a function symbol, which includes the name and
- type. Since we are currently only concerned with processing
- functions this is the only symbol type, though plausibly more
- types should be added and a true symbol table constructed during
- parsing. */
-
+type. Since we are currently only concerned with processing
+functions this is the only symbol type, though plausibly more
+types should be added and a true symbol table constructed during
+parsing. */
public class FunctionSymbol {
- private String name;
- private FunctionType type;
-
- public FunctionSymbol(String name, FunctionType type) {
- this.name = name;
- this.type = type;
- }
-
- public String getName() { return name; }
-
- /** Returns the type of this function. Do not add arguments to it
- directly; use addArgument instead. */
- public FunctionType getType() { return type; }
-
- /** Returns the return type of this function. */
- public Type getReturnType() { return type.getReturnType(); }
-
- public int getNumArguments() { return type.getNumArguments(); }
-
- /** 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) {
- return type.getArgumentName(i);
- }
-
- /** Returns the type of the <i>i</i>th argument. */
- public Type getArgumentType(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) {
- type.addArgument(argumentType, argumentName);
- }
-
- public String toString() {
- return getType().toString(getName());
- }
-
- /** Helper routine for emitting native javadoc tags */
- public String toString(boolean emitNativeTag) {
- return getType().toString(getName(), emitNativeTag);
- }
-
- public int hashCode() {
- if (name == null) {
- return 0;
+
+ private String name;
+ private FunctionType type;
+
+ public FunctionSymbol(String name, FunctionType type) {
+ this.name = name;
+ this.type = type;
}
- return name.hashCode();
- }
- public boolean equals(Object arg) {
- if (arg == this) {
- return true;
+ public String getName() {
+ return name;
}
-
- if (arg == null || (!(arg instanceof FunctionSymbol))) {
- return false;
+
+ /** Returns the type of this function. Do not add arguments to it
+ directly; use addArgument instead. */
+ public FunctionType getType() {
+ return type;
}
-
- FunctionSymbol other = (FunctionSymbol) arg;
- if(getName()==null && other.getName()!=null) {
- return false;
+ /** Returns the return type of this function. */
+ public Type getReturnType() {
+ return type.getReturnType();
}
- return (
- (getName() == other.getName() || getName().equals(other.getName()))
- && type.equals(other.type));
- }
+ public int getNumArguments() {
+ return type.getNumArguments();
+ }
+
+ /** 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) {
+ return type.getArgumentName(i);
+ }
+
+ /** Returns the type of the <i>i</i>th argument. */
+ public Type getArgumentType(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) {
+ type.addArgument(argumentType, argumentName);
+ }
+
+ @Override
+ public String toString() {
+ return getType().toString(getName());
+ }
+
+ /** Helper routine for emitting native javadoc tags */
+ public String toString(boolean emitNativeTag) {
+ return getType().toString(getName(), emitNativeTag);
+ }
+
+ @Override
+ public int hashCode() {
+ if (name == null) {
+ return 0;
+ }
+ return name.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object arg) {
+ if (arg == this) {
+ return true;
+ }
+
+ if (arg == null || (!(arg instanceof FunctionSymbol))) {
+ return false;
+ }
+
+ FunctionSymbol other = (FunctionSymbol) arg;
+
+ if (getName() == null && other.getName() != null) {
+ return false;
+ }
+
+ return (getName().equals(other.getName()) || getName().equals(other.getName())) && type.equals(other.type);
+ }
}
diff --git a/src/java/com/sun/gluegen/cgram/types/FunctionType.java b/src/java/com/sun/gluegen/cgram/types/FunctionType.java
index 7a9c2b5..d36f839 100644
--- a/src/java/com/sun/gluegen/cgram/types/FunctionType.java
+++ b/src/java/com/sun/gluegen/cgram/types/FunctionType.java
@@ -36,144 +36,155 @@
* Sun gratefully acknowledges that this software was originally authored
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-
package com.sun.gluegen.cgram.types;
import java.util.*;
/** Describes a function type, used to model both function
- declarations and (via PointerType) function pointers. */
-
+declarations and (via PointerType) function pointers. */
public class FunctionType extends Type {
- private Type returnType;
- private ArrayList argumentTypes;
- private ArrayList argumentNames;
-
- public FunctionType(String name, SizeThunk size, Type returnType, int cvAttributes) {
- super(name, size, cvAttributes);
- this.returnType = returnType;
- }
-
- public boolean equals(Object arg) {
- if (arg == this) return true;
- if (arg == null || (!(arg instanceof FunctionType))) {
- return false;
+
+ private Type returnType;
+ private ArrayList<Type> argumentTypes;
+ private ArrayList<String> argumentNames;
+
+ public FunctionType(String name, SizeThunk size, Type returnType, int cvAttributes) {
+ super(name, size, cvAttributes);
+ this.returnType = returnType;
+ }
+
+ @Override
+ public boolean equals(Object arg) {
+ if (arg == this) {
+ return true;
+ }
+ if (arg == null || (!(arg instanceof FunctionType))) {
+ return false;
+ }
+ FunctionType t = (FunctionType) arg;
+ return (super.equals(arg)
+ && returnType.equals(t.returnType)
+ && listsEqual(argumentTypes, t.argumentTypes));
}
- FunctionType t = (FunctionType) arg;
- return (super.equals(arg) &&
- returnType.equals(t.returnType) &&
- listsEqual(argumentTypes, t.argumentTypes));
- }
-
- public FunctionType asFunction() { return this; }
-
- /** Returns the return type of this function. */
- public Type getReturnType() { return returnType; }
-
- public int getNumArguments() { return ((argumentTypes == null) ? 0 : argumentTypes.size()); }
-
- /** 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) {
- return (String) argumentNames.get(i);
- }
-
- /** Returns the type of the <i>i</i>th argument. */
- public Type getArgumentType(int i) {
- return (Type) argumentTypes.get(i);
- }
-
- /** Add an argument's name and type. Use null for unknown argument
- names. */
- public void addArgument(Type argumentType, String argumentName) {
- if (argumentTypes == null) {
- argumentTypes = new ArrayList();
- argumentNames = new ArrayList();
+
+ @Override
+ public FunctionType asFunction() {
+ return this;
+ }
+
+ /** Returns the return type of this function. */
+ public Type getReturnType() {
+ return returnType;
}
- argumentTypes.add(argumentType);
- argumentNames.add(argumentName);
- }
-
- public void setArgumentName(int i, String name)
- {
- argumentNames.set(i,name);
- }
-
- public String toString() {
- return toString(null);
- }
-
- public String toString(String functionName) {
- return toString(functionName, false);
- }
-
- public String toString(String functionName, boolean emitNativeTag) {
- return toString(functionName, null, emitNativeTag, false);
- }
-
- String toString(String functionName, String callingConvention, boolean emitNativeTag, boolean isPointer) {
- StringBuffer res = new StringBuffer();
- res.append(getReturnType());
- res.append(" ");
- if (isPointer) {
- res.append("(");
- if (callingConvention != null) {
- res.append(callingConvention);
- }
- res.append("*");
+
+ public int getNumArguments() {
+ return ((argumentTypes == null) ? 0 : argumentTypes.size());
}
- if (functionName != null) {
- if (emitNativeTag) {
- // Emit @native tag for javadoc purposes
- res.append("{@native ");
- }
- res.append(functionName);
- if (emitNativeTag) {
- res.append("}");
- }
+
+ /** 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) {
+ return argumentNames.get(i);
}
- if (isPointer) {
- res.append(")");
+
+ /** Returns the type of the <i>i</i>th argument. */
+ public Type getArgumentType(int i) {
+ return argumentTypes.get(i);
}
- res.append("(");
- int n = getNumArguments();
- for (int i = 0; i < n; i++) {
- Type t = getArgumentType(i);
- if (t.isFunctionPointer()) {
- FunctionType ft = t.asPointer().getTargetType().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);
- if (argumentName != null) {
- res.append(" ");
- res.append(argumentName);
+
+ /**
+ * Add an argument's name and type. Use null for unknown argument names.
+ */
+ public void addArgument(Type argumentType, String argumentName) {
+ if (argumentTypes == null) {
+ argumentTypes = new ArrayList<Type>();
+ argumentNames = new ArrayList<String>();
}
- }
- if (i < n - 1) {
- res.append(", ");
- }
+ argumentTypes.add(argumentType);
+ argumentNames.add(argumentName);
+ }
+
+ public void setArgumentName(int i, String name) {
+ argumentNames.set(i, name);
+ }
+
+ @Override
+ public String toString() {
+ return toString(null);
+ }
+
+ public String toString(String functionName) {
+ return toString(functionName, false);
+ }
+
+ public String toString(String functionName, boolean emitNativeTag) {
+ return toString(functionName, null, emitNativeTag, false);
}
- res.append(")");
- if (!isPointer) {
- res.append(";");
+
+ String toString(String functionName, String callingConvention, boolean emitNativeTag, boolean isPointer) {
+ StringBuffer res = new StringBuffer();
+ res.append(getReturnType());
+ res.append(" ");
+ if (isPointer) {
+ res.append("(");
+ if (callingConvention != null) {
+ res.append(callingConvention);
+ }
+ res.append("*");
+ }
+ if (functionName != null) {
+ if (emitNativeTag) {
+ // Emit @native tag for javadoc purposes
+ res.append("{@native ");
+ }
+ res.append(functionName);
+ if (emitNativeTag) {
+ res.append("}");
+ }
+ }
+ if (isPointer) {
+ res.append(")");
+ }
+ res.append("(");
+ int n = getNumArguments();
+ for (int i = 0; i < n; i++) {
+ Type t = getArgumentType(i);
+ if (t.isFunctionPointer()) {
+ FunctionType ft = t.asPointer().getTargetType().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);
+ if (argumentName != null) {
+ res.append(" ");
+ res.append(argumentName);
+ }
+ }
+ if (i < n - 1) {
+ res.append(", ");
+ }
+ }
+ res.append(")");
+ if (!isPointer) {
+ res.append(";");
+ }
+ return res.toString();
}
- return res.toString();
- }
-
- public void visit(TypeVisitor arg) {
- super.visit(arg);
- returnType.visit(arg);
- int n = getNumArguments();
- for (int i = 0; i < n; i++) {
- getArgumentType(i).visit(arg);
+
+ @Override
+ public void visit(TypeVisitor arg) {
+ super.visit(arg);
+ returnType.visit(arg);
+ int n = getNumArguments();
+ for (int i = 0; i < n; i++) {
+ getArgumentType(i).visit(arg);
+ }
}
- }
- Type newCVVariant(int cvAttributes) {
- // Functions don't have const/volatile attributes
- return this;
- }
+ Type newCVVariant(int cvAttributes) {
+ // Functions don't have const/volatile attributes
+ return this;
+ }
}
diff --git a/src/java/com/sun/gluegen/cgram/types/IntType.java b/src/java/com/sun/gluegen/cgram/types/IntType.java
index acd6a3d..b94e7bb 100644
--- a/src/java/com/sun/gluegen/cgram/types/IntType.java
+++ b/src/java/com/sun/gluegen/cgram/types/IntType.java
@@ -36,47 +36,57 @@
* Sun gratefully acknowledges that this software was originally authored
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-
package com.sun.gluegen.cgram.types;
public class IntType extends PrimitiveType {
- private boolean unsigned;
- private boolean typedefedUnsigned;
- public IntType(String name, SizeThunk size, boolean unsigned, int cvAttributes) {
- this(name, size, unsigned, cvAttributes, false);
- }
+ private boolean unsigned;
+ private boolean typedefedUnsigned;
- private IntType(String name, SizeThunk size, boolean unsigned, int cvAttributes, boolean typedefedUnsigned) {
- super(name, size, cvAttributes);
- this.unsigned = unsigned;
- this.typedefedUnsigned = typedefedUnsigned;
- }
+ public IntType(String name, SizeThunk size, boolean unsigned, int cvAttributes) {
+ this(name, size, unsigned, cvAttributes, false);
+ }
- public boolean equals(Object arg) {
- if (arg == this) return true;
- if (arg == null || (!(arg instanceof IntType))) {
- return false;
+ private IntType(String name, SizeThunk size, boolean unsigned, int cvAttributes, boolean typedefedUnsigned) {
+ super(name, size, cvAttributes);
+ this.unsigned = unsigned;
+ this.typedefedUnsigned = typedefedUnsigned;
}
- IntType t = (IntType) arg;
- return (super.equals(arg) && (unsigned == t.unsigned));
- }
- public void setName(String name) {
- super.setName(name);
- typedefedUnsigned = unsigned;
- }
+ @Override
+ public boolean equals(Object arg) {
+ if (arg == this) {
+ return true;
+ }
+ if (arg == null || (!(arg instanceof IntType))) {
+ return false;
+ }
+ IntType t = (IntType) arg;
+ return (super.equals(arg) && (unsigned == t.unsigned));
+ }
- public IntType asInt() { return this; }
+ @Override
+ public void setName(String name) {
+ super.setName(name);
+ typedefedUnsigned = unsigned;
+ }
- /** Indicates whether this type is unsigned */
- public boolean isUnsigned() { return unsigned; }
+ @Override
+ public IntType asInt() {
+ return this;
+ }
- public String toString() {
- return getCVAttributesString() + ((isUnsigned() & (!typedefedUnsigned)) ? "unsigned " : "") + getName();
- }
+ /** Indicates whether this type is unsigned */
+ public boolean isUnsigned() {
+ return unsigned;
+ }
+
+ @Override
+ public String toString() {
+ return getCVAttributesString() + ((isUnsigned() & (!typedefedUnsigned)) ? "unsigned " : "") + getName();
+ }
- Type newCVVariant(int cvAttributes) {
- return new IntType(getName(), getSize(), isUnsigned(), cvAttributes, typedefedUnsigned);
- }
+ Type newCVVariant(int cvAttributes) {
+ return new IntType(getName(), getSize(), isUnsigned(), cvAttributes, typedefedUnsigned);
+ }
}
diff --git a/src/java/com/sun/gluegen/cgram/types/PointerType.java b/src/java/com/sun/gluegen/cgram/types/PointerType.java
index f95066a..712c4ee 100644
--- a/src/java/com/sun/gluegen/cgram/types/PointerType.java
+++ b/src/java/com/sun/gluegen/cgram/types/PointerType.java
@@ -36,107 +36,123 @@
* Sun gratefully acknowledges that this software was originally authored
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-
package com.sun.gluegen.cgram.types;
public class PointerType extends Type {
- private Type targetType;
- private String computedName;
- private boolean hasTypedefedName;
-
- public PointerType(SizeThunk size, Type targetType, 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) {
- super(targetType.getName() + " *", size, cvAttributes);
- this.hasTypedefedName = false;
- this.targetType = targetType;
- if (hasTypedefedName) {
- setName(typedefedName);
+
+ private Type targetType;
+ private String computedName;
+ private boolean hasTypedefedName;
+
+ public PointerType(SizeThunk size, Type targetType, 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) {
+ super(targetType.getName() + " *", size, cvAttributes);
+ this.hasTypedefedName = false;
+ this.targetType = targetType;
+ if (hasTypedefedName) {
+ setName(typedefedName);
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return targetType.hashCode();
}
- }
- public int hashCode() {
- return targetType.hashCode();
- }
+ @Override
+ public boolean equals(Object arg) {
+ if (arg == this) {
+ return true;
+ }
+ if (arg == null || (!(arg instanceof PointerType))) {
+ return false;
+ }
+ 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
+ // canonicalized to e.g. "LPPIXELFORMATDESCRIPTOR"
+ return ((getSize() == t.getSize())
+ && (getCVAttributes() == t.getCVAttributes())
+ && targetType.equals(t.targetType));
+ }
- public boolean equals(Object arg) {
- if (arg == this) return true;
- if (arg == null || (!(arg instanceof PointerType))) {
- return false;
+ @Override
+ public void setName(String name) {
+ super.setName(name);
+ hasTypedefedName = true;
}
- 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
- // canonicalized to e.g. "LPPIXELFORMATDESCRIPTOR"
- return ((getSize() == t.getSize()) &&
- (getCVAttributes() == t.getCVAttributes()) &&
- targetType.equals(t.targetType));
- }
-
- public void setName(String name) {
- super.setName(name);
- hasTypedefedName = true;
- }
-
- public String getName(boolean includeCVAttrs) {
- if (hasTypedefedName) {
- return super.getName(includeCVAttrs);
- } else {
- // Lazy computation of name due to lazy setting of compound type
- // names during parsing
- if (computedName == null) {
- computedName = targetType.getName(includeCVAttrs) + " *";
- computedName = computedName.intern();
- }
- if (!includeCVAttrs) {
- return computedName;
- }
- return targetType.getName(includeCVAttrs) + " * " + getCVAttributesString();
+
+ @Override
+ public String getName(boolean includeCVAttrs) {
+ if (hasTypedefedName) {
+ return super.getName(includeCVAttrs);
+ } else {
+ // Lazy computation of name due to lazy setting of compound type
+ // names during parsing
+ if (computedName == null) {
+ computedName = targetType.getName(includeCVAttrs) + " *";
+ computedName = computedName.intern();
+ }
+ if (!includeCVAttrs) {
+ return computedName;
+ }
+ return targetType.getName(includeCVAttrs) + " * " + getCVAttributesString();
+ }
}
- }
- public boolean hasTypedefedName() {
- return hasTypedefedName;
- }
+ public boolean hasTypedefedName() {
+ return hasTypedefedName;
+ }
- public PointerType asPointer() { return this; }
+ @Override
+ public PointerType asPointer() {
+ return this;
+ }
- public Type getTargetType() { return targetType; }
+ public Type getTargetType() {
+ return targetType;
+ }
- public boolean isFunctionPointer() { return targetType.isFunction(); }
+ @Override
+ public boolean isFunctionPointer() {
+ return targetType.isFunction();
+ }
- public String toString() {
- if (hasTypedefedName) {
- return super.getName(true);
- } else {
- if (!targetType.isFunction()) {
- return targetType.toString() + " * " + getCVAttributesString();
- }
- return toString(null, null); // this is a pointer to an unnamed function
+ @Override
+ public String toString() {
+ if (hasTypedefedName) {
+ return super.getName(true);
+ } else {
+ if (!targetType.isFunction()) {
+ return targetType.toString() + " * " + getCVAttributesString();
+ }
+ return toString(null, null); // this is a pointer to an unnamed function
+ }
}
- }
-
- /** 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) {
- if (!targetType.isFunction()) {
- throw new RuntimeException("<Internal error or misuse> This method is only for use when printing function pointers");
+
+ /** 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) {
+ if (!targetType.isFunction()) {
+ throw new RuntimeException("<Internal error or misuse> This method is only for use when printing function pointers");
+ }
+ return ((FunctionType) targetType).toString(functionName, callingConvention, false, true);
}
- return ((FunctionType) targetType).toString(functionName, callingConvention, false, true);
- }
- public void visit(TypeVisitor arg) {
- super.visit(arg);
- targetType.visit(arg);
- }
+ @Override
+ public void visit(TypeVisitor arg) {
+ super.visit(arg);
+ targetType.visit(arg);
+ }
- Type newCVVariant(int cvAttributes) {
- return new PointerType(getSize(), targetType, cvAttributes, hasTypedefedName, (hasTypedefedName ? getName() : null));
- }
+ Type newCVVariant(int cvAttributes) {
+ return new PointerType(getSize(), targetType, cvAttributes, hasTypedefedName, (hasTypedefedName ? getName() : null));
+ }
}
diff --git a/src/java/com/sun/gluegen/cgram/types/PrimitiveType.java b/src/java/com/sun/gluegen/cgram/types/PrimitiveType.java
index 80dab9a..8b6e096 100644
--- a/src/java/com/sun/gluegen/cgram/types/PrimitiveType.java
+++ b/src/java/com/sun/gluegen/cgram/types/PrimitiveType.java
@@ -36,15 +36,16 @@
* Sun gratefully acknowledges that this software was originally authored
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-
package com.sun.gluegen.cgram.types;
public abstract class PrimitiveType extends Type {
- protected PrimitiveType(String name, SizeThunk size, int cvAttributes) {
- super(name, size, cvAttributes);
- }
- public boolean isPrimitive() {
- return true;
- }
+ protected PrimitiveType(String name, SizeThunk size, int cvAttributes) {
+ super(name, size, cvAttributes);
+ }
+
+ @Override
+ public boolean isPrimitive() {
+ return true;
+ }
}
diff --git a/src/java/com/sun/gluegen/cgram/types/Type.java b/src/java/com/sun/gluegen/cgram/types/Type.java
index 0dcaabc..4df034b 100644
--- a/src/java/com/sun/gluegen/cgram/types/Type.java
+++ b/src/java/com/sun/gluegen/cgram/types/Type.java
@@ -45,8 +45,8 @@ import java.util.List;
double. All types have an associated name. Structs and unions are
modeled as "compound" types -- composed of fields of primitive or
other types. */
-
public abstract class Type {
+
private String name;
private SizeThunk size;
private int cvAttributes;
@@ -158,13 +158,13 @@ public abstract class Type {
}
/** Hashcode for Types. */
+ @Override
public int hashCode() {
if (name == null) {
return 0;
}
- if (cvAttributes != 0)
- {
+ if (cvAttributes != 0) {
String nameWithAttribs = name + cvAttributes;
return nameWithAttribs.hashCode();
}
@@ -174,6 +174,7 @@ public abstract class Type {
/**
* Equality test for Types.
*/
+ @Override
public boolean equals(Object arg) {
if (arg == this) {
return true;
@@ -182,14 +183,14 @@ public abstract class Type {
return false;
}
Type t = (Type) arg;
- return ((name == t.name || (name != null && name.equals(name))) &&
- (size == t.size) &&
- (cvAttributes == t.cvAttributes));
+ return (((name == null ? t.name == null : name.equals(t.name)) || (name != null && name.equals(name))) &&
+ (size == t.size) && (cvAttributes == t.cvAttributes));
}
/** Returns a string representation of this type. This string is not
necessarily suitable for use as a type specifier; for example,
it will contain an expanded description of structs/unions. */
+ @Override
public String toString() {
return getName(true);
}
@@ -256,7 +257,6 @@ public abstract class Type {
/** Helper routine for list equality comparison */
static boolean listsEqual(List a, List b) {
- return ((a == null && b == null) ||
- (a != null && b != null && a.equals(b)));
+ return ((a == null && b == null) || (a != null && b != null && a.equals(b)));
}
}
diff --git a/src/java/com/sun/gluegen/cgram/types/VoidType.java b/src/java/com/sun/gluegen/cgram/types/VoidType.java
index 3a2f1b9..779a661 100644
--- a/src/java/com/sun/gluegen/cgram/types/VoidType.java
+++ b/src/java/com/sun/gluegen/cgram/types/VoidType.java
@@ -36,21 +36,24 @@
* Sun gratefully acknowledges that this software was originally authored
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-
package com.sun.gluegen.cgram.types;
public class VoidType extends Type {
- public VoidType(int cvAttributes) {
- this("void", cvAttributes);
- }
- private VoidType(String name, int cvAttributes) {
- super(name, null, cvAttributes);
- }
+ public VoidType(int cvAttributes) {
+ this("void", cvAttributes);
+ }
+
+ private VoidType(String name, int cvAttributes) {
+ super(name, null, cvAttributes);
+ }
- public VoidType asVoid() { return this; }
+ @Override
+ public VoidType asVoid() {
+ return this;
+ }
- Type newCVVariant(int cvAttributes) {
- return new VoidType(getName(), cvAttributes);
- }
+ Type newCVVariant(int cvAttributes) {
+ return new VoidType(getName(), cvAttributes);
+ }
}
diff --git a/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java b/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java
index a6c0cfc..8653b07 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 9352bcb..5e7ef7a 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 4ca2e69..ff307c4 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 662e75b..33f94fb 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);