Documentation ¶
Index ¶
- Constants
- func ArrayConstructor(goType, cType string) *ast.FuncDecl
- func CFree() ast.Decl
- func CObjectStruct() ast.Decl
- func CastBasicArg(kind types.BasicKind, name ast.Expr) ast.Expr
- func CastExpr(t types.Type, ident ast.Expr) ast.Expr
- func CastOut(t types.Type, name ast.Expr) ast.Expr
- func CastUnsafePtr(castType, target ast.Expr) *ast.CallExpr
- func CastUnsafePtrOfTypeUuid(castType, target ast.Expr) ast.Expr
- func DeRef(expr ast.Expr) *ast.StarExpr
- func DeclareVar(name *ast.Ident, t ast.Expr) *ast.DeclStmt
- func DecrementRef() ast.Decl
- func DecrementRefCall(target ast.Expr) *ast.ExprStmt
- func ErrorToString() ast.Decl
- func ExportComments(exportName string) []*ast.Comment
- func Fields(funcParams *types.Tuple) *ast.FieldList
- func FormatSprintf(format string, target ast.Expr) *ast.CallExpr
- func FuncAst(f *Func) *ast.FuncDecl
- func GetRef() ast.Decl
- func GetUuidFromPtr() ast.Decl
- func ImplementsError(t types.Type) bool
- func Imports(imports ...string) *ast.GenDecl
- func ImportsFromMap(imports maps.Map) ast.Decl
- func IncludeComments(includeNames ...string) []*ast.Comment
- func IncrementRef() ast.Decl
- func IncrementRefCall(target ast.Expr) ast.Expr
- func Init() ast.Decl
- func InstanceMethodParams(fields ...*ast.Field) *ast.FieldList
- func IsErrorNil() ast.Decl
- func MainFunc() *ast.FuncDecl
- func NamedToField(p *types.Var, named *types.Named) *ast.Field
- func NewAst(functionName string, goType ast.Expr) ast.Decl
- func NewAstWithInitialization(functionName string, goType ast.Expr, params []*ast.Field, ...) ast.Decl
- func NewIdent(name string) *ast.Ident
- func Panic(message string) ast.Expr
- func ParamExpr(param *types.Var, t types.Type) ast.Expr
- func ParamIdents(funcParams *types.Tuple) []ast.Expr
- func PkgPathAliasFromString(path string) string
- func RawComments(strs ...string) []*ast.Comment
- func Ref(expr ast.Expr) ast.Expr
- func RefsStruct() ast.Decl
- func Return(expressions ...ast.Expr) *ast.ReturnStmt
- func ShouldGenerate(v *types.Var) bool
- func ShouldGenerateField(v *types.Var) bool
- func StringAst(functionName string, goType ast.Expr) ast.Decl
- func ToC(typeName string, targets ...ast.Expr) ast.Expr
- func ToCChar(targets ...ast.Expr) ast.Expr
- func ToCDouble(targets ...ast.Expr) ast.Expr
- func ToCFloat(targets ...ast.Expr) ast.Expr
- func ToCInt(targets ...ast.Expr) ast.Expr
- func ToCLong(targets ...ast.Expr) ast.Expr
- func ToCLongLong(targets ...ast.Expr) ast.Expr
- func ToCShort(targets ...ast.Expr) ast.Expr
- func ToCString(targets ...ast.Expr) ast.Expr
- func ToCUInt(targets ...ast.Expr) ast.Expr
- func ToCULong(targets ...ast.Expr) ast.Expr
- func ToCULongLong(targets ...ast.Expr) ast.Expr
- func ToCUShort(targets ...ast.Expr) ast.Expr
- func ToGoString(targets ...ast.Expr) ast.Expr
- func ToUnsafePointer(targets ...ast.Expr) ast.Expr
- func TypeExpression(typ types.Type) ast.Expr
- func TypeExpressionToString(expr ast.Expr) string
- func TypeToArgumentTypeExpr(t types.Type) ast.Expr
- func UnsafePtrOrBasic(p *types.Var, t types.Type) *ast.Field
- func UuidToCBytes(uuidExpr ast.Expr) ast.Expr
- func VarToField(p *types.Var, t types.Type) *ast.Field
- type Aliased
- type Array
- type AstTransformer
- type Exportable
- type Func
- func (f Func) AliasedGoName() ast.Expr
- func (f Func) CDefs() (retTypes string, funcPtrs string, calls string)
- func (f Func) CName() string
- func (f Func) CallbackFuncName() string
- func (f Func) CallbackFuncPtrName() string
- func (f Func) ExportName() string
- func (f Func) InterfaceCallbackAst(iface Interface) ast.Decl
- func (f Func) IsExportable() bool
- func (f Func) PackagePath() string
- func (f Func) Signature() *types.Signature
- func (f Func) String() string
- func (f Func) ToAst() []ast.Decl
- func (f Func) Underlying() types.Type
- type Interface
- func (iface Interface) CDefs() (retTypes []string, funcPtrs []string, calls []string)
- func (iface Interface) CName() string
- func (iface Interface) CTypeName() ast.Expr
- func (iface Interface) ExportName() string
- func (iface Interface) ExportedMethods() []*Func
- func (iface Interface) HelperCallbackRegistrationAst() ast.Decl
- func (iface Interface) HelperStructAst() ast.Decl
- func (iface Interface) Interface() *types.Interface
- func (iface Interface) IsExportable() bool
- func (iface Interface) MethodAsts() []ast.Decl
- func (iface Interface) Name() string
- func (iface Interface) NewAst() ast.Decl
- func (iface Interface) StringAst() ast.Decl
- func (iface Interface) ToAst() []ast.Decl
- func (iface Interface) Underlying() types.Type
- type Named
- func (n Named) Alias() string
- func (n Named) CName() string
- func (n Named) CShortName() string
- func (n Named) CTypeName() ast.Expr
- func (n Named) ExportName() string
- func (n Named) ExportedMethods() []*Func
- func (n Named) IsExportable() bool
- func (n Named) MethodAsts() []ast.Decl
- func (n Named) NewAst() ast.Decl
- func (n Named) NewMethodName() string
- func (n Named) Path() string
- func (n Named) StringAst() ast.Decl
- func (n Named) ToAst() []ast.Decl
- func (n Named) ToStringMethodName() string
- type Package
- func (p Package) AstTransformers() []AstTransformer
- func (p Package) CDefinitions() []string
- func (p Package) ExportedTypes() []types.Type
- func (p Package) Funcs() []*Func
- func (p Package) ImportAliases() maps.Map
- func (p Package) Interfaces() []*Interface
- func (p Package) IsConstructor(f *Func) bool
- func (p Package) Name() string
- func (p Package) Structs() []*Struct
- func (p Package) ToAst() []ast.Decl
- type Slice
- func (s Slice) CGoName() string
- func (s Slice) Elem() types.Type
- func (s Slice) ElementName() string
- func (s Slice) ElementPackageAliasAndPath(typ types.Type) string
- func (s Slice) ExportName() string
- func (s Slice) GoTypeExpr() ast.Expr
- func (s Slice) IsExportable() bool
- func (s Slice) ItemAppendAst() ast.Decl
- func (s Slice) ItemAst() ast.Decl
- func (s Slice) ItemDeleteAst() ast.Decl
- func (s Slice) ItemInsertAst() ast.Decl
- func (s Slice) ItemSetAst() ast.Decl
- func (s Slice) LenAst() ast.Decl
- func (s Slice) MethodName() string
- func (s Slice) NewAst() ast.Decl
- func (s Slice) String() string
- func (s Slice) StringAst() ast.Decl
- func (s Slice) ToAst() []ast.Decl
- func (s Slice) Underlying() types.Type
- type Struct
- func (s Struct) ConstructorName(f *Func) string
- func (s Struct) FieldAccessorsAst() []ast.Decl
- func (s Struct) FieldName(field *types.Var) string
- func (s Struct) Getter(field *types.Var) ast.Decl
- func (s Struct) IsConstructor(f *Func) bool
- func (s Struct) Setter(field *types.Var) ast.Decl
- func (s Struct) Struct() *types.Struct
- func (s Struct) ToAst() []ast.Decl
Constants ¶
const ( GET_REF_FUNC_NAME = "cgo_get_ref" GET_UUID_FROM_PTR_NAME = "cgo_get_uuid_from_ptr" INCREMENT_REF_FUNC_NAME = "cgo_incref" DECREMENT_REF_FUNC_NAME = "cgo_decref" ERROR_TO_STRING_FUNC_NAME = "cgo_error_to_string" IS_ERROR_NIL_FUNC_NAME = "cgo_is_error_nil" CFREE_FUNC_NAME = "cgo_cfree" COBJECT_STRUCT_TYPE_NAME = "cobject" REFS_VAR_NAME = "refs" REFS_STRUCT_FIELD_NAME = "refs" )
Variables ¶
This section is empty.
Functions ¶
func ArrayConstructor ¶
func CObjectStruct ¶
CObjectStruct produces an AST struct which will represent a C exposed Object
func CastUnsafePtr ¶
CastUnsafePtr take a cast type and target expression and returns a cast expression
func DeclareVar ¶
DeclareVar declares a local variable
func DecrementRef ¶
func DecrementRefCall ¶
DecrementRefCall takes a target expression to decrement it's cgo pointer ref and returns the expression
func ErrorToString ¶
func ExportComments ¶
ExportComments takes a name to export as string and returns a comment group
func FormatSprintf ¶
FormatSprintf takes a format and a target expression and returns a fmt.Sprintf expression
func GetUuidFromPtr ¶
func ImplementsError ¶
ImplementsError returns true if a type has an Error() string function signature
func ImportsFromMap ¶
ImportsFromMap create import ASTs from alias keys and package path values
func IncludeComments ¶
IncludeComments takes includeNames and returns AST comments for each include
func IncrementRef ¶
func IncrementRefCall ¶
IncrementRefCall takes a target expression to increment it's cgo pointer ref and returns the expression
func InstanceMethodParams ¶
InstanceMethodParams returns a constructed field list for an instance method
func IsErrorNil ¶
func NamedToField ¶
NameToField transforms a Var that's a Named type into an AST Field
func NewAst ¶
NewAst produces the []ast.Decl to construct a slice type and increment it's reference count
func ParamIdents ¶
ParamIdents transforms parameter tuples into a slice of AST expressions
func PkgPathAliasFromString ¶
PkgPathAliasFromString takes a golang path as a string and returns an import alias for that path
func RawComments ¶
func RefsStruct ¶
RefsStruct produces an AST struct which will keep track of references to pointers used by the host CFFI
func Return ¶
func Return(expressions ...ast.Expr) *ast.ReturnStmt
Return takes an expression and returns a return statement containing the expression
func ShouldGenerate ¶
func ShouldGenerateField ¶
func TypeExpressionToString ¶
func UnsafePtrOrBasic ¶
UnsafePtrOrBasic returns a Basic typed field or an unsafe pointer if not a Basic type
Types ¶
type Array ¶
type Array struct {
// contains filtered or unexported fields
}
ArrayWrapper is a wrapper for the
func (Array) Underlying ¶
Underlying returns the underlying type of the Array (types.Type)
type AstTransformer ¶
type AstTransformer interface { ToAst() []ast.Decl Underlying() types.Type Exportable }
type Exportable ¶
type Func ¶
FuncWrapper is a wrapper for a Function
func (Func) AliasedGoName ¶
func (Func) CallbackFuncName ¶
func (Func) CallbackFuncPtrName ¶
func (Func) ExportName ¶
func (Func) InterfaceCallbackAst ¶
InterfaceCallbackAst produces proxy functions for interface methods which act as a C bridge between Golang and the hosting language. It translates Golang Args to C args, calls a function callback into the hosting language providing arguments, an object handle, and captures a return. The return struct is then transformed back into Golang and C arguments are freed.
The function looks like the following.
func (iface veil_io_Reader_helper) Read(p []byte) (n int, err error) { fun, ok := iface.callbacks["Read"] if ok { arg0 := C.CBytes(cgo_incref(unsafe.Pointer(&p)).Bytes()) res := C.CallHandleFunc_2_1(arg0, iface.handle, (*C.FuncPtr_2_1)(fun)) cgo_decref(arg0) var r0 int if res.r0 == nil { panic("result: 0 is nil and must have a value") } else { r0 = *(*int)(res.r0) } var r1 error if res.r1 == nil { r1 = nil } else { r1 = *(*error)(res.r1) } return r0, r1 } else { panic("can't find registerd method: Read") } }
func (Func) IsExportable ¶
func (Func) PackagePath ¶
func (Func) Underlying ¶
Underlying returns the underlying type
type Interface ¶
type Interface struct {
// contains filtered or unexported fields
}
Inerface is a helpful facade over types.Named which is intended to only contain an Interface
func NewInterface ¶
func (Interface) CTypeName ¶
CTypeName returns the selector expression for the Named aliased package and type
func (Interface) ExportName ¶
func (Interface) ExportedMethods ¶
func (Interface) HelperCallbackRegistrationAst ¶
func (Interface) HelperStructAst ¶
func (Interface) IsExportable ¶
func (Interface) MethodAsts ¶
func (Interface) NewAst ¶
NewAst produces the []ast.Decl to construct a named type and increment it's reference count
func (Interface) StringAst ¶
StringAst produces the []ast.Decl to provide a string representation of the named type
func (Interface) ToAst ¶
ToAst returns the go/ast representation of the CGo wrapper of the named type
func (Interface) Underlying ¶
type Named ¶
func (Named) CShortName ¶
func (Named) CTypeName ¶
CTypeName returns the selector expression for the Named aliased package and type
func (Named) ExportName ¶
func (Named) ExportedMethods ¶
Methods returns the list of methods decorated on the named type
func (Named) IsExportable ¶
func (Named) MethodAsts ¶
func (Named) NewAst ¶
NewAst produces the []ast.Decl to construct a named type and increment it's reference count
func (Named) NewMethodName ¶
func (Named) StringAst ¶
StringAst produces the []ast.Decl to provide a string representation of the named type
func (Named) ToStringMethodName ¶
type Package ¶
type Package struct {
// contains filtered or unexported fields
}
Package is a container for ast.Types and Docs
func NewPackage ¶
NewPackage constructs a Package from pkgPath using the specified working directory
func (Package) AstTransformers ¶
func (p Package) AstTransformers() []AstTransformer
func (Package) CDefinitions ¶
func (Package) ExportedTypes ¶
func (Package) ImportAliases ¶
func (Package) Interfaces ¶
func (Package) IsConstructor ¶
type Slice ¶
type Slice struct {
// contains filtered or unexported fields
}
ArrayWrapper is a wrapper for the
func (Slice) ElementName ¶
func (Slice) ElementPackageAliasAndPath ¶
func (Slice) ExportName ¶
func (Slice) GoTypeExpr ¶
func (Slice) IsExportable ¶
func (Slice) ItemAppendAst ¶
ItemAppendAst returns a function declaration which appends an item to the slice
func (Slice) ItemDeleteAst ¶
ItemDeleteAst returns a function declaration which deletes an item from the slice
func (Slice) ItemInsertAst ¶
ItemInsertAst returns a function declaration which inserts an item into the slice
func (Slice) ItemSetAst ¶
func (Slice) MethodName ¶
func (Slice) NewAst ¶
NewAst produces the []ast.Decl to construct a slice type and increment it's reference count
func (Slice) StringAst ¶
StringAst produces the []ast.Decl to provide a string representation of the slice
func (Slice) Underlying ¶
Underlying returns the underlying type of the Slice (types.Type)
type Struct ¶
type Struct struct {
*Named
}
Struct is a helpful facade over types.Named which is intended to only contain a struct