Use lua_createtable where applicable

This commit is contained in:
Thomas Goyne 2014-04-27 06:41:28 -07:00
parent 5cde33c8d5
commit 689c16deb3
5 changed files with 17 additions and 17 deletions

View file

@ -156,7 +156,7 @@ int regex_process_flags(lua_State *L) {
}
int regex_init_flags(lua_State *L) {
lua_newtable(L);
lua_createtable(L, 0, 9);
set_field(L, "ICASE", (void*)boost::u32regex::icase);
set_field(L, "NOSUB", (void*)boost::u32regex::nosubs);
@ -184,7 +184,7 @@ extern "C" int luaopen_re_impl(lua_State *L) {
lua_pop(L, 1);
}
lua_newtable(L);
lua_createtable(L, 0, 8);
set_field(L, "matches", regex_matches);
set_field(L, "search", regex_search);
set_field(L, "match", regex_match);

View file

@ -157,7 +157,7 @@ namespace {
int clipboard_init(lua_State *L)
{
lua_newtable(L);
lua_createtable(L, 0, 2);
set_field(L, "get", clipboard_get);
set_field(L, "set", clipboard_set);
return 1;
@ -256,7 +256,7 @@ namespace {
std::vector<int> const& kf = c->videoController->GetKeyFrames();
lua_newtable(L);
lua_createtable(L, kf.size(), 0);
for (size_t i = 0; i < kf.size(); ++i) {
push_value(L, kf[i]);
lua_rawseti(L, -2, i);
@ -466,7 +466,7 @@ namespace {
// make "aegisub" table
lua_pushstring(L, "aegisub");
lua_newtable(L);
lua_createtable(L, 0, 12);
set_field(L, "register_macro", LuaCommand::LuaRegister);
set_field(L, "register_filter", LuaExportFilter::LuaRegister);
@ -698,7 +698,7 @@ namespace {
cmd_type |= cmd::COMMAND_TOGGLE;
// new table for containing the functions for this feature
lua_newtable(L);
lua_createtable(L, 0, 3);
// store processing function
push_value(L, "run");
@ -739,9 +739,9 @@ namespace {
return rows;
}
static void transform_selection(lua_State *L, std::vector<int> rows)
static void transform_selection(lua_State *L, std::vector<int> const& rows)
{
lua_newtable(L);
lua_createtable(L, rows.size(), 0);
for (size_t i = 0; i < rows.size(); ++i) {
push_value(L, rows[i]);
lua_rawseti(L, -2, i + 1);
@ -924,7 +924,7 @@ namespace {
luaL_error(L, "The filter processing function must be a function");
// new table for containing the functions for this feature
lua_newtable(L);
lua_createtable(L, 0, 2);
// store processing function
push_value(L, "run");

View file

@ -628,7 +628,7 @@ namespace Automation4 {
// 2.1.x stored everything before the first syllable at index zero
// There's no longer any such thing with the new parser, but scripts
// may rely on kara[0] existing so add an empty syllable
lua_newtable(L);
lua_createtable(L, 0, 6);
set_field(L, "duration", 0);
set_field(L, "start_time", 0);
set_field(L, "end_time", 0);
@ -639,7 +639,7 @@ namespace Automation4 {
AssKaraoke kara(dia, false, false);
for (auto const& syl : kara) {
lua_newtable(L);
lua_createtable(L, 0, 6);
set_field(L, "duration", syl.duration);
set_field(L, "start_time", syl.start_time - dia->Start);
set_field(L, "end_time", syl.start_time + syl.duration - dia->Start);
@ -740,7 +740,7 @@ namespace Automation4 {
*static_cast<LuaAssFile**>(lua_newuserdata(L, sizeof(LuaAssFile*))) = this;
// make the metatable
lua_newtable(L);
lua_createtable(L, 0, 5);
set_field(L, "__index", closure_wrapper<&LuaAssFile::ObjectIndexRead>);
set_field(L, "__newindex", closure_wrapper_v<&LuaAssFile::ObjectIndexWrite, false>);
set_field(L, "__len", closure_wrapper<&LuaAssFile::ObjectGetLen>);

View file

@ -543,7 +543,7 @@ namespace Automation4 {
}
// Then read controls back
lua_newtable(L);
lua_createtable(L, 0, controls.size());
for (auto& control : controls) {
control->LuaReadBack(L);
lua_setfield(L, -2, control->name.c_str());

View file

@ -69,7 +69,7 @@ namespace Automation4 {
lua_getglobal(L, "aegisub");
// Create aegisub.progress table
lua_newtable(L);
lua_createtable(L, 0, 5);
set_field_to_closure(L, "set", LuaSetProgress);
set_field_to_closure(L, "task", LuaSetTask);
set_field_to_closure(L, "title", LuaSetTitle);
@ -77,7 +77,7 @@ namespace Automation4 {
lua_setfield(L, -2, "progress");
// Create aegisub.debug table
lua_newtable(L);
lua_createtable(L, 0, 4);
set_field_to_closure(L, "out", LuaDebugOut);
lua_setfield(L, -2, "debug");
@ -85,7 +85,7 @@ namespace Automation4 {
set_field_to_closure(L, "log", LuaDebugOut, -2);
if (allow_config_dialog) {
lua_newtable(L);
lua_createtable(L, 0, 3);
set_field_to_closure(L, "display", LuaDisplayDialog);
set_field_to_closure(L, "open", LuaDisplayOpenDialog);
set_field_to_closure(L, "save", LuaDisplaySaveDialog);
@ -216,7 +216,7 @@ namespace Automation4 {
wxArrayString files;
diag.GetPaths(files);
lua_newtable(L);
lua_createtable(L, files.size(), 0);
for (size_t i = 0; i < files.size(); ++i) {
lua_pushstring(L, files[i].utf8_str());
lua_rawseti(L, -2, i + 1);