mirror of
https://github.com/weechat/weechat.git
synced 2026-07-01 23:36:37 +02:00
api: add function string_parse_size
This commit is contained in:
@@ -431,6 +431,20 @@ weechat_guile_api_string_format_size (SCM size)
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
SCM
|
||||
weechat_guile_api_string_parse_size (SCM size)
|
||||
{
|
||||
unsigned long long value;
|
||||
|
||||
API_INIT_FUNC(1, "string_parse_size", API_RETURN_LONG(0));
|
||||
if (!scm_is_string (size))
|
||||
API_WRONG_ARGS(API_RETURN_LONG(0));
|
||||
|
||||
value = weechat_string_parse_size (API_SCM_TO_STRING(size));
|
||||
|
||||
API_RETURN_LONG(value);
|
||||
}
|
||||
|
||||
SCM
|
||||
weechat_guile_api_string_color_code_size (SCM string)
|
||||
{
|
||||
@@ -5118,6 +5132,7 @@ weechat_guile_api_module_init (void *data)
|
||||
API_DEF_FUNC(string_has_highlight_regex, 2);
|
||||
API_DEF_FUNC(string_mask_to_regex, 1);
|
||||
API_DEF_FUNC(string_format_size, 1);
|
||||
API_DEF_FUNC(string_parse_size, 1);
|
||||
API_DEF_FUNC(string_color_code_size, 1);
|
||||
API_DEF_FUNC(string_remove_color, 2);
|
||||
API_DEF_FUNC(string_is_command_char, 1);
|
||||
|
||||
@@ -378,6 +378,19 @@ API_FUNC(string_format_size)
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
API_FUNC(string_parse_size)
|
||||
{
|
||||
unsigned long long value;
|
||||
|
||||
API_INIT_FUNC(1, "string_parse_size", "s", API_RETURN_LONG(0));
|
||||
|
||||
v8::String::Utf8Value size(args[0]);
|
||||
|
||||
value = weechat_string_parse_size (*size);
|
||||
|
||||
API_RETURN_LONG(value);
|
||||
}
|
||||
|
||||
API_FUNC(string_color_code_size)
|
||||
{
|
||||
int size;
|
||||
@@ -5060,6 +5073,7 @@ WeechatJsV8::loadLibs()
|
||||
API_DEF_FUNC(string_has_highlight_regex);
|
||||
API_DEF_FUNC(string_mask_to_regex);
|
||||
API_DEF_FUNC(string_format_size);
|
||||
API_DEF_FUNC(string_parse_size);
|
||||
API_DEF_FUNC(string_color_code_size);
|
||||
API_DEF_FUNC(string_remove_color);
|
||||
API_DEF_FUNC(string_is_command_char);
|
||||
|
||||
@@ -423,6 +423,22 @@ API_FUNC(string_format_size)
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
API_FUNC(string_parse_size)
|
||||
{
|
||||
const char *size;
|
||||
unsigned long long value;
|
||||
|
||||
API_INIT_FUNC(1, "string_parse_size", API_RETURN_LONG(0));
|
||||
if (lua_gettop (L) < 1)
|
||||
API_WRONG_ARGS(API_RETURN_LONG(0));
|
||||
|
||||
size = lua_tostring (L, -1);
|
||||
|
||||
value = weechat_string_parse_size (size);
|
||||
|
||||
API_RETURN_LONG(value);
|
||||
}
|
||||
|
||||
API_FUNC(string_color_code_size)
|
||||
{
|
||||
const char *string;
|
||||
@@ -5416,6 +5432,7 @@ const struct luaL_Reg weechat_lua_api_funcs[] = {
|
||||
API_DEF_FUNC(string_has_highlight_regex),
|
||||
API_DEF_FUNC(string_mask_to_regex),
|
||||
API_DEF_FUNC(string_format_size),
|
||||
API_DEF_FUNC(string_parse_size),
|
||||
API_DEF_FUNC(string_color_code_size),
|
||||
API_DEF_FUNC(string_remove_color),
|
||||
API_DEF_FUNC(string_is_command_char),
|
||||
|
||||
@@ -383,6 +383,20 @@ API_FUNC(string_format_size)
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
API_FUNC(string_parse_size)
|
||||
{
|
||||
unsigned long long value;
|
||||
dXSARGS;
|
||||
|
||||
API_INIT_FUNC(1, "string_parse_size", API_RETURN_LONG(0));
|
||||
if (items < 1)
|
||||
API_WRONG_ARGS(API_RETURN_LONG(0));
|
||||
|
||||
value = weechat_string_parse_size (SvPV_nolen (ST (0))); /* size */
|
||||
|
||||
API_RETURN_LONG(value);
|
||||
}
|
||||
|
||||
API_FUNC(string_color_code_size)
|
||||
{
|
||||
int size;
|
||||
@@ -5367,6 +5381,7 @@ weechat_perl_api_init (pTHX)
|
||||
API_DEF_FUNC(string_has_highlight_regex);
|
||||
API_DEF_FUNC(string_mask_to_regex);
|
||||
API_DEF_FUNC(string_format_size);
|
||||
API_DEF_FUNC(string_parse_size);
|
||||
API_DEF_FUNC(string_color_code_size);
|
||||
API_DEF_FUNC(string_remove_color);
|
||||
API_DEF_FUNC(string_is_command_char);
|
||||
|
||||
@@ -496,6 +496,23 @@ API_FUNC(string_format_size)
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
API_FUNC(string_parse_size)
|
||||
{
|
||||
zend_string *z_size;
|
||||
char *size;
|
||||
unsigned long long value;
|
||||
|
||||
API_INIT_FUNC(1, "string_parse_size", API_RETURN_LONG(0));
|
||||
if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_size) == FAILURE)
|
||||
API_WRONG_ARGS(API_RETURN_LONG(0));
|
||||
|
||||
size = ZSTR_VAL(z_size);
|
||||
|
||||
value = weechat_string_parse_size ((const char *)size);
|
||||
|
||||
API_RETURN_LONG(value);
|
||||
}
|
||||
|
||||
API_FUNC(string_color_code_size)
|
||||
{
|
||||
zend_string *z_string;
|
||||
|
||||
@@ -59,6 +59,7 @@ PHP_FUNCTION(weechat_string_has_highlight);
|
||||
PHP_FUNCTION(weechat_string_has_highlight_regex);
|
||||
PHP_FUNCTION(weechat_string_mask_to_regex);
|
||||
PHP_FUNCTION(weechat_string_format_size);
|
||||
PHP_FUNCTION(weechat_string_parse_size);
|
||||
PHP_FUNCTION(weechat_string_color_code_size);
|
||||
PHP_FUNCTION(weechat_string_remove_color);
|
||||
PHP_FUNCTION(weechat_string_is_command_char);
|
||||
|
||||
@@ -117,6 +117,7 @@ const zend_function_entry weechat_functions[] = {
|
||||
PHP_FE(weechat_string_has_highlight_regex, arginfo_weechat_string_has_highlight_regex)
|
||||
PHP_FE(weechat_string_mask_to_regex, arginfo_weechat_string_mask_to_regex)
|
||||
PHP_FE(weechat_string_format_size, arginfo_weechat_string_format_size)
|
||||
PHP_FE(weechat_string_parse_size, arginfo_weechat_string_parse_size)
|
||||
PHP_FE(weechat_string_color_code_size, arginfo_weechat_string_color_code_size)
|
||||
PHP_FE(weechat_string_remove_color, arginfo_weechat_string_remove_color)
|
||||
PHP_FE(weechat_string_is_command_char, arginfo_weechat_string_is_command_char)
|
||||
|
||||
@@ -25,6 +25,7 @@ function weechat_string_has_highlight(string $p0, string $p1): int {}
|
||||
function weechat_string_has_highlight_regex(string $p0, string $p1): int {}
|
||||
function weechat_string_mask_to_regex(string $p0): string {}
|
||||
function weechat_string_format_size(int $p0): string {}
|
||||
function weechat_string_parse_size(string $p0): int {}
|
||||
function weechat_string_color_code_size(string $p0): int {}
|
||||
function weechat_string_remove_color(string $p0, string $p1): string {}
|
||||
function weechat_string_is_command_char(string $p0): int {}
|
||||
|
||||
@@ -57,6 +57,8 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_weechat_string_format_size, 0, 1
|
||||
ZEND_ARG_TYPE_INFO(0, p0, IS_LONG, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
#define arginfo_weechat_string_parse_size arginfo_weechat_charset_set
|
||||
|
||||
#define arginfo_weechat_string_color_code_size arginfo_weechat_charset_set
|
||||
|
||||
#define arginfo_weechat_string_remove_color arginfo_weechat_iconv_to_internal
|
||||
|
||||
@@ -633,6 +633,7 @@ plugin_load (const char *filename, int init_plugin, int argc, char **argv)
|
||||
new_plugin->string_split_command = &string_split_command;
|
||||
new_plugin->string_free_split_command = &string_free_split_command;
|
||||
new_plugin->string_format_size = &string_format_size;
|
||||
new_plugin->string_parse_size = &string_parse_size;
|
||||
new_plugin->string_color_code_size = &gui_color_code_size;
|
||||
new_plugin->string_remove_color = &gui_color_decode;
|
||||
new_plugin->string_base_encode = &string_base_encode;
|
||||
|
||||
@@ -369,6 +369,21 @@ API_FUNC(string_format_size)
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
API_FUNC(string_parse_size)
|
||||
{
|
||||
char *size;
|
||||
unsigned long long value;
|
||||
|
||||
API_INIT_FUNC(1, "string_parse_size", API_RETURN_LONG(0));
|
||||
size = NULL;
|
||||
if (!PyArg_ParseTuple (args, "s", &size))
|
||||
API_WRONG_ARGS(API_RETURN_LONG(0));
|
||||
|
||||
value = weechat_string_parse_size (size);
|
||||
|
||||
API_RETURN_LONG(value);
|
||||
}
|
||||
|
||||
API_FUNC(string_color_code_size)
|
||||
{
|
||||
char *string;
|
||||
@@ -5281,6 +5296,7 @@ PyMethodDef weechat_python_funcs[] =
|
||||
API_DEF_FUNC(string_has_highlight_regex),
|
||||
API_DEF_FUNC(string_mask_to_regex),
|
||||
API_DEF_FUNC(string_format_size),
|
||||
API_DEF_FUNC(string_parse_size),
|
||||
API_DEF_FUNC(string_color_code_size),
|
||||
API_DEF_FUNC(string_remove_color),
|
||||
API_DEF_FUNC(string_is_command_char),
|
||||
|
||||
@@ -122,6 +122,11 @@ def string_format_size(size: int) -> str:
|
||||
...
|
||||
|
||||
|
||||
def string_parse_size(size: str) -> int:
|
||||
"""`string_parse_size in WeeChat plugin API reference <https://weechat.org/doc/api/#_string_parse_size>`_"""
|
||||
...
|
||||
|
||||
|
||||
def string_color_code_size(string: str) -> int:
|
||||
"""`string_color_code_size in WeeChat plugin API reference <https://weechat.org/doc/api/#_string_color_code_size>`_"""
|
||||
...
|
||||
|
||||
@@ -448,6 +448,25 @@ weechat_ruby_api_string_format_size (VALUE class, VALUE size)
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_string_parse_size (VALUE class, VALUE size)
|
||||
{
|
||||
char *c_size;
|
||||
unsigned long long value;
|
||||
|
||||
API_INIT_FUNC(1, "string_parse_size", API_RETURN_LONG(0));
|
||||
if (NIL_P (size))
|
||||
API_WRONG_ARGS(API_RETURN_LONG(0));
|
||||
|
||||
Check_Type (size, T_STRING);
|
||||
|
||||
c_size = StringValuePtr (size);
|
||||
|
||||
value = weechat_string_parse_size (c_size);
|
||||
|
||||
API_RETURN_LONG(value);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_string_color_code_size (VALUE class, VALUE string)
|
||||
{
|
||||
@@ -6562,6 +6581,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
|
||||
API_DEF_FUNC(string_has_highlight_regex, 2);
|
||||
API_DEF_FUNC(string_mask_to_regex, 1);
|
||||
API_DEF_FUNC(string_format_size, 1);
|
||||
API_DEF_FUNC(string_parse_size, 1);
|
||||
API_DEF_FUNC(string_color_code_size, 1);
|
||||
API_DEF_FUNC(string_remove_color, 2);
|
||||
API_DEF_FUNC(string_is_command_char, 1);
|
||||
|
||||
@@ -538,6 +538,24 @@ API_FUNC(string_format_size)
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
API_FUNC(string_parse_size)
|
||||
{
|
||||
Tcl_Obj *objp;
|
||||
char *size;
|
||||
unsigned long long value;
|
||||
int i;
|
||||
|
||||
API_INIT_FUNC(1, "string_parse_size", API_RETURN_LONG(0));
|
||||
if (objc < 2)
|
||||
API_WRONG_ARGS(API_RETURN_LONG(0));
|
||||
|
||||
size = Tcl_GetStringFromObj (objv[1], &i);
|
||||
|
||||
value = weechat_string_parse_size (size);
|
||||
|
||||
API_RETURN_LONG(value);
|
||||
}
|
||||
|
||||
API_FUNC(string_color_code_size)
|
||||
{
|
||||
Tcl_Obj *objp;
|
||||
@@ -5867,6 +5885,7 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
|
||||
API_DEF_FUNC(string_has_highlight_regex);
|
||||
API_DEF_FUNC(string_mask_to_regex);
|
||||
API_DEF_FUNC(string_format_size);
|
||||
API_DEF_FUNC(string_parse_size);
|
||||
API_DEF_FUNC(string_color_code_size);
|
||||
API_DEF_FUNC(string_remove_color);
|
||||
API_DEF_FUNC(string_is_command_char);
|
||||
|
||||
@@ -68,7 +68,7 @@ struct timeval;
|
||||
* please change the date with current one; for a second change at same
|
||||
* date, increment the 01, otherwise please keep 01.
|
||||
*/
|
||||
#define WEECHAT_PLUGIN_API_VERSION "20220816-01"
|
||||
#define WEECHAT_PLUGIN_API_VERSION "20220925-01"
|
||||
|
||||
/* macros for defining plugin infos */
|
||||
#define WEECHAT_PLUGIN_NAME(__name) \
|
||||
@@ -338,6 +338,7 @@ struct t_weechat_plugin
|
||||
char **(*string_split_command) (const char *command, char separator);
|
||||
void (*string_free_split_command) (char **split_command);
|
||||
char *(*string_format_size) (unsigned long long size);
|
||||
unsigned long long (*string_parse_size) (const char *size);
|
||||
int (*string_color_code_size) (const char *string);
|
||||
char *(*string_remove_color) (const char *string, const char *replacement);
|
||||
int (*string_base_encode) (int base, const char *from, int length,
|
||||
@@ -1302,6 +1303,8 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
|
||||
(weechat_plugin->string_free_split_command)(__split_command)
|
||||
#define weechat_string_format_size(__size) \
|
||||
(weechat_plugin->string_format_size)(__size)
|
||||
#define weechat_string_parse_size(__size) \
|
||||
(weechat_plugin->string_parse_size)(__size)
|
||||
#define weechat_string_color_code_size(__string) \
|
||||
(weechat_plugin->string_color_code_size)(__string)
|
||||
#define weechat_string_remove_color(__string, __replacement) \
|
||||
|
||||
Reference in New Issue
Block a user