options: remove some unneeded stuff

No options pointing to global variables are in use anymore, so that part
can be removed.
This commit is contained in:
wm4 2014-06-13 02:16:47 +02:00
parent e00aad18cb
commit a64e099efc
3 changed files with 21 additions and 28 deletions

View File

@ -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 {

View File

@ -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

View File

@ -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),