Closed slava110 closed 1 year ago
If I understand correctly, ignored parameter here is the thing I need https://github.com/gudzpoz/luajava/blob/d17aa85f0587f5aa608167de77dc995d2e2105e0/luajava/src/main/java/party/iroiro/luajava/JuaAPI.java#L330 I'm not sure what's the best way to provide it to users without breaking compatibility with previous versions of LuaJava. Maybe something like that?
public interface JFunction {
int __call(Lua L);
default int __call(Lua L, int paramCount) {
return __call(L);
}
}
Or an additional interface. Or maybe you'll have a better idea. Or just break compatibility with older versions :I
Each function call in Lua gets its own stack, so the number of elements on stack ([Lua::getTop
](https://gudzpoz.github.io/luajava/javadoc/party/iroiro/luajava/Lua.html#getTop())) is just the number of parameters. (See lua_CFunction
.)
Actually I don't remember why I wrote juaFunctionCall
like this. (Probably I just wanted to reduce the number of JNI calls, which I don't think is worth it anymore. Maybe I will do some pruning afterwards.) Anyway, using getTop
should do the job.
Yes, it works! getTop
is the solution. Didn't know that each function call gets its own stack (maybe missed it in the docs). Thank you very much!
Hi. Is it possible to get amount of args in vararg JFunction? I don't see number of arguments anywhere on the stack. Is it not possible to create Java vararg function in such case?