summaryrefslogtreecommitdiff
path: root/plugins/MirLua/src/mlua_metatable.h
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2016-04-04 10:31:38 +0000
committerAlexander Lantsev <aunsane@gmail.com>2016-04-04 10:31:38 +0000
commit7532094f8593a3a0760a7cb453d960b009a6484c (patch)
treeb4b888c8a5377a42db45ec134fa0c60147da8ef6 /plugins/MirLua/src/mlua_metatable.h
parent32089106fa10eba08e946693cb2939a4ab293f77 (diff)
MirLua: added MT::Index as fallback on missed key in metatable
git-svn-id: http://svn.miranda-ng.org/main/trunk@16585 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/src/mlua_metatable.h')
-rw-r--r--plugins/MirLua/src/mlua_metatable.h23
1 files changed, 10 insertions, 13 deletions
diff --git a/plugins/MirLua/src/mlua_metatable.h b/plugins/MirLua/src/mlua_metatable.h
index b8fcdec22b..5048c39288 100644
--- a/plugins/MirLua/src/mlua_metatable.h
+++ b/plugins/MirLua/src/mlua_metatable.h
@@ -63,8 +63,13 @@ private:
//memcpy(*obj, udata, sizeof(T));
*obj = (T*)lua_touserdata(L, 1);
}
-
- static void Free(T **obj)
+
+ static int Index(lua_State *L, T */*obj*/)
+ {
+ lua_pushnil(L);
+ }
+
+ static void Free(lua_State */*L*/, T **obj)
{
*obj = NULL;
}
@@ -130,7 +135,7 @@ private:
lua_pushlightuserdata(L, field->GetValue<void*>(obj));
break;
default:
- lua_pushnil(L);
+ return Index(L, obj);
}
return 1;
@@ -139,7 +144,8 @@ private:
static int lua__gc(lua_State *L)
{
T **obj = (T**)luaL_checkudata(L, 1, MT::name);
- MT::Free(obj);
+ MT::Free(L, obj);
+
return 0;
}
@@ -176,15 +182,6 @@ public:
return *this;
}
- MT& Method(lua_CFunction func, const char *name)
- {
- luaL_getmetatable(L, MT::name);
- lua_pushcfunction(L, func);
- lua_setfield(L, -2, name);
- lua_pop(L, 1);
- return *this;
- }
-
static void Set(lua_State *L, T *obj)
{
if (obj == NULL)