- Description
The Lua State class
To be documented..
-
Inherit State
Public.Lang.___Lua.State
-
Method create
void Public.Lang.Lua.State()->create(void|string|multiset libs)
- Description
Creates a new lua state.
- Parameter libs
Defines what lua libraries to load. Default is to load all libraries, except debug.
Available libraries: base, trable, io, string, math, debug.
-
Method pop
void Public.Lang.Lua.State()->pop(void|int n)
- Description
pop top value from stack
-
Method `[]
mixed Public.Lang.Lua.State()->`[](mixed arg)
- Description
Get lua object from globals
-
Method `->
mixed Public.Lang.Lua.State()->`->(string s)
- Description
Tries to get lua object from globals if s isn't defined in the State class.
-
Method `()
int Public.Lang.Lua.State()->`()(string s)
- Description
Runs the string s as lua code, or loads the file if it is a filename
-
Method getglobal
void Public.Lang.Lua.State()->getglobal(string s)
- Description
Get global value
-
Method setglobal
void Public.Lang.Lua.State()->setglobal(string s)
- Description
Set global value
-
Method register
void Public.Lang.Lua.State()->register(string name, function fun, void|int table)
- Description
Registers the pike function fun with lua, as name in the table at stack
index table, or the global scope (LUA_GLOBALSINDEX) if omited.
-
Method open_base
int Public.Lang.Lua.State()->open_base()
- Description
Open base libarary.
-
Method open_table
int Public.Lang.Lua.State()->open_table()
- Description
Open table library.
-
Method open_io
int Public.Lang.Lua.State()->open_io()
- Description
Open io library.
-
Method open_string
int Public.Lang.Lua.State()->open_string()
- Description
Open string library.
-
Method open_math
int Public.Lang.Lua.State()->open_math()
- Description
Open math library.
-
Method open_debug
int Public.Lang.Lua.State()->open_debug()
- Description
Open debug library.
-
Method gettop
int Public.Lang.Lua.State()->gettop()
- Description
Because indices start at 1, the result of gettop is equal to the number of elements in the stack (and so 0 means an empty stack).
-
Method settop
void Public.Lang.Lua.State()->settop(int index)
- Description
Accepts any acceptable index, or 0, and sets the stack top to that index. If the new top is larger than the old one,
then the new elements are filled with nil. If index is 0, then all stack elements are removed.
-
Method pushvalue
void Public.Lang.Lua.State()->pushvalue(int index)
- Description
Pushes onto the stack a copy of the element at the given index.
-
Method remove
void Public.Lang.Lua.State()->remove(int index)
- Description
Removes the element at the given position, shifting down the elements above that position to fill the gap.
-
Method insert
void Public.Lang.Lua.State()->insert(int index)
- Description
Moves the top element into the given position, shifting up the elements above that position to open space.
-
Method replace
void Public.Lang.Lua.State()->replace(int index)
- Description
Moves the top element into the given position, without shifting any element (therefore replacing the value at the given position).
-
Method checkstack
int Public.Lang.Lua.State()->checkstack(int size)
- Description
Grows the stack size to top + extra elements; it returns false if it cannot grow the stack to that size.
This function never shrinks the stack; if the stack is already larger than the new size, it is left unchanged.
NOTE: When you interact with Lua API, you are responsible for controlling stack overflow.
Whenever Lua calls C, it ensures that at least LUA_MINSTACK stack positions are available.
LUA_MINSTACK is defined in lua.h as 20, so that usually you do not have to worry about stack space unless your code
has loops pushing elements onto the stack.
Most query functions accept as indices any value inside the available stack space, that is, indices up to the maximum
stack size you have set through lua_checkstack. Such indices are called acceptable indices. More formally, we define
an acceptable index as follows:
(index < 0 && abs(index) <= top) || (index > 0 && index <= stackspace)
Note that 0 is never an acceptable index.
Unless otherwise noted, any function that accepts valid indices can also be called with pseudo-indices, which represent some Lua values that are accessible to the C code but are not in the stack. Pseudo-indices are used to access the global environment, the registry, and the upvalues of a C function (see 3.17).
-
Method isnumber
int Public.Lang.Lua.State()->isnumber(int index)
- Description
Return 1 if the object is compatible with the given type, and 0 otherwise.
-
Method isstring
int Public.Lang.Lua.State()->isstring(int index)
- Description
Return 1 if the object is compatible with the given type, and 0 otherwise.
-
Method iscfunction
int Public.Lang.Lua.State()->iscfunction(int index)
- Description
Return 1 if the object is compatible with the given type, and 0 otherwise.
-
Method isuserdata
int Public.Lang.Lua.State()->isuserdata(int index)
- Description
Return 1 if the object is compatible with the given type, and 0 otherwise.
-
Method type
int Public.Lang.Lua.State()->type(int index)
- Description
Returns the type of a value in the stack, or LUA_TNONE for a non-valid index (that is, if that stack position is "empty").
-
Method typename
string Public.Lang.Lua.State()->typename(int type)
- Description
Translates a lua type to a string.
-
Method equal
int Public.Lang.Lua.State()->equal(int index1, int index2)
-
Method rawequal
int Public.Lang.Lua.State()->rawequal(int index1, int index2)
-
Method lessthan
int Public.Lang.Lua.State()->lessthan(int index1, int index2)
-
Method tonumber
float Public.Lang.Lua.State()->tonumber(int index)
- Description
FIXME: make sure lua_Number and pike float's are the same size (lua_Number defaults to double).
configure pike with: --with-double-precision to make pike float's double.
-
Method toboolean
int Public.Lang.Lua.State()->toboolean(int index)
-
Method tostring
string Public.Lang.Lua.State()->tostring(int index)
-
Method strlen
int Public.Lang.Lua.State()->strlen(int index)
-
Method pushnil
void Public.Lang.Lua.State()->pushnil()
-
Method pushnumber
void Public.Lang.Lua.State()->pushnumber(float n) void Public.Lang.Lua.State()->pushnumber(int n)
-
Method pushlstring
void Public.Lang.Lua.State()->pushlstring(string s, int length)
-
Method pushstring
void Public.Lang.Lua.State()->pushstring(string s)
-
Method pushboolean
void Public.Lang.Lua.State()->pushboolean(int(0..1) bool)
-
Method gettable
void Public.Lang.Lua.State()->gettable(int index)
-
Method rawget
void Public.Lang.Lua.State()->rawget(int index)
-
Method rawgeti
void Public.Lang.Lua.State()->rawgeti(int index, int n)
-
Method newtable
void Public.Lang.Lua.State()->newtable()
-
Method getmetatable
int Public.Lang.Lua.State()->getmetatable(int index)
-
Method getfenv
void Public.Lang.Lua.State()->getfenv(int index)
-
Method settable
void Public.Lang.Lua.State()->settable(int index)
-
Method rawset
void Public.Lang.Lua.State()->rawset(int index)
-
Method rawseti
void Public.Lang.Lua.State()->rawseti(int index, int n)
-
Method setmetatable
void Public.Lang.Lua.State()->setmetatable(int index)
-
Method setfenc
void Public.Lang.Lua.State()->setfenc(int index)
-
Method call
void Public.Lang.Lua.State()->call(int nargs, int nresults)
-
Method pcall
int Public.Lang.Lua.State()->pcall(int nargs, int nresults, int errfunc)
-
Method yield
int Public.Lang.Lua.State()->yield(int nresults)
-
Method resume
int Public.Lang.Lua.State()->resume(int nargs)
-
Method getgcthreshold
int Public.Lang.Lua.State()->getgcthreshold()
-
Method getgccount
int Public.Lang.Lua.State()->getgccount()
-
Method setgcthreshold
void Public.Lang.Lua.State()->setgcthreshold(int new_threshold)
-
Method version
string Public.Lang.Lua.State()->version()
-
Method error
int Public.Lang.Lua.State()->error()
-
Method next
int Public.Lang.Lua.State()->next(int index)
-
Method concat
void Public.Lang.Lua.State()->concat(int n)
-
Method loadfile
int Public.Lang.Lua.State()->loadfile(string filename)
-
Method loadbuffer
int Public.Lang.Lua.State()->loadbuffer(string buff, int size, string name)
-
Method dofile
int Public.Lang.Lua.State()->dofile(string filename)
-
Method dostring
int Public.Lang.Lua.State()->dostring(string s)
-
Method dobuffer
int Public.Lang.Lua.State()->dobuffer(string buff, int size, string name)
|