summaryrefslogtreecommitdiff
path: root/libs/honeysuckle/examples/argument_parsing
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2022-04-16 11:55:09 -0500
committersanine <sanine.not@pm.me>2022-04-16 11:55:09 -0500
commitdb81b925d776103326128bf629cbdda576a223e7 (patch)
tree58bea8155c686733310009f6bed7363f91fbeb9d /libs/honeysuckle/examples/argument_parsing
parent55860037b14fb3893ba21cf2654c83d349cc1082 (diff)
move 3rd-party librarys into libs/ and add built-in honeysuckle
Diffstat (limited to 'libs/honeysuckle/examples/argument_parsing')
-rw-r--r--libs/honeysuckle/examples/argument_parsing/argument_parsing.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/libs/honeysuckle/examples/argument_parsing/argument_parsing.c b/libs/honeysuckle/examples/argument_parsing/argument_parsing.c
new file mode 100644
index 0000000..11a48f4
--- /dev/null
+++ b/libs/honeysuckle/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;
+}