Package com.jogamp.gluegen.cgram.types
Class Type
java.lang.Object
com.jogamp.gluegen.cgram.types.Type
- All Implemented Interfaces:
ASTLocusTag.ASTLocusTagProvider,TypeComparator.SemanticEqualityOp
- Direct Known Subclasses:
FunctionType,MemoryLayoutType,PointerType,PrimitiveType,VoidType
public abstract class Type
extends Object
implements TypeComparator.SemanticEqualityOp, ASTLocusTag.ASTLocusTagProvider
Models a C type. Primitive types include int, float, and
double. All types have an associated name. Structs and unions are
modeled as "compound" types -- composed of fields of primitive or
other types.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedType(String name, SizeThunk size, int cvAttributes, ASTLocusTag astLocus) -
Method Summary
Modifier and TypeMethodDescriptionintHelper method for determining how many array dimentions this type represents (i.e., "char[][]" returns 2).asArray()Casts this to an ArrayType or returns null if not an ArrayType.asBit()Casts this to a BitType or returns null if not a BitType.Casts this to a CompoundType or returns null if not a CompoundType.asDouble()Casts this to a DoubleType or returns null if not a DoubleType.asEnum()Casts this to an EnumType or returns null if not an EnumType.asFloat()Casts this to a FloatType or returns null if not a FloatType.Casts this to a FunctionType or returns null if not a FunctionType.asInt()Casts this to an IntType or returns null if not an IntType.Casts this to a PointerType or returns null if not a PointerType.asVoid()Casts this to a VoidType or returns null if not a VoidType.protected final voidclone(ASTLocusTag newLoc) Clones this instance using a newASTLocusTag.final booleanEquality test for Types inclusive its givenname.final booleanSemantic equality test for Types exclusive its givenname.protected abstract booleanprotected abstract booleanequalsImpl(Type t) final ASTLocusTagReturns this instance'sASTLocusTag, if available, otherwise returnsnull.Helper method to returns the bottom-most element type of this type.final StringgetCName()Returns the name of this type.getCName(boolean includeCVAttrs) Returns the name of this type, optionally including const/volatile attributes.final intfinal StringReturns a string indicating the const/volatile attributes of this type.final Stringfinal StringgetName()Returns the name of this type.getName(boolean includeCVAttrs) Returns the name of this type, optionally including const/volatile attributes.final SizeThunkgetSize()SizeThunk which computes size of this type in bytes.final longgetSize(MachineDataInfo machDesc) Size of this type in bytes according to the given MachineDataInfo.Helper method to returns the target type of this type, in case another type is being referenced.final inthashCode()Hashcode for Types.protected abstract intfinal intSemantic hashcode for Types exclusive its givenname.protected abstract intbooleanisAnon()final booleanisArray()Indicates whether this is an ArrayType.final booleanChecks the base type of pointer-to-pointer, pointer, array or plain for const-ness.final booleanisBit()Indicates whether this is a BitType.final booleanIndicates whether this is a CompoundType.final booleanisConst()Indicates whether this type is const.final booleanisDouble()Indicates whether this is a DoubleType.final booleanisEnum()Indicates whether this is an EnumType.final booleanisFloat()Indicates whether this is a FloatType.final booleanIndicates whether this is a FunctionType.booleanConvenience routine indicating whether this Type is a pointer to a function.final booleanisInt()Indicates whether this is an IntType.final booleanIndicates whether this is a PointerType.booleanIndicates whether this type is a primitive type.final booleanIndicates whether this type is a typedef type, i.e.final booleanisVoid()Indicates whether this is a VoidType.final booleanIndicates whether this type is volatile.final TypenewCVVariant(int cvAttributes) Return a variant of this type matching the given const/volatile attributes.intHelper method for determining how many pointer indirections this type represents (i.e., "void **" returns 2).booleansetTypedefName(String name) Set the typedef name of this type and renders this type a typedef, if givennamehas a length.toString()Returns a string representation of this type.voidvisit(TypeVisitor visitor) Traverse thisTypeand all of its component types; for example, the return type and argument types of a FunctionType.
-
Field Details
-
relaxedEqSem
public final boolean relaxedEqSem
-
-
Constructor Details
-
Type
-
-
Method Details
-
clearCache
protected final void clearCache() -
newCVVariant
Return a variant of this type matching the given const/volatile attributes. May return this object if the attributes match. -
clone
Clones this instance using a newASTLocusTag. -
getASTLocusTag
Description copied from interface:ASTLocusTag.ASTLocusTagProviderReturns this instance'sASTLocusTag, if available, otherwise returnsnull.- Specified by:
getASTLocusTagin interfaceASTLocusTag.ASTLocusTagProvider
-
isAnon
public boolean isAnon() -
getCName
Returns the name of this type. The returned string is suitable for use as a type specifier for native C. Does not include any const/volatile attributes. -
getCName
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. -
getName
Returns the name of this type. The returned string is suitable for use as a type specifier for Java. Does not include any const/volatile attributes. -
getName
Returns the name of this type, optionally including const/volatile attributes. The returned string is suitable for use as a type specifier for Java. -
toString
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. -
getDebugString
-
setTypedefName
Set the typedef name of this type and renders this type a typedef, if givennamehas a length.Method issues
clearCache(), to force re-evaluation of hashes. -
isTypedef
public final boolean isTypedef()Indicates whether this type is a typedef type, i.e. declared viasetTypedefName(String). -
getSize
SizeThunk which computes size of this type in bytes. -
getSize
Size of this type in bytes according to the given MachineDataInfo. -
asBit
Casts this to a BitType or returns null if not a BitType. -
asInt
Casts this to an IntType or returns null if not an IntType. -
asEnum
Casts this to an EnumType or returns null if not an EnumType. -
asFloat
Casts this to a FloatType or returns null if not a FloatType. -
asDouble
Casts this to a DoubleType or returns null if not a DoubleType. -
asPointer
Casts this to a PointerType or returns null if not a PointerType. -
asArray
Casts this to an ArrayType or returns null if not an ArrayType. -
asCompound
Casts this to a CompoundType or returns null if not a CompoundType. -
asFunction
Casts this to a FunctionType or returns null if not a FunctionType. -
asVoid
Casts this to a VoidType or returns null if not a VoidType. -
isBit
public final boolean isBit()Indicates whether this is a BitType. -
isInt
public final boolean isInt()Indicates whether this is an IntType. -
isEnum
public final boolean isEnum()Indicates whether this is an EnumType. -
isFloat
public final boolean isFloat()Indicates whether this is a FloatType. -
isDouble
public final boolean isDouble()Indicates whether this is a DoubleType. -
isPointer
public final boolean isPointer()Indicates whether this is a PointerType. -
isArray
public final boolean isArray()Indicates whether this is an ArrayType. -
isCompound
public final boolean isCompound()Indicates whether this is a CompoundType. -
isFunction
public final boolean isFunction()Indicates whether this is a FunctionType. -
isVoid
public final boolean isVoid()Indicates whether this is a VoidType. -
isVolatile
public final boolean isVolatile()Indicates whether this type is volatile. -
isConst
public final boolean isConst()Indicates whether this type is const. -
isPrimitive
public boolean isPrimitive()Indicates whether this type is a primitive type. -
isFunctionPointer
public boolean isFunctionPointer()Convenience routine indicating whether this Type is a pointer to a function. -
isBaseTypeConst
public final boolean isBaseTypeConst()Checks the base type of pointer-to-pointer, pointer, array or plain for const-ness.Note: Intermediate 'const' qualifier are not considered, e.g. const pointer.
-
hashCode
public final int hashCode()Hashcode for Types. -
hashCodeImpl
protected abstract int hashCodeImpl() -
equals
Equality test for Types inclusive its givenname. -
equalsImpl
-
hashCodeSemantics
public final int hashCodeSemantics()Description copied from interface:TypeComparator.SemanticEqualityOpSemantic hashcode for Types exclusive its givenname.- Specified by:
hashCodeSemanticsin interfaceTypeComparator.SemanticEqualityOp- See Also:
-
hashCodeSemanticsImpl
protected abstract int hashCodeSemanticsImpl() -
equalSemantics
Description copied from interface:TypeComparator.SemanticEqualityOpSemantic equality test for Types exclusive its givenname.- Specified by:
equalSemanticsin interfaceTypeComparator.SemanticEqualityOp- See Also:
-
equalSemanticsImpl
-
visit
Traverse thisTypeand all of its component types; for example, the return type and argument types of a FunctionType. -
getCVAttributes
public final int getCVAttributes() -
getCVAttributesString
Returns a string indicating the const/volatile attributes of this type. -
pointerDepth
public int pointerDepth()Helper method for determining how many pointer indirections this type represents (i.e., "void **" returns 2). Returns 0 if this type is not a pointer type. -
arrayDimension
public int arrayDimension()Helper method for determining how many array dimentions this type represents (i.e., "char[][]" returns 2). Returns 0 if this type is not an array type. -
getBaseElementType
Helper method to returns the bottom-most element type of this type.If this is a multidimensional array or pointer method returns the bottom-most element type, otherwise this.
-
getTargetType
Helper method to returns the target type of this type, in case another type is being referenced.
-