aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin/Jin.exebin2312704 -> 2316800 bytes
-rw-r--r--bin/SDL2.dllbin1242112 -> 1242112 bytes
-rw-r--r--bin/game/config.lua1
-rw-r--r--bin/game/main.lua22
-rw-r--r--examples/animation/main.cpp2
-rw-r--r--examples/particle_system/main.cpp20
-rw-r--r--src/3rdparty/buildvm/buildvm.exebin123392 -> 121856 bytes
-rw-r--r--src/3rdparty/minilua/minilua.exebin219136 -> 209920 bytes
-rw-r--r--src/lua/common/je_lua.cpp78
-rw-r--r--src/lua/common/je_lua.h19
-rw-r--r--src/lua/common/je_lua_common.h3
-rw-r--r--src/lua/common/je_lua_shared.hpp5
-rw-r--r--src/lua/jin.cpp2
-rw-r--r--src/lua/jin.h8
-rw-r--r--src/lua/libraries/luax/luax.h3
-rw-r--r--src/lua/modules/graphics/je_lua_animation.cpp1
-rw-r--r--src/lua/modules/graphics/je_lua_animator.cpp1
-rw-r--r--src/lua/modules/graphics/je_lua_canvas.cpp1
-rw-r--r--src/lua/modules/graphics/je_lua_graphics.cpp9
-rw-r--r--src/lua/modules/graphics/je_lua_page.cpp1
-rw-r--r--src/lua/modules/graphics/je_lua_shader.cpp1
-rw-r--r--src/lua/modules/graphics/je_lua_sprite.cpp1
-rw-r--r--src/lua/modules/graphics/je_lua_spritesheet.cpp8
-rw-r--r--src/lua/modules/graphics/je_lua_text.cpp1
-rw-r--r--src/lua/modules/graphics/je_lua_texture.cpp1
-rw-r--r--src/lua/modules/graphics/je_lua_texture_font.cpp1
-rw-r--r--src/lua/modules/graphics/je_lua_ttf.cpp1
-rw-r--r--src/lua/modules/graphics/je_lua_ttf_data.cpp1
-rw-r--r--src/lua/modules/net/je_lua_buffer.cpp1
-rw-r--r--src/lua/modules/net/je_lua_net.cpp1
-rw-r--r--src/lua/modules/net/je_lua_socket.cpp1
-rw-r--r--src/lua/modules/time/je_lua_time.cpp4
-rw-r--r--src/lua/modules/time/je_lua_timer.cpp16
33 files changed, 129 insertions, 85 deletions
diff --git a/bin/Jin.exe b/bin/Jin.exe
index bf2ca52..3e4b361 100644
--- a/bin/Jin.exe
+++ b/bin/Jin.exe
Binary files differ
diff --git a/bin/SDL2.dll b/bin/SDL2.dll
index 2276718..00ae787 100644
--- a/bin/SDL2.dll
+++ b/bin/SDL2.dll
Binary files differ
diff --git a/bin/game/config.lua b/bin/game/config.lua
index 380dd1b..095ee28 100644
--- a/bin/game/config.lua
+++ b/bin/game/config.lua
@@ -2,4 +2,5 @@ return
{
title = "window form",
icon = "splash.png",
+ vsync = true
} \ No newline at end of file
diff --git a/bin/game/main.lua b/bin/game/main.lua
index 98f7bc7..b233272 100644
--- a/bin/game/main.lua
+++ b/bin/game/main.lua
@@ -56,7 +56,7 @@ local spr = nil
local function createAnimation(path, count, r, c, w, h, loop, speed)
local tex = jin.graphics.newTexture(path)
local ssheet = jin.graphics.newSpriteSheet(tex)
- local sprs = ssheet:newSprites(count, r, c, w, h, jin.graphics.SpriteOrigin.BOTTOMCENTER)
+ local sprs = ssheet:newSprites(count, r, c, w, h, 96, 168)
return jin.graphics.newAnimation(sprs, loop, speed)
end
@@ -66,15 +66,11 @@ function jin.core.onLoad()
end)
shader_program = jin.graphics.newShader(shader)
shader_program2 = jin.graphics.newShader(shader2)
- --tex = jin.graphics.newTexture("1.png")
- tex = jin.graphics.newTexture(bitmap)
- local tex2 = jin.graphics.newTexture("anim.png")
- local ssheet2 = jin.graphics.newSpriteSheet(tex2)
local animation = createAnimation("anim2.png", 27, 3, 10, 200, 200, true, 50)
animator = jin.graphics.newAnimator(animation)
- local ssheet = jin.graphics.newSpriteSheet(tex)
spr = animation:getFrame(1)
- tex = nil
+ local tex3 = jin.graphics.newTexture("anim2.png")
+ tex3 = nil
-- music = jin.audio.newSource("forest.ogg")
-- music:setVolume(0.5)
-- music:setLoop(true)
@@ -82,22 +78,18 @@ function jin.core.onLoad()
jin.graphics.clear()
jin.graphics.showWindow()
timer = jin.time.newTimer()
- local h = timer:every(0.5, function(sp)
-
- end, spr)
timer:every(3, function(p)
--timer:cancel(h)
if animator:getSpeed() == 50 then
animator:setSpeed(100)
elseif animator:getSpeed() == 100 then
animator:setSpeed(50)
- end
+ end
end, animator)
jin.graphics.pushMatrix()
jin.graphics.translate(0, 0)
--jin.graphics.rotate(0.2)
end
-local stop = false
function jin.core.onEvent(e)
if e.type == "Quit" then
@@ -105,14 +97,14 @@ function jin.core.onEvent(e)
end
end
-function jin.core.onUpdate()
+function jin.core.onUpdate()
tb.x = t
t = t + jin.time.getDelta()
animator:update(jin.time.getDelta())
+ timer:update(jin.time.getDelta())
end
function jin.core.onDraw()
- timer:update(jin.time.getDelta())
jin.graphics.useShader(shader_program)
jin.graphics.setColor(255, 0, 255, 255)
jin.graphics.rect(jin.graphics.RenderMode.FILL, 30, 50, 100, 200)
@@ -122,7 +114,7 @@ function jin.core.onDraw()
local x, y = jin.mouse.getPosition()
animator:render(x, y, 1, 1, 0)
jin.graphics.print(#sprs, 10, 10)
- jin.graphics.draw(spr, 100, 100, 1, 1, 0)
+ jin.graphics.draw(spr, 100, 200, 1, 1, 0)
--jin.graphics.useShader(shader_program2)
--jin.graphics.draw(tex, 0, 0,0.2, 0.2)
--jin.graphics.unuseShader()
diff --git a/examples/animation/main.cpp b/examples/animation/main.cpp
index 7d85c77..b5ad60f 100644
--- a/examples/animation/main.cpp
+++ b/examples/animation/main.cpp
@@ -41,7 +41,7 @@ void onLoad()
tex = Texture::createTexture("anim.png");
shader = Shader::createShader(shader_code);
SpriteSheet ss = SpriteSheet(tex);
- vector<Sprite*> frames = ss.createSprites(1, 19, 246, 238, Origin::BottomCenter);
+ vector<Sprite*> frames = ss.createSprites(19, 1, 19, 246, 238, Origin::BottomCenter);
anim.addFrames(frames);
anim.setSpeed(10);
animator.setAnimation(&anim);
diff --git a/examples/particle_system/main.cpp b/examples/particle_system/main.cpp
index 9251cc4..6ab3448 100644
--- a/examples/particle_system/main.cpp
+++ b/examples/particle_system/main.cpp
@@ -21,24 +21,24 @@ Shader* shader;
Sprite* spr;
const char* shader_code = R"(
#VERTEX_SHADER
-Vertex vert(Vertex v)
-{
- return v;
-}
+ Vertex vert(Vertex v)
+ {
+ return v;
+ }
#END_VERTEX_SHADER
#FRAGMENT_SHADER
-Color frag(Color col, Texture tex, Vertex v)
-{
- Color c = texel(tex, v.uv);
- return c * col;
-}
+ Color frag(Color col, Texture tex, Vertex v)
+ {
+ Color c = texel(tex, v.uv);
+ return c * col;
+ }
#END_FRAGMENT_SHADER
)";
const float Pi = 3.14f;
void onLoad()
{
tex = Texture::createTexture("texture.png");
- spr = new Sprite(tex, Sprite::Origin::BottomCenter);
+ spr = new Sprite(tex, Origin::BottomCenter);
shader = Shader::createShader(shader_code);
ParticleSystemDef def;
def.maxParticleCount = 30;
diff --git a/src/3rdparty/buildvm/buildvm.exe b/src/3rdparty/buildvm/buildvm.exe
index 32a8f53..d5ad537 100644
--- a/src/3rdparty/buildvm/buildvm.exe
+++ b/src/3rdparty/buildvm/buildvm.exe
Binary files differ
diff --git a/src/3rdparty/minilua/minilua.exe b/src/3rdparty/minilua/minilua.exe
index a245b88..44e9416 100644
--- a/src/3rdparty/minilua/minilua.exe
+++ b/src/3rdparty/minilua/minilua.exe
Binary files differ
diff --git a/src/lua/common/je_lua.cpp b/src/lua/common/je_lua.cpp
index 748606b..2011e15 100644
--- a/src/lua/common/je_lua.cpp
+++ b/src/lua/common/je_lua.cpp
@@ -5,6 +5,18 @@ namespace JinEngine
namespace Lua
{
+ lua_State * LuaState::mL = nullptr;
+
+ void LuaState::set(lua_State* L)
+ {
+ mL = L;
+ }
+
+ lua_State* LuaState::get()
+ {
+ return mL;
+ }
+
///
/// Lua objects table. Map object to proxy, like objects_table[object] = proxy.
///
@@ -33,45 +45,81 @@ namespace JinEngine
return proxy;
}
- int luax_getobject(lua_State* L, SharedBase* shadred)
+ int luax_getobject(lua_State* L, SharedBase* shared)
{
luax_getobjectstable(L);
- luax_pushlightuserdata(L, shadred);
+ luax_pushlightuserdata(L, shared);
luax_gettable(L, -2);
luax_remove(L, -2); // Remove objects table on stack.
return 1;
}
- int luax_getregistrytable(lua_State* L, const char* tbl)
+ void luax_removeobject(lua_State* L, SharedBase* shared)
{
- luax_getfield(L, LUA_REGISTRYINDEX, tbl);
+ luax_getobjectstable(L);
+ luax_pushlightuserdata(L, shared);
+ luax_pushnil(L);
+ luax_settable(L, -3);
+ luax_pop(L, 1);
+ }
+
+ int luax_getobjectstable(lua_State* L)
+ {
+ luax_getfield(L, LUA_REGISTRYINDEX, Jin_Lua_Objects_Table);
// If no such table, add one.
if (luax_isnil(L, -1) || !luax_istable(L, -1))
{
luax_pop(L, 1);
luax_newtable(L);
- luax_pushstring(L, tbl);
- luax_pushvalue(L, -2);
- luax_settable(L, LUA_REGISTRYINDEX);
- }
- return 1;
- }
- int luax_getobjectstable(lua_State* L)
- {
- luax_getregistrytable(L, Jin_Lua_Objects_Table);
+ // metatable
+ luax_newtable(L);
+ // weak table
+ luax_pushliteral(L, "v");
+ luax_setfield(L, -2, "__mode");
+ // setmetatable(newtable, metatable)
+ luax_setmetatable(L, -2);
+
+ luax_pushvalue(L, -1);
+ luax_setfield(L, LUA_REGISTRYINDEX, Jin_Lua_Objects_Table);
+ }
return 1;
}
int luax_getmodulestable(lua_State* L)
{
- luax_getregistrytable(L, Jin_Lua_Modules_Table);
+ luax_getfield(L, LUA_REGISTRYINDEX, Jin_Lua_Modules_Table);
+ // If no such table, add one.
+ if (luax_isnil(L, -1) || !luax_istable(L, -1))
+ {
+ luax_pop(L, 1);
+ luax_newtable(L);
+
+ // metatable
+ luax_newtable(L);
+ // weak table
+ luax_pushliteral(L, "v");
+ luax_setfield(L, -2, "__mode");
+ // setmetatable(newtable, metatable)
+ luax_setmetatable(L, -2);
+
+ luax_pushvalue(L, -1);
+ luax_setfield(L, LUA_REGISTRYINDEX, Jin_Lua_Modules_Table);
+ }
return 1;
}
int luax_getreferencestable(lua_State* L)
{
- luax_getregistrytable(L, Jin_Lua_Reference_Table);
+ luax_getfield(L, LUA_REGISTRYINDEX, Jin_Lua_Reference_Table);
+ // If no such table, add one.
+ if (luax_isnil(L, -1) || !luax_istable(L, -1))
+ {
+ luax_pop(L, 1);
+ luax_newtable(L);
+ luax_pushvalue(L, -1);
+ luax_setfield(L, LUA_REGISTRYINDEX, Jin_Lua_Reference_Table);
+ }
return 1;
}
diff --git a/src/lua/common/je_lua.h b/src/lua/common/je_lua.h
index e053718..753230e 100644
--- a/src/lua/common/je_lua.h
+++ b/src/lua/common/je_lua.h
@@ -3,15 +3,27 @@
#include "LuaJIT/lua.hpp"
#include "libraries/luax/luax.h"
+#include "je_lua_shared.hpp"
#include "je_lua_proxy.h"
#include "je_lua_reference.h"
-#include "je_lua_shared.hpp"
namespace JinEngine
{
namespace Lua
{
+ // Lua state singleton.
+ class LuaState
+ {
+ public:
+ static lua_State * get();
+ static void set(lua_State* L);
+
+ private:
+ static lua_State * mL;
+
+ };
+
///
///
///
@@ -25,6 +37,11 @@ namespace JinEngine
///
///
///
+ void luax_removeobject(lua_State* L, SharedBase* shared);
+
+ ///
+ ///
+ ///
int luax_getobjectstable(lua_State* L);
///
diff --git a/src/lua/common/je_lua_common.h b/src/lua/common/je_lua_common.h
index 5b217a2..cdd4f36 100644
--- a/src/lua/common/je_lua_common.h
+++ b/src/lua/common/je_lua_common.h
@@ -1,9 +1,8 @@
#ifndef __JIN_M_TYPES_H
#define __JIN_M_TYPES_H
+#include "je_lua.h"
#include "je_lua_port.h"
-#include "je_lua_proxy.h"
-#include "je_lua_shared.hpp"
#include "je_lua_error.h"
#include "je_lua_reference.h"
diff --git a/src/lua/common/je_lua_shared.hpp b/src/lua/common/je_lua_shared.hpp
index 7bb3f76..59e945d 100644
--- a/src/lua/common/je_lua_shared.hpp
+++ b/src/lua/common/je_lua_shared.hpp
@@ -1,6 +1,8 @@
#ifndef __JIN_COMMON_SHARED_H__
#define __JIN_COMMON_SHARED_H__
+//#include "je_lua.h"
+
#include <map>
#include <vector>
@@ -144,6 +146,9 @@ namespace JinEngine
// Make shared only be able created with new.
~Shared()
{
+ // Delete object mapping.
+ luax_removeobject(LuaState::get(), this);
+ //
T* obj = static_cast<T*>(mObject);
delete obj;
}
diff --git a/src/lua/jin.cpp b/src/lua/jin.cpp
index f4fcb61..39291ac 100644
--- a/src/lua/jin.cpp
+++ b/src/lua/jin.cpp
@@ -67,6 +67,8 @@ namespace JinEngine
/* register jin module, keep it on the top of stack */
LUA_EXPORT int luaopen_jin(lua_State* L)
{
+ LuaState::set(L);
+
luax_globaltable(L, MODULE_NAME);
// Register values.
diff --git a/src/lua/jin.h b/src/lua/jin.h
index 9042704..473ead7 100644
--- a/src/lua/jin.h
+++ b/src/lua/jin.h
@@ -2,10 +2,10 @@
* Copyright (C) 2016~2018 chai
*/
-#ifndef __JIN_M_JIN_H
-#define __JIN_M_JIN_H
-#include "common/je_lua.h"
+#ifndef __JIN_M_JIN_H__
+#define __JIN_M_JIN_H__
+#include "common/je_lua.h"
#include "common/je_lua_common.h"
#define MODULE_NAME "jin"
@@ -33,4 +33,4 @@ namespace JinEngine
} // namespace JinEngine
} // namespace Lua
-#endif // __JIN_M_JIN_H \ No newline at end of file
+#endif // __JIN_M_JIN_H__ \ No newline at end of file
diff --git a/src/lua/libraries/luax/luax.h b/src/lua/libraries/luax/luax.h
index fc2b21e..0055176 100644
--- a/src/lua/libraries/luax/luax.h
+++ b/src/lua/libraries/luax/luax.h
@@ -123,6 +123,9 @@ inline float luax_rawgetnumberthenpop(lua_State* L, int i, int k)
#define luax_pushlightuserdata lua_pushlightuserdata
#define luax_pushnil lua_pushnil
#define luax_pushvalue lua_pushvalue
+#define luax_pushliteral lua_pushliteral
+
+#define luax_setmetatable lua_setmetatable
//inline void luax_pushuserdata(lua_State* L, void* p)
//{
diff --git a/src/lua/modules/graphics/je_lua_animation.cpp b/src/lua/modules/graphics/je_lua_animation.cpp
index d054761..cd048e3 100644
--- a/src/lua/modules/graphics/je_lua_animation.cpp
+++ b/src/lua/modules/graphics/je_lua_animation.cpp
@@ -1,5 +1,4 @@
#include "common/je_lua_proxy.h"
-
#include "common/je_lua_common.h"
#include "libjin/jin.h"
diff --git a/src/lua/modules/graphics/je_lua_animator.cpp b/src/lua/modules/graphics/je_lua_animator.cpp
index 857d375..843204d 100644
--- a/src/lua/modules/graphics/je_lua_animator.cpp
+++ b/src/lua/modules/graphics/je_lua_animator.cpp
@@ -1,5 +1,4 @@
#include "common/je_lua_proxy.h"
-
#include "common/je_lua_common.h"
#include "libjin/jin.h"
diff --git a/src/lua/modules/graphics/je_lua_canvas.cpp b/src/lua/modules/graphics/je_lua_canvas.cpp
index 5cbcf98..80ee155 100644
--- a/src/lua/modules/graphics/je_lua_canvas.cpp
+++ b/src/lua/modules/graphics/je_lua_canvas.cpp
@@ -1,5 +1,4 @@
#include "common/je_lua_proxy.h"
-
#include "common/je_lua_common.h"
#include "libjin/jin.h"
#include "je_lua_canvas.h"
diff --git a/src/lua/modules/graphics/je_lua_graphics.cpp b/src/lua/modules/graphics/je_lua_graphics.cpp
index cc67055..82793be 100644
--- a/src/lua/modules/graphics/je_lua_graphics.cpp
+++ b/src/lua/modules/graphics/je_lua_graphics.cpp
@@ -3,7 +3,6 @@
#include "libjin/jin.h"
#include "common/je_lua_proxy.h"
-
#include "common/je_lua_common.h"
#include "je_lua_canvas.h"
@@ -794,9 +793,9 @@ namespace JinEngine
// newAnimation([frames table, loop, speed])
LUA_IMPLEMENT int l_newAnimation(lua_State* L)
{
- int args = luax_gettop(L);
+ int argc = luax_gettop(L);
Shared<Animation>* shrAnimation = new Shared<Animation>(new Animation(), Jin_Lua_Animation);
- if (args >= 3)
+ if (argc >= 3)
{
if (!luax_istable(L, 1))
{
@@ -825,9 +824,9 @@ namespace JinEngine
// newAnimator([animation])
LUA_IMPLEMENT int l_newAnimator(lua_State* L)
{
- int args = luax_gettop(L);
+ int argc = luax_gettop(L);
Shared<Animator>* shrAniamtor = new Shared<Animator>(new Animator(), Jin_Lua_Animator);
- if (args >= 1)
+ if (argc >= 1)
{
Proxy* pxyAnimation = (Proxy*)luax_checktype(L, 1, Jin_Lua_Animation);
Shared<Animation>& shrAnimtion = pxyAnimation->getShared<Animation>();
diff --git a/src/lua/modules/graphics/je_lua_page.cpp b/src/lua/modules/graphics/je_lua_page.cpp
index c3fdc7e..c119991 100644
--- a/src/lua/modules/graphics/je_lua_page.cpp
+++ b/src/lua/modules/graphics/je_lua_page.cpp
@@ -1,5 +1,4 @@
#include "common/je_lua_proxy.h"
-
#include "common/je_lua_common.h"
#include "libjin/jin.h"
diff --git a/src/lua/modules/graphics/je_lua_shader.cpp b/src/lua/modules/graphics/je_lua_shader.cpp
index cfe2260..ca4d6f6 100644
--- a/src/lua/modules/graphics/je_lua_shader.cpp
+++ b/src/lua/modules/graphics/je_lua_shader.cpp
@@ -1,5 +1,4 @@
#include "common/je_lua_proxy.h"
-
#include "common/je_lua_common.h"
#include "libjin/jin.h"
diff --git a/src/lua/modules/graphics/je_lua_sprite.cpp b/src/lua/modules/graphics/je_lua_sprite.cpp
index 01ba103..018a43d 100644
--- a/src/lua/modules/graphics/je_lua_sprite.cpp
+++ b/src/lua/modules/graphics/je_lua_sprite.cpp
@@ -1,5 +1,4 @@
#include "common/je_lua_proxy.h"
-
#include "common/je_lua_common.h"
#include "libjin/jin.h"
diff --git a/src/lua/modules/graphics/je_lua_spritesheet.cpp b/src/lua/modules/graphics/je_lua_spritesheet.cpp
index 57b610c..362a78d 100644
--- a/src/lua/modules/graphics/je_lua_spritesheet.cpp
+++ b/src/lua/modules/graphics/je_lua_spritesheet.cpp
@@ -66,12 +66,12 @@ namespace JinEngine
int w = luax_checkinteger(L, 5);
int h = luax_checkinteger(L, 6);
vector<Sprite*> sprs;
- int args = luax_gettop(L);
- if (args == 6)
+ int argc = luax_gettop(L);
+ if (argc == 6)
{
sprs = ss->createSprites(count, r, c, w, h, Origin::TopLeft);
}
- else if (args >= 8)
+ else if (argc >= 8)
{
int ox = luax_checkinteger(L, 7);
int oy = luax_checkinteger(L, 8);
@@ -79,7 +79,7 @@ namespace JinEngine
int offy = luax_optinteger(L, 10, 0);
sprs = ss->createSprites(count, r, c, w, h, ox, oy, offx, offy);
}
- else if (args >= 7)
+ else if (argc >= 7)
{
int o = luax_checkinteger(L, 7);
Origin origin = static_cast<Origin>(o);
diff --git a/src/lua/modules/graphics/je_lua_text.cpp b/src/lua/modules/graphics/je_lua_text.cpp
index 6509e73..adeed35 100644
--- a/src/lua/modules/graphics/je_lua_text.cpp
+++ b/src/lua/modules/graphics/je_lua_text.cpp
@@ -1,5 +1,4 @@
#include "common/je_lua_proxy.h"
-
#include "common/je_lua_common.h"
#include "libjin/jin.h"
diff --git a/src/lua/modules/graphics/je_lua_texture.cpp b/src/lua/modules/graphics/je_lua_texture.cpp
index 5402a99..a8676f1 100644
--- a/src/lua/modules/graphics/je_lua_texture.cpp
+++ b/src/lua/modules/graphics/je_lua_texture.cpp
@@ -1,5 +1,4 @@
#include "common/je_lua_proxy.h"
-
#include "common/je_lua_common.h"
#include "libjin/jin.h"
#include "je_lua_texture.h"
diff --git a/src/lua/modules/graphics/je_lua_texture_font.cpp b/src/lua/modules/graphics/je_lua_texture_font.cpp
index 61c559b..6c62ee2 100644
--- a/src/lua/modules/graphics/je_lua_texture_font.cpp
+++ b/src/lua/modules/graphics/je_lua_texture_font.cpp
@@ -1,5 +1,4 @@
#include "common/je_lua_proxy.h"
-
#include "common/je_lua_common.h"
#include "libjin/jin.h"
diff --git a/src/lua/modules/graphics/je_lua_ttf.cpp b/src/lua/modules/graphics/je_lua_ttf.cpp
index 7fea04b..fb4b0df 100644
--- a/src/lua/modules/graphics/je_lua_ttf.cpp
+++ b/src/lua/modules/graphics/je_lua_ttf.cpp
@@ -1,5 +1,4 @@
#include "common/je_lua_proxy.h"
-
#include "common/je_lua_common.h"
#include "libjin/jin.h"
diff --git a/src/lua/modules/graphics/je_lua_ttf_data.cpp b/src/lua/modules/graphics/je_lua_ttf_data.cpp
index aa2280f..8042d69 100644
--- a/src/lua/modules/graphics/je_lua_ttf_data.cpp
+++ b/src/lua/modules/graphics/je_lua_ttf_data.cpp
@@ -1,5 +1,4 @@
#include "common/je_lua_proxy.h"
-
#include "common/je_lua_common.h"
#include "libjin/jin.h"
diff --git a/src/lua/modules/net/je_lua_buffer.cpp b/src/lua/modules/net/je_lua_buffer.cpp
index 582eec9..5442e14 100644
--- a/src/lua/modules/net/je_lua_buffer.cpp
+++ b/src/lua/modules/net/je_lua_buffer.cpp
@@ -1,5 +1,4 @@
#include "common/je_lua_proxy.h"
-
#include "common/je_lua_common.h"
#include "libjin/jin.h"
#include "je_lua_buffer.h"
diff --git a/src/lua/modules/net/je_lua_net.cpp b/src/lua/modules/net/je_lua_net.cpp
index 456bcf8..4b5513a 100644
--- a/src/lua/modules/net/je_lua_net.cpp
+++ b/src/lua/modules/net/je_lua_net.cpp
@@ -1,5 +1,4 @@
#include "common/je_lua_proxy.h"
-
#include "libjin/jin.h"
#include "common/je_lua_common.h"
diff --git a/src/lua/modules/net/je_lua_socket.cpp b/src/lua/modules/net/je_lua_socket.cpp
index 94e1275..3eed91f 100644
--- a/src/lua/modules/net/je_lua_socket.cpp
+++ b/src/lua/modules/net/je_lua_socket.cpp
@@ -1,5 +1,4 @@
#include "common/je_lua_proxy.h"
-
#include "common/je_lua_common.h"
#include "libjin/jin.h"
#include "je_lua_buffer.h"
diff --git a/src/lua/modules/time/je_lua_time.cpp b/src/lua/modules/time/je_lua_time.cpp
index 6ad4935..4eb579f 100644
--- a/src/lua/modules/time/je_lua_time.cpp
+++ b/src/lua/modules/time/je_lua_time.cpp
@@ -3,7 +3,6 @@
#include "common/je_lua_proxy.h"
#include "libjin/jin.h"
-
#include "je_lua_timer.h"
using namespace JinEngine::Time;
@@ -34,7 +33,8 @@ namespace JinEngine
LUA_IMPLEMENT int l_newTimer(lua_State* L)
{
- Proxy* proxy = luax_newinstance(L, Jin_Lua_Timer, new Shared<Timer>(new Timer(), Jin_Lua_Timer));
+ Shared<Timer>* shrTimer = new Shared<Timer>(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 6dc6798..ccb902a 100644
--- a/src/lua/modules/time/je_lua_timer.cpp
+++ b/src/lua/modules/time/je_lua_timer.cpp
@@ -1,4 +1,3 @@
-
#include "common/je_lua_callback.h"
#include "common/je_lua_common.h"
#include "je_lua_timer.h"
@@ -39,15 +38,13 @@ namespace JinEngine
{
int n = luax_gettop(L);
SharedTimer shared = checkTimer(L);
- Timer* timer = shared.getObject();
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 = timer->every(s, timerCallback, func, finishCallback);
+ Timer::Handler* handler = shared->every(s, timerCallback, func, finishCallback);
Shared<Timer::Handler>* shrHandler = new Shared<Timer::Handler>(handler, Jin_Lua_Handler);
- shrHandler->retain();
Proxy* proxy = luax_newinstance(L, Jin_Lua_Handler, shrHandler);
return 1;
}
@@ -57,15 +54,13 @@ namespace JinEngine
{
int n = luax_gettop(L);
SharedTimer shared = checkTimer(L);
- Timer* timer = shared.getObject();
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 = timer->after(s, timerCallback, func, finishCallback);
+ Timer::Handler* handler = shared->after(s, timerCallback, func, finishCallback);
Shared<Timer::Handler>* shrHandler = new Shared<Timer::Handler>(handler, Jin_Lua_Handler);
- shrHandler->retain();
Proxy* proxy = luax_newinstance(L, Jin_Lua_Handler, shrHandler);
return 1;
}
@@ -75,16 +70,14 @@ namespace JinEngine
{
int n = luax_gettop(L);
SharedTimer shared = checkTimer(L);
- Timer* timer = shared.getObject();
float s = luax_checknumber(L, 2);
int count = luax_checkinteger(L, 3);
LuaCallback* func = new LuaCallback(L);
func->setFunc(4);
for (int i = 5; i <= n; ++i)
func->pushParam(i);
- Timer::Handler* handler = timer->repeat(s, count, timerCallback, func, finishCallback);
+ Timer::Handler* handler = shared->repeat(s, count, timerCallback, func, finishCallback);
Shared<Timer::Handler>* shrHandler = new Shared<Timer::Handler>(handler, Jin_Lua_Handler);
- shrHandler->retain();
Proxy* proxy = luax_newinstance(L, Jin_Lua_Handler, shrHandler);
return 1;
}
@@ -92,9 +85,8 @@ namespace JinEngine
LUA_IMPLEMENT int l_update(lua_State* L)
{
SharedTimer shared = checkTimer(L);
- Timer* timer = shared.getObject();
float s = luax_checknumber(L, 2);
- timer->update(s);
+ shared->update(s);
return 0;
}