From bd96cfeb51b4c2a9a08298f83eb282eadd5e4c99 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sun, 14 Aug 2016 02:54:47 +0000 Subject: [PATCH] =?UTF-8?q?Add=20LuaLoader::Find()=20helper=20to=20find=20?= =?UTF-8?q?the=20state=E2=80=99s=20loader.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lolua/baselua.cpp | 9 +++++++++ src/lolua/baselua.h | 1 + 2 files changed, 10 insertions(+) diff --git a/src/lolua/baselua.cpp b/src/lolua/baselua.cpp index 33545745..223959d5 100644 --- a/src/lolua/baselua.cpp +++ b/src/lolua/baselua.cpp @@ -133,6 +133,15 @@ void Loader::Release(LuaState* l, Lolua::Loader* loader) } } +Lolua::Loader *LuaLoader::Find(LuaState* l) +{ + for (int i = 0; i < g_loaders.count(); ++i) + if (g_loaders[i].m1 == l) + return g_loaders[i].m2; + + return nullptr; +} + //Store lua object -------------------------------------------------------- void Loader::StoreObject(LuaState* l, Object* obj) { diff --git a/src/lolua/baselua.h b/src/lolua/baselua.h index 1ba7210d..ff8b2bf5 100644 --- a/src/lolua/baselua.h +++ b/src/lolua/baselua.h @@ -995,6 +995,7 @@ public: protected: LuaState* GetLuaState(); static void Store(LuaState* l, Loader* loader); + static Loader *Find(LuaState* l); static void Release(LuaState* l, Loader* loader); static void StoreObject(LuaState* l, Object* obj); //Virtual Store lua object ------------------------------------------------