mirror of
https://github.com/mpv-player/mpv
synced 2025-02-16 12:17:12 +00:00
commands: cosmetics: rename things
This is Better (tm). The only actual change is that with M_PROPERTY_SET_STRING, the option parser will use the property name, instead whatever was set in the name field of the option returned by M_PROPERTY_GET_TYPE. In most cases, these should be the same, though.
This commit is contained in:
parent
b591688a27
commit
84af173380
@ -1777,7 +1777,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
||||
|
||||
case MP_CMD_SET: {
|
||||
cmd->args[0].v.s = translate_legacy_property(cmd, cmd->args[0].v.s);
|
||||
int r = mp_property_do(cmd->args[0].v.s, M_PROPERTY_PARSE,
|
||||
int r = mp_property_do(cmd->args[0].v.s, M_PROPERTY_SET_STRING,
|
||||
cmd->args[1].v.s, mpctx);
|
||||
if (r == M_PROPERTY_UNKNOWN)
|
||||
mp_msg(MSGT_CPLAYER, MSGL_WARN,
|
||||
@ -1817,7 +1817,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
||||
case MP_CMD_GET_PROPERTY: {
|
||||
cmd->args[0].v.s = translate_legacy_property(cmd, cmd->args[0].v.s);
|
||||
char *tmp;
|
||||
int r = mp_property_do(cmd->args[0].v.s, M_PROPERTY_TO_STRING,
|
||||
int r = mp_property_do(cmd->args[0].v.s, M_PROPERTY_GET_STRING,
|
||||
&tmp, mpctx);
|
||||
if (r <= 0) {
|
||||
mp_msg(MSGT_CPLAYER, MSGL_WARN,
|
||||
|
@ -88,7 +88,7 @@ int m_property_do(const m_option_t *prop_list, const char *name,
|
||||
*(char **)arg = str;
|
||||
return str != NULL;
|
||||
}
|
||||
case M_PROPERTY_TO_STRING: {
|
||||
case M_PROPERTY_GET_STRING: {
|
||||
if ((r = do_action(prop_list, name, M_PROPERTY_GET, &val, ctx)) <= 0)
|
||||
return r;
|
||||
char *str = m_option_print(&opt, &val);
|
||||
@ -96,9 +96,9 @@ int m_property_do(const m_option_t *prop_list, const char *name,
|
||||
*(char **)arg = str;
|
||||
return str != NULL;
|
||||
}
|
||||
case M_PROPERTY_PARSE: {
|
||||
case M_PROPERTY_SET_STRING: {
|
||||
// (reject 0 return value: success, but empty string with flag)
|
||||
if (m_option_parse(&opt, bstr0(opt->name), bstr0(arg), &val) <= 0)
|
||||
if (m_option_parse(&opt, bstr0(name), bstr0(arg), &val) <= 0)
|
||||
return M_PROPERTY_ERROR;
|
||||
r = do_action(prop_list, name, M_PROPERTY_SET, &val, ctx);
|
||||
m_option_free(&opt, &val);
|
||||
@ -184,7 +184,7 @@ char *m_properties_expand_string(const m_option_t *prop_list, char *str,
|
||||
int method = M_PROPERTY_PRINT;
|
||||
if (str[0] == '=') {
|
||||
str += 1;
|
||||
method = M_PROPERTY_TO_STRING;
|
||||
method = M_PROPERTY_GET_STRING;
|
||||
}
|
||||
int pl = e - str;
|
||||
char pname[pl + 1];
|
||||
|
14
m_property.h
14
m_property.h
@ -52,19 +52,19 @@ enum mp_property_action {
|
||||
// arg: struct m_property_switch_arg*
|
||||
M_PROPERTY_SWITCH,
|
||||
|
||||
// Get a string containing a parsable representation.
|
||||
// Can't be overridden by property implementations.
|
||||
// arg: char**
|
||||
M_PROPERTY_GET_STRING,
|
||||
|
||||
// Set a new value from a string. The property wrapper parses this using the
|
||||
// parse function provided by the property type.
|
||||
// Can't be overridden by property implementations.
|
||||
// arg: char*
|
||||
M_PROPERTY_PARSE,
|
||||
|
||||
// Get a string containing a parsable representation.
|
||||
// Can't be overridden by property implementations.
|
||||
// arg: char**
|
||||
M_PROPERTY_TO_STRING,
|
||||
M_PROPERTY_SET_STRING,
|
||||
|
||||
// Pass down an action to a sub-property.
|
||||
// arg: struct m_property_action_arg*
|
||||
// arg: struct m_property_action_arg*
|
||||
M_PROPERTY_KEY_ACTION,
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user