#ifndef LUATB_H #define LUATB_H #include struct lua_State; /** * @brief Makes certain functions visible to lua while staying type-safe * on the C++ side. */ template class LuaTB { public: /** * @brief Make a function visible to lua * @param _this Pointer to the object that owns the function * @param lua Pointer to the lua state * @param name Name that will be visible to lua for this function * * Only class functions are supported, because that's all we need at * the moment. Extending it to support normal functions as well should * be fairly easy, though. * * If you want to make a function 'Foo::bar' visible, you should call * it like this (assuming no C++17 support): * * LuaTB::registerFunction<&Foo::bar>( ... ); */ template static void registerFunction(ThisType *_this, lua_State *lua, std::string name); }; // We need to include all type-dependant template implementations, because the // compiler needs to know for which types it has to instantiate those. #include "luatb.ipp" #endif // LUATB_H