diff options
-rw-r--r-- | plugins/MirLua/src/m_clist.cpp | 10 | ||||
-rw-r--r-- | plugins/MirLua/src/m_core.cpp | 2 | ||||
-rw-r--r-- | plugins/MirLua/src/m_database.cpp | 56 | ||||
-rw-r--r-- | plugins/MirLua/src/m_msg_buttonsbar.cpp | 8 | ||||
-rw-r--r-- | plugins/MirLua/src/mlua_utils.cpp | 2 |
5 files changed, 43 insertions, 35 deletions
diff --git a/plugins/MirLua/src/m_clist.cpp b/plugins/MirLua/src/m_clist.cpp index a39534c0da..abb54357a6 100644 --- a/plugins/MirLua/src/m_clist.cpp +++ b/plugins/MirLua/src/m_clist.cpp @@ -4,14 +4,14 @@ static int clist_AddMainMenuItem(lua_State *L) {
HGENMENU res = NULL;
- if (lua_type(L, 1) == LUA_TSTRING)
+ if (lua_isstring(L, 1))
{
const char *name = luaL_checkstring(L, 1);
int position = lua_tointeger(L, 2);
HANDLE hIcon = (HANDLE)lua_touserdata(L, 3);
res = Menu_CreateRoot(MO_MAIN, ptrT(Utf8DecodeT(name)), position, hIcon);
}
- else if (lua_type(L, 1) == LUA_TTABLE)
+ else if (lua_istable(L, 1))
{
CMenuItem mi;
MakeMenuItem(L, mi);
@@ -27,14 +27,14 @@ static int clist_AddContactMenuItem(lua_State *L) {
HGENMENU res = NULL;
- if (lua_type(L, 1) == LUA_TSTRING)
+ if (lua_isstring(L, 1))
{
const char *name = luaL_checkstring(L, 1);
int position = lua_tointeger(L, 2);
HANDLE hIcon = (HANDLE)lua_touserdata(L, 3);
res = Menu_CreateRoot(MO_MAIN, ptrT(Utf8DecodeT(name)), position, hIcon);
}
- else if (lua_type(L, 1) == LUA_TTABLE)
+ else if (lua_istable(L, 1))
{
CMenuItem mi;
MakeMenuItem(L, mi);
@@ -49,7 +49,7 @@ static int clist_AddContactMenuItem(lua_State *L) static int clist_AddTrayMenuItem(lua_State *L)
{
- if (lua_type(L, 1) != LUA_TTABLE)
+ if (lua_istable(L, 1) != LUA_TTABLE)
{
lua_pushlightuserdata(L, 0);
return 1;
diff --git a/plugins/MirLua/src/m_core.cpp b/plugins/MirLua/src/m_core.cpp index d75f0435a0..e2e34ea717 100644 --- a/plugins/MirLua/src/m_core.cpp +++ b/plugins/MirLua/src/m_core.cpp @@ -216,7 +216,7 @@ static int core_Utf8DecodeW(lua_State *L) static int core_Free(lua_State *L)
{
- if (lua_type(L, 1) == LUA_TLIGHTUSERDATA)
+ if (lua_islightuserdata(L, 1))
{
void *ptr = lua_touserdata(L, 1);
mir_free(ptr);
diff --git a/plugins/MirLua/src/m_database.cpp b/plugins/MirLua/src/m_database.cpp index 641ec1dc45..8539f32b6e 100644 --- a/plugins/MirLua/src/m_database.cpp +++ b/plugins/MirLua/src/m_database.cpp @@ -456,17 +456,6 @@ static int SettingsChangedHookEventObjParam(void *obj, WPARAM wParam, LPARAM lPa return res;
}
-static luaM_const consts[] =
-{
- { "DBVT_BYTE", DBVT_BYTE },
- { "DBVT_WORD", DBVT_WORD },
- { "DBVT_DWORD", DBVT_DWORD },
- { "DBVT_ASCIIZ", DBVT_ASCIIZ },
- { "DBVT_UTF8", DBVT_UTF8 },
- { "DBVT_WCHAR", DBVT_WCHAR },
- { NULL, NULL }
-};
-
static luaL_Reg databaseApi[] =
{
{ "FindFirstContact", lua_FindFirstContact },
@@ -490,6 +479,13 @@ static luaL_Reg databaseApi[] = { "DeleteSetting", lua_DeleteSetting },
{ "DeleteModule", lua_DeleteModule },
+ { "DBVT_BYTE", NULL },
+ { "DBVT_WORD", NULL },
+ { "DBVT_DWORD", NULL },
+ { "DBVT_ASCIIZ", NULL },
+ { "DBVT_UTF8", NULL },
+ { "DBVT_WCHAR", NULL },
+
{ NULL, NULL }
};
@@ -585,9 +581,9 @@ static int ci__index(lua_State *L) {
CONTACTINFO *ci = (CONTACTINFO*)luaL_checkudata(L, 1, MT_CONTACTINFO);
- if (lua_type(L, 2) == LUA_TNUMBER)
+ if (lua_isnumber(L, 2))
ci->dwFlag = lua_tointeger(L, 2);
- else if (lua_type(L, 2) == LUA_TSTRING)
+ else if (lua_isstring(L, 2))
{
const char *key = luaL_checkstring(L, 2);
@@ -672,25 +668,37 @@ static int ci__index(lua_State *L) LUAMOD_API int luaopen_m_database(lua_State *L)
{
luaL_newlib(L, databaseApi);
- luaM_loadConsts(L, consts);
+
+ lua_pushnumber(L, DBVT_BYTE);
+ lua_setfield(L, -2, "DBVT_BYTE");
+ lua_pushnumber(L, DBVT_WORD);
+ lua_setfield(L, -2, "DBVT_WORD");
+ lua_pushnumber(L, DBVT_DWORD);
+ lua_setfield(L, -2, "DBVT_DWORD");
+ lua_pushnumber(L, DBVT_ASCIIZ);
+ lua_setfield(L, -2, "DBVT_ASCIIZ");
+ lua_pushnumber(L, DBVT_UTF8);
+ lua_setfield(L, -2, "DBVT_UTF8");
+ lua_pushnumber(L, DBVT_WCHAR);
+ lua_setfield(L, -2, "DBVT_WCHAR");
+
MT<DBCONTACTWRITESETTING>(L, MT_DBCONTACTWRITESETTING)
- //.Field(LFUNC(DBCONTACTWRITESETTING, [](DBCONTACTWRITESETTING *p) { return p->szModule; }), "Module", LUA_TSTRINGA)
- //.Field(LFUNC(DBCONTACTWRITESETTING, [](DBCONTACTWRITESETTING *p) { return p->szSetting; }), "Setting", LUA_TSTRINGA)
+ .Field(&DBCONTACTWRITESETTING::szModule, "Module", LUA_TSTRINGA)
+ .Field(&DBCONTACTWRITESETTING::szSetting, "Setting", LUA_TSTRINGA)
.Method(dbcw__index, "__index");
lua_pop(L, 1);
MT<DBEVENTINFO>(L, MT_DBEVENTINFO)
- .Field(LFUNC(DBEVENTINFO, [](DBEVENTINFO* p) { return p->szModule; }), "Module", LUA_TSTRINGA)
- .Field(LFUNC(DBEVENTINFO, [](DBEVENTINFO* p) { return (void*)p->timestamp; }), "Timestamp", LUA_TINTEGER)
- .Field(LFUNC(DBEVENTINFO, [](DBEVENTINFO* p) { return (void*)p->eventType; }), "Type", LUA_TINTEGER)
- .Field(LFUNC(DBEVENTINFO, [](DBEVENTINFO* p) { return (void*)p->flags; }), "Flags", LUA_TINTEGER)
- .Field(LFUNC(DBEVENTINFO, [](DBEVENTINFO* p) { return (void*)p->cbBlob; }), "Length", LUA_TINTEGER)
- .Field(LFUNC(DBEVENTINFO, [](DBEVENTINFO* p) { return p->pBlob; }), "Blob", LUA_TLIGHTUSERDATA);
-
+ .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);
MT<CONTACTINFO>(L, "CONTACTINFO")
- .Field(LFUNC(CONTACTINFO, [](CONTACTINFO* p) { return (void*)p->hContact; }), "hContact", LUA_TINTEGER)
+ .Field(&CONTACTINFO::hContact, "hContact", LUA_TINTEGER)
.Method(ci__index, "__index");
lua_pop(L, 1);
diff --git a/plugins/MirLua/src/m_msg_buttonsbar.cpp b/plugins/MirLua/src/m_msg_buttonsbar.cpp index 9ba12aef48..39fff188a1 100644 --- a/plugins/MirLua/src/m_msg_buttonsbar.cpp +++ b/plugins/MirLua/src/m_msg_buttonsbar.cpp @@ -133,10 +133,10 @@ LUAMOD_API int luaopen_m_msg_buttonsbar(lua_State *L) luaL_newlib(L, msgbuttinsbarApi);
MT<CustomButtonClickData>(L, "CustomButtonClickData")
- .Field(LFUNC(CustomButtonClickData, [](CustomButtonClickData *p) { return p->pszModule; }), "Module", LUA_TSTRINGA)
- .Field(LFUNC(CustomButtonClickData, [](CustomButtonClickData *p) { return (void*)p->dwButtonId; }), "ButtonID", LUA_TINTEGER)
- .Field(LFUNC(CustomButtonClickData, [](CustomButtonClickData *p) { return (void*)p->hContact; }), "hContact", LUA_TINTEGER)
- .Field(LFUNC(CustomButtonClickData, [](CustomButtonClickData *p) { return (void*)p->flags; }), "Flags", LUA_TINTEGER);
+ .Field(&CustomButtonClickData::pszModule, "Module", LUA_TSTRINGA)
+ .Field(&CustomButtonClickData::dwButtonId, "ButtonID", LUA_TINTEGER)
+ .Field(&CustomButtonClickData::hContact, "hContact", LUA_TINTEGER)
+ .Field(&CustomButtonClickData::flags, "Flags", LUA_TINTEGER);
lua_pop(L, 1);
return 1;
diff --git a/plugins/MirLua/src/mlua_utils.cpp b/plugins/MirLua/src/mlua_utils.cpp index d0c89090b3..49078c9563 100644 --- a/plugins/MirLua/src/mlua_utils.cpp +++ b/plugins/MirLua/src/mlua_utils.cpp @@ -116,7 +116,7 @@ int luaM_toucs2(lua_State *L) bool luaM_toboolean(lua_State *L, int idx)
{
- if (lua_type(L, idx) == LUA_TNUMBER)
+ if (lua_isnumber(L, idx))
return lua_tonumber(L, idx) > 0;
return lua_toboolean(L, idx) > 0;
}
|