mirror of
https://github.com/weechat/weechat.git
synced 2026-06-27 21:36:37 +02:00
api: add function string_format_size in scripting API
This commit is contained in:
@@ -393,6 +393,21 @@ weechat_guile_api_string_mask_to_regex (SCM mask)
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
SCM
|
||||
weechat_guile_api_string_format_size (SCM size)
|
||||
{
|
||||
char *result;
|
||||
SCM return_value;
|
||||
|
||||
API_INIT_FUNC(1, "string_format_size", API_RETURN_EMPTY);
|
||||
if (!scm_is_integer (size))
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
result = weechat_string_format_size (scm_to_ulong_long (size));
|
||||
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
SCM
|
||||
weechat_guile_api_string_remove_color (SCM string, SCM replacement)
|
||||
{
|
||||
@@ -4863,6 +4878,7 @@ weechat_guile_api_module_init (void *data)
|
||||
API_DEF_FUNC(string_has_highlight, 2);
|
||||
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_remove_color, 2);
|
||||
API_DEF_FUNC(string_is_command_char, 1);
|
||||
API_DEF_FUNC(string_input_for_buffer, 1);
|
||||
|
||||
@@ -74,6 +74,7 @@ extern "C"
|
||||
{ \
|
||||
if (((js_args[num] == 's') && (!args[num]->IsString())) \
|
||||
|| ((js_args[num] == 'i') && (!args[num]->IsInt32())) \
|
||||
|| ((js_args[num] == 'n') && (!args[num]->IsNumber())) \
|
||||
|| ((js_args[num] == 'h') && (!args[num]->IsObject()))) \
|
||||
{ \
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(JS_CURRENT_SCRIPT_NAME, \
|
||||
@@ -344,6 +345,20 @@ API_FUNC(string_mask_to_regex)
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
API_FUNC(string_format_size)
|
||||
{
|
||||
unsigned long long size;
|
||||
char *result;
|
||||
|
||||
API_INIT_FUNC(1, "string_format_size", "n", API_RETURN_EMPTY);
|
||||
|
||||
size = args[0]->IntegerValue();
|
||||
|
||||
result = weechat_string_format_size (size);
|
||||
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
API_FUNC(string_remove_color)
|
||||
{
|
||||
char *result;
|
||||
@@ -4808,6 +4823,7 @@ WeechatJsV8::loadLibs()
|
||||
API_DEF_FUNC(string_has_highlight);
|
||||
API_DEF_FUNC(string_has_highlight_regex);
|
||||
API_DEF_FUNC(string_mask_to_regex);
|
||||
API_DEF_FUNC(string_format_size);
|
||||
API_DEF_FUNC(string_remove_color);
|
||||
API_DEF_FUNC(string_is_command_char);
|
||||
API_DEF_FUNC(string_input_for_buffer);
|
||||
|
||||
@@ -368,6 +368,22 @@ API_FUNC(string_mask_to_regex)
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
API_FUNC(string_format_size)
|
||||
{
|
||||
unsigned long long size;
|
||||
char *result;
|
||||
|
||||
API_INIT_FUNC(1, "string_format_size", API_RETURN_EMPTY);
|
||||
if (lua_gettop (L) < 1)
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
size = lua_tonumber (L, -1);
|
||||
|
||||
result = weechat_string_format_size (size);
|
||||
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
API_FUNC(string_remove_color)
|
||||
{
|
||||
const char *string, *replacement;
|
||||
@@ -5141,6 +5157,7 @@ const struct luaL_Reg weechat_lua_api_funcs[] = {
|
||||
API_DEF_FUNC(string_has_highlight),
|
||||
API_DEF_FUNC(string_has_highlight_regex),
|
||||
API_DEF_FUNC(string_mask_to_regex),
|
||||
API_DEF_FUNC(string_format_size),
|
||||
API_DEF_FUNC(string_remove_color),
|
||||
API_DEF_FUNC(string_is_command_char),
|
||||
API_DEF_FUNC(string_input_for_buffer),
|
||||
|
||||
@@ -351,6 +351,20 @@ API_FUNC(string_mask_to_regex)
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
API_FUNC(string_format_size)
|
||||
{
|
||||
char *result;
|
||||
dXSARGS;
|
||||
|
||||
API_INIT_FUNC(1, "string_format_size", API_RETURN_EMPTY);
|
||||
if (items < 1)
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
result = weechat_string_format_size (SvUV (ST (0)));
|
||||
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
API_FUNC(string_remove_color)
|
||||
{
|
||||
char *result, *string, *replacement;
|
||||
@@ -5075,6 +5089,7 @@ weechat_perl_api_init (pTHX)
|
||||
API_DEF_FUNC(string_has_highlight);
|
||||
API_DEF_FUNC(string_has_highlight_regex);
|
||||
API_DEF_FUNC(string_mask_to_regex);
|
||||
API_DEF_FUNC(string_format_size);
|
||||
API_DEF_FUNC(string_remove_color);
|
||||
API_DEF_FUNC(string_is_command_char);
|
||||
API_DEF_FUNC(string_input_for_buffer);
|
||||
|
||||
@@ -443,6 +443,21 @@ API_FUNC(string_mask_to_regex)
|
||||
API_RETURN_STRING(retval);
|
||||
}
|
||||
|
||||
API_FUNC(string_format_size)
|
||||
{
|
||||
zend_long z_size;
|
||||
char *retval;
|
||||
|
||||
API_INIT_FUNC(1, "string_format_size", API_RETURN_EMPTY);
|
||||
if (zend_parse_parameters (ZEND_NUM_ARGS(),
|
||||
"l", &z_size) == FAILURE)
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
retval = weechat_string_format_size ((unsigned long long)z_size);
|
||||
|
||||
API_RETURN_STRING(retval);
|
||||
}
|
||||
|
||||
API_FUNC(string_remove_color)
|
||||
{
|
||||
zend_string *z_string, *z_replacement;
|
||||
|
||||
@@ -57,6 +57,7 @@ PHP_FUNCTION(weechat_string_match);
|
||||
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_remove_color);
|
||||
PHP_FUNCTION(weechat_string_is_command_char);
|
||||
PHP_FUNCTION(weechat_string_input_for_buffer);
|
||||
|
||||
@@ -111,6 +111,7 @@ const zend_function_entry weechat_functions[] = {
|
||||
PHP_FE(weechat_string_has_highlight, NULL)
|
||||
PHP_FE(weechat_string_has_highlight_regex, NULL)
|
||||
PHP_FE(weechat_string_mask_to_regex, NULL)
|
||||
PHP_FE(weechat_string_format_size, NULL)
|
||||
PHP_FE(weechat_string_remove_color, NULL)
|
||||
PHP_FE(weechat_string_is_command_char, NULL)
|
||||
PHP_FE(weechat_string_input_for_buffer, NULL)
|
||||
|
||||
@@ -333,6 +333,22 @@ API_FUNC(string_mask_to_regex)
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
API_FUNC(string_format_size)
|
||||
{
|
||||
unsigned long long size;
|
||||
char *result;
|
||||
PyObject *return_value;
|
||||
|
||||
API_INIT_FUNC(1, "string_format_size", API_RETURN_EMPTY);
|
||||
size = 0;
|
||||
if (!PyArg_ParseTuple (args, "K", &size))
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
result = weechat_string_format_size (size);
|
||||
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
API_FUNC(string_remove_color)
|
||||
{
|
||||
char *string, *replacement, *result;
|
||||
@@ -5067,6 +5083,7 @@ PyMethodDef weechat_python_funcs[] =
|
||||
API_DEF_FUNC(string_has_highlight),
|
||||
API_DEF_FUNC(string_has_highlight_regex),
|
||||
API_DEF_FUNC(string_mask_to_regex),
|
||||
API_DEF_FUNC(string_format_size),
|
||||
API_DEF_FUNC(string_remove_color),
|
||||
API_DEF_FUNC(string_is_command_char),
|
||||
API_DEF_FUNC(string_input_for_buffer),
|
||||
|
||||
@@ -400,6 +400,26 @@ weechat_ruby_api_string_mask_to_regex (VALUE class, VALUE mask)
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_string_format_size (VALUE class, VALUE size)
|
||||
{
|
||||
unsigned long long c_size;
|
||||
char *result;
|
||||
VALUE return_value;
|
||||
|
||||
API_INIT_FUNC(1, "string_format_size", API_RETURN_EMPTY);
|
||||
if (NIL_P (size))
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
Check_Type (size, T_FIXNUM);
|
||||
|
||||
c_size = FIX2LONG (size);
|
||||
|
||||
result = weechat_string_format_size (c_size);
|
||||
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_string_remove_color (VALUE class, VALUE string,
|
||||
VALUE replacement)
|
||||
@@ -6208,6 +6228,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
|
||||
API_DEF_FUNC(string_has_highlight, 2);
|
||||
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_remove_color, 2);
|
||||
API_DEF_FUNC(string_is_command_char, 1);
|
||||
API_DEF_FUNC(string_input_for_buffer, 1);
|
||||
|
||||
@@ -488,6 +488,24 @@ API_FUNC(string_mask_to_regex)
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
API_FUNC(string_format_size)
|
||||
{
|
||||
Tcl_Obj *objp;
|
||||
char *result;
|
||||
long size;
|
||||
|
||||
API_INIT_FUNC(1, "string_format_size", API_RETURN_EMPTY);
|
||||
if (objc < 2)
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
if (Tcl_GetLongFromObj (interp, objv[1], &size) != TCL_OK)
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
result = weechat_string_format_size ((unsigned long long)size);
|
||||
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
API_FUNC(string_remove_color)
|
||||
{
|
||||
Tcl_Obj *objp;
|
||||
@@ -5542,6 +5560,7 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
|
||||
API_DEF_FUNC(string_has_highlight);
|
||||
API_DEF_FUNC(string_has_highlight_regex);
|
||||
API_DEF_FUNC(string_mask_to_regex);
|
||||
API_DEF_FUNC(string_format_size);
|
||||
API_DEF_FUNC(string_remove_color);
|
||||
API_DEF_FUNC(string_is_command_char);
|
||||
API_DEF_FUNC(string_input_for_buffer);
|
||||
|
||||
Reference in New Issue
Block a user