diff options
author | wm4 <wm4@nowhere> | 2012-08-06 17:45:17 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-08-06 17:45:17 +0200 |
commit | 7aae399239d02e48de9060dded1d0232310d2141 (patch) | |
tree | c4ede71396dccdc0a661d28fb4089af4c279aa05 /m_option.c | |
parent | 0c1dd8a8f54a152755faef3d323ce6fdc7d63f73 (diff) | |
download | mpv-7aae399239d02e48de9060dded1d0232310d2141.tar.bz2 mpv-7aae399239d02e48de9060dded1d0232310d2141.tar.xz |
m_config: support auto-allocated sub-structs
Given your option struct has a field that is a pointer to another
struct, this commit allows you to declare options that write into that
other struct. The code in m_config will dereference the pointer field
on its own if such an option is accessed. If the field is NULL on
initialization of the containing m_config, the struct is automatically
allocated.
OPT_SUBSTRUCT() can be used to declare such a field.
struct m_sub_options is used to describe the pointed-to struct, and
includes size and defaults if the struct has to be allocated by
m_config.
Diffstat (limited to 'm_option.c')
-rw-r--r-- | m_option.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/m_option.c b/m_option.c index 35b5efc98d..22abee1496 100644 --- a/m_option.c +++ b/m_option.c @@ -907,6 +907,12 @@ const m_option_type_t m_option_type_subconfig = { .parse = parse_subconf, }; +const m_option_type_t m_option_type_subconfig_struct = { + .name = "Subconfig", + .flags = M_OPT_TYPE_HAS_CHILD | M_OPT_TYPE_USE_SUBSTRUCT, + .parse = parse_subconf, +}; + #include "libmpcodecs/img_format.h" /* FIXME: snyc with img_format.h */ |