]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-lua: Make dlua_setmembers() take lua_State * directly
authorJosef 'Jeff' Sipek <jeff.sipek@open-xchange.com>
Thu, 17 Dec 2020 17:53:44 +0000 (12:53 -0500)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 15 Jan 2021 13:32:57 +0000 (13:32 +0000)
src/auth/db-lua.c
src/lib-lua/dlua-script-private.h
src/lib-lua/dlua-script.c
src/lib-storage/mail-storage-lua.c

index afc3cc21e167386d3b6ac6561b2f7263fdf5cc30..cdde89a11260e01a4e06d0675bcdf3eb8995d305 100644 (file)
@@ -387,7 +387,7 @@ static void auth_lua_dovecot_auth_register(struct dlua_script *script)
        lua_newtable(script->L);
 
        /* register constants */
-       dlua_setmembers(script, auth_lua_dovecot_auth_values, -1);
+       dlua_setmembers(script->L, auth_lua_dovecot_auth_values, -1);
 
        /* push new metatable to stack */
        luaL_newmetatable(script->L, AUTH_LUA_DOVECOT_AUTH);
index bcf24c4211392f179963212861aa777e58b6e653..3ec24369d328161f59a6fb46e520a67b96063505 100644 (file)
@@ -96,8 +96,7 @@ void dlua_dovecot_register(struct dlua_script *script);
 void dlua_getdovecot(struct dlua_script *script);
 
 /* assign values to table on idx */
-void dlua_setmembers(struct dlua_script *script,
-                    const struct dlua_table_values *values, int idx);
+void dlua_setmembers(lua_State *L, const struct dlua_table_values *values, int idx);
 
 
 #endif
index 42faec6a19866109f7cdeb7d4f8d90bad4fb6d7f..d4bf6f1b5b758cee0b4ae1a8458696b826c6caf3 100644 (file)
@@ -342,32 +342,32 @@ bool dlua_script_has_function(struct dlua_script *script, const char *fn)
        return ret;
 }
 
-void dlua_setmembers(struct dlua_script *script,
-                    const struct dlua_table_values *values, int idx)
+void dlua_setmembers(lua_State *L, const struct dlua_table_values *values,
+                    int idx)
 {
-       i_assert(script != NULL);
-       i_assert(lua_istable(script->L, idx));
+       i_assert(L != NULL);
+       i_assert(lua_istable(L, idx));
        while(values->name != NULL) {
                switch(values->type) {
                case DLUA_TABLE_VALUE_STRING:
-                       lua_pushstring(script->L, values->v.s);
+                       lua_pushstring(L, values->v.s);
                        break;
                case DLUA_TABLE_VALUE_INTEGER:
-                       lua_pushnumber(script->L, values->v.i);
+                       lua_pushnumber(L, values->v.i);
                        break;
                case DLUA_TABLE_VALUE_DOUBLE:
-                       lua_pushnumber(script->L, values->v.d);
+                       lua_pushnumber(L, values->v.d);
                        break;
                case DLUA_TABLE_VALUE_BOOLEAN:
-                       lua_pushboolean(script->L, values->v.b);
+                       lua_pushboolean(L, values->v.b);
                        break;
                case DLUA_TABLE_VALUE_NULL:
-                       lua_pushnil(script->L);
+                       lua_pushnil(L);
                        break;
                default:
                        i_unreached();
                }
-               lua_setfield(script->L, idx-1, values->name);
+               lua_setfield(L, idx - 1, values->name);
                values++;
        }
 }
index 615c1c693fa687710f0e81a3f509fc01461e0019..538030ae098d0054dfc12726e1c4bb6b47532861 100644 (file)
@@ -67,7 +67,7 @@ void dlua_register_mail_storage(struct dlua_script *script)
        /* Create table for holding values */
        lua_newtable(script->L);
 
-       dlua_setmembers(script, lua_storage_mail_storage_flags, -1);
+       dlua_setmembers(script->L, lua_storage_mail_storage_flags, -1);
 
        /* push new metatable to stack */
        luaL_newmetatable(script->L, LUA_SCRIPT_STORAGE);