40package com.jogamp.gluegen.cgram.types;
42import java.util.ArrayList;
43import java.util.NoSuchElementException;
45import com.jogamp.gluegen.ASTLocusTag;
46import com.jogamp.gluegen.ConstantDefinition;
47import com.jogamp.gluegen.ConstantDefinition.CNumber;
48import com.jogamp.gluegen.GlueGenException;
49import com.jogamp.gluegen.cgram.types.TypeComparator.SemanticEqualityOp;
57 private final String name;
58 private final String expr;
63 this.number =
new CNumber(
false,
false, value);
71 public Enumerator(
final String name,
final String value) {
80 public boolean hasNumber() {
return null != number; }
85 final int hash = name.hashCode();
86 return ((hash << 5) - hash) + expr.hashCode();
90 public boolean equals(
final Object arg) {
97 return name.
equals(t.name) &&
112 public String
toString() {
return "["+name+
" = ["+expr+
", "+number+
"]"; }
115 private final IntType underlyingType;
116 private ArrayList<Enumerator> enums;
129 super(o, cvAttributes, astLocus);
130 underlyingType = o.underlyingType;
131 if(
null != o.enums) {
132 enums =
new ArrayList<Enumerator>(o.enums);
138 return new EnumType(
this, cvAttributes, astLocus);
144 int hash = super.hashCodeImpl();
145 hash = ((hash << 5) - hash) + underlyingType.
hashCode();
146 return ((hash << 5) - hash) +
TypeComparator.listsHashCode(enums);
153 underlyingType.
equals(t.underlyingType) &&
160 int hash = super.hashCodeSemanticsImpl();
162 return ((hash << 5) - hash) +
TypeComparator.listsHashCodeSemantics(enums);
182 enums =
new ArrayList<Enumerator>();
200 for (
int i = 0; i < enums.size(); ++i) {
202 if (n.
getName().equals(name)) {
206 throw new NoSuchElementException(
207 "No enumerate named \"" + name +
"\" in EnumType \""
213 for (
int i = 0; i < enums.size(); ++i) {
214 if ((enums.get(i)).getName().equals(name)) {
225 for (
int i = 0; i < enums.size(); ++i) {
227 if (e.
getName().equals(name)) {
236 public StringBuilder
appendEnums(
final StringBuilder sb,
final boolean cr) {
237 for(
int i=0; i<enums.size(); i++) {
238 sb.append(enums.get(i)).append(
", ");
240 sb.append(String.format(
"%n"));
250 underlyingType.
visit(arg);
A Number, either integer, optionally [long, unsigned], or floating point, optionally [double].
final String toJavaString()
Represents a [native] constant expression, comprises the [native] expression, see getNativeExpr() and...
static CNumber decodeIntegerNumber(final String v)
If the given string isIntegerNumber(String), return the decoded integer value, represented as a ANumb...
Enumerator(final String name, final long value)
boolean equalSemantics(final SemanticEqualityOp arg)
Semantic equality test for Types exclusive its given name.
boolean equals(final Object arg)
int hashCodeSemantics()
Semantic hashcode for Types exclusive its given name.
Enumerator(final String name, final String value)
Enumerator(final String name, final CNumber number)
Describes enumerated types.
boolean equalSemanticsImpl(final Type arg)
EnumType(final String name)
boolean containsEnumerate(final String name)
Does this enum type contain an enumerate with the given name?
boolean equalsImpl(final Type arg)
boolean removeEnumerate(final String name)
Remove the enumerate with the given name.
int getNumEnumerates()
Number of enumerates defined in this enum.
Enumerator getEnum(final int i)
Fetch ith (0..getNumEnumerates() - 1) Enumerator.
EnumType asEnum()
Casts this to an EnumType or returns null if not an EnumType.
void visit(final TypeVisitor arg)
Traverse this Type and all of its component types; for example, the return type and argument types of...
StringBuilder appendEnums(final StringBuilder sb, final boolean cr)
int hashCodeSemanticsImpl()
Enumerator getEnum(final String name)
Fetch the enumerate with the given name.
EnumType(final String name, final SizeThunk enumSizeInBytes, final ASTLocusTag astLocus)
void addEnum(final String name, final Enumerator newEnum)
IntType(final String name, final SizeThunk size, final boolean unsigned, final int cvAttributes)
Provides a level of indirection between the definition of a type's size and the absolute value of thi...
static final SizeThunk LONG
final int hashCodeSemantics()
Semantic hashcode for Types exclusive its given name.
abstract boolean equalSemanticsImpl(final Type t)
final int hashCode()
Hashcode for Types.
abstract boolean equalsImpl(final Type t)
final boolean equalSemantics(final SemanticEqualityOp arg)
Semantic equality test for Types exclusive its given name.
final String getName()
Returns the name of this type.
void visit(final TypeVisitor visitor)
Traverse this Type and all of its component types; for example, the return type and argument types of...
final boolean equals(final Object arg)
Equality test for Types inclusive its given name.
final Type newCVVariant(final int cvAttributes)
Return a variant of this type matching the given const/volatile attributes.
Enumeration for const/volatile attributes.
Supports semantic equality and hash functions for types.
A visitor for Type's visitor model.