🎨 Refactor tutorial examples

- 🛠 Make sure the tutorials compile across platforms!
- ✍ Redo quite a bit of the documentation
This commit is contained in:
ThePhD 2021-03-06 10:14:48 -05:00
parent 8618e39486
commit 57d9a05f88
No known key found for this signature in database
GPG key ID: 1509DB1C0F702BFA
460 changed files with 2468 additions and 1476 deletions

View file

@ -10,8 +10,8 @@ int main(int, char*[]) {
// maybe this is in a lua_CFunction you bind,
// or maybe you're trying to work with a pre-existing system
// maybe you've used a custom lua_load call, or you're working
// with state_view's load(lua_Reader, ...) call...
// maybe you've used a custom lua_load call, or you're
// working with state_view's load(lua_Reader, ...) call...
// here's a little bit of how you can work with the stack
lua_State* L = lua.lua_state();
@ -19,11 +19,14 @@ int main(int, char*[]) {
// stack_aligned_stack_handler,
// as its type name explains so verbosely,
// expects the handler on the stack
sol::stack_reference traceback_handler(L, -sol::stack::push(L, sol::default_traceback_error_handler));
sol::stack_reference traceback_handler(L,
-sol::stack::push(
L, sol::default_traceback_error_handler));
// then, you need the function
// to be on the stack
func_ref.push();
sol::stack_aligned_stack_handler_function func(L, -1, traceback_handler);
sol::stack_aligned_stack_handler_function func(
L, -1, traceback_handler);
lua_pushinteger(L, 5); // argument 1, using plain API
lua_pushinteger(L, 6); // argument 2
@ -38,7 +41,8 @@ int main(int, char*[]) {
// make sure everything is clean
sol_c_assert(result == 22);
sol_c_assert(lua.stack_top() == 0); // stack is empty/balanced
sol_c_assert(
lua.stack_top() == 0); // stack is empty/balanced
return 0;
}