sol2/examples/require_dll_example/source/my_object.cpp
ThePhD 486086ffe0
fix up CMake files once more, and hopefully prepare for a new test coverage paradigm
notably, test normal + single + generated + Lua 5.3.5 only once,
then only run the runtime_test and compile_test for normal for all other permutations to help increase text matrix throughput
2018-12-27 02:17:25 -05:00

29 lines
759 B
C++

#include <my_object/my_object.hpp>
#define SOL_CHECK_ARGUMENTS 1
#include <sol/sol.hpp>
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)>(),
"value", &test::value
);
return module;
}
} // namespace my_object
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 );
}