From a16ce94158c9cf22a19c0e73dfe2e992a8302af1 Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 8 Dec 2018 22:05:31 +0800 Subject: =?UTF-8?q?*=E5=8E=BB=E9=99=A4shared=20template?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lua/modules/audio/je_lua_source.cpp | 48 ++++++++++++++++----------------- 1 file changed, 23 insertions(+), 25 deletions(-) (limited to 'src/lua/modules/audio/je_lua_source.cpp') 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& 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(); + LuaObject* luaObj = luax_checkobject(L, 1, Jin_Lua_Source); + Source* source = luaObj->getObject(); + 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); } -- cgit v1.1-26-g67d0