1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-09 03:03:12 +02:00

api: add stdin options in functions hook_process_hashtable and hook_set (task #10847, task #13031)

The function hook_set has been added in script API.
This commit is contained in:
Sebastien Helleu
2014-01-11 09:12:04 +01:00
parent e5b0b827ef
commit 48837c35bc
12 changed files with 430 additions and 85 deletions
+16
View File
@@ -2964,6 +2964,21 @@ weechat_guile_api_hook_focus (SCM area, SCM function, SCM data)
API_RETURN_STRING_FREE(result);
}
SCM
weechat_guile_api_hook_set (SCM hook, SCM property, SCM value)
{
API_FUNC(1, "hook_set", API_RETURN_ERROR);
if (!scm_is_string (hook) || !scm_is_string (property)
|| !scm_is_string (value))
API_WRONG_ARGS(API_RETURN_ERROR);
weechat_hook_set (API_STR2PTR(API_SCM_TO_STRING(hook)),
API_SCM_TO_STRING(property),
API_SCM_TO_STRING(value));
API_RETURN_OK;
}
SCM
weechat_guile_api_unhook (SCM hook)
{
@@ -4726,6 +4741,7 @@ weechat_guile_api_module_init (void *data)
API_DEF_FUNC(hook_info_hashtable, 6);
API_DEF_FUNC(hook_infolist, 6);
API_DEF_FUNC(hook_focus, 3);
API_DEF_FUNC(hook_set, 3);
API_DEF_FUNC(unhook, 1);
API_DEF_FUNC(unhook_all, 0);
API_DEF_FUNC(buffer_new, 5);
+19
View File
@@ -3201,6 +3201,24 @@ weechat_lua_api_hook_focus (lua_State *L)
API_RETURN_STRING_FREE(result);
}
static int
weechat_lua_api_hook_set (lua_State *L)
{
const char *hook, *property, *value;
API_FUNC(1, "hook_set", API_RETURN_ERROR);
if (lua_gettop (L) < 3)
API_WRONG_ARGS(API_RETURN_ERROR);
hook = lua_tostring (L, -3);
property = lua_tostring (L, -2);
value = lua_tostring (L, -1);
weechat_hook_set (API_STR2PTR(hook), property, value);
API_RETURN_OK;
}
static int
weechat_lua_api_unhook (lua_State *L)
{
@@ -5210,6 +5228,7 @@ const struct luaL_Reg weechat_lua_api_funcs[] = {
API_DEF_FUNC(hook_info_hashtable),
API_DEF_FUNC(hook_infolist),
API_DEF_FUNC(hook_focus),
API_DEF_FUNC(hook_set),
API_DEF_FUNC(unhook),
API_DEF_FUNC(unhook_all),
API_DEF_FUNC(buffer_new),
+19
View File
@@ -3019,6 +3019,24 @@ XS (XS_weechat_api_hook_focus)
API_RETURN_STRING_FREE(result);
}
XS (XS_weechat_api_hook_set)
{
char *hook, *property, *value;
dXSARGS;
API_FUNC(1, "hook_set", API_RETURN_ERROR);
if (items < 3)
API_WRONG_ARGS(API_RETURN_ERROR);
hook = SvPV_nolen (ST (0));
property = SvPV_nolen (ST (1));
value = SvPV_nolen (ST (2));
weechat_hook_set (API_STR2PTR(hook), property, value);
API_RETURN_OK;
}
XS (XS_weechat_api_unhook)
{
dXSARGS;
@@ -4963,6 +4981,7 @@ weechat_perl_api_init (pTHX)
API_DEF_FUNC(hook_info_hashtable);
API_DEF_FUNC(hook_infolist);
API_DEF_FUNC(hook_focus);
API_DEF_FUNC(hook_set);
API_DEF_FUNC(unhook);
API_DEF_FUNC(unhook_all);
API_DEF_FUNC(buffer_new);
+20
View File
@@ -3158,6 +3158,25 @@ weechat_python_api_hook_focus (PyObject *self, PyObject *args)
API_RETURN_STRING_FREE(result);
}
static PyObject *
weechat_python_api_hook_set (PyObject *self, PyObject *args)
{
char *hook, *property, *value;
API_FUNC(1, "hook_set", API_RETURN_ERROR);
hook = NULL;
property = NULL;
value = NULL;
if (!PyArg_ParseTuple (args, "sss", &hook, &property, &value))
API_WRONG_ARGS(API_RETURN_ERROR);
weechat_hook_set (API_STR2PTR(hook),
property,
value);
API_RETURN_OK;
}
static PyObject *
weechat_python_api_unhook (PyObject *self, PyObject *args)
{
@@ -5122,6 +5141,7 @@ PyMethodDef weechat_python_funcs[] =
API_DEF_FUNC(hook_info_hashtable),
API_DEF_FUNC(hook_infolist),
API_DEF_FUNC(hook_focus),
API_DEF_FUNC(hook_set),
API_DEF_FUNC(unhook),
API_DEF_FUNC(unhook_all),
API_DEF_FUNC(buffer_new),
+26
View File
@@ -3648,6 +3648,31 @@ weechat_ruby_api_hook_focus (VALUE class, VALUE area, VALUE function,
API_RETURN_STRING_FREE(result);
}
static VALUE
weechat_ruby_api_hook_set (VALUE class, VALUE hook, VALUE property,
VALUE value)
{
char *c_hook, *c_property, *c_value;
API_FUNC(1, "hook_set", API_RETURN_ERROR);
if (NIL_P (hook) || NIL_P (property) || NIL_P (value))
API_WRONG_ARGS(API_RETURN_ERROR);
Check_Type (hook, T_STRING);
Check_Type (property, T_STRING);
Check_Type (value, T_STRING);
c_hook = StringValuePtr (hook);
c_property = StringValuePtr (property);
c_value = StringValuePtr (value);
weechat_hook_set (API_STR2PTR(c_hook),
c_property,
c_value);
API_RETURN_OK;
}
static VALUE
weechat_ruby_api_unhook (VALUE class, VALUE hook)
{
@@ -6066,6 +6091,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
API_DEF_FUNC(hook_info_hashtable, 6);
API_DEF_FUNC(hook_infolist, 6);
API_DEF_FUNC(hook_focus, 3);
API_DEF_FUNC(hook_set, 3);
API_DEF_FUNC(unhook, 1);
API_DEF_FUNC(unhook_all, 0);
API_DEF_FUNC(buffer_new, 5);
+22
View File
@@ -3504,6 +3504,27 @@ weechat_tcl_api_hook_focus (ClientData clientData, Tcl_Interp *interp,
API_RETURN_STRING_FREE(result);
}
static int
weechat_tcl_api_hook_set (ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj *objp;
char *hook, *property, *value;
int i;
API_FUNC(1, "hook_set", API_RETURN_ERROR);
if (objc < 4)
API_WRONG_ARGS(API_RETURN_ERROR);
hook = Tcl_GetStringFromObj (objv[1], &i);
property = Tcl_GetStringFromObj (objv[2], &i);
value = Tcl_GetStringFromObj (objv[3], &i);
weechat_hook_set (API_STR2PTR(hook), property, value);
API_RETURN_OK;
}
static int
weechat_tcl_api_unhook (ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
@@ -5809,6 +5830,7 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
API_DEF_FUNC(hook_info_hashtable);
API_DEF_FUNC(hook_infolist);
API_DEF_FUNC(hook_focus);
API_DEF_FUNC(hook_set);
API_DEF_FUNC(unhook);
API_DEF_FUNC(unhook_all);
API_DEF_FUNC(buffer_new);