Documentation ¶
Index ¶
- Constants
- func CookiesFrom(location string) (cookies rtypes.Cookies, err error)
- func DecodeCookies(r io.Reader) (cookies rtypes.Cookies, err error)
- func DoHTTPRequest(w *World, options rtypes.HTTPOptions) (resp *rtypes.HTTPResponse, err error)
- func EncodeCookies(w io.Writer, cookies rtypes.Cookies) (err error)
- type Client
- type Constructor
- type Constructors
- type Context
- func (c Context) Context() Context
- func (c Context) CreateTable(acap, hcap int) *lua.LTable
- func (c *Context) CycleClear()
- func (c *Context) CycleGuard() bool
- func (c Context) CycleMark(t interface{}) bool
- func (c Context) GetMetaField(obj lua.LValue, event string) lua.LValue
- func (c Context) GetTypeMetatable(typ string) lua.LValue
- func (c Context) NewUserData(value interface{}) *lua.LUserData
- func (c Context) ReflectorError()
- func (c Context) SetMetatable(obj, mt lua.LValue)
- type FileEntry
- type Format
- type FormatOptions
- type FrameType
- type Global
- type HTTPRequest
- type Library
- type Metamethod
- type Metatable
- type Method
- type Methods
- type Properties
- type Property
- type Puller
- type Pusher
- type Reflector
- type ReflectorFlags
- type Setter
- type State
- func (s State) ArgError(n int, msg string, v ...interface{}) int
- func (s State) CheckAny(n int) lua.LValue
- func (s State) CheckBool(n int) bool
- func (s State) CheckFunction(n int) *lua.LFunction
- func (s State) CheckInt(n int) int
- func (s State) CheckInt64(n int) int64
- func (s State) CheckNumber(n int) lua.LNumber
- func (s State) CheckString(n int) string
- func (s State) CheckTable(n int) *lua.LTable
- func (s State) CheckThread(n int) *lua.LState
- func (s State) CheckUserData(n int) *lua.LUserData
- func (s State) Count() int
- func (s State) OptBool(n int, d bool) bool
- func (s State) OptFunction(n int, d *lua.LFunction) *lua.LFunction
- func (s State) OptInt(n int, d int) int
- func (s State) OptInt64(n int, d int64) int64
- func (s State) OptNumber(n int, d lua.LNumber) lua.LNumber
- func (s State) OptString(n int, d string) string
- func (s State) OptTable(n int, d *lua.LTable) *lua.LTable
- func (s State) OptUserData(n int, d *lua.LUserData) *lua.LUserData
- func (s State) Pull(n int, t string) (v types.Value)
- func (s State) PullAnyFromArray(table *lua.LTable, index int, t ...string) (v types.Value)
- func (s State) PullAnyFromArrayOpt(table *lua.LTable, index int, d types.Value, t ...string) (v types.Value)
- func (s State) PullAnyFromDictionary(table *lua.LTable, key string, t ...string) (v types.Value)
- func (s State) PullAnyFromDictionaryOpt(table *lua.LTable, key string, d types.Value, t ...string) (v types.Value)
- func (s State) PullAnyFromTable(table *lua.LTable, field lua.LValue, t ...string) (v types.Value)
- func (s State) PullAnyFromTableOpt(table *lua.LTable, field lua.LValue, d types.Value, t ...string) (v types.Value)
- func (s State) PullAnyOf(n int, t ...string) (v types.Value)
- func (s State) PullAnyOfOpt(n int, d types.Value, t ...string) (v types.Value)
- func (s State) PullArrayOf(n int, t string) (v rtypes.Array)
- func (s State) PullDictionaryOf(n int, t string) (v rtypes.Dictionary)
- func (s State) PullEncoded(n int, fs rtypes.FormatSelector) (v types.Value)
- func (s State) PullEncodedFormat(n int, f Format) (v types.Value)
- func (s State) PullFromArray(table *lua.LTable, index int, t string) (v types.Value)
- func (s State) PullFromArrayOpt(table *lua.LTable, index int, d types.Value, t string) (v types.Value)
- func (s State) PullFromDictionary(table *lua.LTable, key string, t string) (v types.Value)
- func (s State) PullFromDictionaryOpt(table *lua.LTable, key string, d types.Value, t string) (v types.Value)
- func (s State) PullFromTable(table *lua.LTable, field lua.LValue, t string) (v types.Value)
- func (s State) PullFromTableOpt(table *lua.LTable, field lua.LValue, d types.Value, t string) (v types.Value)
- func (s State) PullOpt(n int, d types.Value, t string) (v types.Value)
- func (s State) PullTuple(n int) rtypes.Tuple
- func (s State) Push(v types.Value) int
- func (s State) PushArrayOf(v rtypes.Array, t string) int
- func (s State) PushDictionaryOf(v rtypes.Dictionary, t string) int
- func (s State) PushToArray(table *lua.LTable, index int, v types.Value)
- func (s State) PushToDictionary(table *lua.LTable, key string, v types.Value)
- func (s State) PushToTable(table *lua.LTable, field lua.LValue, v types.Value)
- func (s State) PushTuple(values ...types.Value) int
- func (s State) RaiseError(format string, args ...interface{}) int
- func (s State) ReflectorError(n int) int
- func (s State) TypeError(n int, want, got string) int
- func (s State) Typeof(n int) string
- type Symbols
- type TypeError
- type World
- func (w *World) Context() Context
- func (w *World) DoFile(fileName string, args int) error
- func (w *World) DoFileHandle(f fs.File, name string, args int) error
- func (w *World) DoString(s, name string, args int) (err error)
- func (w *World) Enum(name string) *rtypes.Enum
- func (w *World) Enums() *rtypes.Enums
- func (w *World) Expand(path string) string
- func (w *World) Ext(filename string) (ext string)
- func (w *World) Format(name string) Format
- func (w *World) Formats() []Format
- func (w *World) Libraries() []Library
- func (w *World) Library(name string) Library
- func (w *World) ListTypes(types []string) string
- func (w *World) LuaState() *lua.LState
- func (w *World) MergeTables(dst, src *lua.LTable, name string) error
- func (w *World) MustEnum(name string) *rtypes.Enum
- func (w *World) MustReflector(name string) Reflector
- func (w *World) Open(lib Library) error
- func (w *World) PeekFile() (entry FileEntry, ok bool)
- func (w *World) PopFile()
- func (w *World) Pull(lv lua.LValue, t string) (v types.Value, err error)
- func (w *World) PullAnyFromArray(table *lua.LTable, index int, t ...string) (v types.Value, err error)
- func (w *World) PullAnyFromArrayOpt(table *lua.LTable, index int, d types.Value, t ...string) (v types.Value, err error)
- func (w *World) PullAnyFromDictionary(table *lua.LTable, key string, t ...string) (v types.Value, err error)
- func (w *World) PullAnyFromDictionaryOpt(table *lua.LTable, key string, d types.Value, t ...string) (v types.Value, err error)
- func (w *World) PullAnyFromTable(table *lua.LTable, field lua.LValue, t ...string) (v types.Value, err error)
- func (w *World) PullAnyFromTableOpt(table *lua.LTable, field lua.LValue, d types.Value, t ...string) (v types.Value, err error)
- func (w *World) PullAnyOf(lv lua.LValue, t ...string) (v types.Value, err error)
- func (w *World) PullAnyOfOpt(lv lua.LValue, d types.Value, t ...string) (v types.Value)
- func (w *World) PullArrayOf(lv lua.LValue, t string) (v rtypes.Array, err error)
- func (w *World) PullDictionaryOf(lv lua.LValue, t string) (v rtypes.Dictionary, err error)
- func (w *World) PullEncoded(lv lua.LValue, fs rtypes.FormatSelector) (v types.Value, err error)
- func (w *World) PullEncodedFormat(lv lua.LValue, f Format) (v types.Value, err error)
- func (w *World) PullEncodedFromDict(table *lua.LTable, field string, format rtypes.FormatSelector) (v types.Value, err error)
- func (w *World) PullFromArray(table *lua.LTable, index int, t string) (v types.Value, err error)
- func (w *World) PullFromArrayOpt(table *lua.LTable, index int, d types.Value, t string) (v types.Value, err error)
- func (w *World) PullFromDictionary(table *lua.LTable, key string, t string) (v types.Value, err error)
- func (w *World) PullFromDictionaryOpt(table *lua.LTable, key string, d types.Value, t string) (v types.Value, err error)
- func (w *World) PullFromTable(table *lua.LTable, field lua.LValue, t string) (v types.Value, err error)
- func (w *World) PullFromTableOpt(table *lua.LTable, field lua.LValue, d types.Value, t string) (v types.Value, err error)
- func (w *World) PullOpt(lv lua.LValue, d types.Value, t string) (v types.Value, err error)
- func (w *World) PullerOf(name string) (p Puller, err error)
- func (w *World) Push(v types.Value) (lv lua.LValue, err error)
- func (w *World) PushArrayOf(v rtypes.Array, t string) (lv *lua.LTable, err error)
- func (w *World) PushDictionaryOf(v rtypes.Dictionary, t string) (lv *lua.LTable, err error)
- func (w *World) PushFile(entry FileEntry) error
- func (w *World) PushToArray(table *lua.LTable, index int, v types.Value) (err error)
- func (w *World) PushToDictionary(table *lua.LTable, key string, v types.Value) (err error)
- func (w *World) PushToTable(table *lua.LTable, field lua.LValue, v types.Value) (err error)
- func (w *World) PusherOf(name string) (p Pusher, err error)
- func (w *World) Reflector(name string) Reflector
- func (w *World) Reflectors(flags ReflectorFlags) []Reflector
- func (w *World) RegisterEnums(enums ...*rtypes.Enum)
- func (w *World) RegisterFormat(f Format)
- func (w *World) RegisterReflector(r Reflector)
- func (w *World) RootDir() string
- func (w *World) SetEnumGlobal()
- func (w *World) SetterOf(name string) (s Setter, err error)
- func (w *World) Split(path string, components ...string) ([]string, error)
- func (w *World) State() State
- func (w *World) TempDir() string
- func (w *World) Typeof(v lua.LValue) string
- func (w *World) UserDataCacheLen() int
- func (w *World) UserDataOf(v types.Value, t string) *lua.LUserData
- func (w *World) WrapFunc(f func(State) int) *lua.LFunction
- func (w *World) WrapMethod(f func(State) int) *lua.LFunction
- func (w *World) WrapOperator(f func(State) int) *lua.LFunction
Constants ¶
const UserAgent = "RobloxStudio/WinInet rbxmk/0.0"
UserAgent is the User-Agent header string sent with HTTP requests made by rbxmk. It includes components that ensure the client will operate with Roblox website APIs.
Variables ¶
This section is empty.
Functions ¶
func CookiesFrom ¶ added in v0.6.0
CookiesFrom retrieves cookies from a known location. location is case-insensitive. The following locations are implemented:
- studio: Returns the cookies used for authentication when logging into Roblox Studio.
func DecodeCookies ¶ added in v0.6.0
DecodeCookies parses cookies from r and returns a list of cookies. Cookies are parsed as a number of "Set-Cookie" HTTP headers. Returns an empty list if the reader is empty.
func DoHTTPRequest ¶ added in v0.6.0
func DoHTTPRequest(w *World, options rtypes.HTTPOptions) (resp *rtypes.HTTPResponse, err error)
DoHTTPRequest begins and resolves an HTTPRequest. Returns an error if the reponse did not return a successful status.
Types ¶
type Client ¶ added in v0.4.0
Client wraps an http.Client to handle various additional behavior.
type Constructor ¶ added in v0.3.0
type Constructor struct { Func func(s State) int // Dump returns a description of constructor's API. Each function describes // one possible signature of the constructor. Dump func() dump.MultiFunction }
Constructor creates a new value of a Reflector. The function can receive arguments from s.L, and must push a new value to s.L.
type Constructors ¶ added in v0.3.0
type Constructors map[string]Constructor
Constructors is a set of constructor functions keyed by name.
type Context ¶ added in v0.9.0
type Context struct { *World // contains filtered or unexported fields }
Context provides a context for reflecting values.
func (Context) CreateTable ¶ added in v0.9.0
CreateTable returns a new table according to the context's LState.
func (*Context) CycleClear ¶ added in v0.9.0
func (c *Context) CycleClear()
CycleClear clears the cycle guard on the state. Panics if the state has no guard.
func (*Context) CycleGuard ¶ added in v0.9.0
CycleGuard begins a guard against reference cycles when reflecting with the state. Returns false if a guard was already set up for the state. If true is returned, the guard must be cleared via CycleClear. For example:
if c.CycleGuard() { defer c.CycleClear() }
func (Context) CycleMark ¶ added in v0.9.0
CycleMark marks t as visited, and returns whether t was already visited. Panics if the state has no guard.
func (Context) GetMetaField ¶ added in v0.9.0
GetMetaField gets the value of the event field from the metatable of obj. Returns LNil if obj has no metatable, or the metatable has no such field.
func (Context) GetTypeMetatable ¶ added in v0.9.0
GetTypeMetatable returns the typ metatable registered with the context's LState.
func (Context) NewUserData ¶ added in v0.9.0
NewUserData returns a new userdata according to the context's LState.
func (Context) ReflectorError ¶ added in v0.9.0
func (c Context) ReflectorError()
ReflectorError panics, indicating that a reflector pushed or pulled an unexpected type. Under normal circumstances, this should be unreachable.
func (Context) SetMetatable ¶ added in v0.9.0
SetMetatable sets the metatable of obj to mt according to the context's LState.
type FileEntry ¶ added in v0.6.0
FileEntry describes a file, including the full path. An empty Path indicates stdin.
type Format ¶
type Format struct { // Name is the name that identifies the format. The name matches a file // extension. Name string // EncodeTypes is an optional list of types that Encode can receive. These // are called with State.PullAnyOf to reflect the value to a type known by // the encoder. If empty, then the value is pulled as Variant. EncodeTypes []string // MediaTypes is a list of media types that are associated with the format, // to be used by sources as needed. MediaTypes []string // Options maps a field name to a number of value types. A FormatOptions // received by Encode or Decode will have only these fields. The value of a // field, if it exists, will be one of the specified type. Options map[string][]string // CanDecode returns whether the format decodes into the given type. CanDecode func(g Global, opt FormatOptions, typeName string) bool // Encode receives a value of one of a number of types and encodes it as a // sequence of bytes written to w. Encode func(g Global, opt FormatOptions, w io.Writer, v types.Value) error // Decode receives a sequence of bytes read from r, and decodes it into a // value of a single type. Decode func(g Global, opt FormatOptions, r io.Reader) (types.Value, error) // Dump returns a description of the format. Dump func() dump.Format }
Format defines a format for encoding between a sequence of bytes and a types.Value. The format can be registered with a World.
type FormatOptions ¶ added in v0.3.0
type FormatOptions interface { // ValueOf returns the value of field. Returns nil if the value does not // exist. ValueOf(field string) types.Value }
FormatOptions contains options to be passed to a Format.
type FrameType ¶ added in v0.6.0
type FrameType uint8
FrameType indicates the kind of frame for a State.
type Global ¶ added in v0.6.0
type Global struct { Desc *rtypes.RootDesc AttrConfig *rtypes.AttrConfig }
Global contains values that available across an entire World.
type HTTPRequest ¶ added in v0.6.0
type HTTPRequest struct {
// contains filtered or unexported fields
}
HTTPRequest performs and HTTP request with a promise-like API.
func BeginHTTPRequest ¶ added in v0.6.0
func BeginHTTPRequest(w *World, options rtypes.HTTPOptions) (request *HTTPRequest, err error)
BeginHTTPRequest begins an HTTP request according to the given options, in the context of the given world.
The request starts immediately, and can either be resolved or canceled.
func (*HTTPRequest) Cancel ¶ added in v0.6.0
func (r *HTTPRequest) Cancel()
Cancel cancels the request.
func (*HTTPRequest) Resolve ¶ added in v0.6.0
func (r *HTTPRequest) Resolve() (*rtypes.HTTPResponse, error)
Resolve blocks until the request resolves.
func (*HTTPRequest) Type ¶ added in v0.6.0
func (*HTTPRequest) Type() string
Type returns a string identifying the type of the value.
type Library ¶ added in v0.3.0
type Library struct { // Name is a name that identifies the library. Name string // ImportedAs is the name that the library is imported as. Empty indicates // that the contents of the library are merged into the global environment. ImportedAs string // Open returns a table with the contents of the library. Open func(s State) *lua.LTable // Dump returns a description of the library's API. Dump func(s State) dump.Library // Types returns a list of type reflector expected by the library. Before // opening the library, each reflector is registered. Types []func() Reflector }
Library represents a Lua library.
type Metamethod ¶ added in v0.3.0
Metamethod is called when a metamethod is invoked.
type Metatable ¶ added in v0.3.0
type Metatable map[string]Metamethod
Metatable defines the metamethods of a custom type.
type Method ¶ added in v0.6.0
type Method struct { // Func is the body of the method. The first argument will be the same value // as v. Func func(s State, v types.Value) int // Dump returns a description of the member's API. Dump func() dump.Function }
Method defines a member of a custom type.
type Properties ¶ added in v0.7.0
Properties is a set of properties keyed by name.
type Property ¶ added in v0.7.0
type Property struct { // Get gets the value of a member from v and pushes it onto s. The index is // the 2nd argument in s. Get func(s State, v types.Value) int // Set gets a value from s and sets it to a member of v. The index and value // are the 2nd and 3rd arguments in s. Set is optional, if nil, the property // will be treated as read-only. Set func(s State, v types.Value) // Dump returns a description of the member's API. Dump func() dump.Property }
Property defines a property of a custom type.
type Puller ¶ added in v0.9.0
Puller converts a Lua value to a types.Value. lv must be non-nil.
func PullTypeFrom ¶ added in v0.3.0
PullTypeFrom returns a Puller that converts v from a userdata set with a type metatable registered as type t.
type Pusher ¶ added in v0.9.0
Pusher converts a types.Value to a Lua value. If err is nil, then lv must not be nil.
func PushPtrTypeTo ¶ added in v0.6.0
PushPtrTypeTo returns a Pusher that converts v to a userdata set with a type metatable registered as type t. The same value will push the same userdata, making the value usable as a table key.
func PushTypeTo ¶ added in v0.3.0
PushTypeTo returns a Pusher that converts v to a userdata set with a type metatable registered as type t. Each push always produces a new userdata. This results in better performance, but makes the value unsuitable as a table key.
type Reflector ¶ added in v0.3.0
type Reflector struct { // Name is the name of the type. Name string Flags ReflectorFlags // PushTo converts v to a Lua value. l must be used only for the conversion // of values as needed. If err is nil, then lv must not be nil. PushTo Pusher // PullFrom converts a Lua value to v. l must be used only for the // conversion of values as needed. lv must be non-nil. PullFrom Puller // SetTo sets reflector type v to the value pointed to by p. p must be a // pointer to a value that v can be set to. Returns an error if p is not a // known type. SetTo Setter // Metatable defines the metamethods of a custom type. If Metatable is // non-nil, then a metatable is constructed and registered as a type // metatable under Name. Metatable Metatable // Properties defines the properties of a custom type. If the __index and // __newindex metamethods are not defined by Metatable, then Properties // defines them according to the given properties. In case of name // conflicts, methods are prioritized over properties. Properties Properties // Symbols defines the symbols of a custom type. If the __index and // __newindex metamethods are not defined by Metatable, then Symbols defines // them according to the given properties. Symbols Symbols // Methods defines the methods of a custom type. If the __index and // __newindex metamethods are not defined by Metatable, then Methods defines // them according to the given members. In case of name conflicts, methods // are prioritized over properties. Methods Methods // Constructors defines functions that construct the type. If non-nil, a // table containing each constructor is created and set as a global // referenced by Name. Constructors Constructors // Environment is called after the type is registered to provide additional // setup. Environment func(s State) // ConvertFrom receives an arbitrary value and attempts to convert it to the // reflector's type. Returns nil if the value could not be converted. ConvertFrom func(v types.Value) types.Value // Enums lists Enum values that related to the type. These are registered // along with the reflector. Enums []*rtypes.Enum // Types is a list of additional type reflectors that this reflector depends // on. Types []func() Reflector // Dump returns an additional description of the API of the reflector's // type. Member and constructor APIs should be described by their respective // fields. Dump func() dump.TypeDef }
Reflector defines reflection behavior for a type. It defines how to convert a types.Value between a Lua value, and behaviors when the type is a userdata. It also defines functions for constructing values of the type. A Reflector can be registered with a World.
type ReflectorFlags ¶ added in v0.3.0
type ReflectorFlags uint8
const (
Exprim ReflectorFlags // Whether the type is an explicit primitive.
)
type Setter ¶ added in v0.9.0
Setter sets known type v to p. p must be a pointer to a known type. Returns an error if v cannot be set to p.
type State ¶ added in v0.3.0
type State struct { *World L *lua.LState // FrameType provides a hint to how errors should be produced. FrameType FrameType }
State facilitates the reflection of values to a particular Lua state.
func (State) ArgError ¶ added in v0.6.0
ArgError raises an argument error depending on the state's frame type.
func (State) CheckAny ¶ added in v0.6.0
CheckAny returns the nth argument, which can be any type as long as the argument exists.
func (State) CheckFunction ¶ added in v0.6.0
CheckFunction returns the nth argument, expecting a function.
func (State) CheckInt ¶ added in v0.6.0
CheckInt returns the nth argument as an int, expecting a number.
func (State) CheckInt64 ¶ added in v0.6.0
CheckInt64 returns the nth argument as an int64, expecting a number.
func (State) CheckNumber ¶ added in v0.6.0
CheckNumber returns the nth argument, expecting a number.
func (State) CheckString ¶ added in v0.3.0
CheckString returns the nth argument, expecting a string. Unlike LState.CheckString, it does not try to convert non-string values into a string.
func (State) CheckTable ¶ added in v0.6.0
CheckTable returns the nth argument, expecting a table.
func (State) CheckThread ¶ added in v0.6.0
CheckThread returns the nth argument, expecting a thread.
func (State) CheckUserData ¶ added in v0.6.0
CheckUserData returns the nth argument, expecting a userdata.
func (State) OptBool ¶ added in v0.6.0
OptBool returns the nth argument as a bool, or d if the argument is nil.
func (State) OptFunction ¶ added in v0.6.0
OptFunction returns the nth argument as a function, or d if the argument is nil.
func (State) OptInt ¶ added in v0.6.0
OptInt returns the nth argument as an int, or d if the argument is nil.
func (State) OptInt64 ¶ added in v0.6.0
OptInt64 returns the nth argument as an int64, or d if the argument is nil.
func (State) OptNumber ¶ added in v0.6.0
OptNumber returns the nth argument as a number, or d if the argument is nil.
func (State) OptString ¶ added in v0.6.0
OptString returns the nth argument as a string, or d if the argument is nil.
func (State) OptTable ¶ added in v0.6.0
OptTable returns the nth argument as a table, or d if the argument is nil.
func (State) OptUserData ¶ added in v0.6.0
OptUserData returns the nth argument as a userdata, or d if the argument is nil.
func (State) Pull ¶ added in v0.3.0
Pull gets from s.L the values starting from n, and reflects a value from them according to type t registered with s.World.
func (State) PullAnyFromArray ¶ added in v0.9.0
PullAnyFromArray is like PullAnyFromTable, but receives an int as the index of the table.
func (State) PullAnyFromArrayOpt ¶ added in v0.9.0
func (s State) PullAnyFromArrayOpt(table *lua.LTable, index int, d types.Value, t ...string) (v types.Value)
PullAnyFromArrayOpt is like PullAnyFromTableOpt, but receives an int as the index of the table.
func (State) PullAnyFromDictionary ¶ added in v0.9.0
PullAnyFromDictionary is like PullAnyFromTable, but receives a string as the key of the table.
func (State) PullAnyFromDictionaryOpt ¶ added in v0.9.0
func (s State) PullAnyFromDictionaryOpt(table *lua.LTable, key string, d types.Value, t ...string) (v types.Value)
PullAnyFromDictionaryOpt is like PullAnyFromTableOpt, but receives a string as the key of the table.
func (State) PullAnyFromTable ¶ added in v0.9.0
PullAnyFromTable gets a value from table[field], and reflects a value from it according to the first successful type from t registered with s.World.
func (State) PullAnyFromTableOpt ¶ added in v0.9.0
func (s State) PullAnyFromTableOpt(table *lua.LTable, field lua.LValue, d types.Value, t ...string) (v types.Value)
PullAnyFromTableOpt gets a value from table[field], and reflects a value from it according to the first successful type from t registered with s.World. If the field is nil, then d is returned instead.
func (State) PullAnyOf ¶ added in v0.3.0
PullAnyOf gets from s.L the values starting from n, and reflects a value from them according to any of the types in t registered with s.World. Returns the first successful reflection among the types in t. If no types succeeded, then a type error is thrown.
func (State) PullAnyOfOpt ¶ added in v0.7.0
PullAnyOfOpt gets from s.L the values starting from n, and reflects a value from them according to any of the types in t registered with s.World. Returns the first successful reflection among the types in t. If no types succeeded, then nil is returned.
func (State) PullArrayOf ¶ added in v0.5.0
PullArrayOf pulls an rtypes.Array from n, ensuring that each element is reflected according to t.
func (State) PullDictionaryOf ¶ added in v0.5.0
func (s State) PullDictionaryOf(n int, t string) (v rtypes.Dictionary)
PullDictionaryOf pulls an rtypes.Dictionary from n, ensuring that each field is reflected according to t.
func (State) PullEncoded ¶ added in v0.9.0
PullEncoded pulls a value to be encoded according to a FormatSelector. The referred format is determined, then Format.EncodeTypes is used to pull the value from n. If fs.Format is empty, or if EncodeTypes is empty, then the value is pulled as a Variant.
func (State) PullEncodedFormat ¶ added in v0.9.0
PullEncodedFormat pulls a value to be encoded according to a Format. Format.EncodeTypes is used to pull the value from n. If EncodeTypes is empty, then the value is pulled as a Variant.
func (State) PullFromArray ¶ added in v0.9.0
PullFromArray is like PullFromTable, but receives an int as the index of the table.
func (State) PullFromArrayOpt ¶ added in v0.9.0
func (s State) PullFromArrayOpt(table *lua.LTable, index int, d types.Value, t string) (v types.Value)
PullFromArrayOpt is like PullFromTableOpt, but receives an int as the index of the table.
func (State) PullFromDictionary ¶ added in v0.9.0
PullFromDictionary is like PullFromTable, but receives a string as the key of the table.
func (State) PullFromDictionaryOpt ¶ added in v0.9.0
func (s State) PullFromDictionaryOpt(table *lua.LTable, key string, d types.Value, t string) (v types.Value)
PullFromDictionaryOpt is like PullFromTableOpt, but receives a string as the key of the table.
func (State) PullFromTable ¶ added in v0.4.0
PullFromTable gets a value from table[field], and reflects a value from it to type t registered with s.World.
func (State) PullFromTableOpt ¶ added in v0.4.0
func (s State) PullFromTableOpt(table *lua.LTable, field lua.LValue, d types.Value, t string) (v types.Value)
PullFromTableOpt gets a value from table[field], and reflects a value from it to type t registered with s.World. If the value is nil, d is returned instead.
func (State) PullOpt ¶ added in v0.3.0
PullOpt gets from s.L the value at n, and reflects a value from it according to type t registered with s.World. If the value is nil, d is returned instead.
func (State) Push ¶ added in v0.3.0
Push reflects v according to its type as registered with s.World, then pushes the results to s.L.
func (State) PushArrayOf ¶ added in v0.5.0
PushArrayOf pushes an rtypes.Array, ensuring that each element is reflected according to t.
func (State) PushDictionaryOf ¶ added in v0.5.0
func (s State) PushDictionaryOf(v rtypes.Dictionary, t string) int
PushDictionaryOf pushes an rtypes.Dictionary, ensuring that each field is reflected according to t.
func (State) PushToArray ¶ added in v0.9.0
PushToArray is like PushToTable, but receives an int as the index of the table.
func (State) PushToDictionary ¶ added in v0.9.0
PushToDictionary is like PushToTable, but receives a string as the key of the table.
func (State) PushToTable ¶ added in v0.4.0
PushToTable reflects v according to its type as registered with s.World, then sets the result to table[field]. The type must be single-value. Does nothing if v is nil.
func (State) RaiseError ¶ added in v0.3.0
RaiseError is a shortcut for LState.RaiseError that returns 0.
func (State) ReflectorError ¶ added in v0.6.0
ReflectorError raises an error indicating that a reflector pushed or pulled an unexpected type. Under normal circumstances, this error should be unreachable.
type TypeError ¶ added in v0.3.0
typeError is an error where a type was received where another was expected.
type World ¶ added in v0.3.0
World contains the entire state of a Lua environment, including a Lua state, and registered Reflectors, Formats, and Sources.
func (*World) DoFile ¶ added in v0.3.0
DoFile executes the contents of the file at fileName as Lua. args is the number of arguments currently on the stack that should be passed in. The file is marked as actively running, and is unmarked when the file returns.
func (*World) DoFileHandle ¶ added in v0.3.0
DoFile executes the contents of file f as Lua. args is the number of arguments currently on the stack that should be passed in. The file is marked as actively running, and is unmarked when the file returns.
func (*World) DoString ¶ added in v0.3.0
DoString executes string s as Lua. args is the number of arguments currently on the stack that should be passed in.
func (*World) Enum ¶ added in v0.9.0
Enum returns the Enum registered with the given name. If the name is not registered, then nil is returned.
func (*World) Ext ¶ added in v0.3.0
Ext returns the extension of filename that most closely matches the name of a registered format. Returns an empty string if no format was found.
func (*World) Format ¶ added in v0.3.0
Format returns the Format registered with the given name. If the name is not registered, then Format.Name will be an empty string.
func (*World) Library ¶ added in v0.9.0
Library returns the Library registered with the given name. If the name is not registered, then Library.Name will be an empty string.
func (*World) MergeTables ¶ added in v0.3.0
MargeTables merges src into dst according to name. If name is empty, then each key in src is set in dst. If dst[name] is a table, then each key in src is set in that table. If dst[name] is nil, then it is set directly to src. Does nothing if src or dst is nil. Returns an error if the tables could not be merged.
func (*World) MustEnum ¶ added in v0.9.0
MustEnum returns the Enum registered with the given name. If the name is not registered, then MustEnum panics.
func (*World) MustReflector ¶ added in v0.6.0
MustReflector returns the Reflector registered with the given name. If the name is not registered, then MustReflector panics.
func (*World) Open ¶ added in v0.3.0
Open opens lib, then merges the result into the world's global table using the ImportedAs field as the name. If the name is already present and is a table, then the table of lib is merged into it, preferring the values of lib. If the name is an empty string, then lib is merged into the global table itself.
The library is registered with the world under the Name of the library. An error is returned if the merged value is not a table, or if the name was already registered.
func (*World) PeekFile ¶ added in v0.3.0
PeekFile returns the info of the currently running file. Returns false if there is no running file.
func (*World) PopFile ¶ added in v0.3.0
func (w *World) PopFile()
PopFile unmarks the currently running file. If the last file on the stack is popped, the file's directory is removed as a root from w.FS.
func (*World) PullAnyFromArray ¶ added in v0.9.0
func (w *World) PullAnyFromArray(table *lua.LTable, index int, t ...string) (v types.Value, err error)
PullAnyFromArray is like PullAnyFromTable, but receives an int as the index of the table.
func (*World) PullAnyFromArrayOpt ¶ added in v0.9.0
func (w *World) PullAnyFromArrayOpt(table *lua.LTable, index int, d types.Value, t ...string) (v types.Value, err error)
PullAnyFromArrayOpt is like PullAnyFromTableOpt, but receives an int as the index of the table.
func (*World) PullAnyFromDictionary ¶ added in v0.9.0
func (w *World) PullAnyFromDictionary(table *lua.LTable, key string, t ...string) (v types.Value, err error)
PullAnyFromDictionary is like PullAnyFromTable, but receives a string as the key of the table.
func (*World) PullAnyFromDictionaryOpt ¶ added in v0.9.0
func (w *World) PullAnyFromDictionaryOpt(table *lua.LTable, key string, d types.Value, t ...string) (v types.Value, err error)
PullAnyFromDictionaryOpt is like PullAnyFromTableOpt, but receives a string as the key of the table.
func (*World) PullAnyFromTable ¶ added in v0.9.0
func (w *World) PullAnyFromTable(table *lua.LTable, field lua.LValue, t ...string) (v types.Value, err error)
PullAnyFromTable gets a value from table[field], and reflects a value from it according to the first successful type from t registered with s.World.
func (*World) PullAnyFromTableOpt ¶ added in v0.9.0
func (w *World) PullAnyFromTableOpt(table *lua.LTable, field lua.LValue, d types.Value, t ...string) (v types.Value, err error)
PullAnyFromTableOpt gets a value from table[field], and reflects a value from it according to the first successful type from t registered with s.World. If the field is nil, then d is returned instead.
func (*World) PullAnyOf ¶ added in v0.3.0
PullAnyOf reflects lv to the first successful type from t. Returns an error if none of the types were successful.
func (*World) PullAnyOfOpt ¶ added in v0.9.0
PullAnyOfOpt reflects lv to the first successful type from t. Returns d if none of the types were successful.
func (*World) PullArrayOf ¶ added in v0.9.0
PullArrayOf reflects lv to v, ensuring that lv is a table, and that each element is reflected according to t.
func (*World) PullDictionaryOf ¶ added in v0.9.0
PullDictionaryOf reflects lv to v, ensuring that lv is a table, and that each string field is reflected according to t.
func (*World) PullEncoded ¶ added in v0.9.0
PullEncoded pulls a value to be encoded according to a FormatSelector. The referred format is acquired, then Format.EncodeTypes is used to reflect the value from lv. If fs.Format is empty, or if EncodeTypes is empty, then the value is pulled as a Variant.
func (*World) PullEncodedFormat ¶ added in v0.9.0
PullEncodedFormat pulls a value to be encoded according to f. Format.EncodeTypes is used to reflect the value from lv. If EncodeTypes is empty, then the value is pulled as a Variant.
func (*World) PullEncodedFromDict ¶ added in v0.9.0
func (w *World) PullEncodedFromDict(table *lua.LTable, field string, format rtypes.FormatSelector) (v types.Value, err error)
PullEncodedFromDict is like PullEncoded, but the value is pulled from a Dictionary.
func (*World) PullFromArray ¶ added in v0.9.0
PullFromArray is like PullFromTable, but receives an int as the index of the table.
func (*World) PullFromArrayOpt ¶ added in v0.9.0
func (w *World) PullFromArrayOpt(table *lua.LTable, index int, d types.Value, t string) (v types.Value, err error)
PullFromArrayOpt is like PullFromTableOpt, but receives an int as the index of the table.
func (*World) PullFromDictionary ¶ added in v0.9.0
func (w *World) PullFromDictionary(table *lua.LTable, key string, t string) (v types.Value, err error)
PullFromDictionary is like PullFromTable, but receives a string as the key of the table.
func (*World) PullFromDictionaryOpt ¶ added in v0.9.0
func (w *World) PullFromDictionaryOpt(table *lua.LTable, key string, d types.Value, t string) (v types.Value, err error)
PullFromDictionaryOpt is like PullFromTableOpt, but receives a string as the key of the table.
func (*World) PullFromTable ¶ added in v0.9.0
func (w *World) PullFromTable(table *lua.LTable, field lua.LValue, t string) (v types.Value, err error)
PullFromTable gets a value from table[field], and reflects a value from it to type t registered with s.World.
func (*World) PullFromTableOpt ¶ added in v0.9.0
func (w *World) PullFromTableOpt(table *lua.LTable, field lua.LValue, d types.Value, t string) (v types.Value, err error)
PullFromTableOpt gets a value from table[field], and reflects a value from it to type t registered with s.World. If the value is nil, d is returned instead.
func (*World) PullOpt ¶ added in v0.3.0
PullOpt reflects lv to v using registered type t. If lv is nil, then d is returned instead.
func (*World) PullerOf ¶ added in v0.9.0
PullerOf returns the PullFrom field for the Reflector registered as name. Returns an error if the name is not registered, or if the reflector does not define PullFrom.
func (*World) PushArrayOf ¶ added in v0.9.0
PushArrayOf reflect v to lv, ensuring that each element is reflected according to t.
func (*World) PushDictionaryOf ¶ added in v0.9.0
PushDictionaryOf reflect v to lv, ensuring that each field is reflected according to t.
func (*World) PushFile ¶ added in v0.3.0
PushFile marks a file as the currently running file. Returns an error if the file is already running. If the file is the first file pushed, its directory is added as a root to w.FS.
func (*World) PushToArray ¶ added in v0.9.0
PushToArray is like PushToTable, but receives an int as the index of the table.
func (*World) PushToDictionary ¶ added in v0.9.0
PushToDictionary is like PushToTable, but receives a string as the key of the table.
func (*World) PushToTable ¶ added in v0.9.0
PushToTable reflects v according to its type as registered with s.World, then sets the result to table[field]. The type must be single-value. Does nothing if v is nil.
func (*World) PusherOf ¶ added in v0.9.0
PusherOf returns the PushTo field for the Reflector registered as name. Returns an error if the name is not registered, or if the reflector does not define PushTo.
func (*World) Reflector ¶ added in v0.3.0
Reflector returns the Reflector registered with the given name. If the name is not registered, then Reflector.Name will be an empty string.
func (*World) Reflectors ¶ added in v0.3.0
func (w *World) Reflectors(flags ReflectorFlags) []Reflector
Reflectors returns a list of reflectors that have all of the given flags set.
func (*World) RegisterEnums ¶ added in v0.9.0
RegisterEnums registers a number of Enum values. Panics if multiple different enums are registered with the same name.
func (*World) RegisterFormat ¶ added in v0.3.0
RegisterFormat registers a format. Panics if the format is already registered.
func (*World) RegisterReflector ¶ added in v0.3.0
RegisterReflector registers a reflector. If the reflector produces a metatable, then it is added as a type metatable to the world's state. Panics if the reflector is already registered.
func (*World) RootDir ¶ added in v0.5.0
RootDir returns the directory of the first file pushed onto the running file stack. Returns an empty string if there are no files on the stack, or the absolute path of the file could not be determined.
func (*World) SetEnumGlobal ¶ added in v0.9.0
func (w *World) SetEnumGlobal()
SetEnumGlobal sets the "Enum" global to the generated enum types from w.Global.Desc. Does nothing if Desc is nil, the Enums type is not registered, or if the Enums reflector returns an error.
func (*World) SetterOf ¶ added in v0.9.0
SetterOf returns the SetTo field for the Reflector registered as name. Returns an error if the name is not registered, or if the reflector does not define SetTo.
func (*World) TempDir ¶ added in v0.5.0
TempDir returns a directory used for temporary files, which is unique per world. Returns an empty string if a temporary directory could not be found.
func (*World) Typeof ¶ added in v0.6.0
Typeof returns the type of the given Lua value. If it is a userdata, Typeof attempts to get the type according to the value's metatable. Panics if v is nil (not if nil Lua value).
func (*World) UserDataCacheLen ¶ added in v0.3.0
UserDataCacheLen return the number of userdata values in the cache.
func (*World) UserDataOf ¶ added in v0.3.0
UserDataOf returns the userdata value associated with v. If there is no such userdata, then a new one is created, with the metatable set to the type corresponding to t.
v must be comparable.
func (*World) WrapFunc ¶ added in v0.3.0
WrapFunc wraps a function that receives a State into a Lua function.
func (*World) WrapMethod ¶ added in v0.6.0
WrapMethod is like WrapFunc, but marks the state as being a method.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Tool to increment the version number, read and write rbxmk/version.go, then create and tag a commit.
|
Tool to increment the version number, read and write rbxmk/version.go, then create and tag a commit. |
The dump package describes Lua APIs.
|
The dump package describes Lua APIs. |
dt
The dt package describes the types of Lua API items.
|
The dt package describes the types of Lua API items. |
The fragments package contains translations of documentation fragments.
|
The fragments package contains translations of documentation fragments. |
htmldrill
The htmldrill package implements a drill/filesys.Handler for the HTML format.
|
The htmldrill package implements a drill/filesys.Handler for the HTML format. |
term
The term package implements rendering HTML content for the terminal.
|
The term package implements rendering HTML content for the terminal. |
The sfs package providing a secure file system, with access limitations.
|
The sfs package providing a secure file system, with access limitations. |