Top Description Fields Constructors Methods
com.jogamp.gluegen.cgram.types

public abstract Class Type

extends Object
implements SemanticEqualityOp, ASTLocusTagProvider
Class Inheritance
All Implemented Interfaces
com.jogamp.gluegen.ASTLocusTag.ASTLocusTagProvider, com.jogamp.gluegen.cgram.types.TypeComparator.SemanticEqualityOp
Known Direct Subclasses
com.jogamp.gluegen.cgram.types.VoidType, com.jogamp.gluegen.cgram.types.FunctionType, com.jogamp.gluegen.cgram.types.MemoryLayoutType, com.jogamp.gluegen.cgram.types.PointerType, com.jogamp.gluegen.cgram.types.PrimitiveType
Imports
com.jogamp.common.os.MachineDataInfo, com.jogamp.gluegen.ASTLocusTag.ASTLocusTagProvider, .ASTLocusTag, .GlueGen, .TypeConfig, com.jogamp.gluegen.cgram.types.TypeComparator.SemanticEqualityOp

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

Modifier and TypeField and Description
pack-priv final ASTLocusTag
private int
private int
private final int
private boolean
private boolean
private boolean
private String
public final boolean
private SizeThunk
private int

Constructor Summary

AccessConstructor and Description
protected
Type(final String name, final SizeThunk size, final int cvAttributes, final ASTLocusTag astLocus)

pack-priv
Type(final Type o, final int cvAttributes, final ASTLocusTag astLocus)

Method Summary

Modifier and TypeMethod and Description
private static StringBuilder
append(final StringBuilder sb, final String val, final boolean prepComma)

public int
arrayDimension()

Helper method for determining how many array dimentions this type represents (i.e., "char[][]" returns 2).

public ArrayType
asArray()

Casts this to an ArrayType or returns null if not an ArrayType.

public BitType
asBit()

Casts this to a BitType or returns null if not a BitType.

public CompoundType
asCompound()

Casts this to a CompoundType or returns null if not a CompoundType.

public DoubleType
asDouble()

Casts this to a DoubleType or returns null if not a DoubleType.

public EnumType
asEnum()

Casts this to an EnumType or returns null if not an EnumType.

public FloatType
asFloat()

Casts this to a FloatType or returns null if not a FloatType.

public FunctionType
asFunction()

Casts this to a FunctionType or returns null if not a FunctionType.

public IntType
asInt()

Casts this to an IntType or returns null if not an IntType.

public PointerType
asPointer()

Casts this to a PointerType or returns null if not a PointerType.

public VoidType
asVoid()

Casts this to a VoidType or returns null if not a VoidType.

protected final void
public Type
clone(final ASTLocusTag newLoc)

Clones this instance using a new ASTLocusTag.

public final boolean
equals(final Object
the reference object with which to compare.
arg
)

Overrides java.lang.Object.equals.

Equality test for Types inclusive its given name.
public final boolean
protected abstract boolean
protected abstract boolean
equalsImpl(final Type t)

public final ASTLocusTag
getASTLocusTag()

Implements com.jogamp.gluegen.ASTLocusTag.ASTLocusTagProvider.getASTLocusTag.

Returns this instance's ASTLocusTag, if available, otherwise returns null.
public Type
getBaseElementType()

Helper method to returns the bottom-most element type of this type.

public final String
getCName()

Returns the name of this type.

public String
getCName(final boolean includeCVAttrs)

Returns the name of this type, optionally including const/volatile attributes.

public final int
public final String
getCVAttributesString()

Returns a string indicating the const/volatile attributes of this type.

public final String
public final String
getName()

Returns the name of this type.

public String
getName(final boolean includeCVAttrs)

Returns the name of this type, optionally including const/volatile attributes.

public final SizeThunk
getSize()

SizeThunk which computes size of this type in bytes.

public final long
getSize(final MachineDataInfo machDesc)

Size of this type in bytes according to the given MachineDataInfo.

public Type
getTargetType()

Helper method to returns the target type of this type, in case another type is being referenced.

pack-priv final int
public final int
hashCode()

Overrides java.lang.Object.hashCode.

Hashcode for Types.
protected abstract int
public final int
protected abstract int
public boolean
public final boolean
isArray()

Indicates whether this is an ArrayType.

public final boolean
isBaseTypeConst()

Checks the base type of pointer-to-pointer, pointer, array or plain for const-ness.

public final boolean
isBit()

Indicates whether this is a BitType.

public final boolean
isCompound()

Indicates whether this is a CompoundType.

public final boolean
isConst()

Indicates whether this type is const.

private final boolean
private final boolean
public final boolean
isDouble()

Indicates whether this is a DoubleType.

public final boolean
isEnum()

Indicates whether this is an EnumType.

public final boolean
isFloat()

Indicates whether this is a FloatType.

public final boolean
isFunction()

Indicates whether this is a FunctionType.

public boolean
isFunctionPointer()

Convenience routine indicating whether this Type is a pointer to a function.

public final boolean
isInt()

Indicates whether this is an IntType.

public final boolean
isPointer()

Indicates whether this is a PointerType.

public boolean
isPrimitive()

Indicates whether this type is a primitive type.

public final boolean
isTypedef()

Indicates whether this type is a typedef type, i.e. declared via setTypedefName(String).

public final boolean
isVoid()

Indicates whether this is a VoidType.

public final boolean
isVolatile()

Indicates whether this type is volatile.

public final Type
newCVVariant(final int cvAttributes)

Return a variant of this type matching the given const/volatile attributes.

pack-priv abstract Type
newVariantImpl(final boolean
true if new variant is intended to have new cvAttributes
newCVVariant
,
final int
the cvAttributes to be used
cvAttributes
,
final ASTLocusTag
the ASTLocusTag to be used
astLocus
)

Create a new variant of this type matching the given parameter

Implementation must use Type's copy-ctor: Type(Type, int, ASTLocusTag)!

private final int
public int
pointerDepth()

Helper method for determining how many pointer indirections this type represents (i.e., "void **" returns 2).

private final boolean
setName(final String name)

Returns true if given name is not null and has a length > 0.

pack-priv final void
setSize(final SizeThunk size)

Set the size of this type; only available for CompoundTypes.

pack-priv final void
setTypedef(final int typedefedCVAttributes)

public boolean
setTypedefName(final String name)

Set the typedef name of this type and renders this type a typedef, if given name has a length.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of this type.
public void
visit(final TypeVisitor visitor)

Traverse this Type and all of its component types; for example, the return type and argument types of a FunctionType.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

astLocusback to summary
pack-priv final ASTLocusTag astLocus
cachedHashback to summary
private int cachedHash
cachedSemanticHashback to summary
private int cachedSemanticHash
cvAttributesback to summary
private final int cvAttributes
hasCachedHashback to summary
private boolean hasCachedHash
hasCachedSemanticHashback to summary
private boolean hasCachedSemanticHash
isTypedefback to summary
private boolean isTypedef
nameback to summary
private String name
relaxedEqSemback to summary
public final boolean relaxedEqSem
sizeback to summary
private SizeThunk size
typedefCVAttributesback to summary
private int typedefCVAttributes

Constructor Detail

Typeback to summary
protected Type(final String name, final SizeThunk size, final int cvAttributes, final ASTLocusTag astLocus)
Typeback to summary
pack-priv Type(final Type o, final int cvAttributes, final ASTLocusTag astLocus)

Method Detail

appendback to summary
private static StringBuilder append(final StringBuilder sb, final String val, final boolean prepComma)
arrayDimensionback to summary
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.

asArrayback to summary
public ArrayType asArray()

Casts this to an ArrayType or returns null if not an ArrayType.

asBitback to summary
public BitType asBit()

Casts this to a BitType or returns null if not a BitType.

asCompoundback to summary
public CompoundType asCompound()

Casts this to a CompoundType or returns null if not a CompoundType.

asDoubleback to summary
public DoubleType asDouble()

Casts this to a DoubleType or returns null if not a DoubleType.

asEnumback to summary
public EnumType asEnum()

Casts this to an EnumType or returns null if not an EnumType.

asFloatback to summary
public FloatType asFloat()

Casts this to a FloatType or returns null if not a FloatType.

asFunctionback to summary
public FunctionType asFunction()

Casts this to a FunctionType or returns null if not a FunctionType.

asIntback to summary
public IntType asInt()

Casts this to an IntType or returns null if not an IntType.

asPointerback to summary
public PointerType asPointer()

Casts this to a PointerType or returns null if not a PointerType.

asVoidback to summary
public VoidType asVoid()

Casts this to a VoidType or returns null if not a VoidType.

clearCacheback to summary
protected final void clearCache()
cloneback to summary
public Type clone(final ASTLocusTag newLoc)

Clones this instance using a new ASTLocusTag.

equalsback to summary
public final boolean equals(final Object arg)

Overrides java.lang.Object.equals.

Equality test for Types inclusive its given name.

Parameters
arg:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
equalSemanticsback to summary
public final boolean equalSemantics(final TypeComparator.SemanticEqualityOp arg)

Implements com.jogamp.gluegen.cgram.types.TypeComparator.SemanticEqualityOp.equalSemantics.

Doc from com.jogamp.gluegen.cgram.types.TypeComparator.SemanticEqualityOp.equalSemantics.

Semantic equality test for Types exclusive its given name.

Annotations
@Override
equalSemanticsImplback to summary
protected abstract boolean equalSemanticsImpl(final Type t)
equalsImplback to summary
protected abstract boolean equalsImpl(final Type t)
getASTLocusTagback to summary
public final ASTLocusTag getASTLocusTag()

Implements com.jogamp.gluegen.ASTLocusTag.ASTLocusTagProvider.getASTLocusTag.

Doc from com.jogamp.gluegen.ASTLocusTag.ASTLocusTagProvider.getASTLocusTag.

Returns this instance's ASTLocusTag, if available, otherwise returns null.

Annotations
@Override
getBaseElementTypeback to summary
public 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.

getCNameback to summary
public final String 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.

getCNameback to summary
public String getCName(final boolean includeCVAttrs)

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.

getCVAttributesback to summary
public final int getCVAttributes()
getCVAttributesStringback to summary
public final String getCVAttributesString()

Returns a string indicating the const/volatile attributes of this type.

getDebugStringback to summary
public final String getDebugString()
getNameback to summary
public final String 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.

getNameback to summary
public String getName(final boolean includeCVAttrs)

Returns the name of this type, optionally including const/volatile attributes. The returned string is suitable for use as a type specifier for Java.

getSizeback to summary
public final SizeThunk getSize()

SizeThunk which computes size of this type in bytes.

getSizeback to summary
public final long getSize(final MachineDataInfo machDesc)

Size of this type in bytes according to the given MachineDataInfo.

getTargetTypeback to summary
public Type getTargetType()

Helper method to returns the target type of this type, in case another type is being referenced.

getTypedefCVAttributesback to summary
pack-priv final int getTypedefCVAttributes()
hashCodeback to summary
public final int hashCode()

Overrides java.lang.Object.hashCode.

Hashcode for Types.

Returns:int

Doc from java.lang.Object.hashCode.

a hash code value for this object

Annotations
@Override
hashCodeImplback to summary
protected abstract int hashCodeImpl()
hashCodeSemanticsback to summary
public final int hashCodeSemantics()

Implements com.jogamp.gluegen.cgram.types.TypeComparator.SemanticEqualityOp.hashCodeSemantics.

Doc from com.jogamp.gluegen.cgram.types.TypeComparator.SemanticEqualityOp.hashCodeSemantics.

Semantic hashcode for Types exclusive its given name.

Annotations
@Override
hashCodeSemanticsImplback to summary
protected abstract int hashCodeSemanticsImpl()
isAnonback to summary
public boolean isAnon()
isArrayback to summary
public final boolean isArray()

Indicates whether this is an ArrayType.

isBaseTypeConstback to summary
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.

isBitback to summary
public final boolean isBit()

Indicates whether this is a BitType.

isCompoundback to summary
public final boolean isCompound()

Indicates whether this is a CompoundType.

isConstback to summary
public final boolean isConst()

Indicates whether this type is const.

isConstRawback to summary
private final boolean isConstRaw()
isConstTypedefback to summary
private final boolean isConstTypedef()
isDoubleback to summary
public final boolean isDouble()

Indicates whether this is a DoubleType.

isEnumback to summary
public final boolean isEnum()

Indicates whether this is an EnumType.

isFloatback to summary
public final boolean isFloat()

Indicates whether this is a FloatType.

isFunctionback to summary
public final boolean isFunction()

Indicates whether this is a FunctionType.

isFunctionPointerback to summary
public boolean isFunctionPointer()

Convenience routine indicating whether this Type is a pointer to a function.

isIntback to summary
public final boolean isInt()

Indicates whether this is an IntType.

isPointerback to summary
public final boolean isPointer()

Indicates whether this is a PointerType.

isPrimitiveback to summary
public boolean isPrimitive()

Indicates whether this type is a primitive type.

isTypedefback to summary
public final boolean isTypedef()

Indicates whether this type is a typedef type, i.e. declared via setTypedefName(String).

isVoidback to summary
public final boolean isVoid()

Indicates whether this is a VoidType.

isVolatileback to summary
public final boolean isVolatile()

Indicates whether this type is volatile.

newCVVariantback to summary
public final Type newCVVariant(final int cvAttributes)

Return a variant of this type matching the given const/volatile attributes. May return this object if the attributes match.

newVariantImplback to summary
pack-priv abstract Type newVariantImpl(final boolean newCVVariant, final int cvAttributes, final ASTLocusTag astLocus)

Create a new variant of this type matching the given parameter

Implementation must use Type's copy-ctor: Type(Type, int, ASTLocusTag)!

Parameters
newCVVariant:boolean

true if new variant is intended to have new cvAttributes

cvAttributes:int

the cvAttributes to be used

astLocus:ASTLocusTag

the ASTLocusTag to be used

objHashback to summary
private final int objHash()
pointerDepthback to summary
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.

setNameback to summary
private final boolean setName(final String name)

Returns true if given name is not null and has a length > 0. In this case this instance's names will be set to the internalized version.

Otherwise method returns false and this instance's name will be set to null.

Method issues clearCache(), to force re-evaluation of hashes.

setSizeback to summary
pack-priv final void setSize(final SizeThunk size)

Set the size of this type; only available for CompoundTypes.

setTypedefback to summary
pack-priv final void setTypedef(final int typedefedCVAttributes)
setTypedefNameback to summary
public boolean setTypedefName(final String name)

Set the typedef name of this type and renders this type a typedef, if given name has a length.

Method issues clearCache(), to force re-evaluation of hashes.

toStringback to summary
public String toString()

Overrides java.lang.Object.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.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object

Annotations
@Override
visitback to summary
public void visit(final TypeVisitor visitor)

Traverse this Type and all of its component types; for example, the return type and argument types of a FunctionType.