|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.luaj.vm.Lua
org.luaj.vm.LuaState
public class LuaState
LuaStatetypedef struct LuaState;
Opaque structure that keeps the whole state of a Lua interpreter. The Lua library is fully reentrant: it has no global variables. All information about a state is kept in this structure.
Here we list all functions and types from the C API in alphabetical order. Each function has an indicator like this: [-o, +p, x]
The first field, o, is how many elements the function pops
from the stack. The second field, p, is how many elements the
function pushes onto the stack. (Any function always pushes its results after
popping its arguments.) A field in the form x|y means the
function may push (or pop) x or y elements,
depending on the situation; an interrogation mark '?' means
that we cannot know how many elements the function pops/pushes by looking
only at its arguments (e.g., they may depend on what is on the stack). The
third field, x, tells whether the function may throw errors: '-'
means the function never throws any error; 'm' means the
function may throw an error only due to not enough memory; 'e'
means the function may throw other kinds of errors; 'v'
means the function may throw an error on purpose.
| Field Summary | |
|---|---|
LTable |
_G
|
int |
base
|
CallInfo[] |
calls
|
int |
cc
|
static int |
LUA_ERRERR
|
static int |
LUA_ERRMEM
|
static int |
LUA_ERRRUN
|
static int |
LUA_ERRSYNTAX
|
static int |
LUA_MASKCALL
|
static int |
LUA_MASKLINE
|
static int |
LUA_MASKRET
|
static int |
LUA_YIELD
|
protected int |
nresults
|
protected LFunction |
panic
|
LValue[] |
stack
|
int |
top
|
protected java.util.Stack |
upvals
|
| Constructor Summary | |
|---|---|
protected |
LuaState()
Creates a new, independent LuaState instance. |
| Method Summary | |
|---|---|
void |
argcheck(boolean cond,
int narg,
java.lang.String extramsg)
Conditionally report an error with an argument. |
void |
argerror(int narg,
java.lang.String extramsg)
Report an error with an argument. |
void |
call(int nargs,
int nreturns)
Calls a function. |
LValue |
call(LFunction function)
Call a function with no arguments and one return value. |
LValue |
call(LFunction function,
LValue arg0)
Call a function with one argument and one return value This may change values in the current stack frame. |
LValue |
checkany(int narg)
Checks whether the function has an argument of any type (including nil) at position narg. |
double |
checkdouble(int narg)
Checks whether the function argument narg is a number and
returns this number cast to a double. |
LFunction |
checkfunction(int narg)
Checks whether the function argument narg is a function and
returns this function. |
int |
checkint(int narg)
Checks whether the function argument narg is a number and
returns this number cast to an int. |
LInteger |
checkinteger(int narg)
Checks whether the function argument narg is a number and
returns this number cast to a LInteger. |
long |
checklong(int narg)
Checks whether the function argument narg is a number and
returns this number cast to a long. |
LString |
checklstring(int narg)
Checks whether the function argument narg is a string and
returns this string as a lua string. |
LNumber |
checknumber(int narg)
Checks whether the function argument narg is a number and
returns this number. |
void |
checkstack(int extra)
Ensures that there are at least extra free stack slots in
the stack. |
java.lang.String |
checkstring(int narg)
Checks whether the function argument narg is a string and
returns this string as a Java String. |
LTable |
checktable(int narg)
Checks whether the function argument narg is a table and
returns this table. |
LThread |
checkthread(int narg)
Checks whether the function argument narg is a thread and
returns this thread. |
LValue |
checktype(int narg,
int t)
Checks whether the function argument narg has type
t and return it as an LValue. |
java.lang.Object |
checkudata(int ud,
java.lang.Class expected)
Check that the type of userdata on the stack matches the required type, and if so, return the Java Object the userdata value points to. |
void |
closeUpVals(int limit)
|
protected void |
debugAssert(boolean b)
|
protected void |
debugHooks(int pc)
|
void |
doCall(LClosure c,
LValue[] args)
Put the closure on the stack with arguments, then perform the call. |
void |
error(java.lang.String message)
Raises an error with the default level. |
void |
error(java.lang.String message,
int level)
Raises an error. |
void |
exec()
execute instructions up to a yield, return, or call |
void |
execute()
Execute bytecodes until the current call completes or the vm yields. |
UpVal |
findUpVal(int target)
|
void |
getfield(int index,
LString k)
Dereference a tables field. |
protected java.lang.String |
getFileLine(int level)
Get the file line number info for a particular call frame. |
void |
getglobal(java.lang.String s)
Look up a global value. |
LFunction |
gethook()
Get the current hook function, if any. |
int |
gethookcount()
Get the current hook count. |
int |
gethookmask()
Get the current hook mask. |
boolean |
getmetatable(int index)
Get a value's metatable. |
java.lang.String |
getSourceFileName(LString s)
|
protected java.lang.String |
getSourceFileName(java.lang.String s)
|
CallInfo |
getStackFrame(int callStackDepth)
|
int |
gettop()
Returns the index of the top element in the stack. |
void |
init()
Performs the initialization. |
void |
insert(int index)
Insert the top item somewhere in the stack. |
void |
installStandardLibs()
Install the standard set of libraries used by most implementations: BaseLib, CoroutineLib, MathLib, PackageLib, TableLib, StringLib |
void |
invokeJavaFunction(LFunction javaFunction)
Invoke a LFunction being called via prepStackCall() |
boolean |
isboolean(int index)
Test if a value is boolean. |
boolean |
isfunction(int index)
Test if a value is a function. |
boolean |
isnil(int index)
Test if a value is nil [-0, +0, -] |
boolean |
isnoneornil(int index)
Test if a value is nil or not valid [-0, +0, -] |
boolean |
isnumber(int index)
Test if a value is a number [-0, +0, -] |
boolean |
isstring(int index)
Test if a value is a string [-0, +0, m] |
boolean |
istable(int index)
Test if a value is a table [-0, +0, -] |
boolean |
isthread(int index)
Test if a value is a thread [-0, +0, -] |
boolean |
isuserdata(int index)
Test if a value is a userdata [-0, +0, -] |
int |
load(java.io.InputStream is,
java.lang.String chunkname)
Loads a Lua chunk. |
LValue |
luaV_call_index(LFunction function,
LValue table,
LValue key)
Call an index function with two arguments and one return value Values in the current stack frame will be preserved. |
LValue |
luaV_call_newindex(LFunction function,
LValue table,
LValue key,
LValue value)
Call a newindex function with three arguments and one return value Values in the current stack frame will be preserved. |
static LValue |
luaV_getmetafield(LValue t,
LString tag)
|
LValue |
luaV_gettable(LValue table,
LValue key)
Get a key from a table using full metatable processing |
void |
luaV_settable(LValue table,
LValue key,
LValue val)
Get a key from a table using full metatable processing |
int |
optint(int narg,
int d)
If the function argument narg is a number, returns this
number cast to an int. |
LInteger |
optinteger(int narg,
int d)
If the function argument narg is a number, returns this
number cast to a lua_Integer. |
long |
optlong(int narg,
long d)
If the function argument narg is a number, returns this
number cast to a long. |
LString |
optlstring(int narg,
LString d)
If the function argument narg is a string, returns this
string. |
LNumber |
optnumber(int narg,
LNumber d)
If the function argument narg is a number, returns this
number. |
java.lang.String |
optstring(int narg,
java.lang.String d)
If the function argument narg is a string, returns this
string. |
int |
pcall(int nargs,
int nreturns,
int errfunc)
Calls a function in protected mode. |
void |
pop(int n)
Pops n elements from the stack. |
LValue |
poplvalue()
|
void |
prepStackCall()
Create a call frame for a call that has been set up on the stack. |
void |
pushboolean(boolean b)
Pushes a boolean value with value b onto the stack. |
void |
pushboolean(java.lang.Boolean b)
Push a Java Boolean value, or nil if the value is null. |
void |
pushfunction(LFunction f)
Pushes a function onto the stack. |
void |
pushinteger(java.lang.Byte b)
Push a Java Byte value, or nil if the value is null. |
void |
pushinteger(java.lang.Character c)
Push a Java Character value, or nil if the value is null. |
void |
pushinteger(int n)
Pushes a number with value n onto the stack. |
void |
pushinteger(java.lang.Integer i)
Push a Java Integer value, or nil if the value is null. |
void |
pushinteger(java.lang.Short s)
Push a Java Short value, or nil if the value is null. |
void |
pushlstring(byte[] byteArray)
Push string bytes onto the stack as a string. |
void |
pushlstring(byte[] bytes,
int offset,
int length)
Push string bytes onto the stack as a string. |
void |
pushlstring(LString s)
Push an LString onto the stack. |
void |
pushlvalue(LValue value)
Push an LValue onto the stack. |
void |
pushnil()
Pushes a nil value onto the stack. |
void |
pushnumber(double d)
Pushes a number with value d onto the stack. |
void |
pushnumber(java.lang.Double d)
Push a Java Double as a double, or nil if the value is null. |
void |
pushnumber(java.lang.Float f)
Push a Java Float value, or nil if the value is null. |
void |
pushnumber(java.lang.Long l)
Push a Java Long value, or nil if the value is null. |
void |
pushstring(java.lang.String s)
Push a String onto the stack. |
void |
pushuserdata(java.lang.Object o)
Push a Java Object as userdata, or nil if the value is null. |
void |
pushvalue(int index)
Push a value from the stack onto the stack. |
void |
rawgeti(int index,
int n)
Deprecated. should get the table and do a raw get instead |
void |
remove(int index)
Remove an element from the stack. |
void |
replace(int index)
Replace an element on the stack. |
void |
resettop()
Set the top to the base. |
void |
setfield(int index,
LString k)
Set the value of a table field. |
void |
setglobal(java.lang.String name)
Set the value of a global variable. |
void |
sethook(LFunction func,
int mask,
int count)
Set the hook function. |
void |
settop(int nt)
Set the top of the stack. |
void |
shutdown()
Perform any shutdown/clean up tasks if needed |
boolean |
toboolean(int index)
Get a value as a boolean. |
java.lang.Boolean |
toboxedboolean(int index)
Convert a value to a Java Boolean value, or null if the value is nil. |
java.lang.Byte |
toboxedbyte(int index)
Convert a value to a Java Byte value, or null if the value is not a number. |
java.lang.Double |
toboxeddouble(int index)
Convert a value to a Java Double value, or null if the value is not a number. |
java.lang.Float |
toboxedfloat(int index)
Convert a value to a Java Float value, or null if the value is not a number. |
java.lang.Integer |
toboxedinteger(int index)
Convert a value to a Java Integer value, or null if the value is not a number. |
java.lang.Long |
toboxedlong(int index)
Convert a value to a Java Long value, or null if the value is nil. |
LValue |
tofunction(int index)
Get a value as a LFunction. |
int |
tointeger(int index)
Get a value as an int. |
LValue |
tolnumber(int index)
Convert a value to an LNumber[-0, +0, -] |
LString |
tolstring(int index)
Gets the value of a string as byte array. |
double |
tonumber(int index)
Convert a value to a double. |
LValue |
topointer(int index)
Get the raw Object at a stack location. |
java.lang.String |
tostring(int index)
Get a stack value as a String. |
LTable |
totable(int index)
Get a value from the stack as a lua table. |
java.lang.Object |
touserdata(int index)
Get the Object from a userdata value. |
int |
type(int index)
Get the type of a value. |
java.lang.String |
typename(int index)
Get the type name for a value. |
void |
typerror(int narg,
int typenum)
Report a type error. |
void |
typerror(int narg,
java.lang.String typename)
Report a type error. |
static void |
vmerror(java.lang.String description)
Method to indicate a vm internal error has occurred. |
void |
xmove(LuaState to,
int n)
Exchange values between threads. |
| Methods inherited from class org.luaj.vm.Lua |
|---|
GET_OPCODE, GETARG_A, GETARG_B, GETARG_Bx, GETARG_C, GETARG_sBx, getBMode, getCMode, getOpMode, INDEXK, ISK, RKASK, testAMode, testTMode |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int LUA_YIELD
public static final int LUA_ERRRUN
public static final int LUA_ERRSYNTAX
public static final int LUA_ERRMEM
public static final int LUA_ERRERR
public static final int LUA_MASKCALL
public static final int LUA_MASKRET
public static final int LUA_MASKLINE
public int base
public int top
protected int nresults
public LValue[] stack
public int cc
public CallInfo[] calls
protected java.util.Stack upvals
protected LFunction panic
public LTable _G
| Constructor Detail |
|---|
protected LuaState()
Returns NULL if cannot create the state (due to lack of
memory). The argument f is the allocator function; Lua
does all memory allocation for this state through this function. The
second argument, ud, is an opaque pointer that Lua simply
passes to the allocator in every call.
| Method Detail |
|---|
protected void debugHooks(int pc)
protected void debugAssert(boolean b)
public void init()
public void shutdown()
public void installStandardLibs()
public void prepStackCall()
public void execute()
public void doCall(LClosure c,
LValue[] args)
c - values - public void invokeJavaFunction(LFunction javaFunction)
javaFunction -
public void call(int nargs,
int nreturns)
To call a function you must use the following protocol: first, the
function to be called is pushed onto the stack; then, the arguments to
the function are pushed in direct order; that is, the first argument is
pushed first. Finally you call lua_call;
nargs is the number of arguments that you pushed onto the
stack. All arguments and the function value are popped from the stack
when the function is called. The function results are pushed onto the
stack when the function returns. The number of results is adjusted to
nresults, unless nresults is LUA_MULTRET. In this case,
all results from the function are pushed. Lua takes care that
the returned values fit into the stack space. The function results are
pushed onto the stack in direct order (the first result is pushed first),
so that after the call the last result is on the top of the stack.
Any error inside the called function is propagated upwards (with a
longjmp).
The following example shows how the host program may do the equivalent to this Lua code:
a = f("how", t.x, 14)
Here it is in C:
lua_getfield(L, LUA_GLOBALSINDEX, "f"); // function to be called lua_pushstring(L, "how"); // 1st argument lua_getfield(L, LUA_GLOBALSINDEX, "t"); // table to be indexed lua_getfield(L, -1, "x"); // push result of t.x (2nd arg) lua_remove(L, -2); // remove 't' from the stack lua_pushinteger(L, 14); // 3rd argument lua_call(L, 3, 1); // call 'f' with 3 arguments and 1 result lua_setfield(L, LUA_GLOBALSINDEX, "a"); // set global 'a'
Note that the code above is "balanced": at its end, the stack is back to its original configuration. This is considered good programming practice.
public int pcall(int nargs,
int nreturns,
int errfunc)
Both nargs and nresults have the same
meaning as in lua_call. If there
are no errors during the call, lua_pcall
behaves exactly like lua_call.
However, if there is any error, lua_pcall
catches it, pushes a single value on the stack (the error message), and
returns an error code. Like lua_call,
lua_pcall always removes the
function and its arguments from the stack.
If errfunc is 0, then the error message returned on the
stack is exactly the original error message. Otherwise,
errfunc is the stack index of an
error handler function. (In the current implementation, this
index cannot be a pseudo-index.) In case of runtime errors, this function
will be called with the error message and its return value will be the
message returned on the stack by lua_pcall.
Typically, the error handler function is used to add more debug
information to the error message, such as a stack traceback. Such
information cannot be gathered after the return of lua_pcall,
since by then the stack has unwound.
The lua_pcall function returns
0 in case of success or one of the following error codes (defined in
lua.h):
LUA_ERRRUN: a
runtime error. LUA_ERRMEM:
memory allocation error. For such errors, Lua does not call the error
handler function. LUA_ERRERR:
error while running the error handler function.
public int load(java.io.InputStream is,
java.lang.String chunkname)
If there are no errors, lua_load
pushes the compiled chunk as a Lua function on top of the stack.
Otherwise, it pushes an error message. The return values of lua_load are:
LUA_ERRSYNTAX:
syntax error during pre-compilation;LUA_ERRMEM:
memory allocation error.This function only loads a chunk; it does not run it.
lua_load automatically detects
whether the chunk is text or binary, and loads it accordingly (see
program luac).
The lua_load function uses a
user-supplied reader function to read the chunk (see lua_Reader). The
data argument is an opaque value passed to the reader
function.
The chunkname argument gives a name to the chunk, which is
used for error messages and in debug information (see §3.8).
public void exec()
public UpVal findUpVal(int target)
public void closeUpVals(int limit)
public CallInfo getStackFrame(int callStackDepth)
public static LValue luaV_getmetafield(LValue t,
LString tag)
public LValue luaV_gettable(LValue table,
LValue key)
public void luaV_settable(LValue table,
LValue key,
LValue val)
public java.lang.String getSourceFileName(LString s)
protected java.lang.String getSourceFileName(java.lang.String s)
protected java.lang.String getFileLine(int level)
cindex - index into call stack, or -1 to get first lua location
public void error(java.lang.String message,
int level)
public void error(java.lang.String message)
public void checkstack(int extra)
extra free stack slots in
the stack. [-0, +0, -]
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.
public void getfield(int index,
LString k)
Pushes onto the stack the value t[k], where
t is the value at the given valid index. As in Lua, this
function may trigger a metamethod for the "index" event (see §2.8).
public void getglobal(java.lang.String s)
Pushes onto the stack the value of the global name. It is
defined as a macro:
#define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, s)
public boolean getmetatable(int index)
Pushes onto the stack the metatable of the value at the given acceptable index. If the index is not valid, or if the value does not have a metatable, the function returns false and pushes nothing on the stack.
public void insert(int index)
Moves the top element into the given valid index, shifting up the elements above this index to open space. Cannot be called with a pseudo-index, because a pseudo-index is not an actual stack position.
public boolean isboolean(int index)
Returns 1 if the value at the given acceptable index has type boolean, and 0 otherwise.
public boolean isfunction(int index)
Returns true if the value at the given acceptable index is a function (either C or Lua), and false otherwise.
public boolean isnil(int index)
Returns 1 if the value at the given acceptable index is nil, and 0 otherwise.
public boolean isnoneornil(int index)
Returns 1 if the the given acceptable index is not valid (that is, it refers to an element outside the current stack) or if the value at this index is nil, and 0 otherwise.
public boolean isnumber(int index)
Returns 1 if the value at the given acceptable index is a number or a string convertible to a number, and 0 otherwise.
public LValue tolnumber(int index)
Returns an LNumber if the value at the given acceptable index is a number or a string convertible to a number, and LNil.NIL otherwise.
public boolean isstring(int index)
Returns 1 if the value at the given acceptable index is a string or a number (which is always convertible to a string), and 0 otherwise.
public boolean istable(int index)
Returns 1 if the value at the given acceptable index is a table, and 0 otherwise.
public boolean isthread(int index)
Returns 1 if the value at the given acceptable index is a thread, and 0 otherwise.
public boolean isuserdata(int index)
Returns 1 if the value at the given acceptable index is a userdata (either full or light), and 0 otherwise.
public void pop(int n)
n elements from the stack. [-n,
+0, -]
public LValue poplvalue()
public void pushlvalue(LValue value)
public void pushboolean(boolean b)
b onto the stack. [-0, +1, -]
public void pushinteger(int n)
n onto the stack. [-0, +1, -]
public void pushfunction(LFunction f)
This function receives an LFunction and pushes onto the
stack a Lua value of type function that, when called,
invokes the corresponding function.
Any function to be registered in Lua must follow the correct protocol to receive its parameters and return its results
LFunctionpublic void pushlstring(LString s)
public void pushlstring(byte[] bytes,
int offset,
int length)
s with size
len onto the stack. Lua makes (or reuses) an internal copy
of the given string, so the memory at s can be freed or
reused immediately after the function returns. The string can contain
embedded zeros.
public void pushlstring(byte[] byteArray)
public void pushnil()
public void pushnumber(double d)
d onto the stack. [-0, +1, -]
public void pushstring(java.lang.String s)
Pushes the String s onto the stack. Lua makes (or reuses)
an internal copy of the given string, so the memory at s
can be freed or reused immediately after the function returns. The string
cannot contain embedded zeros; it is assumed to end at the first zero.
public void pushvalue(int index)
Pushes a copy of the element at the given valid index onto the stack.
public void rawgeti(int index,
int n)
Pushes onto the stack the value t[n], where
t is the value at the given valid index. The access is
raw; that is, it does not invoke metamethods.
public void remove(int index)
Removes the element at the given valid index, shifting down the elements above this index to fill the gap. Cannot be called with a pseudo-index, because a pseudo-index is not an actual stack position.
public void replace(int index)
Moves the top element into the given position (and pops it), without shifting any element (therefore replacing the value at the given position).
public void setfield(int index,
LString k)
Does the equivalent to t[k] = v, where t
is the value at the given valid index and v is the value
at the top of the stack.
This function pops the value from the stack. As in Lua, this function may trigger a metamethod for the "newindex" event (see §2.8).
public void setglobal(java.lang.String name)
Pops a value from the stack and sets it as the new value of global
name. It is defined as a macro:
#define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, s)
public boolean toboolean(int index)
Converts the Lua value at the given acceptable index to a C boolean
value (0 or 1). Like all tests in Lua, lua_toboolean returns 1 for
any Lua value different from false and nil; otherwise it
returns 0. It also returns 0 when called with a non-valid index. (If you
want to accept only actual boolean values, use lua_isboolean
to test the value's type.)
public int tointeger(int index)
Converts the Lua value at the given acceptable index to the signed
integral type lua_Integer.
The Lua value must be a number or a string convertible to a number (see
§2.2.1); otherwise, lua_tointeger
returns 0.
If the number is not an integer, it is truncated in some non-specified way.
public LValue tofunction(int index)
tofunction[-0, +0, -]
LFunction tofunction (lua_State *L, int index);
Converts a value at the given acceptable index to a C function. That
value must be a function; otherwise, returns NULL.
public LString tolstring(int index)
Converts the Lua value at the given acceptable index to a C string.
If len is not NULL, it also sets
*len with the string length. The Lua value must be a
string or a number; otherwise, the function returns NULL.
If the value is a number, then lua_tolstring
also changes the actual value in the stack to a string. (This
change confuses lua_next when lua_tolstring is applied to
keys during a table traversal.)
lua_tolstring returns a
fully aligned pointer to a string inside the Lua state. This string
always has a zero ('\0') after its last character (as
in C), but may contain other zeros in its body. Because Lua has
garbage collection, there is no guarantee that the pointer returned by lua_tolstring will be valid
after the corresponding value is removed from the stack.
public double tonumber(int index)
Converts the Lua value at the given acceptable index to the C type
lua_Number (see lua_Number). The Lua value must
be a number or a string convertible to a number (see §2.2.1); otherwise, lua_tonumber
returns 0.
public int gettop()
Because indices start at 1, this result is equal to the number of elements in the stack (and so 0 means an empty stack).
public void settop(int nt)
Accepts any acceptable index, or 0, and sets the stack top to this
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.
public void resettop()
public LValue topointer(int index)
Converts the value at the given acceptable index to a generic
C pointer (void*). The value may be a userdata, a
table, a thread, or a function; otherwise, lua_topointer
returns NULL. Different objects will give different
pointers. There is no way to convert the pointer back to its original
value.
Typically this function is used only for debug information.
public java.lang.String tostring(int index)
Equivalent to lua_tolstring
with len equal to NULL.
public LTable totable(int index)
Converts the value at the given acceptable index to a Lua table
This value must be a table otherwise, the function returns NIL.
public java.lang.Object touserdata(int index)
If the value at the given acceptable index is a full userdata, returns
its block address. If the value is a light userdata, returns its pointer.
Otherwise, returns NULL.
public int type(int index)
Returns the type of the value in the given acceptable index, or
LUA_TNONE for a non-valid index (that is, an index to an
"empty" stack position). The types returned by lua_type
are coded by the following constants defined in lua.h:
LUA_TNIL, LUA_TNUMBER,
LUA_TBOOLEAN, LUA_TSTRING,
LUA_TTABLE, LUA_TFUNCTION,
LUA_TUSERDATA, LUA_TTHREAD, and
LUA_TLIGHTUSERDATA.
public java.lang.String typename(int index)
Returns the name of the type encoded by the value tp,
which must be one the values returned by lua_type.
public void xmove(LuaState to,
int n)
Exchange values between different threads of the same global state.
This function pops n values from the stack
from, and pushes them onto the stack to.
public void pushboolean(java.lang.Boolean b)
b - Boolean value to convert, or null to to nil.public void pushinteger(java.lang.Byte b)
b - Byte value to convert, or null to to nil.public void pushinteger(java.lang.Character c)
c - Character value to convert, or null to to nil.public void pushnumber(java.lang.Double d)
d - Double value to convert, or null to to nil.public void pushnumber(java.lang.Float f)
f - Float value to convert, or null to to nil.public void pushinteger(java.lang.Integer i)
i - Integer value to convert, or null to to nil.public void pushinteger(java.lang.Short s)
s - Short value to convert, or null to to nil.public void pushnumber(java.lang.Long l)
l - Long value to convert, or null to to nil.public void pushuserdata(java.lang.Object o)
o - Object value to push, or null to to nil.public java.lang.Boolean toboxedboolean(int index)
index - index of the parameter to convert.
public java.lang.Byte toboxedbyte(int index)
index - index of the parameter to convert.
public java.lang.Double toboxeddouble(int index)
index - index of the parameter to convert.
public java.lang.Float toboxedfloat(int index)
index - index of the parameter to convert.
public java.lang.Integer toboxedinteger(int index)
index - index of the parameter to convert.
public java.lang.Long toboxedlong(int index)
index - index of the parameter to convert.
public void argerror(int narg,
java.lang.String extramsg)
narg - Stack index of the bad argumentextramsg - String to include in error message
public void argcheck(boolean cond,
int narg,
java.lang.String extramsg)
cond - boolean condition that generates an error when falsenarg - Stack index of the bad argumentextramsg - String to include in error message
public void typerror(int narg,
java.lang.String typename)
narg - Stack index of the bad argumenttypename - Name of the type that was expected, such as "string"
public void typerror(int narg,
int typenum)
narg - Stack index of the bad argumenttypenum - Constant value specifying the type of argument that was expected (i.e. LUA_TSTRING).public LValue checkany(int narg)
narg.
narg - the argument number
LuaErrorException - if there is no argument at position nargpublic LFunction checkfunction(int narg)
narg is a function and
returns this function.
narg - the argument number
LuaErrorException - if the value is not a functionLFunctionpublic LThread checkthread(int narg)
narg is a thread and
returns this thread.
narg - the argument number
LuaErrorException - if the value is not a threadLThreadpublic int checkint(int narg)
narg is a number and
returns this number cast to an int.
narg - the argument number
LuaErrorException - if the number cannot be converted to an intpublic LInteger checkinteger(int narg)
narg is a number and
returns this number cast to a LInteger.
narg - the argument number
LuaErrorException - if the value cannot be converted to an intLIntegerpublic long checklong(int narg)
narg is a number and
returns this number cast to a long.
narg - the argument number
LuaErrorException - if the value cannot be converted to a longpublic double checkdouble(int narg)
narg is a number and
returns this number cast to a double.
narg - the argument number
LuaErrorException - if the value cannot be converted to a doublepublic LNumber checknumber(int narg)
narg is a number and
returns this number.
narg - the argument number
LuaErrorException - if the value cannot be converted to a numberLNumberpublic LString checklstring(int narg)
narg is a string and
returns this string as a lua string.
narg - the argument number
LuaErrorException - if the value cannot be converted to a stringLStringpublic java.lang.String checkstring(int narg)
narg is a string and
returns this string as a Java String.
narg - the argument number
LuaErrorException - if the value cannot be converted to a stringpublic LTable checktable(int narg)
narg is a table and
returns this table.
narg - the argument number
LuaErrorException - if the value is not a tableLTable
public LValue checktype(int narg,
int t)
narg has type
t and return it as an LValue.
narg - the argument numbert - the type number to check against
LuaErrorException - if the value is not of type t
public java.lang.Object checkudata(int ud,
java.lang.Class expected)
ud - Stack index of the argument to checkexpected - Class that the userdata is expected to have an instance of.
public int optint(int narg,
int d)
narg is a number, returns this
number cast to an int. If this argument is absent or is
nil, returns d. Otherwise, raises an error.
narg - the argument numberd - the default value when the argument is nil or not supplied
LuaErrorException - if the value cannot be converted to an int
public LInteger optinteger(int narg,
int d)
narg is a number, returns this
number cast to a lua_Integer.
If this argument is absent or is nil, returns d.
Otherwise, raises an error.
narg - the argument numberd - the default value when the argument is nil or not supplied
LuaErrorException - if the value cannot be converted to an int
public long optlong(int narg,
long d)
narg is a number, returns this
number cast to a long. If this argument is absent or is
nil, returns d. Otherwise, raises an error.
narg - the argument numberd - the default value when the argument is nil or not supplied
LuaErrorException - if the value cannot be converted to an number
public LNumber optnumber(int narg,
LNumber d)
narg is a number, returns this
number. If this argument is absent or is nil, returns
d. Otherwise, raises an error.
narg - the argument numberd - the default value when the argument is nil or not supplied
LuaErrorException - if the value cannot be converted to an number
public LString optlstring(int narg,
LString d)
narg is a string, returns this
string. If this argument is absent or is nil, returns
d. Otherwise, raises an error.
public java.lang.String optstring(int narg,
java.lang.String d)
narg is a string, returns this
string. If this argument is absent or is nil, returns
d. Otherwise, raises an error.
public static void vmerror(java.lang.String description)
public LValue call(LFunction function)
function -
public LValue call(LFunction function,
LValue arg0)
function - arg0 -
public LValue luaV_call_index(LFunction function,
LValue table,
LValue key)
function - the __index function to calltable - the table on which the metadata operation is taking placekey - the key used in the index operation
public LValue luaV_call_newindex(LFunction function,
LValue table,
LValue key,
LValue value)
function - the __newindex function to calltable - the table on which the metadata operation is taking placekey - the key used in the newindex operationvalue - the value beting set in the newindex operation
public void sethook(LFunction func,
int mask,
int count)
func - LFunction to call on the hook eventmask - combination of LuaState.LUA_MASKLINE, LuaState.LUA_MASKCALL, and LuaState.LUA_MASKRETcount - 0, or number of bytecodes between count events.public LFunction gethook()
public int gethookcount()
public int gethookmask()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||