From cfa05003be67344fbc79c338c2ac82f0accd979d Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 22 Nov 2018 16:15:48 +0800 Subject: =?UTF-8?q?*=E4=BF=AE=E6=94=B9argc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lua/modules/time/je_lua_timer.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'src/lua/modules/time/je_lua_timer.cpp') 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* shrHandler = new Shared(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* shrHandler = new Shared(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* shrHandler = new Shared(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; } -- cgit v1.1-26-g67d0