You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to make custom metatable for pushed java object for faster function invoke(compared using reflection) and making some method lua-side private.
I have resolved this using following (kotlin) code:
// pusing to lua
lua.pushJavaObject(this)
lua.getGlobal("my_metatable")
lua.setMetatable(-2)
There are two major issues on this purpose.
First, It cannot uses .toJavaObject() because it choses whether jclass or jobject using metatable.
I resolved this by temporally replacing the metatable on unpacking like this:
lua.getGlobal("aris__obj_mt")
lua.push(arg[0])
lua.getMetatable(-1)
lua.pushValue(-3)
lua.setMetatable(-3)
val rt =listOf((arg[0].toJavaObject() as/* my class */).method())
lua.setMetatable(-2)
lua.pop(1)
lua.pop(1)
This is a bit dirty but works fine.
The main problem is __gc metamethod throws error. The reason was from this code:
jobject * data = (jobject *) luaL_checkudata(L, 1, R);
It throws error in __gc metamethod (RUNTIME: party.iroiro.luajava.LuaException: no matching method found) in lua5.2 and no error message but coroutine.resume failes on luajit(maybe stackoverflow?).
The text was updated successfully, but these errors were encountered:
I am trying to make custom metatable for pushed java object for faster function invoke(compared using reflection) and making some method lua-side private.
I have resolved this using following (kotlin) code:
There are two major issues on this purpose.
First, It cannot uses .toJavaObject() because it choses whether jclass or jobject using metatable.
I resolved this by temporally replacing the metatable on unpacking like this:
This is a bit dirty but works fine.
The main problem is __gc metamethod throws error. The reason was from this code:
luajava/jni/luajava/juaapi.h
Line 16 in 2a352ec
It throws
error in __gc metamethod (RUNTIME: party.iroiro.luajava.LuaException: no matching method found)
in lua5.2 and no error message but coroutine.resume failes on luajit(maybe stackoverflow?).The text was updated successfully, but these errors were encountered: