diff options
| author | ame <[email protected]> | 2024-08-03 02:30:02 -0500 |
|---|---|---|
| committer | ame <[email protected]> | 2024-08-03 02:30:02 -0500 |
| commit | 76ce905ef3e93f067b6d06458186bcf9eb9b5c01 (patch) | |
| tree | cbfee9fffc70d07bfd6b632e1f73b17da19d578c /src/reg.c | |
| parent | 2d9c55685ef75b8cf2cbc4eabd4b2875a354acba (diff) | |
fix tests, module based require, thread improvments
Diffstat (limited to 'src/reg.c')
| -rw-r--r-- | src/reg.c | 49 |
1 files changed, 37 insertions, 12 deletions
@@ -23,27 +23,52 @@ static int lua_exit(lua_State* L){ return 0;
}
+#define open_common(name)\
+ int luaopen_lullaby_##name (lua_State* L){\
+ luaL_register(L, NULL, name##_function_list);\
+ return 1;\
+ }
+
+open_common(array);
+open_common(crypto);
+open_common(io);
+open_common(math);
+open_common(config);
+open_common(net);
+open_common(thread);
+
+#define push(T, name)\
+ lua_pushstring(L, #name);\
+ luaopen_lullaby_##name(L);\
+ lua_settable(L, T);
+
int luaopen_lullaby(lua_State* L) {
- lua_newuserdata(L, 1);
+ /*lua_newuserdata(L, 1);
int ud = lua_gettop(L);
lua_newtable(L);
int meta = lua_gettop(L);
luaI_tsetcf(L, meta, "__gc", lua_exit);
lua_pushvalue(L, meta);
- lua_setmetatable(L, ud);
-
+ lua_setmetatable(L, ud);*/
//create <lib>.array functions
lua_newtable(L);
-
+ int top = lua_gettop(L);
//lua_newtable(L);
- lreg("array", array_function_list);
- lreg("crypto", crypto_function_list);
- lreg("io", io_function_list);
- lreg("math", math_function_list);
- lreg("config", config_function_list);
- lreg("net", net_function_list);
- lreg("thread", thread_function_list);
-
+ push(top, array);
+ push(top, crypto);
+ push(top, io);
+ push(top, math);
+ push(top, config);
+ push(top, net);
+ push(top, thread);
+ //lreg("array", array_function_list);
+ //lreg("crypto", crypto_function_list);
+ //lreg("io", io_function_list);
+ //lreg("math", math_function_list);
+ //lreg("config", config_function_list);
+ //lreg("net", net_function_list);
+ //lreg("thread", thread_function_list);
+ lua_settop(L, top);
return 1;
}
|
