gen

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Gen

func Gen(items []GenItem, allowPkgPath []string, outDir string) error

func allowPkgPath

Types

type BField

type BField struct {
	Name string `json:"name"`
	Type *BType `json:"type"`
}

type BMethod

type BMethod struct {
	Name string   `json:"name"`
	Type string   `json:"type"`
	In   []*BType `json:"in"`
	Out  []*BType `json:"out"`
	//全局函数
	IsFunc  bool   `json:"is_func"`
	PkgPath string `json:"pkg_path"`
	PkgName string `json:"pkg_name"`
}

func (*BMethod) InDefine

func (m *BMethod) InDefine(i int) string

func (*BMethod) InLen

func (m *BMethod) InLen() int

func (*BMethod) InParam

func (m *BMethod) InParam() string

func (*BMethod) InType

func (m *BMethod) InType() string

func (*BMethod) OutCanNil

func (m *BMethod) OutCanNil(i int) bool

func (*BMethod) OutGet

func (m *BMethod) OutGet(i int) *BType

func (*BMethod) OutLen

func (m *BMethod) OutLen() int

func (*BMethod) OutRetArr

func (m *BMethod) OutRetArr() [][3]any

r1,lua.LNumber(r1)

func (*BMethod) OutRetStr

func (m *BMethod) OutRetStr() string

func (*BMethod) OutType

func (m *BMethod) OutType() string

type BType

type BType struct {
	PkgPath string `json:"pkg_path"`
	PkgName string `json:"pkg_name"`
	Name    string `json:"name"`
	IsPtr   bool   `json:"is_ptr"`

	IsBool   bool `json:"is_bool"`
	IsInt    bool `json:"is_int"`
	IsString bool `json:"is_string"`
	IsFloat  bool `json:"is_float"`
	IsNumber bool `json:"is_number"`

	IsStruct bool   `json:"is_struct"`
	IsSlice  bool   `json:"is_slice"`
	IsArray  bool   `json:"is_array"`
	ElemType *BType `json:"elem_type"`

	IsMap       bool   `json:"is_map"`
	ElemKeyType *BType `json:"elem_key_type"`

	IsInterface bool `json:"is_interface"`
	IsError     bool `json:"is_error"`

	IsAny bool `json:"is_any"`

	IsFunc      bool     `json:"is_func"`
	IsFuncValid bool     `json:"is_func_valid"`
	In          []*BType `json:"in"`
	Out         []*BType `json:"out"`

	RefType reflect.Type `json:"reflect_type"`
	//for fields,methods in out, [1...]
	Index int `json:"index"`
}

func (*BType) FuncDefine

func (t *BType) FuncDefine(pfName string) string

type BindData

type BindData struct {
	//out
	AllType map[string]*BType `json:"all_type"` //tp.PkgPath()/Name
	AllObj  map[string]*Obj   `json:"all_obj"`  //tp.PkgPath()/Name
	Objs    []*Obj            `json:"objs"`
	//filter
	AllInterface     map[string]*BType `json:"interface"` //tp.PkgPath()/Name
	InterfacePkgPath map[string]int    `json:"interface_pkg_path"`
	AllItf           map[string]*Obj   `json:"all_itf"` //tp.PkgPath()/Name
	//in
	AllowPkgPath map[string]int `json:"allow_pkg_path"`
	Items        []GenItem      `json:"-"`
}

func NewBindData

func NewBindData(items []GenItem, allowPkgPath []string) *BindData

func (*BindData) AddBType

func (b *BindData) AddBType(t *BType) (out *BType)

func (*BindData) AddInterface

func (b *BindData) AddInterface(t *Obj) (out *Obj)

func (*BindData) AddObj

func (b *BindData) AddObj(t *Obj) (out *Obj)

func (*BindData) CopyBType

func (b *BindData) CopyBType(t *BType) (out *BType)

func (*BindData) GetBType

func (b *BindData) GetBType(name, pkgPath string) (out *BType)

func (*BindData) GetObj

func (b *BindData) GetObj(name, pkgPath string) (out *Obj)

func (*BindData) IsAllowPkgPath

func (b *BindData) IsAllowPkgPath(path string) (out bool)

func (*BindData) Load

func (b *BindData) Load() error

laod all

func (*BindData) LoadFunc

func (b *BindData) LoadFunc(bObj *Obj, funcs [][2]any) error

load global func

func (*BindData) LoadFuncParam

func (b *BindData) LoadFuncParam(ptp *BType) error

load func in out

func (*BindData) LoadInterface

func (b *BindData) LoadInterface(btp *BType) (*Obj, error)

load interface

func (*BindData) LoadObj

func (b *BindData) LoadObj(obj any) (*Obj, error)

load struct

func (*BindData) LoadType

func (b *BindData) LoadType(tp reflect.Type, btpIn *BType) (btp *BType, ignore bool)

return value is a copy from AllType

type GenItem

type GenItem struct {
	Obj   any
	Funcs [][2]any
}

type Obj

type Obj struct {
	BType   `json:"type"`
	Fields  []*BField  `json:"fields"`
	Methods []*BMethod `json:"methods"`
	//global
	Funcs []*BMethod `json:"funcs"`
	//
	Import map[string]int `json:"import"`
}

func (*Obj) AddImport

func (o *Obj) AddImport(path string)

func (*Obj) AddImportByField

func (o *Obj) AddImportByField(fd *BField)

func (*Obj) FieldsBind

func (o *Obj) FieldsBind() map[string][2]string

simple field

func (*Obj) FieldsBindFunc

func (o *Obj) FieldsBindFunc() [][3]any

func (*Obj) FieldsBindMap

func (o *Obj) FieldsBindMap() [][3]any

table field

func (*Obj) FieldsBindSlice

func (o *Obj) FieldsBindSlice() [][3]any

func (*Obj) GenImportPkg

func (o *Obj) GenImportPkg()

no use,所有xxx_bind 在一个目录

func (*Obj) LowerName

func (o *Obj) LowerName() string

func (*Obj) UdName

func (o *Obj) UdName() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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