mirror of
https://github.com/mpv-player/mpv
synced 2025-03-19 09:57:34 +00:00
options: remove some more stuff
The "classic" sub-option stuff is not really needed anymore. The only remaining use can be emulated in a simpler way. But note that this breaks the --screenshot option (instead of the "flat" options like --screenshot-...). This was undocumented and discouraged, so it shouldn't affect anyone.
This commit is contained in:
parent
a64e099efc
commit
b7bedbbc36
@ -391,25 +391,20 @@ static void m_config_add_option(struct m_config *config,
|
||||
|
||||
// Option with children -> add them
|
||||
if (arg->type->flags & M_OPT_TYPE_HAS_CHILD) {
|
||||
if (arg->type->flags & M_OPT_TYPE_USE_SUBSTRUCT) {
|
||||
const struct m_sub_options *subopts = arg->priv;
|
||||
const struct m_sub_options *subopts = arg->priv;
|
||||
|
||||
void *new_optstruct = NULL;
|
||||
if (co.data) {
|
||||
new_optstruct = m_config_alloc_struct(config, subopts);
|
||||
substruct_write_ptr(co.data, new_optstruct);
|
||||
}
|
||||
|
||||
const void *new_optstruct_def = substruct_read_ptr(co.default_data);
|
||||
if (!new_optstruct_def)
|
||||
new_optstruct_def = subopts->defaults;
|
||||
|
||||
add_options(config, co.name, new_optstruct,
|
||||
new_optstruct_def, subopts->opts);
|
||||
} else {
|
||||
const struct m_option *sub = arg->priv;
|
||||
add_options(config, co.name, optstruct, optstruct_def, sub);
|
||||
void *new_optstruct = NULL;
|
||||
if (co.data) {
|
||||
new_optstruct = m_config_alloc_struct(config, subopts);
|
||||
substruct_write_ptr(co.data, new_optstruct);
|
||||
}
|
||||
|
||||
const void *new_optstruct_def = substruct_read_ptr(co.default_data);
|
||||
if (!new_optstruct_def)
|
||||
new_optstruct_def = subopts->defaults;
|
||||
|
||||
add_options(config, co.name, new_optstruct,
|
||||
new_optstruct_def, subopts->opts);
|
||||
} else {
|
||||
// Initialize options
|
||||
if (co.data && co.default_data) {
|
||||
|
@ -1616,18 +1616,11 @@ static int parse_subconf(struct mp_log *log, const m_option_t *opt,
|
||||
}
|
||||
|
||||
const m_option_type_t m_option_type_subconfig = {
|
||||
// The syntax is -option opt1=foo:flag:opt2=blah
|
||||
.name = "Subconfig",
|
||||
.flags = M_OPT_TYPE_HAS_CHILD,
|
||||
.parse = parse_subconf,
|
||||
};
|
||||
|
||||
const m_option_type_t m_option_type_subconfig_struct = {
|
||||
.name = "Subconfig",
|
||||
.flags = M_OPT_TYPE_HAS_CHILD | M_OPT_TYPE_USE_SUBSTRUCT,
|
||||
.parse = parse_subconf,
|
||||
};
|
||||
|
||||
#undef VAL
|
||||
#define VAL(x) (*(char **)(x))
|
||||
|
||||
|
@ -55,7 +55,6 @@ extern const m_option_type_t m_option_type_choice;
|
||||
extern const m_option_type_t m_option_type_msglevels;
|
||||
extern const m_option_type_t m_option_type_print_fn;
|
||||
extern const m_option_type_t m_option_type_subconfig;
|
||||
extern const m_option_type_t m_option_type_subconfig_struct;
|
||||
extern const m_option_type_t m_option_type_imgfmt;
|
||||
extern const m_option_type_t m_option_type_fourcc;
|
||||
extern const m_option_type_t m_option_type_afmt;
|
||||
@ -164,7 +163,7 @@ struct m_opt_choice_alternatives {
|
||||
typedef int (*m_opt_string_validate_fn)(struct mp_log *log, const m_option_t *opt,
|
||||
struct bstr name, struct bstr param);
|
||||
|
||||
// m_option.priv points to this if M_OPT_TYPE_USE_SUBSTRUCT is used
|
||||
// m_option.priv points to this if OPT_SUBSTRUCT is used
|
||||
struct m_sub_options {
|
||||
const struct m_option *opts;
|
||||
size_t size;
|
||||
@ -178,7 +177,6 @@ struct m_sub_options {
|
||||
#define CONF_TYPE_FLOAT (&m_option_type_float)
|
||||
#define CONF_TYPE_DOUBLE (&m_option_type_double)
|
||||
#define CONF_TYPE_STRING (&m_option_type_string)
|
||||
#define CONF_TYPE_SUBCONFIG (&m_option_type_subconfig)
|
||||
#define CONF_TYPE_STRING_LIST (&m_option_type_string_list)
|
||||
#define CONF_TYPE_IMGFMT (&m_option_type_imgfmt)
|
||||
#define CONF_TYPE_FOURCC (&m_option_type_fourcc)
|
||||
@ -398,10 +396,6 @@ struct m_option {
|
||||
// options can be used without "=" and value.
|
||||
#define M_OPT_TYPE_OPTIONAL_PARAM (1 << 3)
|
||||
|
||||
// modify M_OPT_TYPE_HAS_CHILD so that m_option::p points to
|
||||
// struct m_sub_options, instead of a direct m_option array.
|
||||
#define M_OPT_TYPE_USE_SUBSTRUCT (1 << 4)
|
||||
|
||||
///////////////////////////// Parser flags /////////////////////////////////
|
||||
|
||||
// OptionParserReturn
|
||||
@ -675,7 +669,7 @@ extern const char m_option_path_separator;
|
||||
// the subconf struct.
|
||||
#define OPT_SUBSTRUCT(name, varname, subconf, flagv) \
|
||||
OPT_GENERAL_NOTYPE(name, varname, flagv, \
|
||||
.type = &m_option_type_subconfig_struct, \
|
||||
.type = &m_option_type_subconfig, \
|
||||
.priv = (void*)&subconf)
|
||||
|
||||
#endif /* MPLAYER_M_OPTION_H */
|
||||
|
@ -80,12 +80,6 @@ extern const struct m_obj_list ao_obj_list;
|
||||
|
||||
#define OPT_BASE_STRUCT struct MPOpts
|
||||
|
||||
static const m_option_t screenshot_conf[] = {
|
||||
OPT_SUBSTRUCT("", screenshot_image_opts, image_writer_conf, 0),
|
||||
OPT_STRING("template", screenshot_template, 0),
|
||||
{0},
|
||||
};
|
||||
|
||||
const m_option_t mp_opts[] = {
|
||||
// handled in command line pre-parser (parse_commandline.c)
|
||||
{"v", CONF_TYPE_STORE, CONF_GLOBAL | CONF_NOCFG, .offset = -1},
|
||||
@ -502,8 +496,8 @@ const m_option_t mp_opts[] = {
|
||||
OPT_FLAG("input-terminal", consolecontrols, CONF_GLOBAL),
|
||||
OPT_FLAG("input-cursor", vo.enable_mouse_movements, CONF_GLOBAL),
|
||||
|
||||
{"screenshot", CONF_TYPE_SUBCONFIG, .priv = (void *)screenshot_conf,
|
||||
.offset = -1},
|
||||
OPT_SUBSTRUCT("screenshot", screenshot_image_opts, image_writer_conf, 0),
|
||||
OPT_STRING("screenshot-template", screenshot_template, 0),
|
||||
|
||||
OPT_SUBSTRUCT("input", input_opts, input_config, 0),
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user