summaryrefslogtreecommitdiff
path: root/library/LuaWrapper.cpp
diff options
context:
space:
mode:
authorAlexander Gavrilov2012-03-31 12:11:43 +0400
committerAlexander Gavrilov2012-03-31 12:11:43 +0400
commit9384f0c842f817bf810b34e44bfa3be913e7e3fc (patch)
treee5c69e7f4492ad4b8983e458471ac904a5364d88 /library/LuaWrapper.cpp
parent10b610669fe90bbe32ca412e74234b74d1293f6c (diff)
downloaddfhack-9384f0c842f817bf810b34e44bfa3be913e7e3fc.tar.gz
dfhack-9384f0c842f817bf810b34e44bfa3be913e7e3fc.tar.bz2
dfhack-9384f0c842f817bf810b34e44bfa3be913e7e3fc.tar.xz
Update lua to 5.2 and fix obvious breakage due to obsolete api.
Diffstat (limited to 'library/LuaWrapper.cpp')
-rw-r--r--library/LuaWrapper.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/library/LuaWrapper.cpp b/library/LuaWrapper.cpp
index 8e3bff7d..81712724 100644
--- a/library/LuaWrapper.cpp
+++ b/library/LuaWrapper.cpp
@@ -695,7 +695,7 @@ static int meta_assign(lua_State *state)
/*
* no assign && nil or missing resize field => 1-based lua array
*/
- int size = lua_objlen(state, 2);
+ int size = lua_rawlen(state, 2);
lua_pop(state, 1);
invoke_resize(state, 1, size);
@@ -1242,7 +1242,7 @@ static void RenderTypeChildren(lua_State *state, const std::vector<compound_iden
}
}
-static void DoAttach(lua_State *state)
+static int DoAttach(lua_State *state)
{
int base = lua_gettop(state);
@@ -1287,8 +1287,6 @@ static void DoAttach(lua_State *state)
lua_pushcclosure(state, meta_delete, 1);
lua_setfield(state, LUA_REGISTRYINDEX, DFHACK_DELETE_NAME);
- luaL_register(state, "df", no_functions);
-
{
// Assign df a metatable with read-only contents
lua_newtable(state);
@@ -1312,12 +1310,10 @@ static void DoAttach(lua_State *state)
lua_pushlightuserdata(state, NULL);
lua_setglobal(state, "NULL");
- freeze_table(state, true, "df");
- lua_remove(state, -2);
- lua_setmetatable(state, -2);
+ freeze_table(state, false, "df");
}
- lua_pop(state, 1);
+ return 1;
}
/**
@@ -1327,7 +1323,10 @@ static void DoAttach(lua_State *state)
void DFHack::AttachDFGlobals(lua_State *state)
{
if (luaL_newmetatable(state, DFHACK_TYPETABLE_NAME))
- DoAttach(state);
+ {
+ luaL_requiref(state, "df", DoAttach, 1);
+ lua_pop(state, 1);
+ }
lua_pop(state, 1);
}