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

Function main

examples/source/docs/runtime_extension.cpp:10–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8};
9
10int main(int, char*[]) {
11
12 std::cout << "==== runtime_extension =====" << std::endl;
13
14 sol::state lua;
15 lua.open_libraries(sol::lib::base);
16
17 lua.new_usertype<object>("object");
18
19 // runtime additions: through the sol API
20 lua["object"]["func"] = [](object& o) { return o.value; };
21 // runtime additions: through a lua script
22 lua.script(
23 "function object:print () print(self:func()) end");
24
25 // see it work
26 lua.script("local obj = object.new() \n obj:print()");
27
28 return 0;
29}

Callers

nothing calls this directly

Calls 2

open_librariesMethod · 0.80
scriptMethod · 0.80

Tested by

no test coverage detected