Package com.jogamp.gluegen.cgram.types
Class CompoundType
- java.lang.Object
-
- com.jogamp.gluegen.cgram.types.Type
-
- com.jogamp.gluegen.cgram.types.MemoryLayoutType
-
- com.jogamp.gluegen.cgram.types.CompoundType
-
- All Implemented Interfaces:
ASTLocusTag.ASTLocusTagProvider
,AliasedSymbol
,TypeComparator.SemanticEqualityOp
,Cloneable
- Direct Known Subclasses:
StructType
,UnionType
public abstract class CompoundType extends MemoryLayoutType implements Cloneable, AliasedSymbol
Models all compound types, i.e., those containing fields: structs and unions. The boolean type accessors indicate how the type is really defined.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.jogamp.gluegen.cgram.types.AliasedSymbol
AliasedSymbol.AliasedSymbolImpl, AliasedSymbol.NoneAliasedSymbol
-
-
Field Summary
-
Fields inherited from class com.jogamp.gluegen.cgram.types.Type
relaxedEqSem
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addAliasedName(String origName)
void
addField(Field f)
Adds a field to this type.CompoundType
asCompound()
Casts this to a CompoundType or returns null if not a CompoundType.static CompoundType
create(String structName, SizeThunk size, CompoundTypeKind kind, int cvAttributes, ASTLocusTag astLocus)
protected boolean
equalSemanticsImpl(Type arg)
protected boolean
equalsImpl(Type arg)
Set<String>
getAliasedNames()
Return all aliases for this symbol, i.e.String
getAliasedString()
String
getCName(boolean includeCVAttrs)
Returns the name of this type, optionally including const/volatile attributes.Field
getField(int i)
Returns the ith field of this type.Field
getField(String name)
Returns the name matching field of this type.int
getNumFields()
Returns the number of fields in this type.String
getOrigName()
Return the original-name as set at creation.String
getStructName()
Returns the struct name of this CompoundType, i.e.String
getStructString()
boolean
hasAliases()
Returnstrue
if this symbol has aliases, i.e.protected int
hashCodeImpl()
protected int
hashCodeSemanticsImpl()
abstract boolean
isStruct()
Indicates whether this type was declared as a struct.abstract boolean
isUnion()
Indicates whether this type was declared as a union.void
rename(String newName)
Rename this symbol with the givennewName
if not equalcurrent-name
.void
setBodyParsed()
Indicates to this CompoundType that its body has been parsed and that no moreaddField(com.jogamp.gluegen.cgram.types.Field)
operations will be made.String
toString()
Returns a string representation of this type.void
visit(TypeVisitor arg)
Traverse thisType
and all of its component types; for example, the return type and argument types of a FunctionType.-
Methods inherited from class com.jogamp.gluegen.cgram.types.MemoryLayoutType
isLayouted, setLayouted
-
Methods inherited from class com.jogamp.gluegen.cgram.types.Type
arrayDimension, asArray, asBit, asDouble, asEnum, asFloat, asFunction, asInt, asPointer, asVoid, clearCache, clone, equals, equalSemantics, getArrayBaseOrPointerTargetType, getASTLocusTag, getBaseType, getCName, getCVAttributes, getCVAttributesString, getDebugString, getName, getName, getSignature, getSize, getSize, getTargetFunction, getTargetType, hashCode, hashCodeSemantics, hasSize, isAnon, isArray, isBaseTypeConst, isBit, isCompound, isConst, isDouble, isEnum, isFloat, isFunction, isFunctionPointer, isInt, isPointer, isPrimitive, isTypedef, isVoid, isVolatile, newCVVariant, pointerDepth, setTypedefName
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.jogamp.gluegen.cgram.types.AliasedSymbol
getName
-
-
-
-
Method Detail
-
rename
public void rename(String newName)
Description copied from interface:AliasedSymbol
Rename this symbol with the givennewName
if not equalcurrent-name
.Before renaming the
current-name
will be added to the list ofaliases
. while the givennewName
will be removed.Operation will be ignored if
newName
isnull
.- Specified by:
rename
in interfaceAliasedSymbol
- Parameters:
newName
- the newcurrent-name
, maybenull
-
addAliasedName
public void addAliasedName(String origName)
Description copied from interface:AliasedSymbol
Add the givenorigName
to the list ofaliases
if not equalcurrent-name
.Operation will be ignored if
newName
isnull
.- Specified by:
addAliasedName
in interfaceAliasedSymbol
- Parameters:
origName
- the new alias to be added, maybenull
-
hasAliases
public boolean hasAliases()
Description copied from interface:AliasedSymbol
Returnstrue
if this symbol has aliases, i.e. either beingrenamed
oraliases-added
.Otherwise
false
is being returned.- Specified by:
hasAliases
in interfaceAliasedSymbol
-
getAliasedNames
public Set<String> getAliasedNames()
Description copied from interface:AliasedSymbol
Return all aliases for this symbol, i.e. original names, for this symbol.Inclusive
original-name
, ifrenamed
,Exclusive
current-name
.May return
null
or a zero sizedSet
for no aliases.- Specified by:
getAliasedNames
in interfaceAliasedSymbol
-
getAliasedString
public String getAliasedString()
Description copied from interface:AliasedSymbol
- Specified by:
getAliasedString
in interfaceAliasedSymbol
-
getOrigName
public String getOrigName()
Description copied from interface:AliasedSymbol
Return the original-name as set at creation.- Specified by:
getOrigName
in interfaceAliasedSymbol
-
create
public static CompoundType create(String structName, SizeThunk size, CompoundTypeKind kind, int cvAttributes, ASTLocusTag astLocus)
- Parameters:
structName
- struct name of this CompoundType, i.e. the "foo" in the constructstruct foo { int a, ... };
orstruct foo;
even for anonymous structs.size
-kind
-cvAttributes
-- Returns:
-
hashCodeImpl
protected int hashCodeImpl()
- Specified by:
hashCodeImpl
in classType
-
equalsImpl
protected boolean equalsImpl(Type arg)
- Specified by:
equalsImpl
in classType
-
hashCodeSemanticsImpl
protected int hashCodeSemanticsImpl()
- Specified by:
hashCodeSemanticsImpl
in classType
-
equalSemanticsImpl
protected boolean equalSemanticsImpl(Type arg)
- Specified by:
equalSemanticsImpl
in classType
-
getStructName
public String getStructName()
Returns the struct name of this CompoundType, i.e. the "foo" in the construct "struct foo { ... };".
-
asCompound
public CompoundType asCompound()
Description copied from class:Type
Casts this to a CompoundType or returns null if not a CompoundType.- Overrides:
asCompound
in classType
-
getCName
public String getCName(boolean includeCVAttrs)
Description copied from class:Type
Returns the name of this type, optionally including const/volatile attributes. The returned string is suitable for use as a type specifier for native C.
-
getNumFields
public int getNumFields()
Returns the number of fields in this type.
-
getField
public Field getField(int i)
Returns the ith field of this type.
-
addField
public void addField(Field f)
Adds a field to this type.
-
setBodyParsed
public void setBodyParsed() throws IllegalStateException
Indicates to this CompoundType that its body has been parsed and that no moreaddField(com.jogamp.gluegen.cgram.types.Field)
operations will be made.- Throws:
IllegalStateException
- If called twice.
-
isStruct
public abstract boolean isStruct()
Indicates whether this type was declared as a struct.
-
isUnion
public abstract boolean isUnion()
Indicates whether this type was declared as a union.
-
toString
public String toString()
Description copied from class:Type
Returns a string representation of this type. The returned string is suitable for use as a type specifier for native C. It does contain an expanded description of structs/unions, hence may not be suitable for type declarations.
-
visit
public void visit(TypeVisitor arg)
Description copied from class:Type
Traverse thisType
and all of its component types; for example, the return type and argument types of a FunctionType.
-
getStructString
public String getStructString()
-
-