maint: update deps

This commit is contained in:
Ahrimdon
2024-08-13 05:15:34 -04:00
parent 71843c3821
commit f0d2362fb5
8385 changed files with 2911785 additions and 7484 deletions

View File

@ -0,0 +1,30 @@
#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);
}

View File

@ -0,0 +1,35 @@
#define SOL_ALL_SAFETIES_ON 1
#include <sol/sol.hpp>
#include <my_object/my_object.hpp>
#include <iostream>
int main(int, char*[]) {
std::cout << "=== require from DLL ===" << std::endl;
sol::state lua;
lua.open_libraries(sol::lib::package, sol::lib::base);
const auto& code = R"(
mo = require("my_object")
obj = mo.test.new(24)
print(obj.value))";
auto script_result
= lua.safe_script(code, &sol::script_pass_on_error);
if (script_result.valid()) {
std::cout << "The DLL was require'd from successfully!"
<< std::endl;
}
else {
sol::error err = script_result;
std::cout << "Something bad happened: " << err.what()
<< std::endl;
}
SOL_ASSERT(script_result.valid());
my_object::test& obj = lua["obj"];
SOL_ASSERT(obj.value == 24);
return 0;
}