diff options
author | 2016-04-16 18:01:48 +0200 | |
---|---|---|
committer | 2016-04-16 18:01:48 +0200 | |
commit | fc48cb17f314d3a67ea90885c76191c99fd295b6 (patch) | |
tree | 8b787fbe5bd5303cf12cfdf38f4de796b69eb955 /src | |
parent | 816860f2d81a40f9aecc8c7ef9f5ab2c42e56d7f (diff) |
added print_verbose, print_info, print_debug and print_error to lua, and used it instead of print (nw)
Diffstat (limited to 'src')
-rw-r--r-- | src/emu/luaengine.cpp | 47 | ||||
-rw-r--r-- | src/emu/luaengine.h | 5 |
2 files changed, 52 insertions, 0 deletions
diff --git a/src/emu/luaengine.cpp b/src/emu/luaengine.cpp index 331d2b1372e..8e1ddbf8d93 100644 --- a/src/emu/luaengine.cpp +++ b/src/emu/luaengine.cpp @@ -2075,6 +2075,49 @@ int lua_engine::lua_machine::l_logerror(lua_State *L) return 0; } +std::string lua_engine::get_print_buffer(lua_State *L) +{ + int nargs = lua_gettop(L); + + const std::string sep = " "; + + std::ostringstream ss; + bool first = true; + + for (int i = 1; i <= nargs; i++) { + const char* c = lua_tostring(L, i); + const std::string str = c ? c : "<nil>"; + if (first) first = false; + else ss << sep; + ss << str; + } + + return ss.str(); +} +int lua_engine::l_osd_printf_verbose(lua_State *L) +{ + osd_printf_verbose("%s\n",get_print_buffer(L).c_str()); + return 0; +} + +int lua_engine::l_osd_printf_error(lua_State *L) +{ + osd_printf_error("%s\n",get_print_buffer(L).c_str()); + return 0; +} + +int lua_engine::l_osd_printf_info(lua_State *L) +{ + osd_printf_info("%s\n",get_print_buffer(L).c_str()); + return 0; +} + +int lua_engine::l_osd_printf_debug(lua_State *L) +{ + osd_printf_debug("%s\n",get_print_buffer(L).c_str()); + return 0; +} + //------------------------------------------------- // initialize - initialize lua hookup to emu engine //------------------------------------------------- @@ -2106,6 +2149,10 @@ void lua_engine::initialize() .addCFunction ("register_frame", l_emu_register_frame ) .addCFunction ("register_frame_done", l_emu_register_frame_done ) .addCFunction ("register_menu", l_emu_register_menu ) + .addCFunction ("print_verbose", l_osd_printf_verbose ) + .addCFunction ("print_error", l_osd_printf_error ) + .addCFunction ("print_info", l_osd_printf_info ) + .addCFunction ("print_debug", l_osd_printf_debug ) .beginClass <machine_manager> ("manager") .addFunction ("machine", &machine_manager::machine) .addFunction ("options", &machine_manager::options) diff --git a/src/emu/luaengine.h b/src/emu/luaengine.h index 269ea3d46b3..3b4c85ce939 100644 --- a/src/emu/luaengine.h +++ b/src/emu/luaengine.h @@ -141,6 +141,11 @@ private: static int l_emu_register_frame(lua_State *L); static int l_emu_register_frame_done(lua_State *L); static int l_emu_register_menu(lua_State *L); + static std::string get_print_buffer(lua_State *L); + static int l_osd_printf_verbose(lua_State *L); + static int l_osd_printf_error(lua_State *L); + static int l_osd_printf_info(lua_State *L); + static int l_osd_printf_debug(lua_State *L); static int register_function(lua_State *L, const char *id); // "emu.machine" namespace |