Class 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.
  • Method Details

    • rename

      public void rename(String newName)
      Description copied from interface: AliasedSymbol
      Rename this symbol with the given newName if not equal current-name.

      Before renaming the current-name will be added to the list of aliases. while the given newName will be removed.

      Operation will be ignored if newName is null.

      Specified by:
      rename in interface AliasedSymbol
      Parameters:
      newName - the new current-name, maybe null
    • addAliasedName

      public void addAliasedName(String origName)
      Description copied from interface: AliasedSymbol
      Add the given origName to the list of aliases if not equal current-name.

      Operation will be ignored if newName is null.

      Specified by:
      addAliasedName in interface AliasedSymbol
      Parameters:
      origName - the new alias to be added, maybe null
    • hasAliases

      public boolean hasAliases()
      Description copied from interface: AliasedSymbol
      Returns true if this symbol has aliases, i.e. either being renamed or aliases-added.

      Otherwise false is being returned.

      Specified by:
      hasAliases in interface AliasedSymbol
    • 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, if renamed,

      Exclusive current-name.

      May return null or a zero sized Set for no aliases.

      Specified by:
      getAliasedNames in interface AliasedSymbol
    • getAliasedString

      public String getAliasedString()
      Description copied from interface: AliasedSymbol
      Return this object's #toString() wrapped w/ the current-name and all aliases.
      Specified by:
      getAliasedString in interface AliasedSymbol
    • getOrigName

      public String getOrigName()
      Description copied from interface: AliasedSymbol
      Return the original-name as set at creation.
      Specified by:
      getOrigName in interface AliasedSymbol
    • 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 construct struct foo { int a, ... }; or struct foo; even for anonymous structs.
      size -
      kind -
      cvAttributes -
      Returns:
    • hashCodeImpl

      protected int hashCodeImpl()
      Specified by:
      hashCodeImpl in class Type
    • equalsImpl

      protected boolean equalsImpl(Type arg)
      Specified by:
      equalsImpl in class Type
    • hashCodeSemanticsImpl

      protected int hashCodeSemanticsImpl()
      Specified by:
      hashCodeSemanticsImpl in class Type
    • equalSemanticsImpl

      protected boolean equalSemanticsImpl(Type arg)
      Specified by:
      equalSemanticsImpl in class Type
    • 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 class Type
    • 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.
      Overrides:
      getCName in class Type
    • 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 more addField(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.
      Overrides:
      toString in class Type
    • visit

      public void visit(TypeVisitor arg)
      Description copied from class: Type
      Traverse this Type and all of its component types; for example, the return type and argument types of a FunctionType.
      Overrides:
      visit in class Type
    • getStructString

      public String getStructString()