Documentation
¶
Index ¶
- Variables
- func Create(filename string) (*os.File, error)
- type AliasInfo
- type Class
- type CodeGen
- type CodeWriter
- type EnumValue
- type FileWriter
- type Method
- func (m *Method) GoFuncDeclare(currentModule *modules.Module, goTypeName string) string
- func (m *Method) GoFuncName() string
- func (m *Method) GoImports() set.Set[string]
- func (m *Method) HasProtocolParam() bool
- func (m *Method) NormalizeInstanceTypeMethod(returnType *typing.ClassType) *Method
- func (m *Method) ProtocolGoFuncFieldType(currentModule *modules.Module) string
- func (m *Method) ProtocolGoFuncName() string
- func (m *Method) Selector() string
- func (m *Method) String() string
- func (m *Method) ToProtocolParamAsObjectMethod() *Method
- func (m *Method) WriteGoCallCode(currentModule *modules.Module, typeName string, cw *CodeWriter)
- func (m *Method) WriteGoInterfaceCode(currentModule *modules.Module, classType *typing.ClassType, w *CodeWriter)
- type ModuleWriter
- type Param
- type Property
- type Protocol
Constants ¶
This section is empty.
Variables ¶
var AutoGeneratedMark = "// Code generated by DarwinKit. DO NOT EDIT.\n"
Functions ¶
Types ¶
type Class ¶
type Class struct {
Type *typing.ClassType
Super *Class
Properties []*Property
InstanceTypeMethods []*Method // methods that return instance type
Methods []*Method
Description string
DocURL string
// contains filtered or unexported fields
}
Class is code generator for objc class
func (*Class) WriteGoCode ¶
func (c *Class) WriteGoCode(cw *CodeWriter)
type CodeGen ¶
type CodeGen interface {
Init()
Copy() CodeGen // I do NOT understand why this exists
GoImports() set.Set[string]
WriteGoCode(cw *CodeWriter)
}
CodeGen is interface for Class/Protocol code Gen
type CodeWriter ¶
type CodeWriter struct {
Writer io.Writer
IndentStr string
// contains filtered or unexported fields
}
CodeWriter write code
func (*CodeWriter) WriteLine ¶
func (c *CodeWriter) WriteLine(line string)
WriteLine write one line code
func (*CodeWriter) WriteLineF ¶
func (c *CodeWriter) WriteLineF(format string, values ...any)
WriteLine write one line code
func (*CodeWriter) WriteLines ¶
func (c *CodeWriter) WriteLines(lines []string)
WriteLines write multi lines code
type EnumValue ¶
type EnumValue struct {
Name string // the objc enum name
GoName string // the go name of enum
Value string // the value(amd64 arch)
Arm64Value string // the value for arm64. if is empty, use Value
Module *modules.Module // the module enum value defined in
}
EnumValue the enum name and value
type FileWriter ¶
type FileWriter struct {
Name string // usually the header file name, without .h
Module modules.Module
PlatformDir string
// contains filtered or unexported fields
}
TypeWriter write codes for a go file
func (*FileWriter) Add ¶
func (w *FileWriter) Add(types ...CodeGen)
func (*FileWriter) WriteCode ¶
func (w *FileWriter) WriteCode()
type Method ¶
type Method struct {
Name string // the first part of objc method name
GoName string
Params []*Param
ReturnType typing.Type
ClassMethod bool // true if is class method
WeakProperty bool // if is a weak property setter
Deprecated bool // if has been deprecated
Required bool // If this method is required. only for protocol method.
InitMethod bool // method that return instancetype
Suffix bool // GoName conflicts so add suffix to this method
Variadic bool
Description string
DocURL string
Protocol bool
// contains filtered or unexported fields
}
Method is code generator for objective-c method
func (*Method) GoFuncDeclare ¶
GoFuncDeclare generate go function declaration
func (*Method) HasProtocolParam ¶
func (*Method) NormalizeInstanceTypeMethod ¶
NormalizeInstanceTypeMethod return new init method.
func (*Method) ProtocolGoFuncFieldType ¶
ProtocolGoFuncFieldType generate go function declaration for protocol struct impl field
func (*Method) ProtocolGoFuncName ¶
ProtocolGoFuncName return go protocol func name
func (*Method) ToProtocolParamAsObjectMethod ¶
func (*Method) WriteGoCallCode ¶
func (m *Method) WriteGoCallCode(currentModule *modules.Module, typeName string, cw *CodeWriter)
WriteGoCallCode generate go method code to call c wrapper code
func (*Method) WriteGoInterfaceCode ¶
func (m *Method) WriteGoInterfaceCode(currentModule *modules.Module, classType *typing.ClassType, w *CodeWriter)
WriteGoInterfaceCode generate go interface method signature code
type ModuleWriter ¶
type ModuleWriter struct {
Module modules.Module
Description string
DocURL string
PlatformDir string
Protocols []*typing.ProtocolType
EnumAliases []*AliasInfo
FuncAliases []*AliasInfo
}
ModuleWriter mantains module level auto-generated code source files
func (*ModuleWriter) WriteCode ¶
func (m *ModuleWriter) WriteCode()
func (*ModuleWriter) WriteDocFile ¶
func (m *ModuleWriter) WriteDocFile()
func (*ModuleWriter) WriteEnumAliases ¶
func (m *ModuleWriter) WriteEnumAliases()
func (*ModuleWriter) WriteProtocolsImportCode ¶
func (m *ModuleWriter) WriteProtocolsImportCode()
func (*ModuleWriter) WriteTypeAliases ¶
func (m *ModuleWriter) WriteTypeAliases()
type Param ¶
type Param struct {
Name string
Type typing.Type
FieldName string // objc param field name(part of function name)
Object bool // version of param generalized to IObject for protocols
IsPtrPtr bool
}
Param is code generator for objective-c method param
func (*Param) ObjcDeclare ¶
type Property ¶
type Property struct {
Name string
GoName string
ReadOnly bool
GetterName string
SetterName string
Type typing.Type
ClassProperty bool
Weak bool
Deprecated bool
Required bool //for protocol
Description string
DocURL string
}
Property is code generator for objective-c property
type Protocol ¶
type Protocol struct {
Type *typing.ProtocolType
Supers []*Protocol
Methods []*Method
Properties []*Property
Description string
DocURL string
SkipInterface bool
SkipWrapper bool
SkipDelegate bool
// contains filtered or unexported fields
}
Protocol is code generator for objc protocol.
func (*Protocol) WriteGoCode ¶
func (p *Protocol) WriteGoCode(w *CodeWriter)