yockr

package
v0.0.0-...-9853328 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LuaDoFunc

func LuaDoFunc(lvm *lua.LState, fun *lua.LFunction) error

func New

func New(opts ...YockrOption) yocki.YockRuntime

New initialize yock runtime and returns the its pointer

func UpgradeInterpPool

func UpgradeInterpPool(yockr yocki.YockRuntime) yocki.YockRuntime

func UpgradeTable

func UpgradeTable(tbl *lua.LTable) yocki.Table

Types

type Table

type Table struct {
	*lua.LTable
}

func NewTable

func NewTable() *Table

func (*Table) Bind

func (t *Table) Bind(v any) error

func (*Table) Clone

func (tbl *Table) Clone(l *lua.LState) yocki.Table

func (*Table) GetBool

func (t *Table) GetBool(key string) (bool, bool)

func (*Table) GetFloat

func (t *Table) GetFloat(key string) (float64, bool)

func (*Table) GetInt

func (t *Table) GetInt(key string) (int, bool)

func (*Table) GetLTable

func (t *Table) GetLTable(key string) (*lua.LTable, bool)

func (*Table) GetString

func (t *Table) GetString(key string) (string, bool)

func (*Table) GetTable

func (t *Table) GetTable(key string) (yocki.Table, bool)

func (*Table) MustGetTable

func (t *Table) MustGetTable(key string) yocki.Table

func (*Table) SetBool

func (t *Table) SetBool(k string, v bool)

func (*Table) SetDo

func (t *Table) SetDo(k string, v func(yocki.YockState) lua.LValue, env ...yocki.YockState)

func (*Table) SetField

func (t *Table) SetField(l *lua.LState, k string, v any)

func (*Table) SetFields

func (t *Table) SetFields(l *lua.LState, v map[string]any)

func (*Table) SetInt

func (t *Table) SetInt(k string, v int)

func (*Table) SetLTable

func (t *Table) SetLTable(k string, v *lua.LTable)

func (*Table) SetNil

func (t *Table) SetNil(k string)

func (*Table) SetString

func (t *Table) SetString(k, v string)

func (*Table) SetTable

func (t *Table) SetTable(k string, v yocki.Table)

func (*Table) ToFloat32

func (t *Table) ToFloat32(n int) float32

func (*Table) ToFloat32ByString

func (t *Table) ToFloat32ByString(k string) float32

func (*Table) ToFloat64

func (t *Table) ToFloat64(n int) float64

func (*Table) ToFloat64ByString

func (t *Table) ToFloat64ByString(k string) float64

func (*Table) ToFunction

func (t *Table) ToFunction(n int) *lua.LFunction

func (*Table) ToFunctionByString

func (t *Table) ToFunctionByString(k string) *lua.LFunction

func (*Table) ToInt

func (t *Table) ToInt(n int) int

func (*Table) ToIntByString

func (t *Table) ToIntByString(k string) int

func (*Table) ToString

func (t *Table) ToString(n int) string

func (*Table) ToTable

func (t *Table) ToTable(n int) yocki.Table

func (*Table) Value

func (tbl *Table) Value() *lua.LTable

type YockInterp

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

YockInterp abstracts lua interpreter

func (*YockInterp) Call

func (yockr *YockInterp) Call(fun string) ([]lua.LValue, error)

Call to call specify function without arguments

func (*YockInterp) Eval

func (yockr *YockInterp) Eval(script string) error

Eval to execute string of script

func (*YockInterp) EvalFile

func (yockr *YockInterp) EvalFile(fullpath string) error

EvalFile to execute file of script

func (*YockInterp) EvalFunc

func (yockr *YockInterp) EvalFunc(fn lua.LValue, args []lua.LValue) ([]lua.LValue, error)

EvalFunc to execute function

func (*YockInterp) FastCall

func (yockr *YockInterp) FastCall(fun string) error

FastCall to call specify function without arguments and not return value

func (*YockInterp) FastEvalFunc

func (yockr *YockInterp) FastEvalFunc(fn lua.LValue, args []lua.LValue) error

FastEvalFunc to execute function and not return value

func (*YockInterp) GetGlobalVar

func (yockr *YockInterp) GetGlobalVar(name string) lua.LValue

GetGlobalVar returns global variable

func (*YockInterp) NewState

func (yockr *YockInterp) NewState() (yocki.YockState, context.CancelFunc)

func (*YockInterp) SafeSetGlobalFn

func (yockr *YockInterp) SafeSetGlobalFn(loaders map[string]lua.LGFunction)

SafeSetGlobalFn to set global function when it isn't exist

func (*YockInterp) SafeSetGlobalVar

func (yockr *YockInterp) SafeSetGlobalVar(name string, v lua.LValue)

SafeSetGlobalVar to set global variable when variable isn't exist

func (*YockInterp) SetGlobalFn

func (yockr *YockInterp) SetGlobalFn(loaders map[string]lua.LGFunction)

SetGlobalFn to set global function

func (*YockInterp) SetGlobalVar

func (yockr *YockInterp) SetGlobalVar(name string, v lua.LValue)

SetGlobalVar to set global variable

func (*YockInterp) SetState

func (yockr *YockInterp) SetState(l yocki.YockState)

func (*YockInterp) State

func (yockr *YockInterp) State() yocki.YockState

State returns LState

type YockInterpPool

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

func (*YockInterpPool) Call

func (yockr *YockInterpPool) Call(name string) ([]lua.LValue, error)

Call to call specify function without arguments

func (*YockInterpPool) Eval

func (yockr *YockInterpPool) Eval(string) error

func (*YockInterpPool) EvalFile

func (yockr *YockInterpPool) EvalFile(string) error

EvalFile to execute file of script

func (*YockInterpPool) EvalFunc

func (yockr *YockInterpPool) EvalFunc(lua.LValue, []lua.LValue) ([]lua.LValue, error)

EvalFunc to execute function

func (*YockInterpPool) FastCall

func (yockr *YockInterpPool) FastCall(string) error

FastCall to call specify function without arguments and not return value

func (*YockInterpPool) FastEvalFunc

func (yockr *YockInterpPool) FastEvalFunc(lua.LValue, []lua.LValue) error

FastEvalFunc to execute function and not return value

func (*YockInterpPool) Get

func (yockr *YockInterpPool) Get() yocki.YockRuntime

func (*YockInterpPool) GetGlobalVar

func (yockr *YockInterpPool) GetGlobalVar(string) lua.LValue

GetGlobalVar returns global variable

func (*YockInterpPool) New

func (yockr *YockInterpPool) New() yocki.YockRuntime

func (*YockInterpPool) NewState

func (yockr *YockInterpPool) NewState() (yocki.YockState, context.CancelFunc)

func (*YockInterpPool) Put

func (yockr *YockInterpPool) Put(interp yocki.YockRuntime) error

func (*YockInterpPool) SafeSetGlobalFn

func (yockr *YockInterpPool) SafeSetGlobalFn(map[string]lua.LGFunction)

SafeSetGlobalFn to set global function when it isn't exist

func (*YockInterpPool) SafeSetGlobalVar

func (yockr *YockInterpPool) SafeSetGlobalVar(string, lua.LValue)

SafeSetGlobalVar to set global variable when variable isn't exist

func (*YockInterpPool) SetGlobalFn

func (yockr *YockInterpPool) SetGlobalFn(map[string]lua.LGFunction)

SetGlobalFn to set global function

func (*YockInterpPool) SetGlobalVar

func (yockr *YockInterpPool) SetGlobalVar(string, lua.LValue)

SetGlobalVar to set global variable

func (*YockInterpPool) SetState

func (yockr *YockInterpPool) SetState(l yocki.YockState)

func (*YockInterpPool) State

func (yockr *YockInterpPool) State() yocki.YockState

RegisterModule to register modules RegisterModule(map[string]lua.LGFunction) UnregisterModule to unregister specify module UnregisterModule(string) LoadModule to immediately load module to be specified LoadModule(string, lua.LGFunction) State returns LState

type YockLib

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

func CreateYockLib

func CreateYockLib(state yocki.YockState, name string, tbl ...*Table) *YockLib

CreateYockLib returns new library whether it exist or not.

func OpenYockLib

func OpenYockLib(state yocki.YockState, name string) *YockLib

OpenYockLib returns existed library based on name and creates new library when lib isn't exist.

func (*YockLib) Meta

func (lib *YockLib) Meta() yocki.Table

func (*YockLib) Name

func (lib *YockLib) Name() string

func (*YockLib) SetClosure

func (lib *YockLib) SetClosure(v map[string]lua.LGFunction)

func (*YockLib) SetField

func (lib *YockLib) SetField(v map[string]any)

func (*YockLib) SetFunction

func (lib *YockLib) SetFunction(name string, fn lua.LGFunction)

func (*YockLib) SetFunctions

func (lib *YockLib) SetFunctions(v map[string]lua.LGFunction)

func (*YockLib) SetState

func (lib *YockLib) SetState(s yocki.YockState)

func (*YockLib) SetTable

func (lib *YockLib) SetTable(t yocki.Table)

func (*YockLib) SetYFunction

func (lib *YockLib) SetYFunction(v map[string]yocki.YGFunction)

func (*YockLib) State

func (lib *YockLib) State() yocki.YockState

func (*YockLib) Value

func (lib *YockLib) Value() lua.LValue

type YockState

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

func NewYState

func NewYState() *YockState

func UpgradeLState

func UpgradeLState(s *lua.LState) *YockState

func (*YockState) Argc

func (s *YockState) Argc() int

func (*YockState) Call

func (s *YockState) Call(info yocki.YockFuncInfo, args ...any) error

func (*YockState) CheckAny

func (s *YockState) CheckAny(n int) any

func (*YockState) CheckBool

func (s *YockState) CheckBool(n int) bool

func (*YockState) CheckFunction

func (s *YockState) CheckFunction(n int) *lua.LFunction

func (*YockState) CheckInt

func (s *YockState) CheckInt(n int) int

func (*YockState) CheckLTable

func (s *YockState) CheckLTable(n int) *lua.LTable

func (*YockState) CheckLValue

func (s *YockState) CheckLValue(n int) lua.LValue

func (*YockState) CheckNumber

func (s *YockState) CheckNumber(n int) lua.LNumber

func (*YockState) CheckRune

func (s *YockState) CheckRune(n int) rune

func (*YockState) CheckString

func (s *YockState) CheckString(n int) string

func (*YockState) CheckTable

func (s *YockState) CheckTable(n int) yocki.Table

func (*YockState) Clone

func (s *YockState) Clone() yocki.YockState

func (*YockState) Exit

func (s *YockState) Exit() int

Exit returns amount of return value

func (*YockState) IsBool

func (s *YockState) IsBool(n int) bool

func (*YockState) IsChannel

func (s *YockState) IsChannel(n int) bool

func (*YockState) IsFunction

func (s *YockState) IsFunction(n int) bool

func (*YockState) IsNil

func (s *YockState) IsNil(n int) bool

func (*YockState) IsNumber

func (s *YockState) IsNumber(n int) bool

func (*YockState) IsString

func (s *YockState) IsString(n int) bool

func (*YockState) IsTable

func (s *YockState) IsTable(n int) bool

func (*YockState) IsThread

func (s *YockState) IsThread(n int) bool

func (*YockState) IsUserData

func (s *YockState) IsUserData(n int) bool

func (*YockState) LState

func (s *YockState) LState() *lua.LState

func (*YockState) NewLFunction

func (s *YockState) NewLFunction(f lua.LGFunction) *lua.LFunction

func (*YockState) NewYFunction

func (s *YockState) NewYFunction(f yocki.YGFunction) *lua.LFunction

func (*YockState) PCall

func (s *YockState) PCall() error

func (*YockState) PopAll

func (s *YockState) PopAll()

func (*YockState) Push

func (s *YockState) Push(v lua.LValue) yocki.YockState

func (*YockState) PushAll

func (s *YockState) PushAll(vals ...any) yocki.YockState

func (*YockState) PushBool

func (s *YockState) PushBool(b bool) yocki.YockState

func (*YockState) PushError

func (s *YockState) PushError(err error) yocki.YockState

PushError returns the appropriate value depending on whether the error exists or not. Exists, returns error's text information, otherwise returns null.

@return string|nil

func (*YockState) PushInt

func (s *YockState) PushInt(i int) yocki.YockState

func (*YockState) PushNil

func (s *YockState) PushNil() yocki.YockState

func (*YockState) PushNilTable

func (s *YockState) PushNilTable() yocki.YockState

func (*YockState) PushString

func (s *YockState) PushString(str string) yocki.YockState

func (*YockState) Pusha

func (s *YockState) Pusha(val any) yocki.YockState

func (*YockState) Stack

func (s *YockState) Stack(i int) (dbg *lua.Debug, ok bool)

func (*YockState) Stacktrace

func (s *YockState) Stacktrace() string

stacktrace returns the stack info of function, in form of file:line

func (*YockState) Throw

func (s *YockState) Throw(err error) yocki.YockState

type YockrOption

type YockrOption func(yockr yocki.YockRuntime) error

func OptionEnableInterpPool

func OptionEnableInterpPool() YockrOption

func OptionLState

func OptionLState(opt lua.Options) YockrOption

Jump to

Keyboard shortcuts

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