From 9fdd0bdd384d97d24cb8e34b441c47eed2e90f75 Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Tue, 18 Nov 2014 16:19:01 +0200 Subject: [PATCH] Tweak format of command help files and do some further command cleanup --- include/core/emustatus.hpp | 5 +- include/core/queue.hpp | 11 +++- include/library/command.hpp | 7 +++ include/lua/lua.hpp | 7 +++ src/cmdhelp/action.json | 7 +++ src/cmdhelp/button.json | 95 ++++++++++++---------------- src/cmdhelp/commentary.json | 23 +++---- src/cmdhelp/debug.json | 39 ++++++------ src/cmdhelp/disassemble.json | 7 +++ src/cmdhelp/framebuffer.json | 10 +-- src/cmdhelp/jukebox.json | 37 +++++------ src/cmdhelp/keymapper.json | 11 ++++ src/cmdhelp/libao-sound.json | 7 +++ src/cmdhelp/loadlib.json | 15 +++++ src/cmdhelp/loadsave.json | 113 +++++++++++++++++++++++++++++----- src/cmdhelp/lua.json | 23 +++++++ src/cmdhelp/macro.json | 39 ++++++------ src/cmdhelp/mhold.json | 39 +++++------- src/cmdhelp/mkstubs.cpp | 50 ++++++++------- src/cmdhelp/mkstubsi.cpp | 19 +++--- src/cmdhelp/moviedata.json | 11 ++++ src/cmdhelp/multitrack.json | 36 +++++------ src/cmdhelp/project.json | 65 ++++++++----------- src/cmdhelp/sound.json | 36 +++++++++++ src/cmdhelp/subtitles.json | 36 +++++------ src/cmdhelp/turbo.json | 39 +++++------- src/core/actions.cpp | 4 +- src/core/controller.cpp | 36 +++++------ src/core/controllerframe.cpp | 39 +++++++++++- src/core/debug.cpp | 6 +- src/core/disassemble.cpp | 4 +- src/core/emustatus.cpp | 6 +- src/core/framebuffer.cpp | 2 +- src/core/framerate.cpp | 6 +- src/core/instance.cpp | 2 +- src/core/inthread.cpp | 4 +- src/core/jukebox.cpp | 6 +- src/core/keymapper.cpp | 7 +-- src/core/loadlib.cpp | 11 +++- src/core/mainloop.cpp | 87 ++++++++------------------ src/core/misc.cpp | 34 ---------- src/core/moviedata.cpp | 10 ++- src/core/multitrack.cpp | 6 +- src/core/project.cpp | 17 ++--- src/core/queue.cpp | 16 ++++- src/core/subtitles.cpp | 6 +- src/core/ui-services.cpp | 3 +- src/core/window.cpp | 25 +++----- src/library/command.cpp | 37 ++++++++--- src/lua/lua.cpp | 63 +++++++------------ src/lua/memory.cpp | 3 +- src/platform/libao/sound.cpp | 3 +- src/platform/wxwidgets/mainwindow.cpp | 29 +++++---- 53 files changed, 710 insertions(+), 549 deletions(-) create mode 100644 src/cmdhelp/action.json rewrite src/cmdhelp/button.json (99%) rewrite src/cmdhelp/debug.json (99%) create mode 100644 src/cmdhelp/disassemble.json create mode 100644 src/cmdhelp/keymapper.json create mode 100644 src/cmdhelp/libao-sound.json create mode 100644 src/cmdhelp/loadlib.json create mode 100644 src/cmdhelp/lua.json rewrite src/cmdhelp/macro.json (99%) rewrite src/cmdhelp/mhold.json (99%) create mode 100644 src/cmdhelp/moviedata.json rewrite src/cmdhelp/multitrack.json (99%) rewrite src/cmdhelp/project.json (99%) create mode 100644 src/cmdhelp/sound.json rewrite src/cmdhelp/subtitles.json (99%) rewrite src/cmdhelp/turbo.json (99%) diff --git a/include/core/emustatus.hpp b/include/core/emustatus.hpp index f75eb584..550a85b5 100644 --- a/include/core/emustatus.hpp +++ b/include/core/emustatus.hpp @@ -5,6 +5,7 @@ #include #include #include +#include "library/command.hpp" #include "library/triplebuffer.hpp" class movie_logic; @@ -57,13 +58,15 @@ struct _lsnes_status struct slotinfo_cache { - slotinfo_cache(movie_logic& _mlogic); + slotinfo_cache(movie_logic& _mlogic, command::group& _cmd); std::string get(const std::string& _filename); void flush(const std::string& _filename); void flush(); private: std::map cache; movie_logic& mlogic; + command::group& cmd; + command::_fnptr<> flushcmd; }; struct status_updater diff --git a/include/core/queue.hpp b/include/core/queue.hpp index 947d4c40..63209f1d 100644 --- a/include/core/queue.hpp +++ b/include/core/queue.hpp @@ -65,7 +65,7 @@ struct input_queue threads::lock queue_lock; threads::cv queue_condition; std::deque keypresses; - std::deque commands; + std::deque> commands; std::deque functions; volatile uint64_t functions_executed; volatile uint64_t next_function; @@ -92,6 +92,15 @@ struct input_queue */ void queue(const std::string& c) throw(std::bad_alloc); /** + * Queue command and arguments. + * + * - Can be called from any thread. + * + * Parameter c: The command to queue. + * Parameter a: The arguments for function. + */ + void queue(const char* c, const std::string& a) throw(std::bad_alloc); +/** * Queue function to be called in emulation thread. * * - Can be called from any thread (exception: Synchronous mode can not be used from emulation nor main threads). diff --git a/include/library/command.hpp b/include/library/command.hpp index b6612a19..c8c3cbe9 100644 --- a/include/library/command.hpp +++ b/include/library/command.hpp @@ -96,6 +96,13 @@ public: */ void invoke(const std::string& cmd) throw(); /** + * Look up and invoke a command. No alias expansion is performed, but recursion checking is. + * + * parameter cmd: Command to execute. + * parameter args: The parameters for command. + */ + void invoke(const std::string& cmd, const std::string& args) throw(); +/** * Get set of aliases. */ std::set get_aliases() throw(std::bad_alloc); diff --git a/include/lua/lua.hpp b/include/lua/lua.hpp index b2ea6f41..7003d333 100644 --- a/include/lua/lua.hpp +++ b/include/lua/lua.hpp @@ -5,6 +5,7 @@ #include #include #include "core/controllerframe.hpp" +#include "library/command.hpp" #include "library/movie.hpp" #include "library/framebuffer.hpp" #include "library/lua-base.hpp" @@ -106,6 +107,8 @@ struct lua_state std::list startup_scripts; std::map watch_vars; private: + void do_reset(); + void do_evaluate(const std::string& a); bool run_lua_fragment() throw(std::bad_alloc); template bool run_callback(lua::state::callback_list& list, T... args); void run_synchronous_paint(struct lua::render_context* ctx); @@ -113,6 +116,10 @@ private: command::group& command; bool recursive_flag; const char* luareader_fragment; + command::_fnptr<> resetcmd; + command::_fnptr evalcmd; + command::_fnptr evalcmd2; + command::_fnptr runcmd; }; #endif diff --git a/src/cmdhelp/action.json b/src/cmdhelp/action.json new file mode 100644 index 00000000..2b4276b6 --- /dev/null +++ b/src/cmdhelp/action.json @@ -0,0 +1,7 @@ +{ + "__mod":"CACTION", + "action":[ + "e", "Execute core action", + {" [...]":"Executes core action."} + ] +} diff --git a/src/cmdhelp/button.json b/src/cmdhelp/button.json dissimilarity index 99% index ebbb079e..52e974ec 100644 --- a/src/cmdhelp/button.json +++ b/src/cmdhelp/button.json @@ -1,56 +1,39 @@ -{ - "btnp":{ - "__class":"button", - "__name":"+controller", - "__description":"Press a button", - "