diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2022-09-29 21:21:01 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2022-09-29 21:21:01 +0200 |
commit | b2b110f1a377e92928118c4ccf921bbb2f69ced9 (patch) | |
tree | e4c9ab1bfca964c58c94f2de58d5b414653504d3 | |
parent | 89400cbf7a9c3bc886fac7b5b3e596ff9b097e5d (diff) | |
download | weechat-b2b110f1a377e92928118c4ccf921bbb2f69ced9.zip |
api: change type of argument remaining_calls in hook_timer callback from string to integer (in scripts)
-rw-r--r-- | ChangeLog.adoc | 1 | ||||
-rw-r--r-- | ReleaseNotes.adoc | 26 | ||||
-rw-r--r-- | doc/en/weechat_plugin_api.en.adoc | 2 | ||||
-rw-r--r-- | doc/fr/weechat_plugin_api.fr.adoc | 2 | ||||
-rw-r--r-- | doc/it/weechat_plugin_api.it.adoc | 2 | ||||
-rw-r--r-- | doc/ja/weechat_plugin_api.ja.adoc | 2 | ||||
-rw-r--r-- | doc/sr/weechat_plugin_api.sr.adoc | 2 | ||||
-rw-r--r-- | src/plugins/guile/weechat-guile-api.c | 9 | ||||
-rw-r--r-- | src/plugins/javascript/weechat-js-api.cpp | 9 | ||||
-rw-r--r-- | src/plugins/lua/weechat-lua-api.c | 9 | ||||
-rw-r--r-- | src/plugins/perl/weechat-perl-api.c | 9 | ||||
-rw-r--r-- | src/plugins/python/weechat-python-api.c | 9 | ||||
-rw-r--r-- | src/plugins/ruby/weechat-ruby-api.c | 9 | ||||
-rw-r--r-- | src/plugins/tcl/weechat-tcl-api.c | 9 |
14 files changed, 51 insertions, 49 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 9d36352c7..d3c80c910 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -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) diff --git a/ReleaseNotes.adoc b/ReleaseNotes.adoc index 821138bbc..c4030389a 100644 --- a/ReleaseNotes.adoc +++ b/ReleaseNotes.adoc @@ -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) diff --git a/doc/en/weechat_plugin_api.en.adoc b/doc/en/weechat_plugin_api.en.adoc index fdcdb53ad..096911b9c 100644 --- a/doc/en/weechat_plugin_api.en.adoc +++ b/doc/en/weechat_plugin_api.en.adoc @@ -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 diff --git a/doc/fr/weechat_plugin_api.fr.adoc b/doc/fr/weechat_plugin_api.fr.adoc index c257feee8..767836aa2 100644 --- a/doc/fr/weechat_plugin_api.fr.adoc +++ b/doc/fr/weechat_plugin_api.fr.adoc @@ -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 diff --git a/doc/it/weechat_plugin_api.it.adoc b/doc/it/weechat_plugin_api.it.adoc index e84e24d9d..286b3e68a 100644 --- a/doc/it/weechat_plugin_api.it.adoc +++ b/doc/it/weechat_plugin_api.it.adoc @@ -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 diff --git a/doc/ja/weechat_plugin_api.ja.adoc b/doc/ja/weechat_plugin_api.ja.adoc index 9667cc129..f8c64cee5 100644 --- a/doc/ja/weechat_plugin_api.ja.adoc +++ b/doc/ja/weechat_plugin_api.ja.adoc @@ -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 diff --git a/doc/sr/weechat_plugin_api.sr.adoc b/doc/sr/weechat_plugin_api.sr.adoc index 391c12122..ae92d6453 100644 --- a/doc/sr/weechat_plugin_api.sr.adoc +++ b/doc/sr/weechat_plugin_api.sr.adoc @@ -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 diff --git a/src/plugins/guile/weechat-guile-api.c b/src/plugins/guile/weechat-guile-api.c index ce0d8c75a..539c37020 100644 --- a/src/plugins/guile/weechat-guile-api.c +++ b/src/plugins/guile/weechat-guile-api.c @@ -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; diff --git a/src/plugins/javascript/weechat-js-api.cpp b/src/plugins/javascript/weechat-js-api.cpp index 5019ccbe7..8e2e56b85 100644 --- a/src/plugins/javascript/weechat-js-api.cpp +++ b/src/plugins/javascript/weechat-js-api.cpp @@ -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; diff --git a/src/plugins/lua/weechat-lua-api.c b/src/plugins/lua/weechat-lua-api.c index 6364e86b7..f5bd9ec14 100644 --- a/src/plugins/lua/weechat-lua-api.c +++ b/src/plugins/lua/weechat-lua-api.c @@ -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; diff --git a/src/plugins/perl/weechat-perl-api.c b/src/plugins/perl/weechat-perl-api.c index d25c8f600..c7fc20bde 100644 --- a/src/plugins/perl/weechat-perl-api.c +++ b/src/plugins/perl/weechat-perl-api.c @@ -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; diff --git a/src/plugins/python/weechat-python-api.c b/src/plugins/python/weechat-python-api.c index e8585c368..c487e7d84 100644 --- a/src/plugins/python/weechat-python-api.c +++ b/src/plugins/python/weechat-python-api.c @@ -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; diff --git a/src/plugins/ruby/weechat-ruby-api.c b/src/plugins/ruby/weechat-ruby-api.c index a1a8edf05..59bfcfffc 100644 --- a/src/plugins/ruby/weechat-ruby-api.c +++ b/src/plugins/ruby/weechat-ruby-api.c @@ -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; diff --git a/src/plugins/tcl/weechat-tcl-api.c b/src/plugins/tcl/weechat-tcl-api.c index c7494aa67..e4fb7395a 100644 --- a/src/plugins/tcl/weechat-tcl-api.c +++ b/src/plugins/tcl/weechat-tcl-api.c @@ -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; |