diff options
author | sanine <sanine.not@pm.me> | 2021-09-04 12:24:57 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2021-09-04 12:24:57 -0500 |
commit | 0b55e12f7f9fc98d22b2bead44d064af8c3f92c4 (patch) | |
tree | a3d9529f974da21544ecb55137f3219045b4ab63 /examples/argument_parsing | |
parent | fc8f1758d7c6a21851c5c475254b07da891a7592 (diff) |
remove va_nargs.h and begin adding examples
Diffstat (limited to 'examples/argument_parsing')
-rw-r--r-- | examples/argument_parsing/#argument_parsing.c# | 28 | ||||
-rw-r--r-- | examples/argument_parsing/argument_parsing.c | 23 |
2 files changed, 51 insertions, 0 deletions
diff --git a/examples/argument_parsing/#argument_parsing.c# b/examples/argument_parsing/#argument_parsing.c# new file mode 100644 index 0000000..38309db --- /dev/null +++ b/examples/argument_parsing/#argument_parsing.c# @@ -0,0 +1,28 @@ +#include <honeysuckle.h> + +int demo(lua_State *L) +{ + lua_Integer i; + lua_Number n; + char *string; + hs_parse_args(L, hs_int(i), hs_num(n), hs_str(string)); + printf("received %d, %f, and %s\n", i, n, string); + return 0; +} + +int main() +{ + lua_State *L = luaL_newstate(); + luaL_openlibs(L); + + lua_pushcfunction(L, demo); + lua_setglobal(L, "demo"); + + luaL_dostring("demo(12, 34.4, 'hi there!')"); + return 0; +} + +grindr +hinge +bumble +lex diff --git a/examples/argument_parsing/argument_parsing.c b/examples/argument_parsing/argument_parsing.c new file mode 100644 index 0000000..11a48f4 --- /dev/null +++ b/examples/argument_parsing/argument_parsing.c @@ -0,0 +1,23 @@ +#include <honeysuckle.h> + +int demo(lua_State *L) +{ + lua_Integer i; + lua_Number n; + char *string; + hs_parse_args(L, hs_int(i), hs_num(n), hs_str(string)); + printf("received %ld, %f, and %s\n", i, n, string); + return 0; +} + +int main() +{ + lua_State *L = luaL_newstate(); + luaL_openlibs(L); + + lua_pushcfunction(L, demo); + lua_setglobal(L, "demo"); + + luaL_dostring(L, "demo(12, 34.4, 'hi there!')"); + return 0; +} |