From 116109f069ac3b4517d9710514ef45b1fcf8627c Mon Sep 17 00:00:00 2001 From: takase1121 <20792268+takase1121@users.noreply.github.com> Date: Wed, 7 Jul 2021 01:17:11 +0800 Subject: [PATCH] move constants to the process table reduce code clutter because they're already namespaced --- src/api/process.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/api/process.c b/src/api/process.c index f2a1b1c2..f43a316f 100644 --- a/src/api/process.c +++ b/src/api/process.c @@ -335,8 +335,7 @@ static const struct luaL_Reg process_methods[] = { static const struct luaL_Reg lib[] = { {"strerror", process_strerror}, - {"Process", NULL}, - {"CONSTANTS", NULL} + {NULL, NULL} }; int luaopen_process(lua_State *L) @@ -349,7 +348,7 @@ int luaopen_process(lua_State *L) lua_setfield(L, -2, "__index"); lua_setfield(L, -2, "Process"); // process.Process - lua_newtable(L); + // constants L_SETNUM(L, -1, "ERROR_INVAL", REPROC_EINVAL); L_SETNUM(L, -1, "ERROR_TIMEDOUT", REPROC_ETIMEDOUT); L_SETNUM(L, -1, "ERROR_PIPE", REPROC_EPIPE); @@ -368,7 +367,6 @@ int luaopen_process(lua_State *L) L_SETNUM(L, -1, "REDIRECT_PARENT", REPROC_REDIRECT_PARENT); L_SETNUM(L, -1, "REDIRECT_DISCARD", REPROC_REDIRECT_DISCARD); L_SETNUM(L, -1, "REDIRECT_STDOUT", REPROC_REDIRECT_STDOUT); - lua_setfield(L, -2, "CONSTANTS"); // process.CONSTANTS return 1; }