ruby: fix crash with Ruby 2.0: use one array for the last 6 arguments of function config_new_option (bug #31050)

v2.8-utf8proc
Sebastien Helleu 2013-03-22 19:54:44 +01:00
parent 55e58811b3
commit 4fdbb83a07
12 changed files with 99 additions and 19 deletions

View File

@ -79,6 +79,8 @@ Version 0.4.1 (under dev!)
* rmodifier: rename default rmodifier "nickserv" to "command_auth" (with new
modifier "irc_command_auth"), add default rmodifier "message_auth" (modifier
"irc_message_auth")
* ruby: fix crash with Ruby 2.0: use one array for the last 6 arguments of
function config_new_option (bug #31050)
* script: create "script" directory on each action, just in case it has been
removed (bug #38472)
* script: add option script.scripts.autoload, add options "autoload",

View File

@ -56,6 +56,16 @@ Ruby
* Es muss 'weechat_init' definiert und darin die Funktion 'register' ausgeführt werden
* Funktionen werden im Format `Weechat.xxx(arg1, arg2, ...)` ausgeführt
// TRANSLATION MISSING
* Due to a limitation of Ruby (15 arguments max by function), the function
`Weechat.config_new_option` receives the callbacks in an array of 6 strings
(3 callbacks + 3 data strings), so a call to this function looks like:
[source,ruby]
----------------------------------------
Weechat.config_new_option(config, section, "name", "string", "description of option", "", 0, 0,
"value", "value", 0, ["check_cb", "", "change_cb", "", "delete_cb", ""])
----------------------------------------
Lua
^^^

View File

@ -4352,6 +4352,11 @@ option5 = weechat.config_new_option(config_file, section, "option5", "color",
"", "")
----------------------------------------
[NOTE]
In Ruby, the 3 callbacks + data (6 strings) must be given in an array of 6
strings (due to a Ruby limitation of 15 arguments by function), see the
'WeeChat Scripting Guide' for more info (_fixed in version 0.4.1_).
weechat_config_search_option
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -56,6 +56,15 @@ Ruby
* You have to define 'weechat_init' and call 'register' inside
* Functions are called with `Weechat.xxx(arg1, arg2, ...)`
* Due to a limitation of Ruby (15 arguments max by function), the function
`Weechat.config_new_option` receives the callbacks in an array of 6 strings
(3 callbacks + 3 data strings), so a call to this function looks like:
[source,ruby]
----------------------------------------
Weechat.config_new_option(config, section, "name", "string", "description of option", "", 0, 0,
"value", "value", 0, ["check_cb", "", "change_cb", "", "delete_cb", ""])
----------------------------------------
Lua
^^^

View File

@ -4405,6 +4405,12 @@ option5 = weechat.config_new_option(config_file, section, "option5", "color",
"", "")
----------------------------------------
[NOTE]
En Ruby, les 3 "callbacks" + "data" (6 chaînes) doivent être données dans un
tableau de 6 chaînes de caractères (en raison d'une limitation de Ruby à 15
paramètres par fonction), voir le 'Guide pour Scripts WeeChat' pour plus d'infos
(_corrigé dans la version 0.4.1_).
weechat_config_search_option
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -57,6 +57,16 @@ Ruby
* Vous devez définir 'weechat_init' et appeler 'register' dedans
* Les fonctions sont appelées par `Weechat.xxx(arg1, arg2, ...)`
* En raison d'une limitation de Ruby (15 paramètres maximum par fonction), la
fonction `Weechat.config_new_option` reçoit les "callbacks" dans un tableau de
6 chaînes de caractères (3 callbacks + 3 chaînes de données), donc un appel à
cette fonction ressemble à ceci :
[source,ruby]
----------------------------------------
Weechat.config_new_option(config, section, "name", "string", "description of option", "", 0, 0,
"value", "value", 0, ["check_cb", "", "change_cb", "", "delete_cb", ""])
----------------------------------------
Lua
^^^

View File

@ -1436,7 +1436,7 @@ Extensions
----------
Pour en apprendre plus sur le développement d'extension ou de script (via
l'API), merci de consulter la 'Référence API Extension WeeChat' ou 'Le Guide
l'API), merci de consulter la 'Référence API Extension WeeChat' ou le 'Guide
pour Scripts WeeChat'.
[[plugins_in_weechat]]

View File

@ -4354,6 +4354,12 @@ option5 = weechat.config_new_option(config_file, section, "option5", "color",
"", "")
----------------------------------------
// TRANSLATION MISSING
[NOTE]
In Ruby, the 3 callbacks + data (6 strings) must be given in an array of 6
strings (due to a Ruby limitation of 15 arguments by function), see the
'WeeChat Scripting Guide' for more info (_fixed in version 0.4.1_).
weechat_config_search_option
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -57,6 +57,16 @@ Ruby
* E necessario definire 'weechat_init' e chiamare 'register' all'interno
* Le funzioni sono chiamate con `Weechat.xxx(arg1, arg2, ...)`
// TRANSLATION MISSING
* Due to a limitation of Ruby (15 arguments max by function), the function
`Weechat.config_new_option` receives the callbacks in an array of 6 strings
(3 callbacks + 3 data strings), so a call to this function looks like:
[source,ruby]
----------------------------------------
Weechat.config_new_option(config, section, "name", "string", "description of option", "", 0, 0,
"value", "value", 0, ["check_cb", "", "change_cb", "", "delete_cb", ""])
----------------------------------------
Lua
^^^

View File

@ -49,6 +49,16 @@ WeeChat (Wee Enhanced Environment for Chat) はフリー、高速、軽量な
* 'weechat_init' を定義して、内部で 'register' を呼び出してください。
* 関数は `Weechat.xxx(arg1, arg2, ...)` のように呼び出してください。
// TRANSLATION MISSING
* Due to a limitation of Ruby (15 arguments max by function), the function
`Weechat.config_new_option` receives the callbacks in an array of 6 strings
(3 callbacks + 3 data strings), so a call to this function looks like:
[source,ruby]
----------------------------------------
Weechat.config_new_option(config, section, "name", "string", "description of option", "", 0, 0,
"value", "value", 0, ["check_cb", "", "change_cb", "", "delete_cb", ""])
----------------------------------------
==== Lua ====

View File

@ -56,6 +56,16 @@ Ruby
* Trzeba zdefiniować 'weechat_init' i wywołać 'register' wewnątrz
* Funkcje są wywoływane za pomocą `Weechat.xxx(arg1, arg2, ...)`
// TRANSLATION MISSING
* Due to a limitation of Ruby (15 arguments max by function), the function
`Weechat.config_new_option` receives the callbacks in an array of 6 strings
(3 callbacks + 3 data strings), so a call to this function looks like:
[source,ruby]
----------------------------------------
Weechat.config_new_option(config, section, "name", "string", "description of option", "", 0, 0,
"value", "value", 0, ["check_cb", "", "change_cb", "", "delete_cb", ""])
----------------------------------------
Lua
^^^

View File

@ -1333,28 +1333,21 @@ weechat_ruby_api_config_new_option (VALUE class, VALUE config_file,
VALUE description, VALUE string_values,
VALUE min, VALUE max, VALUE default_value,
VALUE value, VALUE null_value_allowed,
VALUE function_check_value,
VALUE data_check_value,
VALUE function_change,
VALUE data_change,
VALUE function_delete,
VALUE data_delete)
VALUE callbacks)
{
char *c_config_file, *c_section, *c_name, *c_type, *c_description;
char *c_string_values, *c_default_value, *c_value;
char *c_function_check_value, *c_data_check_value, *c_function_change;
char *c_data_change, *c_function_delete, *c_data_delete, *result;
int c_min, c_max, c_null_value_allowed;
VALUE return_value;
VALUE function_check_value, data_check_value, function_change, data_change;
VALUE function_delete, data_delete, return_value;
API_FUNC(1, "config_new_option", API_RETURN_EMPTY);
if (NIL_P (config_file) || NIL_P (section) || NIL_P (name) || NIL_P (type)
|| NIL_P (description) || NIL_P (string_values) || NIL_P (min)
|| NIL_P (max) || NIL_P (default_value) || NIL_P (value)
|| NIL_P (null_value_allowed) || NIL_P (function_check_value)
|| NIL_P (data_check_value) || NIL_P (function_change)
|| NIL_P (data_change) || NIL_P (function_delete)
|| NIL_P (data_delete))
|| NIL_P (null_value_allowed) || NIL_P (callbacks))
API_WRONG_ARGS(API_RETURN_EMPTY);
Check_Type (config_file, T_STRING);
@ -1368,12 +1361,21 @@ weechat_ruby_api_config_new_option (VALUE class, VALUE config_file,
Check_Type (default_value, T_STRING);
Check_Type (value, T_STRING);
Check_Type (null_value_allowed, T_FIXNUM);
Check_Type (function_check_value, T_STRING);
Check_Type (data_check_value, T_STRING);
Check_Type (function_change, T_STRING);
Check_Type (data_change, T_STRING);
Check_Type (function_delete, T_STRING);
Check_Type (data_delete, T_STRING);
Check_Type (callbacks, T_ARRAY);
/*
* due to a Ruby limitation (15 arguments max by function), we receive the
* the callbacks in an array of 6 strings (3 callbacks + 3 data)
*/
if (RARRAY_LEN(callbacks) != 6)
API_WRONG_ARGS(API_RETURN_EMPTY);
function_check_value = rb_ary_entry (callbacks, 0);
data_check_value = rb_ary_entry (callbacks, 1);
function_change = rb_ary_entry (callbacks, 2);
data_change = rb_ary_entry (callbacks, 3);
function_delete = rb_ary_entry (callbacks, 4);
data_delete = rb_ary_entry (callbacks, 5);
c_config_file = StringValuePtr (config_file);
c_section = StringValuePtr (section);
@ -5915,7 +5917,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
API_DEF_FUNC(config_new, 3);
API_DEF_FUNC(config_new_section, 14);
API_DEF_FUNC(config_search_section, 2);
API_DEF_FUNC(config_new_option, 17);
API_DEF_FUNC(config_new_option, 12);
API_DEF_FUNC(config_search_option, 3);
API_DEF_FUNC(config_string_to_boolean, 1);
API_DEF_FUNC(config_option_reset, 2);