2018-12-27 15:17:25 +08:00
|
|
|
#include <my_object/my_object.hpp>
|
2017-08-06 07:20:28 +08:00
|
|
|
|
2019-05-22 07:17:31 +08:00
|
|
|
#define SOL_ALL_SAFETIES_ON 1
|
2018-09-28 13:27:38 +08:00
|
|
|
#include <sol/sol.hpp>
|
2017-08-06 07:20:28 +08:00
|
|
|
|
|
|
|
namespace my_object {
|
|
|
|
|
|
|
|
sol::table open_my_object(sol::this_state L) {
|
|
|
|
sol::state_view lua(L);
|
|
|
|
sol::table module = lua.create_table();
|
|
|
|
module.new_usertype<test>("test",
|
|
|
|
sol::constructors<test(), test(int)>(),
|
2018-12-28 02:02:31 +08:00
|
|
|
"value", &test::value);
|
2017-08-06 07:20:28 +08:00
|
|
|
|
|
|
|
return module;
|
|
|
|
}
|
|
|
|
|
2017-08-07 00:20:32 +08:00
|
|
|
} // namespace my_object
|
2017-08-06 07:20:28 +08:00
|
|
|
|
|
|
|
extern "C" int luaopen_my_object(lua_State* L) {
|
|
|
|
// pass the lua_State,
|
|
|
|
// the index to start grabbing arguments from,
|
|
|
|
// and the function itself
|
|
|
|
// optionally, you can pass extra arguments to the function if that's necessary,
|
|
|
|
// but that's advanced usage and is generally reserved for internals only
|
|
|
|
return sol::stack::call_lua(L, 1, my_object::open_my_object );
|
|
|
|
}
|