aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@nowhere>2015-05-22 20:01:12 +0200
committerGravatar wm4 <wm4@nowhere>2015-05-22 20:02:04 +0200
commitc2f9e3d2b3431ae750aa3b51a0a60d7bf73deb0f (patch)
tree7bb418a7182d4e9b222e1003ab854e1991af8efb
parent17b3cab983e8d2d802d01e99602dcc741d417f89 (diff)
command: add a new property deprecation mechanism
Looks like this will be needed a lot...
-rw-r--r--player/command.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/player/command.c b/player/command.c
index e044e3320a..e849275547 100644
--- a/player/command.c
+++ b/player/command.c
@@ -75,6 +75,9 @@ struct command_ctx {
double prev_pts;
+ char **warned_deprecated;
+ int num_warned_deprecated;
+
struct cycle_counter *cycle_counters;
int num_cycle_counters;
@@ -3081,6 +3084,29 @@ static int mp_property_alias(void *ctx, struct m_property *prop,
return mp_property_do(real_property, action, arg, ctx);
}
+static int mp_property_deprecated_alias(void *ctx, struct m_property *prop,
+ int action, void *arg)
+{
+ MPContext *mpctx = ctx;
+ struct command_ctx *cmd = mpctx->command_ctx;
+ const char *real_property = prop->priv;
+ if (action == M_PROPERTY_SET || action == M_PROPERTY_GET ||
+ action == M_PROPERTY_PRINT)
+ {
+ for (int n = 0; n < cmd->num_warned_deprecated; n++) {
+ if (strcmp(cmd->warned_deprecated[n], prop->name) == 0)
+ goto done;
+ }
+ MP_WARN(mpctx, "Warning: property '%s' was replaced with '%s' and "
+ "might be removed in the future.\n", prop->name, real_property);
+ MP_TARRAY_APPEND(cmd, cmd->warned_deprecated, cmd->num_warned_deprecated,
+ (char *)prop->name);
+
+ done:;
+ }
+ return mp_property_do(real_property, action, arg, ctx);
+}
+
static int access_options(struct m_property_action_arg *ka, bool local,
MPContext *mpctx)
{
@@ -3237,6 +3263,9 @@ static int mp_property_list(void *ctx, struct m_property *prop,
#define M_PROPERTY_ALIAS(name, real_property) \
{(name), mp_property_alias, .priv = (real_property)}
+#define M_PROPERTY_DEPRECATED_ALIAS(name, real_property) \
+ {(name), mp_property_deprecated_alias, .priv = (real_property)}
+
/// All properties available in MPlayer.
/** \ingroup Properties
*/