Author: cazfi
Date: Fri Feb 19 07:05:13 2016
New Revision: 31981

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

See patch #6916

Modified:
    branches/S2_6/common/scriptcore/api_common_utilities.c
    branches/S2_6/common/scriptcore/api_common_utilities.h
    branches/S2_6/common/scriptcore/tolua_common_a.pkg

Modified: branches/S2_6/common/scriptcore/api_common_utilities.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/scriptcore/api_common_utilities.c?rev=31981&r1=31980&r2=31981&view=diff
==============================================================================
--- branches/S2_6/common/scriptcore/api_common_utilities.c      (original)
+++ branches/S2_6/common/scriptcore/api_common_utilities.c      Fri Feb 19 
07:05:13 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: branches/S2_6/common/scriptcore/api_common_utilities.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/scriptcore/api_common_utilities.h?rev=31981&r1=31980&r2=31981&view=diff
==============================================================================
--- branches/S2_6/common/scriptcore/api_common_utilities.h      (original)
+++ branches/S2_6/common/scriptcore/api_common_utilities.h      Fri Feb 19 
07:05:13 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: branches/S2_6/common/scriptcore/tolua_common_a.pkg
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/scriptcore/tolua_common_a.pkg?rev=31981&r1=31980&r2=31981&view=diff
==============================================================================
--- branches/S2_6/common/scriptcore/tolua_common_a.pkg  (original)
+++ branches/S2_6/common/scriptcore/tolua_common_a.pkg  Fri Feb 19 07:05:13 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