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 voidaddAliasedName(String origName)voidaddField(Field f)Adds a field to this type.CompoundTypeasCompound()Casts this to a CompoundType or returns null if not a CompoundType.static CompoundTypecreate(String structName, SizeThunk size, CompoundTypeKind kind, int cvAttributes, ASTLocusTag astLocus)protected booleanequalSemanticsImpl(Type arg)protected booleanequalsImpl(Type arg)Set<String>getAliasedNames()Return all aliases for this symbol, i.e.StringgetAliasedString()StringgetCName(boolean includeCVAttrs)Returns the name of this type, optionally including const/volatile attributes.FieldgetField(int i)Returns the ith field of this type.FieldgetField(String name)Returns the name matching field of this type.intgetNumFields()Returns the number of fields in this type.StringgetOrigName()Return the original-name as set at creation.StringgetStructName()Returns the struct name of this CompoundType, i.e.StringgetStructString()booleanhasAliases()Returnstrueif this symbol has aliases, i.e.protected inthashCodeImpl()protected inthashCodeSemanticsImpl()abstract booleanisStruct()Indicates whether this type was declared as a struct.abstract booleanisUnion()Indicates whether this type was declared as a union.voidrename(String newName)Rename this symbol with the givennewNameif not equalcurrent-name.voidsetBodyParsed()Indicates to this CompoundType that its body has been parsed and that no moreaddField(com.jogamp.gluegen.cgram.types.Field)operations will be made.StringtoString()Returns a string representation of this type.voidvisit(TypeVisitor arg)Traverse thisTypeand 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:AliasedSymbolRename this symbol with the givennewNameif not equalcurrent-name.Before renaming the
current-namewill be added to the list ofaliases. while the givennewNamewill be removed.Operation will be ignored if
newNameisnull.- Specified by:
renamein interfaceAliasedSymbol- Parameters:
newName- the newcurrent-name, maybenull
-
addAliasedName
public void addAliasedName(String origName)
Description copied from interface:AliasedSymbolAdd the givenorigNameto the list ofaliasesif not equalcurrent-name.Operation will be ignored if
newNameisnull.- Specified by:
addAliasedNamein interfaceAliasedSymbol- Parameters:
origName- the new alias to be added, maybenull
-
hasAliases
public boolean hasAliases()
Description copied from interface:AliasedSymbolReturnstrueif this symbol has aliases, i.e. either beingrenamedoraliases-added.Otherwise
falseis being returned.- Specified by:
hasAliasesin interfaceAliasedSymbol
-
getAliasedNames
public Set<String> getAliasedNames()
Description copied from interface:AliasedSymbolReturn all aliases for this symbol, i.e. original names, for this symbol.Inclusive
original-name, ifrenamed,Exclusive
current-name.May return
nullor a zero sizedSetfor no aliases.- Specified by:
getAliasedNamesin interfaceAliasedSymbol
-
getAliasedString
public String getAliasedString()
Description copied from interface:AliasedSymbol- Specified by:
getAliasedStringin interfaceAliasedSymbol
-
getOrigName
public String getOrigName()
Description copied from interface:AliasedSymbolReturn the original-name as set at creation.- Specified by:
getOrigNamein 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:
hashCodeImplin classType
-
equalsImpl
protected boolean equalsImpl(Type arg)
- Specified by:
equalsImplin classType
-
hashCodeSemanticsImpl
protected int hashCodeSemanticsImpl()
- Specified by:
hashCodeSemanticsImplin classType
-
equalSemanticsImpl
protected boolean equalSemanticsImpl(Type arg)
- Specified by:
equalSemanticsImplin 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:TypeCasts this to a CompoundType or returns null if not a CompoundType.- Overrides:
asCompoundin classType
-
getCName
public String getCName(boolean includeCVAttrs)
Description copied from class:TypeReturns 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 IllegalStateExceptionIndicates 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:TypeReturns 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:TypeTraverse thisTypeand all of its component types; for example, the return type and argument types of a FunctionType.
-
getStructString
public String getStructString()
-
-