com.jogamp.gluegen.cgram.types
Class Type

java.lang.Object
  extended by com.jogamp.gluegen.cgram.types.Type
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
FunctionType, MemoryLayoutType, PointerType, PrimitiveType, VoidType

public abstract class Type
extends Object
implements Cloneable

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.


Constructor Summary
protected Type(String name, SizeThunk size, int cvAttributes)
           
 
Method Summary
 int arrayDimension()
          Helper method for determining how many array dimentions this type represents (i.e., "char[][]" returns 2).
 ArrayType asArray()
          Casts this to an ArrayType or returns null if not an ArrayType.
 BitType asBit()
          Casts this to a BitType or returns null if not a BitType.
 CompoundType asCompound()
          Casts this to a CompoundType or returns null if not a CompoundType.
 DoubleType asDouble()
          Casts this to a DoubleType or returns null if not a DoubleType.
 EnumType asEnum()
          Casts this to an EnumType or returns null if not an EnumType.
 FloatType asFloat()
          Casts this to a FloatType or returns null if not a FloatType.
 FunctionType asFunction()
          Casts this to a FunctionType or returns null if not a FunctionType.
 IntType asInt()
          Casts this to an IntType or returns null if not an IntType.
 PointerType asPointer()
          Casts this to a PointerType or returns null if not a PointerType.
 VoidType asVoid()
          Casts this to a VoidType or returns null if not a VoidType.
 Object clone()
           
 boolean equals(Object arg)
          Equality test for Types.
 int getCVAttributes()
           
 String getCVAttributesString()
          Returns a string indicating the const/volatile attributes of this type.
 Type getCVVariant(int cvAttributes)
          Return a variant of this type matching the given const/volatile attributes.
 String getName()
          Returns the name of this type.
 String getName(boolean includeCVAttrs)
          Returns the name of this type, optionally including const/volatile attributes.
 SizeThunk getSize()
          SizeThunk which computes size of this type in bytes.
 long getSize(MachineDescription machDesc)
          Size of this type in bytes according to the given MachineDescription.
 int hashCode()
          Hashcode for Types.
 boolean hasTypedefName()
          Indicates whether setName() has been called on this type, indicating that it already has a typedef name.
 boolean isArray()
          Indicates whether this is an ArrayType.
 boolean isBit()
          Indicates whether this is a BitType.
 boolean isCompound()
          Indicates whether this is a CompoundType.
 boolean isConst()
          Indicates whether this type is const.
 boolean isDouble()
          Indicates whether this is a DoubleType.
 boolean isEnum()
          Indicates whether this is an EnumType.
 boolean isFloat()
          Indicates whether this is a FloatType.
 boolean isFunction()
          Indicates whether this is a FunctionType.
 boolean isFunctionPointer()
          Convenience routine indicating whether this Type is a pointer to a function.
 boolean isInt()
          Indicates whether this is an IntType.
 boolean isPointer()
          Indicates whether this is a PointerType.
 boolean isPrimitive()
          Indicates whether this type is a primitive type.
 boolean isVoid()
          Indicates whether this is a VoidType.
 boolean isVolatile()
          Indicates whether this type is volatile.
 int pointerDepth()
          Helper method for determining how many pointer indirections this type represents (i.e., "void **" returns 2).
 void setName(String name)
          Set the name of this type; used for handling typedefs.
 String toString()
          Returns a string representation of this type.
 void visit(TypeVisitor visitor)
          Visit this type and all of the component types of this one; for example, the return type and argument types of a FunctionType.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Type

protected Type(String name,
               SizeThunk size,
               int cvAttributes)
Method Detail

clone

public Object clone()
Overrides:
clone in class Object

getName

public String getName()
Returns the name of this type. The returned string is suitable for use as a type specifier. Does not include any const/volatile attributes.


getName

public String getName(boolean includeCVAttrs)
Returns the name of this type, optionally including const/volatile attributes. The returned string is suitable for use as a type specifier.


setName

public void setName(String name)
Set the name of this type; used for handling typedefs.


getSize

public SizeThunk getSize()
SizeThunk which computes size of this type in bytes.


getSize

public long getSize(MachineDescription machDesc)
Size of this type in bytes according to the given MachineDescription.


asBit

public BitType asBit()
Casts this to a BitType or returns null if not a BitType.


asInt

public IntType asInt()
Casts this to an IntType or returns null if not an IntType.


asEnum

public EnumType asEnum()
Casts this to an EnumType or returns null if not an EnumType.


asFloat

public FloatType asFloat()
Casts this to a FloatType or returns null if not a FloatType.


asDouble

public DoubleType asDouble()
Casts this to a DoubleType or returns null if not a DoubleType.


asPointer

public PointerType asPointer()
Casts this to a PointerType or returns null if not a PointerType.


asArray

public ArrayType asArray()
Casts this to an ArrayType or returns null if not an ArrayType.


asCompound

public CompoundType asCompound()
Casts this to a CompoundType or returns null if not a CompoundType.


asFunction

public FunctionType asFunction()
Casts this to a FunctionType or returns null if not a FunctionType.


asVoid

public VoidType asVoid()
Casts this to a VoidType or returns null if not a VoidType.


isBit

public boolean isBit()
Indicates whether this is a BitType.


isInt

public boolean isInt()
Indicates whether this is an IntType.


isEnum

public boolean isEnum()
Indicates whether this is an EnumType.


isFloat

public boolean isFloat()
Indicates whether this is a FloatType.


isDouble

public boolean isDouble()
Indicates whether this is a DoubleType.


isPointer

public boolean isPointer()
Indicates whether this is a PointerType.


isArray

public boolean isArray()
Indicates whether this is an ArrayType.


isCompound

public boolean isCompound()
Indicates whether this is a CompoundType.


isFunction

public boolean isFunction()
Indicates whether this is a FunctionType.


isVoid

public boolean isVoid()
Indicates whether this is a VoidType.


isConst

public boolean isConst()
Indicates whether this type is const.


isVolatile

public boolean isVolatile()
Indicates whether this type is volatile.


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.


hashCode

public int hashCode()
Hashcode for Types.

Overrides:
hashCode in class Object

equals

public boolean equals(Object arg)
Equality test for Types.

Overrides:
equals in class Object

toString

public String toString()
Returns a string representation of this type. This string is not necessarily suitable for use as a type specifier; for example, it will contain an expanded description of structs/unions.

Overrides:
toString in class Object

visit

public void visit(TypeVisitor visitor)
Visit this type and all of the component types of this one; for example, the return type and argument types of a FunctionType.


getCVAttributes

public final int getCVAttributes()

getCVAttributesString

public final String getCVAttributesString()
Returns a string indicating the const/volatile attributes of this type.


getCVVariant

public final Type getCVVariant(int cvAttributes)
Return a variant of this type matching the given const/volatile attributes. May return this object if the attributes match.


hasTypedefName

public boolean hasTypedefName()
Indicates whether setName() has been called on this type, indicating that it already has a typedef name.


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.