MCPcopy Create free account
hub / github.com/ThePhD/sol2 / main

Function main

examples/source/customization_multiple.cpp:52–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50}
51
52int main() {
53 std::cout << "=== customization ===" << std::endl;
54 std::cout << std::boolalpha;
55
56 sol::state lua;
57 lua.open_libraries(sol::lib::base);
58
59 // Create a pass-through style of function
60 lua.script(
61 "function f ( a, b ) print(a, b) return a, b end");
62
63 // get the function out of Lua
64 sol::function f = lua["f"];
65
66 two_things things = f(two_things { 24, false });
67 SOL_ASSERT(things.a == 24);
68 SOL_ASSERT(things.b == false);
69 // things.a == 24
70 // things.b == true
71
72 std::cout << "things.a: " << things.a << std::endl;
73 std::cout << "things.b: " << things.b << std::endl;
74 std::cout << std::endl;
75
76 return 0;
77}

Callers

nothing calls this directly

Calls 2

open_librariesMethod · 0.80
scriptMethod · 0.80

Tested by

no test coverage detected