From aa9b5d7d4c425c1437366dd2c80912943c1ea89c Mon Sep 17 00:00:00 2001 From: gudzpoz Date: Thu, 23 May 2024 20:31:49 +0800 Subject: [PATCH] Make LuaNatives a public interface - Remove duplicates of lua_pcall functions - Remove luaL_gsub --- .../java/party/iroiro/luajava/JuaApiTest.java | 9 +- .../party/iroiro/luajava/luaj/LuaJTest.java | 11 +- .../party/iroiro/luajava/LuaScriptSuite.java | 32 +- .../party/iroiro/luajava/LuaTestSuite.java | 4 +- lua51/jni/mod/luacomp.h | 4 - .../party/iroiro/luajava/lua51/Lua51.java | 4 +- .../iroiro/luajava/lua51/Lua51Natives.java | 344 +++++--------- lua52/jni/mod/luacomp.h | 4 - .../party/iroiro/luajava/lua52/Lua52.java | 4 +- .../iroiro/luajava/lua52/Lua52Natives.java | 401 ++++++---------- lua53/jni/mod/luacomp.h | 4 - .../party/iroiro/luajava/lua53/Lua53.java | 4 +- .../iroiro/luajava/lua53/Lua53Natives.java | 410 ++++++----------- lua54/jni/mod/luacomp.h | 4 - .../party/iroiro/luajava/lua54/Lua54.java | 4 +- .../iroiro/luajava/lua54/Lua54Natives.java | 388 ++++++---------- .../java/party/iroiro/luajava/luaj/LuaJ.java | 4 +- .../iroiro/luajava/luaj/LuaJNatives.java | 222 ++++----- .../party/iroiro/luajava/AbstractLua.java | 12 +- .../main/java/party/iroiro/luajava/Lua.java | 4 +- .../{LuaNative.java => LuaNatives.java} | 435 +++++++----------- .../luajava/util/GlobalLibraryLoader.java | 6 +- luajit/jni/mod/luacomp.h | 4 - .../party/iroiro/luajava/luajit/LuaJit.java | 4 +- .../iroiro/luajava/luajit/LuaJitNatives.java | 344 +++++--------- scripts/comm-abstract.py | 142 ++++-- scripts/jnigen-lua.py | 23 +- 27 files changed, 1090 insertions(+), 1741 deletions(-) rename luajava/src/main/java/party/iroiro/luajava/{LuaNative.java => LuaNatives.java} (86%) diff --git a/example/src/test/java/party/iroiro/luajava/JuaApiTest.java b/example/src/test/java/party/iroiro/luajava/JuaApiTest.java index ba01e9c2..3962bb2f 100644 --- a/example/src/test/java/party/iroiro/luajava/JuaApiTest.java +++ b/example/src/test/java/party/iroiro/luajava/JuaApiTest.java @@ -68,16 +68,9 @@ private void convertTableTest(Lua L) { L.pop(1); } - private static class NativeTest extends Lua51Natives { - @Override - public long lua_newuserdata(long ptr, long size) { - return super.lua_newuserdata(ptr, size); - } - } - private void convertUserdataTest() { Lua L = new Lua51(); - assertNotEquals(0, new NativeTest() + assertNotEquals(0, ((Lua51Natives) L.getLuaNative()) .lua_newuserdata(L.getPointer(), 1024)); assertThrows(IllegalArgumentException.class, () -> JuaAPI.convertFromLua(L, Integer.class, -1), diff --git a/example/src/test/java/party/iroiro/luajava/luaj/LuaJTest.java b/example/src/test/java/party/iroiro/luajava/luaj/LuaJTest.java index c85f4b0f..aea17540 100644 --- a/example/src/test/java/party/iroiro/luajava/luaj/LuaJTest.java +++ b/example/src/test/java/party/iroiro/luajava/luaj/LuaJTest.java @@ -195,13 +195,10 @@ public void testLuaJCoroutine() { public void luaJNativesUserDataTest() { try (LuaJ L = new LuaJ()) { Object object = new Object(); - new LuaJNatives() { - { - lua_newuserdata(L.getPointer(), object); - assertEquals(USERDATA, L.type(-1)); - L.setGlobal("customObject"); - } - }; + LuaJNatives C = (LuaJNatives) L.getLuaNative(); + C.lua_newuserdata(L.getPointer(), object); + assertEquals(USERDATA, L.type(-1)); + L.setGlobal("customObject"); L.set("object", object); L.run("assert(object ~= customObject)"); } diff --git a/example/suite/src/main/java/party/iroiro/luajava/LuaScriptSuite.java b/example/suite/src/main/java/party/iroiro/luajava/LuaScriptSuite.java index 4636b98a..1c7586b1 100644 --- a/example/suite/src/main/java/party/iroiro/luajava/LuaScriptSuite.java +++ b/example/suite/src/main/java/party/iroiro/luajava/LuaScriptSuite.java @@ -73,37 +73,17 @@ public static boolean isAndroid() { new ScriptTester("/suite/otherConvTest.lua", L -> { L.push(new OtherTypes(), Lua.Conversion.NONE); L.setGlobal("others"); - LuaNative C = L.getLuaNative(); + LuaNatives C = L.getLuaNative(); if (C instanceof Lua51Natives) { - new Lua51Natives() { - { - lua_newuserdata(L.getPointer(), 1024); - } - }; + ((Lua51Natives) C).lua_newuserdata(L.getPointer(), 1024); } else if (C instanceof Lua52Natives) { - new Lua52Natives() { - { - lua_newuserdata(L.getPointer(), 1024); - } - }; + ((Lua52Natives) C).lua_newuserdata(L.getPointer(), 1024); } else if (C instanceof Lua53Natives) { - new Lua53Natives() { - { - lua_newuserdata(L.getPointer(), 1024); - } - }; + ((Lua53Natives) C).lua_newuserdata(L.getPointer(), 1024); } else if (C instanceof Lua54Natives) { - new Lua54Natives() { - { - lua_newuserdatauv(L.getPointer(), 1024, 0); - } - }; + ((Lua54Natives) C).lua_newuserdatauv(L.getPointer(), 1024, 0); } else if (C instanceof LuaJitNatives) { - new LuaJitNatives() { - { - lua_newuserdata(L.getPointer(), 1024); - } - }; + ((LuaJitNatives) C).lua_newuserdata(L.getPointer(), 1024); } else if (C.getClass().getName().endsWith("LuaJNatives")) { // This is tested instead in NativesTest, // because our Android build has trouble desugaring and cannot run LuaJ. diff --git a/example/suite/src/main/java/party/iroiro/luajava/LuaTestSuite.java b/example/suite/src/main/java/party/iroiro/luajava/LuaTestSuite.java index 3882a9f0..cb5a92e4 100644 --- a/example/suite/src/main/java/party/iroiro/luajava/LuaTestSuite.java +++ b/example/suite/src/main/java/party/iroiro/luajava/LuaTestSuite.java @@ -764,7 +764,7 @@ private void testLuaToJavaConversions() { } L.pop(expected.length); - LuaNative luaNative = L.getLuaNative(); + LuaNatives luaNative = L.getLuaNative(); luaNative.lua_pushlightuserdata(L.getPointer(), 0); assertEquals(LIGHTUSERDATA, L.type(-1)); @@ -832,7 +832,7 @@ private void assertIterableEquals(Iterable a, Iterable b) { } } - private void testToMap(LuaNative luaNative) { + private void testToMap(LuaNatives luaNative) { L.push(true); assertNull(L.toMap(-1)); HashMap emptyMap = new HashMap<>(); diff --git a/lua51/jni/mod/luacomp.h b/lua51/jni/mod/luacomp.h index d27d1f2f..28830e80 100644 --- a/lua51/jni/mod/luacomp.h +++ b/lua51/jni/mod/luacomp.h @@ -63,10 +63,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/lua51/src/main/java/party/iroiro/luajava/lua51/Lua51.java b/lua51/src/main/java/party/iroiro/luajava/lua51/Lua51.java index 5bf28d33..8574f778 100644 --- a/lua51/src/main/java/party/iroiro/luajava/lua51/Lua51.java +++ b/lua51/src/main/java/party/iroiro/luajava/lua51/Lua51.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 Lua51(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/lua51/src/main/java/party/iroiro/luajava/lua51/Lua51Natives.java b/lua51/src/main/java/party/iroiro/luajava/lua51/Lua51Natives.java index afa44bdf..87ba80ac 100644 --- a/lua51/src/main/java/party/iroiro/luajava/lua51/Lua51Natives.java +++ b/lua51/src/main/java/party/iroiro/luajava/lua51/Lua51Natives.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 Lua51Natives extends LuaNative { +public class Lua51Natives 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): - *

- * - * - * - * @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/lua52/jni/mod/luacomp.h b/lua52/jni/mod/luacomp.h index 0e99d899..1a76ef10 100644 --- a/lua52/jni/mod/luacomp.h +++ b/lua52/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, NULL, narg); } diff --git a/lua52/src/main/java/party/iroiro/luajava/lua52/Lua52.java b/lua52/src/main/java/party/iroiro/luajava/lua52/Lua52.java index 8603694b..adbb0dc3 100644 --- a/lua52/src/main/java/party/iroiro/luajava/lua52/Lua52.java +++ b/lua52/src/main/java/party/iroiro/luajava/lua52/Lua52.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 Lua52(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/lua52/src/main/java/party/iroiro/luajava/lua52/Lua52Natives.java b/lua52/src/main/java/party/iroiro/luajava/lua52/Lua52Natives.java index a80fd4d9..a93983c6 100644 --- a/lua52/src/main/java/party/iroiro/luajava/lua52/Lua52Natives.java +++ b/lua52/src/main/java/party/iroiro/luajava/lua52/Lua52Natives.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; /** @@ -108,7 +108,7 @@ * */ @SuppressWarnings({"unused", "rawtypes"}) -public class Lua52Natives extends LuaNative { +public class Lua52Natives implements LuaNatives { /*JNI #include "luacustomamalg.h" @@ -168,7 +168,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; */ @@ -192,7 +192,7 @@ public void loadAsGlobal() { * @param idx the stack position * @return see description */ - protected native int lua_absindex(long ptr, int idx); /* + public native int lua_absindex(long ptr, int idx); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_absindex((lua_State *) L, (int) idx); @@ -247,7 +247,7 @@ public void loadAsGlobal() { * @param ptr the lua_State* pointer * @param op the operator */ - protected native void lua_arith(long ptr, int op); /* + public native void lua_arith(long ptr, int op); /* lua_State * L = (lua_State *) ptr; lua_arith((lua_State *) L, (int) op); @@ -280,7 +280,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); @@ -312,7 +312,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); @@ -361,7 +361,7 @@ public void loadAsGlobal() { * @param op the operator * @return see description */ - protected native int lua_compare(long ptr, int index1, int index2, int op); /* + public native int lua_compare(long ptr, int index1, int index2, int op); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_compare((lua_State *) L, (int) index1, (int) index2, (int) op); @@ -393,7 +393,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); @@ -422,7 +422,7 @@ public void loadAsGlobal() { * @param fromidx a stack position * @param toidx another stack position */ - protected native void lua_copy(long ptr, int fromidx, int toidx); /* + public native void lua_copy(long ptr, int fromidx, int toidx); /* lua_State * L = (lua_State *) ptr; lua_copy((lua_State *) L, (int) fromidx, (int) toidx); @@ -456,7 +456,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); @@ -486,7 +486,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); @@ -597,7 +597,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); @@ -649,7 +649,7 @@ public void loadAsGlobal() { * @param ctx the context storage * @return see description */ - protected native int lua_getctx(long ptr, long ctx); /* + public native int lua_getctx(long ptr, long ctx); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_getctx((lua_State *) L, (int *) ctx); @@ -679,7 +679,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); @@ -708,7 +708,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); @@ -733,7 +733,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); @@ -758,7 +758,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); @@ -786,7 +786,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); @@ -821,7 +821,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); @@ -855,7 +855,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); @@ -883,7 +883,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); @@ -911,7 +911,7 @@ public void loadAsGlobal() { * @param ptr the lua_State* pointer * @param index the stack position of the element */ - protected native void lua_getuservalue(long ptr, int index); /* + public native void lua_getuservalue(long ptr, int index); /* lua_State * L = (lua_State *) ptr; lua_getuservalue((lua_State *) L, (int) index); @@ -939,7 +939,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); @@ -966,7 +966,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); @@ -994,7 +994,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); @@ -1022,7 +1022,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); @@ -1050,7 +1050,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); @@ -1078,7 +1078,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); @@ -1106,7 +1106,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); @@ -1135,7 +1135,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); @@ -1164,7 +1164,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); @@ -1193,7 +1193,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); @@ -1221,7 +1221,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); @@ -1249,7 +1249,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); @@ -1277,7 +1277,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); @@ -1305,7 +1305,7 @@ public void loadAsGlobal() { * @param ptr the lua_State* pointer * @param index the stack position of the element */ - protected native void lua_len(long ptr, int index); /* + public native void lua_len(long ptr, int index); /* lua_State * L = (lua_State *) ptr; lua_len((lua_State *) L, (int) index); @@ -1330,7 +1330,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); @@ -1365,7 +1365,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); @@ -1395,7 +1395,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); @@ -1457,7 +1457,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); @@ -1556,7 +1556,7 @@ public void loadAsGlobal() { * @param msgh stack position of message handler * @return see description */ - protected native int lua_pcall(long ptr, int nargs, int nresults, int msgh); /* + public native int lua_pcall(long ptr, int nargs, int nresults, int msgh); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_pcall((lua_State *) L, (int) nargs, (int) nresults, (int) msgh); @@ -1564,103 +1564,6 @@ public void loadAsGlobal() { */ - /** - * Wrapper of lua_pcall - * - *

-     * [-(nargs + 1), +(nresults|1), –]
-     * 
- * - *

-     * int lua_pcall (lua_State *L, int nargs, int nresults, int msgh);
-     * 
- * - *

- * 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 msgh is 0, - * then the error message returned on the stack - * is exactly the original error message. - * Otherwise, msgh is the stack index of a - * message handler. - * (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 message handler 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 one of the following codes - * (defined in lua.h): - *

- * - * - * - * @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 msgh stack position of message handler - */ - protected native void luaJ_pcall(long ptr, int nargs, int nresults, int msgh); /* - lua_State * L = (lua_State *) ptr; - - lua_pcall((lua_State *) L, (int) nargs, (int) nresults, (int) msgh); - */ - - /** * Wrapper of lua_pop * @@ -1679,7 +1582,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); @@ -1704,7 +1607,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); @@ -1728,7 +1631,7 @@ public void loadAsGlobal() { * * @param ptr the lua_State* pointer */ - protected native void lua_pushglobaltable(long ptr); /* + public native void lua_pushglobaltable(long ptr); /* lua_State * L = (lua_State *) ptr; lua_pushglobaltable((lua_State *) L); @@ -1753,7 +1656,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, @@ -1802,7 +1705,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); @@ -1826,7 +1729,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); @@ -1851,7 +1754,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); @@ -1889,7 +1792,7 @@ public void loadAsGlobal() { * @param s the string * @return see description */ - protected native String lua_pushstring(long ptr, String s); /* + public native String lua_pushstring(long ptr, String s); /* lua_State * L = (lua_State *) ptr; const char * returnValueReceiver = (const char *) lua_pushstring((lua_State *) L, (const char *) s); @@ -1927,7 +1830,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); @@ -1953,7 +1856,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); @@ -1979,7 +1882,7 @@ public void loadAsGlobal() { * @param ptr the lua_State* pointer * @param n the value n */ - protected native void lua_pushunsigned(long ptr, long n); /* + public native void lua_pushunsigned(long ptr, long n); /* lua_State * L = (lua_State *) ptr; lua_pushunsigned((lua_State *) L, (lua_Unsigned) n); @@ -2005,7 +1908,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); @@ -2036,7 +1939,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); @@ -2063,7 +1966,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); @@ -2089,7 +1992,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); @@ -2118,7 +2021,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); @@ -2147,7 +2050,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); @@ -2177,7 +2080,7 @@ public void loadAsGlobal() { * @param index the stack position of the element * @param p the lightuserdata */ - protected native void lua_rawgetp(long ptr, int index, long p); /* + public native void lua_rawgetp(long ptr, int index, long p); /* lua_State * L = (lua_State *) ptr; lua_rawgetp((lua_State *) L, (int) index, (const void *) p); @@ -2209,7 +2112,7 @@ public void loadAsGlobal() { * @param index the stack position of the element * @return see description */ - protected native long lua_rawlen(long ptr, int index); /* + public native long lua_rawlen(long ptr, int index); /* lua_State * L = (lua_State *) ptr; jlong returnValueReceiver = (jlong) lua_rawlen((lua_State *) L, (int) index); @@ -2236,7 +2139,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); @@ -2270,7 +2173,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); @@ -2305,7 +2208,7 @@ public void loadAsGlobal() { * @param index the stack position of the element * @param p the lightuserdata */ - protected native void lua_rawsetp(long ptr, int index, long p); /* + public native void lua_rawsetp(long ptr, int index, long p); /* lua_State * L = (lua_State *) ptr; lua_rawsetp((lua_State *) L, (int) index, (const void *) p); @@ -2333,7 +2236,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); @@ -2361,7 +2264,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); @@ -2424,7 +2327,7 @@ public void loadAsGlobal() { * @param nargs the number of arguments that you pushed onto the stack * @return see description */ - protected native int lua_resume(long ptr, long from, int nargs); /* + public native int lua_resume(long ptr, long from, int nargs); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_resume((lua_State *) L, (lua_State *) from, (int) nargs); @@ -2459,7 +2362,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); @@ -2485,7 +2388,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); @@ -2511,7 +2414,7 @@ public void loadAsGlobal() { * @param ptr the lua_State* pointer * @param index the stack position of the element */ - protected native void lua_setmetatable(long ptr, int index); /* + public native void lua_setmetatable(long ptr, int index); /* lua_State * L = (lua_State *) ptr; lua_setmetatable((lua_State *) L, (int) index); @@ -2537,7 +2440,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); @@ -2571,7 +2474,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); @@ -2600,7 +2503,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); @@ -2626,7 +2529,7 @@ public void loadAsGlobal() { * @param ptr the lua_State* pointer * @param index the stack position of the element */ - protected native void lua_setuservalue(long ptr, int index); /* + public native void lua_setuservalue(long ptr, int index); /* lua_State * L = (lua_State *) ptr; lua_setuservalue((lua_State *) L, (int) index); @@ -2665,7 +2568,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); @@ -2699,7 +2602,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); @@ -2726,7 +2629,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) { @@ -2772,7 +2675,7 @@ public void loadAsGlobal() { * @param isnum pointer to a boolean to be assigned * @return see description */ - protected native long lua_tointegerx(long ptr, int index, long isnum); /* + public native long lua_tointegerx(long ptr, int index, long isnum); /* lua_State * L = (lua_State *) ptr; jlong returnValueReceiver = (jlong) lua_tointegerx((lua_State *) L, (int) index, (int *) isnum); @@ -2799,7 +2702,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); @@ -2837,7 +2740,7 @@ public void loadAsGlobal() { * @param isnum pointer to a boolean to be assigned * @return see description */ - protected native double lua_tonumberx(long ptr, int index, long isnum); /* + public native double lua_tonumberx(long ptr, int index, long isnum); /* lua_State * L = (lua_State *) ptr; jdouble returnValueReceiver = (jdouble) lua_tonumberx((lua_State *) L, (int) index, (int *) isnum); @@ -2873,7 +2776,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); @@ -2900,7 +2803,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); @@ -2930,7 +2833,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); @@ -2957,7 +2860,7 @@ public void loadAsGlobal() { * @param index the stack position of the element * @return see description */ - protected native long lua_tounsigned(long ptr, int index); /* + public native long lua_tounsigned(long ptr, int index); /* lua_State * L = (lua_State *) ptr; jlong returnValueReceiver = (jlong) lua_tounsigned((lua_State *) L, (int) index); @@ -3003,7 +2906,7 @@ public void loadAsGlobal() { * @param isnum pointer to a boolean to be assigned * @return see description */ - protected native long lua_tounsignedx(long ptr, int index, long isnum); /* + public native long lua_tounsignedx(long ptr, int index, long isnum); /* lua_State * L = (lua_State *) ptr; jlong returnValueReceiver = (jlong) lua_tounsignedx((lua_State *) L, (int) index, (int *) isnum); @@ -3034,7 +2937,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); @@ -3074,7 +2977,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); @@ -3102,7 +3005,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); @@ -3129,7 +3032,7 @@ public void loadAsGlobal() { * @param i i * @return see description */ - protected native int lua_upvalueindex(int i); /* + public native int lua_upvalueindex(int i); /* jint returnValueReceiver = (jint) lua_upvalueindex((int) i); return returnValueReceiver; */ @@ -3157,7 +3060,7 @@ public void loadAsGlobal() { * @param ptr the lua_State* pointer * @return see description */ - protected native long lua_version(long ptr); /* + public native long lua_version(long ptr); /* lua_State * L = (lua_State *) ptr; jlong returnValueReceiver = (jlong) lua_version((lua_State *) L); @@ -3189,7 +3092,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); */ @@ -3217,7 +3120,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); @@ -3243,7 +3146,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); @@ -3269,7 +3172,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); @@ -3314,7 +3217,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); @@ -3352,7 +3255,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); @@ -3392,7 +3295,7 @@ public void loadAsGlobal() { * @param n the index in the upvalue * @return see description */ - protected native long lua_upvalueid(long ptr, int funcindex, int n); /* + public native long lua_upvalueid(long ptr, int funcindex, int n); /* lua_State * L = (lua_State *) ptr; jlong returnValueReceiver = (jlong) lua_upvalueid((lua_State *) L, (int) funcindex, (int) n); @@ -3423,7 +3326,7 @@ public void loadAsGlobal() { * @param funcindex2 the stack position of the closure * @param n2 n2 */ - protected native void lua_upvaluejoin(long ptr, int funcindex1, int n1, int funcindex2, int n2); /* + public native void lua_upvaluejoin(long ptr, int funcindex1, int n1, int funcindex2, int n2); /* lua_State * L = (lua_State *) ptr; lua_upvaluejoin((lua_State *) L, (int) funcindex1, (int) n1, (int) funcindex2, (int) n2); @@ -3460,7 +3363,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); @@ -3497,7 +3400,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); @@ -3526,7 +3429,7 @@ public void loadAsGlobal() { * @param stat (I have no idea) * @return see description */ - protected native int luaL_execresult(long ptr, int stat); /* + public native int luaL_execresult(long ptr, int stat); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) luaL_execresult((lua_State *) L, (int) stat); @@ -3556,7 +3459,7 @@ public void loadAsGlobal() { * @param fname the filename * @return see description */ - protected native int luaL_fileresult(long ptr, int stat, String fname); /* + public native int luaL_fileresult(long ptr, int stat, String fname); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) luaL_fileresult((lua_State *) L, (int) stat, (const char *) fname); @@ -3588,7 +3491,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); @@ -3615,7 +3518,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); @@ -3641,7 +3544,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); @@ -3673,7 +3576,7 @@ public void loadAsGlobal() { * @param fname the filename * @return see description */ - protected native int luaL_getsubtable(long ptr, int idx, String fname); /* + public native int luaL_getsubtable(long ptr, int idx, String fname); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) luaL_getsubtable((lua_State *) L, (int) idx, (const char *) fname); @@ -3708,7 +3611,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); @@ -3739,7 +3642,7 @@ public void loadAsGlobal() { * @param index the stack position of the element * @return see description */ - protected native int luaL_len(long ptr, int index); /* + public native int luaL_len(long ptr, int index); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) luaL_len((lua_State *) L, (int) index); @@ -3777,7 +3680,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); @@ -3814,7 +3717,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); @@ -3850,7 +3753,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); @@ -3885,7 +3788,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; @@ -3909,7 +3812,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); @@ -3953,7 +3856,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); @@ -3981,7 +3884,7 @@ public void loadAsGlobal() { * @param ptr the lua_State* pointer * @param tname type name */ - protected native void luaL_setmetatable(long ptr, String tname); /* + public native void luaL_setmetatable(long ptr, String tname); /* lua_State * L = (lua_State *) ptr; luaL_setmetatable((lua_State *) L, (const char *) tname); @@ -4010,7 +3913,7 @@ public void loadAsGlobal() { * @param tname type name * @return see description */ - protected native long luaL_testudata(long ptr, int arg, String tname); /* + public native long luaL_testudata(long ptr, int arg, String tname); /* lua_State * L = (lua_State *) ptr; jlong returnValueReceiver = (jlong) luaL_testudata((lua_State *) L, (int) arg, (const char *) tname); @@ -4050,7 +3953,7 @@ public void loadAsGlobal() { * @param len pointer to length * @return see description */ - protected native String luaL_tolstring(long ptr, int idx, long len); /* + public native String luaL_tolstring(long ptr, int idx, long len); /* lua_State * L = (lua_State *) ptr; const char * returnValueReceiver = (const char *) luaL_tolstring((lua_State *) L, (int) idx, (size_t *) len); @@ -4083,7 +3986,7 @@ public void loadAsGlobal() { * @param msg a message * @param level the running level */ - protected native void luaL_traceback(long ptr, long L1, String msg, int level); /* + public native void luaL_traceback(long ptr, long L1, String msg, int level); /* lua_State * L = (lua_State *) ptr; luaL_traceback((lua_State *) L, (lua_State *) L1, (const char *) msg, (int) level); @@ -4109,7 +4012,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); @@ -4145,7 +4048,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); @@ -4186,7 +4089,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); @@ -4203,7 +4106,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); @@ -4223,7 +4126,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); @@ -4242,7 +4145,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); @@ -4263,7 +4166,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); @@ -4284,7 +4187,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); @@ -4292,26 +4195,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 * @@ -4323,7 +4206,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); @@ -4341,7 +4224,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); @@ -4358,7 +4241,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); @@ -4375,7 +4258,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); @@ -4392,7 +4275,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); @@ -4410,7 +4293,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); @@ -4429,7 +4312,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); @@ -4448,7 +4331,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); @@ -4466,7 +4349,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); @@ -4490,7 +4373,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); @@ -4509,7 +4392,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); @@ -4526,7 +4409,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); @@ -4542,7 +4425,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); @@ -4559,7 +4442,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); @@ -4578,7 +4461,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); @@ -4597,7 +4480,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/lua53/jni/mod/luacomp.h b/lua53/jni/mod/luacomp.h index 64a6f5a6..208bf320 100644 --- a/lua53/jni/mod/luacomp.h +++ b/lua53/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, NULL, narg); } diff --git a/lua53/src/main/java/party/iroiro/luajava/lua53/Lua53.java b/lua53/src/main/java/party/iroiro/luajava/lua53/Lua53.java index 6ba7355f..56719b59 100644 --- a/lua53/src/main/java/party/iroiro/luajava/lua53/Lua53.java +++ b/lua53/src/main/java/party/iroiro/luajava/lua53/Lua53.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 Lua53(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/lua53/src/main/java/party/iroiro/luajava/lua53/Lua53Natives.java b/lua53/src/main/java/party/iroiro/luajava/lua53/Lua53Natives.java index 098ad3e9..a0105275 100644 --- a/lua53/src/main/java/party/iroiro/luajava/lua53/Lua53Natives.java +++ b/lua53/src/main/java/party/iroiro/luajava/lua53/Lua53Natives.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; /** @@ -103,7 +103,7 @@ * */ @SuppressWarnings({"unused", "rawtypes"}) -public class Lua53Natives extends LuaNative { +public class Lua53Natives implements LuaNatives { /*JNI #include "luacustomamalg.h" @@ -163,7 +163,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; */ @@ -188,7 +188,7 @@ public void loadAsGlobal() { * @param idx the stack position * @return see description */ - protected native int lua_absindex(long ptr, int idx); /* + public native int lua_absindex(long ptr, int idx); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_absindex((lua_State *) L, (int) idx); @@ -257,7 +257,7 @@ public void loadAsGlobal() { * @param ptr the lua_State* pointer * @param op the operator */ - protected native void lua_arith(long ptr, int op); /* + public native void lua_arith(long ptr, int op); /* lua_State * L = (lua_State *) ptr; lua_arith((lua_State *) L, (int) op); @@ -292,7 +292,7 @@ public void loadAsGlobal() { * @param n the number of elements * @return see description */ - protected native int lua_checkstack(long ptr, int n); /* + public native int lua_checkstack(long ptr, int n); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_checkstack((lua_State *) L, (int) n); @@ -324,7 +324,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); @@ -373,7 +373,7 @@ public void loadAsGlobal() { * @param op the operator * @return see description */ - protected native int lua_compare(long ptr, int index1, int index2, int op); /* + public native int lua_compare(long ptr, int index1, int index2, int op); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_compare((lua_State *) L, (int) index1, (int) index2, (int) op); @@ -405,7 +405,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); @@ -434,7 +434,7 @@ public void loadAsGlobal() { * @param fromidx a stack position * @param toidx another stack position */ - protected native void lua_copy(long ptr, int fromidx, int toidx); /* + public native void lua_copy(long ptr, int fromidx, int toidx); /* lua_State * L = (lua_State *) ptr; lua_copy((lua_State *) L, (int) fromidx, (int) toidx); @@ -468,7 +468,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); @@ -497,7 +497,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); @@ -590,7 +590,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); @@ -625,7 +625,7 @@ public void loadAsGlobal() { * @param k the field name * @return see description */ - protected native int lua_getfield(long ptr, int index, String k); /* + public native int lua_getfield(long ptr, int index, String k); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_getfield((lua_State *) L, (int) index, (const char *) k); @@ -659,7 +659,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); @@ -698,7 +698,7 @@ public void loadAsGlobal() { * @param ptr the lua_State* pointer * @return see description */ - protected native long lua_getextraspace(long ptr); /* + public native long lua_getextraspace(long ptr); /* lua_State * L = (lua_State *) ptr; jlong returnValueReceiver = (jlong) lua_getextraspace((lua_State *) L); @@ -726,7 +726,7 @@ public void loadAsGlobal() { * @param name the name * @return see description */ - protected native int lua_getglobal(long ptr, String name); /* + public native int lua_getglobal(long ptr, String name); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_getglobal((lua_State *) L, (const char *) name); @@ -753,7 +753,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); @@ -787,7 +787,7 @@ public void loadAsGlobal() { * @param i i * @return see description */ - protected native int lua_geti(long ptr, int index, long i); /* + public native int lua_geti(long ptr, int index, long i); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_geti((lua_State *) L, (int) index, (lua_Integer) i); @@ -821,7 +821,7 @@ public void loadAsGlobal() { * @param index the stack position of the element * @param i i */ - protected native void luaJ_geti(long ptr, int index, long i); /* + public native void luaJ_geti(long ptr, int index, long i); /* lua_State * L = (lua_State *) ptr; lua_geti((lua_State *) L, (int) index, (lua_Integer) i); @@ -850,7 +850,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); @@ -890,7 +890,7 @@ public void loadAsGlobal() { * @param index the stack position of the element * @return see description */ - protected native int lua_gettable(long ptr, int index); /* + public native int lua_gettable(long ptr, int index); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_gettable((lua_State *) L, (int) index); @@ -929,7 +929,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); @@ -957,7 +957,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); @@ -989,7 +989,7 @@ public void loadAsGlobal() { * @param index the stack position of the element * @return see description */ - protected native int lua_getuservalue(long ptr, int index); /* + public native int lua_getuservalue(long ptr, int index); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_getuservalue((lua_State *) L, (int) index); @@ -1018,7 +1018,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); @@ -1045,7 +1045,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); @@ -1073,7 +1073,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); @@ -1101,7 +1101,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); @@ -1130,7 +1130,7 @@ public void loadAsGlobal() { * @param index the stack position of the element * @return see description */ - protected native int lua_isinteger(long ptr, int index); /* + public native int lua_isinteger(long ptr, int index); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_isinteger((lua_State *) L, (int) index); @@ -1158,7 +1158,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); @@ -1186,7 +1186,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); @@ -1214,7 +1214,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); @@ -1243,7 +1243,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); @@ -1272,7 +1272,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); @@ -1301,7 +1301,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); @@ -1329,7 +1329,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); @@ -1357,7 +1357,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); @@ -1385,7 +1385,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); @@ -1412,7 +1412,7 @@ public void loadAsGlobal() { * @param ptr the lua_State* pointer * @return see description */ - protected native int lua_isyieldable(long ptr); /* + public native int lua_isyieldable(long ptr); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_isyieldable((lua_State *) L); @@ -1441,7 +1441,7 @@ public void loadAsGlobal() { * @param ptr the lua_State* pointer * @param index the stack position of the element */ - protected native void lua_len(long ptr, int index); /* + public native void lua_len(long ptr, int index); /* lua_State * L = (lua_State *) ptr; lua_len((lua_State *) L, (int) index); @@ -1466,7 +1466,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); @@ -1501,7 +1501,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); @@ -1531,7 +1531,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); @@ -1593,7 +1593,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); @@ -1693,7 +1693,7 @@ public void loadAsGlobal() { * @param msgh stack position of message handler * @return see description */ - protected native int lua_pcall(long ptr, int nargs, int nresults, int msgh); /* + public native int lua_pcall(long ptr, int nargs, int nresults, int msgh); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_pcall((lua_State *) L, (int) nargs, (int) nresults, (int) msgh); @@ -1701,104 +1701,6 @@ public void loadAsGlobal() { */ - /** - * Wrapper of lua_pcall - * - *

-     * [-(nargs + 1), +(nresults|1), –]
-     * 
- * - *

-     * int lua_pcall (lua_State *L, int nargs, int nresults, int msgh);
-     * 
- * - *

- * 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 object), - * and returns an error code. - * Like lua_call, - * lua_pcall always removes the function - * and its arguments from the stack. - *

- * - *

- * If msgh is 0, - * then the error object returned on the stack - * is exactly the original error object. - * Otherwise, msgh is the stack index of a - * message handler. - * (This index cannot be a pseudo-index.) - * In case of runtime errors, - * this function will be called with the error object - * and its return value will be the object - * returned on the stack by lua_pcall. - *

- * - *

- * Typically, the message handler is used to add more debug - * information to the error object, 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 one of the following constants - * (defined in lua.h): - *

- * - * - * - * @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 msgh stack position of message handler - */ - protected native void luaJ_pcall(long ptr, int nargs, int nresults, int msgh); /* - lua_State * L = (lua_State *) ptr; - - lua_pcall((lua_State *) L, (int) nargs, (int) nresults, (int) msgh); - */ - - /** * Wrapper of lua_pop * @@ -1817,7 +1719,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); @@ -1842,7 +1744,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); @@ -1866,7 +1768,7 @@ public void loadAsGlobal() { * * @param ptr the lua_State* pointer */ - protected native void lua_pushglobaltable(long ptr); /* + public native void lua_pushglobaltable(long ptr); /* lua_State * L = (lua_State *) ptr; lua_pushglobaltable((lua_State *) L); @@ -1891,7 +1793,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, @@ -1940,7 +1842,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); @@ -1964,7 +1866,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); @@ -1989,7 +1891,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); @@ -2027,7 +1929,7 @@ public void loadAsGlobal() { * @param s the string * @return see description */ - protected native String lua_pushstring(long ptr, String s); /* + public native String lua_pushstring(long ptr, String s); /* lua_State * L = (lua_State *) ptr; const char * returnValueReceiver = (const char *) lua_pushstring((lua_State *) L, (const char *) s); @@ -2065,7 +1967,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); @@ -2091,7 +1993,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); @@ -2118,7 +2020,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); @@ -2149,7 +2051,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); @@ -2177,7 +2079,7 @@ public void loadAsGlobal() { * @param index the stack position of the element * @return see description */ - protected native int lua_rawget(long ptr, int index); /* + public native int lua_rawget(long ptr, int index); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_rawget((lua_State *) L, (int) index); @@ -2204,7 +2106,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); @@ -2238,7 +2140,7 @@ public void loadAsGlobal() { * @param n the number / the number of elements * @return see description */ - protected native int lua_rawgeti(long ptr, int index, long n); /* + public native int lua_rawgeti(long ptr, int index, long n); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_rawgeti((lua_State *) L, (int) index, (lua_Integer) n); @@ -2272,7 +2174,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, (lua_Integer) n); @@ -2307,7 +2209,7 @@ public void loadAsGlobal() { * @param p the lightuserdata * @return see description */ - protected native int lua_rawgetp(long ptr, int index, long p); /* + public native int lua_rawgetp(long ptr, int index, long p); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_rawgetp((lua_State *) L, (int) index, (const void *) p); @@ -2340,7 +2242,7 @@ public void loadAsGlobal() { * @param index the stack position of the element * @return see description */ - protected native long lua_rawlen(long ptr, int index); /* + public native long lua_rawlen(long ptr, int index); /* lua_State * L = (lua_State *) ptr; jlong returnValueReceiver = (jlong) lua_rawlen((lua_State *) L, (int) index); @@ -2367,7 +2269,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); @@ -2401,7 +2303,7 @@ public void loadAsGlobal() { * @param index the stack position of the element * @param i i */ - protected native void lua_rawseti(long ptr, int index, int i); /* + public native void lua_rawseti(long ptr, int index, int i); /* lua_State * L = (lua_State *) ptr; lua_rawseti((lua_State *) L, (int) index, (lua_Integer) i); @@ -2436,7 +2338,7 @@ public void loadAsGlobal() { * @param index the stack position of the element * @param p the lightuserdata */ - protected native void lua_rawsetp(long ptr, int index, long p); /* + public native void lua_rawsetp(long ptr, int index, long p); /* lua_State * L = (lua_State *) ptr; lua_rawsetp((lua_State *) L, (int) index, (const void *) p); @@ -2464,7 +2366,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); @@ -2492,7 +2394,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); @@ -2555,7 +2457,7 @@ public void loadAsGlobal() { * @param nargs the number of arguments that you pushed onto the stack * @return see description */ - protected native int lua_resume(long ptr, long from, int nargs); /* + public native int lua_resume(long ptr, long from, int nargs); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_resume((lua_State *) L, (lua_State *) from, (int) nargs); @@ -2591,7 +2493,7 @@ public void loadAsGlobal() { * @param idx the stack position * @param n the number of elements */ - protected native void lua_rotate(long ptr, int idx, int n); /* + public native void lua_rotate(long ptr, int idx, int n); /* lua_State * L = (lua_State *) ptr; lua_rotate((lua_State *) L, (int) idx, (int) n); @@ -2625,7 +2527,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); @@ -2651,7 +2553,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); @@ -2685,7 +2587,7 @@ public void loadAsGlobal() { * @param index the stack position of the element * @param n the number / the number of elements */ - protected native void lua_seti(long ptr, int index, long n); /* + public native void lua_seti(long ptr, int index, long n); /* lua_State * L = (lua_State *) ptr; lua_seti((lua_State *) L, (int) index, (lua_Integer) n); @@ -2711,7 +2613,7 @@ public void loadAsGlobal() { * @param ptr the lua_State* pointer * @param index the stack position of the element */ - protected native void lua_setmetatable(long ptr, int index); /* + public native void lua_setmetatable(long ptr, int index); /* lua_State * L = (lua_State *) ptr; lua_setmetatable((lua_State *) L, (int) index); @@ -2737,7 +2639,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); @@ -2771,7 +2673,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); @@ -2800,7 +2702,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); @@ -2826,7 +2728,7 @@ public void loadAsGlobal() { * @param ptr the lua_State* pointer * @param index the stack position of the element */ - protected native void lua_setuservalue(long ptr, int index); /* + public native void lua_setuservalue(long ptr, int index); /* lua_State * L = (lua_State *) ptr; lua_setuservalue((lua_State *) L, (int) index); @@ -2865,7 +2767,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); @@ -2902,7 +2804,7 @@ public void loadAsGlobal() { * @param s the string * @return see description */ - protected native long lua_stringtonumber(long ptr, String s); /* + public native long lua_stringtonumber(long ptr, String s); /* lua_State * L = (lua_State *) ptr; jlong returnValueReceiver = (jlong) lua_stringtonumber((lua_State *) L, (const char *) s); @@ -2936,7 +2838,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); @@ -2963,7 +2865,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) { @@ -3004,7 +2906,7 @@ public void loadAsGlobal() { * @param isnum pointer to a boolean to be assigned * @return see description */ - protected native long lua_tointegerx(long ptr, int index, long isnum); /* + public native long lua_tointegerx(long ptr, int index, long isnum); /* lua_State * L = (lua_State *) ptr; jlong returnValueReceiver = (jlong) lua_tointegerx((lua_State *) L, (int) index, (int *) isnum); @@ -3031,7 +2933,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); @@ -3069,7 +2971,7 @@ public void loadAsGlobal() { * @param isnum pointer to a boolean to be assigned * @return see description */ - protected native double lua_tonumberx(long ptr, int index, long isnum); /* + public native double lua_tonumberx(long ptr, int index, long isnum); /* lua_State * L = (lua_State *) ptr; jdouble returnValueReceiver = (jdouble) lua_tonumberx((lua_State *) L, (int) index, (int *) isnum); @@ -3105,7 +3007,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); @@ -3132,7 +3034,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); @@ -3162,7 +3064,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); @@ -3193,7 +3095,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); @@ -3233,7 +3135,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); @@ -3261,7 +3163,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); @@ -3288,7 +3190,7 @@ public void loadAsGlobal() { * @param i i * @return see description */ - protected native int lua_upvalueindex(int i); /* + public native int lua_upvalueindex(int i); /* jint returnValueReceiver = (jint) lua_upvalueindex((int) i); return returnValueReceiver; */ @@ -3318,7 +3220,7 @@ public void loadAsGlobal() { * @param ptr the lua_State* pointer * @return see description */ - protected native long lua_version(long ptr); /* + public native long lua_version(long ptr); /* lua_State * L = (lua_State *) ptr; jlong returnValueReceiver = (jlong) lua_version((lua_State *) L); @@ -3350,7 +3252,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); */ @@ -3378,7 +3280,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); @@ -3404,7 +3306,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); @@ -3430,7 +3332,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); @@ -3477,7 +3379,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); @@ -3517,7 +3419,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); @@ -3559,7 +3461,7 @@ public void loadAsGlobal() { * @param n the index in the upvalue * @return see description */ - protected native long lua_upvalueid(long ptr, int funcindex, int n); /* + public native long lua_upvalueid(long ptr, int funcindex, int n); /* lua_State * L = (lua_State *) ptr; jlong returnValueReceiver = (jlong) lua_upvalueid((lua_State *) L, (int) funcindex, (int) n); @@ -3590,7 +3492,7 @@ public void loadAsGlobal() { * @param funcindex2 the stack position of the closure * @param n2 n2 */ - protected native void lua_upvaluejoin(long ptr, int funcindex1, int n1, int funcindex2, int n2); /* + public native void lua_upvaluejoin(long ptr, int funcindex1, int n1, int funcindex2, int n2); /* lua_State * L = (lua_State *) ptr; lua_upvaluejoin((lua_State *) L, (int) funcindex1, (int) n1, (int) funcindex2, (int) n2); @@ -3627,7 +3529,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); @@ -3664,7 +3566,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); @@ -3693,7 +3595,7 @@ public void loadAsGlobal() { * @param stat (I have no idea) * @return see description */ - protected native int luaL_execresult(long ptr, int stat); /* + public native int luaL_execresult(long ptr, int stat); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) luaL_execresult((lua_State *) L, (int) stat); @@ -3723,7 +3625,7 @@ public void loadAsGlobal() { * @param fname the filename * @return see description */ - protected native int luaL_fileresult(long ptr, int stat, String fname); /* + public native int luaL_fileresult(long ptr, int stat, String fname); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) luaL_fileresult((lua_State *) L, (int) stat, (const char *) fname); @@ -3755,7 +3657,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); @@ -3785,7 +3687,7 @@ public void loadAsGlobal() { * @param tname type name * @return see description */ - protected native int luaL_getmetatable(long ptr, String tname); /* + public native int luaL_getmetatable(long ptr, String tname); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) luaL_getmetatable((lua_State *) L, (const char *) tname); @@ -3814,7 +3716,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); @@ -3846,7 +3748,7 @@ public void loadAsGlobal() { * @param fname the filename * @return see description */ - protected native int luaL_getsubtable(long ptr, int idx, String fname); /* + public native int luaL_getsubtable(long ptr, int idx, String fname); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) luaL_getsubtable((lua_State *) L, (int) idx, (const char *) fname); @@ -3881,7 +3783,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); @@ -3912,7 +3814,7 @@ public void loadAsGlobal() { * @param index the stack position of the element * @return see description */ - protected native long luaL_len(long ptr, int index); /* + public native long luaL_len(long ptr, int index); /* lua_State * L = (lua_State *) ptr; jlong returnValueReceiver = (jlong) luaL_len((lua_State *) L, (int) index); @@ -3950,7 +3852,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); @@ -3989,7 +3891,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); @@ -4027,7 +3929,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); @@ -4062,7 +3964,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; @@ -4086,7 +3988,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); @@ -4130,7 +4032,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); @@ -4158,7 +4060,7 @@ public void loadAsGlobal() { * @param ptr the lua_State* pointer * @param tname type name */ - protected native void luaL_setmetatable(long ptr, String tname); /* + public native void luaL_setmetatable(long ptr, String tname); /* lua_State * L = (lua_State *) ptr; luaL_setmetatable((lua_State *) L, (const char *) tname); @@ -4187,7 +4089,7 @@ public void loadAsGlobal() { * @param tname type name * @return see description */ - protected native long luaL_testudata(long ptr, int arg, String tname); /* + public native long luaL_testudata(long ptr, int arg, String tname); /* lua_State * L = (lua_State *) ptr; jlong returnValueReceiver = (jlong) luaL_testudata((lua_State *) L, (int) arg, (const char *) tname); @@ -4227,7 +4129,7 @@ public void loadAsGlobal() { * @param len pointer to length * @return see description */ - protected native String luaL_tolstring(long ptr, int idx, long len); /* + public native String luaL_tolstring(long ptr, int idx, long len); /* lua_State * L = (lua_State *) ptr; const char * returnValueReceiver = (const char *) luaL_tolstring((lua_State *) L, (int) idx, (size_t *) len); @@ -4260,7 +4162,7 @@ public void loadAsGlobal() { * @param msg a message * @param level the running level */ - protected native void luaL_traceback(long ptr, long L1, String msg, int level); /* + public native void luaL_traceback(long ptr, long L1, String msg, int level); /* lua_State * L = (lua_State *) ptr; luaL_traceback((lua_State *) L, (lua_State *) L1, (const char *) msg, (int) level); @@ -4286,7 +4188,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); @@ -4322,7 +4224,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); @@ -4363,7 +4265,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); @@ -4380,7 +4282,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); @@ -4400,7 +4302,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); @@ -4419,7 +4321,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); @@ -4440,7 +4342,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); @@ -4461,7 +4363,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); @@ -4469,26 +4371,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 * @@ -4500,7 +4382,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); @@ -4518,7 +4400,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); @@ -4535,7 +4417,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); @@ -4552,7 +4434,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); @@ -4569,7 +4451,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); @@ -4587,7 +4469,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); @@ -4606,7 +4488,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); @@ -4625,7 +4507,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); @@ -4643,7 +4525,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); @@ -4667,7 +4549,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); @@ -4686,7 +4568,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); @@ -4703,7 +4585,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); @@ -4719,7 +4601,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); @@ -4736,7 +4618,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); @@ -4755,7 +4637,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); @@ -4774,7 +4656,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/lua54/jni/mod/luacomp.h b/lua54/jni/mod/luacomp.h index a7713656..6f7b8e83 100644 --- a/lua54/jni/mod/luacomp.h +++ b/lua54/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) { int nresults; return lua_resume(L, NULL, narg, &nresults); diff --git a/lua54/src/main/java/party/iroiro/luajava/lua54/Lua54.java b/lua54/src/main/java/party/iroiro/luajava/lua54/Lua54.java index 1caa940a..bc95727d 100644 --- a/lua54/src/main/java/party/iroiro/luajava/lua54/Lua54.java +++ b/lua54/src/main/java/party/iroiro/luajava/lua54/Lua54.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 Lua54(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/lua54/src/main/java/party/iroiro/luajava/lua54/Lua54Natives.java b/lua54/src/main/java/party/iroiro/luajava/lua54/Lua54Natives.java index f1744956..fc58339c 100644 --- a/lua54/src/main/java/party/iroiro/luajava/lua54/Lua54Natives.java +++ b/lua54/src/main/java/party/iroiro/luajava/lua54/Lua54Natives.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; /** @@ -111,7 +111,7 @@ * */ @SuppressWarnings({"unused", "rawtypes"}) -public class Lua54Natives extends LuaNative { +public class Lua54Natives implements LuaNatives { /*JNI #include "luacustomamalg.h" @@ -171,7 +171,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; */ @@ -196,7 +196,7 @@ public void loadAsGlobal() { * @param idx the stack position * @return see description */ - protected native int lua_absindex(long ptr, int idx); /* + public native int lua_absindex(long ptr, int idx); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_absindex((lua_State *) L, (int) idx); @@ -265,7 +265,7 @@ public void loadAsGlobal() { * @param ptr the lua_State* pointer * @param op the operator */ - protected native void lua_arith(long ptr, int op); /* + public native void lua_arith(long ptr, int op); /* lua_State * L = (lua_State *) ptr; lua_arith((lua_State *) L, (int) op); @@ -300,7 +300,7 @@ public void loadAsGlobal() { * @param n the number of elements * @return see description */ - protected native int lua_checkstack(long ptr, int n); /* + public native int lua_checkstack(long ptr, int n); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_checkstack((lua_State *) L, (int) n); @@ -336,7 +336,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); @@ -372,7 +372,7 @@ public void loadAsGlobal() { * @param ptr the lua_State* pointer * @param index the stack position of the element */ - protected native void lua_closeslot(long ptr, int index); /* + public native void lua_closeslot(long ptr, int index); /* lua_State * L = (lua_State *) ptr; lua_closeslot((lua_State *) L, (int) index); @@ -416,7 +416,7 @@ public void loadAsGlobal() { * @param from a thread * @return see description */ - protected native int lua_closethread(long ptr, long from); /* + public native int lua_closethread(long ptr, long from); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_closethread((lua_State *) L, (lua_State *) from); @@ -466,7 +466,7 @@ public void loadAsGlobal() { * @param op the operator * @return see description */ - protected native int lua_compare(long ptr, int index1, int index2, int op); /* + public native int lua_compare(long ptr, int index1, int index2, int op); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_compare((lua_State *) L, (int) index1, (int) index2, (int) op); @@ -498,7 +498,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); @@ -527,7 +527,7 @@ public void loadAsGlobal() { * @param fromidx a stack position * @param toidx another stack position */ - protected native void lua_copy(long ptr, int fromidx, int toidx); /* + public native void lua_copy(long ptr, int fromidx, int toidx); /* lua_State * L = (lua_State *) ptr; lua_copy((lua_State *) L, (int) fromidx, (int) toidx); @@ -561,7 +561,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); @@ -590,7 +590,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); @@ -625,7 +625,7 @@ public void loadAsGlobal() { * @param k the field name * @return see description */ - protected native int lua_getfield(long ptr, int index, String k); /* + public native int lua_getfield(long ptr, int index, String k); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_getfield((lua_State *) L, (int) index, (const char *) k); @@ -659,7 +659,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); @@ -698,7 +698,7 @@ public void loadAsGlobal() { * @param ptr the lua_State* pointer * @return see description */ - protected native long lua_getextraspace(long ptr); /* + public native long lua_getextraspace(long ptr); /* lua_State * L = (lua_State *) ptr; jlong returnValueReceiver = (jlong) lua_getextraspace((lua_State *) L); @@ -726,7 +726,7 @@ public void loadAsGlobal() { * @param name the name * @return see description */ - protected native int lua_getglobal(long ptr, String name); /* + public native int lua_getglobal(long ptr, String name); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_getglobal((lua_State *) L, (const char *) name); @@ -753,7 +753,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); @@ -787,7 +787,7 @@ public void loadAsGlobal() { * @param i i * @return see description */ - protected native int lua_geti(long ptr, int index, long i); /* + public native int lua_geti(long ptr, int index, long i); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_geti((lua_State *) L, (int) index, (lua_Integer) i); @@ -821,7 +821,7 @@ public void loadAsGlobal() { * @param index the stack position of the element * @param i i */ - protected native void luaJ_geti(long ptr, int index, long i); /* + public native void luaJ_geti(long ptr, int index, long i); /* lua_State * L = (lua_State *) ptr; lua_geti((lua_State *) L, (int) index, (lua_Integer) i); @@ -850,7 +850,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); @@ -890,7 +890,7 @@ public void loadAsGlobal() { * @param index the stack position of the element * @return see description */ - protected native int lua_gettable(long ptr, int index); /* + public native int lua_gettable(long ptr, int index); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_gettable((lua_State *) L, (int) index); @@ -929,7 +929,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); @@ -957,7 +957,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); @@ -992,7 +992,7 @@ public void loadAsGlobal() { * @param n the number of elements * @return see description */ - protected native int lua_getiuservalue(long ptr, int index, int n); /* + public native int lua_getiuservalue(long ptr, int index, int n); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_getiuservalue((lua_State *) L, (int) index, (int) n); @@ -1021,7 +1021,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); @@ -1048,7 +1048,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); @@ -1076,7 +1076,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); @@ -1104,7 +1104,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); @@ -1133,7 +1133,7 @@ public void loadAsGlobal() { * @param index the stack position of the element * @return see description */ - protected native int lua_isinteger(long ptr, int index); /* + public native int lua_isinteger(long ptr, int index); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_isinteger((lua_State *) L, (int) index); @@ -1161,7 +1161,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); @@ -1189,7 +1189,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); @@ -1217,7 +1217,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); @@ -1246,7 +1246,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); @@ -1275,7 +1275,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); @@ -1304,7 +1304,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); @@ -1332,7 +1332,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); @@ -1360,7 +1360,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); @@ -1388,7 +1388,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); @@ -1415,7 +1415,7 @@ public void loadAsGlobal() { * @param ptr the lua_State* pointer * @return see description */ - protected native int lua_isyieldable(long ptr); /* + public native int lua_isyieldable(long ptr); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_isyieldable((lua_State *) L); @@ -1444,7 +1444,7 @@ public void loadAsGlobal() { * @param ptr the lua_State* pointer * @param index the stack position of the element */ - protected native void lua_len(long ptr, int index); /* + public native void lua_len(long ptr, int index); /* lua_State * L = (lua_State *) ptr; lua_len((lua_State *) L, (int) index); @@ -1469,7 +1469,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); @@ -1503,7 +1503,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); @@ -1543,7 +1543,7 @@ public void loadAsGlobal() { * @param nuvalue number of associated Lua values (user values) * @return see description */ - protected native long lua_newuserdatauv(long ptr, long size, int nuvalue); /* + public native long lua_newuserdatauv(long ptr, long size, int nuvalue); /* lua_State * L = (lua_State *) ptr; jlong returnValueReceiver = (jlong) lua_newuserdatauv((lua_State *) L, (size_t) size, (int) nuvalue); @@ -1607,7 +1607,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); @@ -1675,7 +1675,7 @@ public void loadAsGlobal() { * @param msgh stack position of message handler * @return see description */ - protected native int lua_pcall(long ptr, int nargs, int nresults, int msgh); /* + public native int lua_pcall(long ptr, int nargs, int nresults, int msgh); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_pcall((lua_State *) L, (int) nargs, (int) nresults, (int) msgh); @@ -1683,72 +1683,6 @@ public void loadAsGlobal() { */ - /** - * Wrapper of lua_pcall - * - *

-     * [-(nargs + 1), +(nresults|1), –]
-     * 
- * - *

-     * int lua_pcall (lua_State *L, int nargs, int nresults, int msgh);
-     * 
- * - *

- * Calls a function (or a callable object) 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 object), - * and returns an error code. - * Like lua_call, - * lua_pcall always removes the function - * and its arguments from the stack. - *

- * - *

- * If msgh is 0, - * then the error object returned on the stack - * is exactly the original error object. - * Otherwise, msgh is the stack index of a - * message handler. - * (This index cannot be a pseudo-index.) - * In case of runtime errors, - * this handler will be called with the error object - * and its return value will be the object - * returned on the stack by lua_pcall. - *

- * - *

- * Typically, the message handler is used to add more debug - * information to the error object, 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 one of the following status codes: - * LUA_OK, LUA_ERRRUN, LUA_ERRMEM, or LUA_ERRERR. - *

- * - * @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 msgh stack position of message handler - */ - protected native void luaJ_pcall(long ptr, int nargs, int nresults, int msgh); /* - lua_State * L = (lua_State *) ptr; - - lua_pcall((lua_State *) L, (int) nargs, (int) nresults, (int) msgh); - */ - - /** * Wrapper of lua_pop * @@ -1768,7 +1702,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); @@ -1793,7 +1727,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); @@ -1817,7 +1751,7 @@ public void loadAsGlobal() { * * @param ptr the lua_State* pointer */ - protected native void lua_pushglobaltable(long ptr); /* + public native void lua_pushglobaltable(long ptr); /* lua_State * L = (lua_State *) ptr; lua_pushglobaltable((lua_State *) L); @@ -1842,7 +1776,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, @@ -1891,7 +1825,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); @@ -1915,7 +1849,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); @@ -1940,7 +1874,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); @@ -1978,7 +1912,7 @@ public void loadAsGlobal() { * @param s the string * @return see description */ - protected native String lua_pushstring(long ptr, String s); /* + public native String lua_pushstring(long ptr, String s); /* lua_State * L = (lua_State *) ptr; const char * returnValueReceiver = (const char *) lua_pushstring((lua_State *) L, (const char *) s); @@ -2016,7 +1950,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); @@ -2042,7 +1976,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); @@ -2069,7 +2003,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); @@ -2100,7 +2034,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); @@ -2129,7 +2063,7 @@ public void loadAsGlobal() { * @param index the stack position of the element * @return see description */ - protected native int lua_rawget(long ptr, int index); /* + public native int lua_rawget(long ptr, int index); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_rawget((lua_State *) L, (int) index); @@ -2157,7 +2091,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); @@ -2191,7 +2125,7 @@ public void loadAsGlobal() { * @param n the number / the number of elements * @return see description */ - protected native int lua_rawgeti(long ptr, int index, long n); /* + public native int lua_rawgeti(long ptr, int index, long n); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_rawgeti((lua_State *) L, (int) index, (lua_Integer) n); @@ -2225,7 +2159,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, (lua_Integer) n); @@ -2260,7 +2194,7 @@ public void loadAsGlobal() { * @param p the lightuserdata * @return see description */ - protected native int lua_rawgetp(long ptr, int index, long p); /* + public native int lua_rawgetp(long ptr, int index, long p); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_rawgetp((lua_State *) L, (int) index, (const void *) p); @@ -2293,7 +2227,7 @@ public void loadAsGlobal() { * @param index the stack position of the element * @return see description */ - protected native long lua_rawlen(long ptr, int index); /* + public native long lua_rawlen(long ptr, int index); /* lua_State * L = (lua_State *) ptr; jlong returnValueReceiver = (jlong) lua_rawlen((lua_State *) L, (int) index); @@ -2321,7 +2255,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); @@ -2355,7 +2289,7 @@ public void loadAsGlobal() { * @param index the stack position of the element * @param i i */ - protected native void lua_rawseti(long ptr, int index, int i); /* + public native void lua_rawseti(long ptr, int index, int i); /* lua_State * L = (lua_State *) ptr; lua_rawseti((lua_State *) L, (int) index, (lua_Integer) i); @@ -2390,7 +2324,7 @@ public void loadAsGlobal() { * @param index the stack position of the element * @param p the lightuserdata */ - protected native void lua_rawsetp(long ptr, int index, long p); /* + public native void lua_rawsetp(long ptr, int index, long p); /* lua_State * L = (lua_State *) ptr; lua_rawsetp((lua_State *) L, (int) index, (const void *) p); @@ -2418,7 +2352,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); @@ -2446,7 +2380,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); @@ -2473,7 +2407,7 @@ public void loadAsGlobal() { * @param ptr the lua_State* pointer * @return see description */ - protected native int lua_resetthread(long ptr); /* + public native int lua_resetthread(long ptr); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_resetthread((lua_State *) L); @@ -2537,7 +2471,7 @@ public void loadAsGlobal() { * @param nresults pointer to the number of results * @return see description */ - protected native int lua_resume(long ptr, long from, int nargs, long nresults); /* + public native int lua_resume(long ptr, long from, int nargs, long nresults); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_resume((lua_State *) L, (lua_State *) from, (int) nargs, (int *) nresults); @@ -2573,7 +2507,7 @@ public void loadAsGlobal() { * @param idx the stack position * @param n the number of elements */ - protected native void lua_rotate(long ptr, int idx, int n); /* + public native void lua_rotate(long ptr, int idx, int n); /* lua_State * L = (lua_State *) ptr; lua_rotate((lua_State *) L, (int) idx, (int) n); @@ -2607,7 +2541,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); @@ -2633,7 +2567,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); @@ -2667,7 +2601,7 @@ public void loadAsGlobal() { * @param index the stack position of the element * @param n the number / the number of elements */ - protected native void lua_seti(long ptr, int index, long n); /* + public native void lua_seti(long ptr, int index, long n); /* lua_State * L = (lua_State *) ptr; lua_seti((lua_State *) L, (int) index, (lua_Integer) n); @@ -2697,7 +2631,7 @@ public void loadAsGlobal() { * @param n the number of elements * @return see description */ - protected native int lua_setiuservalue(long ptr, int index, int n); /* + public native int lua_setiuservalue(long ptr, int index, int n); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) lua_setiuservalue((lua_State *) L, (int) index, (int) n); @@ -2731,7 +2665,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); @@ -2764,7 +2698,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); @@ -2798,7 +2732,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); @@ -2832,7 +2766,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); @@ -2871,7 +2805,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); @@ -2908,7 +2842,7 @@ public void loadAsGlobal() { * @param s the string * @return see description */ - protected native long lua_stringtonumber(long ptr, String s); /* + public native long lua_stringtonumber(long ptr, String s); /* lua_State * L = (lua_State *) ptr; jlong returnValueReceiver = (jlong) lua_stringtonumber((lua_State *) L, (const char *) s); @@ -2942,7 +2876,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); @@ -2994,7 +2928,7 @@ public void loadAsGlobal() { * @param ptr the lua_State* pointer * @param index the stack position of the element */ - protected native void lua_toclose(long ptr, int index); /* + public native void lua_toclose(long ptr, int index); /* lua_State * L = (lua_State *) ptr; lua_toclose((lua_State *) L, (int) index); @@ -3020,7 +2954,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) { @@ -3061,7 +2995,7 @@ public void loadAsGlobal() { * @param isnum pointer to a boolean to be assigned * @return see description */ - protected native long lua_tointegerx(long ptr, int index, long isnum); /* + public native long lua_tointegerx(long ptr, int index, long isnum); /* lua_State * L = (lua_State *) ptr; jlong returnValueReceiver = (jlong) lua_tointegerx((lua_State *) L, (int) index, (int *) isnum); @@ -3088,7 +3022,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); @@ -3126,7 +3060,7 @@ public void loadAsGlobal() { * @param isnum pointer to a boolean to be assigned * @return see description */ - protected native double lua_tonumberx(long ptr, int index, long isnum); /* + public native double lua_tonumberx(long ptr, int index, long isnum); /* lua_State * L = (lua_State *) ptr; jdouble returnValueReceiver = (jdouble) lua_tonumberx((lua_State *) L, (int) index, (int *) isnum); @@ -3162,7 +3096,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); @@ -3189,7 +3123,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); @@ -3219,7 +3153,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); @@ -3250,7 +3184,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); @@ -3290,7 +3224,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); @@ -3318,7 +3252,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); @@ -3346,7 +3280,7 @@ public void loadAsGlobal() { * @param i i * @return see description */ - protected native int lua_upvalueindex(int i); /* + public native int lua_upvalueindex(int i); /* jint returnValueReceiver = (jint) lua_upvalueindex((int) i); return returnValueReceiver; */ @@ -3370,7 +3304,7 @@ public void loadAsGlobal() { * @param ptr the lua_State* pointer * @return see description */ - protected native double lua_version(long ptr); /* + public native double lua_version(long ptr); /* lua_State * L = (lua_State *) ptr; jdouble returnValueReceiver = (jdouble) lua_version((lua_State *) L); @@ -3403,7 +3337,7 @@ public void loadAsGlobal() { * @param msg a message * @param tocont continue or not */ - protected native void lua_warning(long ptr, String msg, int tocont); /* + public native void lua_warning(long ptr, String msg, int tocont); /* lua_State * L = (lua_State *) ptr; lua_warning((lua_State *) L, (const char *) msg, (int) tocont); @@ -3434,7 +3368,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); */ @@ -3464,7 +3398,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); @@ -3490,7 +3424,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); @@ -3516,7 +3450,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); @@ -3553,7 +3487,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); @@ -3594,7 +3528,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); @@ -3637,7 +3571,7 @@ public void loadAsGlobal() { * @param n the index in the upvalue * @return see description */ - protected native long lua_upvalueid(long ptr, int funcindex, int n); /* + public native long lua_upvalueid(long ptr, int funcindex, int n); /* lua_State * L = (lua_State *) ptr; jlong returnValueReceiver = (jlong) lua_upvalueid((lua_State *) L, (int) funcindex, (int) n); @@ -3668,7 +3602,7 @@ public void loadAsGlobal() { * @param funcindex2 the stack position of the closure * @param n2 n2 */ - protected native void lua_upvaluejoin(long ptr, int funcindex1, int n1, int funcindex2, int n2); /* + public native void lua_upvaluejoin(long ptr, int funcindex1, int n1, int funcindex2, int n2); /* lua_State * L = (lua_State *) ptr; lua_upvaluejoin((lua_State *) L, (int) funcindex1, (int) n1, (int) funcindex2, (int) n2); @@ -3705,7 +3639,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); @@ -3742,7 +3676,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); @@ -3771,7 +3705,7 @@ public void loadAsGlobal() { * @param stat (I have no idea) * @return see description */ - protected native int luaL_execresult(long ptr, int stat); /* + public native int luaL_execresult(long ptr, int stat); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) luaL_execresult((lua_State *) L, (int) stat); @@ -3801,7 +3735,7 @@ public void loadAsGlobal() { * @param fname the filename * @return see description */ - protected native int luaL_fileresult(long ptr, int stat, String fname); /* + public native int luaL_fileresult(long ptr, int stat, String fname); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) luaL_fileresult((lua_State *) L, (int) stat, (const char *) fname); @@ -3833,7 +3767,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); @@ -3863,7 +3797,7 @@ public void loadAsGlobal() { * @param tname type name * @return see description */ - protected native int luaL_getmetatable(long ptr, String tname); /* + public native int luaL_getmetatable(long ptr, String tname); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) luaL_getmetatable((lua_State *) L, (const char *) tname); @@ -3892,7 +3826,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); @@ -3924,7 +3858,7 @@ public void loadAsGlobal() { * @param fname the filename * @return see description */ - protected native int luaL_getsubtable(long ptr, int idx, String fname); /* + public native int luaL_getsubtable(long ptr, int idx, String fname); /* lua_State * L = (lua_State *) ptr; jint returnValueReceiver = (jint) luaL_getsubtable((lua_State *) L, (int) idx, (const char *) fname); @@ -3959,7 +3893,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); @@ -3990,7 +3924,7 @@ public void loadAsGlobal() { * @param index the stack position of the element * @return see description */ - protected native long luaL_len(long ptr, int index); /* + public native long luaL_len(long ptr, int index); /* lua_State * L = (lua_State *) ptr; jlong returnValueReceiver = (jlong) luaL_len((lua_State *) L, (int) index); @@ -4028,7 +3962,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); @@ -4067,7 +4001,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); @@ -4105,7 +4039,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); @@ -4139,7 +4073,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; @@ -4163,7 +4097,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); @@ -4187,7 +4121,7 @@ public void loadAsGlobal() { * * @param ptr the lua_State* pointer */ - protected native void luaL_pushfail(long ptr); /* + public native void luaL_pushfail(long ptr); /* lua_State * L = (lua_State *) ptr; luaL_pushfail((lua_State *) L); @@ -4231,7 +4165,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); @@ -4259,7 +4193,7 @@ public void loadAsGlobal() { * @param ptr the lua_State* pointer * @param tname type name */ - protected native void luaL_setmetatable(long ptr, String tname); /* + public native void luaL_setmetatable(long ptr, String tname); /* lua_State * L = (lua_State *) ptr; luaL_setmetatable((lua_State *) L, (const char *) tname); @@ -4288,7 +4222,7 @@ public void loadAsGlobal() { * @param tname type name * @return see description */ - protected native long luaL_testudata(long ptr, int arg, String tname); /* + public native long luaL_testudata(long ptr, int arg, String tname); /* lua_State * L = (lua_State *) ptr; jlong returnValueReceiver = (jlong) luaL_testudata((lua_State *) L, (int) arg, (const char *) tname); @@ -4328,7 +4262,7 @@ public void loadAsGlobal() { * @param len pointer to length * @return see description */ - protected native String luaL_tolstring(long ptr, int idx, long len); /* + public native String luaL_tolstring(long ptr, int idx, long len); /* lua_State * L = (lua_State *) ptr; const char * returnValueReceiver = (const char *) luaL_tolstring((lua_State *) L, (int) idx, (size_t *) len); @@ -4361,7 +4295,7 @@ public void loadAsGlobal() { * @param msg a message * @param level the running level */ - protected native void luaL_traceback(long ptr, long L1, String msg, int level); /* + public native void luaL_traceback(long ptr, long L1, String msg, int level); /* lua_State * L = (lua_State *) ptr; luaL_traceback((lua_State *) L, (lua_State *) L1, (const char *) msg, (int) level); @@ -4387,7 +4321,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); @@ -4423,7 +4357,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); @@ -4464,7 +4398,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); @@ -4481,7 +4415,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); @@ -4501,7 +4435,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); @@ -4520,7 +4454,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); @@ -4541,7 +4475,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); @@ -4562,7 +4496,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); @@ -4570,26 +4504,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 * @@ -4601,7 +4515,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); @@ -4619,7 +4533,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); @@ -4636,7 +4550,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); @@ -4653,7 +4567,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); @@ -4670,7 +4584,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); @@ -4688,7 +4602,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); @@ -4707,7 +4621,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); @@ -4726,7 +4640,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); @@ -4744,7 +4658,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); @@ -4768,7 +4682,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); @@ -4787,7 +4701,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); @@ -4804,7 +4718,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); @@ -4820,7 +4734,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); @@ -4837,7 +4751,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); @@ -4856,7 +4770,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); @@ -4875,7 +4789,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/luaj/src/main/java/party/iroiro/luajava/luaj/LuaJ.java b/luaj/src/main/java/party/iroiro/luajava/luaj/LuaJ.java index e3c626c2..56f0131d 100644 --- a/luaj/src/main/java/party/iroiro/luajava/luaj/LuaJ.java +++ b/luaj/src/main/java/party/iroiro/luajava/luaj/LuaJ.java @@ -3,7 +3,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; @@ -27,7 +27,7 @@ public LuaJ(long L, int id, AbstractLua mainThread) { super(mainThread.getLuaNative(), L, id, mainThread); } - private static LuaNative getNatives() { + private static LuaNatives getNatives() { synchronized (natives) { if (natives.get() == null) { natives.set(new LuaJNatives()); diff --git a/luaj/src/main/java/party/iroiro/luajava/luaj/LuaJNatives.java b/luaj/src/main/java/party/iroiro/luajava/luaj/LuaJNatives.java index 0afca503..c2ceacbd 100644 --- a/luaj/src/main/java/party/iroiro/luajava/luaj/LuaJNatives.java +++ b/luaj/src/main/java/party/iroiro/luajava/luaj/LuaJNatives.java @@ -20,7 +20,7 @@ import static party.iroiro.luajava.luaj.LuaJConsts.*; -public class LuaJNatives extends LuaNative { +public class LuaJNatives implements LuaNatives { final static LuaJInstances instances = new LuaJInstances(); @Override @@ -29,23 +29,23 @@ public void loadAsGlobal() { } @Override - protected int getRegistryIndex() { + public int getRegistryIndex() { return LuaJConsts.LUA_REGISTRYINDEX; } @Override - protected int lua_checkstack(long ptr, int extra) { + public int lua_checkstack(long ptr, int extra) { // Pointless return 1; } @Override - protected void lua_close(long ptr) { + public void lua_close(long ptr) { instances.remove((int) ptr); } @Override - protected void lua_concat(long ptr, int n) { + public void lua_concat(long ptr, int n) { LuaJState L = instances.get((int) ptr); if (n < 0) { throw new IllegalArgumentException(); @@ -66,30 +66,30 @@ protected void lua_concat(long ptr, int n) { } @Override - protected void lua_createtable(long ptr, int narr, int nrec) { + public void lua_createtable(long ptr, int narr, int nrec) { LuaJState L = instances.get((int) ptr); L.push(LuaValue.tableOf(narr, nrec)); } @Override - protected int lua_error(long ptr) { + public int lua_error(long ptr) { throw new UnsupportedOperationException(); } @Override - protected void luaJ_getfield(long ptr, int index, String k) { + public void luaJ_getfield(long ptr, int index, String k) { LuaJState L = instances.get((int) ptr); L.push(L.toLuaValue(index).get(k)); } @Override - protected void luaJ_getglobal(long ptr, String name) { + public void luaJ_getglobal(long ptr, String name) { LuaJState L = instances.get((int) ptr); L.push(L.globals.get(name)); } @Override - protected int lua_getmetatable(long ptr, int index) { + public int lua_getmetatable(long ptr, int index) { LuaJState L = instances.get((int) ptr); LuaValue value = L.toLuaValue(index); LuaValue metatable = value.getmetatable(); @@ -101,7 +101,7 @@ protected int lua_getmetatable(long ptr, int index) { } @Override - protected void luaJ_gettable(long ptr, int index) { + public void luaJ_gettable(long ptr, int index) { LuaJState L = instances.get((int) ptr); LuaValue value = L.toLuaValue(index); LuaValue key = L.toLuaValue(-1); @@ -110,13 +110,13 @@ protected void luaJ_gettable(long ptr, int index) { } @Override - protected int lua_gettop(long ptr) { + public int lua_gettop(long ptr) { LuaJState L = instances.get((int) ptr); return L.getTop(); } @Override - protected void lua_insert(long ptr, int index) { + public void lua_insert(long ptr, int index) { LuaJState L = instances.get((int) ptr); LuaValue value = L.toLuaValue(-1); index = L.toAbsoluteIndex(index); @@ -125,105 +125,105 @@ protected void lua_insert(long ptr, int index) { } @Override - protected int lua_isboolean(long ptr, int index) { + public int lua_isboolean(long ptr, int index) { LuaJState L = instances.get((int) ptr); LuaValue value = L.toLuaValue(index); return value.isboolean() ? 1 : 0; } @Override - protected int lua_iscfunction(long ptr, int index) { + public int lua_iscfunction(long ptr, int index) { LuaJState L = instances.get((int) ptr); LuaValue value = L.toLuaValue(index); return value.isfunction() && !value.isclosure() ? 1 : 0; } @Override - protected int lua_isfunction(long ptr, int index) { + public int lua_isfunction(long ptr, int index) { LuaJState L = instances.get((int) ptr); LuaValue value = L.toLuaValue(index); return value.isfunction() ? 1 : 0; } @Override - protected int lua_islightuserdata(long ptr, int index) { + public int lua_islightuserdata(long ptr, int index) { return lua_type(ptr, index) == LUA_TLIGHTUSERDATA ? 1 : 0; } @Override - protected int lua_isnil(long ptr, int index) { + public int lua_isnil(long ptr, int index) { LuaJState L = instances.get((int) ptr); LuaValue value = L.toLuaValue(index); return value.isnil() ? 1 : 0; } @Override - protected int lua_isnone(long ptr, int index) { + public int lua_isnone(long ptr, int index) { LuaJState L = instances.get((int) ptr); LuaValue value = L.toLuaValue(index); return value == LuaValue.NONE ? 1 : 0; } @Override - protected int lua_isnoneornil(long ptr, int index) { + public int lua_isnoneornil(long ptr, int index) { LuaJState L = instances.get((int) ptr); LuaValue value = L.toLuaValue(index); return value == LuaValue.NONE || value.isnil() ? 1 : 0; } @Override - protected int lua_isnumber(long ptr, int index) { + public int lua_isnumber(long ptr, int index) { LuaJState L = instances.get((int) ptr); LuaValue value = L.toLuaValue(index); return value.isnumber() ? 1 : 0; } @Override - protected int luaJ_isinteger(long ptr, int index) { + public int luaJ_isinteger(long ptr, int index) { return 0; } @Override - protected int lua_isstring(long ptr, int index) { + public int lua_isstring(long ptr, int index) { LuaJState L = instances.get((int) ptr); LuaValue value = L.toLuaValue(index); return value.isstring() ? 1 : 0; } @Override - protected int lua_istable(long ptr, int index) { + public int lua_istable(long ptr, int index) { LuaJState L = instances.get((int) ptr); LuaValue value = L.toLuaValue(index); return value.istable() ? 1 : 0; } @Override - protected int lua_isthread(long ptr, int index) { + public int lua_isthread(long ptr, int index) { LuaJState L = instances.get((int) ptr); LuaValue value = L.toLuaValue(index); return value.isthread() ? 1 : 0; } @Override - protected int lua_isuserdata(long ptr, int index) { + public int lua_isuserdata(long ptr, int index) { LuaJState L = instances.get((int) ptr); LuaValue value = L.toLuaValue(index); return value.isuserdata() ? 1 : 0; } - protected void lua_newuserdata(long ptr, Object object) { + public void lua_newuserdata(long ptr, Object object) { LuaJState L = instances.get((int) ptr); L.push(LuaValue.userdataOf(object)); } @Override - protected void lua_newtable(long ptr) { + public void lua_newtable(long ptr) { LuaJState L = instances.get((int) ptr); L.push(LuaValue.tableOf()); } @Override - protected long lua_newthread(long ptr) { + public long lua_newthread(long ptr) { LuaJState L = instances.get((int) ptr); LuaThread thread = new LuaThread(L.globals, new FunctionInvoker()); LuaInstances.Token handle = instances.add(); @@ -277,7 +277,7 @@ public Varargs invoke(Varargs args) { } @Override - protected int lua_next(long ptr, int index) { + public int lua_next(long ptr, int index) { LuaJState L = instances.get((int) ptr); LuaValue table = L.toLuaValue(index); LuaValue key = L.toLuaValue(-1); @@ -292,7 +292,7 @@ protected int lua_next(long ptr, int index) { } @Override - protected int lua_pcall(long ptr, int nargs, int nresults, int errfunc) { + public int lua_pcall(long ptr, int nargs, int nresults, int errfunc) { LuaJState L = instances.get((int) ptr); LuaValue f = L.toLuaValue(-nargs - 1); LuaValue[] args = new LuaValue[nargs]; @@ -338,54 +338,49 @@ protected int lua_pcall(long ptr, int nargs, int nresults, int errfunc) { } @Override - protected void luaJ_pcall(long ptr, int nargs, int nresults, int errfunc) { - lua_pcall(ptr, nargs, nresults, errfunc); - } - - @Override - protected void lua_pop(long ptr, int n) { + public void lua_pop(long ptr, int n) { LuaJState L = instances.get((int) ptr); L.pop(n); } @Override - protected void lua_pushboolean(long ptr, int b) { + public void lua_pushboolean(long ptr, int b) { LuaJState L = instances.get((int) ptr); L.push(LuaValue.valueOf(b != 0)); } @Override - protected void lua_pushinteger(long ptr, long n) { + public void lua_pushinteger(long ptr, long n) { LuaJState L = instances.get((int) ptr); L.push(LuaInteger.valueOf(n)); } @Override - protected void lua_pushlightuserdata(long ptr, long p) { + public void lua_pushlightuserdata(long ptr, long p) { LuaJState L = instances.get((int) ptr); L.push(new LightUserdata(p)); } @Override - protected void lua_pushnil(long ptr) { + public void lua_pushnil(long ptr) { LuaJState L = instances.get((int) ptr); L.push(LuaValue.NIL); } @Override - protected void lua_pushnumber(long ptr, double n) { + public void lua_pushnumber(long ptr, double n) { LuaJState L = instances.get((int) ptr); L.push(LuaValue.valueOf(n)); } @Override - protected void luaJ_pushstring(long ptr, String s) { + public void luaJ_pushstring(long ptr, String s) { LuaJState L = instances.get((int) ptr); L.push(LuaValue.valueOf(s)); } @Override - protected int lua_pushthread(long ptr) { + public int lua_pushthread(long ptr) { LuaJState L = instances.get((int) ptr); if (L.thread != null) { L.push(L.thread); @@ -397,14 +392,14 @@ protected int lua_pushthread(long ptr) { } @Override - protected void lua_pushvalue(long ptr, int index) { + public void lua_pushvalue(long ptr, int index) { LuaJState L = instances.get((int) ptr); LuaValue value = L.toLuaValue(index); L.push(value); } @Override - protected int lua_rawequal(long ptr, int index1, int index2) { + public int lua_rawequal(long ptr, int index1, int index2) { LuaJState L = instances.get((int) ptr); LuaValue v1 = L.toLuaValue(index1); LuaValue v2 = L.toLuaValue(index2); @@ -412,7 +407,7 @@ protected int lua_rawequal(long ptr, int index1, int index2) { } @Override - protected void luaJ_rawget(long ptr, int index) { + public void luaJ_rawget(long ptr, int index) { LuaJState L = instances.get((int) ptr); LuaValue value = L.toLuaValue(index); LuaValue key = L.toLuaValue(-1); @@ -421,14 +416,14 @@ protected void luaJ_rawget(long ptr, int index) { } @Override - protected void luaJ_rawgeti(long ptr, int index, int n) { + public void luaJ_rawgeti(long ptr, int index, int n) { LuaJState L = instances.get((int) ptr); LuaValue value = L.toLuaValue(index); L.push(value.rawget(n)); } @Override - protected void lua_rawset(long ptr, int index) { + public void lua_rawset(long ptr, int index) { LuaJState L = instances.get((int) ptr); LuaValue table = L.toLuaValue(index); LuaValue key = L.toLuaValue(-2); @@ -438,7 +433,7 @@ protected void lua_rawset(long ptr, int index) { } @Override - protected void lua_rawseti(long ptr, int index, int n) { + public void lua_rawseti(long ptr, int index, int n) { LuaJState L = instances.get((int) ptr); LuaValue table = L.toLuaValue(index); LuaValue value = L.toLuaValue(-1); @@ -447,13 +442,13 @@ protected void lua_rawseti(long ptr, int index, int n) { } @Override - protected void lua_remove(long ptr, int index) { + public void lua_remove(long ptr, int index) { LuaJState L = instances.get((int) ptr); L.remove(index); } @Override - protected void lua_replace(long ptr, int index) { + public void lua_replace(long ptr, int index) { LuaJState L = instances.get((int) ptr); LuaValue value = L.toLuaValue(-1); index = L.toAbsoluteIndex(index); @@ -462,7 +457,7 @@ protected void lua_replace(long ptr, int index) { } @Override - protected void lua_setfield(long ptr, int index, String k) { + public void lua_setfield(long ptr, int index, String k) { LuaJState L = instances.get((int) ptr); LuaValue table = L.toLuaValue(index); LuaValue value = L.toLuaValue(-1); @@ -471,7 +466,7 @@ protected void lua_setfield(long ptr, int index, String k) { } @Override - protected void lua_setglobal(long ptr, String name) { + public void lua_setglobal(long ptr, String name) { LuaJState L = instances.get((int) ptr); LuaValue value = L.toLuaValue(-1); L.pop(1); @@ -479,7 +474,7 @@ protected void lua_setglobal(long ptr, String name) { } @Override - protected void luaJ_setmetatable(long ptr, int index) { + public void luaJ_setmetatable(long ptr, int index) { LuaJState L = instances.get((int) ptr); LuaValue value = L.toLuaValue(index); LuaValue meta = L.toLuaValue(-1); @@ -488,7 +483,7 @@ protected void luaJ_setmetatable(long ptr, int index) { } @Override - protected void lua_settable(long ptr, int index) { + public void lua_settable(long ptr, int index) { LuaJState L = instances.get((int) ptr); LuaValue table = L.toLuaValue(index); LuaValue key = L.toLuaValue(-2); @@ -498,13 +493,13 @@ protected void lua_settable(long ptr, int index) { } @Override - protected void lua_settop(long ptr, int index) { + public void lua_settop(long ptr, int index) { LuaJState L = instances.get((int) ptr); L.setTop(index); } @Override - protected int lua_status(long ptr) { + public int lua_status(long ptr) { LuaJState L = instances.get((int) ptr); if (L.thread == null) { return 0; @@ -516,50 +511,50 @@ protected int lua_status(long ptr) { } @Override - protected int lua_toboolean(long ptr, int index) { + public int lua_toboolean(long ptr, int index) { LuaJState L = instances.get((int) ptr); LuaValue value = L.toLuaValue(index); return value.toboolean() ? 1 : 0; } @Override - protected long lua_tointeger(long ptr, int index) { + public long lua_tointeger(long ptr, int index) { LuaJState L = instances.get((int) ptr); LuaValue value = L.toLuaValue(index); return value.tolong(); } @Override - protected double lua_tonumber(long ptr, int index) { + public double lua_tonumber(long ptr, int index) { LuaJState L = instances.get((int) ptr); LuaValue value = L.toLuaValue(index); return value.todouble(); } @Override - protected long lua_topointer(long ptr, int index) { + public long lua_topointer(long ptr, int index) { throw new UnsupportedOperationException(); } @Override - protected String lua_tostring(long ptr, int index) { + public String lua_tostring(long ptr, int index) { LuaJState L = instances.get((int) ptr); LuaValue value = L.toLuaValue(index); return value.tojstring(); } @Override - protected long lua_tothread(long ptr, int index) { + public long lua_tothread(long ptr, int index) { throw new UnsupportedOperationException(); } @Override - protected long lua_touserdata(long ptr, int index) { + public long lua_touserdata(long ptr, int index) { throw new UnsupportedOperationException(); } @Override - protected int lua_type(long ptr, int index) { + public int lua_type(long ptr, int index) { LuaJState L = instances.get((int) ptr); LuaValue value = L.toLuaValue(index); // LuaJ: NONE.type() == NIL.type()... What. @@ -567,14 +562,14 @@ protected int lua_type(long ptr, int index) { } @Override - protected String lua_typename(long ptr, int index) { + public String lua_typename(long ptr, int index) { LuaJState L = instances.get((int) ptr); LuaValue value = L.toLuaValue(index); return value.typename(); } @Override - protected void lua_xmove(long from, long to, int n) { + public void lua_xmove(long from, long to, int n) { LuaJState L = instances.get((int) from); LuaJState J = instances.get((int) to); for (int i = 0; i < n; i++) { @@ -584,22 +579,22 @@ protected void lua_xmove(long from, long to, int n) { } @Override - protected int lua_yield(long ptr, int nresults) { + public int lua_yield(long ptr, int nresults) { throw new UnsupportedOperationException(); } @Override - protected int lua_gethookcount(long ptr) { + public int lua_gethookcount(long ptr) { throw new UnsupportedOperationException(); } @Override - protected int lua_gethookmask(long ptr) { + public int lua_gethookmask(long ptr) { throw new UnsupportedOperationException(); } @Override - protected String lua_getupvalue(long ptr, int funcindex, int n) { + public String lua_getupvalue(long ptr, int funcindex, int n) { LuaJState L = instances.get((int) ptr); LuaClosure value = (LuaClosure) L.toLuaValue(funcindex); L.push(value.upValues[n].getValue()); @@ -607,7 +602,7 @@ protected String lua_getupvalue(long ptr, int funcindex, int n) { } @Override - protected String lua_setupvalue(long ptr, int funcindex, int n) { + public String lua_setupvalue(long ptr, int funcindex, int n) { LuaJState L = instances.get((int) ptr); LuaClosure up = (LuaClosure) L.toLuaValue(funcindex); LuaValue value = L.toLuaValue(-1); @@ -617,7 +612,7 @@ protected String lua_setupvalue(long ptr, int funcindex, int n) { } @Override - protected int luaL_callmeta(long ptr, int obj, String e) { + public int luaL_callmeta(long ptr, int obj, String e) { LuaJState L = instances.get((int) ptr); LuaValue value = L.toLuaValue(obj); LuaValue metatable = value.getmetatable(); @@ -633,7 +628,7 @@ protected int luaL_callmeta(long ptr, int obj, String e) { } @Override - protected int luaL_dostring(long ptr, String str) { + public int luaL_dostring(long ptr, String str) { LuaJState L = instances.get((int) ptr); try { L.push(L.globals.load(str)); @@ -645,7 +640,7 @@ protected int luaL_dostring(long ptr, String str) { } @Override - protected int luaL_getmetafield(long ptr, int obj, String e) { + public int luaL_getmetafield(long ptr, int obj, String e) { LuaJState L = instances.get((int) ptr); LuaValue value = L.toLuaValue(obj); LuaValue metatable = value.getmetatable(); @@ -662,21 +657,13 @@ protected int luaL_getmetafield(long ptr, int obj, String e) { } @Override - protected void luaJ_getmetatable(long ptr, String tname) { + public void luaJ_getmetatable(long ptr, String tname) { LuaJState L = instances.get((int) ptr); L.push(L.getRegistry(tname)); } @Override - protected String luaL_gsub(long ptr, String s, String p, String r) { - LuaJState L = instances.get((int) ptr); - String result = s.replaceAll(p, r); - L.push(LuaValue.valueOf(result)); - return result; - } - - @Override - protected int luaL_loadstring(long ptr, String s) { + public int luaL_loadstring(long ptr, String s) { LuaJState L = instances.get((int) ptr); try { L.push(L.globals.load(s)); @@ -688,7 +675,7 @@ protected int luaL_loadstring(long ptr, String s) { } @Override - protected int luaL_newmetatable(long ptr, String tname) { + public int luaL_newmetatable(long ptr, String tname) { LuaJState L = instances.get((int) ptr); if (L.getRegistry(tname).isnil()) { LuaTable value = LuaValue.tableOf(); @@ -701,12 +688,12 @@ protected int luaL_newmetatable(long ptr, String tname) { } @Override - protected void luaJ_newmetatable(long ptr, String tname) { + public void luaJ_newmetatable(long ptr, String tname) { luaL_newmetatable(ptr, tname); } @Override - protected long luaL_newstate(int lid) { + public long luaL_newstate(int lid) { LuaInstances.Token handle = instances.add(); Globals globals = new Globals(); globals.load(new BaseLib()); @@ -719,7 +706,7 @@ protected long luaL_newstate(int lid) { } @Override - protected void luaL_openlibs(long ptr) { + public void luaL_openlibs(long ptr) { LuaJState L = instances.get((int) ptr); L.globals.load(new PackageLib()); @@ -733,7 +720,7 @@ protected void luaL_openlibs(long ptr) { } @Override - protected int luaL_ref(long ptr, int t) { + public int luaL_ref(long ptr, int t) { LuaJState L = instances.get((int) ptr); LuaValue referee = L.toLuaValue(-1); if (referee.isnil()) { @@ -750,25 +737,25 @@ protected int luaL_ref(long ptr, int t) { } @Override - protected String luaL_typename(long ptr, int index) { + public String luaL_typename(long ptr, int index) { return lua_typename(ptr, index); } @Override - protected void luaL_unref(long ptr, int t, int ref) { + public void luaL_unref(long ptr, int t, int ref) { LuaJState L = instances.get((int) ptr); LuaTable value = (LuaTable) L.toLuaValue(t); value.rawset(ref, LuaValue.NIL); } @Override - protected void luaL_where(long ptr, int lvl) { + public void luaL_where(long ptr, int lvl) { LuaJState L = instances.get((int) ptr); L.push(LuaValue.valueOf("")); } @Override - protected void luaJ_openlib(long ptr, String lib) { + public void luaJ_openlib(long ptr, String lib) { LuaJState L = instances.get((int) ptr); switch (lib) { case "": @@ -802,7 +789,7 @@ protected void luaJ_openlib(long ptr, String lib) { } @Override - protected int luaJ_compare(long ptr, int index1, int index2, int op) { + public int luaJ_compare(long ptr, int index1, int index2, int op) { LuaJState L = instances.get((int) ptr); LuaValue value1 = L.toLuaValue(index1); LuaValue value2 = L.toLuaValue(index2); @@ -818,14 +805,14 @@ protected int luaJ_compare(long ptr, int index1, int index2, int op) { } @Override - protected int luaJ_len(long ptr, int index) { + public int luaJ_len(long ptr, int index) { LuaJState L = instances.get((int) ptr); LuaValue value = L.toLuaValue(index); return value.length(); } @Override - protected int luaJ_loadbuffer(long ptr, Buffer buffer, int size, String name) { + public int luaJ_loadbuffer(long ptr, Buffer buffer, int size, String name) { LuaJState L = instances.get((int) ptr); ByteBuffer bytes = (ByteBuffer) buffer; try { @@ -845,18 +832,13 @@ public int read() { } @Override - protected int luaJ_dobuffer(long ptr, Buffer buffer, int size, String name) { + public int luaJ_dobuffer(long ptr, Buffer buffer, int size, String name) { luaJ_loadbuffer(ptr, buffer, size, name); return lua_pcall(ptr, 0, LUA_MULTRET, 0); } @Override - protected int luaJ_pcall(long ptr, int nargs, int nresults) { - return lua_pcall(ptr, nargs, nresults, 0); - } - - @Override - protected int luaJ_resume(long ptr, int nargs) { + public int luaJ_resume(long ptr, int nargs) { LuaJState L = instances.get((int) ptr); if (L.thread == null) { throw new LuaException(LuaException.LuaError.RUNTIME, @@ -883,25 +865,25 @@ protected int luaJ_resume(long ptr, int nargs) { } @Override - protected void luaJ_pushobject(long ptr, Object obj) { + public void luaJ_pushobject(long ptr, Object obj) { LuaJState L = instances.get((int) ptr); L.push(new JavaObject(obj, L.jObjectMetatable, L.address)); } @Override - protected void luaJ_pushclass(long ptr, Object clazz) { + public void luaJ_pushclass(long ptr, Object clazz) { LuaJState L = instances.get((int) ptr); L.push(new JavaClass((Class) clazz, L.jClassMetatable, L.address)); } @Override - protected void luaJ_pusharray(long ptr, Object array) { + public void luaJ_pusharray(long ptr, Object array) { LuaJState L = instances.get((int) ptr); L.push(new JavaArray(array, L.jArrayMetatable, L.address)); } @Override - protected void luaJ_pushfunction(long ptr, Object func) { + public void luaJ_pushfunction(long ptr, Object func) { LuaJState L = instances.get((int) ptr); JFunction f = (JFunction) func; L.push(new VarArgFunction() { @@ -916,14 +898,14 @@ public Varargs invoke(Varargs args) { } @Override - protected int luaJ_isobject(long ptr, int index) { + public int luaJ_isobject(long ptr, int index) { LuaJState L = instances.get((int) ptr); LuaValue value = L.toLuaValue(index); return (value instanceof JavaObject) ? 1 : 0; } @Override - protected Object luaJ_toobject(long ptr, int index) { + public Object luaJ_toobject(long ptr, int index) { LuaJState L = instances.get((int) ptr); LuaValue value = L.toLuaValue(index); if (value instanceof JavaObject) { @@ -933,12 +915,12 @@ protected Object luaJ_toobject(long ptr, int index) { } @Override - protected long luaJ_newthread(long ptr, int lid) { + public long luaJ_newthread(long ptr, int lid) { return lua_newthread(ptr); } @Override - protected int luaJ_initloader(long ptr) { + public int luaJ_initloader(long ptr) { LuaJState L = instances.get((int) ptr); LuaValue table = L.globals.get("package"); if (!table.istable()) { @@ -966,23 +948,23 @@ public LuaValue call(LuaValue arg) { } @Override - protected int luaJ_invokespecial(long ptr, @SuppressWarnings("rawtypes") Class clazz, String method, String sig, Object obj, String params) { + public int luaJ_invokespecial(long ptr, @SuppressWarnings("rawtypes") Class clazz, String method, String sig, Object obj, String params) { throw new UnsupportedOperationException("invokespecial not available without JNI"); } @Override - protected void luaJ_removestateindex(long ptr) { + public void luaJ_removestateindex(long ptr) { // ignored } @Override - protected void luaJ_gc(long ptr) { + public void luaJ_gc(long ptr) { Runtime.getRuntime().gc(); } @Override - protected Object luaJ_dumptobuffer(long ptr) { + public Object luaJ_dumptobuffer(long ptr) { LuaJState L = instances.get((int) ptr); LuaValue func = L.toLuaValue(-1); if (!func.isclosure()) { @@ -1003,7 +985,7 @@ protected Object luaJ_dumptobuffer(long ptr) { } @Override - protected Object luaJ_tobuffer(long ptr, int index) { + public Object luaJ_tobuffer(long ptr, int index) { LuaJState L = instances.get((int) ptr); LuaValue value = L.toLuaValue(index); if (!value.isstring()) { @@ -1017,11 +999,11 @@ protected Object luaJ_tobuffer(long ptr, int index) { } @Override - protected Object luaJ_todirectbuffer(long ptr, int index) { + public Object luaJ_todirectbuffer(long ptr, int index) { return luaJ_tobuffer(ptr, index); } - protected static class FunctionInvoker extends VarArgFunction { + public static class FunctionInvoker extends VarArgFunction { public final static ThreadLocal insideCoroutine = new ThreadLocal<>(); public static boolean isInsideCoroutine() { diff --git a/luajava/src/main/java/party/iroiro/luajava/AbstractLua.java b/luajava/src/main/java/party/iroiro/luajava/AbstractLua.java index b9769243..4e167cfa 100644 --- a/luajava/src/main/java/party/iroiro/luajava/AbstractLua.java +++ b/luajava/src/main/java/party/iroiro/luajava/AbstractLua.java @@ -40,7 +40,7 @@ import java.util.concurrent.ConcurrentHashMap; /** - * An implementation that relies on {@link LuaNative} for most of the features independent of Lua versions + * An implementation that relies on {@link LuaNatives} for most of the features independent of Lua versions */ public abstract class AbstractLua implements Lua { private final static Object[] EMPTY = new Object[0]; @@ -53,7 +53,7 @@ static AbstractLua getInstance(int lid) { return instances.get(lid); } - protected final LuaNative C; + protected final LuaNatives C; protected final long L; protected final int id; protected final AbstractLua mainThread; @@ -64,7 +64,7 @@ static AbstractLua getInstance(int lid) { * * @param luaNative the Lua native wrapper */ - protected AbstractLua(LuaNative luaNative) { + protected AbstractLua(LuaNatives luaNative) { this.C = luaNative; id = instances.add(this); L = luaNative.luaL_newstate(id); @@ -83,7 +83,7 @@ protected AbstractLua(LuaNative luaNative) { * @param id the Lua state id (see {@link LuaInstances}) * @param mainThread the main state of this sub-state */ - protected AbstractLua(LuaNative luaNative, long L, int id, @NotNull AbstractLua mainThread) { + protected AbstractLua(LuaNatives luaNative, long L, int id, @NotNull AbstractLua mainThread) { loader = null; this.C = luaNative; this.L = L; @@ -849,7 +849,7 @@ public void loadExternal(String module) throws LuaException { } @Override - public LuaNative getLuaNative() { + public LuaNatives getLuaNative() { return C; } @@ -897,7 +897,7 @@ public int error(@Nullable Throwable e) { * Calls a method on an object, equivalent to invokespecial * *

- * Internally it uses {@link LuaNative#luaJ_invokespecial(long, Class, String, String, Object, String)} which then uses + * Internally it uses {@link LuaNatives#luaJ_invokespecial(long, Class, String, String, Object, String)} which then uses * {@code CallNonvirtualMethodA} functions to avoid tons of restrictions imposed by the JVM. *

* diff --git a/luajava/src/main/java/party/iroiro/luajava/Lua.java b/luajava/src/main/java/party/iroiro/luajava/Lua.java index 0053d79f..00e16692 100644 --- a/luajava/src/main/java/party/iroiro/luajava/Lua.java +++ b/luajava/src/main/java/party/iroiro/luajava/Lua.java @@ -1114,9 +1114,9 @@ public interface Lua extends AutoCloseable, LuaThread { void loadExternal(String module) throws LuaException; /** - * @return the underlying {@link LuaNative} natives + * @return the underlying {@link LuaNatives} natives */ - LuaNative getLuaNative(); + LuaNatives getLuaNative(); /** * @return the main Lua state diff --git a/luajava/src/main/java/party/iroiro/luajava/LuaNative.java b/luajava/src/main/java/party/iroiro/luajava/LuaNatives.java similarity index 86% rename from luajava/src/main/java/party/iroiro/luajava/LuaNative.java rename to luajava/src/main/java/party/iroiro/luajava/LuaNatives.java index d603f0c6..5e947c14 100644 --- a/luajava/src/main/java/party/iroiro/luajava/LuaNative.java +++ b/luajava/src/main/java/party/iroiro/luajava/LuaNatives.java @@ -33,7 +33,7 @@ * Lua documentation to confirm. *

*/ -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 - * - *

-     * [-0, +1, m]
-     * 
- * - *

-     * const char *luaL_gsub (lua_State *L,
-     *                        const char *s,
-     *                        const char *p,
-     *                        const char *r);
-     * 
- * - *

- * 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_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. - *
  • - * - *
- * - * @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 loadedNatives = null; + private static volatile Class 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 natives, boolean global) { + public synchronized static void register(Class 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_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. - *
  • - * - *
- * - * @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; /**