summaryrefslogtreecommitdiff
path: root/plugins/MirLua/src/m_protocols.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2016-02-17 11:31:59 +0000
committerAlexander Lantsev <aunsane@gmail.com>2016-02-17 11:31:59 +0000
commit2c7da3b79ebbd1833d1edfdef52d14c2ef2547eb (patch)
tree15beb4e894b43b7e0a9d5912e01dbdc0fd663d0e /plugins/MirLua/src/m_protocols.cpp
parentdf1277bc854e0db5424623890be9a3d74750a03f (diff)
MirLua:
- minor MT fixes - enabled chat module - project cleanup git-svn-id: http://svn.miranda-ng.org/main/trunk@16289 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/src/m_protocols.cpp')
-rw-r--r--plugins/MirLua/src/m_protocols.cpp27
1 files changed, 3 insertions, 24 deletions
diff --git a/plugins/MirLua/src/m_protocols.cpp b/plugins/MirLua/src/m_protocols.cpp
index 2f6f5af836..5e30c1dad4 100644
--- a/plugins/MirLua/src/m_protocols.cpp
+++ b/plugins/MirLua/src/m_protocols.cpp
@@ -152,28 +152,6 @@ static luaL_Reg protocolsApi[] =
/***********************************************/
-#define MT_CCSDATA "CCSDATA"
-
-static int ccs__index(lua_State *L)
-{
- CCSDATA *ccs = *(CCSDATA**)luaL_checkudata(L, 1, MT_CCSDATA);
- const char *key = lua_tostring(L, 2);
-
- if (mir_strcmpi(key, "hContact") == 0)
- lua_pushinteger(L, ccs->hContact);
- else if (mir_strcmpi(key, "Message") == 0)
- {
- PROTORECVEVENT *pre = (PROTORECVEVENT*)ccs->lParam;
- lua_pushstring(L, pre->szMessage);
- }
- else
- lua_pushnil(L);
-
- return 1;
-}
-
-/***********************************************/
-
LUAMOD_API int luaopen_m_protocols(lua_State *L)
{
luaL_newlib(L, protocolsApi);
@@ -202,8 +180,9 @@ LUAMOD_API int luaopen_m_protocols(lua_State *L)
.Field(&ACKDATA::lParam, "lParam", LUA_TLIGHTUSERDATA);
lua_pop(L, 1);
- MT<CCSDATA>(L, MT_CCSDATA)
- .Method(ccs__index, "__index");
+ MT<CCSDATA>(L, "CCSDATA")
+ .Field(&CCSDATA::hContact, "hContact", LUA_TINTEGER)
+ .Field([](CCSDATA *ccs) { return ((PROTORECVEVENT*)ccs->lParam)->szMessage; }, "Message", LUA_TSTRING);
lua_pop(L, 1);
return 1;