35 lines
795 B
Odin
35 lines
795 B
Odin
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
|
|
}
|