Documentation ¶
Index ¶
- Variables
- func Create(filename string) (*os.File, error)
- type Class
- type CodeGen
- type CodeWriter
- type EnumInfo
- type EnumValue
- type FileWriter
- type Method
- func (m *Method) GoFuncDeclare(currentModule *typing.Module, goTypeName string) string
- func (m *Method) GoFuncName(goTypeName string) string
- func (m *Method) GoImports() set.Set[string]
- func (m *Method) NormalizeInstanceTypeMethod(returnType *typing.ClassType) *Method
- func (m *Method) ProtocolGoFuncFieldType(currentModule *typing.Module) string
- func (m *Method) ProtocolGoFuncName() string
- func (m *Method) Selector() string
- func (m *Method) String() string
- func (m *Method) WriteGoCallCode(currentModule *typing.Module, typeName string, cw *CodeWriter)
- func (m *Method) WriteGoInterfaceCode(currentModule *typing.Module, classType *typing.ClassType, w *CodeWriter)
- type ModuleWriter
- type Param
- type Property
- type Protocol
Constants ¶
This section is empty.
Variables ¶
var AutoGeneratedMark = "// auto-generated code, do not modify"
Functions ¶
Types ¶
type Class ¶
type Class struct { Type *typing.ClassType Parent *Class Properties []*Property InstanceTypeMethods []*Method // methods that return instance type Methods []*Method // 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 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 *typing.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 typing.Module CodeFileDir 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 // contains filtered or unexported fields }
Method is code generator for objective-c method
func (*Method) GoFuncDeclare ¶
GoFuncDeclare generate go function declaration
func (*Method) GoFuncName ¶
GoFuncName return go func name
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) WriteGoCallCode ¶
func (m *Method) WriteGoCallCode(currentModule *typing.Module, typeName string, cw *CodeWriter)
WriteGoCallCode generate go method code to call c wrapper code
func (*Method) WriteGoInterfaceCode ¶
func (m *Method) WriteGoInterfaceCode(currentModule *typing.Module, classType *typing.ClassType, w *CodeWriter)
WriteGoInterfaceCode generate go interface method signature code
type ModuleWriter ¶
type ModuleWriter struct { Module typing.Module CodeFileDir string Protocols []*typing.ProtocolType Aliases []*EnumInfo }
ModuleWriter mantains module level auto-generated code source files
func (*ModuleWriter) WriteAliasesCode ¶
func (m *ModuleWriter) WriteAliasesCode()
func (*ModuleWriter) WriteCode ¶
func (m *ModuleWriter) WriteCode()
func (*ModuleWriter) WriteProtocolsImportCode ¶
func (m *ModuleWriter) WriteProtocolsImportCode()
type Param ¶
type Param struct { Name string Type typing.Type FieldName string // objc param field name(part of function name) }
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 Type typing.Type ClassProperty bool Weak bool Deprecated bool Required bool //for protocol }
Property is code generator for objective-c property
type Protocol ¶
type Protocol struct { Type *typing.ProtocolType Parents []*Protocol Methods []*Method Properties []*Property // contains filtered or unexported fields }
Protocol is code generator for objc protocol.
func (*Protocol) WriteGoCode ¶
func (p *Protocol) WriteGoCode(w *CodeWriter)