Documentation
¶
Index ¶
Constants ¶
View Source
const LuaTag = "lua"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Mapper ¶
type Mapper struct {
Option Option
}
Mapper maps a lua table to a Go struct pointer.
func NewMapper ¶
func NewMapper(state *lua.LState) *Mapper
NewMapper returns a new mapper bound to a lua state.
type Option ¶
type Option struct { // NameFunc to convert a lua table key to Go's one. This defaults to "ToUpperCamelCase". NameFunc func(string) string // ErrorUnused returns error if unused keys exist. ErrorUnused bool // TagName struct tag name for lua table keys. TagName string // DecodeHook for MapStructure. DecodeHook any // FnHook to convert lua function to some go value. FnHook func(value lua.LValue) any }
Option is a configuration that is used to create a new mapper.
type OwnedCallback ¶
OwnedCallback represents a callback that will execute inside a lua vm.
func BindToLua ¶
func BindToLua(state *lua.LState, value lua.LValue) OwnedCallback
BindToLua will create a OwnedCallback from a lua function and state.
func (OwnedCallback) Call ¶
func (cb OwnedCallback) Call(args ...any) (any, error)
Call executes the callback with the given arguments. If the callback is nil it will return nil, nil. If the callback returns an error it will be returned as the error of this function.
func (OwnedCallback) MarshalJSON ¶
func (cb OwnedCallback) MarshalJSON() ([]byte, error)
func (OwnedCallback) Present ¶
func (cb OwnedCallback) Present() bool
Present returns true if the callback is not nil.
Click to show internal directories.
Click to hide internal directories.