diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2016-04-04 09:44:12 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2016-04-04 09:44:12 +0000 |
commit | 32089106fa10eba08e946693cb2939a4ab293f77 (patch) | |
tree | 102d714e16eb4d5c8da2a6a34d497ad10724c35f /plugins/MirLua | |
parent | e1110157f8c2989a58aa12ddeef91669525d188f (diff) |
MirLua:
- no need to copy pointer data in MT
- project cleanup
- version bump
git-svn-id: http://svn.miranda-ng.org/main/trunk@16584 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua')
-rw-r--r-- | plugins/MirLua/Modules/m_toptoolbar/src/main.cpp | 2 | ||||
-rw-r--r-- | plugins/MirLua/Modules/m_toptoolbar/src/stdafx.h | 5 | ||||
-rw-r--r-- | plugins/MirLua/src/m_database.cpp | 87 | ||||
-rw-r--r-- | plugins/MirLua/src/m_message.cpp | 8 | ||||
-rw-r--r-- | plugins/MirLua/src/m_schedule.cpp | 21 | ||||
-rw-r--r-- | plugins/MirLua/src/m_sounds.cpp | 12 | ||||
-rw-r--r-- | plugins/MirLua/src/mlua.cpp | 6 | ||||
-rw-r--r-- | plugins/MirLua/src/mlua_metatable.h | 29 | ||||
-rw-r--r-- | plugins/MirLua/src/mlua_module_loader.cpp | 12 | ||||
-rw-r--r-- | plugins/MirLua/src/mlua_module_loader.h | 4 | ||||
-rw-r--r-- | plugins/MirLua/src/mlua_options.cpp | 28 | ||||
-rw-r--r-- | plugins/MirLua/src/mlua_script.cpp | 9 | ||||
-rw-r--r-- | plugins/MirLua/src/mlua_script.h | 1 | ||||
-rw-r--r-- | plugins/MirLua/src/mlua_script_loader.cpp | 10 | ||||
-rw-r--r-- | plugins/MirLua/src/mlua_script_loader.h | 4 | ||||
-rw-r--r-- | plugins/MirLua/src/mlua_utils.cpp | 20 | ||||
-rw-r--r-- | plugins/MirLua/src/stdafx.h | 1 | ||||
-rw-r--r-- | plugins/MirLua/src/version.h | 6 |
18 files changed, 121 insertions, 144 deletions
diff --git a/plugins/MirLua/Modules/m_toptoolbar/src/main.cpp b/plugins/MirLua/Modules/m_toptoolbar/src/main.cpp index 6e488ca8c7..477cf7565b 100644 --- a/plugins/MirLua/Modules/m_toptoolbar/src/main.cpp +++ b/plugins/MirLua/Modules/m_toptoolbar/src/main.cpp @@ -95,7 +95,7 @@ static luaL_Reg toptoolbarApi[] = { NULL, NULL }
};
-LUAMOD_API int luaopen_m_toptoolbar(lua_State *L)
+extern "C" LUAMOD_API int luaopen_m_toptoolbar(lua_State *L)
{
luaL_newlib(L, toptoolbarApi);
diff --git a/plugins/MirLua/Modules/m_toptoolbar/src/stdafx.h b/plugins/MirLua/Modules/m_toptoolbar/src/stdafx.h index b45173f207..741eb49bd9 100644 --- a/plugins/MirLua/Modules/m_toptoolbar/src/stdafx.h +++ b/plugins/MirLua/Modules/m_toptoolbar/src/stdafx.h @@ -8,9 +8,4 @@ #include <m_utils.h>
#include <m_toptoolbar.h>
-#define MLUA_TOPTOOLBAR "m_toptoolbar"
-LUAMOD_API int (luaopen_m_toptoolbar)(lua_State *L);
-
-void KillModuleTTBButton();
-
#endif //_COMMON_H_
\ No newline at end of file diff --git a/plugins/MirLua/src/m_database.cpp b/plugins/MirLua/src/m_database.cpp index 5ee3c10ca0..246d96e9f6 100644 --- a/plugins/MirLua/src/m_database.cpp +++ b/plugins/MirLua/src/m_database.cpp @@ -1,6 +1,6 @@ #include "stdafx.h"
-static int lua_FindFirstContact(lua_State *L)
+static int db_FindFirstContact(lua_State *L)
{
const char *szProto = lua_tostring(L, 1);
@@ -10,7 +10,7 @@ static int lua_FindFirstContact(lua_State *L) return 1;
}
-static int lua_FindNextContact(lua_State *L)
+static int db_FindNextContact(lua_State *L)
{
MCONTACT hContact = luaL_checkinteger(L, 1);
const char *szProto = lua_tostring(L, 2);
@@ -21,7 +21,7 @@ static int lua_FindNextContact(lua_State *L) return 1;
}
-static int lua_ContactIterator(lua_State *L)
+static int db_ContactIterator(lua_State *L)
{
MCONTACT hContact = lua_tointeger(L, lua_upvalueindex(1));
const char *szProto = lua_tostring(L, lua_upvalueindex(2));
@@ -42,20 +42,20 @@ static int lua_ContactIterator(lua_State *L) return 1;
}
-static int lua_Contacts(lua_State *L)
+static int db_Contacts(lua_State *L)
{
const char *szProto = lua_tostring(L, 1);
lua_pushinteger(L, 0);
lua_pushstring(L, szProto);
- lua_pushcclosure(L, lua_ContactIterator, 2);
+ lua_pushcclosure(L, db_ContactIterator, 2);
return 1;
}
/***********************************************/
-static int lua_GetEventCount(lua_State *L)
+static int db_GetEventCount(lua_State *L)
{
MCONTACT hContact = luaL_checkinteger(L, 1);
@@ -65,7 +65,7 @@ static int lua_GetEventCount(lua_State *L) return 1;
}
-static int lua_GetFirstEvent(lua_State *L)
+static int db_GetFirstEvent(lua_State *L)
{
MCONTACT hContact = luaL_checkinteger(L, 1);
@@ -75,7 +75,7 @@ static int lua_GetFirstEvent(lua_State *L) return 1;
}
-static int lua_GetPrevEvent(lua_State *L)
+static int db_GetPrevEvent(lua_State *L)
{
MCONTACT hContact = luaL_checkinteger(L, 1);
MEVENT hDbEvent = luaL_checkinteger(L, 2);
@@ -86,7 +86,7 @@ static int lua_GetPrevEvent(lua_State *L) return 1;
}
-static int lua_GetNextEvent(lua_State *L)
+static int db_GetNextEvent(lua_State *L)
{
MCONTACT hContact = luaL_checkinteger(L, 1);
MEVENT hDbEvent = luaL_checkinteger(L, 2);
@@ -97,7 +97,7 @@ static int lua_GetNextEvent(lua_State *L) return 1;
}
-static int lua_GetLastEvent(lua_State *L)
+static int db_GetLastEvent(lua_State *L)
{
MCONTACT hContact = luaL_checkinteger(L, 1);
@@ -107,7 +107,7 @@ static int lua_GetLastEvent(lua_State *L) return 1;
}
-static int lua_EventIterator(lua_State *L)
+static int db_EventIterator(lua_State *L)
{
MCONTACT hContact = luaL_checkinteger(L, lua_upvalueindex(1));
MEVENT hDbEvent = luaL_checkinteger(L, lua_upvalueindex(2));
@@ -128,18 +128,18 @@ static int lua_EventIterator(lua_State *L) return 1;
}
-static int lua_Events(lua_State *L)
+static int db_Events(lua_State *L)
{
MCONTACT hContact = luaL_checkinteger(L, 1);
lua_pushinteger(L, hContact);
lua_pushinteger(L, NULL);
- lua_pushcclosure(L, lua_EventIterator, 2);
+ lua_pushcclosure(L, db_EventIterator, 2);
return 1;
}
-static int lua_EventReverseIterator(lua_State *L)
+static int db_EventReverseIterator(lua_State *L)
{
MCONTACT hContact = luaL_checkinteger(L, lua_upvalueindex(1));
MEVENT hDbEvent = luaL_checkinteger(L, lua_upvalueindex(2));
@@ -160,13 +160,13 @@ static int lua_EventReverseIterator(lua_State *L) return 1;
}
-static int lua_EventsFromEnd(lua_State *L)
+static int db_EventsFromEnd(lua_State *L)
{
MCONTACT hContact = luaL_checkinteger(L, 1);
lua_pushinteger(L, hContact);
lua_pushinteger(L, NULL);
- lua_pushcclosure(L, lua_EventReverseIterator, 2);
+ lua_pushcclosure(L, db_EventReverseIterator, 2);
return 1;
}
@@ -175,7 +175,7 @@ static int lua_EventsFromEnd(lua_State *L) #define MT_BLOB "BLOB"
-static int array__call(lua_State *L)
+static int array_create(lua_State *L)
{
BYTE *data = (BYTE*)lua_touserdata(L, 1);
size_t size = luaL_checkinteger(L, 2);
@@ -241,7 +241,6 @@ static int array__gc(lua_State *L) static const struct luaL_Reg blobApi[] =
{
- { "__call", array__call },
{ "__index", array__index },
{ "__newindex", array__newindex },
{ "__len", array__len },
@@ -253,7 +252,7 @@ static const struct luaL_Reg blobApi[] = /***********************************************/
-static int lua_GetSetting(lua_State *L)
+static int db_GetSetting(lua_State *L)
{
MCONTACT hContact = lua_tointeger(L, 1);
LPCSTR szModule = luaL_checkstring(L, 2);
@@ -288,8 +287,7 @@ static int lua_GetSetting(lua_State *L) break;
case DBVT_BLOB:
{
- luaL_getmetatable(L, MT_BLOB);
- lua_getfield(L, -1, "__call");
+ lua_pushcfunction(L, array_create);
lua_pushlightuserdata(L, dbv.pbVal);
lua_pushnumber(L, dbv.cpbVal);
luaM_pcall(L, 2, 1);
@@ -326,7 +324,7 @@ static int SettingsEnumProc(const char* szSetting, LPARAM lParam) return 0;
}
-static int lua_SettingIterator(lua_State *L)
+static int db_SettingIterator(lua_State *L)
{
int i = lua_tointeger(L, lua_upvalueindex(1));
enumDBSettingsParam* param = (enumDBSettingsParam*)lua_touserdata(L, lua_upvalueindex(2));
@@ -348,7 +346,7 @@ static int lua_SettingIterator(lua_State *L) return 1;
}
-static int lua_Settings(lua_State *L)
+static int db_Settings(lua_State *L)
{
MCONTACT hContact = lua_tointeger(L, 1);
const char* szModule = luaL_checkstring(L, 2);
@@ -366,12 +364,12 @@ static int lua_Settings(lua_State *L) lua_pushinteger(L, 0);
lua_pushlightuserdata(L, param);
- lua_pushcclosure(L, lua_SettingIterator, 2);
+ lua_pushcclosure(L, db_SettingIterator, 2);
return 1;
}
-static int lua_WriteSetting(lua_State *L)
+static int db_WriteSetting(lua_State *L)
{
MCONTACT hContact = lua_tointeger(L, 1);
LPCSTR szModule = luaL_checkstring(L, 2);
@@ -443,7 +441,7 @@ static int lua_WriteSetting(lua_State *L) return 1;
}
-static int lua_DeleteSetting(lua_State *L)
+static int db_DeleteSetting(lua_State *L)
{
MCONTACT hContact = lua_tointeger(L, 1);
LPCSTR szModule = luaL_checkstring(L, 2);
@@ -455,7 +453,7 @@ static int lua_DeleteSetting(lua_State *L) return 1;
}
-static int lua_DeleteModule(lua_State *L)
+static int db_DeleteModule(lua_State *L)
{
MCONTACT hContact = lua_tointeger(L, 1);
LPCSTR szModule = luaL_checkstring(L, 2);
@@ -470,27 +468,27 @@ static int lua_DeleteModule(lua_State *L) static luaL_Reg databaseApi[] =
{
- { "FindFirstContact", lua_FindFirstContact },
- { "FindNextContact", lua_FindNextContact },
- { "Contacts", lua_Contacts },
+ { "FindFirstContact", db_FindFirstContact },
+ { "FindNextContact", db_FindNextContact },
+ { "Contacts", db_Contacts },
- { "GetEventCount", lua_GetEventCount },
+ { "GetEventCount", db_GetEventCount },
- { "GetFirstEvent", lua_GetFirstEvent },
- { "GetPrevEvent", lua_GetPrevEvent },
- { "GetNextEvent", lua_GetNextEvent },
- { "GetLastEvent", lua_GetLastEvent },
- { "Events", lua_Events },
- { "EventsFromEnd", lua_EventsFromEnd },
+ { "GetFirstEvent", db_GetFirstEvent },
+ { "GetPrevEvent", db_GetPrevEvent },
+ { "GetNextEvent", db_GetNextEvent },
+ { "GetLastEvent", db_GetLastEvent },
+ { "Events", db_Events },
+ { "EventsFromEnd", db_EventsFromEnd },
- { "WriteSetting", lua_WriteSetting },
- { "SetSetting", lua_WriteSetting },
+ { "WriteSetting", db_WriteSetting },
+ { "SetSetting", db_WriteSetting },
- { "GetSetting", lua_GetSetting },
- { "Settings", lua_Settings },
+ { "GetSetting", db_GetSetting },
+ { "Settings", db_Settings },
- { "DeleteSetting", lua_DeleteSetting },
- { "DeleteModule", lua_DeleteModule },
+ { "DeleteSetting", db_DeleteSetting },
+ { "DeleteModule", db_DeleteModule },
{ "DBVT_BYTE", NULL },
{ "DBVT_WORD", NULL },
@@ -539,8 +537,7 @@ static int dbcw__index(lua_State *L) break;
case DBVT_BLOB:
{
- luaL_getmetatable(L, MT_BLOB);
- lua_getfield(L, -1, "__call");
+ lua_pushcfunction(L, array_create);
lua_pushlightuserdata(L, dbcw->value.pbVal);
lua_pushnumber(L, dbcw->value.cpbVal);
luaM_pcall(L, 2, 1);
diff --git a/plugins/MirLua/src/m_message.cpp b/plugins/MirLua/src/m_message.cpp index 64025eb132..63f86441ff 100644 --- a/plugins/MirLua/src/m_message.cpp +++ b/plugins/MirLua/src/m_message.cpp @@ -1,6 +1,6 @@ #include "stdafx.h"
-static int lua_Paste(lua_State *L)
+static int message_Paste(lua_State *L)
{
MCONTACT hContact = luaL_checkinteger(L, 1);
ptrT text(mir_utf8decodeT(luaL_checkstring(L, 2)));
@@ -24,7 +24,7 @@ static int lua_Paste(lua_State *L) return 1;
}
-static int lua_Send(lua_State *L)
+static int message_Send(lua_State *L)
{
MCONTACT hContact = luaL_checkinteger(L, 1);
const char *message = luaL_checkstring(L, 2);
@@ -70,8 +70,8 @@ static int lua_Send(lua_State *L) static luaL_Reg messageApi[] =
{
- { "Paste", lua_Paste },
- { "Send", lua_Send },
+ { "Paste", message_Paste },
+ { "Send", message_Send },
{ NULL, NULL }
};
diff --git a/plugins/MirLua/src/m_schedule.cpp b/plugins/MirLua/src/m_schedule.cpp index 45e961ee2f..3ee8b70663 100644 --- a/plugins/MirLua/src/m_schedule.cpp +++ b/plugins/MirLua/src/m_schedule.cpp @@ -12,8 +12,8 @@ struct ScheduleTask time_t interval;
lua_State *L;
- //int threadRef;
- //int callbackRef;
+ int threadRef;
+ int callbackRef;
};
static int TaskCompare(const ScheduleTask *p1, const ScheduleTask *p2)
@@ -25,12 +25,8 @@ static LIST<ScheduleTask> tasks(1, TaskCompare); void DestroyTask(ScheduleTask *task)
{
- //luaL_unref(task->L, LUA_REGISTRYINDEX, task->callbackRef);
- //luaL_unref(task->L, LUA_REGISTRYINDEX, task->threadRef);
- lua_pushnil(task->L);
- lua_rawsetp(task->L, LUA_REGISTRYINDEX, task->L);
- lua_pushnil(task->L);
- lua_rawsetp(task->L, LUA_REGISTRYINDEX, task);
+ luaL_unref(task->L, LUA_REGISTRYINDEX, task->callbackRef);
+ luaL_unref(task->L, LUA_REGISTRYINDEX, task->threadRef);
delete task;
}
@@ -38,8 +34,7 @@ void ExecuteTaskThread(void *arg) {
ScheduleTask *task = (ScheduleTask*)arg;
- //lua_rawgeti(task->L, LUA_REGISTRYINDEX, task->callbackRef);
- lua_rawgetp(task->L, LUA_REGISTRYINDEX, task->L);
+ lua_rawgeti(task->L, LUA_REGISTRYINDEX, task->callbackRef);
luaM_pcall(task->L, 0, 1);
void* res = lua_touserdata(task->L, -1);
@@ -161,11 +156,9 @@ static int fluent_Do(lua_State *L) task->timestamp = timestamp;
task->interval = interval;
task->L = lua_newthread(L);
- lua_rawsetp(L, LUA_REGISTRYINDEX, task);
- //task->threadRef = luaL_ref(L, LUA_REGISTRYINDEX);
+ task->threadRef = luaL_ref(L, LUA_REGISTRYINDEX);
lua_pushvalue(L, 1);
- //task->callbackRef = luaL_ref(L, LUA_REGISTRYINDEX);
- lua_rawsetp(L, LUA_REGISTRYINDEX, task->L);
+ task->callbackRef = luaL_ref(L, LUA_REGISTRYINDEX);
{
mir_cslock lock(threadLock);
tasks.insert(task);
diff --git a/plugins/MirLua/src/m_sounds.cpp b/plugins/MirLua/src/m_sounds.cpp index 3575ccf546..cd31adfe76 100644 --- a/plugins/MirLua/src/m_sounds.cpp +++ b/plugins/MirLua/src/m_sounds.cpp @@ -1,6 +1,6 @@ #include "stdafx.h"
-static int lua_AddSound(lua_State *L)
+static int sounds_AddSound(lua_State *L)
{
ptrA name(mir_utf8decodeA(luaL_checkstring(L, 1)));
ptrT description(mir_utf8decodeT(luaL_checkstring(L, 2)));
@@ -22,7 +22,7 @@ static int lua_AddSound(lua_State *L) return 1;
}
-static int lua_PlaySound(lua_State *L)
+static int sounds_PlaySound(lua_State *L)
{
const char *name = luaL_checkstring(L, 1);
@@ -32,7 +32,7 @@ static int lua_PlaySound(lua_State *L) return 1;
}
-static int lua_PlayFile(lua_State *L)
+static int sounds_PlayFile(lua_State *L)
{
ptrT filePath(mir_utf8decodeT(luaL_checkstring(L, 1)));
@@ -44,10 +44,10 @@ static int lua_PlayFile(lua_State *L) static luaL_Reg soundApi[] =
{
- { "AddSound", lua_AddSound },
- { "PlaySound", lua_PlaySound },
+ { "AddSound", sounds_AddSound },
+ { "PlaySound", sounds_PlaySound },
- { "PlayFile", lua_PlayFile },
+ { "PlayFile", sounds_PlayFile },
{ NULL, NULL }
};
diff --git a/plugins/MirLua/src/mlua.cpp b/plugins/MirLua/src/mlua.cpp index 8c0d99d689..fea62b2d93 100644 --- a/plugins/MirLua/src/mlua.cpp +++ b/plugins/MirLua/src/mlua.cpp @@ -50,13 +50,13 @@ void CMLua::Load() lua_register(L, "print", luaM_print);
lua_register(L, "a", luaM_toansi);
lua_register(L, "u", luaM_toucs2);
- lua_register(L, "totable", luaM_totable);
lua_atpanic(L, luaM_atpanic);
Log("Loading miranda modules");
- CLuaModuleLoader::Load(L);
- CLuaScriptLoader::Load(L);
+ CMLuaModuleLoader::Load(L);
+ Log("Loading scripts");
+ CMLuaScriptLoader::Load(L);
}
void CMLua::Unload()
diff --git a/plugins/MirLua/src/mlua_metatable.h b/plugins/MirLua/src/mlua_metatable.h index 5262b6f50c..b8fcdec22b 100644 --- a/plugins/MirLua/src/mlua_metatable.h +++ b/plugins/MirLua/src/mlua_metatable.h @@ -59,8 +59,9 @@ private: static void Init(lua_State *L, T **obj)
{
luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
- T *udata = (T*)lua_touserdata(L, 1);
- memcpy(*obj, udata, sizeof(T));
+ //T *udata = (T*)lua_touserdata(L, 1);
+ //memcpy(*obj, udata, sizeof(T));
+ *obj = (T*)lua_touserdata(L, 1);
}
static void Free(T **obj)
@@ -70,10 +71,10 @@ private: static int lua_new(lua_State *L)
{
- T *udata = (T*)lua_newuserdata(L, sizeof(T));
- memset(udata, 0, sizeof(T));
- Init(L, &udata);
- if (udata == NULL)
+ T **udata = (T**)lua_newuserdata(L, sizeof(T*));
+ //memset(udata, 0, sizeof(T));
+ Init(L, udata);
+ if (*udata == NULL)
{
lua_pushnil(L);
return 1;
@@ -83,9 +84,17 @@ private: return 1;
}
+ static int lua__call(lua_State *L)
+ {
+ T *obj = *(T**)luaL_checkudata(L, 1, MT::name);
+ lua_pushlightuserdata(L, obj);
+
+ return 1;
+ }
+
static int lua__index(lua_State *L)
{
- T *obj = (T*)luaL_checkudata(L, 1, MT::name);
+ T *obj = *(T**)luaL_checkudata(L, 1, MT::name);
const char *key = lua_tostring(L, 2);
auto it = fields.find(key);
@@ -129,8 +138,8 @@ private: static int lua__gc(lua_State *L)
{
- T *obj = (T*)luaL_checkudata(L, 1, MT::name);
- MT::Free(&obj);
+ T **obj = (T**)luaL_checkudata(L, 1, MT::name);
+ MT::Free(obj);
return 0;
}
@@ -144,6 +153,8 @@ public: luaL_newmetatable(L, MT::name);
lua_pushcfunction(L, lua__index);
lua_setfield(L, -2, "__index");
+ lua_pushcfunction(L, lua__call);
+ lua_setfield(L, -2, "__call");
lua_pushcfunction(L, lua__gc);
lua_setfield(L, -2, "__gc");
}
diff --git a/plugins/MirLua/src/mlua_module_loader.cpp b/plugins/MirLua/src/mlua_module_loader.cpp index fb54e33573..e0777ac136 100644 --- a/plugins/MirLua/src/mlua_module_loader.cpp +++ b/plugins/MirLua/src/mlua_module_loader.cpp @@ -1,10 +1,10 @@ #include "stdafx.h"
-CLuaModuleLoader::CLuaModuleLoader(lua_State *L) : L(L)
+CMLuaModuleLoader::CMLuaModuleLoader(lua_State *L) : L(L)
{
}
-void CLuaModuleLoader::Load(const char *name, lua_CFunction loader)
+void CMLuaModuleLoader::Load(const char *name, lua_CFunction loader)
{
luaL_getsubtable(L, LUA_REGISTRYINDEX, "_LOADED");
lua_pushcfunction(L, loader);
@@ -14,7 +14,7 @@ void CLuaModuleLoader::Load(const char *name, lua_CFunction loader) lua_pop(L, 1);
}
-void CLuaModuleLoader::Preload(const char *name, lua_CFunction loader)
+void CMLuaModuleLoader::Preload(const char *name, lua_CFunction loader)
{
luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD");
lua_pushcfunction(L, loader);
@@ -22,7 +22,7 @@ void CLuaModuleLoader::Preload(const char *name, lua_CFunction loader) lua_pop(L, 1);
}
-void CLuaModuleLoader::LoadModules()
+void CMLuaModuleLoader::LoadModules()
{
// load m_core module
Load(MLUA_CORE, luaopen_m_core);
@@ -39,8 +39,8 @@ void CLuaModuleLoader::LoadModules() Preload(MLUA_SOUNDS, luaopen_m_sounds);
}
-void CLuaModuleLoader::Load(lua_State *L)
+void CMLuaModuleLoader::Load(lua_State *L)
{
- CLuaModuleLoader loader(L);
+ CMLuaModuleLoader loader(L);
loader.LoadModules();
}
\ No newline at end of file diff --git a/plugins/MirLua/src/mlua_module_loader.h b/plugins/MirLua/src/mlua_module_loader.h index 6ce4e16bd8..123c05bf41 100644 --- a/plugins/MirLua/src/mlua_module_loader.h +++ b/plugins/MirLua/src/mlua_module_loader.h @@ -1,12 +1,12 @@ #ifndef _LUA_MODULE_LOADER_H_
#define _LUA_MODULE_LOADER_H_
-class CLuaModuleLoader
+class CMLuaModuleLoader
{
private:
lua_State *L;
- CLuaModuleLoader(lua_State *L);
+ CMLuaModuleLoader(lua_State *L);
void Load(const char *name, lua_CFunction loader);
void Preload(const char *name, lua_CFunction loader);
diff --git a/plugins/MirLua/src/mlua_options.cpp b/plugins/MirLua/src/mlua_options.cpp index e7f3ef729f..dce88057d6 100644 --- a/plugins/MirLua/src/mlua_options.cpp +++ b/plugins/MirLua/src/mlua_options.cpp @@ -42,19 +42,6 @@ void CMLuaOptions::CreateLink(CCtrlData& ctrl, const char *szSetting, TCHAR *szV ctrl.CreateDbLink(MODULE, szSetting, szValue);
}
-int CMLuaOptions::OnOptionsInit(WPARAM wParam, LPARAM)
-{
- OPTIONSDIALOGPAGE odp = { 0 };
- odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR | ODPF_DONTTRANSLATE;
- odp.ptszGroup = LPGENT("Services");
- odp.ptszTitle = _T(MODULE);
- odp.ptszTab = LPGENT("Scripts");
- odp.pDialog = CMLuaOptions::CreateOptionsPage();
- Options_AddPage(wParam, &odp);
-
- return 0;
-}
-
void CMLuaOptions::LoadScripts()
{
for (int i = 0; i < g_mLua->Scripts.getCount(); i++)
@@ -175,4 +162,19 @@ void CMLuaOptions::OnReload(CCtrlBase*) g_mLua->Load();
LoadScripts();
isScriptListInit = true;
+}
+
+/****************************************/
+
+int CMLuaOptions::OnOptionsInit(WPARAM wParam, LPARAM)
+{
+ OPTIONSDIALOGPAGE odp = { 0 };
+ odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR | ODPF_DONTTRANSLATE;
+ odp.ptszGroup = LPGENT("Services");
+ odp.ptszTitle = _T("Lua");
+ odp.ptszTab = LPGENT("Scripts");
+ odp.pDialog = CMLuaOptions::CreateOptionsPage();
+ Options_AddPage(wParam, &odp);
+
+ return 0;
}
\ No newline at end of file diff --git a/plugins/MirLua/src/mlua_script.cpp b/plugins/MirLua/src/mlua_script.cpp index 9a0d840c0c..ce635a36cf 100644 --- a/plugins/MirLua/src/mlua_script.cpp +++ b/plugins/MirLua/src/mlua_script.cpp @@ -140,8 +140,7 @@ bool CMLuaScript::Load() if (lua_isfunction(L, -1))
{
lua_pushvalue(L, -1);
- lua_rawsetp(L, LUA_REGISTRYINDEX, this);
- //unloadRef = luaL_ref(L, LUA_REGISTRYINDEX);
+ unloadRef = luaL_ref(L, LUA_REGISTRYINDEX);
}
lua_pop(L, 1);
@@ -154,8 +153,7 @@ void CMLuaScript::Unload() {
if (status == Loaded)
{
- lua_rawgetp(L, LUA_REGISTRYINDEX, this);
- //lua_rawgeti(L, LUA_REGISTRYINDEX, unloadRef);
+ lua_rawgeti(L, LUA_REGISTRYINDEX, unloadRef);
if (lua_isfunction(L, -1))
luaM_pcall(L);
lua_pushnil(L);
@@ -168,9 +166,6 @@ void CMLuaScript::Unload() lua_setfield(L, -2, moduleName);
lua_pop(L, 1);
- //lua_pushnil(L);
- //lua_setglobal(L, moduleName);
-
KillModuleIcons(id);
KillModuleSounds(id);
KillModuleMenus(id);
diff --git a/plugins/MirLua/src/mlua_script.h b/plugins/MirLua/src/mlua_script.h index 78fa34bf5b..8f03d5fcb0 100644 --- a/plugins/MirLua/src/mlua_script.h +++ b/plugins/MirLua/src/mlua_script.h @@ -15,6 +15,7 @@ public: private:
int id;
+ int unloadRef;
char *moduleName;
TCHAR *fileName;
TCHAR filePath[MAX_PATH];
diff --git a/plugins/MirLua/src/mlua_script_loader.cpp b/plugins/MirLua/src/mlua_script_loader.cpp index 13dc5bea99..ddecbad547 100644 --- a/plugins/MirLua/src/mlua_script_loader.cpp +++ b/plugins/MirLua/src/mlua_script_loader.cpp @@ -1,10 +1,10 @@ #include "stdafx.h"
-CLuaScriptLoader::CLuaScriptLoader(lua_State *L) : L(L)
+CMLuaScriptLoader::CMLuaScriptLoader(lua_State *L) : L(L)
{
}
-void CLuaScriptLoader::LoadScript(const TCHAR *scriptDir, const TCHAR *file)
+void CMLuaScriptLoader::LoadScript(const TCHAR *scriptDir, const TCHAR *file)
{
TCHAR fullPath[MAX_PATH], path[MAX_PATH];
mir_sntprintf(fullPath, _T("%s\\%s"), scriptDir, file);
@@ -23,7 +23,7 @@ void CLuaScriptLoader::LoadScript(const TCHAR *scriptDir, const TCHAR *file) Log(_T("%s:OK"), path);
}
-void CLuaScriptLoader::LoadScripts()
+void CMLuaScriptLoader::LoadScripts()
{
TCHAR scriptDir[MAX_PATH];
FoldersGetCustomPathT(g_hScriptsFolder, scriptDir, _countof(scriptDir), VARST(MIRLUA_PATHT));
@@ -47,7 +47,7 @@ void CLuaScriptLoader::LoadScripts() }
}
-void CLuaScriptLoader::Load(lua_State *L)
+void CMLuaScriptLoader::Load(lua_State *L)
{
- CLuaScriptLoader(L).LoadScripts();
+ CMLuaScriptLoader(L).LoadScripts();
}
\ No newline at end of file diff --git a/plugins/MirLua/src/mlua_script_loader.h b/plugins/MirLua/src/mlua_script_loader.h index e996fc1fdd..949f870fac 100644 --- a/plugins/MirLua/src/mlua_script_loader.h +++ b/plugins/MirLua/src/mlua_script_loader.h @@ -1,12 +1,12 @@ #ifndef _LUA_SCRIPT_LOADER_H_
#define _LUA_SCRIPT_LOADER_H_
-class CLuaScriptLoader
+class CMLuaScriptLoader
{
private:
lua_State *L;
- CLuaScriptLoader(lua_State *L);
+ CMLuaScriptLoader(lua_State *L);
void LoadScript(const TCHAR *scriptDir, const TCHAR *file);
void LoadScripts();
diff --git a/plugins/MirLua/src/mlua_utils.cpp b/plugins/MirLua/src/mlua_utils.cpp index 7bd46d4db2..7d4515bede 100644 --- a/plugins/MirLua/src/mlua_utils.cpp +++ b/plugins/MirLua/src/mlua_utils.cpp @@ -90,7 +90,7 @@ int luaM_print(lua_State *L) int luaM_toansi(lua_State *L)
{
- const char* value = luaL_checkstring(L, 1);
+ const char *value = luaL_checkstring(L, 1);
int codepage = luaL_optinteger(L, 2, Langpack_GetDefaultCodePage());
ptrA string(mir_strdup(value));
@@ -101,7 +101,7 @@ int luaM_toansi(lua_State *L) int luaM_toucs2(lua_State *L)
{
- const char* value = luaL_checkstring(L, 1);
+ const char *value = luaL_checkstring(L, 1);
ptrW unicode(mir_utf8decodeW(value));
size_t length = mir_wstrlen(unicode) * sizeof(wchar_t);
@@ -121,22 +121,6 @@ bool luaM_toboolean(lua_State *L, int idx) return lua_toboolean(L, idx) > 0;
}
-int luaM_totable(lua_State *L)
-{
- const char *tname = luaL_checkstring(L, 2);
-
- char message[256];
- mir_snprintf(message, "Use %s(...) instead", tname);
- ObsoleteMethod(L, message);
-
- luaL_getmetatable(L, tname);
- lua_getfield(L, -1, "__call");
- lua_pushvalue(L, 1);
- luaM_pcall(L, 1, 1);
-
- return 1;
-}
-
int luaM_ptr2number(lua_State *L)
{
luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
diff --git a/plugins/MirLua/src/stdafx.h b/plugins/MirLua/src/stdafx.h index 32e1d27506..a8a1ba4ff3 100644 --- a/plugins/MirLua/src/stdafx.h +++ b/plugins/MirLua/src/stdafx.h @@ -111,7 +111,6 @@ int luaM_print(lua_State *L); int luaM_toansi(lua_State *L);
int luaM_toucs2(lua_State *L);
int luaM_ptr2number(lua_State *L);
-int luaM_totable(lua_State *L);
bool luaM_toboolean(lua_State *L, int idx);
diff --git a/plugins/MirLua/src/version.h b/plugins/MirLua/src/version.h index 2c191f27f9..c410df9718 100644 --- a/plugins/MirLua/src/version.h +++ b/plugins/MirLua/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 11
-#define __RELEASE_NUM 6
-#define __BUILD_NUM 1
+#define __RELEASE_NUM 7
+#define __BUILD_NUM 0
#include <stdver.h>
@@ -11,4 +11,4 @@ #define __AUTHOR "Miranda NG team"
#define __AUTHOREMAIL ""
#define __AUTHORWEB "http://miranda-ng.org/p/MirLua/"
-#define __COPYRIGHT "© 2015-16 Miranda NG project"
+#define __COPYRIGHT "© 2015-16 Miranda NG project"
|