Skip to content

Commit c038dc4

Browse files
committed
removed unnecessary check, clarified some language
1 parent 64abac3 commit c038dc4

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

lua/call_odin_from_lua/call_odin_from_lua.odin

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import "core:fmt"
66
// The code the Lua VM will run
77
CODE :: "print(add(2, 2))"
88

9-
// Since Lua is a C library, it expects procedures with the "c" calling convention
9+
// Because Lua is a C library, it expects procedures with the "c" calling convention
1010
// Odin takes advantage of an overall implied context that is implicitly passed with each procedure when it is called
1111
// As such, calling procedures with the Odin calling convention (the regular one) inside of a "c" procedure will require you to include "base:runtime" and "context = runtime.default_context()" at the beginning of the "c" procedure
1212
// There is a compiler check for this, and a note, so this issue is very easy to catch
@@ -23,8 +23,6 @@ add :: proc "c" (state: ^lua.State) -> i32 {
2323
// Since the integer type that the Lua library uses is a distinct copy of an i32 (because it is a C library), basic math operations are supported by default
2424
result := a + b
2525

26-
// Make room for the integer we're about to push onto the stack
27-
lua.checkstack(state, 1)
2826
// Push the result onto the stack
2927
lua.pushinteger(state, result)
3028

@@ -47,7 +45,7 @@ main :: proc() {
4745
// This is a macro to push a CFunction to the stack, and then popping and using it to set a global value in the Lua VM's global table
4846
lua.register(state, "add", add)
4947

50-
// Here is the extended version, for reference:
48+
// The extended version, for reference:
5149
/*
5250
lua.pushcfunction(state, add)
5351
lua.setglobal(state, "add")

0 commit comments

Comments
 (0)