diff options
author | 2016-03-02 21:49:49 +0100 | |
---|---|---|
committer | 2016-03-02 21:49:49 +0100 | |
commit | 9fe9f6d93e672bcd926f9e7461774bc9cc22e094 (patch) | |
tree | 3911b611dd010a4108b90fb8b8c82116eec21117 /src/emu/luaengine.cpp | |
parent | dbdf21ee465acadf3e643d62d6bedfcc297ada85 (diff) | |
parent | 1914702e6fae052668df5b068a502bca57c9a3b0 (diff) |
Merge remote-tracking branch 'refs/remotes/mamedev/master'
# Resolved Conflicts:
# src/osd/modules/render/d3d/d3dhlsl.cpp
# src/osd/windows/winmain.cpp
Diffstat (limited to 'src/emu/luaengine.cpp')
-rw-r--r-- | src/emu/luaengine.cpp | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/src/emu/luaengine.cpp b/src/emu/luaengine.cpp index 990f417eac4..ecf1b418de5 100644 --- a/src/emu/luaengine.cpp +++ b/src/emu/luaengine.cpp @@ -19,7 +19,9 @@ #include "ui/ui.h" #include "luaengine.h" #include <mutex> +#if !defined(NO_LIBUV) #include "libuv/include/uv.h" +#endif //************************************************************************** // LUA ENGINE @@ -49,9 +51,11 @@ lua_engine* lua_engine::luaThis = nullptr; extern "C" { int luaopen_lsqlite3(lua_State *L); int luaopen_zlib(lua_State *L); - int luaopen_luv(lua_State *L); int luaopen_lfs(lua_State *L); - uv_loop_t* luv_loop(lua_State* L); +#if !defined(NO_LIBUV) + int luaopen_luv(lua_State *L); + uv_loop_t* luv_loop(lua_State* L); +#endif } static void lstop(lua_State *L, lua_Debug *ar) @@ -136,23 +140,19 @@ lua_engine::hook::hook() cb = -1; } -#if (defined(__sun__) && defined(__svr4__)) || defined(__ANDROID__) || defined(__OpenBSD__) -#undef _L -#endif - -void lua_engine::hook::set(lua_State *_L, int idx) +void lua_engine::hook::set(lua_State *lua, int idx) { if (L) luaL_unref(L, LUA_REGISTRYINDEX, cb); - if (lua_isnil(_L, idx)) { + if (lua_isnil(lua, idx)) { L = nullptr; cb = -1; } else { - L = _L; - lua_pushvalue(_L, idx); - cb = luaL_ref(_L, LUA_REGISTRYINDEX); + L = lua; + lua_pushvalue(lua, idx); + cb = luaL_ref(lua, LUA_REGISTRYINDEX); } } @@ -197,9 +197,9 @@ void lua_engine::resume(lua_State *L, int nparam, lua_State *root) } } -void lua_engine::resume(void *_L, INT32 param) +void lua_engine::resume(void *lua, INT32 param) { - resume(static_cast<lua_State *>(_L)); + resume(static_cast<lua_State *>(lua)); } int lua_engine::l_ioport_write(lua_State *L) @@ -744,7 +744,7 @@ int lua_engine::lua_options_entry::l_entry_value(lua_State *L) luaL_error(L, "%s", error.c_str()); } } - + switch (e->type()) { case OPTION_BOOLEAN: @@ -1194,24 +1194,26 @@ lua_engine::lua_engine() lua_gc(m_lua_state, LUA_GCSTOP, 0); /* stop collector during initialization */ luaL_openlibs(m_lua_state); /* open libraries */ - // Get package.preload so we can store builtins in it. + // Get package.preload so we can store builtins in it. lua_getglobal(m_lua_state, "package"); lua_getfield(m_lua_state, -1, "preload"); lua_remove(m_lua_state, -2); // Remove package +#if !defined(NO_LIBUV) // Store uv module definition at preload.uv lua_pushcfunction(m_lua_state, luaopen_luv); lua_setfield(m_lua_state, -2, "luv"); +#endif lua_pushcfunction(m_lua_state, luaopen_zlib); lua_setfield(m_lua_state, -2, "zlib"); - + lua_pushcfunction(m_lua_state, luaopen_lsqlite3); lua_setfield(m_lua_state, -2, "lsqlite3"); lua_pushcfunction(m_lua_state, luaopen_lfs); lua_setfield(m_lua_state, -2, "lfs"); - + luaopen_ioport(m_lua_state); lua_gc(m_lua_state, LUA_GCRESTART, 0); @@ -1340,15 +1342,18 @@ void lua_engine::update_machine() } port = port->next(); } - machine().add_notifier(MACHINE_NOTIFY_RESET, machine_notify_delegate(FUNC(lua_engine::on_machine_start), this)); - machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(lua_engine::on_machine_stop), this)); - machine().add_notifier(MACHINE_NOTIFY_PAUSE, machine_notify_delegate(FUNC(lua_engine::on_machine_pause), this)); - machine().add_notifier(MACHINE_NOTIFY_RESUME, machine_notify_delegate(FUNC(lua_engine::on_machine_resume), this)); - machine().add_notifier(MACHINE_NOTIFY_FRAME, machine_notify_delegate(FUNC(lua_engine::on_machine_frame), this)); } lua_setglobal(m_lua_state, "ioport"); } +void lua_engine::attach_notifiers() +{ + machine().add_notifier(MACHINE_NOTIFY_RESET, machine_notify_delegate(FUNC(lua_engine::on_machine_start), this)); + machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(lua_engine::on_machine_stop), this)); + machine().add_notifier(MACHINE_NOTIFY_PAUSE, machine_notify_delegate(FUNC(lua_engine::on_machine_pause), this)); + machine().add_notifier(MACHINE_NOTIFY_RESUME, machine_notify_delegate(FUNC(lua_engine::on_machine_resume), this)); + machine().add_notifier(MACHINE_NOTIFY_FRAME, machine_notify_delegate(FUNC(lua_engine::on_machine_frame), this)); +} //------------------------------------------------- // initialize - initialize lua hookup to emu engine @@ -1665,10 +1670,11 @@ void lua_engine::periodic_check() msg.ready = 0; msg.done = 1; } +#if !defined(NO_LIBUV) auto loop = luv_loop(m_lua_state); if (loop!=nullptr) uv_run(loop, UV_RUN_NOWAIT); - +#endif } //------------------------------------------------- |