aboutsummaryrefslogtreecommitdiff
path: root/src/lua/modules/time/je_lua_timer.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-12-08 22:05:31 +0800
committerchai <chaifix@163.com>2018-12-08 22:05:31 +0800
commita16ce94158c9cf22a19c0e73dfe2e992a8302af1 (patch)
tree52d80d950cd410ba82af909e18f77e3b11cd6eda /src/lua/modules/time/je_lua_timer.cpp
parentd34e5c9d7c6135e805f2cc231411cdcc9910190c (diff)
*去除shared template
Diffstat (limited to 'src/lua/modules/time/je_lua_timer.cpp')
-rw-r--r--src/lua/modules/time/je_lua_timer.cpp20
1 files changed, 9 insertions, 11 deletions
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;