Documentation ¶
Overview ¶
Package cxxtypes describes C++ types (classes, structs, functions, ...) which have been somehow loaded into memory (from gccxml, clang, ...)
Index ¶
- func IdNames() []string
- func IsConstQualified(t Type) bool
- func IsRestrictQualified(t Type) bool
- func IsVolatileQualified(t Type) bool
- func LoadIds(distillerName string, r io.Reader) error
- func NumId() int
- func RegisterDistiller(name string, distiller Distiller)
- func SaveIds(dst io.Writer) error
- type AccessSpecifier
- type ArrayType
- type Base
- type BaseId
- type BaseType
- func (t *BaseType) DeclScope() Id
- func (t *BaseType) IdKind() IdKind
- func (t *BaseType) IdName() string
- func (t *BaseType) IdScopedName() string
- func (t *BaseType) Qualifiers() TypeQualifier
- func (t *BaseType) String() string
- func (t *BaseType) TypeKind() TypeKind
- func (t *BaseType) TypeName() string
- func (t *BaseType) TypeSize() uintptr
- type ClassType
- type CvrQualType
- func (t *CvrQualType) DeclScope() Id
- func (t *CvrQualType) IdKind() IdKind
- func (t *CvrQualType) IdName() string
- func (t *CvrQualType) IdScopedName() string
- func (t *CvrQualType) Qualifiers() TypeQualifier
- func (t *CvrQualType) String() string
- func (t *CvrQualType) TypeKind() TypeKind
- func (t *CvrQualType) TypeName() string
- func (t *CvrQualType) TypeSize() uintptr
- type Distiller
- type EnumType
- type Function
- func (t *Function) IsConst() bool
- func (t *Function) IsConstructor() bool
- func (t *Function) IsConverter() bool
- func (t *Function) IsCopyConstructor() bool
- func (t *Function) IsDestructor() bool
- func (t *Function) IsInline() bool
- func (t *Function) IsMethod() bool
- func (t *Function) IsOperator() bool
- func (t *Function) IsStatic() bool
- func (t *Function) IsVariadic() bool
- func (t *Function) IsVirtual() bool
- func (t *Function) NumDefaultParam() int
- func (t *Function) NumParam() int
- func (t *Function) Param(i int) *Parameter
- func (t *Function) Qualifiers() TypeQualifier
- func (t *Function) ReturnType() Type
- func (t *Function) Signature() string
- func (t *Function) Specifier() TypeSpecifier
- func (t *Function) TypeKind() TypeKind
- func (t *Function) TypeName() string
- func (t *Function) TypeSize() uintptr
- type FunctionType
- func (t *FunctionType) IsConstructor() bool
- func (t *FunctionType) IsConverter() bool
- func (t *FunctionType) IsCopyConstructor() bool
- func (t *FunctionType) IsDestructor() bool
- func (t *FunctionType) IsInline() bool
- func (t *FunctionType) IsMethod() bool
- func (t *FunctionType) IsOperator() bool
- func (t *FunctionType) IsStatic() bool
- func (t *FunctionType) IsVariadic() bool
- func (t *FunctionType) IsVirtual() bool
- func (t *FunctionType) NumDefaultParam() int
- func (t *FunctionType) NumParam() int
- func (t *FunctionType) Param(i int) *Parameter
- func (t *FunctionType) ReturnType() Type
- func (t *FunctionType) Specifier() TypeSpecifier
- type FundamentalType
- type Id
- type IdKind
- type Member
- type Namespace
- type OverloadFunctionSet
- func (id *OverloadFunctionSet) Function(i int) *Function
- func (id *OverloadFunctionSet) NumFunction() int
- func (id *OverloadFunctionSet) Qualifiers() TypeQualifier
- func (id *OverloadFunctionSet) TypeKind() TypeKind
- func (id *OverloadFunctionSet) TypeName() string
- func (id *OverloadFunctionSet) TypeSize() uintptr
- type Parameter
- type PtrType
- func (t *PtrType) DeclScope() Id
- func (t *PtrType) IdKind() IdKind
- func (t *PtrType) IdName() string
- func (t *PtrType) IdScopedName() string
- func (t *PtrType) Qualifiers() TypeQualifier
- func (t *PtrType) String() string
- func (t *PtrType) TypeKind() TypeKind
- func (t *PtrType) TypeName() string
- func (t *PtrType) TypeSize() uintptr
- func (t *PtrType) UnderlyingType() Type
- type RefType
- func (t *RefType) DeclScope() Id
- func (t *RefType) IdKind() IdKind
- func (t *RefType) IdName() string
- func (t *RefType) IdScopedName() string
- func (t *RefType) Qualifiers() TypeQualifier
- func (t *RefType) String() string
- func (t *RefType) TypeKind() TypeKind
- func (t *RefType) TypeName() string
- func (t *RefType) TypeSize() uintptr
- func (t *RefType) UnderlyingType() Type
- type StructType
- type Type
- type TypeKind
- type TypeQualifier
- type TypeSpecifier
- type TypedefType
- type UnionType
- type Var
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IdNames ¶
func IdNames() []string
IdNames returns the list of identifier names currently defined.
func IsConstQualified ¶
IsConstQualified returns whether this type is const-qualified. This doesn't look through typedefs that may have added 'const' at different level.
func IsRestrictQualified ¶
IsRestrictQualified returns whether this type is restrict-qualified. This doesn't look through typedefs that may have added 'restrict' at different level.
func IsVolatileQualified ¶
IsVolatileQualified returns whether this type is volatile-qualified. This doesn't look through typedefs that may have added 'volatile' at different level.
func RegisterDistiller ¶
Register makes a distiller available by the provided name.
Types ¶
type AccessSpecifier ¶
type AccessSpecifier uintptr
AccessSpecifier represents the C++ access control level to a base class or a class' member
const ( AS_None AccessSpecifier = 0 AS_Private AccessSpecifier = 1 << iota AS_Protected AS_Public )
func (AccessSpecifier) String ¶
func (a AccessSpecifier) String() string
type ArrayType ¶
type ArrayType struct { BaseType `cxxtypes:"array"` ArrElem string // array element type ArrLen uintptr // array length }
ArrayType represents a fixed array type
func NewArrayType ¶
NewArrayType creates a new array of type T[n].
type Base ¶
type Base struct { OffsetBase uintptr // the offset to the base class TypeBase string // Type of this base class Access AccessSpecifier // specifier for the derivation Virtual bool // whether the derivation is virtual }
Base represents a base class of a C++ class type
func NewBase ¶
func NewBase(offset uintptr, tn string, access AccessSpecifier, virtual bool) Base
NewBase creates a new base class/struct
func (*Base) IsProtected ¶
type BaseType ¶
type BaseType struct { Size uintptr // size in bytes Kind TypeKind // the specific kind of this type Qual TypeQualifier // the qualifiers applied to this type Scope string // declaring scope of this type Name string // the fully qualified name of the type }
BaseType is the common implementation of most types. It is embedded in other, public struct types, but always with a unique tag like `cxxtypes:"array"` or `cxxtypes:"ptr"` so that code cannot convert from, say, *ArrayType to *PtrType.
func (*BaseType) Qualifiers ¶
func (t *BaseType) Qualifiers() TypeQualifier
type ClassType ¶
ClassType represents a C++ class type
func NewClassType ¶
NewClassType creates a new class type.
func (*ClassType) Base ¶
Base returns a class type's i'th base it panics if i is not in the range [0, NumBase()0)
func (*ClassType) Member ¶
Member returns a class type's i'th member It panics if i is not in the range [0, NumMember())
func (*ClassType) SetMembers ¶
SetMembers sets the members of this class type
type CvrQualType ¶
type CvrQualType struct { Name string Qual TypeQualifier Type string // the decorated type (actually, its name) Scope string }
func (*CvrQualType) DeclScope ¶
func (t *CvrQualType) DeclScope() Id
func (*CvrQualType) IdKind ¶
func (t *CvrQualType) IdKind() IdKind
func (*CvrQualType) IdName ¶
func (t *CvrQualType) IdName() string
func (*CvrQualType) Qualifiers ¶
func (t *CvrQualType) Qualifiers() TypeQualifier
func (*CvrQualType) String ¶
func (t *CvrQualType) String() string
func (*CvrQualType) TypeKind ¶
func (t *CvrQualType) TypeKind() TypeKind
func (*CvrQualType) TypeName ¶
func (t *CvrQualType) TypeName() string
func (*CvrQualType) TypeSize ¶
func (t *CvrQualType) TypeSize() uintptr
type EnumType ¶
EnumType represents an enum type
func NewEnumType ¶
NewEnumType creates a new enum type.
type Function ¶
type Function struct { BaseId `cxxtypes:"function"` Qual TypeQualifier Spec TypeSpecifier // or'ed value of virtual/inline/... Variadic bool // whether this function is variadic Params []Parameter // the parameters to this function Ret string // return type of this function }
Function represents a function identifier
e.g. std::fabs
func NewFunction ¶
func NewFunction(name string, qual TypeQualifier, specifiers TypeSpecifier, variadic bool, params []Parameter, ret string, scope string) *Function
NewFunction returns a new function identifier
func (*Function) IsConstructor ¶
func (*Function) IsConverter ¶
func (*Function) IsCopyConstructor ¶
func (*Function) IsDestructor ¶
func (*Function) IsOperator ¶
func (*Function) IsVariadic ¶
IsVariadic returns whether this function is variadic
func (*Function) NumDefaultParam ¶
NumDefaultParam returns the number of parameters of a function's input which have a default value.
func (*Function) Param ¶
Param returns the i'th parameter of this function. It panics if i is not in the range [0, NumParam())
func (*Function) Qualifiers ¶
func (t *Function) Qualifiers() TypeQualifier
func (*Function) ReturnType ¶
ReturnType returns the return type of this function. FIXME: return nil for 'void' fct ? FIXME: return nil for ctor/dtor ?
func (*Function) Specifier ¶
func (t *Function) Specifier() TypeSpecifier
Specifier returns the type specifier for this function
type FunctionType ¶
type FunctionType struct { BaseType `cxxtypes:"function"` Spec TypeSpecifier // or'ed value of virtual/inline/... Variadic bool // whether this function is variadic Params []Parameter // the parameters to this function Ret string // return type of this function }
FunctionType represents a C/C++ function, a member function, c-tor, ...
func NewFunctionType ¶
func NewFunctionType(n string, qual TypeQualifier, specifiers TypeSpecifier, variadic bool, params []Parameter, ret string, scope string) *FunctionType
NewFunctionType creates a new function type.
func (*FunctionType) IsConstructor ¶
func (t *FunctionType) IsConstructor() bool
func (*FunctionType) IsConverter ¶
func (t *FunctionType) IsConverter() bool
func (*FunctionType) IsCopyConstructor ¶
func (t *FunctionType) IsCopyConstructor() bool
func (*FunctionType) IsDestructor ¶
func (t *FunctionType) IsDestructor() bool
func (*FunctionType) IsInline ¶
func (t *FunctionType) IsInline() bool
func (*FunctionType) IsMethod ¶
func (t *FunctionType) IsMethod() bool
func (*FunctionType) IsOperator ¶
func (t *FunctionType) IsOperator() bool
func (*FunctionType) IsStatic ¶
func (t *FunctionType) IsStatic() bool
func (*FunctionType) IsVariadic ¶
func (t *FunctionType) IsVariadic() bool
IsVariadic returns whether this function is variadic
func (*FunctionType) IsVirtual ¶
func (t *FunctionType) IsVirtual() bool
func (*FunctionType) NumDefaultParam ¶
func (t *FunctionType) NumDefaultParam() int
NumDefaultParam returns a function type's input with default value parameter count.
func (*FunctionType) NumParam ¶
func (t *FunctionType) NumParam() int
NumParam returns a function type's input parameter count.
func (*FunctionType) Param ¶
func (t *FunctionType) Param(i int) *Parameter
Param returns the i'th parameter of this function's type. It panics if i is not in the range [0, NumParam())
func (*FunctionType) ReturnType ¶
func (t *FunctionType) ReturnType() Type
ReturnType returns the return type of this function's type. FIXME: return nil for 'void' fct ?
func (*FunctionType) Specifier ¶
func (t *FunctionType) Specifier() TypeSpecifier
Specifier returns the type specifier for this function
type FundamentalType ¶
type FundamentalType struct {
BaseType //`cxxtypes:"builtin"`
}
FundamentalType represents a builtin type
type Id ¶
type Id interface { // IdName returns the name of this identifier // e.g. my_fct // MyClass // vector<int> // fabs // g_some_global_variable IdName() string // IdScopedName returns the scoped name of this identifier // e.g. some_namespace::my_fct // SomeOtherNamespace::MyClass // std::vector<int> // std::fabs // g_some_global_variable IdScopedName() string // IdKind returns the kind of this identifier // IK_Var | IK_Typ | IK_Fct | IK_Nsp IdKind() IdKind // DeclScope returns the declaring scope of this identifier DeclScope() Id }
Id is a C/C++ identifier
type IdKind ¶
type IdKind uint
IdKind represents the specific kind of identifier an Id represents. The zero IdKind is not a valid kind.
type Member ¶
type Member struct { BaseId `cxxtypes:"member"` Type string // the type of this member Kind TypeKind // the kind of this member Access AccessSpecifier // the access specifier for this member Offset uintptr // the offset in the embedding scope }
Member represents a member in a struct, class, enum or union
func NewMember ¶
func NewMember(name string, tn string, idkind IdKind, kind TypeKind, access AccessSpecifier, offset uintptr, scope string) Member
NewMember creates a new member for a struct, class, enum or union
func (*Member) IsDataMember ¶
func (*Member) IsEnumMember ¶
func (*Member) IsFunctionMember ¶
func (*Member) IsProtected ¶
type Namespace ¶
Namespace represents a namespace identifier
func NewNamespace ¶
NewNamespace creates a new namespace identifier
type OverloadFunctionSet ¶
OverloadFunctionSet is a set of functions which are part of the same overload
func (*OverloadFunctionSet) Function ¶
func (id *OverloadFunctionSet) Function(i int) *Function
Function returns the i-th overloaded function in the set It panics if i is not in the range [0, NumFunction())
func (*OverloadFunctionSet) NumFunction ¶
func (id *OverloadFunctionSet) NumFunction() int
NumFunction returns the number of overloads in that set
func (*OverloadFunctionSet) Qualifiers ¶
func (id *OverloadFunctionSet) Qualifiers() TypeQualifier
func (*OverloadFunctionSet) TypeKind ¶
func (id *OverloadFunctionSet) TypeKind() TypeKind
func (*OverloadFunctionSet) TypeName ¶
func (id *OverloadFunctionSet) TypeName() string
func (*OverloadFunctionSet) TypeSize ¶
func (id *OverloadFunctionSet) TypeSize() uintptr
type Parameter ¶
type Parameter struct { Name string // name of the parameter Type string // type of this parameter DefVal bool // whether this parameter has a default value }
Parameter represents a parameter of a function's signature
func NewParameter ¶
NewParameter creates a new parameter.
func (*Parameter) HasDefaultValue ¶
HasDefaultValue returns whether this parameter has a default value
type PtrType ¶
type PtrType struct { Name string // the fully qualified name of the type Scope string // declaring scope of this type Type string // the pointee type, possibly cvr-qualified }
PtrType represents a typed ptr
func NewPtrType ¶
NewPtrType creates a new pointer type from an already existing type t.
func (*PtrType) Qualifiers ¶
func (t *PtrType) Qualifiers() TypeQualifier
func (*PtrType) UnderlyingType ¶
UnderlyingType returns the type of the pointee
type RefType ¶
type RefType struct { Name string // the fully qualified name of the type Scope string // declaring scope of this type Type string // the referenced type, possibly cvr-qualified }
RefType represents a typed reference
func NewRefType ¶
NewRefType creates a new reference type from an already existing type t.
func (*RefType) Qualifiers ¶
func (t *RefType) Qualifiers() TypeQualifier
func (*RefType) UnderlyingType ¶
UnderlyingType returns the referenced type
type StructType ¶
StructType represents a C-struct type
func NewStructType ¶
func NewStructType(n string, sz uintptr, scope string) *StructType
NewStructType creates a new struct type.
func (*StructType) Base ¶
func (t *StructType) Base(i int) *Base
Base returns a struct type's i'th base it panics if i is not in the range [0, NumBase()0)
func (*StructType) HasBase ¶
func (t *StructType) HasBase(b Type) bool
HasBase returns true if a struct has b as one of its base structs
func (*StructType) Member ¶
func (t *StructType) Member(i int) *Member
Member returns a struct type's i'th member It panics if i is not in the range [0, NumMember())
func (*StructType) NumBase ¶
func (t *StructType) NumBase() int
NumBase returns a struct type's base struct count
func (*StructType) NumMember ¶
func (t *StructType) NumMember() int
NumMember returns a struct type's member count
func (*StructType) SetBases ¶
func (t *StructType) SetBases(bases []Base) error
SetBases sets the bases of this struct type
func (*StructType) SetMembers ¶
func (t *StructType) SetMembers(mbrs []Member) error
SetMembers sets the members of this struct type
type Type ¶
type Type interface { // Name returns the name of the type // mod qualifiers can be or'ed // FIXME: implement qualifiers ? TypeName() string // Size returns the number of bytes needed to store // a value of the given type TypeSize() uintptr // Kind returns the specific kind of this type. TypeKind() TypeKind // Qualifiers returns the or'ed values of qualifiers applied to this type. Qualifiers() TypeQualifier // DeclScope returns the declaring scope of this type DeclScope() Id }
Type is the representation of a C/C++ type
Not all methods apply to all kinds of types. Restrictions, if any, are noted in the documentation for each method. Use the Kind method to find out the kind of type before calling kind-specific methods. Calling a method inappropriate to the kind of type causes a run-time panic.
func NewFundamentalType ¶
NewFundamentalType creates a C/C++ builtin type.
func NewPlaceHolder ¶
func NewQualType ¶
func NewQualType(n string, tn string, scope string, qual TypeQualifier) (q Type)
NewQualType creates a new const-restrict-volatile qualified type. The new qualifiers are added to the old ones of the base type.
type TypeKind ¶
type TypeKind uint
TypeKind represents the specific kind of type that a Type represents. The zero TypeKind is not a valid kind.
const ( TK_Invalid TypeKind = iota TK_Unexposed TK_Void TK_Bool TK_Char_U TK_UChar TK_Char16 TK_Char32 TK_UShort TK_UInt TK_ULong TK_ULongLong TK_UInt128 TK_Char_S TK_SChar TK_WChar TK_Short TK_Int TK_Long TK_LongLong TK_Int128 TK_Float TK_Double TK_LongDouble TK_NullPtr TK_Overload TK_Dependent TK_ObjCId TK_ObjCClass TK_ObjCSel TK_Complex TK_Ptr TK_BlockPtr TK_LValueRef TK_RValueRef TK_Record TK_Enum TK_Typedef TK_ObjCInterface TK_ObjCObjectPointer TK_FunctionNoProto TK_FunctionProto TK_ConstantArray TK_FirstBuiltin = TK_Void TK_LastBuiltin = TK_ObjCSel )
type TypeQualifier ¶
type TypeQualifier uintptr
TypeQualifier represents the set of qualifiers (const,volatile,restrict) which decorate a type The zero TypeQualifier denotes no qualifier being applied.
const ( TQ_None TypeQualifier = 0 TQ_Const TypeQualifier = 1 << iota TQ_Restrict TQ_Volatile )
func (TypeQualifier) String ¶
func (tq TypeQualifier) String() string
type TypeSpecifier ¶
type TypeSpecifier uintptr
TypeSpecifier represents the specifiers which can "decorate" C/C++ types. e.g. static,inline,virtual ...
const ( TS_None TypeSpecifier = 0 TS_Register TypeSpecifier = 1 << iota TS_Virtual TS_Static TS_Inline TS_Extern TS_Constructor TS_Destructor TS_CopyCtor TS_Operator TS_Converter TS_Method TS_Explicit TS_Auto TS_Mutable TS_Abstract TS_Transient TS_Artificial )
type TypedefType ¶
type TypedefType struct { BaseType `cxxtypes:"typedef"` Type string // the typedef'd type, possible cvr-qualified }
TypedefType represents a typedef
func NewTypedefType ¶
func NewTypedefType(n string, tn string, tsz uintptr, scope string) *TypedefType
NewTypedefType creates a new typedef from an already existing type t.
func (*TypedefType) UnderlyingType ¶
func (t *TypedefType) UnderlyingType() Type
UnderlyingType returns the type of the typedef'd type
type UnionType ¶
UnionType represents a union type
func NewUnionType ¶
NewUnionType creates a new union type.