mirror of
https://github.com/weechat/weechat.git
synced 2026-06-24 11:56:38 +02:00
scripts: allow null values in config_new_option
The plugin API function config_new_option accepts null as the default_value and/or value however the scripting APIs (except for lua) didn't allow sending null as a parameter value, so it was impossible to use it this way. This allows sending a null value for these parameters. Lua already supported sending in nil for these parameters and it works as expected, so nothing is changed for this plugin. For Guile you can now send in #nil, for JavaScript null or undefined, for Perl undef, for PHP NULL, for Python None, for Ruby nil and for Tcl $::weechat::WEECHAT_NULL. In all of these languages except Tcl this is the special value indicating a missing value. However Tcl only has one type, string, so it doesn't have a null value. Therefore I created a constant with the value `\uFFFF\uFFFF\uFFFFWEECHAT_NULL\uFFFF\uFFFF\uFFFF` which is used instead. This is very unlikely to appear unintentionally. Using the unicode code point \uFFFF was suggested on https://wiki.tcl-lang.org/page/null. I tested this with these scripts: https://gist.github.com/trygveaa/f91977dde5d2876d502bf55fbf9b50cc
This commit is contained in:
committed by
Sébastien Helleu
parent
47e71a1bbd
commit
197a7a01e4
@@ -1255,7 +1255,7 @@ API_FUNC(config_new_option)
|
||||
data_change = NULL;
|
||||
function_delete = NULL;
|
||||
data_delete = NULL;
|
||||
if (!PyArg_ParseTuple (args, "ssssssiississssss", &config_file, §ion, &name,
|
||||
if (!PyArg_ParseTuple (args, "ssssssiizzissssss", &config_file, §ion, &name,
|
||||
&type, &description, &string_values, &min, &max,
|
||||
&default_value, &value, &null_value_allowed,
|
||||
&function_check_value, &data_check_value,
|
||||
|
||||
Reference in New Issue
Block a user