Documentation ¶
Index ¶
- Constants
- func ConvertCase(s string, into NameConvention) string
- type BaseProvider
- func (p *BaseProvider) AddType(tc TypeClass, name string, decl dst.Expr) TypeRef
- func (p *BaseProvider) ConvertQualType(q string) dst.Expr
- func (p *BaseProvider) ConvertTypeExpr(n clang.TypeNode) dst.Expr
- func (p *BaseProvider) FindType(name string) (TypeRef, bool)
- func (p *BaseProvider) ForceSynthetic(name string) bool
- func (p *BaseProvider) InferMethod(name string) (rcv string, newName string)
- func (p *BaseProvider) NameArg(name string, argType, funcName string) string
- func (p *BaseProvider) NameField(name string, recordName string) string
- func (p *BaseProvider) NameFunc(name string) string
- func (p *BaseProvider) NameGetter(name string) string
- func (p *BaseProvider) NameSetter(name string) string
- func (p *BaseProvider) NameType(name string) string
- func (p *BaseProvider) NameValue(name string) string
- func (p *BaseProvider) RemapType(name string, tr TypeRef)
- type BaseProviderOption
- type Identifier
- type MethodInferenceRule
- type Module
- func (m Module) AddInitFunc() *dst.FuncDecl
- func (m Module) AddType(tc TypeClass, name string, decl dst.Expr) TypeRef
- func (mod Module) EmitEnum(n *clang.EnumDecl)
- func (mod Module) EmitFrom(ast clang.Node, layouts *clang.LayoutMap)
- func (mod Module) EmitFunction(n *clang.FunctionDecl)
- func (mod Module) EmitStruct(n *clang.RecordDecl, layouts *clang.LayoutMap, deferred *deferred, ...)
- func (mod Module) EmitSyntheticStruct(n *clang.RecordDecl, layout *clang.RecordLayout, ty TypeRef, fl *dst.FieldList, ...)
- func (mod Module) EmitTypedef(n *clang.TypedefDecl)
- func (m Module) Fprint(w io.Writer)
- func (m Module) GetInitFunc() *dst.FuncDecl
- func (m Module) Go() (*ast.File, error)
- func (m Module) OnInit(stmts ...dst.Stmt)
- func (m Module) Print()
- func (m Module) String() string
- func (mod Module) TryEmitNaturalStruct(n *clang.RecordDecl, layout *clang.RecordLayout, ty TypeRef, fl *dst.FieldList, ...) bool
- type NameConvention
- type Package
- type Provider
- type RelaxedIdentifier
- type TrackedIdentifier
- type TypeClass
- type TypeRef
Constants ¶
View Source
const ( BuiltinVoid = RelaxedIdentifier("void") BuiltinInt8 = RelaxedIdentifier("int8") BuiltinInt16 = RelaxedIdentifier("int16") BuiltinInt32 = RelaxedIdentifier("int32") BuiltinInt64 = RelaxedIdentifier("int64") BuiltinUint8 = RelaxedIdentifier("uint8") BuiltinUint16 = RelaxedIdentifier("uint16") BuiltinUint32 = RelaxedIdentifier("uint32") BuiltinUint64 = RelaxedIdentifier("uint64") BuiltinUint = RelaxedIdentifier("uint") BuiltinInt = RelaxedIdentifier("int") BuiltinFloat32 = RelaxedIdentifier("float32") BuiltinFloat64 = RelaxedIdentifier("float64") BuiltinComplex64 = RelaxedIdentifier("complex64") BuiltinComplex128 = RelaxedIdentifier("complex128") BuiltinBool = RelaxedIdentifier("bool") BuiltinByte = RelaxedIdentifier("byte") BuiltinRune = RelaxedIdentifier("rune") BuiltinUintptr = RelaxedIdentifier("uintptr") BuiltinAny = RelaxedIdentifier("any") )
Builtin types.
View Source
const PRELOAD = true
Variables ¶
This section is empty.
Functions ¶
func ConvertCase ¶ added in v0.2.0
func ConvertCase(s string, into NameConvention) string
Types ¶
type BaseProvider ¶
type BaseProvider struct { Types map[string]TypeRef Builtins map[string]Identifier RemovedPrefixes []string InferredMethods []MethodInferenceRule ForcedSynthetic map[string]struct{} }
func NewBaseProvider ¶
func NewBaseProvider(opt ...BaseProviderOption) *BaseProvider
func (*BaseProvider) ConvertQualType ¶
func (p *BaseProvider) ConvertQualType(q string) dst.Expr
func (*BaseProvider) ConvertTypeExpr ¶
func (p *BaseProvider) ConvertTypeExpr(n clang.TypeNode) dst.Expr
func (*BaseProvider) ForceSynthetic ¶
func (p *BaseProvider) ForceSynthetic(name string) bool
func (*BaseProvider) InferMethod ¶
func (p *BaseProvider) InferMethod(name string) (rcv string, newName string)
func (*BaseProvider) NameArg ¶
func (p *BaseProvider) NameArg(name string, argType, funcName string) string
func (*BaseProvider) NameField ¶
func (p *BaseProvider) NameField(name string, recordName string) string
func (*BaseProvider) NameFunc ¶
func (p *BaseProvider) NameFunc(name string) string
func (*BaseProvider) NameGetter ¶
func (p *BaseProvider) NameGetter(name string) string
func (*BaseProvider) NameSetter ¶
func (p *BaseProvider) NameSetter(name string) string
func (*BaseProvider) NameType ¶
func (p *BaseProvider) NameType(name string) string
func (*BaseProvider) NameValue ¶
func (p *BaseProvider) NameValue(name string) string
func (*BaseProvider) RemapType ¶
func (p *BaseProvider) RemapType(name string, tr TypeRef)
type BaseProviderOption ¶
type BaseProviderOption func(*BaseProvider)
func WithForcedSynthetic ¶
func WithForcedSynthetic(names ...string) BaseProviderOption
func WithInferredMethods ¶
func WithInferredMethods(rules []MethodInferenceRule) BaseProviderOption
func WithRemovePrefix ¶
func WithRemovePrefix(prefixes ...string) BaseProviderOption
type MethodInferenceRule ¶
type Module ¶
func (Module) AddInitFunc ¶
func (Module) EmitFunction ¶
func (mod Module) EmitFunction(n *clang.FunctionDecl)
func (Module) EmitStruct ¶
func (mod Module) EmitStruct(n *clang.RecordDecl, layouts *clang.LayoutMap, deferred *deferred, vld *[]initTypeValidation)
func (Module) EmitSyntheticStruct ¶
func (mod Module) EmitSyntheticStruct(n *clang.RecordDecl, layout *clang.RecordLayout, ty TypeRef, fl *dst.FieldList, vld *[]initTypeValidation)
func (Module) EmitTypedef ¶
func (mod Module) EmitTypedef(n *clang.TypedefDecl)
func (Module) GetInitFunc ¶
func (Module) TryEmitNaturalStruct ¶
func (mod Module) TryEmitNaturalStruct(n *clang.RecordDecl, layout *clang.RecordLayout, ty TypeRef, fl *dst.FieldList, vld *[]initTypeValidation) bool
type NameConvention ¶ added in v0.2.0
type NameConvention int
const ( ConventionCamelCase NameConvention = iota // camelCase ConventionSnakeCase // snake_case ConventionConstCase // CONST_CASE ConventionPascalCase // PascalCase )
type Package ¶
type Package struct { Name string Restorer *decorator.Restorer Files map[string]*dst.File Provider }
func NewPackage ¶
func NewPackage(name string, opts ...BaseProviderOption) *Package
func NewPackageWithProvider ¶
func (*Package) WriteToDir ¶
type Provider ¶
type Provider interface { // NameField converts a field name to a Go compatible name. NameField(name string, recordName string) string // NameType converts a type name to a Go compatible name. NameType(name string) string // NameValue converts a value name to a Go compatible name. NameValue(name string) string // NameFunc converts a function name to a Go compatible name. NameFunc(name string) string // NameArg converts an argument name to a Go compatible name. NameArg(name string, argType, funcName string) string // NameGetter takes a transformed field name and returns the getter name. NameGetter(name string) string // NameSetter takes a transformed field name and returns the setter name. NameSetter(name string) string // ForceSynthetic returns true if the type should be syntethic (accessors instead of direct fields). ForceSynthetic(name string) bool // ConvertQualType converts a qualified type to a Go expression. ConvertQualType(q string) dst.Expr // ConvertTypeExpr converts a type node to a Go expression. ConvertTypeExpr(n clang.TypeNode) dst.Expr // AddType adds a type to the provider. AddType(tc TypeClass, name string, decl dst.Expr) TypeRef // RemapType remaps a given qualified typename to a type reference. RemapType(name string, tr TypeRef) // FindType resolves a type reference from a Go name. FindType(name string) (TypeRef, bool) // InferMethod returns the receiver type given the method name. InferMethod(name string) (rcv string, newName string) }
Provider is a type provider allowing hooks for library specific type conversions.
type RelaxedIdentifier ¶
type RelaxedIdentifier string
func (RelaxedIdentifier) Ref ¶
func (r RelaxedIdentifier) Ref() *dst.Ident
func (RelaxedIdentifier) Rename ¶
func (r RelaxedIdentifier) Rename(k string)
func (RelaxedIdentifier) String ¶
func (r RelaxedIdentifier) String() string
type TrackedIdentifier ¶
func (*TrackedIdentifier) Ref ¶
func (t *TrackedIdentifier) Ref() *dst.Ident
func (*TrackedIdentifier) Rename ¶
func (t *TrackedIdentifier) Rename(k string)
func (*TrackedIdentifier) String ¶
func (t *TrackedIdentifier) String() string
type TypeRef ¶
type TypeRef struct { Identifier Decl *dst.GenDecl }
Click to show internal directories.
Click to hide internal directories.