From da8daa8dfcbb21280d9ea40a772be82336246b22 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sat, 29 Jun 2019 23:10:34 -0400 Subject: [PATCH] debug: Allow "deprecated_in" for class deprecation. --- lib/gears/debug.lua | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/gears/debug.lua b/lib/gears/debug.lua index 4b6e328d..54bbeba3 100644 --- a/lib/gears/debug.lua +++ b/lib/gears/debug.lua @@ -130,12 +130,23 @@ end --- Create a class proxy with deprecation messages. -- This is useful when a class has moved somewhere else. --- @tparam table fallback The new class --- @tparam string old_name The old class name --- @tparam string new_name The new class name +-- @tparam table fallback The new class. +-- @tparam string old_name The old class name. +-- @tparam string new_name The new class name. +-- @tparam[opt={}] args The name. +-- @tparam[opt] number args.deprecated_in The version which deprecated this +-- class. -- @treturn table A proxy class. -- @staticfct gears.debug.deprecate_class -function debug.deprecate_class(fallback, old_name, new_name) +function debug.deprecate_class(fallback, old_name, new_name, args) + args = args or {} + if args.deprecated_in then + local dep_ver = "v" .. tostring(args.deprecated_in) + if awesome.version < dep_ver then + return fallback + end + end + local message = old_name.." has been renamed to "..new_name local function call(_,...)