diff options
author | Matthew Hoops | 2011-05-03 17:17:27 -0400 |
---|---|---|
committer | Matthew Hoops | 2011-05-03 17:25:41 -0400 |
commit | 9cb600099f4c29298707787cafad2741a1cd6686 (patch) | |
tree | fb1930fa56b611317831d66442cba19b18d2e57a /engines/sword25/script | |
parent | 3b2283daf850605ca897002afbafe44489c35473 (diff) | |
parent | 95a6098f672191dc0792bd4f9bfa18706bbe8e3a (diff) | |
download | scummvm-rg350-9cb600099f4c29298707787cafad2741a1cd6686.tar.gz scummvm-rg350-9cb600099f4c29298707787cafad2741a1cd6686.tar.bz2 scummvm-rg350-9cb600099f4c29298707787cafad2741a1cd6686.zip |
Merge remote branch 'upstream/master' into pegasus
Diffstat (limited to 'engines/sword25/script')
-rw-r--r-- | engines/sword25/script/luabindhelper.cpp | 21 | ||||
-rw-r--r-- | engines/sword25/script/luabindhelper.h | 2 | ||||
-rw-r--r-- | engines/sword25/script/luacallback.cpp | 2 |
3 files changed, 25 insertions, 0 deletions
diff --git a/engines/sword25/script/luabindhelper.cpp b/engines/sword25/script/luabindhelper.cpp index 5ff9708b95..03a1802a04 100644 --- a/engines/sword25/script/luabindhelper.cpp +++ b/engines/sword25/script/luabindhelper.cpp @@ -303,6 +303,27 @@ bool LuaBindhelper::getMetatable(lua_State *L, const Common::String &tableName) return true; } +// Like luaL_checkudata, only without that no error is generated. +void *LuaBindhelper::my_checkudata(lua_State *L, int ud, const char *tname) { + int top = lua_gettop(L); + + void *p = lua_touserdata(L, ud); + if (p != NULL) { /* value is a userdata? */ + if (lua_getmetatable(L, ud)) { /* does it have a metatable? */ + // lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */ + LuaBindhelper::getMetatable(L, tname); + if (lua_rawequal(L, -1, -2)) { /* does it have the correct mt? */ + lua_settop(L, top); + return p; + } + } + } + + lua_settop(L, top); + return NULL; +} + + bool LuaBindhelper::createTable(lua_State *L, const Common::String &tableName) { const char *partBegin = tableName.c_str(); diff --git a/engines/sword25/script/luabindhelper.h b/engines/sword25/script/luabindhelper.h index dc45104d53..94f52743f3 100644 --- a/engines/sword25/script/luabindhelper.h +++ b/engines/sword25/script/luabindhelper.h @@ -110,6 +110,8 @@ public: static bool getMetatable(lua_State *L, const Common::String &tableName); + static void *my_checkudata(lua_State *L, int ud, const char *tname); + private: static bool createTable(lua_State *L, const Common::String &tableName); }; diff --git a/engines/sword25/script/luacallback.cpp b/engines/sword25/script/luacallback.cpp index 137e37bf8d..809676796e 100644 --- a/engines/sword25/script/luacallback.cpp +++ b/engines/sword25/script/luacallback.cpp @@ -32,6 +32,8 @@ * */ +#include "common/textconsole.h" + #include "sword25/script/luacallback.h" #include "sword25/script/luabindhelper.h" |