typing

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Bool = &PrimitiveType{GoName_: "bool", ObjcName_: "BOOL"}
View Source
var Byte = &PrimitiveType{GoName_: "byte", ObjcName_: "char"}
View Source
var Class = &ClassType{
	Name:   "Class",
	GName:  "Class",
	Module: modules.Get("objc"),
}
View Source
var Double = &PrimitiveType{GoName_: "float64", ObjcName_: "double"}
View Source
var Float = &PrimitiveType{GoName_: "float32", ObjcName_: "float"}
View Source
var Int = &PrimitiveType{GoName_: "int", ObjcName_: "NSInteger"}
View Source
var Int16 = &PrimitiveType{GoName_: "int16", ObjcName_: "int16_t"}
View Source
var Int32 = &PrimitiveType{GoName_: "int32", ObjcName_: "int32_t"}
View Source
var Int64 = &PrimitiveType{GoName_: "int64", ObjcName_: "int64_t"}
View Source
var Int8 = &PrimitiveType{GoName_: "int8", ObjcName_: "int8_t"}
View Source
var Object = &ClassType{
	Name:   "NSObject",
	GName:  "Object",
	Module: modules.Get("objc"),
}

Object is the objc object root class type

View Source
var UInt = &PrimitiveType{GoName_: "uint", ObjcName_: "NSUInteger"}
View Source
var UInt16 = &PrimitiveType{GoName_: "uint16", ObjcName_: "uint16_t"}
View Source
var UInt32 = &PrimitiveType{GoName_: "uint32", ObjcName_: "uint32_t"}
View Source
var UInt64 = &PrimitiveType{GoName_: "uint64", ObjcName_: "uint64_t"}
View Source
var UInt8 = &PrimitiveType{GoName_: "uint8", ObjcName_: "uint8_t"}

Functions

func FullGoName

func FullGoName(module modules.Module, name string, currentModule modules.Module) string

Types

type AliasType

type AliasType struct {
	Type   Type            // the real type
	GName  string          // alias name for new go type
	Name   string          // the objc name
	Module *modules.Module // used when Alias is not empty
}

AliasType type def types

func (*AliasType) DeclareModule

func (a *AliasType) DeclareModule() *modules.Module

func (*AliasType) GoImports

func (a *AliasType) GoImports() set.Set[string]

func (*AliasType) GoName

func (a *AliasType) GoName(currentModule *modules.Module, receiveFromObjc bool) string

func (*AliasType) ObjcName

func (a *AliasType) ObjcName() string

type ArrayType

type ArrayType struct {
	Type Type
}

ArrayType the element should be StringType or ClassType

func (*ArrayType) DeclareModule

func (a *ArrayType) DeclareModule() *modules.Module

func (*ArrayType) GoImports

func (a *ArrayType) GoImports() set.Set[string]

func (*ArrayType) GoName

func (a *ArrayType) GoName(currentModule *modules.Module, receiveFromObjc bool) string

func (*ArrayType) ObjcName

func (a *ArrayType) ObjcName() string

type BlockParam

type BlockParam struct {
	Type Type
	Name string // the param name
}

type BlockType

type BlockType struct {
	ReturnType Type
	Params     []BlockParam
}

BlockType

func (*BlockType) DeclareModule

func (a *BlockType) DeclareModule() *modules.Module

func (*BlockType) GoImports

func (a *BlockType) GoImports() set.Set[string]

func (*BlockType) GoName

func (a *BlockType) GoName(currentModule *modules.Module, receiveFromObjc bool) string

func (*BlockType) ObjcName

func (a *BlockType) ObjcName() string

type ClassType

type ClassType struct {
	Name   string          // objc type name
	GName  string          // Go name, usually is objc type name without prefix 'NS'
	Module *modules.Module // object-c module
}

ClassType Objective-c interface type

func (*ClassType) DeclareModule

func (c *ClassType) DeclareModule() *modules.Module

func (*ClassType) GoImports

func (c *ClassType) GoImports() set.Set[string]

func (*ClassType) GoInterfaceName

func (c *ClassType) GoInterfaceName() string

GoInterfaceName return the go wrapper interface name

func (*ClassType) GoName

func (c *ClassType) GoName(currentModule *modules.Module, receiveFromObjc bool) string

func (*ClassType) GoStructName

func (c *ClassType) GoStructName() string

GoStructName return the go wrapper struct name

func (*ClassType) ObjcName

func (c *ClassType) ObjcName() string

type DataType

type DataType struct {
}

DataType objc binary data type

func (*DataType) DeclareModule

func (d *DataType) DeclareModule() *modules.Module

func (*DataType) GoImports

func (d *DataType) GoImports() set.Set[string]

func (*DataType) GoName

func (d *DataType) GoName(currentModule *modules.Module, receiveFromObjc bool) string

func (*DataType) ObjcName

func (d *DataType) ObjcName() string

type DictType

type DictType struct {
	KeyType   Type
	ValueType Type
}

DictType for objc Dictionary types, the element should be StringType or ClassType

func (*DictType) DeclareModule

func (d *DictType) DeclareModule() *modules.Module

func (*DictType) GoImports

func (d *DictType) GoImports() set.Set[string]

func (*DictType) GoName

func (d *DictType) GoName(currentModule *modules.Module, receiveFromObjc bool) string

func (*DictType) ObjcName

func (d *DictType) ObjcName() string

type DispatchType

type DispatchType struct {
	ObjcName_ string // objc type name
}

func (*DispatchType) DeclareModule

func (d *DispatchType) DeclareModule() *modules.Module

func (*DispatchType) GoImports

func (d *DispatchType) GoImports() set.Set[string]

func (*DispatchType) GoName

func (d *DispatchType) GoName(currentModule *modules.Module, receiveFromObjc bool) string

func (*DispatchType) ObjcName

func (d *DispatchType) ObjcName() string

type IDType

type IDType struct {
}

InstanceType the objc instancetype. class method start with alloc or new, instance method start with autorelease,init,retain or self, return instancetype.

func (*IDType) DeclareModule

func (i *IDType) DeclareModule() *modules.Module

func (*IDType) GoImports

func (i *IDType) GoImports() set.Set[string]

func (*IDType) GoName

func (i *IDType) GoName(currentModule *modules.Module, receiveFromObjc bool) string

func (*IDType) ObjcName

func (i *IDType) ObjcName() string

type InstanceType

type InstanceType struct {
}

InstanceType the objc instancetype. class method start with alloc or new, instance method start with autorelease,init,retain or self, return instancetype.

func (*InstanceType) DeclareModule

func (i *InstanceType) DeclareModule() *modules.Module

func (*InstanceType) GoImports

func (i *InstanceType) GoImports() set.Set[string]

func (*InstanceType) GoName

func (i *InstanceType) GoName(currentModule *modules.Module, receiveFromObjc bool) string

func (*InstanceType) ObjcName

func (i *InstanceType) ObjcName() string

type KernelType

type KernelType struct {
	ObjcName_ string // objc type name
}

func (*KernelType) DeclareModule

func (k *KernelType) DeclareModule() *modules.Module

func (*KernelType) GoImports

func (k *KernelType) GoImports() set.Set[string]

func (*KernelType) GoName

func (k *KernelType) GoName(currentModule *modules.Module, receiveFromObjc bool) string

func (*KernelType) ObjcName

func (k *KernelType) ObjcName() string

type PointerRefType

type PointerRefType struct {
	Name   string          // objc type name
	GName  string          // Go name, usually is objc type name without prefix 'NS'
	Module *modules.Module // object-c module
}

PointerRefType c pointer type def

func (*PointerRefType) DeclareModule

func (c *PointerRefType) DeclareModule() *modules.Module

func (*PointerRefType) GoImports

func (c *PointerRefType) GoImports() set.Set[string]

func (*PointerRefType) GoName

func (c *PointerRefType) GoName(currentModule *modules.Module, receiveFromObjc bool) string

func (*PointerRefType) ObjcName

func (c *PointerRefType) ObjcName() string

type PointerType

type PointerType struct {
	Type Type
}

PointerType is c pointer type

func (*PointerType) DeclareModule

func (c *PointerType) DeclareModule() *modules.Module

func (*PointerType) GoImports

func (c *PointerType) GoImports() set.Set[string]

func (*PointerType) GoName

func (c *PointerType) GoName(currentModule *modules.Module, receiveFromObjc bool) string

func (*PointerType) ObjcName

func (c *PointerType) ObjcName() string

type PrimitiveType

type PrimitiveType struct {
	GoName_   string // go type name
	ObjcName_ string // objc type name
}

PrimitiveType primitive types

func GetPrimitiveType

func GetPrimitiveType(typeName string) (*PrimitiveType, bool)

func (*PrimitiveType) DeclareModule

func (p *PrimitiveType) DeclareModule() *modules.Module

func (*PrimitiveType) GoImports

func (p *PrimitiveType) GoImports() set.Set[string]

func (*PrimitiveType) GoName

func (p *PrimitiveType) GoName(currentModule *modules.Module, receiveFromObjc bool) string

func (*PrimitiveType) ObjcName

func (p *PrimitiveType) ObjcName() string

func (*PrimitiveType) ToUnsigned

func (p *PrimitiveType) ToUnsigned() *PrimitiveType

type ProtocolType

type ProtocolType struct {
	Name   string          // the objc type name
	GName  string          // Go name, usually is objc type name without prefix 'NS'
	Module *modules.Module // object-c module name
}

ProtocolType objective-c protocol type

func (*ProtocolType) DeclareModule

func (p *ProtocolType) DeclareModule() *modules.Module

func (*ProtocolType) GoImports

func (p *ProtocolType) GoImports() set.Set[string]

func (*ProtocolType) GoInterfaceName

func (p *ProtocolType) GoInterfaceName() string

func (*ProtocolType) GoName

func (p *ProtocolType) GoName(currentModule *modules.Module, receiveFromObjc bool) string

func (*ProtocolType) GoStructName

func (p *ProtocolType) GoStructName() string

func (*ProtocolType) GoWrapperName

func (p *ProtocolType) GoWrapperName() string

func (*ProtocolType) ObjcName

func (p *ProtocolType) ObjcName() string

type RefType

type RefType struct {
	Name string // c and objc type name

}

for weird struct refs like those ending in "Ref"

func (*RefType) DeclareModule

func (s *RefType) DeclareModule() *modules.Module

func (*RefType) GoImports

func (s *RefType) GoImports() set.Set[string]

func (*RefType) GoName

func (s *RefType) GoName(currentModule *modules.Module, receiveFromObjc bool) string

func (*RefType) ObjcName

func (s *RefType) ObjcName() string

type SelectorType

type SelectorType struct {
}

SelectorType objc selector type

func (*SelectorType) DeclareModule

func (s *SelectorType) DeclareModule() *modules.Module

func (*SelectorType) GoImports

func (s *SelectorType) GoImports() set.Set[string]

func (*SelectorType) GoName

func (s *SelectorType) GoName(currentModule *modules.Module, receiveFromObjc bool) string

func (*SelectorType) ObjcName

func (s *SelectorType) ObjcName() string

type StringType

type StringType struct {
	NeedNil bool // string type need nil value.If set to true, will use foundation.String instread string for generated go code.
}

StringType string

func (*StringType) DeclareModule

func (s *StringType) DeclareModule() *modules.Module

func (*StringType) GoImports

func (s *StringType) GoImports() set.Set[string]

func (*StringType) GoName

func (s *StringType) GoName(currentModule *modules.Module, receiveFromObjc bool) string

func (*StringType) ObjcName

func (s *StringType) ObjcName() string

type StructType

type StructType struct {
	Name   string          // c and objc type name
	GName  string          // the go struct name
	Module *modules.Module // the module
}

StructType struct type

func (*StructType) DeclareModule

func (s *StructType) DeclareModule() *modules.Module

func (*StructType) GoImports

func (s *StructType) GoImports() set.Set[string]

func (*StructType) GoName

func (s *StructType) GoName(currentModule *modules.Module, receiveFromObjc bool) string

func (*StructType) ObjcName

func (s *StructType) ObjcName() string

type Type

type Type interface {
	// GoName Go type name
	GoName(currentModule *modules.Module, receiveFromObjc bool) string
	// ObjcName Objective-c type name
	ObjcName() string

	// GoImports go imports for this type
	GoImports() set.Set[string]

	// DeclareModule the module of this type. return nil if is a built in type
	DeclareModule() *modules.Module
}

Type interface for all type

func GetDispatchType

func GetDispatchType(typeName string) (Type, bool)

func GetKernelType

func GetKernelType(typeName string) (Type, bool)

func UnwrapAlias

func UnwrapAlias(t Type) Type

UnwrapAlias unwrap alias type to it's real underlying type

type VoidPointerType

type VoidPointerType struct {
	Name  string // objc type name
	GName string // Go name, usually is objc type name without prefix 'NS'
}

VoidPointerType void*/unsafe.Pointer

func (*VoidPointerType) DeclareModule

func (c *VoidPointerType) DeclareModule() *modules.Module

func (*VoidPointerType) GoImports

func (c *VoidPointerType) GoImports() set.Set[string]

func (*VoidPointerType) GoName

func (c *VoidPointerType) GoName(currentModule *modules.Module, receiveFromObjc bool) string

func (*VoidPointerType) ObjcName

func (c *VoidPointerType) ObjcName() string

type VoidType

type VoidType struct {
}

VoidType for void return

func (*VoidType) DeclareModule

func (d *VoidType) DeclareModule() *modules.Module

func (*VoidType) GoImports

func (d *VoidType) GoImports() set.Set[string]

func (*VoidType) GoName

func (d *VoidType) GoName(currentModule *modules.Module, receiveFromObjc bool) string

func (*VoidType) ObjcName

func (d *VoidType) ObjcName() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL