From 398966630f99329021d4335d819326e27a9d49df Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 18 Aug 2018 17:18:47 +0800 Subject: *update --- src/lua/audio/luaopen_Source.cpp | 46 +++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 22 deletions(-) (limited to 'src/lua/audio/luaopen_Source.cpp') diff --git a/src/lua/audio/luaopen_Source.cpp b/src/lua/audio/luaopen_Source.cpp index 3e4408a..658adcb 100644 --- a/src/lua/audio/luaopen_Source.cpp +++ b/src/lua/audio/luaopen_Source.cpp @@ -9,7 +9,9 @@ namespace lua using namespace jin::audio; - static inline Ref& checkSource(lua_State* L) + typedef Ref& SourceRef; + + static inline SourceRef checkSource(lua_State* L) { Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_AUDIO_SOURCE); return proxy->getRef(); @@ -17,42 +19,42 @@ namespace lua static int l_play(lua_State* L) { - Ref& ref = checkSource(L); + SourceRef ref = checkSource(L); ref->play(); return 0; } static int l_stop(lua_State* L) { - Ref& ref = checkSource(L); + SourceRef ref = checkSource(L); ref->stop(); return 0; } static int l_pause(lua_State* L) { - Ref& ref = checkSource(L); + SourceRef ref = checkSource(L); ref->pause(); return 0; } static int l_rewind(lua_State* L) { - Ref& ref = checkSource(L); + SourceRef ref = checkSource(L); ref->rewind(); return 0; } static int l_resume(lua_State* L) { - Ref& ref = checkSource(L); + SourceRef ref = checkSource(L); ref->resume(); return 0; } static int l_isStop(lua_State* L) { - Ref& ref = checkSource(L); + SourceRef ref = checkSource(L); bool isStop = ref->isStopped(); luax_pushboolean(L, isStop); return 1; @@ -60,7 +62,7 @@ namespace lua static int l_isPaused(lua_State* L) { - Ref& ref = checkSource(L); + SourceRef ref = checkSource(L); bool isPaused = ref->isPaused(); luax_pushboolean(L, isPaused); return 1; @@ -68,7 +70,7 @@ namespace lua static int l_setVolume(lua_State* L) { - Ref& ref = checkSource(L); + SourceRef ref = checkSource(L); float volume = luax_checknumber(L, 2); ref->setVolume(volume); return 0; @@ -76,7 +78,7 @@ namespace lua static int l_setLoop(lua_State* L) { - Ref& ref = checkSource(L); + SourceRef ref = checkSource(L); bool loop = luax_checkbool(L, 2); ref->setLoop(loop); return 0; @@ -90,17 +92,17 @@ namespace lua } static const luaL_Reg f[] = { - { "__gc", l_gc }, - { "play", l_play }, - { "stop", l_stop }, - { "pause", l_pause }, - { "resume", l_resume }, - { "rewind", l_rewind }, - { "isStop", l_isStop }, - { "isPaused", l_isPaused }, + { "__gc", l_gc }, + { "play", l_play }, + { "stop", l_stop }, + { "pause", l_pause }, + { "resume", l_resume }, + { "rewind", l_rewind }, + { "isStop", l_isStop }, + { "isPaused", l_isPaused }, { "setVolume", l_setVolume }, - { "setLoop", l_setLoop }, - {0, 0} + { "setLoop", l_setLoop }, + {0, 0 } }; int luaopen_Source(lua_State* L) @@ -109,5 +111,5 @@ namespace lua return 0; } -} -} \ No newline at end of file +} // lua +} // jin \ No newline at end of file -- cgit v1.1-26-g67d0