diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2016-02-17 12:00:00 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2016-02-17 12:00:00 +0000 |
commit | 9990ff21f9acacc42015e43609bf26cfa2104bb1 (patch) | |
tree | e8838b6856a1544a9e4d36d469b1d2806cac66fb /plugins/MirLua | |
parent | 2c7da3b79ebbd1833d1edfdef52d14c2ef2547eb (diff) |
MirLua: fixed getting script eviroment
git-svn-id: http://svn.miranda-ng.org/main/trunk@16290 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua')
-rw-r--r-- | plugins/MirLua/src/mlua_script.cpp | 16 | ||||
-rw-r--r-- | plugins/MirLua/src/mlua_script.h | 6 |
2 files changed, 11 insertions, 11 deletions
diff --git a/plugins/MirLua/src/mlua_script.cpp b/plugins/MirLua/src/mlua_script.cpp index f9fb1ac6f3..9e3769cabe 100644 --- a/plugins/MirLua/src/mlua_script.cpp +++ b/plugins/MirLua/src/mlua_script.cpp @@ -26,16 +26,16 @@ CMLuaScript::~CMLuaScript() mir_free(moduleName);
}
-bool CMLuaScript::GetScriptEnviroment(lua_State *L, int n)
+bool CMLuaScript::GetScriptEnviroment(lua_State *L)
{
lua_Debug ar; - if (lua_getstack(L, 1, &ar) == 0 || lua_getinfo(L, "f", &ar) == 0 || lua_iscfunction(L, -1)) + if (lua_getstack(L, 1, &ar) == 0 || lua_getinfo(L, "Sf", &ar) == 0 || lua_iscfunction(L, -1)) { lua_pop(L, 1); return false;
}
- const char *env = lua_getupvalue(L, n, 1); + const char *env = lua_getupvalue(L, -1, 1); if (!env || mir_strcmp(env, "_ENV") != 0) { lua_pop(L, 1); @@ -45,9 +45,9 @@ bool CMLuaScript::GetScriptEnviroment(lua_State *L, int n) return true;
}
-CMLuaScript* CMLuaScript::GetScriptFromEnviroment(lua_State *L, int n)
+CMLuaScript* CMLuaScript::GetScriptFromEnviroment(lua_State *L)
{
- if (!GetScriptEnviroment(L, n)) + if (!GetScriptEnviroment(L)) return NULL; lua_getfield(L, -1, SCRIPT);
@@ -57,9 +57,9 @@ CMLuaScript* CMLuaScript::GetScriptFromEnviroment(lua_State *L, int n) return script;
}
-int CMLuaScript::GetScriptIdFromEnviroment(lua_State *L, int n)
+int CMLuaScript::GetScriptIdFromEnviroment(lua_State *L)
{
- CMLuaScript *script = GetScriptFromEnviroment(L, n);
+ CMLuaScript *script = GetScriptFromEnviroment(L);
if (script != NULL)
return script->id;
@@ -105,7 +105,7 @@ bool CMLuaScript::Load() lua_getglobal(L, "_G");
lua_setfield(L, -2, "__index");
lua_setmetatable(L, -2);
- lua_setupvalue(L, -2, 1);
+ const char *env = lua_setupvalue(L, -2, 1);
if (luaM_pcall(L, 0, 1))
return false;
diff --git a/plugins/MirLua/src/mlua_script.h b/plugins/MirLua/src/mlua_script.h index 68b382921e..78fa34bf5b 100644 --- a/plugins/MirLua/src/mlua_script.h +++ b/plugins/MirLua/src/mlua_script.h @@ -24,9 +24,9 @@ public: CMLuaScript(lua_State *L, const TCHAR *path);
~CMLuaScript();
- static bool GetScriptEnviroment(lua_State *L, int n = 1);
- static CMLuaScript* GetScriptFromEnviroment(lua_State *L, int n = 1);
- static int GetScriptIdFromEnviroment(lua_State *L, int n = 1);
+ static bool GetScriptEnviroment(lua_State *L);
+ static CMLuaScript* GetScriptFromEnviroment(lua_State *L);
+ static int GetScriptIdFromEnviroment(lua_State *L);
const char* GetModuleName() const;
|