1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-12 14:14:48 +02:00

api: change type of argument remaining_calls in hook_timer callback from string to integer (in scripts)

This commit is contained in:
Sébastien Helleu
2022-09-29 21:21:01 +02:00
parent 89400cbf7a
commit b2b110f1a3
14 changed files with 51 additions and 49 deletions
+1
View 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)
+24 -2
View 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)
+1 -1
View 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
+1 -1
View 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
+1 -1
View 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
+1 -1
View 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
+1 -1
View 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
+3 -6
View 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;
+3 -6
View 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;
+3 -6
View 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;
+3 -6
View 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;
+3 -6
View 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;
+3 -6
View 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;
+3 -6
View 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;