encapsulation closure

This commit is contained in:
Bluub
2021-06-19 19:00:56 +02:00
parent 35adf49c66
commit fc3b6943f0
3 changed files with 19 additions and 39 deletions
+7
View File
@@ -115,4 +115,11 @@ namespace LuaG
{
lua_pop(_state, -1);
}
void State::registerClosure(void *ptr, std::string funcName, lua_CFunction fn)
{
lua_pushlightuserdata(_state, ptr);
lua_pushcclosure(_state, fn, 1);
lua_setglobal(_state, funcName.c_str());
}
}
+2
View File
@@ -78,5 +78,7 @@ namespace LuaG
//! @brief Pop last value on the stack
void popLast(void);
void registerClosure(void *ptr, std::string funcName, lua_CFunction fn);
};
}