Use different output messages for deprecated methods versus functions.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2017-08-27 16:55:33 -03:00
parent 3128a127cf
commit fcd9f1526c
10 changed files with 43 additions and 20 deletions
+19 -5
View File
@@ -91,9 +91,22 @@ std::string getDeprecationNotice(const DeprecationInfo &info, bool usewhere)
if (usewhere)
notice += info.where;
notice += "Using deprecated function " + info.name;
notice += "Using deprecated ";
if (info.type == DEPRECATED_REPLACEMENT && !info.replacement.empty())
if (info.apiType == API_FUNCTION)
notice += "function ";
else if (info.apiType == API_METHOD)
notice += "method ";
else if (info.apiType == API_FIELD)
notice += "field ";
else if (info.apiType == API_CONSTANT)
notice += "constant ";
else
notice += "API ";
notice += info.name;
if (info.type == DEPRECATED_REPLACED && !info.replacement.empty())
notice += " (replaced by " + info.replacement + ")";
else if (info.type == DEPRECATED_RENAMED && !info.replacement.empty())
notice += " (renamed to " + info.replacement + ")";
@@ -114,12 +127,12 @@ GetDeprecated::~GetDeprecated()
mutex->unlock();
}
MarkDeprecated::MarkDeprecated(const char *name)
: MarkDeprecated(name, DEPRECATED_NO_REPLACEMENT, nullptr)
MarkDeprecated::MarkDeprecated(const char *name, APIType api)
: MarkDeprecated(name, api, DEPRECATED_NO_REPLACEMENT, nullptr)
{
}
MarkDeprecated::MarkDeprecated(const char *name, DeprecationType type, const char *replacement)
MarkDeprecated::MarkDeprecated(const char *name, APIType api, DeprecationType type, const char *replacement)
: info(nullptr)
{
if (mutex != nullptr)
@@ -137,6 +150,7 @@ MarkDeprecated::MarkDeprecated(const char *name, DeprecationType type, const cha
DeprecationInfo newinfo = {};
newinfo.type = type;
newinfo.apiType = api;
newinfo.uses = 1;
newinfo.name = name;
+12 -3
View File
@@ -28,16 +28,25 @@
namespace love
{
enum APIType
{
API_FUNCTION,
API_METHOD,
API_FIELD,
API_CONSTANT,
};
enum DeprecationType
{
DEPRECATED_NO_REPLACEMENT,
DEPRECATED_REPLACEMENT,
DEPRECATED_REPLACED,
DEPRECATED_RENAMED,
};
struct DeprecationInfo
{
DeprecationType type;
APIType apiType;
int64 uses;
std::string name;
std::string replacement;
@@ -62,8 +71,8 @@ struct GetDeprecated
struct MarkDeprecated
{
MarkDeprecated(const char *name);
MarkDeprecated(const char *name, DeprecationType type, const char *replacement);
MarkDeprecated(const char *name, APIType api);
MarkDeprecated(const char *name, APIType api, DeprecationType type, const char *replacement);
~MarkDeprecated();
DeprecationInfo *info;
+4 -4
View File
@@ -786,14 +786,14 @@ lua_State *luax_getpinnedthread(lua_State *L)
return thread;
}
void luax_markdeprecated(lua_State *L, const char *name)
void luax_markdeprecated(lua_State *L, const char *name, APIType api)
{
luax_markdeprecated(L, name, DEPRECATED_NO_REPLACEMENT, nullptr);
luax_markdeprecated(L, name, api, DEPRECATED_NO_REPLACEMENT, nullptr);
}
void luax_markdeprecated(lua_State *L, const char *name, DeprecationType type, const char *replacement)
void luax_markdeprecated(lua_State *L, const char *name, APIType api, DeprecationType type, const char *replacement)
{
MarkDeprecated deprecated(name, type, replacement);
MarkDeprecated deprecated(name, api, type, replacement);
if (deprecated.info != nullptr && deprecated.info->uses == 1)
{
+2 -2
View File
@@ -452,8 +452,8 @@ lua_State *luax_getpinnedthread(lua_State *L);
* Mark a function as deprecated. Should only be called inside wrapper function
* code.
**/
void luax_markdeprecated(lua_State *L, const char *name);
void luax_markdeprecated(lua_State *L, const char *name, DeprecationType type, const char *replacement);
void luax_markdeprecated(lua_State *L, const char *name, APIType api);
void luax_markdeprecated(lua_State *L, const char *name, APIType api, DeprecationType type, const char *replacement);
extern "C" { // Also called from luasocket
int luax_typerror(lua_State *L, int narg, const char *tname);