Class LuaJNatives
- All Implemented Interfaces:
LuaNatives
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns the Lua registry index constant.voidExposes the symbols in the natives to external libraries.intlua_checkstack(long ptr, int extra) Wrapper oflua_checkstackvoidlua_close(long ptr) Wrapper oflua_closevoidlua_concat(long ptr, int n) Wrapper oflua_concatprotected org.luaj.vm2.LuaThreadlua_create_thread(long ptr, org.luaj.vm2.LuaValue func) voidlua_createtable(long ptr, int narr, int nrec) Wrapper oflua_createtableintlua_error(long ptr) Wrapper oflua_errorintlua_gethookcount(long ptr) Wrapper oflua_gethookcountintlua_gethookmask(long ptr) Wrapper oflua_gethookmaskintlua_getmetatable(long ptr, int index) Wrapper oflua_getmetatableintlua_gettop(long ptr) Wrapper oflua_gettoplua_getupvalue(long ptr, int funcindex, int n) Wrapper oflua_getupvaluevoidlua_insert(long ptr, int index) Wrapper oflua_insertintlua_isboolean(long ptr, int index) Wrapper oflua_isbooleanintlua_iscfunction(long ptr, int index) Wrapper oflua_iscfunctionintlua_isfunction(long ptr, int index) Wrapper oflua_isfunctionintlua_islightuserdata(long ptr, int index) Wrapper oflua_islightuserdataintlua_isnil(long ptr, int index) Wrapper oflua_isnilintlua_isnone(long ptr, int index) Wrapper oflua_isnoneintlua_isnoneornil(long ptr, int index) Wrapper oflua_isnoneornilintlua_isnumber(long ptr, int index) Wrapper oflua_isnumberintlua_isstring(long ptr, int index) Wrapper oflua_isstringintlua_istable(long ptr, int index) Wrapper oflua_istableintlua_isthread(long ptr, int index) Wrapper oflua_isthreadintlua_isuserdata(long ptr, int index) Wrapper oflua_isuserdatavoidlua_newtable(long ptr) Wrapper oflua_newtablelonglua_newthread(long ptr) Wrapper oflua_newthreadvoidlua_newuserdata(long ptr, Object object) intlua_next(long ptr, int index) Wrapper oflua_nextintlua_pcall(long ptr, int nargs, int nresults, int errfunc) Wrapper oflua_pcallvoidlua_pop(long ptr, int n) Wrapper oflua_popvoidlua_pushboolean(long ptr, int b) Wrapper oflua_pushbooleanvoidlua_pushinteger(long ptr, long n) Wrapper oflua_pushintegervoidlua_pushlightuserdata(long ptr, long p) Wrapper oflua_pushlightuserdatavoidlua_pushnil(long ptr) Wrapper oflua_pushnilvoidlua_pushnumber(long ptr, double n) Wrapper oflua_pushnumberintlua_pushthread(long ptr) Wrapper oflua_pushthreadvoidlua_pushvalue(long ptr, int index) Wrapper oflua_pushvalueintlua_rawequal(long ptr, int index1, int index2) Wrapper oflua_rawequalvoidlua_rawset(long ptr, int index) Wrapper oflua_rawsetvoidlua_rawseti(long ptr, int index, int n) Wrapper oflua_rawsetivoidlua_remove(long ptr, int index) Wrapper oflua_removevoidlua_replace(long ptr, int index) Wrapper oflua_replaceprotected voidlua_require_coroutine(long ptr) voidlua_setfield(long ptr, int index, String k) Wrapper oflua_setfieldvoidlua_setglobal(long ptr, String name) Wrapper oflua_setglobalvoidlua_settable(long ptr, int index) Wrapper oflua_settablevoidlua_settop(long ptr, int index) Wrapper oflua_settoplua_setupvalue(long ptr, int funcindex, int n) Wrapper oflua_setupvalueintlua_status(long ptr) Wrapper oflua_statusintlua_toboolean(long ptr, int index) Wrapper oflua_tobooleanlonglua_tointeger(long ptr, int index) Wrapper oflua_tointegerdoublelua_tonumber(long ptr, int index) Wrapper oflua_tonumberlonglua_topointer(long ptr, int index) Wrapper oflua_topointerlua_tostring(long ptr, int index) Wrapper oflua_tostringlonglua_tothread(long ptr, int index) Wrapper oflua_tothreadlonglua_touserdata(long ptr, int index) Wrapper oflua_touserdataintlua_type(long ptr, int index) Wrapper oflua_typelua_typename(long ptr, int index) Wrapper oflua_typenamevoidlua_xmove(long from, long to, int n) Wrapper oflua_xmoveintlua_yield(long ptr, int nresults) Wrapper oflua_yieldintluaJ_compare(long ptr, int index1, int index2, int op) A wrapper functionintluaJ_dobuffer(long ptr, Buffer buffer, int start, int size, String name) A wrapper functionluaJ_dumptobuffer(long ptr) Wrapper oflua_dumpvoidluaJ_gc(long ptr) A wrapper functionvoidluaJ_getfield(long ptr, int index, String k) Wrapper oflua_getfieldvoidluaJ_getglobal(long ptr, String name) Wrapper oflua_getglobalvoidluaJ_getmetatable(long ptr, String tname) Wrapper ofluaL_getmetatablevoidluaJ_gettable(long ptr, int index) Wrapper oflua_gettableintluaJ_initloader(long ptr) A wrapper functionintA wrapper functionintluaJ_isinteger(long ptr, int index) Wrapper oflua_isintegerintluaJ_isobject(long ptr, int index) A wrapper functionintluaJ_len(long ptr, int index) A wrapper functionintluaJ_loadbuffer(long ptr, Buffer buffer, int start, int size, String name) A wrapper functionlongluaJ_newthread(long ptr, int lid) A wrapper functionvoidluaJ_openlib(long ptr, String lib) A wrapper functionvoidluaJ_pusharray(long ptr, Object array) A wrapper functionvoidluaJ_pushclass(long ptr, Object clazz) A wrapper functionvoidluaJ_pushfunction(long ptr, Object func) A wrapper functionvoidluaJ_pushlstring(long ptr, Buffer buffer, int start, int size) A wrapper functionvoidluaJ_pushobject(long ptr, Object obj) A wrapper functionvoidluaJ_pushstring(long ptr, String s) Wrapper oflua_pushstringvoidluaJ_rawget(long ptr, int index) Wrapper oflua_rawgetvoidluaJ_rawgeti(long ptr, int index, int n) Wrapper oflua_rawgetivoidluaJ_removestateindex(long ptr) A wrapper functionintluaJ_resume(long ptr, int nargs) A wrapper functionvoidluaJ_setmetatable(long ptr, int index) Wrapper oflua_setmetatableluaJ_tobuffer(long ptr, int index) Creates aByteBufferfrom the string at the specific indexluaJ_todirectbuffer(long ptr, int index) Creates a directByteBufferbacked by the string at the stack indexluaJ_toobject(long ptr, int index) A wrapper functionintluaL_callmeta(long ptr, int obj, String e) Wrapper ofluaL_callmetaintluaL_dostring(long ptr, String str) Wrapper ofluaL_dostringintluaL_getmetafield(long ptr, int obj, String e) Wrapper ofluaL_getmetafieldintluaL_loadstring(long ptr, String s) Wrapper ofluaL_loadstringintluaL_newmetatable(long ptr, String tname) Wrapper ofluaL_newmetatablelongluaL_newstate(int lid) Wrapper ofluaL_newstatevoidluaL_openlibs(long ptr) Wrapper ofluaL_openlibsintluaL_ref(long ptr, int t) Wrapper ofluaL_refluaL_typename(long ptr, int index) Wrapper ofluaL_typenamevoidluaL_unref(long ptr, int t, int ref) Wrapper ofluaL_unrefvoidluaL_where(long ptr, int lvl) Wrapper ofluaL_where
-
Constructor Details
-
LuaJNatives
public LuaJNatives()
-
-
Method Details
-
loadAsGlobal
public void loadAsGlobal()Description copied from interface:LuaNativesExposes the symbols in the natives to external libraries.Users are only allowed load one instance of natives if they want it global. Otherwise, the JVM might just crash due to identical symbol names in different binaries.
- Specified by:
loadAsGlobalin interfaceLuaNatives
-
getRegistryIndex
public int getRegistryIndex()Description copied from interface:LuaNativesReturns the Lua registry index constant.- Specified by:
getRegistryIndexin interfaceLuaNatives- Returns:
- the
LUA_REGISTRYINDEXconstant, which changes between versions
-
lua_checkstack
public int lua_checkstack(long ptr, int extra) Description copied from interface:LuaNativesWrapper oflua_checkstack[-0, +0, m]int lua_checkstack (lua_State *L, int extra);Ensures that there are at least
extrafree stack slots in the stack. 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.- Specified by:
lua_checkstackin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerextra- slots- Returns:
- see description
-
lua_close
public void lua_close(long ptr) Description copied from interface:LuaNativesWrapper oflua_close[-0, +0, -]void lua_close (lua_State *L);Destroys all objects in the given Lua state (calling the corresponding garbage-collection metamethods, if any) and frees all dynamic memory used by this state. On several platforms, you may not need to call this function, because all resources are naturally released when the host program ends. On the other hand, long-running programs, such as a daemon or a web server, might need to release states as soon as they are not needed, to avoid growing too large.
- Specified by:
lua_closein interfaceLuaNatives- Parameters:
ptr- thelua_State*pointer
-
lua_concat
public void lua_concat(long ptr, int n) Description copied from interface:LuaNativesWrapper oflua_concat[-n, +1, e]void lua_concat (lua_State *L, int n);Concatenates the
nvalues at the top of the stack, pops them, and leaves the result at the top. Ifnis 1, the result is the single value on the stack (that is, the function does nothing); ifnis 0, the result is the empty string. Concatenation is performed following the usual semantics of Lua (see §2.5.4).- Specified by:
lua_concatin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointern- the number of elements
-
lua_createtable
public void lua_createtable(long ptr, int narr, int nrec) Description copied from interface:LuaNativesWrapper oflua_createtable[-0, +1, m]void lua_createtable (lua_State *L, int narr, int nrec);Creates a new empty table and pushes it onto the stack. The new table has space pre-allocated for
narrarray elements andnrecnon-array elements. This pre-allocation is useful when you know exactly how many elements the table will have. Otherwise you can use the functionlua_newtable.- Specified by:
lua_createtablein interfaceLuaNatives- Parameters:
ptr- thelua_State*pointernarr- the number of pre-allocated array elementsnrec- the number of pre-allocated non-array elements
-
lua_error
public int lua_error(long ptr) Description copied from interface:LuaNativesWrapper oflua_error[-1, +0, v]int lua_error (lua_State *L);Generates a Lua error. The error message (which can actually be a Lua value of any type) must be on the stack top. This function does a long jump, and therefore never returns. (see
luaL_error).- Specified by:
lua_errorin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointer- Returns:
- see description
-
luaJ_getfield
Description copied from interface:LuaNativesWrapper oflua_getfield[-0, +1, e]void lua_getfield (lua_State *L, int index, const char *k);Pushes onto the stack the value
t[k], wheretis the value at the given valid index. As in Lua, this function may trigger a metamethod for the "index" event (see §2.8).- Specified by:
luaJ_getfieldin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the elementk- the field name
-
luaJ_getglobal
Description copied from interface:LuaNativesWrapper oflua_getglobal[-0, +1, e]void lua_getglobal (lua_State *L, const char *name);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)- Specified by:
luaJ_getglobalin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointername- the name
-
lua_getmetatable
public int lua_getmetatable(long ptr, int index) Description copied from interface:LuaNativesWrapper oflua_getmetatable[-0, +(0|1), -]int lua_getmetatable (lua_State *L, 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 0 and pushes nothing on the stack.
- Specified by:
lua_getmetatablein interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element- Returns:
- see description
-
luaJ_gettable
public void luaJ_gettable(long ptr, int index) Description copied from interface:LuaNativesWrapper oflua_gettable[-1, +1, e]void lua_gettable (lua_State *L, int index);Pushes onto the stack the value
t[k], wheretis the value at the given valid index andkis the value at the top of the stack.This function pops the key from the stack (putting the resulting value in its place). As in Lua, this function may trigger a metamethod for the "index" event (see §2.8).
- Specified by:
luaJ_gettablein interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element
-
lua_gettop
public int lua_gettop(long ptr) Description copied from interface:LuaNativesWrapper oflua_gettop[-0, +0, -]int lua_gettop (lua_State *L);Returns the index of the top element in the stack. Because indices start at 1, this result is equal to the number of elements in the stack (and so 0 means an empty stack).
- Specified by:
lua_gettopin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointer- Returns:
- see description
-
lua_insert
public void lua_insert(long ptr, int index) Description copied from interface:LuaNativesWrapper oflua_insert[-1, +1, -]void lua_insert (lua_State *L, 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.
- Specified by:
lua_insertin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element
-
lua_isboolean
public int lua_isboolean(long ptr, int index) Description copied from interface:LuaNativesWrapper oflua_isboolean[-0, +0, -]int lua_isboolean (lua_State *L, int index);Returns 1 if the value at the given acceptable index has type boolean, and 0 otherwise.
- Specified by:
lua_isbooleanin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element- Returns:
- see description
-
lua_iscfunction
public int lua_iscfunction(long ptr, int index) Description copied from interface:LuaNativesWrapper oflua_iscfunction[-0, +0, -]int lua_iscfunction (lua_State *L, int index);Returns 1 if the value at the given acceptable index is a C function, and 0 otherwise.
- Specified by:
lua_iscfunctionin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element- Returns:
- see description
-
lua_isfunction
public int lua_isfunction(long ptr, int index) Description copied from interface:LuaNativesWrapper oflua_isfunction[-0, +0, -]int lua_isfunction (lua_State *L, int index);Returns 1 if the value at the given acceptable index is a function (either C or Lua), and 0 otherwise.
- Specified by:
lua_isfunctionin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element- Returns:
- see description
-
lua_islightuserdata
public int lua_islightuserdata(long ptr, int index) Description copied from interface:LuaNativesWrapper oflua_islightuserdata[-0, +0, -]int lua_islightuserdata (lua_State *L, int index);Returns 1 if the value at the given acceptable index is a light userdata, and 0 otherwise.
- Specified by:
lua_islightuserdatain interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element- Returns:
- see description
-
lua_isnil
public int lua_isnil(long ptr, int index) Description copied from interface:LuaNativesWrapper oflua_isnil[-0, +0, -]int lua_isnil (lua_State *L, int index);Returns 1 if the value at the given acceptable index is nil, and 0 otherwise.
- Specified by:
lua_isnilin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element- Returns:
- see description
-
lua_isnone
public int lua_isnone(long ptr, int index) Description copied from interface:LuaNativesWrapper oflua_isnone[-0, +0, -]int lua_isnone (lua_State *L, int index);Returns 1 if the given acceptable index is not valid (that is, it refers to an element outside the current stack), and 0 otherwise.
- Specified by:
lua_isnonein interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element- Returns:
- see description
-
lua_isnoneornil
public int lua_isnoneornil(long ptr, int index) Description copied from interface:LuaNativesWrapper oflua_isnoneornil[-0, +0, -]int lua_isnoneornil (lua_State *L, int index);Returns 1 if 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.
- Specified by:
lua_isnoneornilin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element- Returns:
- see description
-
lua_isnumber
public int lua_isnumber(long ptr, int index) Description copied from interface:LuaNativesWrapper oflua_isnumber[-0, +0, -]int lua_isnumber (lua_State *L, 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.
- Specified by:
lua_isnumberin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element- Returns:
- see description
-
luaJ_isinteger
public int luaJ_isinteger(long ptr, int index) Description copied from interface:LuaNativesWrapper oflua_isinteger[-0, +0, –]int lua_isinteger (lua_State *L, int index);Returns 1 if the value at the given index is an integer (that is, the value is a number and is represented as an integer), and 0 otherwise.
- Specified by:
luaJ_isintegerin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element- Returns:
- see description
-
lua_isstring
public int lua_isstring(long ptr, int index) Description copied from interface:LuaNativesWrapper oflua_isstring[-0, +0, -]int lua_isstring (lua_State *L, 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.
- Specified by:
lua_isstringin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element- Returns:
- see description
-
lua_istable
public int lua_istable(long ptr, int index) Description copied from interface:LuaNativesWrapper oflua_istable[-0, +0, -]int lua_istable (lua_State *L, int index);Returns 1 if the value at the given acceptable index is a table, and 0 otherwise.
- Specified by:
lua_istablein interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element- Returns:
- see description
-
lua_isthread
public int lua_isthread(long ptr, int index) Description copied from interface:LuaNativesWrapper oflua_isthread[-0, +0, -]int lua_isthread (lua_State *L, int index);Returns 1 if the value at the given acceptable index is a thread, and 0 otherwise.
- Specified by:
lua_isthreadin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element- Returns:
- see description
-
lua_isuserdata
public int lua_isuserdata(long ptr, int index) Description copied from interface:LuaNativesWrapper oflua_isuserdata[-0, +0, -]int lua_isuserdata (lua_State *L, int index);Returns 1 if the value at the given acceptable index is a userdata (either full or light), and 0 otherwise.
- Specified by:
lua_isuserdatain interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element- Returns:
- see description
-
lua_newuserdata
-
lua_newtable
public void lua_newtable(long ptr) Description copied from interface:LuaNativesWrapper oflua_newtable[-0, +1, m]void lua_newtable (lua_State *L);Creates a new empty table and pushes it onto the stack. It is equivalent to
lua_createtable(L, 0, 0).- Specified by:
lua_newtablein interfaceLuaNatives- Parameters:
ptr- thelua_State*pointer
-
lua_newthread
public long lua_newthread(long ptr) Description copied from interface:LuaNativesWrapper oflua_newthread[-0, +1, m]lua_State *lua_newthread (lua_State *L);Creates a new thread, pushes it on the stack, and returns a pointer to a
lua_Statethat represents this new thread. The new state returned by this function shares with the original state all global objects (such as tables), but has an independent execution stack.There is no explicit function to close or to destroy a thread. Threads are subject to garbage collection, like any Lua object.
- Specified by:
lua_newthreadin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointer- Returns:
- see description
-
lua_create_thread
protected org.luaj.vm2.LuaThread lua_create_thread(long ptr, org.luaj.vm2.LuaValue func) -
lua_require_coroutine
protected void lua_require_coroutine(long ptr) -
lua_next
public int lua_next(long ptr, int index) Description copied from interface:LuaNativesWrapper oflua_next[-1, +(2|0), e]int lua_next (lua_State *L, int index);Pops a key from the stack, and pushes a key-value pair from the table at the given index (the "next" pair after the given key). If there are no more elements in the table, then
lua_nextreturns 0 (and pushes nothing).A typical traversal looks like this:
/* table is in the stack at index 't' */ lua_pushnil(L); /* first key */ while (lua_next(L, t) != 0) { /* uses 'key' (at index -2) and 'value' (at index -1) */ printf("%s - %s\n", lua_typename(L, lua_type(L, -2)), lua_typename(L, lua_type(L, -1))); /* removes 'value'; keeps 'key' for next iteration */ lua_pop(L, 1); }While traversing a table, do not call
lua_tolstringdirectly on a key, unless you know that the key is actually a string. Recall thatlua_tolstringchanges the value at the given index; this confuses the next call tolua_next.- Specified by:
lua_nextin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element- Returns:
- see description
-
lua_pcall
public int lua_pcall(long ptr, int nargs, int nresults, int errfunc) Description copied from interface:LuaNativesWrapper oflua_pcall[-(nargs + 1), +(nresults|1), -]int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc);Calls a function in public mode.
Both
nargsandnresultshave the same meaning as inlua_call. If there are no errors during the call,lua_pcallbehaves exactly likelua_call. However, if there is any error,lua_pcallcatches it, pushes a single value on the stack (the error message), and returns an error code. Likelua_call,lua_pcallalways removes the function and its arguments from the stack.If
errfuncis 0, then the error message returned on the stack is exactly the original error message. Otherwise,errfuncis 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 bylua_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_pcallfunction returns 0 in case of success or one of the following error codes (defined inlua.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.
- Specified by:
lua_pcallin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointernargs- the number of arguments that you pushed onto the stacknresults- the number of results, orLUA_MULTRETerrfunc- 0 or the stack index of an error handler function- Returns:
- see description
-
-
lua_pop
public void lua_pop(long ptr, int n) Description copied from interface:LuaNatives- Specified by:
lua_popin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointern- the number of elements
-
lua_pushboolean
public void lua_pushboolean(long ptr, int b) Description copied from interface:LuaNativesWrapper oflua_pushboolean[-0, +1, -]void lua_pushboolean (lua_State *L, int b);Pushes a boolean value with value
bonto the stack.- Specified by:
lua_pushbooleanin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerb- boolean
-
lua_pushinteger
public void lua_pushinteger(long ptr, long n) Description copied from interface:LuaNativesWrapper oflua_pushinteger[-0, +1, -]void lua_pushinteger (lua_State *L, lua_Integer n);Pushes a number with value
nonto the stack.- Specified by:
lua_pushintegerin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointern- integer
-
lua_pushlightuserdata
public void lua_pushlightuserdata(long ptr, long p) Description copied from interface:LuaNativesWrapper oflua_pushlightuserdata[-0, +1, -]void lua_pushlightuserdata (lua_State *L, void *p);Pushes a light userdata onto the stack.
Userdata represent C values in Lua. A light userdata represents a pointer. It is a value (like a number): you do not create it, it has no individual metatable, and it is not collected (as it was never created). A light userdata is equal to "any" light userdata with the same C address.
- Specified by:
lua_pushlightuserdatain interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerp- the pointer
-
lua_pushnil
public void lua_pushnil(long ptr) Description copied from interface:LuaNativesWrapper oflua_pushnil[-0, +1, -]void lua_pushnil (lua_State *L);Pushes a nil value onto the stack.
- Specified by:
lua_pushnilin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointer
-
lua_pushnumber
public void lua_pushnumber(long ptr, double n) Description copied from interface:LuaNativesWrapper oflua_pushnumber[-0, +1, -]void lua_pushnumber (lua_State *L, lua_Number n);Pushes a number with value
nonto the stack.- Specified by:
lua_pushnumberin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointern- the number of elements
-
luaJ_pushstring
Description copied from interface:LuaNativesWrapper oflua_pushstring[-0, +1, m]void lua_pushstring (lua_State *L, const char *s);Pushes the zero-terminated string pointed to by
sonto the stack. Lua makes (or reuses) an internal copy of the given string, so the memory atscan be freed or reused immediately after the function returns. The string cannot contain embedded zeros; it is assumed to end at the first zero.- Specified by:
luaJ_pushstringin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointers- the string
-
lua_pushthread
public int lua_pushthread(long ptr) Description copied from interface:LuaNativesWrapper oflua_pushthread[-0, +1, -]int lua_pushthread (lua_State *L);Pushes the thread represented by
Lonto the stack. Returns 1 if this thread is the main thread of its state.- Specified by:
lua_pushthreadin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointer- Returns:
- see description
-
lua_pushvalue
public void lua_pushvalue(long ptr, int index) Description copied from interface:LuaNativesWrapper oflua_pushvalue[-0, +1, -]void lua_pushvalue (lua_State *L, int index);Pushes a copy of the element at the given valid index onto the stack.
- Specified by:
lua_pushvaluein interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element
-
lua_rawequal
public int lua_rawequal(long ptr, int index1, int index2) Description copied from interface:LuaNativesWrapper oflua_rawequal[-0, +0, -]int lua_rawequal (lua_State *L, int index1, int index2);Returns 1 if the two values in acceptable indices
index1andindex2are primitively equal (that is, without calling metamethods). Otherwise returns 0. Also returns 0 if any of the indices are non valid.- Specified by:
lua_rawequalin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex1- the stack position of the first elementindex2- the stack position of the second element- Returns:
- see description
-
luaJ_rawget
public void luaJ_rawget(long ptr, int index) Description copied from interface:LuaNativesWrapper oflua_rawget[-1, +1, -]void lua_rawget (lua_State *L, int index);Similar to
lua_gettable, but does a raw access (i.e., without metamethods).- Specified by:
luaJ_rawgetin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element
-
luaJ_rawgeti
public void luaJ_rawgeti(long ptr, int index, int n) Description copied from interface:LuaNativesWrapper oflua_rawgeti[-0, +1, -]void lua_rawgeti (lua_State *L, int index, int n);Pushes onto the stack the value
t[n], wheretis the value at the given valid index. The access is raw; that is, it does not invoke metamethods.- Specified by:
luaJ_rawgetiin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the elementn- the number of elements
-
lua_rawset
public void lua_rawset(long ptr, int index) Description copied from interface:LuaNativesWrapper oflua_rawset[-2, +0, m]void lua_rawset (lua_State *L, int index);Similar to
lua_settable, but does a raw assignment (i.e., without metamethods).- Specified by:
lua_rawsetin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element
-
lua_rawseti
public void lua_rawseti(long ptr, int index, int n) Description copied from interface:LuaNativesWrapper oflua_rawseti[-1, +0, m]void lua_rawseti (lua_State *L, int index, int n);Does the equivalent of
t[n] = v, wheretis the value at the given valid index andvis the value at the top of the stack.This function pops the value from the stack. The assignment is raw; that is, it does not invoke metamethods.
- Specified by:
lua_rawsetiin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the elementn- the index
-
lua_remove
public void lua_remove(long ptr, int index) Description copied from interface:LuaNativesWrapper oflua_remove[-1, +0, -]void lua_remove (lua_State *L, 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.
- Specified by:
lua_removein interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element
-
lua_replace
public void lua_replace(long ptr, int index) Description copied from interface:LuaNativesWrapper oflua_replace[-1, +0, -]void lua_replace (lua_State *L, 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).
- Specified by:
lua_replacein interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element
-
lua_setfield
Description copied from interface:LuaNativesWrapper oflua_setfield[-1, +0, e]void lua_setfield (lua_State *L, int index, const char *k);Does the equivalent to
t[k] = v, wheretis the value at the given valid index andvis 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).
- Specified by:
lua_setfieldin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the elementk- the field name
-
lua_setglobal
Description copied from interface:LuaNativesWrapper oflua_setglobal[-1, +0, e]void lua_setglobal (lua_State *L, const char *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)- Specified by:
lua_setglobalin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointername- the name
-
luaJ_setmetatable
public void luaJ_setmetatable(long ptr, int index) Description copied from interface:LuaNativesWrapper oflua_setmetatable[-1, +0, -]int lua_setmetatable (lua_State *L, int index);Pops a table from the stack and sets it as the new metatable for the value at the given acceptable index.
- Specified by:
luaJ_setmetatablein interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element
-
lua_settable
public void lua_settable(long ptr, int index) Description copied from interface:LuaNativesWrapper oflua_settable[-2, +0, e]void lua_settable (lua_State *L, int index);Does the equivalent to
t[k] = v, wheretis the value at the given valid index,vis the value at the top of the stack, andkis the value just below the top.This function pops both the key and the value from the stack. As in Lua, this function may trigger a metamethod for the "newindex" event (see §2.8).
- Specified by:
lua_settablein interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element
-
lua_settop
public void lua_settop(long ptr, int index) Description copied from interface:LuaNativesWrapper oflua_settop[-?, +?, -]void lua_settop (lua_State *L, int index);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
indexis 0, then all stack elements are removed.- Specified by:
lua_settopin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element
-
lua_status
public int lua_status(long ptr) Description copied from interface:LuaNativesWrapper oflua_status[-0, +0, -]int lua_status (lua_State *L);Returns the status of the thread
L.The status can be 0 for a normal thread, an error code if the thread finished its execution with an error, or
LUA_YIELDif the thread is suspended.- Specified by:
lua_statusin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointer- Returns:
- see description
-
lua_toboolean
public int lua_toboolean(long ptr, int index) Description copied from interface:LuaNativesWrapper oflua_toboolean[-0, +0, -]int lua_toboolean (lua_State *L, 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_tobooleanreturns 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, uselua_isbooleanto test the value's type.)- Specified by:
lua_tobooleanin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element- Returns:
- see description
-
lua_tointeger
public long lua_tointeger(long ptr, int index) Description copied from interface:LuaNativesWrapper oflua_tointeger[-0, +0, -]lua_Integer lua_tointeger (lua_State *L, 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_tointegerreturns 0.If the number is not an integer, it is truncated in some non-specified way.
- Specified by:
lua_tointegerin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element- Returns:
- see description
-
lua_tonumber
public double lua_tonumber(long ptr, int index) Description copied from interface:LuaNativesWrapper oflua_tonumber[-0, +0, -]lua_Number lua_tonumber (lua_State *L, int index);Converts the Lua value at the given acceptable index to the C type
lua_Number(seelua_Number). The Lua value must be a number or a string convertible to a number (see §2.2.1); otherwise,lua_tonumberreturns 0.- Specified by:
lua_tonumberin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element- Returns:
- see description
-
lua_topointer
public long lua_topointer(long ptr, int index) Description copied from interface:LuaNativesWrapper oflua_topointer[-0, +0, -]const void *lua_topointer (lua_State *L, int index);Converts the value at the given acceptable index to a generic C pointer (
void*). The value can be a userdata, a table, a thread, or a function; otherwise,lua_topointerreturnsNULL. 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.
- Specified by:
lua_topointerin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element- Returns:
- see description
-
lua_tostring
Description copied from interface:LuaNativesWrapper oflua_tostring[-0, +0, m]const char *lua_tostring (lua_State *L, int index);Equivalent to
lua_tolstringwithlenequal toNULL.- Specified by:
lua_tostringin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element- Returns:
- see description
-
lua_tothread
public long lua_tothread(long ptr, int index) Description copied from interface:LuaNativesWrapper oflua_tothread[-0, +0, -]lua_State *lua_tothread (lua_State *L, int index);Converts the value at the given acceptable index to a Lua thread (represented as
lua_State*). This value must be a thread; otherwise, the function returnsNULL.- Specified by:
lua_tothreadin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element- Returns:
- see description
-
lua_touserdata
public long lua_touserdata(long ptr, int index) Description copied from interface:LuaNativesWrapper oflua_touserdata[-0, +0, -]void *lua_touserdata (lua_State *L, 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.- Specified by:
lua_touserdatain interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element- Returns:
- see description
-
lua_type
public int lua_type(long ptr, int index) Description copied from interface:LuaNativesWrapper oflua_type[-0, +0, -]int lua_type (lua_State *L, int index);Returns the type of the value in the given acceptable index, or
LUA_TNONEfor a non-valid index (that is, an index to an "empty" stack position). The types returned bylua_typeare coded by the following constants defined inlua.h:LUA_TNIL,LUA_TNUMBER,LUA_TBOOLEAN,LUA_TSTRING,LUA_TTABLE,LUA_TFUNCTION,LUA_TUSERDATA,LUA_TTHREAD, andLUA_TLIGHTUSERDATA.- Specified by:
lua_typein interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element- Returns:
- see description
-
lua_typename
Description copied from interface:LuaNativesWrapper oflua_typename[-0, +0, -]const char *lua_typename (lua_State *L, int tp);Returns the name of the type encoded by the value
tp, which must be one the values returned bylua_type.- Specified by:
lua_typenamein interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- type id- Returns:
- see description
-
lua_xmove
public void lua_xmove(long from, long to, int n) Description copied from interface:LuaNativesWrapper oflua_xmove[-?, +?, -]void lua_xmove (lua_State *from, lua_State *to, int n);Exchange values between different threads of the same global state.
This function pops
nvalues from the stackfrom, and pushes them onto the stackto.- Specified by:
lua_xmovein interfaceLuaNatives- Parameters:
from- a threadto- another threadn- the number of elements
-
lua_yield
public int lua_yield(long ptr, int nresults) Description copied from interface:LuaNativesWrapper oflua_yield[-?, +?, -]int lua_yield (lua_State *L, int nresults);Yields a coroutine.
This function should only be called as the return expression of a C function, as follows:
return lua_yield (L, nresults);When a C function calls
lua_yieldin that way, the running coroutine suspends its execution, and the call tolua_resumethat started this coroutine returns. The parameternresultsis the number of values from the stack that are passed as results tolua_resume.- Specified by:
lua_yieldin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointernresults- the number of results, orLUA_MULTRET- Returns:
- see description
-
lua_gethookcount
public int lua_gethookcount(long ptr) Description copied from interface:LuaNativesWrapper oflua_gethookcount[-0, +0, -]int lua_gethookcount (lua_State *L);Returns the current hook count.
- Specified by:
lua_gethookcountin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointer- Returns:
- see description
-
lua_gethookmask
public int lua_gethookmask(long ptr) Description copied from interface:LuaNativesWrapper oflua_gethookmask[-0, +0, -]int lua_gethookmask (lua_State *L);Returns the current hook mask.
- Specified by:
lua_gethookmaskin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointer- Returns:
- see description
-
lua_getupvalue
Description copied from interface:LuaNativesWrapper oflua_getupvalue[-0, +(0|1), -]const char *lua_getupvalue (lua_State *L, int funcindex, int n);Gets information about a closure's upvalue. (For Lua functions, upvalues are the external local variables that the function uses, and that are consequently included in its closure.)
lua_getupvaluegets the indexnof an upvalue, pushes the upvalue's value onto the stack, and returns its name.funcindexpoints to the closure in the stack. (Upvalues have no particular order, as they are active through the whole function. So, they are numbered in an arbitrary order.)Returns
NULL(and pushes nothing) when the index is greater than the number of upvalues. For C functions, this function uses the empty string""as a name for all upvalues.- Specified by:
lua_getupvaluein interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerfuncindex- the stack position of the closuren- the index in the upvalue- Returns:
- see description
-
lua_setupvalue
Description copied from interface:LuaNativesWrapper oflua_setupvalue[-(0|1), +0, -]const char *lua_setupvalue (lua_State *L, int funcindex, int n);Sets the value of a closure's upvalue. It assigns the value at the top of the stack to the upvalue and returns its name. It also pops the value from the stack. Parameters
funcindexandnare as in thelua_getupvalue(seelua_getupvalue).Returns
NULL(and pops nothing) when the index is greater than the number of upvalues.- Specified by:
lua_setupvaluein interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerfuncindex- the stack position of the closuren- the index in the upvalue- Returns:
- see description
-
luaL_callmeta
Description copied from interface:LuaNativesWrapper ofluaL_callmeta[-0, +(0|1), e]int luaL_callmeta (lua_State *L, int obj, const char *e);Calls a metamethod.
If the object at index
objhas a metatable and this metatable has a fielde, this function calls this field and passes the object as its only argument. In this case this function returns 1 and pushes onto the stack the value returned by the call. If there is no metatable or no metamethod, this function returns 0 (without pushing any value on the stack).- Specified by:
luaL_callmetain interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerobj- the stack position of the objecte- field name- Returns:
- see description
-
luaL_dostring
Description copied from interface:LuaNativesWrapper ofluaL_dostring[-0, +?, m]int luaL_dostring (lua_State *L, const char *str);Loads and runs the given string. It is defined as the following macro:
(luaL_loadstring(L, str) || lua_pcall(L, 0, LUA_MULTRET, 0))It returns 0 if there are no errors or 1 in case of errors.
- Specified by:
luaL_dostringin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerstr- string- Returns:
- see description
-
luaL_getmetafield
Description copied from interface:LuaNativesWrapper ofluaL_getmetafield[-0, +(0|1), m]int luaL_getmetafield (lua_State *L, int obj, const char *e);Pushes onto the stack the field
efrom the metatable of the object at indexobj. If the object does not have a metatable, or if the metatable does not have this field, returns 0 and pushes nothing.- Specified by:
luaL_getmetafieldin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerobj- the stack position of the objecte- field name- Returns:
- see description
-
luaJ_getmetatable
Description copied from interface:LuaNativesWrapper ofluaL_getmetatable[-0, +1, -]void luaL_getmetatable (lua_State *L, const char *tname);Pushes onto the stack the metatable associated with name
tnamein the registry (seeluaL_newmetatable).- Specified by:
luaJ_getmetatablein interfaceLuaNatives- Parameters:
ptr- thelua_State*pointertname- type name
-
luaL_loadstring
Description copied from interface:LuaNativesWrapper ofluaL_loadstring[-0, +1, m]int luaL_loadstring (lua_State *L, const char *s);Loads a string as a Lua chunk. This function uses
lua_loadto load the chunk in the zero-terminated strings.This function returns the same results as
lua_load.Also as
lua_load, this function only loads the chunk; it does not run it.- Specified by:
luaL_loadstringin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointers- the string- Returns:
- see description
-
luaL_newmetatable
Description copied from interface:LuaNativesWrapper ofluaL_newmetatable[-0, +1, m]int luaL_newmetatable (lua_State *L, const char *tname);If the registry already has the key
tname, returns 0. Otherwise, creates a new table to be used as a metatable for userdata, adds it to the registry with keytname, and returns 1.In both cases pushes onto the stack the final value associated with
tnamein the registry.- Specified by:
luaL_newmetatablein interfaceLuaNatives- Parameters:
ptr- thelua_State*pointertname- type name- Returns:
- see description
-
luaL_newstate
public long luaL_newstate(int lid) Description copied from interface:LuaNativesWrapper ofluaL_newstate[-0, +0, -]lua_State *luaL_newstate (void);Creates a new Lua state. It calls
lua_newstatewith an allocator based on the standard Creallocfunction and then sets a panic function (seelua_atpanic) that prints an error message to the standard error output in case of fatal errors.Returns the new state, or
NULLif there is a memory allocation error.- Specified by:
luaL_newstatein interfaceLuaNatives- Parameters:
lid- the id of the Lua state, to be used to identify between Java and Lua- Returns:
- see description
-
luaL_openlibs
public void luaL_openlibs(long ptr) Description copied from interface:LuaNativesWrapper ofluaL_openlibs[-0, +0, m]void luaL_openlibs (lua_State *L);Opens all standard Lua libraries into the given state.
- Specified by:
luaL_openlibsin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointer
-
luaL_ref
public int luaL_ref(long ptr, int t) Description copied from interface:LuaNativesWrapper ofluaL_ref[-1, +0, m]int luaL_ref (lua_State *L, int t);Creates and returns a reference, in the table at index
t, for the object at the top of the stack (and pops the object).A reference is a unique integer key. As long as you do not manually add integer keys into table
t,luaL_refensures the uniqueness of the key it returns. You can retrieve an object referred by referencerby callinglua_rawgeti(L, t, r). FunctionluaL_unreffrees a reference and its associated object.If the object at the top of the stack is nil,
luaL_refreturns the constantLUA_REFNIL. The constantLUA_NOREFis guaranteed to be different from any reference returned byluaL_ref.- Specified by:
luaL_refin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointert- the stack index- Returns:
- see description
-
luaL_typename
Description copied from interface:LuaNativesWrapper ofluaL_typename[-0, +0, -]const char *luaL_typename (lua_State *L, int index);Returns the name of the type of the value at the given index.
- Specified by:
luaL_typenamein interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element- Returns:
- see description
-
luaL_unref
public void luaL_unref(long ptr, int t, int ref) Description copied from interface:LuaNativesWrapper ofluaL_unref[-0, +0, -]void luaL_unref (lua_State *L, int t, int ref);Releases reference
reffrom the table at indext(seeluaL_ref). The entry is removed from the table, so that the referred object can be collected. The referencerefis also freed to be used again.If
refisLUA_NOREForLUA_REFNIL,luaL_unrefdoes nothing.- Specified by:
luaL_unrefin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointert- the stack indexref- the reference
-
luaL_where
public void luaL_where(long ptr, int lvl) Description copied from interface:LuaNativesWrapper ofluaL_where[-0, +1, m]void luaL_where (lua_State *L, int lvl);Pushes onto the stack a string identifying the current position of the control at level
lvlin the call stack. Typically this string has the following format:chunkname:currentline:Level 0 is the running function, level 1 is the function that called the running function, etc.
This function is used to build a prefix for error messages.
- Specified by:
luaL_wherein interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerlvl- the running level
-
luaJ_openlib
Description copied from interface:LuaNativesA wrapper functionOpen a library indivisually, alternative to
luaL_openlibs- Specified by:
luaJ_openlibin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerlib- library name
-
luaJ_compare
public int luaJ_compare(long ptr, int index1, int index2, int op) Description copied from interface:LuaNativesA wrapper functionSee
lua_compare- Specified by:
luaJ_comparein interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex1- the stack position of the first elementindex2- the stack position of the second elementop- the operator- Returns:
- see description
-
luaJ_len
public int luaJ_len(long ptr, int index) Description copied from interface:LuaNativesA wrapper functionWrapper of
lua_(obj)len- Specified by:
luaJ_lenin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element- Returns:
- see description
-
luaJ_loadbuffer
Description copied from interface:LuaNativesA wrapper functionLoad a direct buffer
- Specified by:
luaJ_loadbufferin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerbuffer- the buffer (expecting direct)start- the starting indexsize- sizename- the name- Returns:
- see description
-
luaJ_dobuffer
Description copied from interface:LuaNativesA wrapper functionRun a direct buffer
- Specified by:
luaJ_dobufferin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerbuffer- the buffer (expecting direct)start- the starting indexsize- sizename- the name- Returns:
- see description
-
luaJ_resume
public int luaJ_resume(long ptr, int nargs) Description copied from interface:LuaNativesA wrapper functionResume a coroutine
- Specified by:
luaJ_resumein interfaceLuaNatives- Parameters:
ptr- thelua_State*pointernargs- the number of arguments that you pushed onto the stack- Returns:
- see description
-
luaJ_pushobject
Description copied from interface:LuaNativesA wrapper functionPush a Java object
- Specified by:
luaJ_pushobjectin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerobj- the Java object
-
luaJ_pushclass
Description copied from interface:LuaNativesA wrapper functionPush a Java class
- Specified by:
luaJ_pushclassin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerclazz- the Java class
-
luaJ_pusharray
Description copied from interface:LuaNativesA wrapper functionPush a Java array
- Specified by:
luaJ_pusharrayin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerarray- the Java array
-
luaJ_pushfunction
Description copied from interface:LuaNativesA wrapper functionPush a JFunction
- Specified by:
luaJ_pushfunctionin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerfunc- the function object
-
luaJ_pushlstring
Description copied from interface:LuaNativesA wrapper functionPush a buffer as a raw Lua string
- Specified by:
luaJ_pushlstringin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerbuffer- the buffer (expecting direct)start- the starting indexsize- size
-
luaJ_isobject
public int luaJ_isobject(long ptr, int index) Description copied from interface:LuaNativesA wrapper functionIs a Java object (including object, array or class)
- Specified by:
luaJ_isobjectin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element- Returns:
- see description
-
luaJ_toobject
Description copied from interface:LuaNativesA wrapper functionConvert to Java object if it is one
- Specified by:
luaJ_toobjectin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element- Returns:
- see description
-
luaJ_newthread
public long luaJ_newthread(long ptr, int lid) Description copied from interface:LuaNativesA wrapper functionCreate a new thread
- Specified by:
luaJ_newthreadin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerlid- the id of the Lua state, to be used to identify between Java and Lua- Returns:
- see description
-
luaJ_initloader
public int luaJ_initloader(long ptr) Description copied from interface:LuaNativesA wrapper functionAppend a searcher loading from Java side into
package.searchers / loaders- Specified by:
luaJ_initloaderin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointer- Returns:
- see description
-
luaJ_invokespecial
public int luaJ_invokespecial(long ptr, Class clazz, String method, String sig, Object obj, String params) Description copied from interface:LuaNativesA wrapper functionRuns
CallNonvirtual<type>MethodA. See AbstractLua for usages. Parameters should be boxed and pushed on stack.- Specified by:
luaJ_invokespecialin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerclazz- the Java classmethod- the method namesig- the method signature used inGetMethodIDobj- the Java objectparams- encoded parameter types- Returns:
- see description
-
luaJ_removestateindex
public void luaJ_removestateindex(long ptr) Description copied from interface:LuaNativesA wrapper functionRemoves the thread from the global registry, thus allowing it to get garbage collected
- Specified by:
luaJ_removestateindexin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointer
-
luaJ_gc
public void luaJ_gc(long ptr) Description copied from interface:LuaNativesA wrapper functionPerforms a full garbage-collection cycle
- Specified by:
luaJ_gcin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointer
-
luaJ_dumptobuffer
Description copied from interface:LuaNativesWrapper oflua_dump[-0, +0, m]int lua_dump (lua_State *L, lua_Writer writer, void *data);Dumps a function as a binary chunk. Receives a Lua function on the top of the stack and produces a binary chunk that, if loaded again, results in a function equivalent to the one dumped. As it produces parts of the chunk,
lua_dumpcalls function writer (seelua_Writer) with the given data to write them.The value returned is the error code returned by the last call to the writer; 0 means no errors.
This function does not pop the Lua function from the stack.
- Specified by:
luaJ_dumptobufferin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointer- Returns:
- a nullable
ByteBuffercontaining the dumped binary
-
luaJ_tobuffer
Description copied from interface:LuaNativesCreates aByteBufferfrom the string at the specific indexThis method copies the content of the string into a buffer managed by Java, and you are safe to pop the string from Lua stack.
- Specified by:
luaJ_tobufferin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element- Returns:
- a nullable
ByteBuffercontaining the string
-
luaJ_todirectbuffer
Description copied from interface:LuaNativesCreates a directByteBufferbacked by the string at the stack indexThis method creates a buffer that directly accesses the memory managed by Lua. You are not expected to modify the content of the buffer, and the buffer will become invalid after the string.
- Specified by:
luaJ_todirectbufferin interfaceLuaNatives- Parameters:
ptr- thelua_State*pointerindex- the stack position of the element- Returns:
- a nullable
ByteBuffercontaining the string
-