summaryrefslogtreecommitdiffstats
path: root/core/m_option.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-09-20 03:32:01 +0200
committerwm4 <wm4@nowhere>2013-02-09 00:21:16 +0100
commit830560979c02b4e06924a813cf9bacb1629d40c9 (patch)
treec90295bcc2bc77bee2d2a8c13d661d5b20772117 /core/m_option.h
parentae070a6f1eff9f38dcd3ec785dd1f251e3761472 (diff)
downloadmpv-830560979c02b4e06924a813cf9bacb1629d40c9.tar.bz2
mpv-830560979c02b4e06924a813cf9bacb1629d40c9.tar.xz
options: change handling of "no-" options
Normally, all flag options can be negated by prepending a "no-", for example "--no-opt" becomes "--opt=no". Some flag options can't actually be negated, so add a CONF_TYPE_STORE option type to disallow the "no-" fallback. Do the same for choice options. Remove the explicit "no-" prefixed options, add "no" as choice. Move the handling of automatic "no-" options from parser-mpcmd.c to m_config.c, and use it in m_config_set_option/m_config_parse_option. This makes these options available in the config file. It also simplifies sub-option parsing, because it doesn't need to handle "no-" anymore.
Diffstat (limited to 'core/m_option.h')
-rw-r--r--core/m_option.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/core/m_option.h b/core/m_option.h
index 81ab73e98b..a3da08ea7a 100644
--- a/core/m_option.h
+++ b/core/m_option.h
@@ -36,6 +36,7 @@ struct m_struct_st;
// Simple types
extern const m_option_type_t m_option_type_flag;
+extern const m_option_type_t m_option_type_store;
extern const m_option_type_t m_option_type_int;
extern const m_option_type_t m_option_type_int64;
extern const m_option_type_t m_option_type_intpair;
@@ -180,6 +181,7 @@ struct m_sub_options {
// FIXME: backward compatibility
#define CONF_TYPE_FLAG (&m_option_type_flag)
+#define CONF_TYPE_STORE (&m_option_type_store)
#define CONF_TYPE_INT (&m_option_type_int)
#define CONF_TYPE_INT64 (&m_option_type_int64)
#define CONF_TYPE_FLOAT (&m_option_type_float)
@@ -205,6 +207,7 @@ struct m_sub_options {
// size/alignment requirements for option values in general.
union m_option_value {
int flag; // not the C type "bool"!
+ int store;
int int_;
int64_t int64;
float float_;
@@ -513,6 +516,7 @@ static inline void m_option_free(const m_option_t *opt, void *dst)
#define OPT_MAKE_FLAGS OPT_FLAG_ON
#define OPT_FLAG_CONSTANTS(...) OPT_FLAG_CONSTANTS_(__VA_ARGS__, .type = &m_option_type_flag)
#define OPT_FLAG_CONSTANTS_(optname, varname, flags, offvalue, value, ...) OPT_GENERAL(optname, varname, flags, .min = offvalue, .max = value, __VA_ARGS__)
+#define OPT_FLAG_STORE(optname, varname, flags, value) OPT_GENERAL(optname, varname, flags, .max = value, .type = &m_option_type_store)
#define OPT_STRINGLIST(...) OPT_GENERAL(__VA_ARGS__, .type = &m_option_type_string_list)
#define OPT_PATHLIST(...) OPT_GENERAL(__VA_ARGS__, .type = &m_option_type_string_list, .priv = (void *)&(const char){OPTION_PATH_SEPARATOR})
#define OPT_INT(...) OPT_GENERAL(__VA_ARGS__, .type = &m_option_type_int)