diff options
author | wm4 <wm4@nowhere> | 2018-05-01 02:38:59 +0200 |
---|---|---|
committer | Jan Ekström <jeebjp@gmail.com> | 2018-05-03 01:20:01 +0300 |
commit | fb9bbf2a0d7f8dba0d0674595cc2dc0dab68ad94 (patch) | |
tree | b386f221e961ad81e35a3bc23bb66320ba942b80 /input/cmd_parse.c | |
parent | e8b073584d749bb864f495d9e1cd31b102c6283d (diff) | |
download | mpv-fb9bbf2a0d7f8dba0d0674595cc2dc0dab68ad94.tar.bz2 mpv-fb9bbf2a0d7f8dba0d0674595cc2dc0dab68ad94.tar.xz |
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
Diffstat (limited to 'input/cmd_parse.c')
-rw-r--r-- | input/cmd_parse.c | 3 |
1 files changed, 0 insertions, 3 deletions
diff --git a/input/cmd_parse.c b/input/cmd_parse.c index ae518fdf98..f401e5b9c7 100644 --- a/input/cmd_parse.c +++ b/input/cmd_parse.c @@ -29,7 +29,6 @@ #include "libmpv/client.h" const struct mp_cmd_def mp_cmd_list = { - .id = MP_CMD_COMMAND_LIST, .name = "list", }; @@ -87,7 +86,6 @@ static bool find_cmd(struct mp_log *log, struct mp_cmd *cmd, bstr name) if (strcmp(nname, mp_cmds[n].name) == 0) { cmd->def = &mp_cmds[n]; cmd->name = (char *)cmd->def->name; - cmd->id = cmd->def->id; return true; } } @@ -341,7 +339,6 @@ mp_cmd_t *mp_input_parse_cmd_(struct mp_log *log, bstr str, const char *loc) struct mp_cmd *list = talloc_ptrtype(NULL, list); talloc_set_destructor(list, destroy_cmd); *list = (struct mp_cmd) { - .id = mp_cmd_list.id, .name = (char *)mp_cmd_list.name, .def = &mp_cmd_list, .original = bstrdup(list, original), |