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

Function main

examples/source/metatable_customization.cpp:168–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166}
167
168int main() {
169
170 std::cout << "=== metatable with custom-built (static) "
171 "handling ==="
172 << std::endl;
173
174
175 sol::state lua;
176 lua.open_libraries(sol::lib::base);
177
178 // register custom type + storage
179 register_thing_type(lua);
180
181 lua.script(R"(t = thing.new()
182 print(t.member_variable)
183 print(t:member_function())
184 t.member_variable = 24
185 print(t.member_variable)
186 print(t:member_function())
187 )");
188
189 // clear storage
190 unregister_thing_type(lua);
191
192 std::cout << std::endl;
193
194 return 0;
195}

Callers

nothing calls this directly

Calls 4

register_thing_typeFunction · 0.85
unregister_thing_typeFunction · 0.85
open_librariesMethod · 0.80
scriptMethod · 0.80

Tested by

no test coverage detected