mirror of https://github.com/mpv-player/mpv
options: Add validation macro for int type
As an illustrative example.
This commit is contained in:
parent
c8f474e3e5
commit
e5551f775d
|
@ -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) \
|
||||
|
|
Loading…
Reference in New Issue