diff options
Diffstat (limited to 'src/lua/modules')
24 files changed, 251 insertions, 285 deletions
diff --git a/src/lua/modules/audio/je_lua_audio.cpp b/src/lua/modules/audio/je_lua_audio.cpp index 6257c93..22f0dba 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<Source>(src, Jin_Lua_Source)); + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Source, new Shared(src, Jin_Lua_Source)); return 1; } diff --git a/src/lua/modules/audio/je_lua_source.cpp b/src/lua/modules/audio/je_lua_source.cpp index f115721..7bb28d9 100644 --- a/src/lua/modules/audio/je_lua_source.cpp +++ b/src/lua/modules/audio/je_lua_source.cpp @@ -10,79 +10,78 @@ namespace JinEngine { const char* Jin_Lua_Source = "Source"; - - typedef Shared<Source>& SharedSource; - - LUA_IMPLEMENT inline SharedSource checkSource(lua_State* L) + + LUA_IMPLEMENT inline Source* checkSource(lua_State* L) { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Source); - return luaObj->getShared<Source>(); + LuaObject* luaObj = luax_checkobject(L, 1, Jin_Lua_Source); + Source* source = luaObj->getObject<Source>(); + return source; } LUA_IMPLEMENT int l_play(lua_State* L) { - SharedSource shared = checkSource(L); - shared->play(); + Source* source = checkSource(L); + source->play(); return 0; } LUA_IMPLEMENT int l_stop(lua_State* L) { - SharedSource shared = checkSource(L); - shared->stop(); + Source* source = checkSource(L); + source->stop(); return 0; } LUA_IMPLEMENT int l_pause(lua_State* L) { - SharedSource shared = checkSource(L); - shared->pause(); + Source* source = checkSource(L); + source->pause(); return 0; } LUA_IMPLEMENT int l_rewind(lua_State* L) { - SharedSource shared = checkSource(L); - shared->rewind(); + Source* source = checkSource(L); + source->rewind(); return 0; } LUA_IMPLEMENT int l_resume(lua_State* L) { - SharedSource shared = checkSource(L); - shared->resume(); + Source* source = checkSource(L); + source->resume(); return 0; } LUA_IMPLEMENT int l_isStop(lua_State* L) { - SharedSource shared = checkSource(L); - bool isStop = shared->isStopped(); + Source* source = checkSource(L); + bool isStop = source->isStopped(); luax_pushboolean(L, isStop); return 1; } LUA_IMPLEMENT int l_isPaused(lua_State* L) { - SharedSource shared = checkSource(L); - bool isPaused = shared->isPaused(); + Source* source = checkSource(L); + bool isPaused = source->isPaused(); luax_pushboolean(L, isPaused); return 1; } LUA_IMPLEMENT int l_setVolume(lua_State* L) { - SharedSource shared = checkSource(L); + Source* source = checkSource(L); float volume = luax_checknumber(L, 2); - shared->setVolume(volume); + source->setVolume(volume); return 0; } LUA_IMPLEMENT int l_setLoop(lua_State* L) { - SharedSource shared = checkSource(L); + Source* source = checkSource(L); bool loop = luax_checkbool(L, 2); - shared->setLoop(loop); + source->setLoop(loop); return 0; } @@ -108,7 +107,6 @@ namespace JinEngine { "setLoop", l_setLoop }, { 0, 0 } }; - luax_newtype(L, Jin_Lua_Source, methods); } diff --git a/src/lua/modules/graphics/je_lua_animation.cpp b/src/lua/modules/graphics/je_lua_animation.cpp index bdba10d..2bb635a 100644 --- a/src/lua/modules/graphics/je_lua_animation.cpp +++ b/src/lua/modules/graphics/je_lua_animation.cpp @@ -20,12 +20,10 @@ namespace JinEngine { const char* Jin_Lua_Animation = "Animation"; - typedef Shared<Animation>& SharedAnimation; - - LUA_IMPLEMENT inline SharedAnimation checkAnimation(lua_State* L) + LUA_IMPLEMENT inline Animation* checkAnimation(lua_State* L) { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation); - return luaObj->getShared<Animation>(); + LuaObject* luaObj = luax_checkobject(L, 1, Jin_Lua_Animation); + return luaObj->getObject<Animation>(); } LUA_IMPLEMENT int l_gc(lua_State* L) @@ -39,12 +37,12 @@ namespace JinEngine LUA_IMPLEMENT int l_addFrame(lua_State* L) { LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation); - SharedAnimation shrAnimation = luaObj->getShared<Animation>(); + Animation* animation = luaObj->getObject<Animation>(); LuaObject* luaSprite = (LuaObject*)luax_checktype(L, 2, Jin_Lua_Sprite); - Shared<Sprite>& shrSprite = luaSprite->getShared<Sprite>(); - shrAnimation->addFrame(shrSprite.getObject()); - int i = shrAnimation->getFrameCount() - 1; - luaObj->setDependency((int)AnimationDependency::DEP_SPRITES + i, &shrSprite); + Sprite* sprite = luaSprite->getObject<Sprite>(); + animation->addFrame(sprite); + int i = animation->getFrameCount() - 1; + luaObj->setDependency((int)AnimationDependency::DEP_SPRITES + i, luaSprite->getShared()); return 0; } @@ -52,7 +50,7 @@ namespace JinEngine LUA_IMPLEMENT int l_addFrames(lua_State* L) { LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation); - SharedAnimation shrAnimation = luaObj->getShared<Animation>(); + Animation* shrAnimation = luaObj->getObject<Animation>(); if (!luax_istable(L, 2)) { luax_typerror(L, 2, "sprites table"); @@ -63,17 +61,17 @@ namespace JinEngine { luax_rawgeti(L, 2, i); LuaObject* luaSprite = (LuaObject*)luax_checktype(L, -1, Jin_Lua_Sprite); - Shared<Sprite>& shrSprite = luaSprite->getShared<Sprite>(); - shrAnimation->addFrame(shrSprite.getObject()); + Sprite* sprite = luaSprite->getObject<Sprite>(); + shrAnimation->addFrame(sprite); int index = shrAnimation->getFrameCount() - 1; - luaObj->setDependency((int)AnimationDependency::DEP_SPRITES + index, &shrSprite); + luaObj->setDependency((int)AnimationDependency::DEP_SPRITES + index, luaSprite->getShared()); } return 0; } LUA_IMPLEMENT int l_isLoop(lua_State* L) { - SharedAnimation shrAnimation = checkAnimation(L); + Animation* shrAnimation = checkAnimation(L); bool loop = shrAnimation->isLoop(); luax_pushboolean(L, loop); return 1; @@ -81,7 +79,7 @@ namespace JinEngine LUA_IMPLEMENT int l_getSpeed(lua_State* L) { - SharedAnimation shrAnimation = checkAnimation(L); + Animation* shrAnimation = checkAnimation(L); float speed = shrAnimation->getSpeed(); luax_pushnumber(L, speed); return 1; @@ -90,16 +88,16 @@ namespace JinEngine LUA_IMPLEMENT int l_getFrame(lua_State* L) { LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation); - SharedAnimation shrAnimation = luaObj->getShared<Animation>(); + Animation* shrAnimation = luaObj->getObject<Animation>(); int i = luax_checkinteger(L, 2); - SharedBase* shrFrame = luaObj->getDependency((int)AnimationDependency::DEP_SPRITES + i); + Shared* shrFrame = luaObj->getDependency((int)AnimationDependency::DEP_SPRITES + i); luax_getobject(L, shrFrame); return 1; } LUA_IMPLEMENT int getFrameCount(lua_State* L) { - SharedAnimation shrAnimation = checkAnimation(L); + Animation* shrAnimation = checkAnimation(L); int n = shrAnimation->getFrameCount(); luax_pushinteger(L, n); return 1; diff --git a/src/lua/modules/graphics/je_lua_animator.cpp b/src/lua/modules/graphics/je_lua_animator.cpp index 360a276..b264c17 100644 --- a/src/lua/modules/graphics/je_lua_animator.cpp +++ b/src/lua/modules/graphics/je_lua_animator.cpp @@ -20,12 +20,10 @@ namespace JinEngine { const char* Jin_Lua_Animator = "Animator"; - typedef Shared<Animator>& SharedAnimator; - - LUA_IMPLEMENT inline SharedAnimator checkAnimator(lua_State* L) + LUA_IMPLEMENT inline Animator* checkAnimator(lua_State* L) { LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animator); - return luaObj->getShared<Animator>(); + return luaObj->getObject<Animator>(); } LUA_IMPLEMENT int l_gc(lua_State* L) @@ -37,7 +35,7 @@ namespace JinEngine LUA_IMPLEMENT int l_update(lua_State* L) { - SharedAnimator animator = checkAnimator(L); + Animator* animator = checkAnimator(L); float dt = luax_checknumber(L, 2); animator->update(dt); return 0; @@ -45,35 +43,35 @@ namespace JinEngine LUA_IMPLEMENT int l_play(lua_State* L) { - SharedAnimator animator = checkAnimator(L); + Animator* animator = checkAnimator(L); animator->play(); return 0; } LUA_IMPLEMENT int l_pause(lua_State* L) { - SharedAnimator animator = checkAnimator(L); + Animator* animator = checkAnimator(L); animator->pause(); return 0; } LUA_IMPLEMENT int l_resume(lua_State* L) { - SharedAnimator animator = checkAnimator(L); + Animator* animator = checkAnimator(L); animator->resume(); return 0; } LUA_IMPLEMENT int l_rewind(lua_State* L) { - SharedAnimator animator = checkAnimator(L); + Animator* animator = checkAnimator(L); animator->rewind(); return 0; } LUA_IMPLEMENT int l_render(lua_State* L) { - SharedAnimator animator = checkAnimator(L); + Animator* animator = checkAnimator(L); float x = luax_checknumber(L, 2); float y = luax_checknumber(L, 3); float sx = luax_checknumber(L, 4); @@ -86,17 +84,16 @@ namespace JinEngine LUA_IMPLEMENT int l_setAnimation(lua_State* L) { LuaObject* luaAnimator = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animator); - SharedAnimator shrAnimator = luaAnimator->getShared<Animator>(); + Animator* animator = luaAnimator->getObject<Animator>(); LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation); - Shared<Animation>& shrAnimation = luaObj->getShared<Animation>(); - luaAnimator->setDependency((int)AnimatorDependency::DEP_ANIMATION, &shrAnimation); - shrAnimator->setAnimation(shrAnimation.getObject()); + luaAnimator->setDependency((int)AnimatorDependency::DEP_ANIMATION, luaObj->getShared()); + animator->setAnimation(luaObj->getObject<Animation>()); return 0; } LUA_IMPLEMENT int l_forceToFrame(lua_State* L) { - SharedAnimator shrAnimator = checkAnimator(L); + Animator* shrAnimator = checkAnimator(L); int index = luax_checkinteger(L, 2); shrAnimator->forceToFrame(index); return 0; @@ -104,7 +101,7 @@ namespace JinEngine LUA_IMPLEMENT int l_setSpeed(lua_State* L) { - SharedAnimator shrAnimator = checkAnimator(L); + Animator* shrAnimator = checkAnimator(L); float fps = luax_checknumber(L, 2); shrAnimator->setSpeed(fps); return 0; @@ -112,14 +109,14 @@ namespace JinEngine LUA_IMPLEMENT int l_setDefaultSpeed(lua_State* L) { - SharedAnimator shrAnimator = checkAnimator(L); + Animator* shrAnimator = checkAnimator(L); shrAnimator->setDefaultSpeed(); return 0; } LUA_IMPLEMENT int l_setLoop(lua_State* L) { - SharedAnimator shrAnimator = checkAnimator(L); + Animator* shrAnimator = checkAnimator(L); bool loop = luax_checkbool(L, 2); shrAnimator->setLoop(loop); return 0; @@ -127,14 +124,14 @@ namespace JinEngine LUA_IMPLEMENT int l_setDefaultLoop(lua_State* L) { - SharedAnimator shrAnimator = checkAnimator(L); + Animator* shrAnimator = checkAnimator(L); shrAnimator->setDefaultLoop(); return 0; } LUA_IMPLEMENT int l_getSpeed(lua_State* L) { - SharedAnimator shrAnimator = checkAnimator(L); + Animator* shrAnimator = checkAnimator(L); float speed = shrAnimator->getSpeed(); luax_pushnumber(L, speed); return 1; diff --git a/src/lua/modules/graphics/je_lua_bitmap.cpp b/src/lua/modules/graphics/je_lua_bitmap.cpp index 8d8b76e..cd0bb18 100644 --- a/src/lua/modules/graphics/je_lua_bitmap.cpp +++ b/src/lua/modules/graphics/je_lua_bitmap.cpp @@ -13,12 +13,10 @@ namespace JinEngine const char* Jin_Lua_Bitmap = "Bitmap"; - typedef Shared<Bitmap>& SharedBitmap; - - LUA_IMPLEMENT inline SharedBitmap checkBitmap(lua_State* L) + LUA_IMPLEMENT inline Bitmap* checkBitmap(lua_State* L) { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Bitmap); - return luaObj->getShared<Bitmap>(); + LuaObject* luaObj = luax_checkobject(L, 1, Jin_Lua_Bitmap); + return luaObj->getObject<Bitmap>(); } LUA_IMPLEMENT int l_gc(lua_State* L) @@ -30,25 +28,25 @@ namespace JinEngine LUA_IMPLEMENT int l_getWidth(lua_State* L) { - SharedBitmap shared = checkBitmap(L); - int w = shared->getWidth(); + Bitmap* bitmap = checkBitmap(L); + int w = bitmap->getWidth(); luax_pushinteger(L, w); return 1; } LUA_IMPLEMENT int l_getHeight(lua_State* L) { - SharedBitmap shared = checkBitmap(L); - int h = shared->getHeight(); + Bitmap* bitmap = checkBitmap(L); + int h = bitmap->getHeight(); luax_pushinteger(L, h); return 1; } LUA_IMPLEMENT int l_getSize(lua_State* L) { - SharedBitmap shared = checkBitmap(L); - int w = shared->getWidth(); - int h = shared->getHeight(); + Bitmap* bitmap = checkBitmap(L); + int w = bitmap->getWidth(); + int h = bitmap->getHeight(); luax_pushinteger(L, w); luax_pushinteger(L, h); return 2; @@ -56,10 +54,10 @@ namespace JinEngine LUA_IMPLEMENT int l_getPixel(lua_State* L) { - SharedBitmap shared = checkBitmap(L); + Bitmap* bitmap = checkBitmap(L); int x = luax_checkinteger(L, 2); int y = luax_checkinteger(L, 3); - Color col = shared->getPixel(x, y); + Color col = bitmap->getPixel(x, y); luax_pushinteger(L, col.r); luax_pushinteger(L, col.g); luax_pushinteger(L, col.b); @@ -69,7 +67,7 @@ namespace JinEngine LUA_IMPLEMENT int l_setPixel(lua_State* L) { - SharedBitmap shared = checkBitmap(L); + Bitmap* bitmap = checkBitmap(L); int x = luax_checkinteger(L, 2); int y = luax_checkinteger(L, 3); if (!luax_istable(L, 4)) @@ -81,16 +79,15 @@ namespace JinEngine unsigned int g = luax_rawgetnumber(L, 4, 2); unsigned int b = luax_rawgetnumber(L, 4, 3); unsigned int a = luax_rawgetnumber(L, 4, 4); - shared->setPixel(Color(r, g, b, a), x, y); + bitmap->setPixel(Color(r, g, b, a), x, y); return 0; } LUA_IMPLEMENT int l_clone(lua_State* L) { - SharedBitmap shared = checkBitmap(L); - Bitmap* bitmap = shared.getObject(); + Bitmap* bitmap = checkBitmap(L); Bitmap* b = bitmap->clone(); - LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Bitmap, new Shared<Bitmap>(b, Jin_Lua_Bitmap)); + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Bitmap, new Shared(b, Jin_Lua_Bitmap)); return 1; } diff --git a/src/lua/modules/graphics/je_lua_canvas.cpp b/src/lua/modules/graphics/je_lua_canvas.cpp index 261f940..0e884f8 100644 --- a/src/lua/modules/graphics/je_lua_canvas.cpp +++ b/src/lua/modules/graphics/je_lua_canvas.cpp @@ -12,33 +12,31 @@ namespace JinEngine const char* Jin_Lua_Canvas = "Canvas"; - typedef Shared<Canvas>& SharedCanvas; - - LUA_IMPLEMENT inline SharedCanvas checkCanvas(lua_State* L) + LUA_IMPLEMENT inline Canvas* checkCanvas(lua_State* L) { LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Canvas); - return luaObj->getShared<Canvas>(); + return luaObj->getObject<Canvas>(); } LUA_IMPLEMENT int l_getWidth(lua_State* L) { - SharedCanvas shared = checkCanvas(L); - luax_pushnumber(L, shared->getWidth()); + Canvas* canvas = checkCanvas(L); + luax_pushnumber(L, canvas->getWidth()); return 1; } LUA_IMPLEMENT int l_getHeight(lua_State* L) { - SharedCanvas shared = checkCanvas(L); - luax_pushnumber(L, shared->getHeight()); + Canvas* canvas = checkCanvas(L); + luax_pushnumber(L, canvas->getHeight()); return 1; } LUA_IMPLEMENT int l_getSize(lua_State* L) { - SharedCanvas shared = checkCanvas(L); - luax_pushnumber(L, shared->getWidth()); - luax_pushnumber(L, shared->getHeight()); + Canvas* canvas = checkCanvas(L); + luax_pushnumber(L, canvas->getWidth()); + luax_pushnumber(L, canvas->getHeight()); return 2; } diff --git a/src/lua/modules/graphics/je_lua_graphics.cpp b/src/lua/modules/graphics/je_lua_graphics.cpp index 40bb4fa..accd209 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>(bitmap, Jin_Lua_Bitmap)); + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Bitmap, new Shared(bitmap, Jin_Lua_Bitmap)); return 1; } @@ -218,9 +218,8 @@ namespace JinEngine Texture* texture = nullptr; if (luax_istype(L, 1, Jin_Lua_Bitmap)) { - LuaObject* p = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Bitmap); - Shared<Bitmap>& refBitmap = p->getShared<Bitmap>(); - Bitmap* bitmap = refBitmap.getObject(); + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Bitmap); + Bitmap* bitmap = luaObj->getObject<Bitmap>(); texture = new Texture(bitmap); } else if (luax_isstring(L, 1)) @@ -228,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>(texture, Jin_Lua_Texture)); + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Texture, new Shared(texture, Jin_Lua_Texture)); return 1; } @@ -242,7 +241,7 @@ namespace JinEngine luax_pushnil(L); return 1; } - LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Shader, new Shared<Shader>(jsl, Jin_Lua_Shader)); + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Shader, new Shared(jsl, Jin_Lua_Shader)); return 1; } @@ -265,7 +264,7 @@ namespace JinEngine luax_pushnil(L); return 1; } - LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Shader, new Shared<Shader>(jsl, Jin_Lua_Shader)); + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Shader, new Shared(jsl, Jin_Lua_Shader)); return 1; } @@ -274,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<Canvas>(cvs, Jin_Lua_Canvas)); + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Canvas, new Shared(cvs, Jin_Lua_Canvas)); return 1; } @@ -322,7 +321,7 @@ namespace JinEngine float ox = luax_optnumber(L, 7, 0); float oy = luax_optnumber(L, 8, 0); LuaObject* luaObj = (LuaObject*)luax_toudata(L, 1); - Shared<Texture>& tex = luaObj->getShared<Texture>(); + Texture* tex = luaObj->getObject<Texture>(); tex->render(x, y, sx, sy, r, ox, oy); } @@ -338,8 +337,8 @@ namespace JinEngine float ox = luax_optnumber(L, 7, 0); float oy = luax_optnumber(L, 8, 0); LuaObject* luaObj = (LuaObject*)luax_toudata(L, 1); - Shared<Canvas>& p = luaObj->getShared<Canvas>(); - p->render(x, y, sx, sy, r, ox, oy); + Canvas* canvas = luaObj->getObject<Canvas>(); + canvas->render(x, y, sx, sy, r, ox, oy); } /* jin.graphics.draw(text, font, x, y) */ @@ -444,14 +443,14 @@ namespace JinEngine if (luax_istype(L, 1, Jin_Lua_Texture)) { LuaObject* luaObj = (LuaObject*)luax_toudata(L, 1); - Shared<Texture>& tex = luaObj->getShared<Texture>(); + Texture* tex = luaObj->getObject<Texture>(); tex->render(q, x, y, sx, sy, r, ox, oy); } else if (luax_istype(L, 1, Jin_Lua_Canvas)) { LuaObject* luaObj = (LuaObject*)luax_toudata(L, 1); - Shared<Canvas>& p = luaObj->getShared<Canvas>(); - p->render(q, x, y, sx, sy, r, ox, oy); + Canvas* canvas = luaObj->getObject<Canvas>(); + canvas->render(q, x, y, sx, sy, r, ox, oy); } else { @@ -514,8 +513,8 @@ namespace JinEngine return 0; } LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Canvas); - Shared<Canvas>& shared = luaObj->getShared<Canvas>(); - gl.bindCanvas(shared.getObject()); + Canvas* canvas = luaObj->getObject<Canvas>(); + gl.bindCanvas(canvas); return 0; } @@ -535,8 +534,8 @@ namespace JinEngine if (luax_istype(L, 1, Jin_Lua_Shader)) { LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Shader); - Shared<Shader>& shader = luaObj->getShared<Shader>(); - gl.useShader(shader.getObject()); + Shader* shader = luaObj->getObject<Shader>(); + gl.useShader(shader); } else { @@ -685,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<TTFData>(fd, Jin_Lua_TTFData)); + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_TTFData, new Shared(fd, Jin_Lua_TTFData)); return 1; } @@ -708,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>(text, Jin_Lua_Text)); + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Text, new Shared(text, Jin_Lua_Text)); return 1; } @@ -736,7 +735,7 @@ 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<Sprite>(new Sprite(graphic, quad, origin), Jin_Lua_Sprite)); + 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()); } else if (n == 4) @@ -748,21 +747,21 @@ 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<Sprite>(new Sprite(graphic, quad, ox, oy), Jin_Lua_Sprite)); + 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()); } 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<Sprite>(new Sprite(graphic, origin), Jin_Lua_Sprite)); + 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()); } 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<Sprite>(new Sprite(graphic, ox, oy), Jin_Lua_Sprite)); + 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()); } else @@ -785,10 +784,10 @@ namespace JinEngine if (objGraphic != nullptr) { Graphic* graphic = objGraphic->getObject<Graphic>(); - Shared<SpriteSheet>* shrSSheet = new Shared<SpriteSheet>(new SpriteSheet(graphic), Jin_Lua_SpriteSheet); - Shared<Graphic>& shrGraphic = objGraphic->getShared<Graphic>(); + Shared* shrSSheet = new Shared(new SpriteSheet(graphic), Jin_Lua_SpriteSheet); + Shared* shrGraphic = objGraphic->getShared(); LuaObject* luaSSheet = luax_newinstance(L, Jin_Lua_SpriteSheet, shrSSheet); - luaSSheet->setDependency((int)SpriteSheetDependency::DEP_GRAPHIC, &shrGraphic); + luaSSheet->setDependency((int)SpriteSheetDependency::DEP_GRAPHIC, shrGraphic); return 1; } else @@ -799,7 +798,8 @@ namespace JinEngine LUA_IMPLEMENT int l_newAnimation(lua_State* L) { int argc = luax_gettop(L); - Shared<Animation>* shrAnimation = new Shared<Animation>(new Animation(), Jin_Lua_Animation); + Animation* animation = new Animation(); + Shared* shrAnimation = new Shared(animation, Jin_Lua_Animation); LuaObject* luaAnimation = luax_newinstance(L, Jin_Lua_Animation, shrAnimation); if (argc >= 3) { @@ -815,13 +815,12 @@ namespace JinEngine { luax_rawgeti(L, 1, i); LuaObject* luaSprite = (LuaObject*)luax_checktype(L, -1, Jin_Lua_Sprite); - Shared<Sprite>& shrSprite = luaSprite->getShared<Sprite>(); - (*shrAnimation)->addFrame(shrSprite.getObject()); - int index = (*shrAnimation)->getFrameCount() - 1; - luaAnimation->setDependency((int)AnimationDependency::DEP_SPRITES + index, &shrSprite); + animation->addFrame(luaSprite->getObject<Sprite>()); + int index = animation->getFrameCount() - 1; + luaAnimation->setDependency((int)AnimationDependency::DEP_SPRITES + index, luaSprite->getShared()); } - (*shrAnimation)->setLoop(loop); - (*shrAnimation)->setSpeed(speed); + animation->setLoop(loop); + animation->setSpeed(speed); } luax_pushvalue(L, argc + 1); return 1; @@ -831,14 +830,15 @@ namespace JinEngine LUA_IMPLEMENT int l_newAnimator(lua_State* L) { int argc = luax_gettop(L); - Shared<Animator>* shrAniamtor = new Shared<Animator>(new Animator(), Jin_Lua_Animator); + Animator* animator = new Animator(); + Shared* shrAniamtor = new Shared(animator, Jin_Lua_Animator); if (argc >= 1) { LuaObject* luaAnimation = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation); - Shared<Animation>& shrAnimtion = luaAnimation->getShared<Animation>(); - (*shrAniamtor)->setAnimation(shrAnimtion.getObject()); + Shared* shrAnimtion = luaAnimation->getShared(); + animator->setAnimation(shrAnimtion->getObject<Animation>()); LuaObject* luaAnimator = luax_newinstance(L, Jin_Lua_Animator, shrAniamtor); - luaAnimator->setDependency((int)AnimatorDependency::DEP_ANIMATION, &shrAnimtion); + luaAnimator->setDependency((int)AnimatorDependency::DEP_ANIMATION, shrAnimtion); return 1; } LuaObject* luaAnimator = luax_newinstance(L, Jin_Lua_Animator, shrAniamtor); @@ -892,13 +892,13 @@ namespace JinEngine // Delete temporary text. delete text; } - LuaObject* luaObj = luax_newinstance(L, Jin_Lua_TextureFont, new Shared<TextureFont>(textureFont, Jin_Lua_TextureFont)); + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_TextureFont, new Shared(textureFont, Jin_Lua_TextureFont)); return 1; } LUA_IMPLEMENT int l_newParticleSystem(lua_State* L) { - LuaObject* luaObj = luax_newinstance(L, Jin_Lua_ParticleSystem, new Shared<ParticleSystem>(new ParticleSystem(), Jin_Lua_ParticleSystem)); + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_ParticleSystem, new Shared(new ParticleSystem(), Jin_Lua_ParticleSystem)); return 1; } diff --git a/src/lua/modules/graphics/je_lua_page.cpp b/src/lua/modules/graphics/je_lua_page.cpp index 6234f3f..6d84c4f 100644 --- a/src/lua/modules/graphics/je_lua_page.cpp +++ b/src/lua/modules/graphics/je_lua_page.cpp @@ -15,8 +15,6 @@ namespace JinEngine const char* Jin_Lua_Page = "Page"; - typedef Shared<Font>& SharedFont; - Page* getPage(lua_State* L) { LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Page); diff --git a/src/lua/modules/graphics/je_lua_particle_system.cpp b/src/lua/modules/graphics/je_lua_particle_system.cpp index 05be4b7..0b348ad 100644 --- a/src/lua/modules/graphics/je_lua_particle_system.cpp +++ b/src/lua/modules/graphics/je_lua_particle_system.cpp @@ -19,12 +19,10 @@ namespace JinEngine const char* Jin_Lua_ParticleSystem = "ParticleSystem"; - typedef Shared<ParticleSystem>& SharedParticleSystem; - - LUA_IMPLEMENT inline SharedParticleSystem checkPS(lua_State* L) + LUA_IMPLEMENT inline ParticleSystem* checkPS(lua_State* L) { LuaObject* luaObj = luax_checkobject(L, 1, Jin_Lua_ParticleSystem); - return luaObj->getShared<ParticleSystem>(); + return luaObj->getObject<ParticleSystem>(); } LUA_IMPLEMENT int l_gc(lua_State* L) @@ -36,7 +34,7 @@ namespace JinEngine LUA_IMPLEMENT int l_update(lua_State* L) { - SharedParticleSystem ps = checkPS(L); + ParticleSystem* ps = checkPS(L); float dt = luax_checknumber(L, 2); ps->update(dt); return 0; @@ -44,14 +42,14 @@ namespace JinEngine LUA_IMPLEMENT int l_render(lua_State* L) { - SharedParticleSystem ps = checkPS(L); + ParticleSystem* ps = checkPS(L); ps->render(); return 0; } LUA_IMPLEMENT int l_setPosition(lua_State* L) { - SharedParticleSystem ps = checkPS(L); + ParticleSystem* ps = checkPS(L); float x = luax_checknumber(L, 2); float y = luax_checknumber(L, 3); ps->setPosition(x, y); @@ -60,7 +58,7 @@ namespace JinEngine LUA_IMPLEMENT int l_setScale(lua_State* L) { - SharedParticleSystem ps = checkPS(L); + ParticleSystem* ps = checkPS(L); float sx = luax_checknumber(L, 2); float sy = luax_checknumber(L, 3); //ps->setScale(sx, sy); @@ -69,7 +67,7 @@ namespace JinEngine LUA_IMPLEMENT int l_pause(lua_State* L) { - SharedParticleSystem ps = checkPS(L); + ParticleSystem* ps = checkPS(L); bool b = luax_checkbool(L, 2); //ps->pause(b); return 0; @@ -77,14 +75,14 @@ namespace JinEngine LUA_IMPLEMENT int l_clear(lua_State* L) { - SharedParticleSystem ps = checkPS(L); + ParticleSystem* ps = checkPS(L); //ps->clear(); return 0; } LUA_IMPLEMENT int l_setEmitRate(lua_State* L) { - SharedParticleSystem ps = checkPS(L); + ParticleSystem* ps = checkPS(L); if (luax_gettop(L) >= 3) { float floor = luax_checknumber(L, 2); @@ -101,7 +99,7 @@ namespace JinEngine LUA_IMPLEMENT int l_setEmitForce(lua_State* L) { - SharedParticleSystem ps = checkPS(L); + ParticleSystem* ps = checkPS(L); if (luax_gettop(L) >= 3) { float floor = luax_checknumber(L, 2); @@ -118,7 +116,7 @@ namespace JinEngine LUA_IMPLEMENT int l_setEmitDirection(lua_State* L) { - SharedParticleSystem ps = checkPS(L); + ParticleSystem* ps = checkPS(L); if (luax_gettop(L) >= 3) { float floor = luax_checknumber(L, 2); @@ -135,7 +133,7 @@ namespace JinEngine LUA_IMPLEMENT int l_setEmitPosition(lua_State* L) { - SharedParticleSystem ps = checkPS(L); + ParticleSystem* ps = checkPS(L); if (luax_gettop(L) >= 3) { if (!luax_istable(L, 2)) @@ -172,7 +170,7 @@ namespace JinEngine LUA_IMPLEMENT int l_setParticleLife(lua_State* L) { - SharedParticleSystem ps = checkPS(L); + ParticleSystem* ps = checkPS(L); if (luax_gettop(L) >= 3) { float floor = luax_checknumber(L, 2); @@ -189,7 +187,7 @@ namespace JinEngine LUA_IMPLEMENT int l_setParticleLinearAccelaration(lua_State* L) { - SharedParticleSystem ps = checkPS(L); + ParticleSystem* ps = checkPS(L); if (!luax_istable(L, 2)) { luax_typerror(L, 2, "table"); @@ -204,7 +202,7 @@ namespace JinEngine LUA_IMPLEMENT int l_setParticleRadialAccelaration(lua_State* L) { - SharedParticleSystem ps = checkPS(L); + ParticleSystem* ps = checkPS(L); float ra = luax_checknumber(L, 2); ps->setParticleRadialAccelaration(ra); return 0; @@ -212,7 +210,7 @@ namespace JinEngine LUA_IMPLEMENT int l_setParticleAngularSpeed(lua_State* L) { - SharedParticleSystem ps = checkPS(L); + ParticleSystem* ps = checkPS(L); if (luax_gettop(L) >= 3) { float floor = luax_checknumber(L, 2); @@ -229,7 +227,7 @@ namespace JinEngine LUA_IMPLEMENT int l_setParticleSpritesMode(lua_State* L) { - SharedParticleSystem ps = checkPS(L); + ParticleSystem* ps = checkPS(L); int n = luax_checkinteger(L, 2); SpriteMode mode = static_cast<SpriteMode>(n); ps->setParticleSpritesMode(mode); @@ -239,7 +237,7 @@ namespace JinEngine LUA_IMPLEMENT int l_addParticleSprite(lua_State* L) { LuaObject* obj = luax_checkobject(L, 1, Jin_Lua_ParticleSystem); - SharedParticleSystem ps = obj->getShared<ParticleSystem>(); + ParticleSystem* ps = obj->getObject<ParticleSystem>(); LuaObject* objSpr = luax_checkobject(L, 2, Jin_Lua_Sprite); Sprite* spr = objSpr->getObject<Sprite>(); ps->addParticleSprite(spr); @@ -251,7 +249,7 @@ namespace JinEngine LUA_IMPLEMENT int l_addParticleSprites(lua_State* L) { LuaObject* obj = luax_checkobject(L, 1, Jin_Lua_ParticleSystem); - SharedParticleSystem ps = obj->getShared<ParticleSystem>(); + ParticleSystem* ps = obj->getObject<ParticleSystem>(); if (!luax_istable(L, 2)) { luax_typerror(L, 2, "sprites table"); @@ -275,7 +273,7 @@ namespace JinEngine LUA_IMPLEMENT int l_removeParticleSprite(lua_State* L) { LuaObject* obj = luax_checkobject(L, 1, Jin_Lua_ParticleSystem); - SharedParticleSystem ps = obj->getShared<ParticleSystem>(); + ParticleSystem* ps = obj->getObject<ParticleSystem>(); int n = luax_checkinteger(L, 2); ps->removeParticleSprite(n); (*obj).removeDependency((int)ParticleSystemDependency::DEP_SPRITES + n); @@ -284,7 +282,7 @@ namespace JinEngine LUA_IMPLEMENT int l_enableParticleBlendAdditive(lua_State* L) { - SharedParticleSystem ps = checkPS(L); + ParticleSystem* ps = checkPS(L); bool enable = luax_checkbool(L, 2); ps->enableParticleBlendAdditive(enable); return 0; @@ -292,7 +290,7 @@ namespace JinEngine LUA_IMPLEMENT int l_setParticleScale(lua_State* L) { - SharedParticleSystem ps = checkPS(L); + ParticleSystem* ps = checkPS(L); float scale = luax_checknumber(L, 2); ps->setParticleScale(scale); return 0; @@ -300,7 +298,7 @@ namespace JinEngine LUA_IMPLEMENT int l_addParticleScalePoint(lua_State* L) { - SharedParticleSystem ps = checkPS(L); + ParticleSystem* ps = checkPS(L); float scale = luax_checknumber(L, 2); float t = luax_checknumber(L, 3); ps->addParticleScalePoint(scale, t); @@ -309,7 +307,7 @@ namespace JinEngine LUA_IMPLEMENT int l_removeParticleScalePoint(lua_State* L) { - SharedParticleSystem ps = checkPS(L); + ParticleSystem* ps = checkPS(L); int i = luax_checkinteger(L, 2); ps->removeParticleScalePoint(i); return 0; @@ -317,7 +315,7 @@ namespace JinEngine LUA_IMPLEMENT int l_setParticleColor(lua_State* L) { - SharedParticleSystem ps = checkPS(L); + ParticleSystem* ps = checkPS(L); if (!luax_istable(L, 2)) { luax_typerror(L, 2, "color table"); @@ -334,7 +332,7 @@ namespace JinEngine LUA_IMPLEMENT int l_addParticleColorPoint(lua_State* L) { - SharedParticleSystem ps = checkPS(L); + ParticleSystem* ps = checkPS(L); if (!luax_istable(L, 2)) { luax_typerror(L, 2, "color table"); @@ -352,7 +350,7 @@ namespace JinEngine LUA_IMPLEMENT int l_removeParticleColorPoint(lua_State* L) { - SharedParticleSystem ps = checkPS(L); + ParticleSystem* ps = checkPS(L); int i = luax_checkinteger(L, 2); ps->removeParticleColorPoint(i); return 0; @@ -360,7 +358,7 @@ namespace JinEngine LUA_IMPLEMENT int l_setParticleTransparency(lua_State* L) { - SharedParticleSystem ps = checkPS(L); + ParticleSystem* ps = checkPS(L); float transparency = luax_checknumber(L, 2); ps->setParticleTransparency(transparency); return 0; @@ -368,7 +366,7 @@ namespace JinEngine LUA_IMPLEMENT int l_addParticleTransparencyPoint(lua_State* L) { - SharedParticleSystem ps = checkPS(L); + ParticleSystem* ps = checkPS(L); float transparency = luax_checknumber(L, 2); float t = luax_checknumber(L, 3); ps->addParticleTransparencyPoint(transparency, t); @@ -377,7 +375,7 @@ namespace JinEngine LUA_IMPLEMENT int l_removeParticleTransparencyPoint(lua_State* L) { - SharedParticleSystem ps = checkPS(L); + ParticleSystem* ps = checkPS(L); int i = luax_checkinteger(L, 2); ps->removeParticleTransparencyPoint(i); return 0; diff --git a/src/lua/modules/graphics/je_lua_shader.cpp b/src/lua/modules/graphics/je_lua_shader.cpp index f4a4231..9505444 100644 --- a/src/lua/modules/graphics/je_lua_shader.cpp +++ b/src/lua/modules/graphics/je_lua_shader.cpp @@ -16,12 +16,10 @@ namespace JinEngine const char* Jin_Lua_Shader = "Shader"; - typedef Shared<Shader>& ShaderRef; - - static inline ShaderRef checkShader(lua_State* L) + static inline Shader* checkShader(lua_State* L) { LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Shader); - return luaObj->getShared<Shader>(); + return luaObj->getObject<Shader>(); } /** @@ -29,36 +27,34 @@ namespace JinEngine */ LUA_IMPLEMENT int l_sendNumber(lua_State* L) { - ShaderRef shared = checkShader(L); + Shader* shader = checkShader(L); const char* variable = luax_checkstring(L, 2); float number = luax_checknumber(L, 3); - shared->sendFloat(variable, number); + shader->sendFloat(variable, number); return 0; } LUA_IMPLEMENT int l_sendTexture(lua_State* L) { - ShaderRef shared = checkShader(L); + Shader* shader = checkShader(L); const char* variable = luax_checkstring(L, 2); LuaObject* luaObj = (LuaObject*)luax_checktype(L, 3, Jin_Lua_Texture); - Shared<Texture>& tex = luaObj->getShared<Texture>(); - shared->sendTexture(variable, tex.getObject()); + shader->sendTexture(variable, luaObj->getObject<Texture>()); return 0; } LUA_IMPLEMENT int l_sendCanvas(lua_State* L) { - ShaderRef shared = checkShader(L); + Shader* shader = checkShader(L); const char* variable = luax_checkstring(L, 2); LuaObject* luaObj = (LuaObject*)luax_checktype(L, 3, Jin_Lua_Canvas); - Shared<Canvas>& canvas = luaObj->getShared<Canvas>(); - shared->sendCanvas(variable, canvas.getObject()); + shader->sendCanvas(variable, luaObj->getObject<Canvas>()); return 0; } LUA_IMPLEMENT int l_sendVec2(lua_State* L) { - ShaderRef shared = checkShader(L); + Shader* shader = checkShader(L); const char* variable = luax_checkstring(L, 2); if (!luax_istable(L, 3)) { @@ -67,13 +63,13 @@ namespace JinEngine } float x = luax_rawgetnumber(L, 3, 1); float y = luax_rawgetnumber(L, 3, 2); - shared->sendVec2(variable, x, y); + shader->sendVec2(variable, x, y); return 0; } LUA_IMPLEMENT int l_sendVec3(lua_State* L) { - ShaderRef shared = checkShader(L); + Shader* shader = checkShader(L); const char* variable = luax_checkstring(L, 2); if (!luax_istable(L, 3)) { @@ -83,13 +79,13 @@ namespace JinEngine float x = luax_rawgetnumber(L, 3, 1); float y = luax_rawgetnumber(L, 3, 2); float z = luax_rawgetnumber(L, 3, 3); - shared->sendVec3(variable, x, y, z); + shader->sendVec3(variable, x, y, z); return 0; } LUA_IMPLEMENT int l_sendVec4(lua_State* L) { - ShaderRef shared = checkShader(L); + Shader* shader = checkShader(L); const char* variable = luax_checkstring(L, 2); if (!luax_istable(L, 3)) { @@ -100,7 +96,7 @@ namespace JinEngine float y = luax_rawgetnumber(L, 3, 2); float z = luax_rawgetnumber(L, 3, 3); float w = luax_rawgetnumber(L, 3, 4); - shared->sendVec4(variable, x, y, z, w); + shader->sendVec4(variable, x, y, z, w); return 0; } diff --git a/src/lua/modules/graphics/je_lua_sprite.cpp b/src/lua/modules/graphics/je_lua_sprite.cpp index f9f8b5d..f1bc6aa 100644 --- a/src/lua/modules/graphics/je_lua_sprite.cpp +++ b/src/lua/modules/graphics/je_lua_sprite.cpp @@ -17,12 +17,10 @@ namespace JinEngine { const char* Jin_Lua_Sprite = "Sprite"; - typedef Shared<Sprite>& SharedSprite; - - LUA_IMPLEMENT inline SharedSprite checkSprite(lua_State* L) + LUA_IMPLEMENT inline Sprite* checkSprite(lua_State* L) { LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Sprite); - return luaObj->getShared<Sprite>(); + return luaObj->getObject<Sprite>(); } LUA_IMPLEMENT int l_gc(lua_State* L) @@ -34,7 +32,7 @@ namespace JinEngine LUA_IMPLEMENT int l_render(lua_State* L) { - SharedSprite sprite = checkSprite(L); + Sprite* sprite = checkSprite(L); float x = luax_checknumber(L, 2); float y = luax_checknumber(L, 3); float sx = luax_checknumber(L, 4); @@ -46,7 +44,7 @@ namespace JinEngine LUA_IMPLEMENT int l_getSize(lua_State* L) { - SharedSprite sprite = checkSprite(L); + Sprite* sprite = checkSprite(L); Vector2<int> size = sprite->getSize(); luax_pushinteger(L, size.x); luax_pushinteger(L, size.y); diff --git a/src/lua/modules/graphics/je_lua_spritesheet.cpp b/src/lua/modules/graphics/je_lua_spritesheet.cpp index 23b655e..0cfdb93 100644 --- a/src/lua/modules/graphics/je_lua_spritesheet.cpp +++ b/src/lua/modules/graphics/je_lua_spritesheet.cpp @@ -27,7 +27,6 @@ namespace JinEngine LUA_IMPLEMENT int l_newSprite(lua_State* L) { LuaObject* luaSSheet = (LuaObject*)luax_checktype(L, 1, Jin_Lua_SpriteSheet); - Shared<SpriteSheet>& shrSSheet = luaSSheet->getShared<SpriteSheet>(); SpriteSheet* sheet = luaSSheet->getObject<SpriteSheet>(); Quad quad; quad.x = luax_rawgetnumberthenpop(L, 2, 1); @@ -48,9 +47,9 @@ namespace JinEngine origin = static_cast<Origin>(o); spr = sheet->createSprite(quad, origin); } - Shared<Sprite>* shrSprite = new Shared<Sprite>(spr, Jin_Lua_Sprite); + Shared* shrSprite = new Shared(spr, Jin_Lua_Sprite); LuaObject* luaSprite = luax_newinstance(L, Jin_Lua_Sprite, shrSprite); - luaSprite->setDependency((int)SpriteDependency::DEP_SPRITESHEET, &shrSSheet); + luaSprite->setDependency((int)SpriteDependency::DEP_SPRITESHEET, luaSSheet->getShared()); return 1; } @@ -58,7 +57,6 @@ namespace JinEngine LUA_IMPLEMENT int l_newSprites(lua_State* L) { LuaObject* luaSS = (LuaObject*)luax_checktype(L, 1, Jin_Lua_SpriteSheet); - Shared<SpriteSheet>& shrSS = luaSS->getShared<SpriteSheet>(); SpriteSheet* ss = luaSS->getObject<SpriteSheet>(); int count = luax_checkinteger(L, 2); int r = luax_checkinteger(L, 3); @@ -93,11 +91,11 @@ namespace JinEngine return 1; } luax_newtable(L); - SharedBase* shrGraphic = luaSS->getDependency((int)SpriteSheetDependency::DEP_GRAPHIC); + Shared* shrGraphic = luaSS->getDependency((int)SpriteSheetDependency::DEP_GRAPHIC); for (int i = 0; i < sprs.size(); ++i) { Sprite* spr = sprs[i]; - Shared<Sprite>* shrSpr = new Shared<Sprite>(spr, Jin_Lua_Sprite); + Shared* shrSpr = new Shared(spr, Jin_Lua_Sprite); LuaObject* luaSpr = (LuaObject*)luax_newinstance(L, Jin_Lua_Sprite, shrSpr); luaSpr->setDependency((int)SpriteDependency::DEP_GRAPHIC, shrGraphic); luax_rawseti(L, -2, i + 1); diff --git a/src/lua/modules/graphics/je_lua_texture.cpp b/src/lua/modules/graphics/je_lua_texture.cpp index 9d2d567..7bac237 100644 --- a/src/lua/modules/graphics/je_lua_texture.cpp +++ b/src/lua/modules/graphics/je_lua_texture.cpp @@ -12,31 +12,29 @@ namespace JinEngine const char* Jin_Lua_Texture = "Texture"; - typedef Shared<Texture>& SharedTexture; - - LUA_IMPLEMENT inline SharedTexture checkTexture(lua_State* L) + LUA_IMPLEMENT inline Texture* checkTexture(lua_State* L) { LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Texture); - return luaObj->getShared<Texture>(); + return luaObj->getObject<Texture>(); } LUA_IMPLEMENT int l_getWidth(lua_State* L) { - SharedTexture shared = checkTexture(L); + Texture* shared = checkTexture(L); luax_pushnumber(L, shared->getWidth()); return 1; } LUA_IMPLEMENT int l_getHeight(lua_State *L) { - SharedTexture shared = checkTexture(L); + Texture* shared = checkTexture(L); luax_pushnumber(L, shared->getHeight()); return 1; } LUA_IMPLEMENT int l_getSize(lua_State* L) { - SharedTexture shared = checkTexture(L); + Texture* shared = checkTexture(L); luax_pushnumber(L, shared->getWidth()); luax_pushnumber(L, shared->getHeight()); return 2; diff --git a/src/lua/modules/graphics/je_lua_texture_font.cpp b/src/lua/modules/graphics/je_lua_texture_font.cpp index 8a3eca0..1365aa8 100644 --- a/src/lua/modules/graphics/je_lua_texture_font.cpp +++ b/src/lua/modules/graphics/je_lua_texture_font.cpp @@ -26,7 +26,6 @@ namespace JinEngine LUA_IMPLEMENT int l_typeset(lua_State* L) { LuaObject* luaTexFont = (LuaObject*)luax_checktype(L, 1, Jin_Lua_TextureFont); - Shared<TextureFont>& shrTexFont = luaTexFont->getShared<TextureFont>(); TextureFont* tf = luaTexFont->getObject<TextureFont>(); int lineheight = luax_checkinteger(L, 3); int spacing = luax_optnumber(L, 4, 0); @@ -44,9 +43,9 @@ namespace JinEngine Text* text = p2->getObject<Text>(); page = tf->typeset(*text, lineheight, spacing); } - Shared<Page>* shrPage = new Shared<Page>(page, Jin_Lua_Page); + Shared* shrPage = new Shared(page, Jin_Lua_Page); LuaObject* luaPage = luax_newinstance(L, Jin_Lua_Page, shrPage); - luaPage->setDependency((int)PageDependency::DEP_TEXTURE_FONT, &shrTexFont); + luaPage->setDependency((int)PageDependency::DEP_TEXTURE_FONT, luaTexFont->getShared()); return 1; } diff --git a/src/lua/modules/graphics/je_lua_ttf.cpp b/src/lua/modules/graphics/je_lua_ttf.cpp index 317670c..ad1872f 100644 --- a/src/lua/modules/graphics/je_lua_ttf.cpp +++ b/src/lua/modules/graphics/je_lua_ttf.cpp @@ -26,7 +26,6 @@ namespace JinEngine LUA_IMPLEMENT int l_typeset(lua_State* L) { LuaObject* luaTTF = (LuaObject*)luax_checktype(L, 1, Jin_Lua_TTF); - Shared<TTF>& shrTTF = luaTTF->getShared<TTF>(); TTF* ttf = luaTTF->getObject<TTF>(); int lineheight = luax_optnumber(L, 3, ttf->getFontSize()); int spacing = luax_optnumber(L, 4, 0); @@ -44,9 +43,9 @@ namespace JinEngine Text* text = luaText->getObject<Text>(); page = ttf->typeset(*text, lineheight, spacing); } - Shared<Page>* refPage = new Shared<Page>(page, Jin_Lua_Page); + Shared* refPage = new Shared(page, Jin_Lua_Page); LuaObject* luaPage = luax_newinstance(L, Jin_Lua_Page, refPage); - luaPage->setDependency((int)PageDependency::DEP_TTF, &shrTTF); + luaPage->setDependency((int)PageDependency::DEP_TTF, luaTTF->getShared()); 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 9f4437e..b10b993 100644 --- a/src/lua/modules/graphics/je_lua_ttf_data.cpp +++ b/src/lua/modules/graphics/je_lua_ttf_data.cpp @@ -19,12 +19,11 @@ namespace JinEngine { LuaObject* luaTTFData = (LuaObject*)luax_checktype(L, 1, Jin_Lua_TTFData); int fontsize = luax_checkinteger(L, 2); - Shared<TTFData>& shrFontData = luaTTFData->getShared<TTFData>(); - TTFData* fontData = shrFontData.getObject(); + TTFData* fontData = luaTTFData->getObject<TTFData>(); TTF* font = fontData->createTTF(fontsize); - Shared<TTF>* shrTTF = new Shared<TTF>(font, Jin_Lua_TTF); + Shared* shrTTF = new Shared(font, Jin_Lua_TTF); LuaObject* luaTTF = luax_newinstance(L, Jin_Lua_TTF, shrTTF); - luaTTF->setDependency((int)TTFDependency::DEP_TTFDATA, &shrFontData); + luaTTF->setDependency((int)TTFDependency::DEP_TTFDATA, luaTTFData->getShared()); return 1; } diff --git a/src/lua/modules/net/je_lua_buffer.cpp b/src/lua/modules/net/je_lua_buffer.cpp index 327e7ed..dcfdf01 100644 --- a/src/lua/modules/net/je_lua_buffer.cpp +++ b/src/lua/modules/net/je_lua_buffer.cpp @@ -3,6 +3,8 @@ #include "libjin/jin.h" #include "je_lua_buffer.h" +using namespace JinEngine::Lua::Net; + namespace JinEngine { namespace Lua @@ -10,24 +12,22 @@ namespace JinEngine const char* Jin_Lua_Buffer = "Buffer"; - typedef Shared<Net::Buffer>& SharedBuffer; - - static inline SharedBuffer checkNetBuffer(lua_State* L) + static inline Net::Buffer* checkNetBuffer(lua_State* L) { LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Buffer); - return luaObj->getShared<Net::Buffer>(); + return luaObj->getObject<Net::Buffer>(); } // net.Buffer:append(value) -> value_length LUA_IMPLEMENT int l_append(lua_State* L) { - SharedBuffer shared = checkNetBuffer(L); + Buffer* buffer = checkNetBuffer(L); const int vp = 2; if (luax_isintegerstrict(L, vp)) { int n = luax_checkinteger(L, vp); int size = sizeof(n); - shared->append(&n, size); + buffer->append(&n, size); luax_pushinteger(L, size); return 1; } @@ -35,7 +35,7 @@ namespace JinEngine { float n = luax_checknumber(L, vp); int size = sizeof(n); - shared->append(&n, size); + buffer->append(&n, size); luax_pushinteger(L, size); return 1; } @@ -43,7 +43,7 @@ namespace JinEngine { bool n = luax_checkbool(L, vp); int size = sizeof(n); - shared->append(&n, size); + buffer->append(&n, size); luax_pushinteger(L, size); return 1; } @@ -51,7 +51,7 @@ namespace JinEngine { const char* str = luax_checkstring(L, vp); int size = strlen(str) + 1; - shared->append(str, size); + buffer->append(str, size); luax_pushinteger(L, size); return 1; } @@ -65,10 +65,10 @@ namespace JinEngine // net.Buffer:grabString(offset) -> string, length LUA_IMPLEMENT int l_grabString(lua_State* L) { - SharedBuffer shared = checkNetBuffer(L); + Buffer* buffer = checkNetBuffer(L); int offset = luax_checkinteger(L, 2); unsigned int len; - char* data = shared->grabString(&len, offset); + char* data = buffer->grabString(&len, offset); Array<char> str; str.bind(data, len); luax_pushstring(L, &str); @@ -79,10 +79,10 @@ namespace JinEngine // net.Buffer:grabInteger(offset) -> integer, length LUA_IMPLEMENT int l_grabInteger(lua_State* L) { - SharedBuffer shared = checkNetBuffer(L); + Buffer* buffer = checkNetBuffer(L); int offset = luax_checkinteger(L, 2); int len; - int integer = shared->grabInteger(&len, offset); + int integer = buffer->grabInteger(&len, offset); luax_pushinteger(L, integer); luax_pushinteger(L, len); return 2; @@ -90,10 +90,10 @@ namespace JinEngine LUA_IMPLEMENT int l_grabFloat(lua_State* L) { - SharedBuffer shared = checkNetBuffer(L); + Buffer* buffer = checkNetBuffer(L); int offset = luax_checkinteger(L, 2); int len; - float floatv = shared->grabFloat(&len, offset); + float floatv = buffer->grabFloat(&len, offset); luax_pushnumber(L, floatv); luax_pushinteger(L, len); return 2; @@ -101,10 +101,10 @@ namespace JinEngine LUA_IMPLEMENT int l_grabBoolean(lua_State* L) { - SharedBuffer shared = checkNetBuffer(L); + Buffer* buffer = checkNetBuffer(L); int offset = luax_checkinteger(L, 2); int len; - bool boolean = shared->grabBoolean(&len, offset); + bool boolean = buffer->grabBoolean(&len, offset); luax_pushboolean(L, boolean); luax_pushinteger(L, len); return 2; diff --git a/src/lua/modules/net/je_lua_buffer.h b/src/lua/modules/net/je_lua_buffer.h index 7584f47..974e23a 100644 --- a/src/lua/modules/net/je_lua_buffer.h +++ b/src/lua/modules/net/je_lua_buffer.h @@ -17,7 +17,7 @@ namespace JinEngine namespace Net { - class Buffer + class Buffer : public Object { public: Buffer(size_t s = 0) diff --git a/src/lua/modules/net/je_lua_net.cpp b/src/lua/modules/net/je_lua_net.cpp index 5db4722..d003640 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>(socket, Jin_Lua_Socket)); + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Socket, new Shared(socket, Jin_Lua_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>(buffer, Jin_Lua_Buffer)); + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Buffer, new Shared(buffer, Jin_Lua_Buffer)); return 1; } diff --git a/src/lua/modules/net/je_lua_socket.cpp b/src/lua/modules/net/je_lua_socket.cpp index 8eb4051..af0cef0 100644 --- a/src/lua/modules/net/je_lua_socket.cpp +++ b/src/lua/modules/net/je_lua_socket.cpp @@ -13,61 +13,59 @@ namespace JinEngine const char* Jin_Lua_Socket = "Socket"; - typedef Shared<Socket>& SharedSocket; - const int BUFFER_SIZE = 1024; - LUA_IMPLEMENT inline SharedSocket checkSocket(lua_State* L, int pos = 1) + LUA_IMPLEMENT inline Socket* checkSocket(lua_State* L, int pos = 1) { LuaObject* luaObj = (LuaObject*)luax_checktype(L, pos, Jin_Lua_Socket); - return luaObj->getShared<Socket>(); + return luaObj->getObject<Socket>(); } - LUA_IMPLEMENT inline Shared<Buffer>& checkNetBuffer(lua_State* L, int pos = 1) + LUA_IMPLEMENT inline Buffer* checkNetBuffer(lua_State* L, int pos = 1) { LuaObject* luaObj = (LuaObject*)luax_checktype(L, pos, Jin_Lua_Buffer); - return luaObj->getShared<Buffer>(); + return luaObj->getObject<Buffer>(); } // return net.Socket LUA_IMPLEMENT int l_accept(lua_State* L) { - SharedSocket socket = checkSocket(L); + Socket* socket = checkSocket(L); Socket* client = socket->accept(); - LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Socket, new Shared<Socket>(client, Jin_Lua_Socket)); + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Socket, new Shared(client, Jin_Lua_Socket)); return 1; } // return net.Buffer LUA_IMPLEMENT int l_receive(lua_State* L) { - SharedSocket socket = checkSocket(L); + Socket* socket = checkSocket(L); 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<Buffer>(netBuffer, Jin_Lua_Buffer)); + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Buffer, new Shared(netBuffer, Jin_Lua_Buffer)); return 1; } // Socket:receiveFrom(address, port) LUA_IMPLEMENT int l_receiveFrom(lua_State* L) { - SharedSocket socket = checkSocket(L); + Socket* socket = checkSocket(L); int address = luax_checkinteger(L, 2); int port = luax_checkinteger(L, 3); 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<Buffer>(netBuffer, Jin_Lua_Buffer)); + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Buffer, new Shared(netBuffer, Jin_Lua_Buffer)); return 1; } // Socket:send(net.Buffer) -> data_length LUA_IMPLEMENT int l_send(lua_State* L) { - SharedSocket socket = checkSocket(L); - Shared<Buffer>& shared = checkNetBuffer(L, 2); - int len = socket->send(shared->buffer, shared->size); + Socket* socket = checkSocket(L); + Buffer* buffer = checkNetBuffer(L, 2); + int len = socket->send(buffer->buffer, buffer->size); luax_pushinteger(L, len); return 1; } @@ -75,24 +73,24 @@ namespace JinEngine // Socket:sendTo(address, port, net.Buffer) LUA_IMPLEMENT int l_sendTo(lua_State* L) { - SharedSocket socket = checkSocket(L); + Socket* socket = checkSocket(L); int address = luax_checkinteger(L, 2); int port = luax_checkinteger(L, 3); - Shared<Buffer>& buffer = checkNetBuffer(L, 4); + Buffer* buffer = checkNetBuffer(L, 4); socket->sendTo(buffer->buffer, buffer->size, address, port); return 0; } LUA_IMPLEMENT int l_close(lua_State* L) { - SharedSocket socket = checkSocket(L); + Socket* socket = checkSocket(L); socket->close(); return 0; } LUA_IMPLEMENT int l_configBlocking(lua_State* L) { - SharedSocket socket = checkSocket(L); + Socket* socket = checkSocket(L); bool blocking = luax_checkbool(L, 2); socket->configureBlocking(blocking); return 0; diff --git a/src/lua/modules/thread/je_lua_thread.cpp b/src/lua/modules/thread/je_lua_thread.cpp index 566d0ff..35bf876 100644 --- a/src/lua/modules/thread/je_lua_thread.cpp +++ b/src/lua/modules/thread/je_lua_thread.cpp @@ -12,26 +12,25 @@ namespace JinEngine const char* Jin_Lua_Thread = "Thread"; - typedef Shared<Thread>& SharedThread; - int luaopen_thread(lua_State* L); - static inline SharedThread checkThread(lua_State* L) + static inline Thread* checkThread(lua_State* L) { LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Thread); - return luaObj->getShared<Thread>(); + return luaObj->getObject<Thread>(); } LUA_IMPLEMENT int threadRunner(void* t) { - SharedThread shared = *(Shared<Thread>*)t; + Shared* shared = (Shared*)t; + Thread* thread = shared->getObject<Thread>(); lua_State* L = lua_open(); luax_openlibs(L); open(L); luax_getglobal(L, MODULE_NAME); - LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Thread, &shared); + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Thread, shared); luax_setfield(L, -2, "_curThread"); - luax_dostring(L, shared->code.c_str()); + luax_dostring(L, thread->code.c_str()); luax_close(L); return 0; } @@ -45,7 +44,7 @@ namespace JinEngine LUA_IMPLEMENT int l_start(lua_State* L) { - SharedThread shared = checkThread(L); + Thread* shared = checkThread(L); bool result = shared->start(&shared); luax_pushboolean(L, result); return 1; @@ -53,14 +52,14 @@ namespace JinEngine LUA_IMPLEMENT int l_wait(lua_State* L) { - SharedThread shared = checkThread(L); + Thread* shared = checkThread(L); shared->wait(); return 0; } LUA_IMPLEMENT int l_send(lua_State* L) { - SharedThread shared = checkThread(L); + Thread* shared = checkThread(L); int slot = luax_checkinteger(L, 2); const int vp = 3; if (luax_isnumberstrict(L, vp)) @@ -93,7 +92,7 @@ namespace JinEngine LUA_IMPLEMENT int l_receive(lua_State* L) { - SharedThread shared = checkThread(L); + Thread* shared = checkThread(L); int slot = luax_checkinteger(L, 2); bool result = shared->receive(slot); luax_pushboolean(L, result); @@ -102,7 +101,7 @@ namespace JinEngine LUA_IMPLEMENT int l_fetch(lua_State* L) { - SharedThread shared = checkThread(L); + Thread* shared = checkThread(L); int slot = luax_checkinteger(L, 2); Thread::Variant v = shared->fetch(slot); switch (v.type) @@ -135,7 +134,7 @@ namespace JinEngine LUA_IMPLEMENT int l_demand(lua_State* L) { - SharedThread shared = checkThread(L); + Thread* shared = checkThread(L); int slot = luax_checkinteger(L, 2); Thread::Variant v = shared->demand(slot); switch (v.type) @@ -168,7 +167,7 @@ namespace JinEngine LUA_IMPLEMENT int l_remove(lua_State* L) { - SharedThread shared = checkThread(L); + Thread* shared = checkThread(L); int slot = luax_checkinteger(L, 2); shared->remove(slot); return 0; @@ -176,7 +175,7 @@ namespace JinEngine LUA_IMPLEMENT int l_getName(lua_State* L) { - SharedThread shared = checkThread(L); + Thread* shared = checkThread(L); const char* name = shared->getName(); luax_pushstring(L, name); return 1; @@ -184,7 +183,7 @@ namespace JinEngine LUA_IMPLEMENT int l_isRunning(lua_State* L) { - SharedThread shared = checkThread(L); + Thread* shared = checkThread(L); bool running = shared->isRunning(); luax_pushboolean(L, running); return 1; @@ -214,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>(thread, Jin_Lua_Thread)); + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Thread, new Shared(thread, Jin_Lua_Thread)); return 1; } diff --git a/src/lua/modules/thread/je_lua_thread.h b/src/lua/modules/thread/je_lua_thread.h index 396cf5b..9978d35 100644 --- a/src/lua/modules/thread/je_lua_thread.h +++ b/src/lua/modules/thread/je_lua_thread.h @@ -8,7 +8,7 @@ namespace JinEngine extern const char* Jin_Lua_Thread; - class Thread + class Thread : public Object { public: typedef JinEngine::Threads::Thread::Variant Variant; diff --git a/src/lua/modules/time/je_lua_time.cpp b/src/lua/modules/time/je_lua_time.cpp index 3da5669..1d8b852 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<Timer>* shrTimer = new Shared<Timer>(new Timer(), Jin_Lua_Timer); + Shared* shrTimer = new Shared(new Timer(), Jin_Lua_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 5516be0..f689277 100644 --- a/src/lua/modules/time/je_lua_timer.cpp +++ b/src/lua/modules/time/je_lua_timer.cpp @@ -13,8 +13,6 @@ namespace JinEngine const char* Jin_Lua_Handler = "Handler"; - typedef Shared<Timer>& SharedTimer; - static Timer::TimerCallback timerCallback = [](void* data)->void { LuaCallback* func = static_cast<LuaCallback*>(data); @@ -27,24 +25,24 @@ namespace JinEngine delete func; }; - LUA_IMPLEMENT inline SharedTimer checkTimer(lua_State* L) + LUA_IMPLEMENT inline Timer* checkTimer(lua_State* L) { LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Timer); - return luaObj->getShared<Timer>(); + return luaObj->getObject<Timer>(); } // timer:every(time, callback, parameter) LUA_IMPLEMENT int l_every(lua_State* L) { int n = luax_gettop(L); - SharedTimer shared = checkTimer(L); + Timer* shared = checkTimer(L); float s = luax_checknumber(L, 2); LuaCallback* func = new LuaCallback(L); func->setFunc(3); for(int i = 4; i <= n; ++i) func->pushParam(i); Timer::Handler* handler = shared->every(s, timerCallback, func, finishCallback); - Shared<Timer::Handler>* shrHandler = new Shared<Timer::Handler>(handler, Jin_Lua_Handler); + Shared* shrHandler = new Shared(handler, Jin_Lua_Handler); LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Handler, shrHandler); return 1; } @@ -53,14 +51,14 @@ namespace JinEngine LUA_IMPLEMENT int l_after(lua_State* L) { int n = luax_gettop(L); - SharedTimer shared = checkTimer(L); + Timer* shared = checkTimer(L); float s = luax_checknumber(L, 2); LuaCallback* func = new LuaCallback(L); func->setFunc(3); for (int i = 4; i <= n; ++i) func->pushParam(i); Timer::Handler* handler = shared->after(s, timerCallback, func, finishCallback); - Shared<Timer::Handler>* shrHandler = new Shared<Timer::Handler>(handler, Jin_Lua_Handler); + Shared* shrHandler = new Shared(handler, Jin_Lua_Handler); LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Handler, shrHandler); return 1; } @@ -69,7 +67,7 @@ namespace JinEngine LUA_IMPLEMENT int l_repeat(lua_State* L) { int n = luax_gettop(L); - SharedTimer shared = checkTimer(L); + Timer* shared = checkTimer(L); float s = luax_checknumber(L, 2); int count = luax_checkinteger(L, 3); LuaCallback* func = new LuaCallback(L); @@ -77,14 +75,14 @@ namespace JinEngine for (int i = 5; i <= n; ++i) func->pushParam(i); Timer::Handler* handler = shared->repeat(s, count, timerCallback, func, finishCallback); - Shared<Timer::Handler>* shrHandler = new Shared<Timer::Handler>(handler, Jin_Lua_Handler); + Shared* shrHandler = new Shared(handler, Jin_Lua_Handler); LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Handler, shrHandler); return 1; } LUA_IMPLEMENT int l_update(lua_State* L) { - SharedTimer shared = checkTimer(L); + Timer* shared = checkTimer(L); float s = luax_checknumber(L, 2); shared->update(s); return 0; |