41package com.jogamp.gluegen.cgram.types;
45import com.jogamp.gluegen.ASTLocusTag;
53 private final String structName;
54 private ArrayList<Field> fields;
55 private boolean visiting;
56 private boolean bodyParsed;
59 public void rename(
final String newName) {
60 throw new UnsupportedOperationException();
64 throw new UnsupportedOperationException();
97 res =
new StructType(
null, size, cvAttributes, structName, astLocus);
100 res =
new UnionType(
null, size, cvAttributes, structName, astLocus);
103 throw new RuntimeException(
"OO relation "+kind+
" / Compount not yet supported");
109 final String structName,
final ASTLocusTag astLocus) {
110 super(
null == name ? structName : name, size, cvAttributes, astLocus);
111 this.structName = structName;
115 super(o, cvAttributes, astLocus);
116 this.structName = o.structName;
117 if(
null != o.fields) {
118 fields =
new ArrayList<Field>(o.fields);
120 bodyParsed = o.bodyParsed;
126 final int hash = 31 + (
null != structName ? structName.hashCode() : 0 );
127 return ((hash << 5) - hash) +
TypeComparator.listsHashCode(fields);
133 return ( (structName ==
null ? ct.structName ==
null : structName.equals(ct.structName)) ||
134 (structName !=
null && structName.equals(ct.structName))
161 public String
getCName(
final boolean includeCVAttrs) {
163 return getName(includeCVAttrs);
169 ArrayList<Field> getFields() {
return fields; }
170 void setFields(
final ArrayList<Field> fields) { this.fields = fields;
clearCache(); }
174 return ((fields ==
null) ? 0 : fields.size());
179 return fields.get(i);
184 for(
final Field f : fields ) {
185 if( f.getName().equals(name) ) {
195 throw new IllegalStateException(String.format(
196 "Body of this CompoundType (%s) has been already closed (Field supplied %s)",
this, f
199 if (fields ==
null) {
200 fields =
new ArrayList<Field>();
213 throw new IllegalStateException(String.format(
214 "Body of this CompoundType (%s) has been already closed",
this
229 if (
null != cname ) {
230 return cvAttributesString + cname;
247 for (
int i = 0; i < n; i++) {
261 return "struct {/*Recursive type reference*/}";
266 final String kind = (
isStruct() ?
"struct {" :
"union {");
267 final StringBuilder res =
new StringBuilder();
270 for (
int i = 0; i < n; i++) {
275 return res.toString();
Models all compound types, i.e., those containing fields: structs and unions.
int hashCodeSemanticsImpl()
void rename(final String newName)
Rename this symbol with the given newName if not equal current-name.
void setBodyParsed()
Indicates to this CompoundType that its body has been parsed and that no more addField operations wil...
String getAliasedString()
Return this object's toString() wrapped w/ the current-name and all aliases.
boolean equalSemanticsImpl(final Type arg)
Field getField(final int i)
Returns the ith field of this type.
String getOrigName()
Return the original-name as set at creation.
void addField(final Field f)
Adds a field to this type.
Field getField(final String name)
Returns the name matching field of this type.
int getNumFields()
Returns the number of fields in this type.
String getStructName()
Returns the struct name of this CompoundType, i.e.
void addAliasedName(final String origName)
Add the given origName to the list of aliases if not equal current-name.
Set< String > getAliasedNames()
Return all aliases for this symbol, i.e.
String getCName(final boolean includeCVAttrs)
Returns the name of this type, optionally including const/volatile attributes.
abstract boolean isStruct()
Indicates whether this type was declared as a struct.
String toString()
Returns a string representation of this type.
boolean equalsImpl(final Type arg)
static CompoundType create(final String structName, final SizeThunk size, final CompoundTypeKind kind, final int cvAttributes, final ASTLocusTag astLocus)
void visit(final TypeVisitor arg)
Traverse this Type and all of its component types; for example, the return type and argument types of...
abstract boolean isUnion()
Indicates whether this type was declared as a union.
boolean hasAliases()
Returns true if this symbol has aliases, i.e.
CompoundType asCompound()
Casts this to a CompoundType or returns null if not a CompoundType.
Represents a field in a struct or union.
Type getType()
Type of this field.
Provides a level of indirection between the definition of a type's size and the absolute value of thi...
final String getCName()
Returns the name of this type.
final String getCVAttributesString()
Returns a string indicating the const/volatile attributes 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 isTypedef()
Indicates whether this type is a typedef type, i.e.
Type-safe enum for discriminating between structs and unions represented as compound types.
Supports symbol aliasing, i.e.
String getName()
Return the current-name, which is the last renamed-name if issued, or the original-name.
A visitor for Type's visitor model.