From a64e099efcc835e93ea9dafff9bb01829d632fa6 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 13 Jun 2014 02:16:47 +0200 Subject: options: remove some unneeded stuff No options pointing to global variables are in use anymore, so that part can be removed. --- options/m_config.c | 9 ++------- options/m_option.h | 16 ++++++---------- options/options.c | 24 +++++++++++++----------- 3 files changed, 21 insertions(+), 28 deletions(-) diff --git a/options/m_config.c b/options/m_config.c index ebb24ad098..585f1f5d81 100644 --- a/options/m_config.c +++ b/options/m_config.c @@ -323,8 +323,6 @@ static void add_negation_option(struct m_config *config, .name = opt->name, .type = CONF_TYPE_STORE, .flags = opt->flags & (M_OPT_NOCFG | M_OPT_GLOBAL | M_OPT_PRE_PARSE), - .is_new_option = opt->is_new_option, - .p = opt->p, .offset = opt->offset, .max = value, }; @@ -371,14 +369,11 @@ static void m_config_add_option(struct m_config *config, .name = arg->name, }; - if (arg->is_new_option) { + if (arg->offset >= 0) { if (optstruct) co.data = (char *)optstruct + arg->offset; if (optstruct_def) co.default_data = (char *)optstruct_def + arg->offset; - } else { - co.data = arg->p; - co.default_data = arg->p; } if (arg->defval) @@ -412,7 +407,7 @@ static void m_config_add_option(struct m_config *config, add_options(config, co.name, new_optstruct, new_optstruct_def, subopts->opts); } else { - const struct m_option *sub = arg->p; + const struct m_option *sub = arg->priv; add_options(config, co.name, optstruct, optstruct_def, sub); } } else { diff --git a/options/m_option.h b/options/m_option.h index fc210b3a43..3f1de72fd7 100644 --- a/options/m_option.h +++ b/options/m_option.h @@ -307,15 +307,14 @@ struct m_option { // Option name. const char *name; - // Deprecated field for "old" options which mutate global state. - void *p; - // Option type. const m_option_type_t *type; // See \ref OptionFlags. unsigned int flags; + int offset; + // \brief Mostly useful for numeric types, the \ref M_OPT_MIN flags must // also be set. double min; @@ -327,10 +326,6 @@ struct m_option { // Type dependent data (for all kinds of extended settings). void *priv; - int is_new_option; - - int offset; - // Initialize variable to given default before parsing options const void *defval; }; @@ -538,12 +533,12 @@ extern const char m_option_path_separator; #define OPTDEF_DOUBLE(d) .defval = (void *)&(const double){d} #define OPT_GENERAL(ctype, optname, varname, flagv, ...) \ - {.name = optname, .flags = flagv, .is_new_option = 1, \ + {.name = optname, .flags = flagv, \ .offset = MP_CHECKED_OFFSETOF(OPT_BASE_STRUCT, varname, ctype), \ __VA_ARGS__} #define OPT_GENERAL_NOTYPE(optname, varname, flagv, ...) \ - {.name = optname, .flags = flagv, .is_new_option = 1, \ + {.name = optname, .flags = flagv, \ .offset = offsetof(OPT_BASE_STRUCT, varname), \ __VA_ARGS__} @@ -669,7 +664,8 @@ extern const char m_option_path_separator; {.name = optname, \ .flags = M_OPT_FIXED | M_OPT_GLOBAL | M_OPT_NOCFG | M_OPT_PRE_PARSE, \ .type = &m_option_type_print_fn, \ - .priv = MP_EXPECT_TYPE(m_opt_print_fn, fn)} + .priv = MP_EXPECT_TYPE(m_opt_print_fn, fn), \ + .offset = -1} // subconf must have the type struct m_sub_options. // All sub-options are prefixed with "name-" and are added to the current diff --git a/options/options.c b/options/options.c index 5f2ca9687d..f9814e9da9 100644 --- a/options/options.c +++ b/options/options.c @@ -88,20 +88,21 @@ static const m_option_t screenshot_conf[] = { const m_option_t mp_opts[] = { // handled in command line pre-parser (parse_commandline.c) - {"v", NULL, CONF_TYPE_STORE, CONF_GLOBAL | CONF_NOCFG, 0, 0, NULL}, - {"playlist", NULL, CONF_TYPE_STRING, CONF_NOCFG | M_OPT_MIN | M_OPT_FIXED, - 1, 0, NULL}, - {"{", NULL, CONF_TYPE_STORE, CONF_NOCFG | M_OPT_FIXED, 0, 0, NULL}, - {"}", NULL, CONF_TYPE_STORE, CONF_NOCFG | M_OPT_FIXED, 0, 0, NULL}, + {"v", CONF_TYPE_STORE, CONF_GLOBAL | CONF_NOCFG, .offset = -1}, + {"playlist", CONF_TYPE_STRING, CONF_NOCFG | M_OPT_MIN | M_OPT_FIXED, + .min = 1, .offset = -1}, + {"{", CONF_TYPE_STORE, CONF_NOCFG | M_OPT_FIXED, .offset = -1}, + {"}", CONF_TYPE_STORE, CONF_NOCFG | M_OPT_FIXED, .offset = -1}, // handled in m_config.c - { "include", NULL, CONF_TYPE_STRING, M_OPT_FIXED }, - { "profile", NULL, CONF_TYPE_STRING_LIST, M_OPT_FIXED }, - { "show-profile", NULL, CONF_TYPE_STRING, CONF_NOCFG | M_OPT_FIXED }, - { "list-options", NULL, CONF_TYPE_STORE, CONF_NOCFG | M_OPT_FIXED }, + { "include", CONF_TYPE_STRING, M_OPT_FIXED, .offset = -1}, + { "profile", CONF_TYPE_STRING_LIST, M_OPT_FIXED, .offset = -1}, + { "show-profile", CONF_TYPE_STRING, CONF_NOCFG | M_OPT_FIXED, .offset = -1}, + { "list-options", CONF_TYPE_STORE, CONF_NOCFG | M_OPT_FIXED, .offset = -1}, // handled in main.c (looks at the raw argv[]) - {"leak-report", NULL, CONF_TYPE_STORE, CONF_GLOBAL | CONF_NOCFG | M_OPT_FIXED }, + { "leak-report", CONF_TYPE_STORE, CONF_GLOBAL | CONF_NOCFG | M_OPT_FIXED, + .offset = -1 }, OPT_FLAG("shuffle", shuffle, CONF_GLOBAL | CONF_NOCFG), @@ -501,7 +502,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", (void *) screenshot_conf, CONF_TYPE_SUBCONFIG}, + {"screenshot", CONF_TYPE_SUBCONFIG, .priv = (void *)screenshot_conf, + .offset = -1}, OPT_SUBSTRUCT("input", input_opts, input_config, 0), -- cgit v1.2.3