aboutsummaryrefslogtreecommitdiff
path: root/src/lua/common/je_lua_runtime.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-12-10 11:46:29 +0800
committerchai <chaifix@163.com>2018-12-10 11:46:29 +0800
commitce8e259441410aba3f2345333003032ed9c45d65 (patch)
treeb28b8a30e2b30081a2f9bdbf0a142099f7a8cd6f /src/lua/common/je_lua_runtime.cpp
parentb1dfdae7a071407ef5e2d56f2203f96e6ba6068d (diff)
*删除shared的lua类型信息
Diffstat (limited to 'src/lua/common/je_lua_runtime.cpp')
-rw-r--r--src/lua/common/je_lua_runtime.cpp42
1 files changed, 22 insertions, 20 deletions
diff --git a/src/lua/common/je_lua_runtime.cpp b/src/lua/common/je_lua_runtime.cpp
index d7069b8..fb665f1 100644
--- a/src/lua/common/je_lua_runtime.cpp
+++ b/src/lua/common/je_lua_runtime.cpp
@@ -23,6 +23,7 @@ namespace JinEngine
{
LuaObject* obj = static_cast<LuaObject*>(luax_newinstance(L, type, sizeof(LuaObject)));
obj->state = L;
+ obj->type = type;
obj->bind(shared);
// Add to objects_table, objects_table[shared] = luaObj
luax_getobjectstable(L);
@@ -46,10 +47,11 @@ namespace JinEngine
DepsMap& srcDeps = *src->dependencies;
for (DepsMap::iterator it = srcDeps.begin(); it != srcDeps.end(); ++it)
{
- Shared* shr = it->second;
+ LuaObject* obj = it->second;
+ Shared* shr = obj->shared;
// Try get lua object.
- luax_getobject(src->state, shr);
- LuaObject* luaObj = (LuaObject*)luax_checktype(src->state, -1, shr->getType());
+ luax_getobject(src->state, obj);
+ LuaObject* luaObj = (LuaObject*)luax_checktype(src->state, -1, obj->getObjectType());
luax_pop(src->state, 1); // Pop lua object.
luax_copyinstance(to, luaObj);
luax_pop(to, 1); // Pop reference object.
@@ -68,25 +70,25 @@ namespace JinEngine
DepsMap::iterator it = deps.begin();
for (; it != deps.end(); ++it)
{
- Shared* dep = it->second;
- luax_addreference(to, shr, dep);
+ LuaObject* dep = it->second;
+ luax_addreference(to, src, dep);
}
return obj;
}
- int luax_getobject(lua_State* L, Shared* shared)
+ int luax_getobject(lua_State* L, LuaObject* obj)
{
luax_getobjectstable(L);
- luax_pushlightuserdata(L, shared);
+ luax_pushlightuserdata(L, obj->shared);
luax_gettable(L, -2);
luax_remove(L, -2); // Remove objects table on stack.
return 1;
}
- void luax_removeobject(lua_State* L, Shared* shared)
+ void luax_removeobject(lua_State* L, LuaObject* obj)
{
luax_getobjectstable(L);
- luax_pushlightuserdata(L, shared);
+ luax_pushlightuserdata(L, obj->shared);
luax_pushnil(L);
luax_settable(L, -3);
luax_pop(L, 1);
@@ -152,29 +154,29 @@ namespace JinEngine
return 1;
}
- void luax_getreference(lua_State* L, Shared* shared)
+ void luax_getreference(lua_State* L, LuaObject* obj)
{
luax_getreferencestable(L);
- luax_pushlightuserdata(L, shared);
+ luax_pushlightuserdata(L, obj->shared);
luax_gettable(L, -2);
luax_remove(L, -2);
}
- bool luax_addreference(lua_State* L, Shared* shared, Shared* dep)
+ bool luax_addreference(lua_State* L, LuaObject* obj, LuaObject* dep)
{
- luax_getreference(L, shared);
+ luax_getreference(L, obj);
// If no dependencies table, add one.
if (luax_isnil(L, -1))
{
luax_pop(L, 1);
luax_getreferencestable(L);
luax_newtable(L);
- luax_pushlightuserdata(L, shared);
+ luax_pushlightuserdata(L, obj->shared);
luax_pushvalue(L, -2);
luax_settable(L, -4);
luax_remove(L, -2); // Remove references table.
}
- luax_pushlightuserdata(L, dep);
+ luax_pushlightuserdata(L, dep->shared);
luax_getobject(L, dep);
if (luax_isnil(L, -1))
{
@@ -186,24 +188,24 @@ namespace JinEngine
return true;
}
- void luax_removereference(lua_State* L, Shared* shared)
+ void luax_removereference(lua_State* L, LuaObject* obj)
{
luax_getreferencestable(L);
- luax_pushlightuserdata(L, shared);
+ luax_pushlightuserdata(L, obj->shared);
luax_pushnil(L);
luax_settable(L, -3);
luax_pop(L, 1);
}
- void luax_removereference(lua_State* L, Shared* shared, Shared* dep)
+ void luax_removereference(lua_State* L, LuaObject* obj, LuaObject* dep)
{
- luax_getreference(L, shared);
+ luax_getreference(L, obj);
if (luax_isnil(L, -1))
{
luax_pop(L, 1);
return;
}
- luax_pushlightuserdata(L, dep);
+ luax_pushlightuserdata(L, dep->shared);
luax_pushnil(L);
luax_settable(L, -3);
luax_pop(L, 1);