summaryrefslogtreecommitdiff
path: root/plugins/MirLua/src/m_message.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-10-21 18:29:50 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-10-21 18:29:50 +0000
commitc99bbd2ef7f9fb2295ff2ec07bb690c4d7351a71 (patch)
treea760bc80000499732a80034d32bdd02cb3e9b885 /plugins/MirLua/src/m_message.cpp
parentdd4878e302ae384f7b51b9ef60ff3a06dbd11a11 (diff)
MirLua:
- added totable to cast userdata to metatable - all modules hooks are marked as obsolete - version bumb git-svn-id: http://svn.miranda-ng.org/main/trunk@15586 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/src/m_message.cpp')
-rw-r--r--plugins/MirLua/src/m_message.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/plugins/MirLua/src/m_message.cpp b/plugins/MirLua/src/m_message.cpp
index 2968b1aeda..1722671689 100644
--- a/plugins/MirLua/src/m_message.cpp
+++ b/plugins/MirLua/src/m_message.cpp
@@ -103,6 +103,8 @@ int MsgWindowEventHookEventObjParam(void *obj, WPARAM wParam, LPARAM lParam, LPA
static int lua_OnMsgWindowEvent(lua_State *L)
{
+ ObsoleteMethod(L, "Use m.HookEvent instead");
+
if (!lua_isfunction(L, 1))
{
lua_pushlightuserdata(L, NULL);
@@ -131,9 +133,58 @@ static luaL_Reg messageApi[] =
{ NULL, NULL }
};
+#define MT_MESSAGEWINDOWEVENTDATA "MessageWindowEventData"
+
+static int mwed__init(lua_State *L)
+{
+ MessageWindowEventData *udata = (MessageWindowEventData*)lua_touserdata(L, 1);
+ if (udata == NULL)
+ {
+ lua_pushnil(L);
+ return 1;
+ }
+
+ MessageWindowEventData **mwed = (MessageWindowEventData**)lua_newuserdata(L, sizeof(MessageWindowEventData*));
+ *mwed = udata;
+
+ luaL_setmetatable(L, MT_MESSAGEWINDOWEVENTDATA);
+
+ return 1;
+}
+
+static int mwed__index(lua_State *L)
+{
+ MessageWindowEventData *mwed = *(MessageWindowEventData**)luaL_checkudata(L, 1, MT_MESSAGEWINDOWEVENTDATA);
+ const char *key = lua_tostring(L, 2);
+
+ if (!mir_strcmpi(key, "Module"))
+ lua_pushstring(L, ptrA(mir_utf8encode(mwed->szModule)));
+ if (!mir_strcmpi(key, "Type"))
+ lua_pushinteger(L, mwed->uType);
+ if (!mir_strcmpi(key, "hContact"))
+ lua_pushinteger(L, mwed->hContact);
+ if (!mir_strcmpi(key, "Flags"))
+ lua_pushinteger(L, mwed->uFlags);
+ else
+ lua_pushnil(L);
+
+ return 1;
+}
+
+static luaL_Reg mwedMeta[] =
+{
+ { "__init", mwed__init },
+ { "__index", mwed__index },
+ { NULL, NULL }
+};
+
LUAMOD_API int luaopen_m_message(lua_State *L)
{
luaL_newlib(L, messageApi);
+ luaL_newmetatable(L, MT_MESSAGEWINDOWEVENTDATA);
+ luaL_setfuncs(L, mwedMeta, 0);
+ lua_pop(L, 1);
+
return 1;
}