diff options
-rw-r--r-- | ChangeLog.adoc | 1 | ||||
-rw-r--r-- | src/plugins/guile/weechat-guile-api.c | 2 | ||||
-rw-r--r-- | src/plugins/javascript/weechat-js-api.cpp | 5 | ||||
-rw-r--r-- | src/plugins/lua/weechat-lua-api.c | 3 | ||||
-rw-r--r-- | src/plugins/php/weechat-php-api.c | 5 | ||||
-rw-r--r-- | src/plugins/plugin-script-api.c | 2 | ||||
-rw-r--r-- | src/plugins/plugin-script-api.h | 2 | ||||
-rw-r--r-- | src/plugins/python/weechat-python-api.c | 5 | ||||
-rw-r--r-- | src/plugins/ruby/weechat-ruby-api.c | 5 | ||||
-rw-r--r-- | src/plugins/tcl/weechat-tcl-api.c | 5 | ||||
-rw-r--r-- | tests/scripts/python/testapi.py | 14 |
11 files changed, 35 insertions, 14 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 5284d07ed..30859b616 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -33,6 +33,7 @@ Bug fixes:: * javascript: fix return of long value in functions infolist_time, hdata_long and hdata_time * relay: fix parsing of IRC messages received from clients (issue #1796) * scripts: fix issue with year ≥ 2038 in functions infolist_new_var_time, print_date_tags and print_y_date_tags (plugins: python/lua/tcl/guile/javascript) + * scripts: fix issue with long interval in function hook_timer (plugins: python/ruby/lua/tcl/guile/javascript/php) * xfer: fix crash when closing DCC chat buffer Tests:: diff --git a/src/plugins/guile/weechat-guile-api.c b/src/plugins/guile/weechat-guile-api.c index c83577860..e56ea76af 100644 --- a/src/plugins/guile/weechat-guile-api.c +++ b/src/plugins/guile/weechat-guile-api.c @@ -2255,7 +2255,7 @@ weechat_guile_api_hook_timer (SCM interval, SCM align_second, SCM max_calls, result = API_PTR2STR(plugin_script_api_hook_timer (weechat_guile_plugin, guile_current_script, - scm_to_int (interval), + scm_to_long (interval), scm_to_int (align_second), scm_to_int (max_calls), &weechat_guile_api_hook_timer_cb, diff --git a/src/plugins/javascript/weechat-js-api.cpp b/src/plugins/javascript/weechat-js-api.cpp index 32a2d742a..829b31057 100644 --- a/src/plugins/javascript/weechat-js-api.cpp +++ b/src/plugins/javascript/weechat-js-api.cpp @@ -2148,10 +2148,11 @@ weechat_js_api_hook_timer_cb (const void *pointer, void *data, API_FUNC(hook_timer) { - int interval, align_second, max_calls; + long interval; + int align_second, max_calls; const char *result; - API_INIT_FUNC(1, "hook_timer", "iiiss", API_RETURN_EMPTY); + API_INIT_FUNC(1, "hook_timer", "niiss", API_RETURN_EMPTY); interval = args[0]->IntegerValue(); align_second = args[1]->IntegerValue(); diff --git a/src/plugins/lua/weechat-lua-api.c b/src/plugins/lua/weechat-lua-api.c index 2e62804ff..e97d3a9e2 100644 --- a/src/plugins/lua/weechat-lua-api.c +++ b/src/plugins/lua/weechat-lua-api.c @@ -2361,7 +2361,8 @@ weechat_lua_api_hook_timer_cb (const void *pointer, void *data, API_FUNC(hook_timer) { - int interval, align_second, max_calls; + long interval; + int align_second, max_calls; const char *function, *data; const char *result; diff --git a/src/plugins/php/weechat-php-api.c b/src/plugins/php/weechat-php-api.c index cfe2ffaca..b28561040 100644 --- a/src/plugins/php/weechat-php-api.c +++ b/src/plugins/php/weechat-php-api.c @@ -2376,7 +2376,8 @@ API_FUNC(hook_timer) zend_long z_interval, z_align_second, z_max_calls; zval *z_callback; zend_string *z_data; - int interval, align_second, max_calls; + long interval; + int align_second, max_calls; char *data; const char *result; @@ -2386,7 +2387,7 @@ API_FUNC(hook_timer) &z_data) == FAILURE) API_WRONG_ARGS(API_RETURN_EMPTY); - interval = (int)z_interval; + interval = (long)z_interval; align_second = (int)z_align_second; max_calls = (int)z_max_calls; weechat_php_get_function_name (z_callback, callback_name); diff --git a/src/plugins/plugin-script-api.c b/src/plugins/plugin-script-api.c index 9ae37e4a0..e69ea56e3 100644 --- a/src/plugins/plugin-script-api.c +++ b/src/plugins/plugin-script-api.c @@ -523,7 +523,7 @@ plugin_script_api_hook_command_run (struct t_weechat_plugin *weechat_plugin, struct t_hook * plugin_script_api_hook_timer (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *script, - int interval, int align_second, int max_calls, + long interval, int align_second, int max_calls, int (*callback)(const void *pointer, void *data, int remaining_calls), diff --git a/src/plugins/plugin-script-api.h b/src/plugins/plugin-script-api.h index b7a369dea..c7264d72e 100644 --- a/src/plugins/plugin-script-api.h +++ b/src/plugins/plugin-script-api.h @@ -151,7 +151,7 @@ extern struct t_hook *plugin_script_api_hook_command_run (struct t_weechat_plugi const char *data); extern struct t_hook *plugin_script_api_hook_timer (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *script, - int interval, int align_second, + long interval, int align_second, int max_calls, int (*callback)(const void *pointer, void *data, diff --git a/src/plugins/python/weechat-python-api.c b/src/plugins/python/weechat-python-api.c index cab0040dc..b823f1967 100644 --- a/src/plugins/python/weechat-python-api.c +++ b/src/plugins/python/weechat-python-api.c @@ -2264,7 +2264,8 @@ weechat_python_api_hook_timer_cb (const void *pointer, void *data, API_FUNC(hook_timer) { - int interval, align_second, max_calls; + long interval; + int align_second, max_calls; char *function, *data; const char *result; @@ -2274,7 +2275,7 @@ API_FUNC(hook_timer) max_calls = 0; function = NULL; data = NULL; - if (!PyArg_ParseTuple (args, "iiiss", &interval, &align_second, &max_calls, + if (!PyArg_ParseTuple (args, "liiss", &interval, &align_second, &max_calls, &function, &data)) API_WRONG_ARGS(API_RETURN_EMPTY); diff --git a/src/plugins/ruby/weechat-ruby-api.c b/src/plugins/ruby/weechat-ruby-api.c index 8bad2f8e2..efe097cc5 100644 --- a/src/plugins/ruby/weechat-ruby-api.c +++ b/src/plugins/ruby/weechat-ruby-api.c @@ -2782,7 +2782,8 @@ static VALUE weechat_ruby_api_hook_timer (VALUE class, VALUE interval, VALUE align_second, VALUE max_calls, VALUE function, VALUE data) { - int c_interval, c_align_second, c_max_calls; + long c_interval; + int c_align_second, c_max_calls; char *c_function, *c_data; const char *result; @@ -2797,7 +2798,7 @@ weechat_ruby_api_hook_timer (VALUE class, VALUE interval, VALUE align_second, Check_Type (function, T_STRING); Check_Type (data, T_STRING); - c_interval = NUM2INT (interval); + c_interval = NUM2LONG (interval); c_align_second = NUM2INT (align_second); c_max_calls = NUM2INT (max_calls); c_function = StringValuePtr (function); diff --git a/src/plugins/tcl/weechat-tcl-api.c b/src/plugins/tcl/weechat-tcl-api.c index 4da40eec1..24cfc64e5 100644 --- a/src/plugins/tcl/weechat-tcl-api.c +++ b/src/plugins/tcl/weechat-tcl-api.c @@ -2554,13 +2554,14 @@ API_FUNC(hook_timer) { Tcl_Obj *objp; const char *result; - int i, interval, align_second, max_calls; + long interval; + int i, align_second, max_calls; API_INIT_FUNC(1, "hook_timer", API_RETURN_EMPTY); if (objc < 6) API_WRONG_ARGS(API_RETURN_EMPTY); - if ((Tcl_GetIntFromObj (interp, objv[1], &interval) != TCL_OK) + if ((Tcl_GetLongFromObj (interp, objv[1], &interval) != TCL_OK) || (Tcl_GetIntFromObj (interp, objv[2], &align_second) != TCL_OK) || (Tcl_GetIntFromObj (interp, objv[3], &max_calls) != TCL_OK)) API_WRONG_ARGS(API_RETURN_EMPTY); diff --git a/tests/scripts/python/testapi.py b/tests/scripts/python/testapi.py index c4630981e..62dd922f6 100644 --- a/tests/scripts/python/testapi.py +++ b/tests/scripts/python/testapi.py @@ -219,6 +219,11 @@ def command_run_cb(data, buf, command): return weechat.WEECHAT_RC_OK +def timer_cb(data, remaining_calls): + """Timer callback.""" + return weechat.WEECHAT_RC_OK + + def test_hooks(): """Test function hook_command.""" # hook_completion / hook_completion_args / and hook_command @@ -237,6 +242,15 @@ def test_hooks(): weechat.unhook(hook_cmd_run) weechat.unhook(hook_cmd) weechat.unhook(hook_cmplt) + # hook_timer + hook_timer = weechat.hook_timer(5000111000, 0, 1, + 'timer_cb', 'timer_cb_data') + ptr_infolist = weechat.infolist_get('hook', hook_timer, '') + check(ptr_infolist != '') + check(weechat.infolist_next(ptr_infolist) == 1) + check(weechat.infolist_string(ptr_infolist, 'interval') == '5000111000') + weechat.infolist_free(ptr_infolist) + weechat.unhook(hook_timer) def test_command(): |