1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-26 04:46:37 +02:00

api: add parameters pointers, extra_vars and options in function hdata_search

This commit is contained in:
Sébastien Helleu
2021-11-06 15:59:18 +01:00
parent 018a4bda53
commit 2da2172593
21 changed files with 722 additions and 217 deletions
+31 -3
View File
@@ -4667,21 +4667,49 @@ weechat_guile_api_hdata_move (SCM hdata, SCM pointer, SCM count)
}
SCM
weechat_guile_api_hdata_search (SCM hdata, SCM pointer, SCM search, SCM move)
weechat_guile_api_hdata_search (SCM hdata, SCM pointer, SCM search,
SCM pointers, SCM extra_vars, SCM options,
SCM move)
{
const char *result;
SCM return_value;
struct t_hashtable *c_pointers, *c_extra_vars, *c_options;
API_INIT_FUNC(1, "hdata_search", API_RETURN_EMPTY);
if (!scm_is_string (hdata) || !scm_is_string (pointer)
|| !scm_is_string (search) || !scm_is_integer (move))
|| !scm_is_string (search) || !scm_list_p (pointers)
|| !scm_list_p (extra_vars) || !scm_list_p (options)
|| !scm_is_integer (move))
API_WRONG_ARGS(API_RETURN_EMPTY);
c_pointers = weechat_guile_alist_to_hashtable (pointers,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_POINTER);
c_extra_vars = weechat_guile_alist_to_hashtable (extra_vars,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
c_options = weechat_guile_alist_to_hashtable (options,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
result = API_PTR2STR(weechat_hdata_search (API_STR2PTR(API_SCM_TO_STRING(hdata)),
API_STR2PTR(API_SCM_TO_STRING(pointer)),
API_SCM_TO_STRING(search),
c_pointers,
c_extra_vars,
c_options,
scm_to_int (move)));
if (c_pointers)
weechat_hashtable_free (c_pointers);
if (c_extra_vars)
weechat_hashtable_free (c_extra_vars);
if (c_options)
weechat_hashtable_free (c_options);
API_RETURN_STRING(result);
}
@@ -5199,7 +5227,7 @@ weechat_guile_api_module_init (void *data)
API_DEF_FUNC(hdata_get_list, 2);
API_DEF_FUNC(hdata_check_pointer, 3);
API_DEF_FUNC(hdata_move, 3);
API_DEF_FUNC(hdata_search, 4);
API_DEF_FUNC(hdata_search, 7);
API_DEF_FUNC(hdata_char, 3);
API_DEF_FUNC(hdata_integer, 3);
API_DEF_FUNC(hdata_long, 3);
+28 -2
View File
@@ -4569,23 +4569,49 @@ API_FUNC(hdata_move)
API_FUNC(hdata_search)
{
struct t_hashtable *pointers, *extra_vars, *options;
int move;
const char *result;
API_INIT_FUNC(1, "hdata_search", "sssi", API_RETURN_EMPTY);
API_INIT_FUNC(1, "hdata_search", "ssshhhi", API_RETURN_EMPTY);
v8::String::Utf8Value hdata(args[0]);
v8::String::Utf8Value pointer(args[1]);
v8::String::Utf8Value search(args[2]);
move = args[3]->IntegerValue();
pointers = weechat_js_object_to_hashtable (
args[3]->ToObject(),
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_POINTER);
extra_vars = weechat_js_object_to_hashtable (
args[4]->ToObject(),
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
options = weechat_js_object_to_hashtable (
args[5]->ToObject(),
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
move = args[6]->IntegerValue();
result = API_PTR2STR(
weechat_hdata_search (
(struct t_hdata *)API_STR2PTR(*hdata),
API_STR2PTR(*pointer),
*search,
pointers,
extra_vars,
options,
move));
if (pointers)
weechat_hashtable_free (pointers);
if (extra_vars)
weechat_hashtable_free (extra_vars);
if (options)
weechat_hashtable_free (options);
API_RETURN_STRING(result);
}
+27 -4
View File
@@ -4961,22 +4961,45 @@ API_FUNC(hdata_search)
{
const char *hdata, *pointer, *search;
const char *result;
struct t_hashtable *pointers, *extra_vars, *options;
int move;
API_INIT_FUNC(1, "hdata_search", API_RETURN_EMPTY);
if (lua_gettop (L) < 4)
if (lua_gettop (L) < 7)
API_WRONG_ARGS(API_RETURN_EMPTY);
hdata = lua_tostring (L, -4);
pointer = lua_tostring (L, -3);
search = lua_tostring (L, -2);
hdata = lua_tostring (L, -7);
pointer = lua_tostring (L, -6);
search = lua_tostring (L, -5);
pointers = weechat_lua_tohashtable (L, -4,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_POINTER);
extra_vars = weechat_lua_tohashtable (L, -3,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
options = weechat_lua_tohashtable (L, -2,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
move = lua_tonumber (L, -1);
result = API_PTR2STR(weechat_hdata_search (API_STR2PTR(hdata),
API_STR2PTR(pointer),
search,
pointers,
extra_vars,
options,
move));
if (pointers)
weechat_hashtable_free (pointers);
if (extra_vars)
weechat_hashtable_free (extra_vars);
if (options)
weechat_hashtable_free (options);
API_RETURN_STRING(result);
}
+25 -2
View File
@@ -4894,23 +4894,46 @@ API_FUNC(hdata_search)
{
char *hdata, *pointer, *search;
const char *result;
struct t_hashtable *pointers, *extra_vars, *options;
int move;
dXSARGS;
API_INIT_FUNC(1, "hdata_search", API_RETURN_EMPTY);
if (items < 4)
if (items < 7)
API_WRONG_ARGS(API_RETURN_EMPTY);
hdata = SvPV_nolen (ST (0));
pointer = SvPV_nolen (ST (1));
search = SvPV_nolen (ST (2));
move = SvIV(ST (3));
pointers = weechat_perl_hash_to_hashtable (ST (3),
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_POINTER);
extra_vars = weechat_perl_hash_to_hashtable (ST (4),
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
options = weechat_perl_hash_to_hashtable (ST (5),
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
move = SvIV(ST (6));
result = API_PTR2STR(weechat_hdata_search (API_STR2PTR(hdata),
API_STR2PTR(pointer),
search,
pointers,
extra_vars,
options,
move));
if (pointers)
weechat_hashtable_free (pointers);
if (extra_vars)
weechat_hashtable_free (extra_vars);
if (options)
weechat_hashtable_free (options);
API_RETURN_STRING(result);
}
+35 -3
View File
@@ -4975,25 +4975,57 @@ API_FUNC(hdata_move)
API_FUNC(hdata_search)
{
zend_string *z_hdata, *z_pointer, *z_search;
zval *z_pointers, *z_extra_vars, *z_options;
zend_long z_move;
struct t_hdata *hdata;
void *pointer;
char *search;
int move;
const char *result;
struct t_hashtable *pointers, *extra_vars, *options;
API_INIT_FUNC(1, "hdata_search", API_RETURN_EMPTY);
if (zend_parse_parameters (ZEND_NUM_ARGS(), "SSSl", &z_hdata, &z_pointer,
&z_search, &z_move) == FAILURE)
if (zend_parse_parameters (ZEND_NUM_ARGS(), "SSSaaal", &z_hdata,
&z_pointer, &z_search, &z_pointers,
&z_extra_vars, &z_options, &z_move) == FAILURE)
API_WRONG_ARGS(API_RETURN_EMPTY);
hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata));
pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer));
search = ZSTR_VAL(z_search);
pointers = weechat_php_array_to_hashtable (
z_pointers,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_POINTER);
extra_vars = weechat_php_array_to_hashtable (
z_extra_vars,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
options = weechat_php_array_to_hashtable (
z_options,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
move = (int)z_move;
result = API_PTR2STR(
weechat_hdata_search (hdata, pointer, (const char *)search, move));
weechat_hdata_search (
hdata,
pointer,
(const char *)search,
pointers,
extra_vars,
options,
move));
if (pointers)
weechat_hashtable_free (pointers);
if (extra_vars)
weechat_hashtable_free (extra_vars);
if (options)
weechat_hashtable_free (options);
API_RETURN_STRING(result);
}
+32 -1
View File
@@ -4877,21 +4877,52 @@ API_FUNC(hdata_search)
{
char *hdata, *pointer, *search;
const char *result;
struct t_hashtable *pointers, *extra_vars, *options;
PyObject *dict, *dict2, *dict3;
int move;
API_INIT_FUNC(1, "hdata_search", API_RETURN_EMPTY);
hdata = NULL;
pointer = NULL;
search = NULL;
pointers = NULL;
extra_vars = NULL;
options = NULL;
move = 0;
if (!PyArg_ParseTuple (args, "sssi", &hdata, &pointer, &search, &move))
if (!PyArg_ParseTuple (args, "sssOOOi", &hdata, &pointer, &search,
&dict, &dict2, &dict3, &move))
{
API_WRONG_ARGS(API_RETURN_EMPTY);
}
pointers = weechat_python_dict_to_hashtable (dict,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_POINTER);
extra_vars = weechat_python_dict_to_hashtable (dict2,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
options = weechat_python_dict_to_hashtable (dict3,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
result = API_PTR2STR(weechat_hdata_search (API_STR2PTR(hdata),
API_STR2PTR(pointer),
search,
pointers,
extra_vars,
options,
move));
if (pointers)
weechat_hashtable_free (pointers);
if (extra_vars)
weechat_hashtable_free (extra_vars);
if (options)
weechat_hashtable_free (options);
API_RETURN_STRING(result);
}
+3 -1
View File
@@ -973,7 +973,9 @@ def hdata_move(hdata: str, pointer: str, count: int) -> str:
...
def hdata_search(hdata: str, pointer: str, search: str, count: int) -> str:
def hdata_search(hdata: str, pointer: str, search: str,
pointers: Dict[str, str], extra_vars: Dict[str, str], options: Dict[str, str],
count: int) -> str:
"""`hdata_search in WeeChat plugin API reference <https://weechat.org/doc/api#_hdata_search>`_"""
...
+33 -3
View File
@@ -5938,31 +5938,61 @@ weechat_ruby_api_hdata_move (VALUE class, VALUE hdata, VALUE pointer,
static VALUE
weechat_ruby_api_hdata_search (VALUE class, VALUE hdata, VALUE pointer,
VALUE search, VALUE move)
VALUE search, VALUE pointers, VALUE extra_vars,
VALUE options, VALUE move)
{
char *c_hdata, *c_pointer, *c_search;
const char *result;
struct t_hashtable *c_pointers, *c_extra_vars, *c_options;
int c_move;
API_INIT_FUNC(1, "hdata_search", API_RETURN_EMPTY);
if (NIL_P (hdata) || NIL_P (pointer) || NIL_P (search) || NIL_P (move))
if (NIL_P (hdata) || NIL_P (pointer) || NIL_P (search) || NIL_P (pointers)
|| NIL_P (extra_vars) || NIL_P (options) || NIL_P (move))
{
API_WRONG_ARGS(API_RETURN_EMPTY);
}
Check_Type (hdata, T_STRING);
Check_Type (pointer, T_STRING);
Check_Type (search, T_STRING);
Check_Type (pointers, T_HASH);
Check_Type (extra_vars, T_HASH);
Check_Type (options, T_HASH);
CHECK_INTEGER(move);
c_hdata = StringValuePtr (hdata);
c_pointer = StringValuePtr (pointer);
c_search = StringValuePtr (search);
c_pointers = weechat_ruby_hash_to_hashtable (pointers,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_POINTER);
c_extra_vars = weechat_ruby_hash_to_hashtable (extra_vars,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
c_options = weechat_ruby_hash_to_hashtable (options,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
c_move = NUM2INT (move);
result = API_PTR2STR(weechat_hdata_search (API_STR2PTR(c_hdata),
API_STR2PTR(c_pointer),
c_search,
c_pointers,
c_extra_vars,
c_options,
c_move));
if (c_pointers)
weechat_hashtable_free (c_pointers);
if (c_extra_vars)
weechat_hashtable_free (c_extra_vars);
if (c_options)
weechat_hashtable_free (c_options);
API_RETURN_STRING(result);
}
@@ -6616,7 +6646,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
API_DEF_FUNC(hdata_get_list, 2);
API_DEF_FUNC(hdata_check_pointer, 3);
API_DEF_FUNC(hdata_move, 3);
API_DEF_FUNC(hdata_search, 4);
API_DEF_FUNC(hdata_search, 7);
API_DEF_FUNC(hdata_char, 3);
API_DEF_FUNC(hdata_integer, 3);
API_DEF_FUNC(hdata_long, 3);
+25 -2
View File
@@ -5256,24 +5256,47 @@ API_FUNC(hdata_search)
Tcl_Obj *objp;
char *hdata, *pointer, *search;
const char *result;
struct t_hashtable *pointers, *extra_vars, *options;
int i, move;
API_INIT_FUNC(1, "hdata_search", API_RETURN_EMPTY);
if (objc < 5)
if (objc < 8)
API_WRONG_ARGS(API_RETURN_EMPTY);
hdata = Tcl_GetStringFromObj (objv[1], &i);
pointer = Tcl_GetStringFromObj (objv[2], &i);
search = Tcl_GetStringFromObj (objv[3], &i);
pointers = weechat_tcl_dict_to_hashtable (interp, objv[4],
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_POINTER);
extra_vars = weechat_tcl_dict_to_hashtable (interp, objv[5],
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
options = weechat_tcl_dict_to_hashtable (interp, objv[6],
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
if (Tcl_GetIntFromObj (interp, objv[4], &move) != TCL_OK)
if (Tcl_GetIntFromObj (interp, objv[7], &move) != TCL_OK)
API_WRONG_ARGS(API_RETURN_EMPTY);
result = API_PTR2STR(weechat_hdata_search (API_STR2PTR(hdata),
API_STR2PTR(pointer),
search,
pointers,
extra_vars,
options,
move));
if (pointers)
weechat_hashtable_free (pointers);
if (extra_vars)
weechat_hashtable_free (extra_vars);
if (options)
weechat_hashtable_free (options);
API_RETURN_STRING(result);
}
+8 -3
View File
@@ -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 "20210704-01"
#define WEECHAT_PLUGIN_API_VERSION "20211106-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
@@ -1119,7 +1119,10 @@ struct t_weechat_plugin
void *pointer);
void *(*hdata_move) (struct t_hdata *hdata, void *pointer, int count);
void *(*hdata_search) (struct t_hdata *hdata, void *pointer,
const char *search, int move);
const char *search, struct t_hashtable *pointers,
struct t_hashtable *extra_vars,
struct t_hashtable *options,
int move);
char (*hdata_char) (struct t_hdata *hdata, void *pointer,
const char *name);
int (*hdata_integer) (struct t_hdata *hdata, void *pointer,
@@ -2112,8 +2115,10 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
(weechat_plugin->hdata_check_pointer)(__hdata, __list, __pointer)
#define weechat_hdata_move(__hdata, __pointer, __count) \
(weechat_plugin->hdata_move)(__hdata, __pointer, __count)
#define weechat_hdata_search(__hdata, __pointer, __search, __move) \
#define weechat_hdata_search(__hdata, __pointer, __search, __pointers, \
__extra_vars, __options, __move) \
(weechat_plugin->hdata_search)(__hdata, __pointer, __search, \
__pointers, __extra_vars, __options, \
__move)
#define weechat_hdata_char(__hdata, __pointer, __name) \
(weechat_plugin->hdata_char)(__hdata, __pointer, __name)