From: Josef 'Jeff' Sipek Date: Thu, 17 Dec 2020 00:05:04 +0000 (-0500) Subject: lib-lua: Make DLUA_REQUIRE_ARGS*() take the lua_State * directly X-Git-Tag: 2.3.14.rc1~137 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2e60aba389880ee885fc4e1c2c33110ed6f8f681;p=thirdparty%2Fdovecot%2Fcore.git lib-lua: Make DLUA_REQUIRE_ARGS*() take the lua_State * directly This is the first in a series of commits that convert a number of functions to pass around the lua_State pointer directly and to use it instead of using the lua_State pointed to by the struct dlua_script. This change is needed to eventually support the 'yield' functionality and "sequential looking, but async behind the scenes" lua scripts. To support this, the C code needs to instantiate multiple lua_States and then operate on the correct one - whichever one is passed back by the lua runtime. This lays the ground work for that. --- diff --git a/src/lib-lua/dlua-dovecot.c b/src/lib-lua/dlua-dovecot.c index f8302a2ef3..a16436011c 100644 --- a/src/lib-lua/dlua-dovecot.c +++ b/src/lib-lua/dlua-dovecot.c @@ -63,7 +63,7 @@ static void dlua_push_event_passthrough(struct dlua_script *script, static int dlua_event_pt_append_log_prefix(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 2); + DLUA_REQUIRE_ARGS(L, 2); struct event_passthrough *event = dlua_check_event_passthrough(script, 1); const char *prefix = luaL_checkstring(script->L, 2); @@ -77,7 +77,7 @@ static int dlua_event_pt_append_log_prefix(lua_State *L) static int dlua_event_pt_replace_log_prefix(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 2); + DLUA_REQUIRE_ARGS(L, 2); struct event_passthrough *event = dlua_check_event_passthrough(script, 1); const char *prefix = luaL_checkstring(script->L, 2); @@ -91,7 +91,7 @@ static int dlua_event_pt_replace_log_prefix(lua_State *L) static int dlua_event_pt_set_name(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 2); + DLUA_REQUIRE_ARGS(L, 2); struct event_passthrough *event = dlua_check_event_passthrough(script, 1); const char *name = luaL_checkstring(script->L, 2); @@ -106,7 +106,7 @@ static int dlua_event_pt_set_name(lua_State *L) static int dlua_event_pt_set_always_log_source(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 1); + DLUA_REQUIRE_ARGS(L, 1); struct event_passthrough *event = dlua_check_event_passthrough(script, 1); event->set_always_log_source(); @@ -119,7 +119,7 @@ static int dlua_event_pt_set_always_log_source(lua_State *L) static int dlua_event_pt_add_str(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 3); + DLUA_REQUIRE_ARGS(L, 3); struct event_passthrough *event = dlua_check_event_passthrough(script, 1); const char *name = luaL_checkstring(script->L, 2); const char *value = luaL_checkstring(script->L, 3); @@ -134,7 +134,7 @@ static int dlua_event_pt_add_str(lua_State *L) static int dlua_event_pt_add_int(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 3); + DLUA_REQUIRE_ARGS(L, 3); struct event_passthrough *event = dlua_check_event_passthrough(script, 1); const char *name = luaL_checkstring(script->L, 2); lua_Integer value = luaL_checkinteger(script->L, 3); @@ -149,7 +149,7 @@ static int dlua_event_pt_add_int(lua_State *L) static int dlua_event_pt_add_timeval(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 3); + DLUA_REQUIRE_ARGS(L, 3); struct event_passthrough *event = dlua_check_event_passthrough(script, 1); const char *name = luaL_checkstring(script->L, 2); /* this is time in seconds */ @@ -168,7 +168,7 @@ static int dlua_event_pt_add_timeval(lua_State *L) static int dlua_event_pt_inc_int(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 3); + DLUA_REQUIRE_ARGS(L, 3); struct event_passthrough *event = dlua_check_event_passthrough(script, 1); const char *name = luaL_checkstring(script->L, 2); lua_Integer value = luaL_checkinteger(script->L, 3); @@ -183,7 +183,7 @@ static int dlua_event_pt_inc_int(lua_State *L) static int dlua_event_pt_log_debug(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 2); + DLUA_REQUIRE_ARGS(L, 2); struct event_passthrough *event = dlua_check_event_passthrough(script, 1); const char *str = luaL_checkstring(script->L, 2); @@ -197,7 +197,7 @@ static int dlua_event_pt_log_debug(lua_State *L) static int dlua_event_pt_log_info(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 2); + DLUA_REQUIRE_ARGS(L, 2); struct event_passthrough *event = dlua_check_event_passthrough(script, 1); const char *str = luaL_checkstring(script->L, 2); @@ -211,7 +211,7 @@ static int dlua_event_pt_log_info(lua_State *L) static int dlua_event_pt_log_warning(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 2); + DLUA_REQUIRE_ARGS(L, 2); struct event_passthrough *event = dlua_check_event_passthrough(script, 1); const char *str = luaL_checkstring(script->L, 2); @@ -225,7 +225,7 @@ static int dlua_event_pt_log_warning(lua_State *L) static int dlua_event_pt_log_error(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 2); + DLUA_REQUIRE_ARGS(L, 2); struct event_passthrough *event = dlua_check_event_passthrough(script, 1); const char *str = luaL_checkstring(script->L, 2); @@ -294,7 +294,7 @@ void dlua_push_event(struct dlua_script *script, struct event *event) static int dlua_event_append_log_prefix(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 2); + DLUA_REQUIRE_ARGS(L, 2); struct event *event = dlua_check_event(script, 1); const char *prefix = luaL_checkstring(script->L, 2); @@ -308,7 +308,7 @@ static int dlua_event_append_log_prefix(lua_State *L) static int dlua_event_replace_log_prefix(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 2); + DLUA_REQUIRE_ARGS(L, 2); struct event *event = dlua_check_event(script, 1); const char *prefix = luaL_checkstring(script->L, 2); @@ -322,7 +322,7 @@ static int dlua_event_replace_log_prefix(lua_State *L) static int dlua_event_set_name(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 2); + DLUA_REQUIRE_ARGS(L, 2); struct event *event = dlua_check_event(script, 1); const char *name = luaL_checkstring(script->L, 2); @@ -337,7 +337,7 @@ static int dlua_event_set_name(lua_State *L) static int dlua_event_set_always_log_source(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 1); + DLUA_REQUIRE_ARGS(L, 1); struct event *event = dlua_check_event(script, 1); event_set_always_log_source(event); @@ -350,7 +350,7 @@ static int dlua_event_set_always_log_source(lua_State *L) static int dlua_event_add_str(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 3); + DLUA_REQUIRE_ARGS(L, 3); struct event *event = dlua_check_event(script, 1); const char *name = luaL_checkstring(script->L, 2); const char *value = luaL_checkstring(script->L, 3); @@ -365,7 +365,7 @@ static int dlua_event_add_str(lua_State *L) static int dlua_event_add_int(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 3); + DLUA_REQUIRE_ARGS(L, 3); struct event *event = dlua_check_event(script, 1); const char *name = luaL_checkstring(script->L, 2); lua_Integer value = luaL_checkinteger(script->L, 3); @@ -380,7 +380,7 @@ static int dlua_event_add_int(lua_State *L) static int dlua_event_add_timeval(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 3); + DLUA_REQUIRE_ARGS(L, 3); struct event *event = dlua_check_event(script, 1); const char *name = luaL_checkstring(script->L, 2); /* this is time in seconds */ @@ -399,7 +399,7 @@ static int dlua_event_add_timeval(lua_State *L) static int dlua_event_inc_int(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 3); + DLUA_REQUIRE_ARGS(L, 3); struct event *event = dlua_check_event(script, 1); const char *name = luaL_checkstring(script->L, 2); lua_Integer value = luaL_checkinteger(script->L, 3); @@ -414,7 +414,7 @@ static int dlua_event_inc_int(lua_State *L) static int dlua_event_log_debug(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 2); + DLUA_REQUIRE_ARGS(L, 2); struct event *event = dlua_check_event(script, 1); const char *str = luaL_checkstring(script->L, 2); @@ -428,7 +428,7 @@ static int dlua_event_log_debug(lua_State *L) static int dlua_event_log_info(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 2); + DLUA_REQUIRE_ARGS(L, 2); struct event *event = dlua_check_event(script, 1); const char *str = luaL_checkstring(script->L, 2); @@ -442,7 +442,7 @@ static int dlua_event_log_info(lua_State *L) static int dlua_event_log_warning(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 2); + DLUA_REQUIRE_ARGS(L, 2); struct event *event = dlua_check_event(script, 1); const char *str = luaL_checkstring(script->L, 2); @@ -456,7 +456,7 @@ static int dlua_event_log_warning(lua_State *L) static int dlua_event_log_error(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 2); + DLUA_REQUIRE_ARGS(L, 2); struct event *event = dlua_check_event(script, 1); const char *str = luaL_checkstring(script->L, 2); @@ -472,7 +472,7 @@ static int dlua_event_log_error(lua_State *L) static int dlua_event_passthrough_event(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 1); + DLUA_REQUIRE_ARGS(L, 1); struct event *event = dlua_check_event(script, 1); const char *file; unsigned int line; @@ -488,7 +488,7 @@ static int dlua_event_passthrough_event(lua_State *L) static int dlua_event_new(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS_IN(script, 0, 1); + DLUA_REQUIRE_ARGS_IN(L, 0, 1); struct event *event, *parent = script->event; const char *file; unsigned int line; @@ -535,7 +535,7 @@ static void dlua_event_register(struct dlua_script *script){ static int dlua_i_debug(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 1); + DLUA_REQUIRE_ARGS(L, 1); const char *msg = luaL_checkstring(script->L, 1); i_debug("%s", msg); return 0; @@ -544,7 +544,7 @@ static int dlua_i_debug(lua_State *L) static int dlua_i_info(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 1); + DLUA_REQUIRE_ARGS(L, 1); const char *msg = luaL_checkstring(script->L, 1); i_info("%s", msg); return 0; @@ -553,7 +553,7 @@ static int dlua_i_info(lua_State *L) static int dlua_i_warning(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 1); + DLUA_REQUIRE_ARGS(L, 1); const char *msg = luaL_checkstring(script->L, 1); i_warning("%s", msg); return 0; @@ -562,7 +562,7 @@ static int dlua_i_warning(lua_State *L) static int dlua_i_error(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 1); + DLUA_REQUIRE_ARGS(L, 1); const char *msg = luaL_checkstring(script->L, 1); i_error("%s", msg); return 0; @@ -571,7 +571,7 @@ static int dlua_i_error(lua_State *L) static int dlua_has_flag(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 2); + DLUA_REQUIRE_ARGS(L, 2); /* we rather deal with unsigned value here */ lua_Integer value = luaL_checkinteger(script->L, 1); lua_Integer flag = luaL_checkinteger(script->L, 2); @@ -583,7 +583,7 @@ static int dlua_has_flag(lua_State *L) static int dlua_set_flag(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 2); + DLUA_REQUIRE_ARGS(L, 2); lua_Integer value = luaL_checkinteger(script->L, 1); lua_Integer flag = luaL_checkinteger(script->L, 2); @@ -594,7 +594,7 @@ static int dlua_set_flag(lua_State *L) static int dlua_clear_flag(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 2); + DLUA_REQUIRE_ARGS(L, 2); lua_Integer value = luaL_checkinteger(script->L, 1); lua_Integer flag = luaL_checkinteger(script->L, 2); diff --git a/src/lib-lua/dlua-script-private.h b/src/lib-lua/dlua-script-private.h index e4c0243e6b..bcf24c4211 100644 --- a/src/lib-lua/dlua-script-private.h +++ b/src/lib-lua/dlua-script-private.h @@ -35,18 +35,18 @@ void luaL_setmetatable (lua_State *L, const char *tname); #define DLUA_TABLE_NULL(n, s) { .name = (n), .type = DLUA_TABLE_VALUE_NULL } #define DLUA_TABLE_END { .name = NULL } -#define DLUA_REQUIRE_ARGS_IN(s, x, y) \ +#define DLUA_REQUIRE_ARGS_IN(L, x, y) \ STMT_START { \ - if (lua_gettop((s)->L) < (x) || lua_gettop((s)->L) > (y)) { \ - return luaL_error((s)->L, "expected %d to %d arguments, got %d", \ - (x), (y), lua_gettop((s)->L)); \ + if (lua_gettop(L) < (x) || lua_gettop(L) > (y)) { \ + return luaL_error((L), "expected %d to %d arguments, got %d", \ + (x), (y), lua_gettop(L)); \ } \ } STMT_END -#define DLUA_REQUIRE_ARGS(s, x) \ +#define DLUA_REQUIRE_ARGS(L, x) \ STMT_START { \ - if (lua_gettop((s)->L) != (x)) { \ - return luaL_error((s)->L, "expected %d arguments, got %d", \ - (x), lua_gettop((s)->L)); \ + if (lua_gettop(L) != (x)) { \ + return luaL_error((L), "expected %d arguments, got %d", \ + (x), lua_gettop(L)); \ } \ } STMT_END diff --git a/src/lib-storage/mail-lua.c b/src/lib-storage/mail-lua.c index c0ae1363bb..24c51bce45 100644 --- a/src/lib-storage/mail-lua.c +++ b/src/lib-storage/mail-lua.c @@ -61,7 +61,7 @@ lua_check_storage_mail(struct dlua_script *script, int arg) static int lua_storage_mail_tostring(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 1); + DLUA_REQUIRE_ARGS(L, 1); struct mail *mail = lua_check_storage_mail(script, 1); const char *str = @@ -74,7 +74,7 @@ static int lua_storage_mail_tostring(lua_State *L) static int lua_storage_mail_eq(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 2); + DLUA_REQUIRE_ARGS(L, 2); struct mail *mail = lua_check_storage_mail(script, 1); struct mail *mail2 = lua_check_storage_mail(script, 2); @@ -88,7 +88,7 @@ static int lua_storage_mail_eq(lua_State *L) static int lua_storage_mail_lt(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 2); + DLUA_REQUIRE_ARGS(L, 2); struct mail *mail = lua_check_storage_mail(script, 1); struct mail *mail2 = lua_check_storage_mail(script, 2); @@ -103,7 +103,7 @@ static int lua_storage_mail_lt(lua_State *L) static int lua_storage_mail_le(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 2); + DLUA_REQUIRE_ARGS(L, 2); struct mail *mail = lua_check_storage_mail(script, 1); struct mail *mail2 = lua_check_storage_mail(script, 2); diff --git a/src/lib-storage/mail-user-lua.c b/src/lib-storage/mail-user-lua.c index 27995272e1..95310c86e9 100644 --- a/src/lib-storage/mail-user-lua.c +++ b/src/lib-storage/mail-user-lua.c @@ -87,7 +87,7 @@ lua_check_storage_mail_user(struct dlua_script *script, int arg) static int lua_storage_mail_user_tostring(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 1); + DLUA_REQUIRE_ARGS(L, 1); struct mail_user *user = lua_check_storage_mail_user(script, 1); lua_pushstring(L, user->username); @@ -106,7 +106,7 @@ int lua_storage_cmp(struct dlua_script *script) static int lua_storage_mail_user_eq(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 2); + DLUA_REQUIRE_ARGS(L, 2); bool res = lua_storage_cmp(script) == 0; lua_pushboolean(script->L, res); return 1; @@ -115,7 +115,7 @@ static int lua_storage_mail_user_eq(lua_State *L) static int lua_storage_mail_user_lt(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 2); + DLUA_REQUIRE_ARGS(L, 2); bool res = lua_storage_cmp(script) <= 0; lua_pushboolean(script->L, res); return 1; @@ -124,7 +124,7 @@ static int lua_storage_mail_user_lt(lua_State *L) static int lua_storage_mail_user_le(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 2); + DLUA_REQUIRE_ARGS(L, 2); bool res = lua_storage_cmp(script) < 0; lua_pushboolean(script->L, res); return 1; @@ -133,7 +133,7 @@ static int lua_storage_mail_user_le(lua_State *L) static int lua_storage_mail_user_var_expand(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 2); + DLUA_REQUIRE_ARGS(L, 2); struct mail_user *user = lua_check_storage_mail_user(script, 1); const char *error; const char *format = luaL_checkstring(script->L, 2); @@ -151,7 +151,7 @@ static int lua_storage_mail_user_var_expand(lua_State *L) static int lua_storage_mail_user_plugin_getenv(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 2); + DLUA_REQUIRE_ARGS(L, 2); struct mail_user *user = lua_check_storage_mail_user(script, 1); const char *set = lua_tostring(script->L, 2); const char *val = mail_user_plugin_getenv(user, set); @@ -162,7 +162,7 @@ static int lua_storage_mail_user_plugin_getenv(lua_State *L) static int lua_storage_mail_user_mailbox_alloc(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS_IN(script, 2, 3); + DLUA_REQUIRE_ARGS_IN(L, 2, 3); struct mail_user *user = lua_check_storage_mail_user(script, 1); const char *mboxname = luaL_checkstring(script->L, 2); enum mailbox_flags flags = 0; @@ -300,7 +300,7 @@ lua_storage_mail_user_set_metadata_unset(struct dlua_script *script, static int lua_storage_mail_user_metadata_set(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 3); + DLUA_REQUIRE_ARGS(L, 3); struct mail_user *user = lua_check_storage_mail_user(script, 1); const char *key = luaL_checkstring(script->L, 2); const char *value; @@ -315,7 +315,7 @@ static int lua_storage_mail_user_metadata_set(lua_State *L) static int lua_storage_mail_user_metadata_unset(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 2); + DLUA_REQUIRE_ARGS(L, 2); struct mail_user *user = lua_check_storage_mail_user(script, 1); const char *key = luaL_checkstring(script->L, 2); diff --git a/src/lib-storage/mailbox-lua.c b/src/lib-storage/mailbox-lua.c index 95d0789bc8..877b282241 100644 --- a/src/lib-storage/mailbox-lua.c +++ b/src/lib-storage/mailbox-lua.c @@ -58,7 +58,7 @@ lua_check_storage_mailbox(struct dlua_script *script, int arg) static int lua_storage_mailbox_tostring(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 1); + DLUA_REQUIRE_ARGS(L, 1); struct mailbox *mbox = lua_check_storage_mailbox(script, 1); lua_pushstring(L, mailbox_get_vname(mbox)); @@ -70,7 +70,7 @@ static int lua_storage_mailbox_tostring(lua_State *L) static int lua_storage_mailbox_eq(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 2); + DLUA_REQUIRE_ARGS(L, 2); struct mailbox *mbox = lua_check_storage_mailbox(script, 1); struct mailbox *mbox2 = lua_check_storage_mailbox(script, 2); lua_pushboolean(script->L, DLUA_MAILBOX_EQUALS(mbox, mbox2)); @@ -81,7 +81,7 @@ static int lua_storage_mailbox_eq(lua_State *L) static int lua_storage_mailbox_lt(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 2); + DLUA_REQUIRE_ARGS(L, 2); bool res = lua_storage_cmp(script) <= 0; lua_pushboolean(script->L, res); return 1; @@ -90,7 +90,7 @@ static int lua_storage_mailbox_lt(lua_State *L) static int lua_storage_mailbox_le(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 2); + DLUA_REQUIRE_ARGS(L, 2); bool res = lua_storage_cmp(script) < 0; lua_pushboolean(script->L, res); return 1; @@ -99,7 +99,7 @@ static int lua_storage_mailbox_le(lua_State *L) static int lua_storage_mailbox_unref(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 1); + DLUA_REQUIRE_ARGS(L, 1); /* fetch item from table */ lua_pushliteral(script->L, "item"); lua_rawget(script->L, 1); @@ -125,7 +125,7 @@ static int lua_storage_mailbox_gc(lua_State *L) static int lua_storage_mailbox_open(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 1); + DLUA_REQUIRE_ARGS(L, 1); struct mailbox *mbox = lua_check_storage_mailbox(script, 1); /* try to open the box */ @@ -141,7 +141,7 @@ static int lua_storage_mailbox_open(lua_State *L) static int lua_storage_mailbox_close(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 1); + DLUA_REQUIRE_ARGS(L, 1); struct mailbox *mbox = lua_check_storage_mailbox(script, 1); mailbox_close(mbox); @@ -152,7 +152,7 @@ static int lua_storage_mailbox_close(lua_State *L) static int lua_storage_mailbox_sync(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS_IN(script, 1, 2); + DLUA_REQUIRE_ARGS_IN(L, 1, 2); struct mailbox *mbox = lua_check_storage_mailbox(script, 1); enum mailbox_sync_flags flags = 0; @@ -277,7 +277,7 @@ static int lua_storage_mailbox_metadata_get(lua_State *L) static int lua_storage_mailbox_metadata_set(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 3); + DLUA_REQUIRE_ARGS(L, 3); struct mailbox *mbox = lua_check_storage_mailbox(script, 1); const char *key = luaL_checkstring(script->L, 2); const char *value, *error; @@ -295,7 +295,7 @@ static int lua_storage_mailbox_metadata_set(lua_State *L) static int lua_storage_mailbox_metadata_unset(lua_State *L) { struct dlua_script *script = dlua_script_from_state(L); - DLUA_REQUIRE_ARGS(script, 2); + DLUA_REQUIRE_ARGS(L, 2); struct mailbox *mbox = lua_check_storage_mailbox(script, 1); const char *key = luaL_checkstring(script->L, 2); const char *error;