lua

package
v0.0.0-...-7540414 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddLuaPath

func AddLuaPath(p ...string)

func ArrayToLuaTable

func ArrayToLuaTable(l *lua.LState, dic []interface{}) *lua.LTable

func CheckGlobal

func CheckGlobal(proto *lua.FunctionProto) error

检查是否使用了全局变量 涉及到全局变量的指令有两条:GETGLOBAL(Opcode 5)和 SETGLOBAL(Opcode 7)

func CompileByString

func CompileByString(name string, content string) (*lua.FunctionProto, error)

func CompileByfile

func CompileByfile(filename string) (*lua.FunctionProto, error)

func GetRealTypeAndValue

func GetRealTypeAndValue(obj interface{}) (interface{}, reflect.Type)

func SetLuaPath

func SetLuaPath(p ...string)

func SetReadOnly

func SetReadOnly(l *lua.LState, table *lua.LTable) *lua.LUserData

设置表为只读

func StringArrayToLuaTable

func StringArrayToLuaTable(l *lua.LState, dic []string) *lua.LTable

func ToGoMap

func ToGoMap(lv lua.LValue) map[string]interface{}

func ToGoStringArray

func ToGoStringArray(lv lua.LValue) []string

func ToGoValue

func ToGoValue(lv lua.LValue, opt LuaOption) interface{}

func ToLuaTable

func ToLuaTable(l *lua.LState, dic map[string]string) *lua.LTable

func ToLuaTable2

func ToLuaTable2(l *lua.LState, dic map[string]interface{}) *lua.LTable

func ToLuaValue

func ToLuaValue(v interface{}) lua.LValue

func ToUpperCamelCase

func ToUpperCamelCase(s string) string

ToUpperCamelCase is an Option.NameFunc that converts strings from snake case to upper camel case.

Types

type LuaContext

type LuaContext map[string]interface{}

type LuaHandle

type LuaHandle func(*lua.LState)

type LuaLib

type LuaLib struct {
	ExportName      string
	ExportFunctions map[string]lua.LGFunction
}

type LuaLogFunction

type LuaLogFunction func(string)

type LuaOption

type LuaOption struct {
	// Function to convert a lua table key to Go's one. This defaults to "ToUpperCamelCase".
	NameFunc func(string) string

	// Returns error if unused keys exist.
	ErrorUnused bool

	// A struct tag name for lua table keys . This defaults to "gluamapper"
	TagName string
}

Option is a configuration that is used to create a new mapper.

func NewLuaDefaultOption

func NewLuaDefaultOption() LuaOption

func NewLuaOption

func NewLuaOption() LuaOption

type LuaPool

type LuaPool struct {
	// contains filtered or unexported fields
}

lua虚拟机池

func NewLuaPool

func NewLuaPool(max int, name string, lib map[string]lua.LGFunction) *LuaPool

构建池

func NewLuaPool2

func NewLuaPool2(max int, name string, lib ...*LuaLib) *LuaPool

func (*LuaPool) Get

func (this *LuaPool) Get() *lua.LState

func (*LuaPool) Init

func (this *LuaPool) Init(max int, name string, lib map[string]lua.LGFunction)

func (*LuaPool) InitByLibs

func (this *LuaPool) InitByLibs(max int, name string, lib ...*LuaLib)

func (*LuaPool) Put

func (this *LuaPool) Put(L *lua.LState) int

归还

func (*LuaPool) Shutdown

func (this *LuaPool) Shutdown()

type LuaScript

type LuaScript struct {
	Context LuaContext
	Log     LuaLogFunction
	// contains filtered or unexported fields
}

func (*LuaScript) Call

func (this *LuaScript) Call(before LuaHandle, after LuaHandle) (interface{}, error)

func (*LuaScript) CallByParame

func (this *LuaScript) CallByParame(funcname string, p ...interface{}) (interface{}, error)

func (*LuaScript) Load

func (this *LuaScript) Load(name, content string)

加载脚本

func (*LuaScript) Loadfile

func (this *LuaScript) Loadfile(filename string)

加载脚本文件

func (*LuaScript) SetPool

func (this *LuaScript) SetPool(p *LuaPool)

设置lua vm pool

Jump to

Keyboard shortcuts

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