Documentation ¶
Index ¶
- Variables
- func Lazy(name string, init func() interface{}) func(*lua.LState) error
- func Library() func(ls *lua.LState) error
- func Module(name string, val interface{}) func(*lua.LState) error
- func Source(r io.Reader, name ...string) func(*lua.LState) error
- func Type(name string, val interface{}) func(*lua.LState) error
- func Value(name string, val interface{}) func(*lua.LState) error
- type LuaModule
- type LuaPool
- func (p *LuaPool) Close() error
- func (p *LuaPool) DoFile(file string) error
- func (p *LuaPool) DoString(source string) error
- func (p *LuaPool) Get() *lua.LState
- func (p *LuaPool) Group(l int) (result []*lua.LState)
- func (p *LuaPool) ModuleFile(file string) (LuaModule, error)
- func (p *LuaPool) ModuleString(source string) (LuaModule, error)
- func (p *LuaPool) Preload(load ...func(*lua.LState) error) *LuaPool
- func (p *LuaPool) Put(L *lua.LState)
Constants ¶
This section is empty.
Variables ¶
View Source
var TypeTable = map[reflect.Type]func(interface{}, lua.LValue){ reflect.TypeOf(""): func(dst interface{}, src lua.LValue) { *(dst.(*string)) = src.String() }, reflect.TypeOf(true): func(dst interface{}, src lua.LValue) { switch src.Type() { case lua.LTNil: *(dst.(*bool)) = false case lua.LTString: *(dst.(*bool)), _ = strconv.ParseBool(string(src.(lua.LString))) default: *(dst.(*bool)) = true } }, reflect.TypeOf(float64(0)): func(dst interface{}, src lua.LValue) { switch src.Type() { case lua.LTNumber: *(dst.(*float64)) = float64(src.(lua.LNumber)) case lua.LTString: *(dst.(*float64)), _ = strconv.ParseFloat(string(src.(lua.LString)), 64) default: *(dst.(*float64)) = 0 } }, reflect.TypeOf(float32(0)): func(dst interface{}, src lua.LValue) { switch src.Type() { case lua.LTNumber: *(dst.(*float32)) = float32(src.(lua.LNumber)) case lua.LTString: v, _ := strconv.ParseFloat(string(src.(lua.LString)), 32) *(dst.(*float32)) = float32(v) default: *(dst.(*float32)) = 0 } }, reflect.TypeOf(int(0)): func(dst interface{}, src lua.LValue) { switch src.Type() { case lua.LTNumber: *(dst.(*int)) = int(src.(lua.LNumber)) case lua.LTString: v, _ := strconv.ParseInt(string(src.(lua.LString)), 0, 63) *(dst.(*int)) = int(v) default: *(dst.(*int)) = 0 } }, reflect.TypeOf(int8(0)): func(dst interface{}, src lua.LValue) { switch src.Type() { case lua.LTNumber: *(dst.(*int8)) = int8(src.(lua.LNumber)) case lua.LTString: v, _ := strconv.ParseInt(string(src.(lua.LString)), 0, 7) *(dst.(*int8)) = int8(v) default: *(dst.(*int8)) = 0 } }, reflect.TypeOf(int16(0)): func(dst interface{}, src lua.LValue) { switch src.Type() { case lua.LTNumber: *(dst.(*int16)) = int16(src.(lua.LNumber)) case lua.LTString: v, _ := strconv.ParseInt(string(src.(lua.LString)), 0, 15) *(dst.(*int16)) = int16(v) default: *(dst.(*int16)) = 0 } }, reflect.TypeOf(int32(0)): func(dst interface{}, src lua.LValue) { switch src.Type() { case lua.LTNumber: *(dst.(*int32)) = int32(src.(lua.LNumber)) case lua.LTString: v, _ := strconv.ParseInt(string(src.(lua.LString)), 0, 31) *(dst.(*int32)) = int32(v) default: *(dst.(*int32)) = 0 } }, reflect.TypeOf(int64(0)): func(dst interface{}, src lua.LValue) { switch src.Type() { case lua.LTNumber: *(dst.(*int64)) = int64(src.(lua.LNumber)) case lua.LTString: v, _ := strconv.ParseInt(string(src.(lua.LString)), 0, 63) *(dst.(*int64)) = int64(v) default: *(dst.(*int64)) = 0 } }, reflect.TypeOf(rune(0)): func(dst interface{}, src lua.LValue) { switch src.Type() { case lua.LTNumber: *(dst.(*rune)) = rune(src.(lua.LNumber)) case lua.LTString: if s := string(src.(lua.LString)); len(s) > 0 { *(dst.(*rune)), _ = utf8.DecodeRuneInString(s) } default: *(dst.(*rune)) = 0 } }, reflect.TypeOf(uint(0)): func(dst interface{}, src lua.LValue) { switch src.Type() { case lua.LTNumber: *(dst.(*uint)) = uint(src.(lua.LNumber)) case lua.LTString: v, _ := strconv.ParseUint(string(src.(lua.LString)), 0, 64) *(dst.(*uint)) = uint(v) default: *(dst.(*uint)) = 0 } }, reflect.TypeOf(byte(0)): func(dst interface{}, src lua.LValue) { switch src.Type() { case lua.LTNumber: *(dst.(*byte)) = byte(src.(lua.LNumber)) case lua.LTString: v, _ := strconv.ParseUint(string(src.(lua.LString)), 0, 8) *(dst.(*byte)) = byte(v) default: *(dst.(*byte)) = 0 } }, reflect.TypeOf(uint8(0)): func(dst interface{}, src lua.LValue) { switch src.Type() { case lua.LTNumber: *(dst.(*uint8)) = uint8(src.(lua.LNumber)) case lua.LTString: v, _ := strconv.ParseUint(string(src.(lua.LString)), 0, 8) *(dst.(*uint8)) = uint8(v) default: *(dst.(*uint8)) = 0 } }, reflect.TypeOf(uint16(0)): func(dst interface{}, src lua.LValue) { switch src.Type() { case lua.LTNumber: *(dst.(*uint16)) = uint16(src.(lua.LNumber)) case lua.LTString: v, _ := strconv.ParseUint(string(src.(lua.LString)), 0, 16) *(dst.(*uint16)) = uint16(v) default: *(dst.(*uint16)) = 0 } }, reflect.TypeOf(uint32(0)): func(dst interface{}, src lua.LValue) { switch src.Type() { case lua.LTNumber: *(dst.(*uint32)) = uint32(src.(lua.LNumber)) case lua.LTString: v, _ := strconv.ParseUint(string(src.(lua.LString)), 0, 32) *(dst.(*uint32)) = uint32(v) default: *(dst.(*uint32)) = 0 } }, reflect.TypeOf(uint64(0)): func(dst interface{}, src lua.LValue) { switch src.Type() { case lua.LTNumber: *(dst.(*uint64)) = uint64(src.(lua.LNumber)) case lua.LTString: v, _ := strconv.ParseUint(string(src.(lua.LString)), 0, 64) *(dst.(*uint64)) = uint64(v) default: *(dst.(*uint64)) = 0 } }, }
Functions ¶
Types ¶
type LuaPool ¶
type LuaPool struct {
// contains filtered or unexported fields
}
func NewLuaPool ¶
func NewLuaPool(opt ...lua.Options) *LuaPool
func (*LuaPool) ModuleFile ¶ added in v1.0.4
func (*LuaPool) ModuleString ¶ added in v1.0.4
Click to show internal directories.
Click to hide internal directories.