diff options
author | clyne <clyne@bitgloo.com> | 2022-11-17 07:41:09 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-17 07:41:09 -0500 |
commit | 6663c25633a27fcc14d0648bd1afea7ea12f497f (patch) | |
tree | dcc2ec993db3c4b75c3e7e3df35b0494a9ce1f32 /lib/sol2/examples/source/table_create_if_nil.cpp | |
parent | da0913771538fd9b1ca538615fd9aa0388608466 (diff) | |
parent | 57013add5b7c524086272be7d395f9ec5109bde2 (diff) |
Lib cleanup
Diffstat (limited to 'lib/sol2/examples/source/table_create_if_nil.cpp')
-rw-r--r-- | lib/sol2/examples/source/table_create_if_nil.cpp | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/lib/sol2/examples/source/table_create_if_nil.cpp b/lib/sol2/examples/source/table_create_if_nil.cpp deleted file mode 100644 index 0ccc47c..0000000 --- a/lib/sol2/examples/source/table_create_if_nil.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#define SOL_ALL_SAFETIES_ON 1
-#include <sol/sol.hpp>
-
-#include "assert.hpp"
-#include <iostream>
-
-void create_namespace_sf(sol::state& lua) {
- // this would explode
- // lua["sf"]["value"] = 256;
- lua[sol::create_if_nil]["sf"]["value"] = 256;
-}
-
-int main(int, char*[]) {
-
- std::cout << "=== sol::lua_value/sol::array_value ===" << std::endl;
-
- sol::state lua;
- lua.open_libraries(sol::lib::base);
-
- const auto& code = R"(
- print(sf)
- print(sf.value)
- assert(sf.value == 256)
- )";
-
- auto result = lua.safe_script(code, sol::script_pass_on_error);
- // did not work
- c_assert(!result.valid());
-
- // create values
- create_namespace_sf(lua);
-
- auto result2 = lua.safe_script(code, sol::script_pass_on_error);
- // it worked properly
- c_assert(result2.valid());
-
- std::cout << std::endl;
-
- return 0;
-}
|