aboutsummaryrefslogtreecommitdiffstats
path: root/deps/sol2/examples/require_dll_example/source/my_object.cpp
diff options
context:
space:
mode:
authorAndy Belle-Isle <drumsetmonkey@gmail.com>2019-08-30 00:19:31 -0400
committerAndy Belle-Isle <drumsetmonkey@gmail.com>2019-08-30 00:19:31 -0400
commitbd3fe0cac583739bc0d7c4b5c8f301bb350abca0 (patch)
tree7eeb1aabcebd6999de1c3457d0882246ec0ff4d4 /deps/sol2/examples/require_dll_example/source/my_object.cpp
parent2662ac356ce14dacfbc91689fd37244facff4989 (diff)
Renamed lib to deps so github will ignore it for language stats
Diffstat (limited to 'deps/sol2/examples/require_dll_example/source/my_object.cpp')
-rw-r--r--deps/sol2/examples/require_dll_example/source/my_object.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/deps/sol2/examples/require_dll_example/source/my_object.cpp b/deps/sol2/examples/require_dll_example/source/my_object.cpp
new file mode 100644
index 0000000..d966c2b
--- /dev/null
+++ b/deps/sol2/examples/require_dll_example/source/my_object.cpp
@@ -0,0 +1,27 @@
+#include <my_object/my_object.hpp>
+
+#define SOL_ALL_SAFETIES_ON 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 );
+}