aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lua/common/je_lua.h12
-rw-r--r--src/lua/common/je_lua_object.cpp28
-rw-r--r--src/lua/common/je_lua_object.h12
-rw-r--r--src/lua/common/je_lua_runtime.cpp42
-rw-r--r--src/lua/common/je_lua_shared.hpp15
-rw-r--r--src/lua/modules/audio/je_lua_audio.cpp2
-rw-r--r--src/lua/modules/graphics/je_lua_animation.cpp8
-rw-r--r--src/lua/modules/graphics/je_lua_animator.cpp2
-rw-r--r--src/lua/modules/graphics/je_lua_bitmap.cpp2
-rw-r--r--src/lua/modules/graphics/je_lua_graphics.cpp52
-rw-r--r--src/lua/modules/graphics/je_lua_particle_system.cpp4
-rw-r--r--src/lua/modules/graphics/je_lua_spritesheet.cpp10
-rw-r--r--src/lua/modules/graphics/je_lua_texture_font.cpp4
-rw-r--r--src/lua/modules/graphics/je_lua_ttf.cpp4
-rw-r--r--src/lua/modules/graphics/je_lua_ttf_data.cpp4
-rw-r--r--src/lua/modules/net/je_lua_net.cpp4
-rw-r--r--src/lua/modules/net/je_lua_socket.cpp6
-rw-r--r--src/lua/modules/thread/je_lua_thread.cpp2
-rw-r--r--src/lua/modules/time/je_lua_time.cpp2
-rw-r--r--src/lua/modules/time/je_lua_timer.cpp7
20 files changed, 106 insertions, 116 deletions
diff --git a/src/lua/common/je_lua.h b/src/lua/common/je_lua.h
index cacec95..74f9819 100644
--- a/src/lua/common/je_lua.h
+++ b/src/lua/common/je_lua.h
@@ -35,32 +35,32 @@ namespace JinEngine
///
/// Access lua object by object pointer.
///
- int luax_getobject(lua_State* L, Shared* shared);
+ int luax_getobject(lua_State* L, LuaObject* obj);
///
/// Get object's reference table.
///
- void luax_getreference(lua_State* L, Shared* shared);
+ void luax_getreference(lua_State* L, LuaObject* obj);
///
///
///
- bool luax_addreference(lua_State* L, Shared* shared, Shared* dep);
+ bool luax_addreference(lua_State* L, LuaObject* obj, LuaObject* dep);
///
///
///
- void luax_removereference(lua_State* L, Shared* shared);
+ void luax_removereference(lua_State* L, LuaObject* obj);
///
///
///
- void luax_removereference(lua_State* L, Shared* shared, Shared* dep);
+ void luax_removereference(lua_State* L, LuaObject* obj, LuaObject* dep);
///
///
///
- void luax_removeobject(lua_State* L, Shared* shared);
+ void luax_removeobject(lua_State* L, LuaObject* obj);
///
///
diff --git a/src/lua/common/je_lua_object.cpp b/src/lua/common/je_lua_object.cpp
index 9aabeb5..c35356e 100644
--- a/src/lua/common/je_lua_object.cpp
+++ b/src/lua/common/je_lua_object.cpp
@@ -12,7 +12,7 @@ namespace JinEngine
{
shared = obj;
shared->retain();
- dependencies = new std::map<uint, Shared*>();
+ dependencies = new std::map<uint, LuaObject*>();
}
}
@@ -35,7 +35,7 @@ namespace JinEngine
const char* LuaObject::getObjectType()
{
- return shared->getType();
+ return type;
}
Shared* LuaObject::getShared()
@@ -43,11 +43,11 @@ namespace JinEngine
return shared;
}
- void LuaObject::setDependency(uint key, Shared* dep)
+ void LuaObject::setDependency(uint key, LuaObject* dep)
{
removeDependency(key);
- dependencies->insert(std::pair<uint, Shared*>(key, dep));
- luax_addreference(state, shared, dep);
+ dependencies->insert(std::pair<uint, LuaObject*>(key, dep));
+ luax_addreference(state, this, dep);
}
void LuaObject::removeDependency(uint key)
@@ -55,19 +55,19 @@ namespace JinEngine
if (!isDependOn(key))
return;
DepsMap::iterator it = dependencies->find(key);
- Shared* dep = it->second;
- luax_removereference(state, shared, dep);
+ LuaObject* dep = it->second;
+ luax_removereference(state, this, dep);
dependencies->erase(it);
}
- void LuaObject::removeDependency(Shared* dependency)
+ void LuaObject::removeDependency(LuaObject* dependency)
{
for (DepsMap::iterator it = dependencies->begin(); it != dependencies->end();)
{
- Shared* dep = it->second;
+ LuaObject* dep = it->second;
if (dep == dependency)
{
- luax_removereference(state, shared, dep);
+ luax_removereference(state, this, dep);
dependencies->erase(it);
}
else
@@ -80,9 +80,9 @@ namespace JinEngine
return dependencies->find(key) != dependencies->end();
}
- bool LuaObject::isDependOn(Shared* shared)
+ bool LuaObject::isDependOn(LuaObject* shared)
{
- for (std::pair<uint, Shared*> dep : (*dependencies))
+ for (std::pair<uint, LuaObject*> dep : (*dependencies))
{
if (dep.second == shared)
return true;
@@ -92,11 +92,11 @@ namespace JinEngine
void LuaObject::clearDependencies()
{
- luax_removereference(state, shared);
+ luax_removereference(state, this);
dependencies->clear();
}
- Shared* LuaObject::getDependency(uint key)
+ LuaObject* LuaObject::getDependency(uint key)
{
if (!isDependOn(key))
return nullptr;
diff --git a/src/lua/common/je_lua_object.h b/src/lua/common/je_lua_object.h
index a81f57c..6e86508 100644
--- a/src/lua/common/je_lua_object.h
+++ b/src/lua/common/je_lua_object.h
@@ -31,19 +31,19 @@ namespace JinEngine
return shared->getObject<T>();
}
- void setDependency(uint key, Shared* shared);
+ void setDependency(uint key, LuaObject* dep);
void removeDependency(uint key);
- void removeDependency(Shared* dep);
+ void removeDependency(LuaObject* dep);
bool isDependOn(uint key);
- bool isDependOn(Shared* shared);
+ bool isDependOn(LuaObject* shared);
void clearDependencies();
- Shared* getDependency(uint key);
+ LuaObject* getDependency(uint key);
int getDependenciesCount();
@@ -51,12 +51,14 @@ namespace JinEngine
// Lua state object.
//////////////////////////////////////////////////////////////////////////////////////////////////////
- using DepsMap = std::map<uint, Shared*>;
+ using DepsMap = std::map<uint, LuaObject*>;
lua_State* state;
Shared* shared;
+ const char* type;
+
DepsMap* dependencies;
};
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);
diff --git a/src/lua/common/je_lua_shared.hpp b/src/lua/common/je_lua_shared.hpp
index 55434c9..6a58ab3 100644
--- a/src/lua/common/je_lua_shared.hpp
+++ b/src/lua/common/je_lua_shared.hpp
@@ -20,10 +20,9 @@ namespace JinEngine
class Shared
{
public:
- Shared(Object* obj, const char* type)
+ Shared(Object* obj)
: mCount(0)
, mObject(obj)
- , mType(type)
{
}
@@ -37,16 +36,6 @@ namespace JinEngine
return static_cast<Object*>(mObject);
}
- inline const char* getType()
- {
- return mType;
- }
-
- inline bool isType(const char* t)
- {
- return strcmp(mType, t) == 0;
- }
-
template<class T>
inline T* getObject()
{
@@ -86,7 +75,7 @@ namespace JinEngine
Object* mObject;
int mCount;
- const char* mType;
+
};
} // namespace Lua
diff --git a/src/lua/modules/audio/je_lua_audio.cpp b/src/lua/modules/audio/je_lua_audio.cpp
index 22f0dba..7bfc206 100644
--- a/src/lua/modules/audio/je_lua_audio.cpp
+++ b/src/lua/modules/audio/je_lua_audio.cpp
@@ -98,7 +98,7 @@ namespace JinEngine
luax_pushnil(L);
return 1;
}
- LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Source, new Shared(src, Jin_Lua_Source));
+ LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Source, new Shared(src));
return 1;
}
diff --git a/src/lua/modules/graphics/je_lua_animation.cpp b/src/lua/modules/graphics/je_lua_animation.cpp
index 2bb635a..5cd3b1f 100644
--- a/src/lua/modules/graphics/je_lua_animation.cpp
+++ b/src/lua/modules/graphics/je_lua_animation.cpp
@@ -42,7 +42,7 @@ namespace JinEngine
Sprite* sprite = luaSprite->getObject<Sprite>();
animation->addFrame(sprite);
int i = animation->getFrameCount() - 1;
- luaObj->setDependency((int)AnimationDependency::DEP_SPRITES + i, luaSprite->getShared());
+ luaObj->setDependency((int)AnimationDependency::DEP_SPRITES + i, luaSprite);
return 0;
}
@@ -64,7 +64,7 @@ namespace JinEngine
Sprite* sprite = luaSprite->getObject<Sprite>();
shrAnimation->addFrame(sprite);
int index = shrAnimation->getFrameCount() - 1;
- luaObj->setDependency((int)AnimationDependency::DEP_SPRITES + index, luaSprite->getShared());
+ luaObj->setDependency((int)AnimationDependency::DEP_SPRITES + index, luaSprite);
}
return 0;
}
@@ -90,8 +90,8 @@ namespace JinEngine
LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation);
Animation* shrAnimation = luaObj->getObject<Animation>();
int i = luax_checkinteger(L, 2);
- Shared* shrFrame = luaObj->getDependency((int)AnimationDependency::DEP_SPRITES + i);
- luax_getobject(L, shrFrame);
+ LuaObject* frame = luaObj->getDependency((int)AnimationDependency::DEP_SPRITES + i);
+ luax_getobject(L, frame);
return 1;
}
diff --git a/src/lua/modules/graphics/je_lua_animator.cpp b/src/lua/modules/graphics/je_lua_animator.cpp
index b264c17..94c61b5 100644
--- a/src/lua/modules/graphics/je_lua_animator.cpp
+++ b/src/lua/modules/graphics/je_lua_animator.cpp
@@ -86,7 +86,7 @@ namespace JinEngine
LuaObject* luaAnimator = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animator);
Animator* animator = luaAnimator->getObject<Animator>();
LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation);
- luaAnimator->setDependency((int)AnimatorDependency::DEP_ANIMATION, luaObj->getShared());
+ luaAnimator->setDependency((int)AnimatorDependency::DEP_ANIMATION, luaObj);
animator->setAnimation(luaObj->getObject<Animation>());
return 0;
}
diff --git a/src/lua/modules/graphics/je_lua_bitmap.cpp b/src/lua/modules/graphics/je_lua_bitmap.cpp
index cd0bb18..553c786 100644
--- a/src/lua/modules/graphics/je_lua_bitmap.cpp
+++ b/src/lua/modules/graphics/je_lua_bitmap.cpp
@@ -87,7 +87,7 @@ namespace JinEngine
{
Bitmap* bitmap = checkBitmap(L);
Bitmap* b = bitmap->clone();
- LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Bitmap, new Shared(b, Jin_Lua_Bitmap));
+ LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Bitmap, new Shared(b));
return 1;
}
diff --git a/src/lua/modules/graphics/je_lua_graphics.cpp b/src/lua/modules/graphics/je_lua_graphics.cpp
index accd209..2eeb1d6 100644
--- a/src/lua/modules/graphics/je_lua_graphics.cpp
+++ b/src/lua/modules/graphics/je_lua_graphics.cpp
@@ -208,7 +208,7 @@ namespace JinEngine
return 1;
}
}
- LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Bitmap, new Shared(bitmap, Jin_Lua_Bitmap));
+ LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Bitmap, new Shared(bitmap));
return 1;
}
@@ -227,7 +227,7 @@ namespace JinEngine
const char* path = luax_checkstring(L, 1);
texture = new Texture(path);
}
- LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Texture, new Shared(texture, Jin_Lua_Texture));
+ LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Texture, new Shared(texture));
return 1;
}
@@ -241,7 +241,7 @@ namespace JinEngine
luax_pushnil(L);
return 1;
}
- LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Shader, new Shared(jsl, Jin_Lua_Shader));
+ LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Shader, new Shared(jsl));
return 1;
}
@@ -264,7 +264,7 @@ namespace JinEngine
luax_pushnil(L);
return 1;
}
- LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Shader, new Shared(jsl, Jin_Lua_Shader));
+ LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Shader, new Shared(jsl));
return 1;
}
@@ -273,7 +273,7 @@ namespace JinEngine
int w = luax_checknumber(L, 1);
int h = luax_checknumber(L, 2);
Canvas* cvs = new Canvas(w, h);
- LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Canvas, new Shared(cvs, Jin_Lua_Canvas));
+ LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Canvas, new Shared(cvs));
return 1;
}
@@ -684,7 +684,7 @@ namespace JinEngine
fs->read(path, b);
fd = new TTFData(&b, b.size());
}
- LuaObject* luaObj = luax_newinstance(L, Jin_Lua_TTFData, new Shared(fd, Jin_Lua_TTFData));
+ LuaObject* luaObj = luax_newinstance(L, Jin_Lua_TTFData, new Shared(fd));
return 1;
}
@@ -707,7 +707,7 @@ namespace JinEngine
unsigned length;
const char* data = luax_checklstring(L, 1, &length);
Text* text = new Text(encode, data, length);
- LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Text, new Shared(text, Jin_Lua_Text));
+ LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Text, new Shared(text));
return 1;
}
@@ -735,8 +735,8 @@ namespace JinEngine
quad.h = luax_rawgetnumberthenpop(L, 2, 4);
int o = luax_checkinteger(L, 3);
Origin origin = static_cast<Origin>(o);
- LuaObject* p = luax_newinstance(L, Jin_Lua_Sprite, new Shared(new Sprite(graphic, quad, origin), Jin_Lua_Sprite));
- p->setDependency((int)SpriteDependency::DEP_GRAPHIC, objGraphic->getShared());
+ LuaObject* p = luax_newinstance(L, Jin_Lua_Sprite, new Shared(new Sprite(graphic, quad, origin)));
+ p->setDependency((int)SpriteDependency::DEP_GRAPHIC, objGraphic);
}
else if (n == 4)
{
@@ -747,22 +747,22 @@ namespace JinEngine
quad.h = luax_rawgetnumberthenpop(L, 2, 4);
int ox = luax_checkinteger(L, 3);
int oy = luax_checkinteger(L, 4);
- LuaObject* p = luax_newinstance(L, Jin_Lua_Sprite, new Shared(new Sprite(graphic, quad, ox, oy), Jin_Lua_Sprite));
- p->setDependency((int)SpriteDependency::DEP_GRAPHIC, objGraphic->getShared());
+ LuaObject* p = luax_newinstance(L, Jin_Lua_Sprite, new Shared(new Sprite(graphic, quad, ox, oy)));
+ p->setDependency((int)SpriteDependency::DEP_GRAPHIC, objGraphic);
}
else if (n == 2)
{
int o = luax_checkinteger(L, 2);
Origin origin = static_cast<Origin>(o);
- LuaObject* p = luax_newinstance(L, Jin_Lua_Sprite, new Shared(new Sprite(graphic, origin), Jin_Lua_Sprite));
- p->setDependency((int)SpriteDependency::DEP_GRAPHIC, objGraphic->getShared());
+ LuaObject* p = luax_newinstance(L, Jin_Lua_Sprite, new Shared(new Sprite(graphic, origin)));
+ p->setDependency((int)SpriteDependency::DEP_GRAPHIC, objGraphic);
}
else if (n == 3)
{
int ox = luax_checkinteger(L, 2);
int oy = luax_checkinteger(L, 3);
- LuaObject* p = luax_newinstance(L, Jin_Lua_Sprite, new Shared(new Sprite(graphic, ox, oy), Jin_Lua_Sprite));
- p->setDependency((int)SpriteDependency::DEP_GRAPHIC, objGraphic->getShared());
+ LuaObject* p = luax_newinstance(L, Jin_Lua_Sprite, new Shared(new Sprite(graphic, ox, oy)));
+ p->setDependency((int)SpriteDependency::DEP_GRAPHIC, objGraphic);
}
else
{
@@ -784,10 +784,9 @@ namespace JinEngine
if (objGraphic != nullptr)
{
Graphic* graphic = objGraphic->getObject<Graphic>();
- Shared* shrSSheet = new Shared(new SpriteSheet(graphic), Jin_Lua_SpriteSheet);
- Shared* shrGraphic = objGraphic->getShared();
+ Shared* shrSSheet = new Shared(new SpriteSheet(graphic));
LuaObject* luaSSheet = luax_newinstance(L, Jin_Lua_SpriteSheet, shrSSheet);
- luaSSheet->setDependency((int)SpriteSheetDependency::DEP_GRAPHIC, shrGraphic);
+ luaSSheet->setDependency((int)SpriteSheetDependency::DEP_GRAPHIC, objGraphic);
return 1;
}
else
@@ -799,7 +798,7 @@ namespace JinEngine
{
int argc = luax_gettop(L);
Animation* animation = new Animation();
- Shared* shrAnimation = new Shared(animation, Jin_Lua_Animation);
+ Shared* shrAnimation = new Shared(animation);
LuaObject* luaAnimation = luax_newinstance(L, Jin_Lua_Animation, shrAnimation);
if (argc >= 3)
{
@@ -817,7 +816,7 @@ namespace JinEngine
LuaObject* luaSprite = (LuaObject*)luax_checktype(L, -1, Jin_Lua_Sprite);
animation->addFrame(luaSprite->getObject<Sprite>());
int index = animation->getFrameCount() - 1;
- luaAnimation->setDependency((int)AnimationDependency::DEP_SPRITES + index, luaSprite->getShared());
+ luaAnimation->setDependency((int)AnimationDependency::DEP_SPRITES + index, luaSprite);
}
animation->setLoop(loop);
animation->setSpeed(speed);
@@ -831,14 +830,13 @@ namespace JinEngine
{
int argc = luax_gettop(L);
Animator* animator = new Animator();
- Shared* shrAniamtor = new Shared(animator, Jin_Lua_Animator);
+ Shared* shrAniamtor = new Shared(animator);
if (argc >= 1)
{
- LuaObject* luaAnimation = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation);
- Shared* shrAnimtion = luaAnimation->getShared();
- animator->setAnimation(shrAnimtion->getObject<Animation>());
+ LuaObject* animation = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation);
+ animator->setAnimation(animation->getObject<Animation>());
LuaObject* luaAnimator = luax_newinstance(L, Jin_Lua_Animator, shrAniamtor);
- luaAnimator->setDependency((int)AnimatorDependency::DEP_ANIMATION, shrAnimtion);
+ luaAnimator->setDependency((int)AnimatorDependency::DEP_ANIMATION, animation);
return 1;
}
LuaObject* luaAnimator = luax_newinstance(L, Jin_Lua_Animator, shrAniamtor);
@@ -892,13 +890,13 @@ namespace JinEngine
// Delete temporary text.
delete text;
}
- LuaObject* luaObj = luax_newinstance(L, Jin_Lua_TextureFont, new Shared(textureFont, Jin_Lua_TextureFont));
+ LuaObject* luaObj = luax_newinstance(L, Jin_Lua_TextureFont, new Shared(textureFont));
return 1;
}
LUA_IMPLEMENT int l_newParticleSystem(lua_State* L)
{
- LuaObject* luaObj = luax_newinstance(L, Jin_Lua_ParticleSystem, new Shared(new ParticleSystem(), Jin_Lua_ParticleSystem));
+ LuaObject* luaObj = luax_newinstance(L, Jin_Lua_ParticleSystem, new Shared(new ParticleSystem()));
return 1;
}
diff --git a/src/lua/modules/graphics/je_lua_particle_system.cpp b/src/lua/modules/graphics/je_lua_particle_system.cpp
index 0b348ad..0c42209 100644
--- a/src/lua/modules/graphics/je_lua_particle_system.cpp
+++ b/src/lua/modules/graphics/je_lua_particle_system.cpp
@@ -242,7 +242,7 @@ namespace JinEngine
Sprite* spr = objSpr->getObject<Sprite>();
ps->addParticleSprite(spr);
int depn = (*obj).getDependenciesCount();
- (*obj).setDependency((int)ParticleSystemDependency::DEP_SPRITES + depn, objSpr->getShared());
+ (*obj).setDependency((int)ParticleSystemDependency::DEP_SPRITES + depn, objSpr);
return 0;
}
@@ -264,7 +264,7 @@ namespace JinEngine
luax_pop(L, 1);
Sprite* spr = objSpr->getObject<Sprite>();
ps->addParticleSprite(spr);
- (*obj).setDependency((int)ParticleSystemDependency::DEP_SPRITES + depn + i - 1, objSpr->getShared());
+ (*obj).setDependency((int)ParticleSystemDependency::DEP_SPRITES + depn + i - 1, objSpr);
}
return 0;
}
diff --git a/src/lua/modules/graphics/je_lua_spritesheet.cpp b/src/lua/modules/graphics/je_lua_spritesheet.cpp
index 0cfdb93..a1a2c59 100644
--- a/src/lua/modules/graphics/je_lua_spritesheet.cpp
+++ b/src/lua/modules/graphics/je_lua_spritesheet.cpp
@@ -47,9 +47,9 @@ namespace JinEngine
origin = static_cast<Origin>(o);
spr = sheet->createSprite(quad, origin);
}
- Shared* shrSprite = new Shared(spr, Jin_Lua_Sprite);
+ Shared* shrSprite = new Shared(spr);
LuaObject* luaSprite = luax_newinstance(L, Jin_Lua_Sprite, shrSprite);
- luaSprite->setDependency((int)SpriteDependency::DEP_SPRITESHEET, luaSSheet->getShared());
+ luaSprite->setDependency((int)SpriteDependency::DEP_SPRITESHEET, luaSSheet);
return 1;
}
@@ -91,13 +91,13 @@ namespace JinEngine
return 1;
}
luax_newtable(L);
- Shared* shrGraphic = luaSS->getDependency((int)SpriteSheetDependency::DEP_GRAPHIC);
+ LuaObject* graphic = luaSS->getDependency((int)SpriteSheetDependency::DEP_GRAPHIC);
for (int i = 0; i < sprs.size(); ++i)
{
Sprite* spr = sprs[i];
- Shared* shrSpr = new Shared(spr, Jin_Lua_Sprite);
+ Shared* shrSpr = new Shared(spr);
LuaObject* luaSpr = (LuaObject*)luax_newinstance(L, Jin_Lua_Sprite, shrSpr);
- luaSpr->setDependency((int)SpriteDependency::DEP_GRAPHIC, shrGraphic);
+ luaSpr->setDependency((int)SpriteDependency::DEP_GRAPHIC, graphic);
luax_rawseti(L, -2, i + 1);
}
return 1;
diff --git a/src/lua/modules/graphics/je_lua_texture_font.cpp b/src/lua/modules/graphics/je_lua_texture_font.cpp
index 1365aa8..9c9d52c 100644
--- a/src/lua/modules/graphics/je_lua_texture_font.cpp
+++ b/src/lua/modules/graphics/je_lua_texture_font.cpp
@@ -43,9 +43,9 @@ namespace JinEngine
Text* text = p2->getObject<Text>();
page = tf->typeset(*text, lineheight, spacing);
}
- Shared* shrPage = new Shared(page, Jin_Lua_Page);
+ Shared* shrPage = new Shared(page);
LuaObject* luaPage = luax_newinstance(L, Jin_Lua_Page, shrPage);
- luaPage->setDependency((int)PageDependency::DEP_TEXTURE_FONT, luaTexFont->getShared());
+ luaPage->setDependency((int)PageDependency::DEP_TEXTURE_FONT, luaTexFont);
return 1;
}
diff --git a/src/lua/modules/graphics/je_lua_ttf.cpp b/src/lua/modules/graphics/je_lua_ttf.cpp
index ad1872f..caa1e53 100644
--- a/src/lua/modules/graphics/je_lua_ttf.cpp
+++ b/src/lua/modules/graphics/je_lua_ttf.cpp
@@ -43,9 +43,9 @@ namespace JinEngine
Text* text = luaText->getObject<Text>();
page = ttf->typeset(*text, lineheight, spacing);
}
- Shared* refPage = new Shared(page, Jin_Lua_Page);
+ Shared* refPage = new Shared(page);
LuaObject* luaPage = luax_newinstance(L, Jin_Lua_Page, refPage);
- luaPage->setDependency((int)PageDependency::DEP_TTF, luaTTF->getShared());
+ luaPage->setDependency((int)PageDependency::DEP_TTF, luaTTF);
return 1;
}
diff --git a/src/lua/modules/graphics/je_lua_ttf_data.cpp b/src/lua/modules/graphics/je_lua_ttf_data.cpp
index b10b993..4a95ab2 100644
--- a/src/lua/modules/graphics/je_lua_ttf_data.cpp
+++ b/src/lua/modules/graphics/je_lua_ttf_data.cpp
@@ -21,9 +21,9 @@ namespace JinEngine
int fontsize = luax_checkinteger(L, 2);
TTFData* fontData = luaTTFData->getObject<TTFData>();
TTF* font = fontData->createTTF(fontsize);
- Shared* shrTTF = new Shared(font, Jin_Lua_TTF);
+ Shared* shrTTF = new Shared(font);
LuaObject* luaTTF = luax_newinstance(L, Jin_Lua_TTF, shrTTF);
- luaTTF->setDependency((int)TTFDependency::DEP_TTFDATA, luaTTFData->getShared());
+ luaTTF->setDependency((int)TTFDependency::DEP_TTFDATA, luaTTFData);
return 1;
}
diff --git a/src/lua/modules/net/je_lua_net.cpp b/src/lua/modules/net/je_lua_net.cpp
index d003640..6ff5221 100644
--- a/src/lua/modules/net/je_lua_net.cpp
+++ b/src/lua/modules/net/je_lua_net.cpp
@@ -49,7 +49,7 @@ namespace JinEngine
}
}
Socket* socket = new Socket(info);
- LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Socket, new Shared(socket, Jin_Lua_Socket));
+ LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Socket, new Shared(socket));
return 1;
}
@@ -57,7 +57,7 @@ namespace JinEngine
{
int size = luax_checkinteger(L, 1);
Net::Buffer* buffer = new Net::Buffer(size);
- LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Buffer, new Shared(buffer, Jin_Lua_Buffer));
+ LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Buffer, new Shared(buffer));
return 1;
}
diff --git a/src/lua/modules/net/je_lua_socket.cpp b/src/lua/modules/net/je_lua_socket.cpp
index af0cef0..1d87175 100644
--- a/src/lua/modules/net/je_lua_socket.cpp
+++ b/src/lua/modules/net/je_lua_socket.cpp
@@ -32,7 +32,7 @@ namespace JinEngine
{
Socket* socket = checkSocket(L);
Socket* client = socket->accept();
- LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Socket, new Shared(client, Jin_Lua_Socket));
+ LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Socket, new Shared(client));
return 1;
}
@@ -43,7 +43,7 @@ namespace JinEngine
char buffer[BUFFER_SIZE] = {0};
int size = socket->receive(buffer, BUFFER_SIZE);
Net::Buffer* netBuffer = new Net::Buffer(buffer, size);
- LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Buffer, new Shared(netBuffer, Jin_Lua_Buffer));
+ LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Buffer, new Shared(netBuffer));
return 1;
}
@@ -56,7 +56,7 @@ namespace JinEngine
char buffer[BUFFER_SIZE];
int size = socket->receiveFrom(buffer, BUFFER_SIZE, address, port);
Net::Buffer* netBuffer = new Net::Buffer(buffer, size);
- LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Buffer, new Shared(netBuffer, Jin_Lua_Buffer));
+ LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Buffer, new Shared(netBuffer));
return 1;
}
diff --git a/src/lua/modules/thread/je_lua_thread.cpp b/src/lua/modules/thread/je_lua_thread.cpp
index 35bf876..9e785ff 100644
--- a/src/lua/modules/thread/je_lua_thread.cpp
+++ b/src/lua/modules/thread/je_lua_thread.cpp
@@ -213,7 +213,7 @@ namespace JinEngine
const char* name = luax_checkstring(L, 1);
const char* code = luax_checkstring(L, 2);
Thread* thread = new Thread(name, code, threadRunner);
- LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Thread, new Shared(thread, Jin_Lua_Thread));
+ LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Thread, new Shared(thread));
return 1;
}
diff --git a/src/lua/modules/time/je_lua_time.cpp b/src/lua/modules/time/je_lua_time.cpp
index 1d8b852..cd49978 100644
--- a/src/lua/modules/time/je_lua_time.cpp
+++ b/src/lua/modules/time/je_lua_time.cpp
@@ -33,7 +33,7 @@ namespace JinEngine
LUA_IMPLEMENT int l_newTimer(lua_State* L)
{
- Shared* shrTimer = new Shared(new Timer(), Jin_Lua_Timer);
+ Shared* shrTimer = new Shared(new Timer());
luax_newinstance(L, Jin_Lua_Timer, shrTimer);
return 1;
}
diff --git a/src/lua/modules/time/je_lua_timer.cpp b/src/lua/modules/time/je_lua_timer.cpp
index f689277..e30baab 100644
--- a/src/lua/modules/time/je_lua_timer.cpp
+++ b/src/lua/modules/time/je_lua_timer.cpp
@@ -42,7 +42,7 @@ namespace JinEngine
for(int i = 4; i <= n; ++i)
func->pushParam(i);
Timer::Handler* handler = shared->every(s, timerCallback, func, finishCallback);
- Shared* shrHandler = new Shared(handler, Jin_Lua_Handler);
+ Shared* shrHandler = new Shared(handler);
LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Handler, shrHandler);
return 1;
}
@@ -58,7 +58,7 @@ namespace JinEngine
for (int i = 4; i <= n; ++i)
func->pushParam(i);
Timer::Handler* handler = shared->after(s, timerCallback, func, finishCallback);
- Shared* shrHandler = new Shared(handler, Jin_Lua_Handler);
+ Shared* shrHandler = new Shared(handler);
LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Handler, shrHandler);
return 1;
}
@@ -75,7 +75,7 @@ namespace JinEngine
for (int i = 5; i <= n; ++i)
func->pushParam(i);
Timer::Handler* handler = shared->repeat(s, count, timerCallback, func, finishCallback);
- Shared* shrHandler = new Shared(handler, Jin_Lua_Handler);
+ Shared* shrHandler = new Shared(handler);
LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Handler, shrHandler);
return 1;
}
@@ -125,7 +125,6 @@ namespace JinEngine
{ "cancelAll", l_cancelAll },
{ 0, 0 }
};
-
luax_newtype(L, Jin_Lua_Timer, methods);
}