Defining LuaModuleDef
First, we need to provide the name of the module and then the __index
metatable. Finally, we need to provide a name for the metatable. Recall that in Destinations.cc
, the name of the metatable is hardcoded as follows:
const std::string METATABLE_NAME( "Destinations.Metatable");
Now, this needs to be passed to the exporter. Let us define a structure for the aforementioned three pieces of information. In LuaModule.h
, add the following declaration:
template <typename T> struct LuaModuleDef { const std::string moduleName; const std::vector<luaL_Reg> moduleRegs; const std::string metatableName() const { return std::string(moduleName) .append(".Metatable"); } };
This...