Author: cazfi
Date: Fri Feb 19 07:05:02 2016
New Revision: 31980

URL: http://svn.gna.org/viewcvs/freeciv?rev=31980&view=rev
Log:
Added log.deprecation_warning() to lua API.

See patch #6916

Modified:
    trunk/common/scriptcore/api_common_utilities.c
    trunk/common/scriptcore/api_common_utilities.h
    trunk/common/scriptcore/tolua_common_a.pkg

Modified: trunk/common/scriptcore/api_common_utilities.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/scriptcore/api_common_utilities.c?rev=31980&r1=31979&r2=31980&view=diff
==============================================================================
--- trunk/common/scriptcore/api_common_utilities.c      (original)
+++ trunk/common/scriptcore/api_common_utilities.c      Fri Feb 19 07:05:02 2016
@@ -18,6 +18,7 @@
 #include <math.h>
 
 /* utilities */
+#include "deprecations.h"
 #include "log.h"
 #include "rand.h"
 
@@ -123,3 +124,25 @@
   return opposite_direction(dir);
 }
 
+/**************************************************************************
+  Lua script wants to warn about use of deprecated construct.
+**************************************************************************/
+void api_utilities_deprecation_warning(lua_State *L, char *method,
+                                       char *replacement,
+                                       char *deprecated_since)
+{
+  if (are_deprecation_warnings_enabled()) {
+    /* TODO: Keep track which deprecations we have already warned about, and 
do not keep spamming
+     * about them. */
+    if (deprecated_since != NULL && replacement != NULL) {
+      log_deprecation_always("Deprecated: lua construct \"%s\", deprecated 
since \"%s\", used. "
+                             "Use \"%s\" instead", method, deprecated_since, 
replacement);
+    } else if (replacement != NULL) {
+      log_deprecation_always("Deprecated: lua construct \"%s\" used. "
+                             "Use \"%s\" instead", method, replacement);
+    } else {
+      log_deprecation_always("Deprecated: lua construct \"%s\" used.",
+                             method);
+    }
+  }
+}

Modified: trunk/common/scriptcore/api_common_utilities.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/scriptcore/api_common_utilities.h?rev=31980&r1=31979&r2=31980&view=diff
==============================================================================
--- trunk/common/scriptcore/api_common_utilities.h      (original)
+++ trunk/common/scriptcore/api_common_utilities.h      Fri Feb 19 07:05:02 2016
@@ -34,6 +34,10 @@
 
 void api_utilities_log_base(lua_State *L, int level, const char *message);
 
+void api_utilities_deprecation_warning(lua_State *L, char *method,
+                                       char *replacement,
+                                       char *deprecated_since);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */

Modified: trunk/common/scriptcore/tolua_common_a.pkg
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/scriptcore/tolua_common_a.pkg?rev=31980&r1=31979&r2=31980&view=diff
==============================================================================
--- trunk/common/scriptcore/tolua_common_a.pkg  (original)
+++ trunk/common/scriptcore/tolua_common_a.pkg  Fri Feb 19 07:05:02 2016
@@ -65,6 +65,9 @@
 
   void api_utilities_log_base
     @ base (lua_State *L, int log_level, const char *message);
+
+  void api_utilities_deprecation_warning
+    @ deprecation_warning(lua_State *L, char *method, char *replacement, char 
*deprecated_since);
 }
 
 $[


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to