From be337aa41567b6603ad5b017ff8add6a5f1e0bd8 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 2 Aug 2014 01:35:32 +0200 Subject: command: add a property that returns a list of all properties Also remove the undocumented Lua mp.property_list() function. --- DOCS/man/input.rst | 2 ++ player/command.c | 30 +++++++++++++++++++++++++----- player/command.h | 3 --- player/lua.c | 13 ------------- 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index 5a458fbd67..a4a314011d 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -1258,6 +1258,8 @@ Property list require reloading the file for changes to take effect. If there is an equivalent property, prefer setting the property instead. +``property-list`` + Return the list of top-level properties. Property Expansion ------------------ diff --git a/player/command.c b/player/command.c index dee8729b04..df44df5f69 100644 --- a/player/command.c +++ b/player/command.c @@ -2623,6 +2623,30 @@ static int mp_property_options(void *ctx, struct m_property *prop, return M_PROPERTY_NOT_IMPLEMENTED; } +static const struct m_property mp_properties[]; + +static int mp_property_list(void *ctx, struct m_property *prop, + int action, void *arg) +{ + switch (action) { + case M_PROPERTY_GET_TYPE: + *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING_LIST}; + return M_PROPERTY_OK; + case M_PROPERTY_GET: { + char **list = NULL; + int num = 0; + for (int n = 0; mp_properties[n].name; n++) { + MP_TARRAY_APPEND(NULL, list, num, + talloc_strdup(NULL, mp_properties[n].name)); + } + MP_TARRAY_APPEND(NULL, list, num, NULL); + *(char ***)arg = list; + return M_PROPERTY_OK; + } + } + return M_PROPERTY_NOT_IMPLEMENTED; +} + // Redirect a property name to another #define M_PROPERTY_ALIAS(name, real_property) \ {(name), mp_property_alias, .priv = (real_property)} @@ -2780,6 +2804,7 @@ static const struct m_property mp_properties[] = { M_PROPERTY_ALIAS("sub", "sid"), {"options", mp_property_options}, + {"property-list", mp_property_list}, {0}, }; @@ -2809,11 +2834,6 @@ static const char *const *const mp_event_property_change[] = { }; #undef E -const struct m_property *mp_get_property_list(void) -{ - return mp_properties; -} - static bool is_property_set(int action, void *val) { switch (action) { diff --git a/player/command.h b/player/command.h index c9a07ff733..2f9770b714 100644 --- a/player/command.h +++ b/player/command.h @@ -33,9 +33,6 @@ void property_print_help(struct mp_log *log); int mp_property_do(const char* name, int action, void* val, struct MPContext *mpctx); -const struct m_property *mp_get_property_list(void); -int mp_find_property_index(const char *property); - void mp_notify(struct MPContext *mpctx, int event, void *arg); void mp_notify_property(struct MPContext *mpctx, const char *property); diff --git a/player/lua.c b/player/lua.c index 81a6363d2a..ce0de907a5 100644 --- a/player/lua.c +++ b/player/lua.c @@ -699,18 +699,6 @@ static int script_set_property_native(lua_State *L) } -static int script_property_list(lua_State *L) -{ - const struct m_property *props = mp_get_property_list(); - lua_newtable(L); - for (int i = 0; props[i].name; i++) { - lua_pushinteger(L, i + 1); - lua_pushstring(L, props[i].name); - lua_settable(L, -3); - } - return 1; -} - static int script_get_property(lua_State *L) { struct script_ctx *ctx = get_ctx(L); @@ -1099,7 +1087,6 @@ static const struct fn_entry main_fns[] = { FN_ENTRY(set_property_native), FN_ENTRY(raw_observe_property), FN_ENTRY(raw_unobserve_property), - FN_ENTRY(property_list), FN_ENTRY(set_osd_ass), FN_ENTRY(get_osd_resolution), FN_ENTRY(get_screen_size), -- cgit v1.2.3