I want to copy a function from one Lua_State to another using luabridge.
luabridge provides a Function called addFunction(const char * name,FP fp)
and an Function called getGlobal(lua_State* L,const char*)
which returns a Object of Type LuaRef
which has overloaded operators. I am using a multimap to store the names of the functions I want to copy.
the function addFunction()
does not support the usage of a pointer to a class, therefore i cannot pass getGlobal().operator()
directly
//get all functions that match the Criteria
std::pair<acc_map_iter, acc_map_iter> range = sec_map->equal_range(acl);
//Add them to the first State
std::for_each(range.first, range.second, [&](acc_map_iter iter){
script->compilerContext->addFunction(iter->second.c_str(), [&](/*args...?*/)
{
return luabridge::getGlobal(sec_state, iter->second.c_str()).operator(/*args...?*/);
});
});
Can I somehow make the lambda accept multiple arguments from addFunction()
. Is there a trick or is it simply impossible?