You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lua/call_odin_from_lua/call_odin_from_lua.odin
+2-4Lines changed: 2 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ import "core:fmt"
6
6
// The code the Lua VM will run
7
7
CODE :: "print(add(2, 2))"
8
8
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
10
10
// Odin takes advantage of an overall implied context that is implicitly passed with each procedure when it is called
11
11
// 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
12
12
// There is a compiler check for this, and a note, so this issue is very easy to catch
// 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
24
24
result := a + b
25
25
26
-
// Make room for the integer we're about to push onto the stack
27
-
lua.checkstack(state, 1)
28
26
// Push the result onto the stack
29
27
lua.pushinteger(state, result)
30
28
@@ -47,7 +45,7 @@ main :: proc() {
47
45
// 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
0 commit comments