aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@nowhere>2014-06-13 02:17:31 +0200
committerGravatar wm4 <wm4@nowhere>2014-06-13 02:18:26 +0200
commitb7bedbbc367b0e248880d25139056a690ac996a2 (patch)
tree838eb2b7467089e39d8eea4d3a3995e7a5e7f0c0
parenta64e099efcc835e93ea9dafff9bb01829d632fa6 (diff)
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.
-rw-r--r--options/m_config.c27
-rw-r--r--options/m_option.c7
-rw-r--r--options/m_option.h10
-rw-r--r--options/options.c10
4 files changed, 15 insertions, 39 deletions
diff --git a/options/m_config.c b/options/m_config.c
index 585f1f5d81..d1f6faca0d 100644
--- a/options/m_config.c
+++ b/options/m_config.c
@@ -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);
- }
+ 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;
+ 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);
- }
+ add_options(config, co.name, new_optstruct,
+ new_optstruct_def, subopts->opts);
} else {
// Initialize options
if (co.data && co.default_data) {
diff --git a/options/m_option.c b/options/m_option.c
index b76fe072f4..04b4783dc1 100644
--- a/options/m_option.c
+++ b/options/m_option.c
@@ -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))
diff --git a/options/m_option.h b/options/m_option.h
index 3f1de72fd7..02fcb9bfca 100644
--- a/options/m_option.h
+++ b/options/m_option.h
@@ -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 */
diff --git a/options/options.c b/options/options.c
index f9814e9da9..4140c10c5a 100644
--- a/options/options.c
+++ b/options/options.c
@@ -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),