Documentation ¶
Index ¶
- Variables
- type ArraySizeSpec
- type ArraySpec
- type CDecl
- type CEnumSpec
- func (c *CEnumSpec) AddInnerArr(size uint64)
- func (c *CEnumSpec) AddOuterArr(size uint64)
- func (c CEnumSpec) AtLevel(level int) CType
- func (c *CEnumSpec) CGoName() string
- func (c CEnumSpec) Copy() CType
- func (c *CEnumSpec) GetBase() string
- func (c *CEnumSpec) GetPointers() uint8
- func (c *CEnumSpec) GetTag() string
- func (c *CEnumSpec) InnerArraySizes() []ArraySizeSpec
- func (c *CEnumSpec) InnerArrays() ArraySpec
- func (c *CEnumSpec) IsComplete() bool
- func (c *CEnumSpec) IsConst() bool
- func (c *CEnumSpec) IsOpaque() bool
- func (c *CEnumSpec) Kind() CTypeKind
- func (c *CEnumSpec) OuterArraySizes() []ArraySizeSpec
- func (c *CEnumSpec) OuterArrays() ArraySpec
- func (c *CEnumSpec) PromoteType(v Value) *CTypeSpec
- func (c *CEnumSpec) SetPointers(n uint8)
- func (c *CEnumSpec) SetRaw(x string)
- func (spec CEnumSpec) String() string
- type CFunctionSpec
- func (c *CFunctionSpec) AddInnerArr(uint64)
- func (c *CFunctionSpec) AddOuterArr(uint64)
- func (c CFunctionSpec) AtLevel(level int) CType
- func (c *CFunctionSpec) CGoName() string
- func (c CFunctionSpec) Copy() CType
- func (c *CFunctionSpec) GetBase() string
- func (c *CFunctionSpec) GetPointers() uint8
- func (c *CFunctionSpec) GetTag() string
- func (c *CFunctionSpec) InnerArraySizes() []ArraySizeSpec
- func (c *CFunctionSpec) InnerArrays() ArraySpec
- func (c *CFunctionSpec) IsComplete() bool
- func (c *CFunctionSpec) IsConst() bool
- func (c *CFunctionSpec) IsOpaque() bool
- func (c *CFunctionSpec) Kind() CTypeKind
- func (c *CFunctionSpec) OuterArraySizes() []ArraySizeSpec
- func (c *CFunctionSpec) OuterArrays() ArraySpec
- func (c *CFunctionSpec) SetPointers(n uint8)
- func (c *CFunctionSpec) SetRaw(x string)
- func (c CFunctionSpec) String() string
- type CGoSpec
- type CStructSpec
- func (c *CStructSpec) AddInnerArr(size uint64)
- func (c *CStructSpec) AddOuterArr(size uint64)
- func (c CStructSpec) AtLevel(level int) CType
- func (c *CStructSpec) CGoName() string
- func (c CStructSpec) Copy() CType
- func (c *CStructSpec) GetBase() string
- func (c *CStructSpec) GetPointers() uint8
- func (c *CStructSpec) GetTag() string
- func (c *CStructSpec) InnerArraySizes() []ArraySizeSpec
- func (c *CStructSpec) InnerArrays() ArraySpec
- func (c *CStructSpec) IsComplete() bool
- func (c *CStructSpec) IsConst() bool
- func (c *CStructSpec) IsOpaque() bool
- func (c *CStructSpec) Kind() CTypeKind
- func (c *CStructSpec) OuterArraySizes() []ArraySizeSpec
- func (c *CStructSpec) OuterArrays() ArraySpec
- func (c *CStructSpec) SetPointers(n uint8)
- func (c *CStructSpec) SetRaw(x string)
- func (spec CStructSpec) String() string
- type CType
- type CTypeKind
- type CTypeMap
- type CTypeSpec
- func (c *CTypeSpec) AddInnerArr(size uint64)
- func (c *CTypeSpec) AddOuterArr(size uint64)
- func (c CTypeSpec) AtLevel(level int) CType
- func (c *CTypeSpec) CGoName() (name string)
- func (c CTypeSpec) Copy() CType
- func (c *CTypeSpec) GetBase() string
- func (c *CTypeSpec) GetPointers() uint8
- func (c *CTypeSpec) GetTag() string
- func (c *CTypeSpec) InnerArraySizes() []ArraySizeSpec
- func (c *CTypeSpec) InnerArrays() ArraySpec
- func (c *CTypeSpec) IsComplete() bool
- func (c *CTypeSpec) IsConst() bool
- func (c *CTypeSpec) IsOpaque() bool
- func (c *CTypeSpec) Kind() CTypeKind
- func (c *CTypeSpec) OuterArraySizes() []ArraySizeSpec
- func (c *CTypeSpec) OuterArrays() ArraySpec
- func (c *CTypeSpec) SetPointers(n uint8)
- func (c *CTypeSpec) SetRaw(x string)
- func (spec CTypeSpec) String() string
- type CachedNameTransform
- type Config
- type ConstRule
- type ConstRules
- type ConstScope
- type GoTypeMap
- type GoTypeSpec
- type MemTipRxList
- type MemTips
- type NameTransformCache
- type PtrTipRxMap
- type PtrTips
- type RuleAction
- type RuleSpec
- type RuleTarget
- type RuleTransform
- type Rules
- type Rx
- type RxMap
- type Tip
- type TipCache
- type TipKind
- type TipScope
- type TipSpec
- type TipSpecRx
- type Tips
- type Translator
- func (t *Translator) CGoSpec(spec CType, asArg bool) CGoSpec
- func (t *Translator) Declares() []*CDecl
- func (t *Translator) Defines() []*CDecl
- func (t *Translator) ExpressionMap() map[string]string
- func (t *Translator) IsAcceptableName(target RuleTarget, name string) bool
- func (t *Translator) IsTokenIgnored(p token.Pos) bool
- func (t *Translator) Learn(unit *cc.TranslationUnit)
- func (t *Translator) MemTipRx(name string) (TipSpecRx, bool)
- func (t *Translator) NormalizeSpecPointers(spec CType) CType
- func (t *Translator) PtrTipRx(scope TipScope, name string) (TipSpecRx, bool)
- func (t *Translator) SrcLocation(docTarget RuleTarget, name string, p token.Pos) string
- func (t *Translator) TagMap() map[string]*CDecl
- func (t *Translator) TipRxsForSpec(scope TipScope, name string, spec CType) (ptr, typ, mem TipSpecRx)
- func (t *Translator) TransformName(target RuleTarget, str string, publicOpt ...bool) []byte
- func (t *Translator) TranslateSpec(spec CType, tips ...Tip) GoTypeSpec
- func (t *Translator) TypeTipRx(scope TipScope, name string) (TipSpecRx, bool)
- func (t *Translator) Typedefs() []*CDecl
- func (t *Translator) ValueMap() map[string]Value
- type TypeCache
- type TypeTipRxMap
- type TypeTips
- type Value
Constants ¶
This section is empty.
Variables ¶
View Source
var ( BoolSpec = GoTypeSpec{Base: "bool"} IntSpec = GoTypeSpec{Base: "int"} UintSpec = GoTypeSpec{Base: "int", Unsigned: true} Int8Spec = GoTypeSpec{Base: "int", Bits: 8} Uint8Spec = GoTypeSpec{Base: "int", Bits: 8, Unsigned: true} Int16Spec = GoTypeSpec{Base: "int", Bits: 16} Uint16Spec = GoTypeSpec{Base: "int", Bits: 16, Unsigned: true} Int32Spec = GoTypeSpec{Base: "int", Bits: 32} Uint32Spec = GoTypeSpec{Base: "int", Bits: 32, Unsigned: true} Int64Spec = GoTypeSpec{Base: "int", Bits: 64} Uint64Spec = GoTypeSpec{Base: "int", Bits: 64, Unsigned: true} RuneSpec = GoTypeSpec{Base: "rune"} ByteSpec = GoTypeSpec{Base: "byte"} UByteSpec = GoTypeSpec{Base: "byte", Unsigned: true} StringSpec = GoTypeSpec{Base: "string"} UStringSpec = GoTypeSpec{Base: "string", Unsigned: true} Float32Spec = GoTypeSpec{Base: "float", Bits: 32} Float64Spec = GoTypeSpec{Base: "float", Bits: 64} Complex64Spec = GoTypeSpec{Base: "complex", Bits: 64} Complex128Spec = GoTypeSpec{Base: "complex", Bits: 128} UnsafePointerSpec = GoTypeSpec{Base: "unsafe.Pointer", Pointers: 1} VoidSpec = GoTypeSpec{Base: "byte", OuterArr: "[0]"} // InterfaceSliceSpec = GoTypeSpec{Base: "[]interface{}"} )
Functions ¶
This section is empty.
Types ¶
type ArraySizeSpec ¶
type ArraySpec ¶
type ArraySpec string
func (ArraySpec) Sizes ¶
func (a ArraySpec) Sizes() (sizes []ArraySizeSpec)
type CDecl ¶
type CEnumSpec ¶
type CEnumSpec struct { Tag string Typedef string Members []*CDecl Type CTypeSpec Pointers uint8 InnerArr ArraySpec OuterArr ArraySpec }
func (*CEnumSpec) AddInnerArr ¶
func (*CEnumSpec) AddOuterArr ¶
func (*CEnumSpec) GetPointers ¶
func (*CEnumSpec) InnerArraySizes ¶
func (c *CEnumSpec) InnerArraySizes() []ArraySizeSpec
func (*CEnumSpec) InnerArrays ¶
func (*CEnumSpec) IsComplete ¶
func (*CEnumSpec) OuterArraySizes ¶
func (c *CEnumSpec) OuterArraySizes() []ArraySizeSpec
func (*CEnumSpec) OuterArrays ¶
func (*CEnumSpec) PromoteType ¶
func (*CEnumSpec) SetPointers ¶
type CFunctionSpec ¶
func (*CFunctionSpec) AddInnerArr ¶
func (c *CFunctionSpec) AddInnerArr(uint64)
func (*CFunctionSpec) AddOuterArr ¶
func (c *CFunctionSpec) AddOuterArr(uint64)
func (CFunctionSpec) AtLevel ¶
func (c CFunctionSpec) AtLevel(level int) CType
func (*CFunctionSpec) CGoName ¶
func (c *CFunctionSpec) CGoName() string
func (CFunctionSpec) Copy ¶
func (c CFunctionSpec) Copy() CType
func (*CFunctionSpec) GetBase ¶
func (c *CFunctionSpec) GetBase() string
func (*CFunctionSpec) GetPointers ¶
func (c *CFunctionSpec) GetPointers() uint8
func (*CFunctionSpec) GetTag ¶
func (c *CFunctionSpec) GetTag() string
func (*CFunctionSpec) InnerArraySizes ¶
func (c *CFunctionSpec) InnerArraySizes() []ArraySizeSpec
func (*CFunctionSpec) InnerArrays ¶
func (c *CFunctionSpec) InnerArrays() ArraySpec
func (*CFunctionSpec) IsComplete ¶
func (c *CFunctionSpec) IsComplete() bool
func (*CFunctionSpec) IsConst ¶
func (c *CFunctionSpec) IsConst() bool
func (*CFunctionSpec) IsOpaque ¶
func (c *CFunctionSpec) IsOpaque() bool
func (*CFunctionSpec) Kind ¶
func (c *CFunctionSpec) Kind() CTypeKind
func (*CFunctionSpec) OuterArraySizes ¶
func (c *CFunctionSpec) OuterArraySizes() []ArraySizeSpec
func (*CFunctionSpec) OuterArrays ¶
func (c *CFunctionSpec) OuterArrays() ArraySpec
func (*CFunctionSpec) SetPointers ¶
func (c *CFunctionSpec) SetPointers(n uint8)
func (*CFunctionSpec) SetRaw ¶
func (c *CFunctionSpec) SetRaw(x string)
func (CFunctionSpec) String ¶
func (c CFunctionSpec) String() string
type CStructSpec ¶
type CStructSpec struct { Tag string Typedef string IsUnion bool Members []*CDecl Pointers uint8 InnerArr ArraySpec OuterArr ArraySpec }
func (*CStructSpec) AddInnerArr ¶
func (c *CStructSpec) AddInnerArr(size uint64)
func (*CStructSpec) AddOuterArr ¶
func (c *CStructSpec) AddOuterArr(size uint64)
func (CStructSpec) AtLevel ¶
func (c CStructSpec) AtLevel(level int) CType
func (*CStructSpec) CGoName ¶
func (c *CStructSpec) CGoName() string
func (CStructSpec) Copy ¶
func (c CStructSpec) Copy() CType
func (*CStructSpec) GetBase ¶
func (c *CStructSpec) GetBase() string
func (*CStructSpec) GetPointers ¶
func (c *CStructSpec) GetPointers() uint8
func (*CStructSpec) GetTag ¶
func (c *CStructSpec) GetTag() string
func (*CStructSpec) InnerArraySizes ¶
func (c *CStructSpec) InnerArraySizes() []ArraySizeSpec
func (*CStructSpec) InnerArrays ¶
func (c *CStructSpec) InnerArrays() ArraySpec
func (*CStructSpec) IsComplete ¶
func (c *CStructSpec) IsComplete() bool
func (*CStructSpec) IsConst ¶
func (c *CStructSpec) IsConst() bool
func (*CStructSpec) IsOpaque ¶
func (c *CStructSpec) IsOpaque() bool
func (*CStructSpec) Kind ¶
func (c *CStructSpec) Kind() CTypeKind
func (*CStructSpec) OuterArraySizes ¶
func (c *CStructSpec) OuterArraySizes() []ArraySizeSpec
func (*CStructSpec) OuterArrays ¶
func (c *CStructSpec) OuterArrays() ArraySpec
func (*CStructSpec) SetPointers ¶
func (c *CStructSpec) SetPointers(n uint8)
func (*CStructSpec) SetRaw ¶
func (c *CStructSpec) SetRaw(x string)
func (CStructSpec) String ¶
func (spec CStructSpec) String() string
type CType ¶
type CType interface { GetBase() string GetTag() string SetRaw(x string) CGoName() string GetPointers() uint8 SetPointers(uint8) AddOuterArr(uint64) AddInnerArr(uint64) OuterArrays() ArraySpec InnerArrays() ArraySpec OuterArraySizes() []ArraySizeSpec InnerArraySizes() []ArraySizeSpec // IsConst() bool IsOpaque() bool IsComplete() bool Kind() CTypeKind String() string Copy() CType AtLevel(level int) CType }
type CTypeMap ¶
type CTypeMap map[CTypeSpec]GoTypeSpec
type CTypeSpec ¶
type CTypeSpec struct { Raw string Base string Const bool Signed bool Unsigned bool Short bool Long bool Complex bool Opaque bool Pointers uint8 InnerArr ArraySpec OuterArr ArraySpec }
func (*CTypeSpec) AddInnerArr ¶
func (*CTypeSpec) AddOuterArr ¶
func (*CTypeSpec) GetPointers ¶
func (*CTypeSpec) InnerArraySizes ¶
func (c *CTypeSpec) InnerArraySizes() []ArraySizeSpec
func (*CTypeSpec) InnerArrays ¶
func (*CTypeSpec) IsComplete ¶
func (*CTypeSpec) OuterArraySizes ¶
func (c *CTypeSpec) OuterArraySizes() []ArraySizeSpec
func (*CTypeSpec) OuterArrays ¶
func (*CTypeSpec) SetPointers ¶
type CachedNameTransform ¶
type CachedNameTransform struct { Target RuleTarget Visibility RuleTarget Name string }
type ConstRules ¶
type ConstRules map[ConstScope]ConstRule
type ConstScope ¶
type ConstScope string
const ( ConstEnum ConstScope = "enum" ConstDecl ConstScope = "decl" ConstDefines ConstScope = "defines" )
type GoTypeMap ¶
type GoTypeMap map[string]GoTypeSpec
type GoTypeSpec ¶
type GoTypeSpec struct { Slices uint8 Pointers uint8 InnerArr ArraySpec OuterArr ArraySpec Unsigned bool Kind CTypeKind Base string Raw string Bits uint16 }
func (GoTypeSpec) IsGoString ¶
func (spec GoTypeSpec) IsGoString() bool
func (GoTypeSpec) IsPlain ¶
func (spec GoTypeSpec) IsPlain() bool
func (GoTypeSpec) IsPlainKind ¶
func (spec GoTypeSpec) IsPlainKind() bool
func (*GoTypeSpec) PlainType ¶
func (spec *GoTypeSpec) PlainType() string
func (GoTypeSpec) String ¶
func (spec GoTypeSpec) String() string
func (GoTypeSpec) UnderlyingString ¶
func (spec GoTypeSpec) UnderlyingString() string
type MemTipRxList ¶
type MemTipRxList []TipSpecRx
type NameTransformCache ¶
type NameTransformCache struct {
// contains filtered or unexported fields
}
func (*NameTransformCache) Get ¶
func (n *NameTransformCache) Get(target, visibility RuleTarget, name string) ([]byte, bool)
func (*NameTransformCache) Set ¶
func (n *NameTransformCache) Set(target, visibility RuleTarget, name string, result []byte)
type PtrTipRxMap ¶
type RuleAction ¶
type RuleAction string
const ( ActionNone RuleAction = "" ActionAccept RuleAction = "accept" ActionIgnore RuleAction = "ignore" ActionReplace RuleAction = "replace" ActionDocument RuleAction = "doc" )
type RuleSpec ¶
type RuleSpec struct {
From, To string
Action RuleAction
Transform RuleTransform
Load string
}
type RuleTarget ¶
type RuleTarget string
const ( NoTarget RuleTarget = "" TargetGlobal RuleTarget = "global" TargetPostGlobal RuleTarget = "post-global" // TargetConst RuleTarget = "const" TargetType RuleTarget = "type" TargetFunction RuleTarget = "function" // TargetPublic RuleTarget = "public" TargetPrivate RuleTarget = "private" )
type RuleTransform ¶
type RuleTransform string
const ( TransformLower RuleTransform = "lower" TransformTitle RuleTransform = "title" TransformExport RuleTransform = "export" TransformUnexport RuleTransform = "unexport" TransformUpper RuleTransform = "upper" )
type Rules ¶
type Rules map[RuleTarget][]RuleSpec
type RxMap ¶
type RxMap map[RuleTarget][]Rx
type TipSpecRx ¶
type Translator ¶
type Translator struct {
// contains filtered or unexported fields
}
func New ¶
func New(cfg *Config) (*Translator, error)
func (*Translator) Declares ¶
func (t *Translator) Declares() []*CDecl
func (*Translator) Defines ¶
func (t *Translator) Defines() []*CDecl
func (*Translator) ExpressionMap ¶
func (t *Translator) ExpressionMap() map[string]string
func (*Translator) IsAcceptableName ¶
func (t *Translator) IsAcceptableName(target RuleTarget, name string) bool
func (*Translator) IsTokenIgnored ¶
func (t *Translator) IsTokenIgnored(p token.Pos) bool
func (*Translator) Learn ¶
func (t *Translator) Learn(unit *cc.TranslationUnit)
func (*Translator) NormalizeSpecPointers ¶
func (t *Translator) NormalizeSpecPointers(spec CType) CType
func (*Translator) PtrTipRx ¶
func (t *Translator) PtrTipRx(scope TipScope, name string) (TipSpecRx, bool)
func (*Translator) SrcLocation ¶
func (t *Translator) SrcLocation(docTarget RuleTarget, name string, p token.Pos) string
func (*Translator) TagMap ¶
func (t *Translator) TagMap() map[string]*CDecl
func (*Translator) TipRxsForSpec ¶
func (t *Translator) TipRxsForSpec(scope TipScope, name string, spec CType) (ptr, typ, mem TipSpecRx)
func (*Translator) TransformName ¶
func (t *Translator) TransformName(target RuleTarget, str string, publicOpt ...bool) []byte
func (*Translator) TranslateSpec ¶
func (t *Translator) TranslateSpec(spec CType, tips ...Tip) GoTypeSpec
func (*Translator) TypeTipRx ¶
func (t *Translator) TypeTipRx(scope TipScope, name string) (TipSpecRx, bool)
func (*Translator) Typedefs ¶
func (t *Translator) Typedefs() []*CDecl
func (*Translator) ValueMap ¶
func (t *Translator) ValueMap() map[string]Value
type TypeTipRxMap ¶
Click to show internal directories.
Click to hide internal directories.