Browse Source

Use different output messages for deprecated methods versus functions.

--HG--
branch : minor
Alex Szpakowski 8 years ago
parent
commit
fcd9f1526c

+ 19 - 5
src/common/deprecation.cpp

@@ -91,9 +91,22 @@ std::string getDeprecationNotice(const DeprecationInfo &info, bool usewhere)
 	if (usewhere)
 	if (usewhere)
 		notice += info.where;
 		notice += info.where;
 
 
-	notice += "Using deprecated function " + info.name;
+	notice += "Using deprecated ";
+
+	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_REPLACEMENT && !info.replacement.empty())
+	if (info.type == DEPRECATED_REPLACED && !info.replacement.empty())
 		notice += " (replaced by " + info.replacement + ")";
 		notice += " (replaced by " + info.replacement + ")";
 	else if (info.type == DEPRECATED_RENAMED && !info.replacement.empty())
 	else if (info.type == DEPRECATED_RENAMED && !info.replacement.empty())
 		notice += " (renamed to " + info.replacement + ")";
 		notice += " (renamed to " + info.replacement + ")";
@@ -114,12 +127,12 @@ GetDeprecated::~GetDeprecated()
 		mutex->unlock();
 		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)
 	: info(nullptr)
 {
 {
 	if (mutex != nullptr)
 	if (mutex != nullptr)
@@ -137,6 +150,7 @@ MarkDeprecated::MarkDeprecated(const char *name, DeprecationType type, const cha
 		DeprecationInfo newinfo = {};
 		DeprecationInfo newinfo = {};
 
 
 		newinfo.type = type;
 		newinfo.type = type;
+		newinfo.apiType = api;
 		newinfo.uses = 1;
 		newinfo.uses = 1;
 		newinfo.name = name;
 		newinfo.name = name;
 
 

+ 12 - 3
src/common/deprecation.h

@@ -28,16 +28,25 @@
 namespace love
 namespace love
 {
 {
 
 
+enum APIType
+{
+	API_FUNCTION,
+	API_METHOD,
+	API_FIELD,
+	API_CONSTANT,
+};
+
 enum DeprecationType
 enum DeprecationType
 {
 {
 	DEPRECATED_NO_REPLACEMENT,
 	DEPRECATED_NO_REPLACEMENT,
-	DEPRECATED_REPLACEMENT,
+	DEPRECATED_REPLACED,
 	DEPRECATED_RENAMED,
 	DEPRECATED_RENAMED,
 };
 };
 
 
 struct DeprecationInfo
 struct DeprecationInfo
 {
 {
 	DeprecationType type;
 	DeprecationType type;
+	APIType apiType;
 	int64 uses;
 	int64 uses;
 	std::string name;
 	std::string name;
 	std::string replacement;
 	std::string replacement;
@@ -62,8 +71,8 @@ struct GetDeprecated
 
 
 struct MarkDeprecated
 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();
 	~MarkDeprecated();
 
 
 	DeprecationInfo *info;
 	DeprecationInfo *info;

+ 4 - 4
src/common/runtime.cpp

@@ -786,14 +786,14 @@ lua_State *luax_getpinnedthread(lua_State *L)
 	return thread;
 	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)
 	if (deprecated.info != nullptr && deprecated.info->uses == 1)
 	{
 	{

+ 2 - 2
src/common/runtime.h

@@ -452,8 +452,8 @@ lua_State *luax_getpinnedthread(lua_State *L);
  * Mark a function as deprecated. Should only be called inside wrapper function
  * Mark a function as deprecated. Should only be called inside wrapper function
  * code.
  * 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
 extern "C" { // Also called from luasocket
 	int luax_typerror(lua_State *L, int narg, const char *tname);
 	int luax_typerror(lua_State *L, int narg, const char *tname);

+ 1 - 1
src/modules/audio/wrap_Audio.cpp

@@ -526,7 +526,7 @@ int w_setMixWithSystem(lua_State *L)
 
 
 int w_getSourceCount(lua_State *L)
 int w_getSourceCount(lua_State *L)
 {
 {
-	luax_markdeprecated(L, "love.audio.getSourceCount", DEPRECATED_RENAMED, "love.audio.getActiveSourceCount");
+	luax_markdeprecated(L, "love.audio.getSourceCount", API_FUNCTION, DEPRECATED_RENAMED, "love.audio.getActiveSourceCount");
 	return w_getActiveSourceCount(L);
 	return w_getActiveSourceCount(L);
 }
 }
 
 

+ 1 - 1
src/modules/audio/wrap_Source.cpp

@@ -584,7 +584,7 @@ int w_Source_getType(lua_State *L)
 
 
 int w_Source_getChannels(lua_State *L)
 int w_Source_getChannels(lua_State *L)
 {
 {
-	luax_markdeprecated(L, "Source:getChannels", DEPRECATED_RENAMED, "Source:getChannelCount");
+	luax_markdeprecated(L, "Source:getChannels", API_METHOD, DEPRECATED_RENAMED, "Source:getChannelCount");
 	return w_Source_getChannelCount(L);
 	return w_Source_getChannelCount(L);
 }
 }
 
 

+ 1 - 1
src/modules/physics/box2d/wrap_PrismaticJoint.cpp

@@ -180,7 +180,7 @@ int w_PrismaticJoint_getReferenceAngle(lua_State *L)
 
 
 int w_PrismaticJoint_hasLimitsEnabled(lua_State *L)
 int w_PrismaticJoint_hasLimitsEnabled(lua_State *L)
 {
 {
-	luax_markdeprecated(L, "PrismaticJoint:hasLimitsEnabled", DEPRECATED_RENAMED, "PrismaticJoint:areLimitsEnabled");
+	luax_markdeprecated(L, "PrismaticJoint:hasLimitsEnabled", API_METHOD, DEPRECATED_RENAMED, "PrismaticJoint:areLimitsEnabled");
 	return w_PrismaticJoint_areLimitsEnabled(L);
 	return w_PrismaticJoint_areLimitsEnabled(L);
 }
 }
 
 

+ 1 - 1
src/modules/physics/box2d/wrap_RevoluteJoint.cpp

@@ -173,7 +173,7 @@ int w_RevoluteJoint_getReferenceAngle(lua_State *L)
 
 
 int w_RevoluteJoint_hasLimitsEnabled(lua_State *L)
 int w_RevoluteJoint_hasLimitsEnabled(lua_State *L)
 {
 {
-	luax_markdeprecated(L, "RevoluteJoint:hasLimitsEnabled", DEPRECATED_RENAMED, "RevoluteJoint:areLimitsEnabled");
+	luax_markdeprecated(L, "RevoluteJoint:hasLimitsEnabled", API_METHOD, DEPRECATED_RENAMED, "RevoluteJoint:areLimitsEnabled");
 	return w_RevoluteJoint_areLimitsEnabled(L);
 	return w_RevoluteJoint_areLimitsEnabled(L);
 }
 }
 
 

+ 1 - 1
src/modules/sound/wrap_Decoder.cpp

@@ -98,7 +98,7 @@ int w_Decoder_seek(lua_State *L)
 
 
 int w_Decoder_getChannels(lua_State *L)
 int w_Decoder_getChannels(lua_State *L)
 {
 {
-	luax_markdeprecated(L, "Decoder:getChannels", DEPRECATED_RENAMED, "Decoder:getChannelCount");
+	luax_markdeprecated(L, "Decoder:getChannels", API_METHOD, DEPRECATED_RENAMED, "Decoder:getChannelCount");
 	return w_Decoder_getChannelCount(L);
 	return w_Decoder_getChannelCount(L);
 }
 }
 
 

+ 1 - 1
src/modules/sound/wrap_SoundData.cpp

@@ -107,7 +107,7 @@ int w_SoundData_getSample(lua_State *L)
 
 
 int w_SoundData_getChannels(lua_State *L)
 int w_SoundData_getChannels(lua_State *L)
 {
 {
-	luax_markdeprecated(L, "SoundData:getChannels", DEPRECATED_RENAMED, "SoundData:getChannelCount");
+	luax_markdeprecated(L, "SoundData:getChannels", API_METHOD, DEPRECATED_RENAMED, "SoundData:getChannelCount");
 	return w_SoundData_getChannelCount(L);
 	return w_SoundData_getChannelCount(L);
 }
 }