Suggestion: A way to determinate if LuaRef is callable
Useful way to determinate if LuaRef is callable for functions and tables with metatable __call, for example: bool LuaRef::isCallable() const;
Now tables with metatable __call can be called by LuaRef, but is no easy way to check it has a sense (isFunction()==false, isTable()==true, as for regular table).
Access to metatable is not easy too (luaL_getmetatable?). LuaRef LuaRef::metatable() will be nice.
Thanks for your work!
It's not forbidden to manipulate metatables on the C++ side (but forbidden on the Lua side). You can do the following:
luaRef.push ();
lua_getmetatable (L, -1);
auto metatable = LuaRef::fromStack (L);
and then
if (metatable ["__call"].isFunction ())
{
luaRef (1, 2);
}
I'm just thinking whether it's worth adding a helper function like that:
luabridge::LuaRef luabridge::getMetatable (const luabridge::LuaRef& luaRef);
Great, getMetatable looks OK.
And next helper isCallable will be perfect :-)
Both getMetatable and isCallable are available in https://github.com/kunitoki/LuaBridge3
@kunitoki If you want to take care of the LB why don't you just ask? There are no obstacles, if your version is better, we'll just put instructions how to switch to your repo. Otherwise you can simply push your version to this repo. I'm not the owner as well, but.
Will think about it.