Documentation ¶
Index ¶
- func ProcessFuncs(context *errors.ParseContext, functions []*ast.FunctionDecl, ...) ([]*CFuncDef, []*CStruct)
- func ProcessTypes(context *errors.ParseContext, recordDeclarations []*ast.RecordDecl, ...) (structs []*CStruct, types []*CType)
- func ReadAst(headerFile string) ([]*ast.FunctionDecl, []*ast.RecordDecl, []*ast.TypedefDecl, error)
- type CFuncDef
- type CStruct
- type CStructInstance
- type CType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ProcessFuncs ¶
func ProcessFuncs(context *errors.ParseContext, functions []*ast.FunctionDecl, structs []*CStruct, types []*CType, cfg config.ParseConfig) ([]*CFuncDef, []*CStruct)
ProcessFuncs parses the function list and builds a set of function descriptions. It also figures out the minimal used set of structs and returns this.
func ProcessTypes ¶
func ProcessTypes(context *errors.ParseContext, recordDeclarations []*ast.RecordDecl, typeDeclarations []*ast.TypedefDecl, cfg config.ParseConfig) (structs []*CStruct, types []*CType)
ProcessTypes parses the AST information and converts it into lists of CStructs and CTypes. If errors are encountered during processing, they are recorded in the context and processing continues.
func ReadAst ¶
func ReadAst(headerFile string) ([]*ast.FunctionDecl, []*ast.RecordDecl, []*ast.TypedefDecl, error)
ReadAst processes the header file and converts it into the AST types used by the c2go project.
Types ¶
type CFuncDef ¶
type CFuncDef struct { // Name is the name of the function in the header file. Name string // Params defines the parameters and their type. Params []*CStructInstance // ReturnType is the function return type, or nil for void functions. ReturnType *CStructInstance }
CFuncDef describes a function found in the C header file.
type CStruct ¶
type CStruct struct { // Basic indicates if this is a pseudo-struct representing a basic type (e.g. int, char etc.). Basic bool // Name contains the name of the struct, which may be empty for anonymous structs. Name string // TypeName contains the type name for this struct, if one exists. During processing, if there are any typedefs // which alias this struct (without pointers), one of them will be stored in this field. TypeName string // Fields contains the fields defined in this struct. Fields []*CStructInstance }
A CStruct represents a C struct.
type CStructInstance ¶
type CStructInstance struct { // Name contains the name of the variable or parameter. This will be empty in contexts where a name is not // associated with the struct (e.g. return types). Name string // PointerCount counts how many pointers were used in this instance. E.g. "int *foo" would result in a PointerCount // of 1. PointerCount uint // ArrayCount indicates if the struct was used in a fixed-sized array. E.g. "int foo[4]" would result in an // ArrayCount of 4, where as "int foo" would result in 0. ArrayCount uint // WasVoidPointer indicates if this instance was actually a void pointer, which we've mapped to an underlying // type through the user-supplied config. WasVoidPointer bool // Struct is the type that was used in this instance. Struct *CStruct }
A CStructInstance contains information about a specific use of a struct, for instance as a field in another struct, as a parameter in a function or as a return type.
type CType ¶
type CType struct { // Name is the typedef name. Name string // PointerCount describes the number of pointers this typedef introduces, on top of the underlying struct. PointerCount uint // Struct is the underlying struct this typedef references. The parsing phase will resolve any intermediate // typdefs, ensuring we can directly tie each CType to a CStruct. Struct *CStruct }
A CType describes a typedef for a CStruct.