From e8e12b11db220160eb63727fb03548410bf3afd2 Mon Sep 17 00:00:00 2001 From: chai Date: Sun, 25 Nov 2018 00:11:28 +0800 Subject: *misc --- src/lua/common/je_lua.h | 2 ++ src/lua/common/je_lua_reference.cpp | 2 ++ src/lua/common/je_lua_shared.cpp | 4 ++-- src/lua/common/je_lua_shared.hpp | 11 ++++++----- 4 files changed, 12 insertions(+), 7 deletions(-) (limited to 'src/lua/common') diff --git a/src/lua/common/je_lua.h b/src/lua/common/je_lua.h index b6fc878..66647aa 100644 --- a/src/lua/common/je_lua.h +++ b/src/lua/common/je_lua.h @@ -15,6 +15,8 @@ namespace JinEngine namespace Lua { + // Extends luax.h library. + /// /// /// diff --git a/src/lua/common/je_lua_reference.cpp b/src/lua/common/je_lua_reference.cpp index 37ed441..72c1c3e 100644 --- a/src/lua/common/je_lua_reference.cpp +++ b/src/lua/common/je_lua_reference.cpp @@ -10,7 +10,9 @@ namespace JinEngine LuaRef::LuaRef(lua_State* L, int i) : mL(L) { + // Get value. luax_pushvalue(mL, i); + // Set reference. luax_getreferencestable(L); luax_pushvalue(mL, -2); mIndex = luax_ref(mL, -2); diff --git a/src/lua/common/je_lua_shared.cpp b/src/lua/common/je_lua_shared.cpp index 55832fd..acf1494 100644 --- a/src/lua/common/je_lua_shared.cpp +++ b/src/lua/common/je_lua_shared.cpp @@ -36,7 +36,7 @@ namespace JinEngine { if (!isDependOn(key)) return; - std::map::iterator it = mDependencies.find(key); + DepsMap::iterator it = mDependencies.find(key); SharedBase* dep = it->second; // Remove lua reference. luax_removereference(mL, this, dep); @@ -46,7 +46,7 @@ namespace JinEngine void SharedBase::removeDependency(SharedBase* dependency) { - for (std::map::iterator it = mDependencies.begin(); it != mDependencies.end();) + for (DepsMap::iterator it = mDependencies.begin(); it != mDependencies.end();) { SharedBase* dep = it->second; if (dep == dependency) diff --git a/src/lua/common/je_lua_shared.hpp b/src/lua/common/je_lua_shared.hpp index 2f1e18b..579a38e 100644 --- a/src/lua/common/je_lua_shared.hpp +++ b/src/lua/common/je_lua_shared.hpp @@ -1,8 +1,6 @@ #ifndef __JIN_COMMON_SHARED_H__ #define __JIN_COMMON_SHARED_H__ -//#include "je_lua.h" - #include #include #include @@ -59,10 +57,13 @@ namespace JinEngine clearDependencies(); } - void* mObject; - int mCount; + using DepsMap = std::map; + + void* mObject; + int mCount; lua_State* mL; - std::map mDependencies; + DepsMap mDependencies; + }; template -- cgit v1.1-26-g67d0