Changed misleading name: push should push.

This commit is contained in:
Guillaume Melquiond 2010-08-06 21:14:11 +00:00
parent c8b1a1c1de
commit ba266cbab3
2 changed files with 13 additions and 11 deletions

View file

@ -319,8 +319,7 @@ void lua_ai_action_handler::handle(config &cfg, bool configOut)
if (!configOut)
{
lua_newtable(L);//stack size is 3 [-1: table -2: ai_context -3: ai_action]
luaW_pushconfig(L, cfg);//the new table now contains the config
luaW_pushconfig(L, cfg);
luaW_pcall(L, 2, LUA_MULTRET, true);
}
else if (lua_gettop(L) > initial_top)

View file

@ -248,7 +248,7 @@ static t_string luaW_checktstring(lua_State *L, int index)
* The destination table should be at the top of the stack on entry. It is
* still at the top on exit.
*/
void luaW_pushconfig(lua_State *L, config const &cfg)
static void luaW_filltable(lua_State *L, config const &cfg)
{
if (!lua_checkstack(L, LUA_MINSTACK))
return;
@ -260,7 +260,7 @@ void luaW_pushconfig(lua_State *L, config const &cfg)
lua_pushstring(L, ch.key.c_str());
lua_rawseti(L, -2, 1);
lua_newtable(L);
luaW_pushconfig(L, ch.cfg);
luaW_filltable(L, ch.cfg);
lua_rawseti(L, -2, 2);
lua_rawseti(L, -2, k++);
}
@ -271,6 +271,15 @@ void luaW_pushconfig(lua_State *L, config const &cfg)
}
}
/**
* Converts a config object to a Lua table pushed at the top of the stack.
*/
void luaW_pushconfig(lua_State *L, config const &cfg)
{
lua_newtable(L);
luaW_filltable(L, cfg);
}
#define return_misformed() \
do { lua_settop(L, initial_top); return false; } while (0)
@ -641,12 +650,10 @@ static int impl_vconfig_get(lua_State *L)
char const *m = luaL_checkstring(L, 2);
if (strcmp(m, "__literal") == 0) {
lua_newtable(L);
luaW_pushconfig(L, v->get_config());
return 1;
}
if (strcmp(m, "__parsed") == 0) {
lua_newtable(L);
luaW_pushconfig(L, v->get_parsed_config());
return 1;
}
@ -740,14 +747,12 @@ static int impl_vconfig_collect(lua_State *L)
if (strcmp(m, name) == 0) { \
config cfg; \
accessor; \
lua_newtable(L); \
luaW_pushconfig(L, cfg); \
return 1; \
}
#define return_cfgref_attrib(name, accessor) \
if (strcmp(m, name) == 0) { \
lua_newtable(L); \
luaW_pushconfig(L, accessor); \
return 1; \
}
@ -1126,7 +1131,7 @@ static int intf_get_variable(lua_State *L)
if (w.is_valid) {
lua_newtable(L);
if (lua_toboolean(L, 2))
luaW_pushconfig(L, w.as_container());
luaW_filltable(L, w.as_container());
return 1;
}
}
@ -1550,7 +1555,6 @@ static int impl_current_get(lua_State *L)
cfg["x2"] = ev.loc2.x + 1;
cfg["y2"] = ev.loc2.y + 1;
}
lua_newtable(L);
luaW_pushconfig(L, cfg);
return 1;
}
@ -2255,7 +2259,6 @@ static int intf_synchronize_choice(lua_State *L)
{
lua_settop(L, 1);
config cfg = mp_sync::get_user_choice("input", lua_synchronize(L));
lua_newtable(L);
luaW_pushconfig(L, cfg);
return 1;
}