1
0

Add borderless-win32-odin, lua-dylib-odin

This commit is contained in:
2024-11-09 15:52:52 -05:00
parent 54d7bf4267
commit 654367a6d5
8 changed files with 217 additions and 6 deletions

3
lua-dylib-odin/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
args.dll
args.exp
args.lib

2
lua-dylib-odin/build.bat Normal file
View File

@@ -0,0 +1,2 @@
odin build . -build-mode:dll -out:args.dll
lua test.lua

34
lua-dylib-odin/main.odin Normal file
View File

@@ -0,0 +1,34 @@
package args
import "base:runtime"
import "core:fmt"
LUA_SHARED :: true
import lua "vendor:lua/5.4"
lua_print_arg_count :: lua.L_Reg {
name = "printargcount",
func = lua_print_arg_count_proc,
}
lua_print_arg_count_proc :: proc "c" (L: ^lua.State) -> i32 {
context = runtime.default_context()
top := lua.gettop(L)
if top > 0 {
fmt.println(top, "arguments were passed to the function", lua_print_arg_count.name)
} else {
fmt.println("no arguments were passed to the function", lua_print_arg_count.name)
}
return 0
}
procs :: []lua.L_Reg{lua_print_arg_count, {nil, nil}}
@(export)
luaopen_args :: proc(L: ^lua.State) -> i32 {
lua.L_checkversion(L)
lua.L_newlib(L, procs)
lua.pushinteger(L, 8008135)
lua.setfield(L, -2, "version")
return 1
}

4
lua-dylib-odin/test.lua Normal file
View File

@@ -0,0 +1,4 @@
local a = require'args'
print('version', a.version)
print('printargcount(1,2,3):')
a.printargcount(1,2,3)