mirror of
https://github.com/weechat/weechat.git
synced 2026-06-25 04:16:38 +02:00
Add description for info and infolist hooks
This commit is contained in:
@@ -3105,7 +3105,7 @@ weechat_lua_api_hook_info_cb (void *data, const char *info_name,
|
||||
static int
|
||||
weechat_lua_api_hook_info (lua_State *L)
|
||||
{
|
||||
const char *info_name, *function;
|
||||
const char *info_name, *description, *function;
|
||||
char *result;
|
||||
int n;
|
||||
|
||||
@@ -3123,18 +3123,20 @@ weechat_lua_api_hook_info (lua_State *L)
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 2)
|
||||
if (n < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_info");
|
||||
LUA_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
info_name = lua_tostring (lua_current_interpreter, -2);
|
||||
info_name = lua_tostring (lua_current_interpreter, -3);
|
||||
description = lua_tostring (lua_current_interpreter, -2);
|
||||
function = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
result = script_ptr2str (script_api_hook_info (weechat_lua_plugin,
|
||||
lua_current_script,
|
||||
info_name,
|
||||
description,
|
||||
&weechat_lua_api_hook_info_cb,
|
||||
function));
|
||||
|
||||
@@ -3178,7 +3180,7 @@ weechat_lua_api_hook_infolist_cb (void *data, const char *info_name,
|
||||
static int
|
||||
weechat_lua_api_hook_infolist (lua_State *L)
|
||||
{
|
||||
const char *infolist_name, *function;
|
||||
const char *infolist_name, *description, *function;
|
||||
char *result;
|
||||
int n;
|
||||
|
||||
@@ -3196,18 +3198,20 @@ weechat_lua_api_hook_infolist (lua_State *L)
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 2)
|
||||
if (n < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_infolist");
|
||||
LUA_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
infolist_name = lua_tostring (lua_current_interpreter, -2);
|
||||
infolist_name = lua_tostring (lua_current_interpreter, -3);
|
||||
description = lua_tostring (lua_current_interpreter, -2);
|
||||
function = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
result = script_ptr2str (script_api_hook_infolist (weechat_lua_plugin,
|
||||
lua_current_script,
|
||||
infolist_name,
|
||||
description,
|
||||
&weechat_lua_api_hook_infolist_cb,
|
||||
function));
|
||||
|
||||
|
||||
@@ -2597,7 +2597,7 @@ weechat_perl_api_hook_info_cb (void *data, const char *info_name,
|
||||
|
||||
static XS (XS_weechat_hook_info)
|
||||
{
|
||||
char *result, *info_name, *perl_fn;
|
||||
char *result, *info_name, *description, *perl_fn;
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -2609,17 +2609,19 @@ static XS (XS_weechat_hook_info)
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (items < 2)
|
||||
if (items < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_info");
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
info_name = SvPV (ST (0), PL_na);
|
||||
perl_fn = SvPV (ST (1), PL_na);
|
||||
description = SvPV (ST (1), PL_na);
|
||||
perl_fn = SvPV (ST (2), PL_na);
|
||||
result = script_ptr2str (script_api_hook_info (weechat_perl_plugin,
|
||||
perl_current_script,
|
||||
info_name,
|
||||
description,
|
||||
&weechat_perl_api_hook_info_cb,
|
||||
perl_fn));
|
||||
|
||||
@@ -2662,7 +2664,7 @@ weechat_perl_api_hook_infolist_cb (void *data, const char *infolist_name,
|
||||
|
||||
static XS (XS_weechat_hook_infolist)
|
||||
{
|
||||
char *result, *infolist_name, *perl_fn;
|
||||
char *result, *infolist_name, *description, *perl_fn;
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -2674,17 +2676,19 @@ static XS (XS_weechat_hook_infolist)
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (items < 2)
|
||||
if (items < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_infolist");
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
infolist_name = SvPV (ST (0), PL_na);
|
||||
perl_fn = SvPV (ST (1), PL_na);
|
||||
description = SvPV (ST (1), PL_na);
|
||||
perl_fn = SvPV (ST (2), PL_na);
|
||||
result = script_ptr2str (script_api_hook_infolist (weechat_perl_plugin,
|
||||
perl_current_script,
|
||||
infolist_name,
|
||||
description,
|
||||
&weechat_perl_api_hook_infolist_cb,
|
||||
perl_fn));
|
||||
|
||||
|
||||
@@ -2754,7 +2754,7 @@ weechat_python_api_hook_info_cb (void *data, const char *info_name,
|
||||
static PyObject *
|
||||
weechat_python_api_hook_info (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *info_name, *function, *result;
|
||||
char *info_name, *description, *function, *result;
|
||||
PyObject *object;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -2767,9 +2767,10 @@ weechat_python_api_hook_info (PyObject *self, PyObject *args)
|
||||
}
|
||||
|
||||
info_name = NULL;
|
||||
description = NULL;
|
||||
function = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "ss", &info_name, &function))
|
||||
if (!PyArg_ParseTuple (args, "sss", &info_name, &description, &function))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_info");
|
||||
PYTHON_RETURN_EMPTY;
|
||||
@@ -2778,6 +2779,7 @@ weechat_python_api_hook_info (PyObject *self, PyObject *args)
|
||||
result = script_ptr2str(script_api_hook_info (weechat_python_plugin,
|
||||
python_current_script,
|
||||
info_name,
|
||||
description,
|
||||
&weechat_python_api_hook_info_cb,
|
||||
function));
|
||||
|
||||
@@ -2821,7 +2823,7 @@ weechat_python_api_hook_infolist_cb (void *data, const char *infolist_name,
|
||||
static PyObject *
|
||||
weechat_python_api_hook_infolist (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *infolist_name, *function, *result;
|
||||
char *infolist_name, *description, *function, *result;
|
||||
PyObject *object;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -2834,9 +2836,10 @@ weechat_python_api_hook_infolist (PyObject *self, PyObject *args)
|
||||
}
|
||||
|
||||
infolist_name = NULL;
|
||||
description = NULL;
|
||||
function = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "ss", &infolist_name, &function))
|
||||
if (!PyArg_ParseTuple (args, "sss", &infolist_name, &description, &function))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_infolist");
|
||||
PYTHON_RETURN_EMPTY;
|
||||
@@ -2845,6 +2848,7 @@ weechat_python_api_hook_infolist (PyObject *self, PyObject *args)
|
||||
result = script_ptr2str(script_api_hook_infolist (weechat_python_plugin,
|
||||
python_current_script,
|
||||
infolist_name,
|
||||
description,
|
||||
&weechat_python_api_hook_infolist_cb,
|
||||
function));
|
||||
|
||||
|
||||
@@ -3162,9 +3162,10 @@ weechat_ruby_api_hook_info_cb (void *data, const char *info_name,
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_hook_info (VALUE class, VALUE info_name, VALUE function)
|
||||
weechat_ruby_api_hook_info (VALUE class, VALUE info_name, VALUE description,
|
||||
VALUE function)
|
||||
{
|
||||
char *c_info_name, *c_function, *result;
|
||||
char *c_info_name, *c_description, *c_function, *result;
|
||||
VALUE return_value;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -3177,23 +3178,27 @@ weechat_ruby_api_hook_info (VALUE class, VALUE info_name, VALUE function)
|
||||
}
|
||||
|
||||
c_info_name = NULL;
|
||||
c_description = NULL;
|
||||
c_function = NULL;
|
||||
|
||||
if (NIL_P (info_name) || NIL_P (function))
|
||||
if (NIL_P (info_name) || NIL_P (description) || NIL_P (function))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_info");
|
||||
RUBY_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
Check_Type (info_name, T_STRING);
|
||||
Check_Type (description, T_STRING);
|
||||
Check_Type (function, T_STRING);
|
||||
|
||||
c_info_name = STR2CSTR (info_name);
|
||||
c_description = STR2CSTR (description);
|
||||
c_function = STR2CSTR (function);
|
||||
|
||||
result = script_ptr2str (script_api_hook_info (weechat_ruby_plugin,
|
||||
ruby_current_script,
|
||||
c_info_name,
|
||||
c_description,
|
||||
&weechat_ruby_api_hook_info_cb,
|
||||
c_function));
|
||||
|
||||
@@ -3235,9 +3240,10 @@ weechat_ruby_api_hook_infolist_cb (void *data, const char *infolist_name,
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_hook_infolist (VALUE class, VALUE infolist_name, VALUE function)
|
||||
weechat_ruby_api_hook_infolist (VALUE class, VALUE infolist_name,
|
||||
VALUE description, VALUE function)
|
||||
{
|
||||
char *c_infolist_name, *c_function, *result;
|
||||
char *c_infolist_name, *c_description, *c_function, *result;
|
||||
VALUE return_value;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -3250,23 +3256,27 @@ weechat_ruby_api_hook_infolist (VALUE class, VALUE infolist_name, VALUE function
|
||||
}
|
||||
|
||||
c_infolist_name = NULL;
|
||||
c_description = NULL;
|
||||
c_function = NULL;
|
||||
|
||||
if (NIL_P (infolist_name) || NIL_P (function))
|
||||
if (NIL_P (infolist_name) || NIL_P (description) || NIL_P (function))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_infolist");
|
||||
RUBY_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
Check_Type (infolist_name, T_STRING);
|
||||
Check_Type (description, T_STRING);
|
||||
Check_Type (function, T_STRING);
|
||||
|
||||
c_infolist_name = STR2CSTR (infolist_name);
|
||||
c_description = STR2CSTR (description);
|
||||
c_function = STR2CSTR (function);
|
||||
|
||||
result = script_ptr2str (script_api_hook_infolist (weechat_ruby_plugin,
|
||||
ruby_current_script,
|
||||
c_infolist_name,
|
||||
c_description,
|
||||
&weechat_ruby_api_hook_infolist_cb,
|
||||
c_function));
|
||||
|
||||
@@ -4964,8 +4974,8 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
|
||||
rb_define_module_function (ruby_mWeechat, "hook_completion_list_add", &weechat_ruby_api_hook_completion_list_add, 4);
|
||||
rb_define_module_function (ruby_mWeechat, "hook_modifier", &weechat_ruby_api_hook_modifier, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "hook_modifier_exec", &weechat_ruby_api_hook_modifier_exec, 3);
|
||||
rb_define_module_function (ruby_mWeechat, "hook_info", &weechat_ruby_api_hook_info, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "hook_infolist", &weechat_ruby_api_hook_infolist, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "hook_info", &weechat_ruby_api_hook_info, 3);
|
||||
rb_define_module_function (ruby_mWeechat, "hook_infolist", &weechat_ruby_api_hook_infolist, 3);
|
||||
rb_define_module_function (ruby_mWeechat, "unhook", &weechat_ruby_api_unhook, 1);
|
||||
rb_define_module_function (ruby_mWeechat, "unhook_all", &weechat_ruby_api_unhook_all, 0);
|
||||
rb_define_module_function (ruby_mWeechat, "buffer_new", &weechat_ruby_api_buffer_new, 4);
|
||||
|
||||
@@ -884,6 +884,7 @@ struct t_hook *
|
||||
script_api_hook_info (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
const char *info_name,
|
||||
const char *description,
|
||||
char *(*callback)(void *data,
|
||||
const char *info_name,
|
||||
const char *arguments),
|
||||
@@ -896,7 +897,8 @@ script_api_hook_info (struct t_weechat_plugin *weechat_plugin,
|
||||
if (!new_script_callback)
|
||||
return NULL;
|
||||
|
||||
new_hook = weechat_hook_info (info_name, callback, new_script_callback);
|
||||
new_hook = weechat_hook_info (info_name, description,
|
||||
callback, new_script_callback);
|
||||
if (!new_hook)
|
||||
{
|
||||
script_callback_free_data (new_script_callback);
|
||||
@@ -922,6 +924,7 @@ struct t_hook *
|
||||
script_api_hook_infolist (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
const char *infolist_name,
|
||||
const char *description,
|
||||
struct t_infolist *(*callback)(void *data,
|
||||
const char *infolist_name,
|
||||
void *pointer,
|
||||
@@ -935,7 +938,7 @@ script_api_hook_infolist (struct t_weechat_plugin *weechat_plugin,
|
||||
if (!new_script_callback)
|
||||
return NULL;
|
||||
|
||||
new_hook = weechat_hook_infolist (infolist_name,
|
||||
new_hook = weechat_hook_infolist (infolist_name, description,
|
||||
callback, new_script_callback);
|
||||
if (!new_hook)
|
||||
{
|
||||
|
||||
@@ -153,6 +153,7 @@ extern struct t_hook *script_api_hook_modifier (struct t_weechat_plugin *weechat
|
||||
extern struct t_hook *script_api_hook_info (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
const char *info_name,
|
||||
const char *description,
|
||||
char *(*callback)(void *data,
|
||||
const char *info_name,
|
||||
const char *arguments),
|
||||
@@ -160,6 +161,7 @@ extern struct t_hook *script_api_hook_info (struct t_weechat_plugin *weechat_plu
|
||||
extern struct t_hook *script_api_hook_infolist (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
const char *infolist_name,
|
||||
const char *description,
|
||||
struct t_infolist *(*callback)(void *data,
|
||||
const char *infolist_name,
|
||||
void *pointer,
|
||||
|
||||
Reference in New Issue
Block a user