diff options
-rw-r--r-- | plugins/MirLua/src/m_chat.cpp | 6 | ||||
-rw-r--r-- | plugins/MirLua/src/m_core.cpp | 103 | ||||
-rw-r--r-- | plugins/MirLua/src/m_database.cpp | 83 | ||||
-rw-r--r-- | plugins/MirLua/src/m_message.cpp | 52 | ||||
-rw-r--r-- | plugins/MirLua/src/m_msg_buttonsbar.cpp | 49 | ||||
-rw-r--r-- | plugins/MirLua/src/m_protocols.cpp | 167 | ||||
-rw-r--r-- | plugins/MirLua/src/mlua_metatable.h | 3 |
7 files changed, 112 insertions, 351 deletions
diff --git a/plugins/MirLua/src/m_chat.cpp b/plugins/MirLua/src/m_chat.cpp index 5874db12bd..cc32d26d78 100644 --- a/plugins/MirLua/src/m_chat.cpp +++ b/plugins/MirLua/src/m_chat.cpp @@ -123,11 +123,11 @@ static int gce__index(lua_State *L) else if (mir_strcmpi(key, "Uid") == 0)
lua_pushstring(L, ptrA(mir_utf8encodeT(gce->pDest->ptszID)));
else if (mir_strcmpi(key, "Nick") == 0)
- lua_pushstring(L, ptrA(mir_utf8encodeT(gce->pDest->ptszID)));
+ lua_pushstring(L, ptrA(mir_utf8encodeT(gce->ptszNick)));
else if (mir_strcmpi(key, "Status") == 0)
- lua_pushstring(L, ptrA(mir_utf8encodeT(gce->pDest->ptszID)));
+ lua_pushstring(L, ptrA(mir_utf8encodeT(gce->ptszStatus)));
else if (mir_strcmpi(key, "Text") == 0)
- lua_pushstring(L, ptrA(mir_utf8encodeT(gce->pDest->ptszID)));
+ lua_pushstring(L, ptrA(mir_utf8encodeT(gce->ptszText)));
else
lua_pushnil(L);
diff --git a/plugins/MirLua/src/m_core.cpp b/plugins/MirLua/src/m_core.cpp index a9a6bcf280..cc26e6bab2 100644 --- a/plugins/MirLua/src/m_core.cpp +++ b/plugins/MirLua/src/m_core.cpp @@ -5,33 +5,37 @@ static int lua_CreateHookableEvent(lua_State *L) const char *name = luaL_checkstring(L, 1);
HANDLE res = ::CreateHookableEvent(name);
- lua_pushlightuserdata(L, res);
-
- CMLua::Events.insert(res);
+ if (res)
+ {
+ lua_pushlightuserdata(L, res);
+ CMLua::Events.insert(res);
+ }
+ else
+ lua_pushnil(L);
return 1;
}
static int lua_DestroyHookableEvent(lua_State *L)
{
- HANDLE hEvent = (HANDLE)lua_touserdata(L, 1);
-
- CMLua::Events.remove(hEvent);
+ HANDLE hEvent = lua_touserdata(L, 1);
int res = ::DestroyHookableEvent(hEvent);
- lua_pushinteger(L, res);
+ if (!res)
+ CMLua::Events.remove(hEvent);
+ lua_pushboolean(L, !res);
return 1;
}
static int lua_NotifyEventHooks(lua_State *L)
{
- HANDLE hEvent = (HANDLE)lua_touserdata(L, 1);
+ HANDLE hEvent = lua_touserdata(L, 1);
WPARAM wParam = luaM_towparam(L, 2);
LPARAM lParam = luaM_tolparam(L, 3);
int res = ::NotifyEventHooks(hEvent, wParam, lParam);
- lua_pushinteger(L, res);
+ lua_pushboolean(L, res != -1);
return 1;
}
@@ -56,41 +60,46 @@ int HookEventObjParam(void *obj, WPARAM wParam, LPARAM lParam, LPARAM param) static int lua_HookEvent(lua_State *L)
{
const char *name = luaL_checkstring(L, 1);
-
- if (!lua_isfunction(L, 2))
- {
- lua_pushlightuserdata(L, NULL);
- return 1;
- }
+ luaL_checktype(L, 2, LUA_TFUNCTION);
lua_pushvalue(L, 2);
int ref = luaL_ref(L, LUA_REGISTRYINDEX);
HANDLE res = ::HookEventObjParam(name, HookEventObjParam, L, ref);
- lua_pushlightuserdata(L, res);
-
- CMLua::Hooks.insert(res);
- CMLua::HookRefs.insert(new HandleRefParam(L, res, ref));
+ if (res)
+ {
+ CMLua::Hooks.insert(res);
+ CMLua::HookRefs.insert(new HandleRefParam(L, res, ref));
+
+ lua_pushlightuserdata(L, res);
+ }
+ else
+ {
+ luaL_unref(L, LUA_REGISTRYINDEX, ref);
+ lua_pushnil(L);
+ }
return 1;
}
static int lua_UnhookEvent(lua_State *L)
{
- HANDLE hEvent = (HANDLE)lua_touserdata(L, 1);
-
- CMLua::Hooks.remove(hEvent);
+ HANDLE hEvent = lua_touserdata(L, 1);
- HandleRefParam *param = (HandleRefParam*)CMLua::HookRefs.find(hEvent);
- if (param != NULL)
+ int res = ::UnhookEvent(hEvent);
+ if (!res)
{
- luaL_unref(param->L, LUA_REGISTRYINDEX, param->ref);
- CMLua::HookRefs.remove(param);
- delete param;
+ CMLua::Hooks.remove(hEvent);
+
+ HandleRefParam *param = (HandleRefParam*)CMLua::HookRefs.find(hEvent);
+ if (param != NULL)
+ {
+ luaL_unref(param->L, LUA_REGISTRYINDEX, param->ref);
+ CMLua::HookRefs.remove(param);
+ delete param;
+ }
}
-
- int res = ::UnhookEvent(hEvent);
- lua_pushinteger(L, res);
+ lua_pushboolean(L, !res);
return 1;
}
@@ -107,7 +116,7 @@ INT_PTR CreateServiceFunctionObjParam(void *obj, WPARAM wParam, LPARAM lParam, L if (lua_pcall(L, 2, 1, 0))
CallService(MS_NETLIB_LOG, (WPARAM)hNetlib, (LPARAM)lua_tostring(L, -1));
- INT_PTR res = (INT_PTR)lua_tointeger(L, 1);
+ INT_PTR res = lua_tointeger(L, 1);
lua_pushinteger(L, res);
return res;
@@ -116,28 +125,31 @@ INT_PTR CreateServiceFunctionObjParam(void *obj, WPARAM wParam, LPARAM lParam, L static int lua_CreateServiceFunction(lua_State *L)
{
const char *name = luaL_checkstring(L, 1);
-
- if (!lua_isfunction(L, 2))
- {
- lua_pushlightuserdata(L, NULL);
- return 1;
- }
+ luaL_checktype(L, 2, LUA_TFUNCTION);
lua_pushvalue(L, 2);
int ref = luaL_ref(L, LUA_REGISTRYINDEX);
HANDLE res = ::CreateServiceFunctionObjParam(name, CreateServiceFunctionObjParam, L, ref);
- lua_pushlightuserdata(L, res);
+ if (!res)
+ {
+ CMLua::Services.insert(res);
+ CMLua::ServiceRefs.insert(new HandleRefParam(L, res, ref));
- CMLua::Services.insert(res);
- CMLua::ServiceRefs.insert(new HandleRefParam(L, res, ref));
+ lua_pushlightuserdata(L, res);
+ }
+ else
+ {
+ luaL_unref(L, LUA_REGISTRYINDEX, ref);
+ lua_pushnil(L);
+ }
return 1;
}
static int lua_DestroyServiceFunction(lua_State *L)
{
- HANDLE hService = (HANDLE)lua_touserdata(L, 1);
+ HANDLE hService = lua_touserdata(L, 1);
CMLua::Services.remove(hService);
@@ -149,10 +161,9 @@ static int lua_DestroyServiceFunction(lua_State *L) delete param;
}
- int res = ::DestroyServiceFunction(hService);
- lua_pushinteger(L, res);
+ ::DestroyServiceFunction(hService);
- return 1;
+ return 0;
}
static int lua_ServiceExists(lua_State *L)
@@ -190,7 +201,6 @@ static int lua_IsPluginLoaded(lua_State *L) return 1;
}
-
static int lua_Utf8DecodeA(lua_State *L)
{
return luaM_toansi(L);
@@ -272,6 +282,7 @@ luaL_Reg coreApi[] = { "NULL", NULL },
{ "INVALID_HANDLE_VALUE", NULL },
+ { "CALLSERVICE_NOTFOUND", NULL },
{ NULL, NULL }
};
@@ -283,6 +294,8 @@ LUAMOD_API int luaopen_m_core(lua_State *L) lua_setfield(L, -2, "NULL");
lua_pushlightuserdata(L, INVALID_HANDLE_VALUE);
lua_setfield(L, -2, "INVALID_HANDLE_VALUE");
+ lua_pushinteger(L, CALLSERVICE_NOTFOUND);
+ lua_setfield(L, -2, "CALLSERVICE_NOTFOUND");
// set copy to global variable m
lua_pushvalue(L, -1);
lua_setglobal(L, "m");
diff --git a/plugins/MirLua/src/m_database.cpp b/plugins/MirLua/src/m_database.cpp index 63fb270bfd..886be02dd6 100644 --- a/plugins/MirLua/src/m_database.cpp +++ b/plugins/MirLua/src/m_database.cpp @@ -583,63 +583,6 @@ static luaL_Reg databaseApi[] = { NULL, NULL }
};
-#define MT_DBEVENTINFO "DBEVENTINFO"
-
-static int dbei__init(lua_State *L)
-{
- MEVENT hEvent = lua_tointeger(L, 1);
-
- DBEVENTINFO *dbei = (DBEVENTINFO*)lua_newuserdata(L, sizeof(DBEVENTINFO));
- dbei->cbSize = sizeof(DBEVENTINFO);
- dbei->cbBlob = db_event_getBlobSize(hEvent);
- dbei->pBlob = (PBYTE)mir_calloc(dbei->cbBlob);
- db_event_get(hEvent, dbei);
-
- luaL_setmetatable(L, MT_DBEVENTINFO);
-
- return 1;
-}
-
-static int dbei__index(lua_State *L)
-{
- DBEVENTINFO *dbei = (DBEVENTINFO*)luaL_checkudata(L, 1, MT_DBEVENTINFO);
- const char *key = luaL_checkstring(L, 2);
-
- if (mir_strcmpi(key, "Module") == 0)
- lua_pushstring(L, ptrA(mir_utf8encode(dbei->szModule)));
- else if (mir_strcmpi(key, "Timestamp") == 0)
- lua_pushnumber(L, dbei->timestamp);
- else if (mir_strcmpi(key, "Type") == 0)
- lua_pushinteger(L, dbei->eventType);
- else if (mir_strcmpi(key, "Flags") == 0)
- lua_pushinteger(L, dbei->flags);
- else if (mir_strcmpi(key, "Length") == 0)
- lua_pushnumber(L, dbei->cbBlob);
- else if (mir_strcmpi(key, "Blob") == 0)
- lua_pushlightuserdata(L, dbei->pBlob);
- else
- lua_pushnil(L);
-
- return 1;
-}
-
-static int dbei__gc(lua_State *L)
-{
- DBEVENTINFO *dbei = (DBEVENTINFO*)luaL_checkudata(L, 1, MT_DBEVENTINFO);
-
- mir_free(dbei->pBlob);
-
- return 0;
-}
-
-static const luaL_Reg dbeiMeta[] =
-{
- { "MT_DBEVENTINFO", dbei__init },
- { "__index", dbei__index },
- { "__gc", dbei__gc },
- { NULL, NULL }
-};
-
#define MT_DBCONTACTWRITESETTING "DBCONTACTWRITESETTING"
static int dbcw__init(lua_State *L)
@@ -707,13 +650,35 @@ static const luaL_Reg dbcwMeta[] = { NULL, NULL }
};
+DBEVENTINFO* MT<DBEVENTINFO>::Load(lua_State *L)
+{
+ MEVENT hDbEvent = luaL_checkinteger(L, 1);
+
+ DBEVENTINFO *dbei = (DBEVENTINFO*)mir_calloc(sizeof(DBEVENTINFO));
+ dbei->cbSize = sizeof(DBEVENTINFO);
+ dbei->cbBlob = db_event_getBlobSize((MEVENT)hDbEvent);
+ dbei->pBlob = (PBYTE)mir_calloc(dbei->cbBlob);
+ db_event_get((MEVENT)hDbEvent, dbei);
+ return dbei;
+}
+
+void MT<DBEVENTINFO>::Free(DBEVENTINFO **dbei)
+{
+ mir_free((*dbei)->pBlob);
+ mir_free(*dbei);
+}
LUAMOD_API int luaopen_m_database(lua_State *L)
{
luaL_newlib(L, databaseApi);
- luaL_newmetatable(L, MT_DBEVENTINFO);
- luaL_setfuncs(L, dbeiMeta, 0);
+ MT<DBEVENTINFO>(L, "DBEVENTINFO")
+ .Field(&DBEVENTINFO::szModule, "Module", LUA_TSTRINGA)
+ .Field(&DBEVENTINFO::timestamp, "Timestamp", LUA_TINTEGER)
+ .Field(&DBEVENTINFO::eventType, "Type", LUA_TINTEGER)
+ .Field(&DBEVENTINFO::flags, "Flags", LUA_TINTEGER)
+ .Field(&DBEVENTINFO::cbBlob, "Length", LUA_TINTEGER)
+ .Field(&DBEVENTINFO::pBlob, "Blob", LUA_TLIGHTUSERDATA);
lua_pop(L, 1);
luaL_newmetatable(L, MT_DBCONTACTWRITESETTING);
diff --git a/plugins/MirLua/src/m_message.cpp b/plugins/MirLua/src/m_message.cpp index 6d6959c5e4..3d0848d523 100644 --- a/plugins/MirLua/src/m_message.cpp +++ b/plugins/MirLua/src/m_message.cpp @@ -133,57 +133,15 @@ 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") == 0)
- lua_pushstring(L, ptrA(mir_utf8encode(mwed->szModule)));
- else if (!mir_strcmpi(key, "Type") == 0)
- lua_pushinteger(L, mwed->uType);
- else if (!mir_strcmpi(key, "hContact") == 0)
- lua_pushinteger(L, mwed->hContact);
- else if (!mir_strcmpi(key, "Flags") == 0)
- lua_pushinteger(L, mwed->uFlags);
- else
- lua_pushnil(L);
-
- return 1;
-}
-
-static luaL_Reg mwedMeta[] =
-{
- { MT_MESSAGEWINDOWEVENTDATA, 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);
+ MT<MessageWindowEventData>(L, "MessageWindowEventData")
+ .Field(&MessageWindowEventData::szModule, "Module", LUA_TSTRINGA)
+ .Field(&MessageWindowEventData::uType, "Type", LUA_TINTEGER)
+ .Field(&MessageWindowEventData::hContact, "hContact", LUA_TINTEGER)
+ .Field(&MessageWindowEventData::uFlags, "Flags", LUA_TINTEGER);
lua_pop(L, 1);
return 1;
diff --git a/plugins/MirLua/src/m_msg_buttonsbar.cpp b/plugins/MirLua/src/m_msg_buttonsbar.cpp index 662441a4ad..a798c076c8 100644 --- a/plugins/MirLua/src/m_msg_buttonsbar.cpp +++ b/plugins/MirLua/src/m_msg_buttonsbar.cpp @@ -212,51 +212,6 @@ static luaL_Reg msgbuttinsbarApi[] = { NULL, NULL }
};
-/*#define MT_CUSTOMBUTTONCLICKDATA "CustomButtonClickData"
-
-static int bcd__init(lua_State *L)
-{
- CustomButtonClickData *udata = (CustomButtonClickData*)lua_touserdata(L, 1);
- if (udata == NULL)
- {
- lua_pushnil(L);
- return 1;
- }
-
- CustomButtonClickData **bcd = (CustomButtonClickData**)lua_newuserdata(L, sizeof(CustomButtonClickData*));
- *bcd = udata;
-
- luaL_setmetatable(L, MT_CUSTOMBUTTONCLICKDATA);
-
- return 1;
-}
-
-static int bcd__index(lua_State *L)
-{
- CustomButtonClickData *bcd = *(CustomButtonClickData**)luaL_checkudata(L, 1, MT_CUSTOMBUTTONCLICKDATA);
- const char *key = lua_tostring(L, 2);
-
- if (mir_strcmpi(key, "Module") == 0)
- lua_pushstring(L, ptrA(mir_utf8encode(bcd->pszModule)));
- else if (mir_strcmpi(key, "ButtonID") == 0)
- lua_pushinteger(L, bcd->dwButtonId);
- else if (mir_strcmpi(key, "hContact") == 0)
- lua_pushinteger(L, bcd->hContact);
- else if (mir_strcmpi(key, "Flags") == 0)
- lua_pushinteger(L, bcd->flags);
- else
- lua_pushnil(L);
-
- return 1;
-}
-
-static luaL_Reg bcdMeta[] =
-{
- { MT_CUSTOMBUTTONCLICKDATA, bcd__init },
- { "__index", bcd__index },
- { NULL, NULL }
-};*/
-
LUAMOD_API int luaopen_m_msg_buttonsbar(lua_State *L)
{
luaL_newlib(L, msgbuttinsbarApi);
@@ -268,9 +223,5 @@ LUAMOD_API int luaopen_m_msg_buttonsbar(lua_State *L) .Field(&CustomButtonClickData::flags, "Flags", LUA_TINTEGER);
lua_pop(L, 1);
- /*luaL_newmetatable(L, MT_CUSTOMBUTTONCLICKDATA);
- luaL_setfuncs(L, bcdMeta, 0);
- lua_pop(L, 1);*/
-
return 1;
}
diff --git a/plugins/MirLua/src/m_protocols.cpp b/plugins/MirLua/src/m_protocols.cpp index dc5fa97839..987f72a571 100644 --- a/plugins/MirLua/src/m_protocols.cpp +++ b/plugins/MirLua/src/m_protocols.cpp @@ -325,147 +325,6 @@ static luaL_Reg protocolsApi[] = { NULL, NULL }
};
-#define MT_PROTOCOLDESCRIPTOR "PROTOCOLDESCRIPTOR"
-
-static int pd__init(lua_State *L)
-{
- PROTOCOLDESCRIPTOR *udata = (PROTOCOLDESCRIPTOR*)lua_touserdata(L, 1);
- if (udata == NULL)
- {
- lua_pushnil(L);
- return 1;
- }
-
- PROTOCOLDESCRIPTOR **pd = (PROTOCOLDESCRIPTOR**)lua_newuserdata(L, sizeof(PROTOCOLDESCRIPTOR*));
- *pd = udata;
-
- luaL_setmetatable(L, MT_PROTOCOLDESCRIPTOR);
-
- return 1;
-}
-
-static int pd__index(lua_State *L)
-{
- PROTOCOLDESCRIPTOR *pd = *(PROTOCOLDESCRIPTOR**)luaL_checkudata(L, 1, MT_PROTOCOLDESCRIPTOR);
- const char *key = lua_tostring(L, 2);
-
- if (mir_strcmpi(key, "Name") == 0)
- lua_pushstring(L, ptrA(mir_utf8encode(pd->szName)));
- else if (mir_strcmpi(key, "Type") == 0)
- lua_pushinteger(L, pd->type);
- else
- lua_pushnil(L);
-
- return 1;
-}
-
-static luaL_Reg pdMeta[] =
-{
- { MT_PROTOCOLDESCRIPTOR, pd__init },
- { "__index", pd__index },
- { NULL, NULL }
-};
-
-#define MT_PROTOACCOUNT "PROTOACCOUNT"
-
-static int pa__init(lua_State *L)
-{
- PROTOACCOUNT *udata = (PROTOACCOUNT*)lua_touserdata(L, 1);
- if (udata == NULL)
- {
- lua_pushnil(L);
- return 1;
- }
-
- PROTOACCOUNT **pa = (PROTOACCOUNT**)lua_newuserdata(L, sizeof(PROTOACCOUNT*));
- *pa = udata;
-
- luaL_setmetatable(L, MT_PROTOACCOUNT);
-
- return 1;
-}
-
-static int pa__index(lua_State *L)
-{
- PROTOACCOUNT *pa = *(PROTOACCOUNT**)luaL_checkudata(L, 1, MT_PROTOACCOUNT);
- const char *key = lua_tostring(L, 2);
-
- if (mir_strcmpi(key, "ModuleName") == 0)
- lua_pushstring(L, ptrA(mir_utf8encode(pa->szModuleName)));
- else if (mir_strcmpi(key, "AccountName") == 0)
- lua_pushstring(L, ptrA(mir_utf8encodeT(pa->tszAccountName)));
- else if (mir_strcmpi(key, "ProtoName") == 0)
- lua_pushstring(L, ptrA(mir_utf8encode(pa->szProtoName)));
- else if (mir_strcmpi(key, "IsEnabled") == 0)
- lua_pushboolean(L, pa->bIsEnabled);
- else if (mir_strcmpi(key, "IsVisible") == 0)
- lua_pushboolean(L, pa->bIsVisible);
- else if (mir_strcmpi(key, "IsVirtual") == 0)
- lua_pushboolean(L, pa->bIsVirtual);
- else if (mir_strcmpi(key, "IsOldProto") == 0)
- lua_pushboolean(L, pa->bOldProto);
- else
- lua_pushnil(L);
-
- return 1;
-}
-
-static luaL_Reg paMeta[] =
-{
- { MT_PROTOACCOUNT, pa__init },
- { "__index", pa__index },
- { NULL, NULL }
-};
-
-#define MT_ACKDATA "ACKDATA"
-
-static int ack__init(lua_State *L)
-{
- ACKDATA *udata = (ACKDATA*)lua_touserdata(L, 1);
- if (udata == NULL)
- {
- lua_pushnil(L);
- return 1;
- }
-
- ACKDATA **ack = (ACKDATA**)lua_newuserdata(L, sizeof(ACKDATA*));
- *ack = udata;
-
- luaL_setmetatable(L, MT_ACKDATA);
-
- return 1;
-}
-
-static int ack__index(lua_State *L)
-{
- ACKDATA *ack = *(ACKDATA**)luaL_checkudata(L, 1, MT_ACKDATA);
- const char *key = lua_tostring(L, 2);
-
- if (mir_strcmpi(key, "Module") == 0)
- lua_pushstring(L, ptrA(mir_utf8encode(ack->szModule)));
- else if (mir_strcmpi(key, "hContact") == 0)
- lua_pushinteger(L, ack->hContact);
- else if (mir_strcmpi(key, "Type") == 0)
- lua_pushinteger(L, ack->type);
- else if (mir_strcmpi(key, "Result") == 0)
- lua_pushinteger(L, ack->result);
- else if (mir_strcmpi(key, "hProcess") == 0)
- lua_pushlightuserdata(L, ack->hProcess);
- else if (mir_strcmpi(key, "lParam") == 0)
- lua_pushnumber(L, ack->lParam);
- else
- lua_pushnil(L);
-
- return 1;
-}
-
-static luaL_Reg ackMeta[] =
-{
- { MT_ACKDATA, ack__init },
- { "__index", ack__index },
- { NULL, NULL }
-};
-
#define MT_CCSDATA "CCSDATA"
static int ccs__init(lua_State *L)
@@ -480,7 +339,7 @@ static int ccs__init(lua_State *L) CCSDATA **ccs = (CCSDATA**)lua_newuserdata(L, sizeof(CCSDATA*));
*ccs = udata;
- luaL_setmetatable(L, MT_ACKDATA);
+ luaL_setmetatable(L, MT_CCSDATA);
return 1;
}
@@ -514,16 +373,28 @@ LUAMOD_API int luaopen_m_protocols(lua_State *L) {
luaL_newlib(L, protocolsApi);
- luaL_newmetatable(L, MT_PROTOCOLDESCRIPTOR);
- luaL_setfuncs(L, pdMeta, 0);
+ MT<PROTOCOLDESCRIPTOR>(L, "PROTOCOLDESCRIPTOR")
+ .Field(&PROTOCOLDESCRIPTOR::szName, "Name", LUA_TSTRINGA)
+ .Field(&PROTOCOLDESCRIPTOR::type, "Type", LUA_TINTEGER);
lua_pop(L, 1);
- luaL_newmetatable(L, MT_PROTOACCOUNT);
- luaL_setfuncs(L, paMeta, 0);
+ MT<PROTOACCOUNT>(L, "PROTOACCOUNT")
+ .Field(&PROTOACCOUNT::szModuleName, "ModuleName", LUA_TSTRINGA)
+ .Field(&PROTOACCOUNT::tszAccountName, "AccountName", LUA_TSTRINGW)
+ .Field(&PROTOACCOUNT::szProtoName, "ProtoName", LUA_TSTRINGA)
+ .Field(&PROTOACCOUNT::bIsEnabled, "IsEnabled", LUA_TBOOLEAN)
+ .Field(&PROTOACCOUNT::bIsVisible, "IsVisible", LUA_TBOOLEAN)
+ .Field(&PROTOACCOUNT::bIsVirtual, "IsVirtual", LUA_TBOOLEAN)
+ .Field(&PROTOACCOUNT::bOldProto, "IsOldProto", LUA_TBOOLEAN);
lua_pop(L, 1);
- luaL_newmetatable(L, MT_ACKDATA);
- luaL_setfuncs(L, ackMeta, 0);
+ MT<ACKDATA>(L, "ACKDATA")
+ .Field(&ACKDATA::szModule, "Module", LUA_TSTRINGA)
+ .Field(&ACKDATA::hContact, "hContact", LUA_TINTEGER)
+ .Field(&ACKDATA::type, "Type", LUA_TINTEGER)
+ .Field(&ACKDATA::result, "Result", LUA_TINTEGER)
+ .Field(&ACKDATA::hProcess, "hProcess", LUA_TLIGHTUSERDATA)
+ .Field(&ACKDATA::lParam, "lParam", LUA_TLIGHTUSERDATA);
lua_pop(L, 1);
luaL_newmetatable(L, MT_CCSDATA);
diff --git a/plugins/MirLua/src/mlua_metatable.h b/plugins/MirLua/src/mlua_metatable.h index 108cf50f1a..0d60cb278e 100644 --- a/plugins/MirLua/src/mlua_metatable.h +++ b/plugins/MirLua/src/mlua_metatable.h @@ -92,6 +92,9 @@ private: case LUA_TSTRINGW:
lua_pushstring(L, ptrA(mir_utf8encodeW(GetValue<wchar_t*>(obj, offset, size))));
break;
+ case LUA_TLIGHTUSERDATA:
+ lua_pushlightuserdata(L, GetValue<void*>(obj, offset, size));
+ break;
default:
lua_pushnil(L);
}
|