summaryrefslogtreecommitdiffstats
path: root/options/m_option.h
diff options
context:
space:
mode:
authorPhilip Langdale <philipl@overt.org>2021-03-20 11:50:22 -0700
committerJan Ekström <jeebjp@gmail.com>2021-03-28 19:46:32 +0300
commite5551f775dcdd1ab535f34171eb7f352443332fd (patch)
tree6fa4a12ce93d9e05c907a053d585453dbcf5c349 /options/m_option.h
parentc8f474e3e5005373796f2a9fea77aa57ffcd7637 (diff)
downloadmpv-e5551f775dcdd1ab535f34171eb7f352443332fd.tar.bz2
mpv-e5551f775dcdd1ab535f34171eb7f352443332fd.tar.xz
options: Add validation macro for int type
As an illustrative example.
Diffstat (limited to 'options/m_option.h')
-rw-r--r--options/m_option.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/options/m_option.h b/options/m_option.h
index e7446ce663..322f120a06 100644
--- a/options/m_option.h
+++ b/options/m_option.h
@@ -195,6 +195,9 @@ typedef int (*m_opt_generic_validate_fn)(struct mp_log *log, const m_option_t *o
typedef int (*m_opt_string_validate_fn)(struct mp_log *log, const m_option_t *opt,
struct bstr name, const char **value);
+typedef int (*m_opt_int_validate_fn)(struct mp_log *log, const m_option_t *opt,
+ struct bstr name, const int *value);
+
// m_option.priv points to this if OPT_SUBSTRUCT is used
struct m_sub_options {
@@ -674,6 +677,11 @@ extern const char m_option_path_separator;
#define OPT_CHANNELS(field) \
OPT_TYPED_FIELD(m_option_type_channels, struct m_channels, field)
+#define OPT_INT_VALIDATE(field, validate_fn) \
+ OPT_TYPED_FIELD(m_option_type_int, int, field), \
+ .validate = (m_opt_generic_validate_fn) \
+ MP_EXPECT_TYPE(m_opt_int_validate_fn, validate_fn)
+
#define OPT_STRING_VALIDATE(field, validate_fn) \
OPT_TYPED_FIELD(m_option_type_string, char*, field), \
.validate = (m_opt_generic_validate_fn) \