summaryrefslogtreecommitdiffstats
path: root/options/m_property.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-06-13 02:11:39 +0200
committerwm4 <wm4@nowhere>2014-06-13 02:11:39 +0200
commite00aad18cb76d39cc520526cece1505c63a8afe0 (patch)
tree2c75ce913dd360f860713fc1937a8e6380b9a091 /options/m_property.h
parent6a4a5595d8d2a17188cdea64dfdfceed88d1905a (diff)
downloadmpv-e00aad18cb76d39cc520526cece1505c63a8afe0.tar.bz2
mpv-e00aad18cb76d39cc520526cece1505c63a8afe0.tar.xz
command: redo the property type
Instead of absuing m_option to store the property list, introduce a separate type for properties. m_option is still used to handle data types. The property declaration itself now never contains the option type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This was already done with some properties, now all properties use it.) This also fixes that the function signatures did not match the function type with which these functions were called. They were called as: int (*)(const m_option_t*, int, void*, void*) but the actual function signatures were: int (*)(m_option_t*, int, void*, MPContext *) Two arguments were mismatched. This adds one line per property implementation. With additional the reordering of the parameters, this makes most of the changes in this commit.
Diffstat (limited to 'options/m_property.h')
-rw-r--r--options/m_property.h35
1 files changed, 20 insertions, 15 deletions
diff --git a/options/m_property.h b/options/m_property.h
index 7ba2c5181d..78b3292fba 100644
--- a/options/m_property.h
+++ b/options/m_property.h
@@ -26,8 +26,6 @@
struct mp_log;
-extern const struct m_option_type m_option_type_dummy;
-
enum mp_property_action {
// Get the property type. This defines the fundamental data type read from
// or written to the property.
@@ -120,11 +118,22 @@ enum mp_property_return {
M_PROPERTY_INVALID_FORMAT = -4,
};
+struct m_property {
+ const char *name;
+ // ctx: opaque caller context, which the property might use
+ // prop: pointer to this struct
+ // action: one of enum mp_property_action
+ // arg: specific to the action
+ // returns: one of enum mp_property_return
+ int (*call)(void *ctx, struct m_property *prop, int action, void *arg);
+ void *priv;
+};
+
// Access a property.
// action: one of m_property_action
// ctx: opaque value passed through to property implementation
// returns: one of mp_property_return
-int m_property_do(struct mp_log *log, const struct m_option* prop_list,
+int m_property_do(struct mp_log *log, const struct m_property* prop_list,
const char* property_name, int action, void* arg, void *ctx);
// Given a path of the form "a/b/c", this function will set *prefix to "a",
@@ -135,7 +144,7 @@ bool m_property_split_path(const char *path, bstr *prefix, char **rem);
// Print a list of properties.
void m_properties_print_help_list(struct mp_log *log,
- const struct m_option* list);
+ const struct m_property *list);
// Expand a property string.
// This function allows to print strings containing property values.
@@ -149,20 +158,16 @@ void m_properties_print_help_list(struct mp_log *log,
// STR is recursively expanded using the same rules.
// "$$" can be used to escape "$", and "$}" to escape "}".
// "$>" disables parsing of "$" for the rest of the string.
-char* m_properties_expand_string(const struct m_option* prop_list,
+char* m_properties_expand_string(const struct m_property *prop_list,
const char *str, void *ctx);
// Trivial helpers for implementing properties.
-int m_property_int_ro(const struct m_option* prop, int action, void* arg,
- int var);
-int m_property_int64_ro(const struct m_option* prop, int action, void* arg,
- int64_t var);
-int m_property_float_ro(const struct m_option* prop, int action, void* arg,
- float var);
-int m_property_double_ro(const struct m_option* prop, int action, void* arg,
- double var);
-int m_property_strdup_ro(const struct m_option* prop, int action, void* arg,
- const char *var);
+int m_property_flag_ro(int action, void* arg, int var);
+int m_property_int_ro(int action, void* arg, int var);
+int m_property_int64_ro(int action, void* arg, int64_t var);
+int m_property_float_ro(int action, void* arg, float var);
+int m_property_double_ro(int action, void* arg, double var);
+int m_property_strdup_ro(int action, void* arg, const char *var);
struct m_sub_property {
// Name of the sub-property - this will be prefixed with the parent