summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2016-04-24 13:13:31 +0000
committerAlexander Lantsev <aunsane@gmail.com>2016-04-24 13:13:31 +0000
commit0080cd035eaa00062b5f0f494be1e8862d8548b7 (patch)
treefabf8dda506c5637328f03770f676e152cfd64c7 /plugins
parent79812b0325d58e7954d4aec16aa8dddfec9c5479 (diff)
MirLua: fixed CONTACTINFO metatable
git-svn-id: http://svn.miranda-ng.org/main/trunk@16760 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/MirLua/src/m_database.cpp17
-rw-r--r--plugins/MirLua/src/mlua_metatable.h5
2 files changed, 10 insertions, 12 deletions
diff --git a/plugins/MirLua/src/m_database.cpp b/plugins/MirLua/src/m_database.cpp
index a493970bfc..f81baf06b6 100644
--- a/plugins/MirLua/src/m_database.cpp
+++ b/plugins/MirLua/src/m_database.cpp
@@ -577,20 +577,14 @@ void MT<DBEVENTINFO>::Free(lua_State*, DBEVENTINFO **dbei)
void MT<CONTACTINFO>::Init(lua_State *L, CONTACTINFO **ci)
{
- MCONTACT hContact = 0;
- switch (lua_type(L, 1))
+ if (!lua_isinteger(L, 1))
{
- case LUA_TNUMBER:
- hContact = lua_tointeger(L, 1);
- break;
- case LUA_TLIGHTUSERDATA:
- hContact = (MCONTACT)lua_touserdata(L, 1);
- break;
- default:
const char *msg = lua_pushfstring(L, "hContact expected, got %s", luaL_typename(L, 1));
luaL_argerror(L, 1, msg);
}
+ MCONTACT hContact = luaL_checkinteger(L, 1);
+ (*ci) = (CONTACTINFO*)mir_calloc(sizeof(CONTACTINFO));
(*ci)->cbSize = sizeof(CONTACTINFO);
(*ci)->hContact = hContact;
}
@@ -681,6 +675,11 @@ int MT<CONTACTINFO>::Index(lua_State *L, CONTACTINFO *ci)
return 1;
}
+void MT<CONTACTINFO>::Free(lua_State *L, CONTACTINFO **ci)
+{
+ mir_free((*ci));
+}
+
/***********************************************/
LUAMOD_API int luaopen_m_database(lua_State *L)
diff --git a/plugins/MirLua/src/mlua_metatable.h b/plugins/MirLua/src/mlua_metatable.h
index 0946eb9caa..13c2d614e3 100644
--- a/plugins/MirLua/src/mlua_metatable.h
+++ b/plugins/MirLua/src/mlua_metatable.h
@@ -106,8 +106,7 @@ private:
auto it = fields.find(key);
if (it == fields.end())
{
- lua_pushnil(L);
- return 1;
+ return Index(L, obj);
}
MTField<T> *field = it->second;
@@ -136,7 +135,7 @@ private:
lua_pushlightuserdata(L, field->GetValue<void*>(obj));
break;
default:
- return Index(L, obj);
+ lua_pushnil(L);
}
return 1;