]> jfr.im git - irc/weechat/weechat.git/commitdiff
api: change type of argument remaining_calls in hook_timer callback from string to...
authorSébastien Helleu <redacted>
Thu, 29 Sep 2022 19:21:01 +0000 (21:21 +0200)
committerSébastien Helleu <redacted>
Thu, 29 Sep 2022 19:21:01 +0000 (21:21 +0200)
14 files changed:
ChangeLog.adoc
ReleaseNotes.adoc
doc/en/weechat_plugin_api.en.adoc
doc/fr/weechat_plugin_api.fr.adoc
doc/it/weechat_plugin_api.it.adoc
doc/ja/weechat_plugin_api.ja.adoc
doc/sr/weechat_plugin_api.sr.adoc
src/plugins/guile/weechat-guile-api.c
src/plugins/javascript/weechat-js-api.cpp
src/plugins/lua/weechat-lua-api.c
src/plugins/perl/weechat-perl-api.c
src/plugins/python/weechat-python-api.c
src/plugins/ruby/weechat-ruby-api.c
src/plugins/tcl/weechat-tcl-api.c

index 9d36352c70f36b8fc6778e1103584e5456860fc8..d3c80c9102fbe4053b58338dc6383a945c76ad88 100644 (file)
@@ -40,6 +40,7 @@ New features::
 Bug fixes::
 
   * core: fix wrong terminal title on terminal resize (issue #1702)
+  * api: change type of argument remaining_calls in hook_timer callback from string to integer (in scripts)
   * irc: fix duplicated channels in autojoin option when autojoin_dynamic is enabled (issue #1795)
   * irc: fix display of TOPIC and QUIT messages with an empty trailing parameter (issue #1797)
   * irc: fix parsing of messages with trailing spaces and no trailing parameter (issue #1803)
index 821138bbcd56c72a2e3891745e3731691f811a61..c4030389a7c27879614f6d7e1ab835f21da5c599 100644 (file)
@@ -20,6 +20,21 @@ https://weechat.org/files/changelog/ChangeLog-devel.html[ChangeLog]
 [[v3.7]]
 == Version 3.7 (under dev)
 
+[[v3.7_hook_timer_callback_remaining_calls]]
+=== Argument "remaining_calls" in callback of hook_timer
+
+In all script languages (except PHP), the argument "remaining_calls" sent to the
+callback of "hook_timer" is now an integer (it was a string in older releases).
+
+To be compatible with all versions, it is recommended to convert the argument
+to integer before testing it, for example in Python:
+
+[source,python]
+----
+if int(remaining_calls) > 0:
+    # ...
+----
+
 [[v3.7_delete_previous_word_whitespace]]
 === Delete previous word until whitespace
 
@@ -1804,9 +1819,16 @@ between your current keys and WeeChat default keys.
 === Function hook_print
 
 In scripts, the arguments "displayed" and "highlight" sent to the callback of
-"hook_print" are now integers (they were strings in older releases). +
+"hook_print" are now integers (they were strings in older releases).
+
 To be compatible with all versions, it is recommended to convert the argument
-to integer before testing it, for example in Python: `if int(highlight):`.
+to integer before testing it, for example in Python:
+
+[source,python]
+----
+if int(highlight):
+    # ...
+----
 
 [[v0.4.3]]
 == Version 0.4.3 (2014-02-09)
index fdcdb53ad2432c2073eaae7977cb9cf887b9689e..096911b9c4f52fea4767317cfc7d6b20ba43201e 100644 (file)
@@ -9325,7 +9325,7 @@ Script (Python):
 def hook_timer(interval: int, align_second: int, max_calls: int, callback: str, callback_data: str) -> str: ...
 
 # example
-def my_timer_cb(data: str, remaining_calls: str) -> int:
+def my_timer_cb(data: str, remaining_calls: int) -> int:
     # ...
     return weechat.WEECHAT_RC_OK
 
index c257feee88acd0c00b2e2ef7d6b5e67785b88a26..767836aa25a0f3eeda36b978b95c6e8a22f545c2 100644 (file)
@@ -9489,7 +9489,7 @@ Script (Python) :
 def hook_timer(interval: int, align_second: int, max_calls: int, callback: str, callback_data: str) -> str: ...
 
 # exemple
-def my_timer_cb(data: str, remaining_calls: str) -> int:
+def my_timer_cb(data: str, remaining_calls: int) -> int:
     # ...
     return weechat.WEECHAT_RC_OK
 
index e84e24d9df892f40387cd47d73e4e3ea0d09d63d..286b3e68ae0aeaf57f1307537f32a167b32b1282 100644 (file)
@@ -9620,7 +9620,7 @@ Script (Python):
 def hook_timer(interval: int, align_second: int, max_calls: int, callback: str, callback_data: str) -> str: ...
 
 # esempio
-def my_timer_cb(data: str, remaining_calls: str) -> int:
+def my_timer_cb(data: str, remaining_calls: int) -> int:
     # ...
     return weechat.WEECHAT_RC_OK
 
index 9667cc1294d8a29c82ac547d4529c751165fd2a6..f8c64cee51d448be178e11173a4833e3e5d15502 100644 (file)
@@ -9367,7 +9367,7 @@ struct t_hook *my_timer_hook =
 def hook_timer(interval: int, align_second: int, max_calls: int, callback: str, callback_data: str) -> str: ...
 
 # 例
-def my_timer_cb(data: str, remaining_calls: str) -> int:
+def my_timer_cb(data: str, remaining_calls: int) -> int:
     # ...
     return weechat.WEECHAT_RC_OK
 
index 391c12122c13d980fc7862b29963be2190140899..ae92d6453521fc915a960779d737d10d62661e13 100644 (file)
@@ -9037,7 +9037,7 @@ struct t_hook *my_timer_hook =
 def hook_timer(interval: int, align_second: int, max_calls: int, callback: str, callback_data: str) -> str: ...
 
 # пример
-def my_timer_cb(data: str, remaining_calls: str) -> int:
+def my_timer_cb(data: str, remaining_calls: int) -> int:
     # ...
     return weechat.WEECHAT_RC_OK
 
index ce0d8c75a25e3751f7abf00da7ced54caf6783e8..539c37020a834d00da6af8aa97f53f5bbcd16003 100644 (file)
@@ -2220,7 +2220,7 @@ weechat_guile_api_hook_timer_cb (const void *pointer, void *data,
 {
     struct t_plugin_script *script;
     void *func_argv[2];
-    char str_remaining_calls[32], empty_arg[1] = { '\0' };
+    char empty_arg[1] = { '\0' };
     const char *ptr_function, *ptr_data;
     int *rc, ret;
 
@@ -2229,16 +2229,13 @@ weechat_guile_api_hook_timer_cb (const void *pointer, void *data,
 
     if (ptr_function && ptr_function[0])
     {
-        snprintf (str_remaining_calls, sizeof (str_remaining_calls),
-                  "%d", remaining_calls);
-
         func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
-        func_argv[1] = str_remaining_calls;
+        func_argv[1] = &remaining_calls;
 
         rc = (int *) weechat_guile_exec (script,
                                          WEECHAT_SCRIPT_EXEC_INT,
                                          ptr_function,
-                                         "ss", func_argv);
+                                         "si", func_argv);
 
         if (!rc)
             ret = WEECHAT_RC_ERROR;
index 5019ccbe7529e19adb97a9e4f5206df046964204..8e2e56b851cb2bd17a1a0cf8d21d07953dd84252 100644 (file)
@@ -2125,7 +2125,7 @@ weechat_js_api_hook_timer_cb (const void *pointer, void *data,
 {
     struct t_plugin_script *script;
     void *func_argv[2];
-    char str_remaining_calls[32], empty_arg[1] = { '\0' };
+    char empty_arg[1] = { '\0' };
     const char *ptr_function, *ptr_data;
     int *rc, ret;
 
@@ -2134,16 +2134,13 @@ weechat_js_api_hook_timer_cb (const void *pointer, void *data,
 
     if (ptr_function && ptr_function[0])
     {
-        snprintf (str_remaining_calls, sizeof (str_remaining_calls),
-                  "%d", remaining_calls);
-
         func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
-        func_argv[1] = str_remaining_calls;
+        func_argv[1] = &remaining_calls;
 
         rc = (int *)weechat_js_exec (script,
                                      WEECHAT_SCRIPT_EXEC_INT,
                                      ptr_function,
-                                     "ss", func_argv);
+                                     "si", func_argv);
 
         if (!rc)
             ret = WEECHAT_RC_ERROR;
index 6364e86b7eda908cc612a201bd1c84fcee3b852b..f5bd9ec14cf3e2230bb85f296e6470f07db6528e 100644 (file)
@@ -2341,7 +2341,7 @@ weechat_lua_api_hook_timer_cb (const void *pointer, void *data,
 {
     struct t_plugin_script *script;
     void *func_argv[2];
-    char str_remaining_calls[32], empty_arg[1] = { '\0' };
+    char empty_arg[1] = { '\0' };
     const char *ptr_function, *ptr_data;
     int *rc, ret;
 
@@ -2350,16 +2350,13 @@ weechat_lua_api_hook_timer_cb (const void *pointer, void *data,
 
     if (ptr_function && ptr_function[0])
     {
-        snprintf (str_remaining_calls, sizeof (str_remaining_calls),
-                  "%d", remaining_calls);
-
         func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
-        func_argv[1] = str_remaining_calls;
+        func_argv[1] = &remaining_calls;
 
         rc = (int *) weechat_lua_exec (script,
                                        WEECHAT_SCRIPT_EXEC_INT,
                                        ptr_function,
-                                       "ss", func_argv);
+                                       "si", func_argv);
 
         if (!rc)
             ret = WEECHAT_RC_ERROR;
index d25c8f600fb7c74284b23a4136c96aeacc1aa3b0..c7fc20bde6ac7b5c6ed4132ee0248445e4b1a9d6 100644 (file)
@@ -2252,7 +2252,7 @@ weechat_perl_api_hook_timer_cb (const void *pointer, void *data,
 {
     struct t_plugin_script *script;
     void *func_argv[2];
-    char str_remaining_calls[32], empty_arg[1] = { '\0' };
+    char empty_arg[1] = { '\0' };
     const char *ptr_function, *ptr_data;
     int *rc, ret;
 
@@ -2261,16 +2261,13 @@ weechat_perl_api_hook_timer_cb (const void *pointer, void *data,
 
     if (ptr_function && ptr_function[0])
     {
-        snprintf (str_remaining_calls, sizeof (str_remaining_calls),
-                  "%d", remaining_calls);
-
         func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
-        func_argv[1] = str_remaining_calls;
+        func_argv[1] = &remaining_calls;
 
         rc = (int *) weechat_perl_exec (script,
                                         WEECHAT_SCRIPT_EXEC_INT,
                                         ptr_function,
-                                        "ss", func_argv);
+                                        "si", func_argv);
 
         if (!rc)
             ret = WEECHAT_RC_ERROR;
index e8585c368de98fe31672d39899af2dd42da4348d..c487e7d84f3084ab4fae60faefe853e64a18bce1 100644 (file)
@@ -2243,7 +2243,7 @@ weechat_python_api_hook_timer_cb (const void *pointer, void *data,
 {
     struct t_plugin_script *script;
     void *func_argv[2];
-    char str_remaining_calls[32], empty_arg[1] = { '\0' };
+    char empty_arg[1] = { '\0' };
     const char *ptr_function, *ptr_data;
     int *rc, ret;
 
@@ -2252,16 +2252,13 @@ weechat_python_api_hook_timer_cb (const void *pointer, void *data,
 
     if (ptr_function && ptr_function[0])
     {
-        snprintf (str_remaining_calls, sizeof (str_remaining_calls),
-                  "%d", remaining_calls);
-
         func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
-        func_argv[1] = str_remaining_calls;
+        func_argv[1] = &remaining_calls;
 
         rc = (int *) weechat_python_exec (script,
                                           WEECHAT_SCRIPT_EXEC_INT,
                                           ptr_function,
-                                          "ss", func_argv);
+                                          "si", func_argv);
 
         if (!rc)
             ret = WEECHAT_RC_ERROR;
index a1a8edf05ee29b3e1f45ca74bfbbe757cd0498cd..59bfcfffcad55575a32627b9c324cbe3e37c7ab5 100644 (file)
@@ -2763,7 +2763,7 @@ weechat_ruby_api_hook_timer_cb (const void *pointer, void *data,
 {
     struct t_plugin_script *script;
     void *func_argv[2];
-    char str_remaining_calls[32], empty_arg[1] = { '\0' };
+    char empty_arg[1] = { '\0' };
     const char *ptr_function, *ptr_data;
     int *rc, ret;
 
@@ -2772,16 +2772,13 @@ weechat_ruby_api_hook_timer_cb (const void *pointer, void *data,
 
     if (ptr_function && ptr_function[0])
     {
-        snprintf (str_remaining_calls, sizeof (str_remaining_calls),
-                  "%d", remaining_calls);
-
         func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
-        func_argv[1] = str_remaining_calls;
+        func_argv[1] = &remaining_calls;
 
         rc = (int *) weechat_ruby_exec (script,
                                         WEECHAT_SCRIPT_EXEC_INT,
                                         ptr_function,
-                                        "ss", func_argv);
+                                        "si", func_argv);
 
         if (!rc)
             ret = WEECHAT_RC_ERROR;
index c7494aa67fa2ca81659f3f35950eea7f44a15cb5..e4fb7395a35e75a22ed29923385febd51ea14e10 100644 (file)
@@ -2534,7 +2534,7 @@ weechat_tcl_api_hook_timer_cb (const void *pointer, void *data,
 {
     struct t_plugin_script *script;
     void *func_argv[2];
-    char str_remaining_calls[32], empty_arg[1] = { '\0' };
+    char empty_arg[1] = { '\0' };
     const char *ptr_function, *ptr_data;
     int *rc, ret;
 
@@ -2543,16 +2543,13 @@ weechat_tcl_api_hook_timer_cb (const void *pointer, void *data,
 
     if (ptr_function && ptr_function[0])
     {
-        snprintf (str_remaining_calls, sizeof (str_remaining_calls),
-                  "%d", remaining_calls);
-
         func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
-        func_argv[1] = str_remaining_calls;
+        func_argv[1] = &remaining_calls;
 
         rc = (int *) weechat_tcl_exec (script,
                                        WEECHAT_SCRIPT_EXEC_INT,
                                        ptr_function,
-                                       "ss", func_argv);
+                                       "si", func_argv);
 
         if (!rc)
             ret = WEECHAT_RC_ERROR;