*/
-public abstract class LuaNative {
+public interface LuaNatives {
/**
* Exposes the symbols in the natives to external libraries.
@@ -43,7 +43,7 @@ public abstract class LuaNative {
* Otherwise, the JVM might just crash due to identical symbol names in different binaries.
*
*/
- public abstract void loadAsGlobal();
+ void loadAsGlobal();
/**
* Wrapper of lua_tonumber
@@ -68,12 +68,12 @@ public abstract class LuaNative {
* @param index the stack position of the element
* @return see description
*/
- protected abstract double lua_tonumber(long ptr, int index);
+ double lua_tonumber(long ptr, int index);
/**
* @return the {@code LUA_REGISTRYINDEX} constant, which changes between versions
*/
- protected abstract int getRegistryIndex();
+ int getRegistryIndex();
/**
* Wrapper of lua_checkstack
@@ -95,10 +95,10 @@ public abstract class LuaNative {
*
*
* @param ptr the lua_State* pointer
- * @param extra extra slots
+ * @param n slots
* @return see description
*/
- protected abstract int lua_checkstack(long ptr, int extra);
+ int lua_checkstack(long ptr, int n);
/**
* Wrapper of lua_error
@@ -123,7 +123,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @return see description
*/
- protected abstract int lua_error(long ptr);
+ int lua_error(long ptr);
/**
* Wrapper of lua_gethookcount
@@ -143,7 +143,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @return see description
*/
- protected abstract int lua_gethookcount(long ptr);
+ int lua_gethookcount(long ptr);
/**
* Wrapper of lua_gethookmask
@@ -163,7 +163,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @return see description
*/
- protected abstract int lua_gethookmask(long ptr);
+ int lua_gethookmask(long ptr);
/**
* Wrapper of lua_getmetatable
@@ -188,7 +188,7 @@ public abstract class LuaNative {
* @param index the stack position of the element
* @return see description
*/
- protected abstract int lua_getmetatable(long ptr, int index);
+ int lua_getmetatable(long ptr, int index);
/**
* Wrapper of lua_gettop
@@ -211,7 +211,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @return see description
*/
- protected abstract int lua_gettop(long ptr);
+ int lua_gettop(long ptr);
/**
* Wrapper of lua_isboolean
@@ -233,7 +233,7 @@ public abstract class LuaNative {
* @param index the stack position of the element
* @return see description
*/
- protected abstract int lua_isboolean(long ptr, int index);
+ int lua_isboolean(long ptr, int index);
/**
* Wrapper of lua_iscfunction
@@ -255,7 +255,7 @@ public abstract class LuaNative {
* @param index the stack position of the element
* @return see description
*/
- protected abstract int lua_iscfunction(long ptr, int index);
+ int lua_iscfunction(long ptr, int index);
/**
* Wrapper of lua_isfunction
@@ -277,7 +277,7 @@ public abstract class LuaNative {
* @param index the stack position of the element
* @return see description
*/
- protected abstract int lua_isfunction(long ptr, int index);
+ int lua_isfunction(long ptr, int index);
/**
* Wrapper of lua_islightuserdata
@@ -299,7 +299,7 @@ public abstract class LuaNative {
* @param index the stack position of the element
* @return see description
*/
- protected abstract int lua_islightuserdata(long ptr, int index);
+ int lua_islightuserdata(long ptr, int index);
/**
* Wrapper of lua_isnil
@@ -321,7 +321,7 @@ public abstract class LuaNative {
* @param index the stack position of the element
* @return see description
*/
- protected abstract int lua_isnil(long ptr, int index);
+ int lua_isnil(long ptr, int index);
/**
* Wrapper of lua_isnone
@@ -344,7 +344,7 @@ public abstract class LuaNative {
* @param index the stack position of the element
* @return see description
*/
- protected abstract int lua_isnone(long ptr, int index);
+ int lua_isnone(long ptr, int index);
/**
* Wrapper of lua_isnoneornil
@@ -368,7 +368,7 @@ public abstract class LuaNative {
* @param index the stack position of the element
* @return see description
*/
- protected abstract int lua_isnoneornil(long ptr, int index);
+ int lua_isnoneornil(long ptr, int index);
/**
* Wrapper of lua_isnumber
@@ -391,30 +391,7 @@ public abstract class LuaNative {
* @param index the stack position of the element
* @return see description
*/
- protected abstract int lua_isnumber(long ptr, int index);
-
- /**
- * Wrapper of lua_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.
- *
- *
- * @param ptr the lua_State* pointer
- * @param index the stack position of the element
- * @return see description
- */
- protected abstract int luaJ_isinteger(long ptr, int index);
+ int lua_isnumber(long ptr, int index);
/**
* Wrapper of lua_isstring
@@ -437,7 +414,7 @@ public abstract class LuaNative {
* @param index the stack position of the element
* @return see description
*/
- protected abstract int lua_isstring(long ptr, int index);
+ int lua_isstring(long ptr, int index);
/**
* Wrapper of lua_istable
@@ -459,7 +436,7 @@ public abstract class LuaNative {
* @param index the stack position of the element
* @return see description
*/
- protected abstract int lua_istable(long ptr, int index);
+ int lua_istable(long ptr, int index);
/**
* Wrapper of lua_isthread
@@ -481,7 +458,7 @@ public abstract class LuaNative {
* @param index the stack position of the element
* @return see description
*/
- protected abstract int lua_isthread(long ptr, int index);
+ int lua_isthread(long ptr, int index);
/**
* Wrapper of lua_isuserdata
@@ -503,7 +480,7 @@ public abstract class LuaNative {
* @param index the stack position of the element
* @return see description
*/
- protected abstract int lua_isuserdata(long ptr, int index);
+ int lua_isuserdata(long ptr, int index);
/**
* A wrapper function
@@ -516,7 +493,7 @@ public abstract class LuaNative {
* @param op the operator
* @return see description
*/
- protected abstract int luaJ_compare(long ptr, int index1, int index2, int op);
+ int luaJ_compare(long ptr, int index1, int index2, int op);
/**
* A wrapper function
@@ -529,7 +506,7 @@ public abstract class LuaNative {
* @param name the name
* @return see description
*/
- protected abstract int luaJ_dobuffer(long ptr, Buffer buffer, int size, String name);
+ int luaJ_dobuffer(long ptr, Buffer buffer, int size, String name);
/**
* A wrapper function
@@ -539,7 +516,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @return see description
*/
- protected abstract int luaJ_initloader(long ptr);
+ int luaJ_initloader(long ptr);
/**
* A wrapper function
@@ -558,54 +535,65 @@ public abstract class LuaNative {
* @return see description
*/
@SuppressWarnings("rawtypes")
- protected abstract int luaJ_invokespecial(long ptr, Class clazz, String method, String sig, Object obj, String params);
+ int luaJ_invokespecial(long ptr, Class clazz, String method, String sig, Object obj, String params);
/**
- * A wrapper function
+ * Wrapper of lua_isinteger
*
- *
Is a Java object (including object, array or class)
+ *
+ * [-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.
+ *
*
* @param ptr the lua_State* pointer
* @param index the stack position of the element
* @return see description
*/
- protected abstract int luaJ_isobject(long ptr, int index);
+ int luaJ_isinteger(long ptr, int index);
/**
* A wrapper function
*
- *
Wrapper of lua_(obj)len
+ *
Is a Java object (including object, array or class)
*
* @param ptr the lua_State* pointer
* @param index the stack position of the element
* @return see description
*/
- protected abstract int luaJ_len(long ptr, int index);
+ int luaJ_isobject(long ptr, int index);
/**
* A wrapper function
*
- *
Load a direct buffer
+ *
Wrapper of lua_(obj)len
*
* @param ptr the lua_State* pointer
- * @param buffer the buffer (expecting direct)
- * @param size size
- * @param name the name
+ * @param index the stack position of the element
* @return see description
*/
- protected abstract int luaJ_loadbuffer(long ptr, Buffer buffer, int size, String name);
+ int luaJ_len(long ptr, int index);
/**
* A wrapper function
*
- *
Protected call
+ *
Load a direct buffer
*
* @param ptr the lua_State* pointer
- * @param nargs the number of arguments that you pushed onto the stack
- * @param nresults the number of results, or LUA_MULTRET
+ * @param buffer the buffer (expecting direct)
+ * @param size size
+ * @param name the name
* @return see description
*/
- protected abstract int luaJ_pcall(long ptr, int nargs, int nresults);
+ int luaJ_loadbuffer(long ptr, Buffer buffer, int size, String name);
/**
* A wrapper function
@@ -616,7 +604,7 @@ public abstract class LuaNative {
* @param nargs the number of arguments that you pushed onto the stack
* @return see description
*/
- protected abstract int luaJ_resume(long ptr, int nargs);
+ int luaJ_resume(long ptr, int nargs);
/**
* Wrapper of luaL_callmeta
@@ -648,7 +636,7 @@ public abstract class LuaNative {
* @param e field name
* @return see description
*/
- protected abstract int luaL_callmeta(long ptr, int obj, String e);
+ int luaL_callmeta(long ptr, int obj, String e);
/**
* Wrapper of luaL_dostring
@@ -679,7 +667,7 @@ public abstract class LuaNative {
* @param str string
* @return see description
*/
- protected abstract int luaL_dostring(long ptr, String str);
+ int luaL_dostring(long ptr, String str);
/**
* Wrapper of luaL_getmetafield
@@ -705,7 +693,7 @@ public abstract class LuaNative {
* @param e field name
* @return see description
*/
- protected abstract int luaL_getmetafield(long ptr, int obj, String e);
+ int luaL_getmetafield(long ptr, int obj, String e);
/**
* Wrapper of luaL_loadstring
@@ -737,7 +725,7 @@ public abstract class LuaNative {
* @param s the string
* @return see description
*/
- protected abstract int luaL_loadstring(long ptr, String s);
+ int luaL_loadstring(long ptr, String s);
/**
* Wrapper of luaL_newmetatable
@@ -768,7 +756,7 @@ public abstract class LuaNative {
* @param tname type name
* @return see description
*/
- protected abstract int luaL_newmetatable(long ptr, String tname);
+ int luaL_newmetatable(long ptr, String tname);
/**
* Wrapper of luaL_ref
@@ -807,7 +795,7 @@ public abstract class LuaNative {
* @param t the stack index
* @return see description
*/
- protected abstract int luaL_ref(long ptr, int t);
+ int luaL_ref(long ptr, int t);
/**
* Wrapper of lua_next
@@ -858,7 +846,7 @@ public abstract class LuaNative {
* @param index the stack position of the element
* @return see description
*/
- protected abstract int lua_next(long ptr, int index);
+ int lua_next(long ptr, int index);
/**
* Wrapper of lua_pcall
@@ -872,7 +860,7 @@ public abstract class LuaNative {
*
*
*
- * Calls a function in protected mode.
+ * Calls a function in public mode.
*
*
*
@@ -937,10 +925,10 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @param nargs the number of arguments that you pushed onto the stack
* @param nresults the number of results, or LUA_MULTRET
- * @param errfunc 0 or the stack index of an error handler function
+ * @param msgh 0 or the stack index of an error handler function
* @return see description
*/
- protected abstract int lua_pcall(long ptr, int nargs, int nresults, int errfunc);
+ int lua_pcall(long ptr, int nargs, int nresults, int msgh);
/**
* Wrapper of lua_pushthread
@@ -961,7 +949,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @return see description
*/
- protected abstract int lua_pushthread(long ptr);
+ int lua_pushthread(long ptr);
/**
* Wrapper of lua_rawequal
@@ -987,7 +975,7 @@ public abstract class LuaNative {
* @param index2 the stack position of the second element
* @return see description
*/
- protected abstract int lua_rawequal(long ptr, int index1, int index2);
+ int lua_rawequal(long ptr, int index1, int index2);
/**
* Wrapper of lua_status
@@ -1013,7 +1001,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @return see description
*/
- protected abstract int lua_status(long ptr);
+ int lua_status(long ptr);
/**
* Wrapper of lua_toboolean
@@ -1042,37 +1030,7 @@ public abstract class LuaNative {
* @param index the stack position of the element
* @return see description
*/
- protected abstract int lua_toboolean(long ptr, int index);
-
- /**
- * Wrapper of lua_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_tointeger returns 0.
- *
- *
- *
- * If the number is not an integer,
- * it is truncated in some non-specified way.
- *
- *
- * @param ptr the lua_State* pointer
- * @param index the stack position of the element
- * @return see description
- */
- protected abstract long lua_tointeger(long ptr, int index);
+ int lua_toboolean(long ptr, int index);
/**
* Wrapper of lua_type
@@ -1107,7 +1065,7 @@ public abstract class LuaNative {
* @param index the stack position of the element
* @return see description
*/
- protected abstract int lua_type(long ptr, int index);
+ int lua_type(long ptr, int index);
/**
* Wrapper of lua_yield
@@ -1157,7 +1115,7 @@ public abstract class LuaNative {
* @param nresults the number of results, or LUA_MULTRET
* @return see description
*/
- protected abstract int lua_yield(long ptr, int nresults);
+ int lua_yield(long ptr, int nresults);
/**
* A wrapper function
@@ -1168,7 +1126,7 @@ public abstract class LuaNative {
* @param lid the id of the Lua state, to be used to identify between Java and Lua
* @return see description
*/
- protected abstract long luaJ_newthread(long ptr, int lid);
+ long luaJ_newthread(long ptr, int lid);
/**
* Wrapper of luaL_newstate
@@ -1198,7 +1156,7 @@ public abstract class LuaNative {
* @param lid the id of the Lua state, to be used to identify between Java and Lua
* @return see description
*/
- protected abstract long luaL_newstate(int lid);
+ long luaL_newstate(int lid);
/**
* Wrapper of lua_newthread
@@ -1228,7 +1186,37 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @return see description
*/
- protected abstract long lua_newthread(long ptr);
+ long lua_newthread(long ptr);
+
+ /**
+ * Wrapper of lua_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_tointeger returns 0.
+ *
+ *
+ *
+ * If the number is not an integer,
+ * it is truncated in some non-specified way.
+ *
+ *
+ * @param ptr the lua_State* pointer
+ * @param index the stack position of the element
+ * @return see description
+ */
+ long lua_tointeger(long ptr, int index);
/**
* Wrapper of lua_topointer
@@ -1258,7 +1246,7 @@ public abstract class LuaNative {
* @param index the stack position of the element
* @return see description
*/
- protected abstract long lua_topointer(long ptr, int index);
+ long lua_topointer(long ptr, int index);
/**
* Wrapper of lua_tothread
@@ -1282,7 +1270,7 @@ public abstract class LuaNative {
* @param index the stack position of the element
* @return see description
*/
- protected abstract long lua_tothread(long ptr, int index);
+ long lua_tothread(long ptr, int index);
/**
* Wrapper of lua_touserdata
@@ -1307,7 +1295,7 @@ public abstract class LuaNative {
* @param index the stack position of the element
* @return see description
*/
- protected abstract long lua_touserdata(long ptr, int index);
+ long lua_touserdata(long ptr, int index);
/**
* Wrapper of lua_dump
@@ -1343,7 +1331,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @return a nullable {@link java.nio.ByteBuffer} containing the dumped binary
*/
- protected abstract Object luaJ_dumptobuffer(long ptr);
+ Object luaJ_dumptobuffer(long ptr);
/**
* Creates a {@link java.nio.ByteBuffer} from the string at the specific index
@@ -1357,7 +1345,7 @@ public abstract class LuaNative {
* @param index the stack position of the element
* @return a nullable {@link java.nio.ByteBuffer} containing the string
*/
- protected abstract Object luaJ_tobuffer(long ptr, int index);
+ Object luaJ_tobuffer(long ptr, int index);
/**
* Creates a direct {@link java.nio.ByteBuffer} backed by the string at the stack index
@@ -1372,7 +1360,7 @@ public abstract class LuaNative {
* @param index the stack position of the element
* @return a nullable {@link java.nio.ByteBuffer} containing the string
*/
- protected abstract Object luaJ_todirectbuffer(long ptr, int index);
+ Object luaJ_todirectbuffer(long ptr, int index);
/**
* A wrapper function
@@ -1383,7 +1371,7 @@ public abstract class LuaNative {
* @param index the stack position of the element
* @return see description
*/
- protected abstract Object luaJ_toobject(long ptr, int index);
+ Object luaJ_toobject(long ptr, int index);
/**
* Wrapper of lua_getupvalue
@@ -1422,36 +1410,7 @@ public abstract class LuaNative {
* @param n the index in the upvalue
* @return see description
*/
- protected abstract String lua_getupvalue(long ptr, int funcindex, int n);
-
- /**
- * Wrapper of luaL_gsub
- *
- *
- * Creates a copy of string s by replacing
- * any occurrence of the string p
- * with the string r.
- * Pushes the resulting string on the stack and returns it.
- *
- *
- * @param ptr the lua_State* pointer
- * @param s the string
- * @param p the replaced sequence
- * @param r the replacing string
- * @return see description
- */
- protected abstract String luaL_gsub(long ptr, String s, String p, String r);
+ String lua_getupvalue(long ptr, int funcindex, int n);
/**
* Wrapper of luaL_typename
@@ -1472,7 +1431,7 @@ public abstract class LuaNative {
* @param index the stack position of the element
* @return see description
*/
- protected abstract String luaL_typename(long ptr, int index);
+ String luaL_typename(long ptr, int index);
/**
* Wrapper of lua_setupvalue
@@ -1504,7 +1463,7 @@ public abstract class LuaNative {
* @param n the index in the upvalue
* @return see description
*/
- protected abstract String lua_setupvalue(long ptr, int funcindex, int n);
+ String lua_setupvalue(long ptr, int funcindex, int n);
/**
* Wrapper of lua_tostring
@@ -1525,7 +1484,7 @@ public abstract class LuaNative {
* @param index the stack position of the element
* @return see description
*/
- protected abstract String lua_tostring(long ptr, int index);
+ String lua_tostring(long ptr, int index);
/**
* Wrapper of lua_typename
@@ -1547,7 +1506,7 @@ public abstract class LuaNative {
* @param tp type id
* @return see description
*/
- protected abstract String lua_typename(long ptr, int tp);
+ String lua_typename(long ptr, int tp);
/**
* Wrapper of lua_close
@@ -1574,7 +1533,7 @@ public abstract class LuaNative {
*
* @param ptr the lua_State* pointer
*/
- protected abstract void lua_close(long ptr);
+ void lua_close(long ptr);
/**
* Wrapper of lua_concat
@@ -1600,7 +1559,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @param n the number of elements
*/
- protected abstract void lua_concat(long ptr, int n);
+ void lua_concat(long ptr, int n);
/**
* Wrapper of lua_createtable
@@ -1626,7 +1585,7 @@ public abstract class LuaNative {
* @param narr the number of pre-allocated array elements
* @param nrec the number of pre-allocated non-array elements
*/
- protected abstract void lua_createtable(long ptr, int narr, int nrec);
+ void lua_createtable(long ptr, int narr, int nrec);
/**
* Wrapper of lua_insert
@@ -1649,7 +1608,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @param index the stack position of the element
*/
- protected abstract void lua_insert(long ptr, int index);
+ void lua_insert(long ptr, int index);
/**
* A wrapper function
@@ -1660,7 +1619,7 @@ public abstract class LuaNative {
*
* @param ptr the lua_State* pointer
*/
- protected abstract void luaJ_gc(long ptr);
+ void luaJ_gc(long ptr);
/**
* Wrapper of lua_getfield
@@ -1684,7 +1643,7 @@ public abstract class LuaNative {
* @param index the stack position of the element
* @param k the field name
*/
- protected abstract void luaJ_getfield(long ptr, int index, String k);
+ void luaJ_getfield(long ptr, int index, String k);
/**
* Wrapper of lua_getglobal
@@ -1709,7 +1668,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @param name the name
*/
- protected abstract void luaJ_getglobal(long ptr, String name);
+ void luaJ_getglobal(long ptr, String name);
/**
* Wrapper of luaL_getmetatable
@@ -1730,7 +1689,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @param tname type name
*/
- protected abstract void luaJ_getmetatable(long ptr, String tname);
+ void luaJ_getmetatable(long ptr, String tname);
/**
* Wrapper of lua_gettable
@@ -1759,7 +1718,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @param index the stack position of the element
*/
- protected abstract void luaJ_gettable(long ptr, int index);
+ void luaJ_gettable(long ptr, int index);
/**
* Wrapper of luaL_newmetatable
@@ -1789,7 +1748,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @param tname type name
*/
- protected abstract void luaJ_newmetatable(long ptr, String tname);
+ void luaJ_newmetatable(long ptr, String tname);
/**
* A wrapper function
@@ -1799,88 +1758,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @param lib library name
*/
- protected abstract void luaJ_openlib(long ptr, String lib);
-
- /**
- * Wrapper of lua_pcall
- *
- *
- * [-(nargs + 1), +(nresults|1), -]
- *
- *
- *
- * int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc);
- *
- *
- *
- * Calls a function in protected mode.
- *
- *
- *
- * 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_ERRMEM:
- * memory allocation error.
- * For such errors, Lua does not call the error handler function.
- *
- *
- *
- * LUA_ERRERR:
- * error while running the error handler function.
- *
- *
- *
- *
- * @param ptr the lua_State* pointer
- * @param nargs the number of arguments that you pushed onto the stack
- * @param nresults the number of results, or LUA_MULTRET
- * @param errfunc 0 or the stack index of an error handler function
- */
- protected abstract void luaJ_pcall(long ptr, int nargs, int nresults, int errfunc);
+ void luaJ_openlib(long ptr, String lib);
/**
* A wrapper function
@@ -1890,7 +1768,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @param array the Java array
*/
- protected abstract void luaJ_pusharray(long ptr, Object array);
+ void luaJ_pusharray(long ptr, Object array);
/**
* A wrapper function
@@ -1900,7 +1778,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @param clazz the Java class
*/
- protected abstract void luaJ_pushclass(long ptr, Object clazz);
+ void luaJ_pushclass(long ptr, Object clazz);
/**
* A wrapper function
@@ -1910,7 +1788,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @param func the function object
*/
- protected abstract void luaJ_pushfunction(long ptr, Object func);
+ void luaJ_pushfunction(long ptr, Object func);
/**
* A wrapper function
@@ -1920,7 +1798,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @param obj the Java object
*/
- protected abstract void luaJ_pushobject(long ptr, Object obj);
+ void luaJ_pushobject(long ptr, Object obj);
/**
* Wrapper of lua_pushstring
@@ -1946,7 +1824,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @param s the string
*/
- protected abstract void luaJ_pushstring(long ptr, String s);
+ void luaJ_pushstring(long ptr, String s);
/**
* Wrapper of lua_rawget
@@ -1967,7 +1845,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @param index the stack position of the element
*/
- protected abstract void luaJ_rawget(long ptr, int index);
+ void luaJ_rawget(long ptr, int index);
/**
* Wrapper of lua_rawgeti
@@ -1991,7 +1869,7 @@ public abstract class LuaNative {
* @param index the stack position of the element
* @param n the number of elements
*/
- protected abstract void luaJ_rawgeti(long ptr, int index, int n);
+ void luaJ_rawgeti(long ptr, int index, int n);
/**
* A wrapper function
@@ -2002,7 +1880,7 @@ public abstract class LuaNative {
*
* @param ptr the lua_State* pointer
*/
- protected abstract void luaJ_removestateindex(long ptr);
+ void luaJ_removestateindex(long ptr);
/**
* Wrapper of lua_setmetatable
@@ -2024,7 +1902,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @param index the stack position of the element
*/
- protected abstract void luaJ_setmetatable(long ptr, int index);
+ void luaJ_setmetatable(long ptr, int index);
/**
* Wrapper of luaL_openlibs
@@ -2043,7 +1921,7 @@ public abstract class LuaNative {
*
* @param ptr the lua_State* pointer
*/
- protected abstract void luaL_openlibs(long ptr);
+ void luaL_openlibs(long ptr);
/**
* Wrapper of luaL_unref
@@ -2073,7 +1951,7 @@ public abstract class LuaNative {
* @param t the stack index
* @param ref the reference
*/
- protected abstract void luaL_unref(long ptr, int t, int ref);
+ void luaL_unref(long ptr, int t, int ref);
/**
* Wrapper of luaL_where
@@ -2109,7 +1987,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @param lvl the running level
*/
- protected abstract void luaL_where(long ptr, int lvl);
+ void luaL_where(long ptr, int lvl);
/**
* Wrapper of lua_newtable
@@ -2129,7 +2007,7 @@ public abstract class LuaNative {
*
* @param ptr the lua_State* pointer
*/
- protected abstract void lua_newtable(long ptr);
+ void lua_newtable(long ptr);
/**
* Wrapper of lua_pop
@@ -2149,7 +2027,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @param n the number of elements
*/
- protected abstract void lua_pop(long ptr, int n);
+ void lua_pop(long ptr, int n);
/**
* Wrapper of lua_pushboolean
@@ -2169,7 +2047,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @param b boolean
*/
- protected abstract void lua_pushboolean(long ptr, int b);
+ void lua_pushboolean(long ptr, int b);
/**
* Wrapper of lua_pushinteger
@@ -2187,9 +2065,9 @@ public abstract class LuaNative {
*
*
* @param ptr the lua_State* pointer
- * @param i integer
+ * @param n integer
*/
- protected abstract void lua_pushinteger(long ptr, long i);
+ void lua_pushinteger(long ptr, long n);
/**
* Wrapper of lua_pushlightuserdata
@@ -2219,7 +2097,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @param p the pointer
*/
- protected abstract void lua_pushlightuserdata(long ptr, long p);
+ void lua_pushlightuserdata(long ptr, long p);
/**
* Wrapper of lua_pushnil
@@ -2238,7 +2116,7 @@ public abstract class LuaNative {
*
* @param ptr the lua_State* pointer
*/
- protected abstract void lua_pushnil(long ptr);
+ void lua_pushnil(long ptr);
/**
* Wrapper of lua_pushnumber
@@ -2258,7 +2136,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @param n the number of elements
*/
- protected abstract void lua_pushnumber(long ptr, double n);
+ void lua_pushnumber(long ptr, double n);
/**
* Wrapper of lua_pushvalue
@@ -2279,7 +2157,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @param index the stack position of the element
*/
- protected abstract void lua_pushvalue(long ptr, int index);
+ void lua_pushvalue(long ptr, int index);
/**
* Wrapper of lua_rawset
@@ -2300,7 +2178,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @param index the stack position of the element
*/
- protected abstract void lua_rawset(long ptr, int index);
+ void lua_rawset(long ptr, int index);
/**
* Wrapper of lua_rawseti
@@ -2327,9 +2205,9 @@ public abstract class LuaNative {
*
* @param ptr the lua_State* pointer
* @param index the stack position of the element
- * @param n the number of elements
+ * @param i the index
*/
- protected abstract void lua_rawseti(long ptr, int index, int n);
+ void lua_rawseti(long ptr, int index, int i);
/**
* Wrapper of lua_remove
@@ -2352,7 +2230,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @param index the stack position of the element
*/
- protected abstract void lua_remove(long ptr, int index);
+ void lua_remove(long ptr, int index);
/**
* Wrapper of lua_replace
@@ -2374,7 +2252,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @param index the stack position of the element
*/
- protected abstract void lua_replace(long ptr, int index);
+ void lua_replace(long ptr, int index);
/**
* Wrapper of lua_setfield
@@ -2403,7 +2281,7 @@ public abstract class LuaNative {
* @param index the stack position of the element
* @param k the field name
*/
- protected abstract void lua_setfield(long ptr, int index, String k);
+ void lua_setfield(long ptr, int index, String k);
/**
* Wrapper of lua_setglobal
@@ -2429,7 +2307,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @param name the name
*/
- protected abstract void lua_setglobal(long ptr, String name);
+ void lua_setglobal(long ptr, String name);
/**
* Wrapper of lua_settable
@@ -2458,7 +2336,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @param index the stack position of the element
*/
- protected abstract void lua_settable(long ptr, int index);
+ void lua_settable(long ptr, int index);
/**
* Wrapper of lua_settop
@@ -2482,7 +2360,7 @@ public abstract class LuaNative {
* @param ptr the lua_State* pointer
* @param index the stack position of the element
*/
- protected abstract void lua_settop(long ptr, int index);
+ void lua_settop(long ptr, int index);
/**
* Wrapper of lua_xmove
@@ -2508,5 +2386,6 @@ public abstract class LuaNative {
* @param to another thread
* @param n the number of elements
*/
- protected abstract void lua_xmove(long from, long to, int n);
+ void lua_xmove(long from, long to, int n);
+
}
diff --git a/luajava/src/main/java/party/iroiro/luajava/util/GlobalLibraryLoader.java b/luajava/src/main/java/party/iroiro/luajava/util/GlobalLibraryLoader.java
index 382332dc..df660f0b 100644
--- a/luajava/src/main/java/party/iroiro/luajava/util/GlobalLibraryLoader.java
+++ b/luajava/src/main/java/party/iroiro/luajava/util/GlobalLibraryLoader.java
@@ -2,7 +2,7 @@
import com.badlogic.gdx.utils.SharedLibraryLoadRuntimeException;
import com.badlogic.gdx.utils.SharedLibraryLoader;
-import party.iroiro.luajava.LuaNative;
+import party.iroiro.luajava.LuaNatives;
import java.io.File;
import java.io.FileInputStream;
@@ -41,7 +41,7 @@
*/
public class GlobalLibraryLoader {
private final static SharedLibraryLoader loader = new SharedLibraryLoader();
- private static volatile Class extends LuaNative> loadedNatives = null;
+ private static volatile Class extends LuaNatives> loadedNatives = null;
private static volatile int nativesLoaded = 0;
private static InputStream readFile(String path) {
@@ -99,7 +99,7 @@ public static String load(String libraryName) {
* @param natives the natives to be loaded
* @param global whether the natives are
*/
- public synchronized static void register(Class extends LuaNative> natives, boolean global) {
+ public synchronized static void register(Class extends LuaNatives> natives, boolean global) {
if (loadedNatives == null && nativesLoaded == 0) {
loadedNatives = natives;
nativesLoaded = global ? 0 : 1;
diff --git a/luajit/jni/mod/luacomp.h b/luajit/jni/mod/luacomp.h
index 1eb6ca08..92e4aea2 100644
--- a/luajit/jni/mod/luacomp.h
+++ b/luajit/jni/mod/luacomp.h
@@ -58,10 +58,6 @@ static int luaJ_dobuffer(lua_State * L, unsigned char * buffer, int size, const
return (luaL_loadbuffer(L, (const char *) buffer, size, name) || lua_pcall(L, 0, LUA_MULTRET, 0));
}
-static int luaJ_pcall(lua_State * L, int nargs, int nresults) {
- return lua_pcall(L, nargs, nresults, 0);
-}
-
static int luaJ_resume(lua_State * L, int narg) {
return lua_resume(L, narg);
}
diff --git a/luajit/src/main/java/party/iroiro/luajava/luajit/LuaJit.java b/luajit/src/main/java/party/iroiro/luajava/luajit/LuaJit.java
index 8b82293a..c9bf2f20 100644
--- a/luajit/src/main/java/party/iroiro/luajava/luajit/LuaJit.java
+++ b/luajit/src/main/java/party/iroiro/luajava/luajit/LuaJit.java
@@ -25,7 +25,7 @@
import party.iroiro.luajava.AbstractLua;
import party.iroiro.luajava.LuaException;
import party.iroiro.luajava.LuaException.LuaError;
-import party.iroiro.luajava.LuaNative;
+import party.iroiro.luajava.LuaNatives;
import java.util.concurrent.atomic.AtomicReference;
@@ -50,7 +50,7 @@ protected LuaJit(long L, int id, AbstractLua main) {
super(main.getLuaNative(), L, id, main);
}
- private static LuaNative getNatives() throws LinkageError {
+ private static LuaNatives getNatives() throws LinkageError {
synchronized (natives) {
if (natives.get() == null) {
try {
diff --git a/luajit/src/main/java/party/iroiro/luajava/luajit/LuaJitNatives.java b/luajit/src/main/java/party/iroiro/luajava/luajit/LuaJitNatives.java
index 2db8245f..ac99d823 100644
--- a/luajit/src/main/java/party/iroiro/luajava/luajit/LuaJitNatives.java
+++ b/luajit/src/main/java/party/iroiro/luajava/luajit/LuaJitNatives.java
@@ -25,7 +25,7 @@
import java.util.concurrent.atomic.AtomicReference;
import java.nio.Buffer;
-import party.iroiro.luajava.LuaNative;
+import party.iroiro.luajava.LuaNatives;
import party.iroiro.luajava.util.GlobalLibraryLoader;
/**
@@ -95,7 +95,7 @@
*
*/
@SuppressWarnings({"unused", "rawtypes"})
-public class LuaJitNatives extends LuaNative {
+public class LuaJitNatives implements LuaNatives {
/*JNI
#include "luacustomamalg.h"
@@ -155,7 +155,7 @@ public void loadAsGlobal() {
/**
* Get LUA_REGISTRYINDEX, which is a computed compile time constant
*/
- protected native int getRegistryIndex(); /*
+ public native int getRegistryIndex(); /*
return LUA_REGISTRYINDEX;
*/
@@ -182,7 +182,7 @@ public void loadAsGlobal() {
* @param extra extra slots
* @return see description
*/
- protected native int lua_checkstack(long ptr, int extra); /*
+ public native int lua_checkstack(long ptr, int extra); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) lua_checkstack((lua_State *) L, (int) extra);
@@ -215,7 +215,7 @@ public void loadAsGlobal() {
*
* @param ptr the lua_State* pointer
*/
- protected native void lua_close(long ptr); /*
+ public native void lua_close(long ptr); /*
lua_State * L = (lua_State *) ptr;
lua_close((lua_State *) L);
@@ -246,7 +246,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @param n the number of elements
*/
- protected native void lua_concat(long ptr, int n); /*
+ public native void lua_concat(long ptr, int n); /*
lua_State * L = (lua_State *) ptr;
lua_concat((lua_State *) L, (int) n);
@@ -277,7 +277,7 @@ public void loadAsGlobal() {
* @param narr the number of pre-allocated array elements
* @param nrec the number of pre-allocated non-array elements
*/
- protected native void lua_createtable(long ptr, int narr, int nrec); /*
+ public native void lua_createtable(long ptr, int narr, int nrec); /*
lua_State * L = (lua_State *) ptr;
lua_createtable((lua_State *) L, (int) narr, (int) nrec);
@@ -309,7 +309,7 @@ public void loadAsGlobal() {
* @param index2 the stack position of the second element
* @return see description
*/
- protected native int lua_equal(long ptr, int index1, int index2); /*
+ public native int lua_equal(long ptr, int index1, int index2); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) lua_equal((lua_State *) L, (int) index1, (int) index2);
@@ -340,7 +340,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @return see description
*/
- protected native int lua_error(long ptr); /*
+ public native int lua_error(long ptr); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) lua_error((lua_State *) L);
@@ -428,7 +428,7 @@ public void loadAsGlobal() {
* @param data data
* @return see description
*/
- protected native int lua_gc(long ptr, int what, int data); /*
+ public native int lua_gc(long ptr, int what, int data); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) lua_gc((lua_State *) L, (int) what, (int) data);
@@ -455,7 +455,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @param index the stack position of the element
*/
- protected native void lua_getfenv(long ptr, int index); /*
+ public native void lua_getfenv(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
lua_getfenv((lua_State *) L, (int) index);
@@ -484,7 +484,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @param k the field name
*/
- protected native void lua_getfield(long ptr, int index, String k); /*
+ public native void lua_getfield(long ptr, int index, String k); /*
lua_State * L = (lua_State *) ptr;
lua_getfield((lua_State *) L, (int) index, (const char *) k);
@@ -513,7 +513,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @param k the field name
*/
- protected native void luaJ_getfield(long ptr, int index, String k); /*
+ public native void luaJ_getfield(long ptr, int index, String k); /*
lua_State * L = (lua_State *) ptr;
lua_getfield((lua_State *) L, (int) index, (const char *) k);
@@ -543,7 +543,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @param name the name
*/
- protected native void lua_getglobal(long ptr, String name); /*
+ public native void lua_getglobal(long ptr, String name); /*
lua_State * L = (lua_State *) ptr;
lua_getglobal((lua_State *) L, (const char *) name);
@@ -573,7 +573,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @param name the name
*/
- protected native void luaJ_getglobal(long ptr, String name); /*
+ public native void luaJ_getglobal(long ptr, String name); /*
lua_State * L = (lua_State *) ptr;
lua_getglobal((lua_State *) L, (const char *) name);
@@ -603,7 +603,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @return see description
*/
- protected native int lua_getmetatable(long ptr, int index); /*
+ public native int lua_getmetatable(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) lua_getmetatable((lua_State *) L, (int) index);
@@ -638,7 +638,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @param index the stack position of the element
*/
- protected native void lua_gettable(long ptr, int index); /*
+ public native void lua_gettable(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
lua_gettable((lua_State *) L, (int) index);
@@ -672,7 +672,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @param index the stack position of the element
*/
- protected native void luaJ_gettable(long ptr, int index); /*
+ public native void luaJ_gettable(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
lua_gettable((lua_State *) L, (int) index);
@@ -700,7 +700,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @return see description
*/
- protected native int lua_gettop(long ptr); /*
+ public native int lua_gettop(long ptr); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) lua_gettop((lua_State *) L);
@@ -729,7 +729,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @param index the stack position of the element
*/
- protected native void lua_insert(long ptr, int index); /*
+ public native void lua_insert(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
lua_insert((lua_State *) L, (int) index);
@@ -756,7 +756,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @return see description
*/
- protected native int lua_isboolean(long ptr, int index); /*
+ public native int lua_isboolean(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) lua_isboolean((lua_State *) L, (int) index);
@@ -784,7 +784,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @return see description
*/
- protected native int lua_iscfunction(long ptr, int index); /*
+ public native int lua_iscfunction(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) lua_iscfunction((lua_State *) L, (int) index);
@@ -812,7 +812,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @return see description
*/
- protected native int lua_isfunction(long ptr, int index); /*
+ public native int lua_isfunction(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) lua_isfunction((lua_State *) L, (int) index);
@@ -840,7 +840,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @return see description
*/
- protected native int lua_islightuserdata(long ptr, int index); /*
+ public native int lua_islightuserdata(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) lua_islightuserdata((lua_State *) L, (int) index);
@@ -868,7 +868,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @return see description
*/
- protected native int lua_isnil(long ptr, int index); /*
+ public native int lua_isnil(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) lua_isnil((lua_State *) L, (int) index);
@@ -897,7 +897,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @return see description
*/
- protected native int lua_isnone(long ptr, int index); /*
+ public native int lua_isnone(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) lua_isnone((lua_State *) L, (int) index);
@@ -927,7 +927,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @return see description
*/
- protected native int lua_isnoneornil(long ptr, int index); /*
+ public native int lua_isnoneornil(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) lua_isnoneornil((lua_State *) L, (int) index);
@@ -956,7 +956,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @return see description
*/
- protected native int lua_isnumber(long ptr, int index); /*
+ public native int lua_isnumber(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) lua_isnumber((lua_State *) L, (int) index);
@@ -985,7 +985,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @return see description
*/
- protected native int lua_isstring(long ptr, int index); /*
+ public native int lua_isstring(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) lua_isstring((lua_State *) L, (int) index);
@@ -1013,7 +1013,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @return see description
*/
- protected native int lua_istable(long ptr, int index); /*
+ public native int lua_istable(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) lua_istable((lua_State *) L, (int) index);
@@ -1041,7 +1041,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @return see description
*/
- protected native int lua_isthread(long ptr, int index); /*
+ public native int lua_isthread(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) lua_isthread((lua_State *) L, (int) index);
@@ -1069,7 +1069,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @return see description
*/
- protected native int lua_isuserdata(long ptr, int index); /*
+ public native int lua_isuserdata(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) lua_isuserdata((lua_State *) L, (int) index);
@@ -1102,7 +1102,7 @@ public void loadAsGlobal() {
* @param index2 the stack position of the second element
* @return see description
*/
- protected native int lua_lessthan(long ptr, int index1, int index2); /*
+ public native int lua_lessthan(long ptr, int index1, int index2); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) lua_lessthan((lua_State *) L, (int) index1, (int) index2);
@@ -1128,7 +1128,7 @@ public void loadAsGlobal() {
*
* @param ptr the lua_State* pointer
*/
- protected native void lua_newtable(long ptr); /*
+ public native void lua_newtable(long ptr); /*
lua_State * L = (lua_State *) ptr;
lua_newtable((lua_State *) L);
@@ -1163,7 +1163,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @return see description
*/
- protected native long lua_newthread(long ptr); /*
+ public native long lua_newthread(long ptr); /*
lua_State * L = (lua_State *) ptr;
jlong returnValueReceiver = (jlong) lua_newthread((lua_State *) L);
@@ -1208,7 +1208,7 @@ public void loadAsGlobal() {
* @param size size
* @return see description
*/
- protected native long lua_newuserdata(long ptr, long size); /*
+ public native long lua_newuserdata(long ptr, long size); /*
lua_State * L = (lua_State *) ptr;
jlong returnValueReceiver = (jlong) lua_newuserdata((lua_State *) L, (size_t) size);
@@ -1265,7 +1265,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @return see description
*/
- protected native int lua_next(long ptr, int index); /*
+ public native int lua_next(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) lua_next((lua_State *) L, (int) index);
@@ -1297,7 +1297,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @return see description
*/
- protected native long lua_objlen(long ptr, int index); /*
+ public native long lua_objlen(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
jlong returnValueReceiver = (jlong) lua_objlen((lua_State *) L, (int) index);
@@ -1385,7 +1385,7 @@ public void loadAsGlobal() {
* @param errfunc 0 or the stack index of an error handler function
* @return see description
*/
- protected native int lua_pcall(long ptr, int nargs, int nresults, int errfunc); /*
+ public native int lua_pcall(long ptr, int nargs, int nresults, int errfunc); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) lua_pcall((lua_State *) L, (int) nargs, (int) nresults, (int) errfunc);
@@ -1393,92 +1393,6 @@ public void loadAsGlobal() {
*/
- /**
- * Wrapper of lua_pcall
- *
- *
- * [-(nargs + 1), +(nresults|1), -]
- *
- *
- *
- * int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc);
- *
- *
- *
- * Calls a function in protected mode.
- *
- *
- *
- * 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_ERRMEM:
- * memory allocation error.
- * For such errors, Lua does not call the error handler function.
- *
- *
- *
- * LUA_ERRERR:
- * error while running the error handler function.
- *
- *
- *
- *
- * @param ptr the lua_State* pointer
- * @param nargs the number of arguments that you pushed onto the stack
- * @param nresults the number of results, or LUA_MULTRET
- * @param errfunc 0 or the stack index of an error handler function
- */
- protected native void luaJ_pcall(long ptr, int nargs, int nresults, int errfunc); /*
- lua_State * L = (lua_State *) ptr;
-
- lua_pcall((lua_State *) L, (int) nargs, (int) nresults, (int) errfunc);
- */
-
-
/**
* Wrapper of lua_pop
*
@@ -1497,7 +1411,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @param n the number of elements
*/
- protected native void lua_pop(long ptr, int n); /*
+ public native void lua_pop(long ptr, int n); /*
lua_State * L = (lua_State *) ptr;
lua_pop((lua_State *) L, (int) n);
@@ -1522,7 +1436,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @param b boolean
*/
- protected native void lua_pushboolean(long ptr, int b); /*
+ public native void lua_pushboolean(long ptr, int b); /*
lua_State * L = (lua_State *) ptr;
lua_pushboolean((lua_State *) L, (int) b);
@@ -1547,7 +1461,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @param n the number / the number of elements
*/
- protected native void lua_pushinteger(long ptr, long n); /*
+ public native void lua_pushinteger(long ptr, long n); /*
lua_State * L = (lua_State *) ptr;
// What we want to achieve here is:
// Pushing any Java number (long or double) always results in an approximated number on the stack,
@@ -1596,7 +1510,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @param p the pointer
*/
- protected native void lua_pushlightuserdata(long ptr, long p); /*
+ public native void lua_pushlightuserdata(long ptr, long p); /*
lua_State * L = (lua_State *) ptr;
lua_pushlightuserdata((lua_State *) L, (void *) p);
@@ -1620,7 +1534,7 @@ public void loadAsGlobal() {
*
* @param ptr the lua_State* pointer
*/
- protected native void lua_pushnil(long ptr); /*
+ public native void lua_pushnil(long ptr); /*
lua_State * L = (lua_State *) ptr;
lua_pushnil((lua_State *) L);
@@ -1645,7 +1559,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @param n the number / the number of elements
*/
- protected native void lua_pushnumber(long ptr, double n); /*
+ public native void lua_pushnumber(long ptr, double n); /*
lua_State * L = (lua_State *) ptr;
lua_pushnumber((lua_State *) L, (lua_Number) n);
@@ -1676,7 +1590,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @param s the string
*/
- protected native void lua_pushstring(long ptr, String s); /*
+ public native void lua_pushstring(long ptr, String s); /*
lua_State * L = (lua_State *) ptr;
lua_pushstring((lua_State *) L, (const char *) s);
@@ -1707,7 +1621,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @param s the string
*/
- protected native void luaJ_pushstring(long ptr, String s); /*
+ public native void luaJ_pushstring(long ptr, String s); /*
lua_State * L = (lua_State *) ptr;
lua_pushstring((lua_State *) L, (const char *) s);
@@ -1733,7 +1647,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @return see description
*/
- protected native int lua_pushthread(long ptr); /*
+ public native int lua_pushthread(long ptr); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) lua_pushthread((lua_State *) L);
@@ -1760,7 +1674,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @param index the stack position of the element
*/
- protected native void lua_pushvalue(long ptr, int index); /*
+ public native void lua_pushvalue(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
lua_pushvalue((lua_State *) L, (int) index);
@@ -1791,7 +1705,7 @@ public void loadAsGlobal() {
* @param index2 the stack position of the second element
* @return see description
*/
- protected native int lua_rawequal(long ptr, int index1, int index2); /*
+ public native int lua_rawequal(long ptr, int index1, int index2); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) lua_rawequal((lua_State *) L, (int) index1, (int) index2);
@@ -1818,7 +1732,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @param index the stack position of the element
*/
- protected native void lua_rawget(long ptr, int index); /*
+ public native void lua_rawget(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
lua_rawget((lua_State *) L, (int) index);
@@ -1844,7 +1758,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @param index the stack position of the element
*/
- protected native void luaJ_rawget(long ptr, int index); /*
+ public native void luaJ_rawget(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
lua_rawget((lua_State *) L, (int) index);
@@ -1873,7 +1787,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @param n the number of elements
*/
- protected native void lua_rawgeti(long ptr, int index, int n); /*
+ public native void lua_rawgeti(long ptr, int index, int n); /*
lua_State * L = (lua_State *) ptr;
lua_rawgeti((lua_State *) L, (int) index, (int) n);
@@ -1902,7 +1816,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @param n the number of elements
*/
- protected native void luaJ_rawgeti(long ptr, int index, int n); /*
+ public native void luaJ_rawgeti(long ptr, int index, int n); /*
lua_State * L = (lua_State *) ptr;
lua_rawgeti((lua_State *) L, (int) index, (int) n);
@@ -1928,7 +1842,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @param index the stack position of the element
*/
- protected native void lua_rawset(long ptr, int index); /*
+ public native void lua_rawset(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
lua_rawset((lua_State *) L, (int) index);
@@ -1962,7 +1876,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @param n the number of elements
*/
- protected native void lua_rawseti(long ptr, int index, int n); /*
+ public native void lua_rawseti(long ptr, int index, int n); /*
lua_State * L = (lua_State *) ptr;
lua_rawseti((lua_State *) L, (int) index, (int) n);
@@ -1990,7 +1904,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @param index the stack position of the element
*/
- protected native void lua_remove(long ptr, int index); /*
+ public native void lua_remove(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
lua_remove((lua_State *) L, (int) index);
@@ -2017,7 +1931,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @param index the stack position of the element
*/
- protected native void lua_replace(long ptr, int index); /*
+ public native void lua_replace(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
lua_replace((lua_State *) L, (int) index);
@@ -2066,7 +1980,7 @@ public void loadAsGlobal() {
* @param narg the number of arguments
* @return see description
*/
- protected native int lua_resume(long ptr, int narg); /*
+ public native int lua_resume(long ptr, int narg); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) lua_resume((lua_State *) L, (int) narg);
@@ -2098,7 +2012,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @return see description
*/
- protected native int lua_setfenv(long ptr, int index); /*
+ public native int lua_setfenv(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) lua_setfenv((lua_State *) L, (int) index);
@@ -2133,7 +2047,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @param k the field name
*/
- protected native void lua_setfield(long ptr, int index, String k); /*
+ public native void lua_setfield(long ptr, int index, String k); /*
lua_State * L = (lua_State *) ptr;
lua_setfield((lua_State *) L, (int) index, (const char *) k);
@@ -2164,7 +2078,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @param name the name
*/
- protected native void lua_setglobal(long ptr, String name); /*
+ public native void lua_setglobal(long ptr, String name); /*
lua_State * L = (lua_State *) ptr;
lua_setglobal((lua_State *) L, (const char *) name);
@@ -2192,7 +2106,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @return see description
*/
- protected native int lua_setmetatable(long ptr, int index); /*
+ public native int lua_setmetatable(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) lua_setmetatable((lua_State *) L, (int) index);
@@ -2220,7 +2134,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @param index the stack position of the element
*/
- protected native void luaJ_setmetatable(long ptr, int index); /*
+ public native void luaJ_setmetatable(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
lua_setmetatable((lua_State *) L, (int) index);
@@ -2254,7 +2168,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @param index the stack position of the element
*/
- protected native void lua_settable(long ptr, int index); /*
+ public native void lua_settable(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
lua_settable((lua_State *) L, (int) index);
@@ -2283,7 +2197,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @param index the stack position of the element
*/
- protected native void lua_settop(long ptr, int index); /*
+ public native void lua_settop(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
lua_settop((lua_State *) L, (int) index);
@@ -2314,7 +2228,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @return see description
*/
- protected native int lua_status(long ptr); /*
+ public native int lua_status(long ptr); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) lua_status((lua_State *) L);
@@ -2349,7 +2263,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @return see description
*/
- protected native int lua_toboolean(long ptr, int index); /*
+ public native int lua_toboolean(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) lua_toboolean((lua_State *) L, (int) index);
@@ -2385,7 +2299,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @return see description
*/
- protected native long lua_tointeger(long ptr, int index); /*
+ public native long lua_tointeger(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
// See lua_pushinteger for comments.
if (sizeof(lua_Integer) == 4) {
@@ -2419,7 +2333,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @return see description
*/
- protected native double lua_tonumber(long ptr, int index); /*
+ public native double lua_tonumber(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
jdouble returnValueReceiver = (jdouble) lua_tonumber((lua_State *) L, (int) index);
@@ -2455,7 +2369,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @return see description
*/
- protected native long lua_topointer(long ptr, int index); /*
+ public native long lua_topointer(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
jlong returnValueReceiver = (jlong) lua_topointer((lua_State *) L, (int) index);
@@ -2482,7 +2396,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @return see description
*/
- protected native String lua_tostring(long ptr, int index); /*
+ public native String lua_tostring(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
const char * returnValueReceiver = (const char *) lua_tostring((lua_State *) L, (int) index);
@@ -2512,7 +2426,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @return see description
*/
- protected native long lua_tothread(long ptr, int index); /*
+ public native long lua_tothread(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
jlong returnValueReceiver = (jlong) lua_tothread((lua_State *) L, (int) index);
@@ -2543,7 +2457,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @return see description
*/
- protected native long lua_touserdata(long ptr, int index); /*
+ public native long lua_touserdata(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
jlong returnValueReceiver = (jlong) lua_touserdata((lua_State *) L, (int) index);
@@ -2584,7 +2498,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @return see description
*/
- protected native int lua_type(long ptr, int index); /*
+ public native int lua_type(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) lua_type((lua_State *) L, (int) index);
@@ -2612,7 +2526,7 @@ public void loadAsGlobal() {
* @param tp type id
* @return see description
*/
- protected native String lua_typename(long ptr, int tp); /*
+ public native String lua_typename(long ptr, int tp); /*
lua_State * L = (lua_State *) ptr;
const char * returnValueReceiver = (const char *) lua_typename((lua_State *) L, (int) tp);
@@ -2644,7 +2558,7 @@ public void loadAsGlobal() {
* @param to another thread
* @param n the number of elements
*/
- protected native void lua_xmove(long from, long to, int n); /*
+ public native void lua_xmove(long from, long to, int n); /*
lua_xmove((lua_State *) from, (lua_State *) to, (int) n);
*/
@@ -2697,7 +2611,7 @@ public void loadAsGlobal() {
* @param nresults the number of results, or LUA_MULTRET
* @return see description
*/
- protected native int lua_yield(long ptr, int nresults); /*
+ public native int lua_yield(long ptr, int nresults); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) lua_yield((lua_State *) L, (int) nresults);
@@ -2723,7 +2637,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @return see description
*/
- protected native int lua_gethookcount(long ptr); /*
+ public native int lua_gethookcount(long ptr); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) lua_gethookcount((lua_State *) L);
@@ -2749,7 +2663,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @return see description
*/
- protected native int lua_gethookmask(long ptr); /*
+ public native int lua_gethookmask(long ptr); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) lua_gethookmask((lua_State *) L);
@@ -2794,7 +2708,7 @@ public void loadAsGlobal() {
* @param n the index in the upvalue
* @return see description
*/
- protected native String lua_getupvalue(long ptr, int funcindex, int n); /*
+ public native String lua_getupvalue(long ptr, int funcindex, int n); /*
lua_State * L = (lua_State *) ptr;
const char * returnValueReceiver = (const char *) lua_getupvalue((lua_State *) L, (int) funcindex, (int) n);
@@ -2832,7 +2746,7 @@ public void loadAsGlobal() {
* @param n the index in the upvalue
* @return see description
*/
- protected native String lua_setupvalue(long ptr, int funcindex, int n); /*
+ public native String lua_setupvalue(long ptr, int funcindex, int n); /*
lua_State * L = (lua_State *) ptr;
const char * returnValueReceiver = (const char *) lua_setupvalue((lua_State *) L, (int) funcindex, (int) n);
@@ -2870,7 +2784,7 @@ public void loadAsGlobal() {
* @param e field name
* @return see description
*/
- protected native int luaL_callmeta(long ptr, int obj, String e); /*
+ public native int luaL_callmeta(long ptr, int obj, String e); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) luaL_callmeta((lua_State *) L, (int) obj, (const char *) e);
@@ -2907,7 +2821,7 @@ public void loadAsGlobal() {
* @param str string
* @return see description
*/
- protected native int luaL_dostring(long ptr, String str); /*
+ public native int luaL_dostring(long ptr, String str); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) luaL_dostring((lua_State *) L, (const char *) str);
@@ -2939,7 +2853,7 @@ public void loadAsGlobal() {
* @param e field name
* @return see description
*/
- protected native int luaL_getmetafield(long ptr, int obj, String e); /*
+ public native int luaL_getmetafield(long ptr, int obj, String e); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) luaL_getmetafield((lua_State *) L, (int) obj, (const char *) e);
@@ -2966,7 +2880,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @param tname type name
*/
- protected native void luaL_getmetatable(long ptr, String tname); /*
+ public native void luaL_getmetatable(long ptr, String tname); /*
lua_State * L = (lua_State *) ptr;
luaL_getmetatable((lua_State *) L, (const char *) tname);
@@ -2992,7 +2906,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @param tname type name
*/
- protected native void luaJ_getmetatable(long ptr, String tname); /*
+ public native void luaJ_getmetatable(long ptr, String tname); /*
lua_State * L = (lua_State *) ptr;
luaL_getmetatable((lua_State *) L, (const char *) tname);
@@ -3026,7 +2940,7 @@ public void loadAsGlobal() {
* @param r the replacing string
* @return see description
*/
- protected native String luaL_gsub(long ptr, String s, String p, String r); /*
+ public native String luaL_gsub(long ptr, String s, String p, String r); /*
lua_State * L = (lua_State *) ptr;
const char * returnValueReceiver = (const char *) luaL_gsub((lua_State *) L, (const char *) s, (const char *) p, (const char *) r);
@@ -3064,7 +2978,7 @@ public void loadAsGlobal() {
* @param s the string
* @return see description
*/
- protected native int luaL_loadstring(long ptr, String s); /*
+ public native int luaL_loadstring(long ptr, String s); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) luaL_loadstring((lua_State *) L, (const char *) s);
@@ -3101,7 +3015,7 @@ public void loadAsGlobal() {
* @param tname type name
* @return see description
*/
- protected native int luaL_newmetatable(long ptr, String tname); /*
+ public native int luaL_newmetatable(long ptr, String tname); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) luaL_newmetatable((lua_State *) L, (const char *) tname);
@@ -3137,7 +3051,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @param tname type name
*/
- protected native void luaJ_newmetatable(long ptr, String tname); /*
+ public native void luaJ_newmetatable(long ptr, String tname); /*
lua_State * L = (lua_State *) ptr;
luaL_newmetatable((lua_State *) L, (const char *) tname);
@@ -3172,7 +3086,7 @@ public void loadAsGlobal() {
* @param lid the id of the Lua state, to be used to identify between Java and Lua
* @return see description
*/
- protected native long luaL_newstate(int lid); /*
+ public native long luaL_newstate(int lid); /*
lua_State* L = luaL_newstate();
luaJavaSetup(L, env, lid);
return (jlong) L;
@@ -3196,7 +3110,7 @@ public void loadAsGlobal() {
*
* @param ptr the lua_State* pointer
*/
- protected native void luaL_openlibs(long ptr); /*
+ public native void luaL_openlibs(long ptr); /*
lua_State * L = (lua_State *) ptr;
luaL_openlibs((lua_State *) L);
@@ -3240,7 +3154,7 @@ public void loadAsGlobal() {
* @param t the stack index
* @return see description
*/
- protected native int luaL_ref(long ptr, int t); /*
+ public native int luaL_ref(long ptr, int t); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) luaL_ref((lua_State *) L, (int) t);
@@ -3267,7 +3181,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @return see description
*/
- protected native String luaL_typename(long ptr, int index); /*
+ public native String luaL_typename(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
const char * returnValueReceiver = (const char *) luaL_typename((lua_State *) L, (int) index);
@@ -3305,7 +3219,7 @@ public void loadAsGlobal() {
* @param tname type name
* @return see description
*/
- protected native int luaL_typerror(long ptr, int narg, String tname); /*
+ public native int luaL_typerror(long ptr, int narg, String tname); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) luaL_typerror((lua_State *) L, (int) narg, (const char *) tname);
@@ -3341,7 +3255,7 @@ public void loadAsGlobal() {
* @param t the stack index
* @param ref the reference
*/
- protected native void luaL_unref(long ptr, int t, int ref); /*
+ public native void luaL_unref(long ptr, int t, int ref); /*
lua_State * L = (lua_State *) ptr;
luaL_unref((lua_State *) L, (int) t, (int) ref);
@@ -3382,7 +3296,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @param lvl the running level
*/
- protected native void luaL_where(long ptr, int lvl); /*
+ public native void luaL_where(long ptr, int lvl); /*
lua_State * L = (lua_State *) ptr;
luaL_where((lua_State *) L, (int) lvl);
@@ -3399,7 +3313,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @param lib library name
*/
- protected native void luaJ_openlib(long ptr, String lib); /*
+ public native void luaJ_openlib(long ptr, String lib); /*
lua_State * L = (lua_State *) ptr;
luaJ_openlib((lua_State *) L, (const char *) lib);
@@ -3419,7 +3333,7 @@ public void loadAsGlobal() {
* @param op the operator
* @return see description
*/
- protected native int luaJ_compare(long ptr, int index1, int index2, int op); /*
+ public native int luaJ_compare(long ptr, int index1, int index2, int op); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) luaJ_compare((lua_State *) L, (int) index1, (int) index2, (int) op);
@@ -3438,7 +3352,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @return see description
*/
- protected native int luaJ_len(long ptr, int index); /*
+ public native int luaJ_len(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) luaJ_len((lua_State *) L, (int) index);
@@ -3459,7 +3373,7 @@ public void loadAsGlobal() {
* @param name the name
* @return see description
*/
- protected native int luaJ_loadbuffer(long ptr, Buffer buffer, int size, String name); /*
+ public native int luaJ_loadbuffer(long ptr, Buffer buffer, int size, String name); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) luaJ_loadbuffer((lua_State *) L, (unsigned char *) buffer, (int) size, (const char *) name);
@@ -3480,7 +3394,7 @@ public void loadAsGlobal() {
* @param name the name
* @return see description
*/
- protected native int luaJ_dobuffer(long ptr, Buffer buffer, int size, String name); /*
+ public native int luaJ_dobuffer(long ptr, Buffer buffer, int size, String name); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) luaJ_dobuffer((lua_State *) L, (unsigned char *) buffer, (int) size, (const char *) name);
@@ -3488,26 +3402,6 @@ public void loadAsGlobal() {
*/
- /**
- * A wrapper function
- *
- *
- * Protected call
- *
- *
- * @param ptr the lua_State* pointer
- * @param nargs the number of arguments that you pushed onto the stack
- * @param nresults the number of results, or LUA_MULTRET
- * @return see description
- */
- protected native int luaJ_pcall(long ptr, int nargs, int nresults); /*
- lua_State * L = (lua_State *) ptr;
-
- jint returnValueReceiver = (jint) luaJ_pcall((lua_State *) L, (int) nargs, (int) nresults);
- return returnValueReceiver;
- */
-
-
/**
* A wrapper function
*
@@ -3519,7 +3413,7 @@ public void loadAsGlobal() {
* @param nargs the number of arguments that you pushed onto the stack
* @return see description
*/
- protected native int luaJ_resume(long ptr, int nargs); /*
+ public native int luaJ_resume(long ptr, int nargs); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) luaJ_resume((lua_State *) L, (int) nargs);
@@ -3537,7 +3431,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @param obj the Java object
*/
- protected native void luaJ_pushobject(long ptr, Object obj); /*
+ public native void luaJ_pushobject(long ptr, Object obj); /*
lua_State * L = (lua_State *) ptr;
luaJ_pushobject((JNIEnv *) env, (lua_State *) L, (jobject) obj);
@@ -3554,7 +3448,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @param clazz the Java class
*/
- protected native void luaJ_pushclass(long ptr, Object clazz); /*
+ public native void luaJ_pushclass(long ptr, Object clazz); /*
lua_State * L = (lua_State *) ptr;
luaJ_pushclass((JNIEnv *) env, (lua_State *) L, (jobject) clazz);
@@ -3571,7 +3465,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @param array the Java array
*/
- protected native void luaJ_pusharray(long ptr, Object array); /*
+ public native void luaJ_pusharray(long ptr, Object array); /*
lua_State * L = (lua_State *) ptr;
luaJ_pusharray((JNIEnv *) env, (lua_State *) L, (jobject) array);
@@ -3588,7 +3482,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @param func the function object
*/
- protected native void luaJ_pushfunction(long ptr, Object func); /*
+ public native void luaJ_pushfunction(long ptr, Object func); /*
lua_State * L = (lua_State *) ptr;
luaJ_pushfunction((JNIEnv *) env, (lua_State *) L, (jobject) func);
@@ -3606,7 +3500,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @return see description
*/
- protected native int luaJ_isobject(long ptr, int index); /*
+ public native int luaJ_isobject(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) luaJ_isobject((lua_State *) L, (int) index);
@@ -3625,7 +3519,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @return see description
*/
- protected native Object luaJ_toobject(long ptr, int index); /*
+ public native Object luaJ_toobject(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
jobject returnValueReceiver = (jobject) luaJ_toobject((lua_State *) L, (int) index);
@@ -3644,7 +3538,7 @@ public void loadAsGlobal() {
* @param lid the id of the Lua state, to be used to identify between Java and Lua
* @return see description
*/
- protected native long luaJ_newthread(long ptr, int lid); /*
+ public native long luaJ_newthread(long ptr, int lid); /*
lua_State * L = (lua_State *) ptr;
jlong returnValueReceiver = (jlong) luaJ_newthread((lua_State *) L, (int) lid);
@@ -3662,7 +3556,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @return see description
*/
- protected native int luaJ_initloader(long ptr); /*
+ public native int luaJ_initloader(long ptr); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) luaJ_initloader((lua_State *) L);
@@ -3686,7 +3580,7 @@ public void loadAsGlobal() {
* @param params encoded parameter types
* @return see description
*/
- protected native int luaJ_invokespecial(long ptr, Class clazz, String method, String sig, Object obj, String params); /*
+ public native int luaJ_invokespecial(long ptr, Class clazz, String method, String sig, Object obj, String params); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) luaJ_invokespecial((JNIEnv *) env, (lua_State *) L, (jclass) clazz, (const char *) method, (const char *) sig, (jobject) obj, (const char *) params);
@@ -3705,7 +3599,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @return see description
*/
- protected native int luaJ_isinteger(long ptr, int index); /*
+ public native int luaJ_isinteger(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
jint returnValueReceiver = (jint) luaJ_isinteger((lua_State *) L, (int) index);
@@ -3722,7 +3616,7 @@ public void loadAsGlobal() {
*
* @param ptr the lua_State* pointer
*/
- protected native void luaJ_removestateindex(long ptr); /*
+ public native void luaJ_removestateindex(long ptr); /*
lua_State * L = (lua_State *) ptr;
luaJ_removestateindex((lua_State *) L);
@@ -3738,7 +3632,7 @@ public void loadAsGlobal() {
*
* @param ptr the lua_State* pointer
*/
- protected native void luaJ_gc(long ptr); /*
+ public native void luaJ_gc(long ptr); /*
lua_State * L = (lua_State *) ptr;
luaJ_gc((lua_State *) L);
@@ -3755,7 +3649,7 @@ public void loadAsGlobal() {
* @param ptr the lua_State* pointer
* @return see description
*/
- protected native Object luaJ_dumptobuffer(long ptr); /*
+ public native Object luaJ_dumptobuffer(long ptr); /*
lua_State * L = (lua_State *) ptr;
jobject returnValueReceiver = (jobject) luaJ_dumptobuffer((lua_State *) L);
@@ -3774,7 +3668,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @return see description
*/
- protected native Object luaJ_tobuffer(long ptr, int index); /*
+ public native Object luaJ_tobuffer(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
jobject returnValueReceiver = (jobject) luaJ_tobuffer((lua_State *) L, (int) index);
@@ -3793,7 +3687,7 @@ public void loadAsGlobal() {
* @param index the stack position of the element
* @return see description
*/
- protected native Object luaJ_todirectbuffer(long ptr, int index); /*
+ public native Object luaJ_todirectbuffer(long ptr, int index); /*
lua_State * L = (lua_State *) ptr;
jobject returnValueReceiver = (jobject) luaJ_todirectbuffer((lua_State *) L, (int) index);
diff --git a/scripts/comm-abstract.py b/scripts/comm-abstract.py
index 019668dd..22169fd9 100644
--- a/scripts/comm-abstract.py
+++ b/scripts/comm-abstract.py
@@ -1,57 +1,97 @@
#!/bin/python
-# python scripts/comm-abstract.py lua*/src/main/java/party/iroiro/luajava/*Natives*
+# python scripts/comm-abstract.py \
+# luajava/src/main/java/party/iroiro/luajava/LuaNatives.java \
+# lua5*/src/main/java/party/iroiro/luajava/lua5*/*Natives*
+import dataclasses
import sys
import re
+from pathlib import Path
-
-defPattern = re.compile('^protected native (\\w+) (\\w+)\\(([^)]*)\\); /\\*$')
+defPattern = re.compile('^public native (\\w+) (\\w+)\\(([^)]*)\\); /\\*$')
paramPattern = re.compile('^(.+\\W)(\\w+)$')
-def getSig(signature):
- params = filter(lambda param: param != '', signature.strip().split(','))
- params = list(map(lambda param: paramPattern.findall(param)[0],
- params))
- return params
+@dataclasses.dataclass
+class Method:
+ returns: str
+ name: str
+ signature: list
+ line: str
+
+def getSig(signature: str):
+ return [
+ paramPattern.findall(param)[0]
+ for param in signature.strip().split(',') if param != ''
+ ]
-def strip(line):
+
+def strip(line: str):
line = line.strip()
match = defPattern.findall(line)
- return {
- 'return': match[0][0],
- 'name': match[0][1],
- 'signature': getSig(match[0][2]),
- 'line': line[:-3],
- }
+ return Method(
+ returns=match[0][0],
+ name=match[0][1],
+ signature=getSig(match[0][2]),
+ line=line[:-3],
+ )
-def readlines(path):
+def readlines(path: str):
f = open(path, 'r')
lines = f.readlines()
f.close()
- return list(map(strip,
- filter(lambda line: 'protected native' in line, lines)))
+ return [
+ strip(line)
+ for line in lines if 'public native' in line
+ ]
-def hashKey(method):
+def hashKey(method: Method):
return (
- method['return'] + method['name'] +
- ''.join([param[0].strip() for param in method['signature']])
+ method.returns + method.name +
+ ''.join([param[0].strip() for param in method.signature])
)
-files = sys.argv[1:]
+methodPattern = re.compile('^ (?:public abstract )?\\w+ (lua\\w+|getRegistryIndex)\\([ A-Za-z0-9,]*\\);$')
+
+def extract_documentation(file: Path):
+ lines = file.read_text().splitlines()
+ documentation: dict[str, str] = {}
+ prev_lines: list[str] = []
+ for line in lines:
+ if '/**' in line:
+ assert line.endswith('/**')
+ prev_lines = [line]
+ continue
+ if '*/' in line:
+ assert line.endswith('*/')
+ match = methodPattern.match(line)
+ if match is None:
+ prev_lines.append(line)
+ continue
+ method = match.group(1)
+ assert method == 'luaJ_pcall' or method not in documentation, method
+ documentation[method] = '\n'.join(prev_lines)
+ prev_lines = []
+ return documentation
+
+
+original = Path(sys.argv[1])
+documentation = extract_documentation(original)
+
+files = sys.argv[2:]
contents = list(map(readlines, files))
-def comm(content1, content2):
+def comm(content1: list[Method], content2: list[Method]) -> list[Method]:
hashSet = {}
for method in content1:
hashSet[hashKey(method)] = True
- output = []
+ output: list[Method] = []
for method in content2:
if hashKey(method) in hashSet:
output.append(method)
@@ -62,16 +102,60 @@ def comm(content1, content2):
for content in contents[1:]:
common = comm(common, content)
-print("""package party.iroiro.luajava;
+print("""/*
+ * Copyright (C) 2022 the original author or authors.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package party.iroiro.luajava;
import java.nio.Buffer;
/**
* Generated from the common parts of Lua5.[1..4]
+ *
+ *
+ * The following documentation is copied from that of Lua 5.1.
+ * There might be inconsistencies between versions. So please check the official
+ * Lua documentation to confirm.
+ *
*/
-@SuppressWarnings("unused")
-public abstract class LuaNative {
+public interface LuaNatives {
+
+ /**
+ * Exposes 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.
+ *
+ */
+ void loadAsGlobal();
+""")
+for line, method in sorted(
+ [(m.line, m) for m in common],
+ key=lambda s: s[0].replace('_', '').lower(),
+):
+ if method.name in ['luaL_gsub']:
+ continue
+ print(f"""{documentation.get(method.name, '')}
+ {line.replace('public native ', '')}
""")
-for line in sorted(map(lambda method: method['line'], common), key=lambda s: s.replace('_', '').lower()):
- print(' %s\n' % (line.replace('native', 'abstract'),))
print('}')
diff --git a/scripts/jnigen-lua.py b/scripts/jnigen-lua.py
index 75b8a6d9..63d6fd70 100644
--- a/scripts/jnigen-lua.py
+++ b/scripts/jnigen-lua.py
@@ -425,13 +425,13 @@ def _javadocSignature(self, f: LuaAPI):
def _javaSignature(self, f: LuaAPI):
if f.name in overrideFunctions:
- return f" protected native {overrideFunctions[f.name][0]};"
+ return f" public native {overrideFunctions[f.name][0]};"
params = ', '.join(
f"{returnTypes[paramType]} {name}"
for paramType, name in self._normalizeParams(f)
)
returns = returnTypes[f.signature.returns]
- return f" protected native {returns} {f.name}({params});"
+ return f" public native {returns} {f.name}({params});"
def _jniGen(self, f: LuaAPI):
if f.name in overrideFunctions:
@@ -580,18 +580,6 @@ def filterFunction(f: LuaAPI):
],
),
),
- LuaAPI(
- name='luaJ_pcall',
- description='Protected call',
- signature=FunctionSignature(
- returns='int',
- params=[
- ('lua_State *', 'L'),
- ('int', 'nargs'),
- ('int', 'nresults'),
- ],
- ),
- ),
LuaAPI(
name='luaJ_resume',
description='Resume a coroutine',
@@ -775,7 +763,6 @@ def filterFunction(f: LuaAPI):
),
]
returnValueInconsistencies = [
- 'lua_pcall',
'lua_getfield',
'lua_getglobal',
'lua_geti',
@@ -810,7 +797,7 @@ def getWhole(luaVersion: str, package: str):
className = f"Lua{luaVersion.replace('.', '')}Natives"
inner = (
f'''@SuppressWarnings({{"unused", "rawtypes"}})
-public class {className} extends LuaNative {{
+public class {className} implements LuaNatives {{
/*JNI
#include "luacustomamalg.h"
@@ -870,7 +857,7 @@ def getWhole(luaVersion: str, package: str):
/**
* Get LUA_REGISTRYINDEX, which is a computed compile time constant
*/
- protected native int getRegistryIndex(); /*
+ public native int getRegistryIndex(); /*
return LUA_REGISTRYINDEX;
*/
@@ -912,7 +899,7 @@ def getWhole(luaVersion: str, package: str):
import java.util.concurrent.atomic.AtomicReference;
import java.nio.Buffer;
-import party.iroiro.luajava.LuaNative;
+import party.iroiro.luajava.LuaNatives;
import party.iroiro.luajava.util.GlobalLibraryLoader;
/**