1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-12 14:14:48 +02:00

Add function "infolist_new_item" in script API

This commit is contained in:
Sebastien Helleu
2009-12-18 18:09:12 +01:00
parent 846fb5d283
commit 58df8c2d83
6 changed files with 173 additions and 1 deletions
+38
View File
@@ -6012,6 +6012,43 @@ weechat_lua_api_infolist_new (lua_State *L)
LUA_RETURN_STRING_FREE(result);
}
/*
* weechat_lua_api_infolist_new_item: create new item in infolist
*/
static int
weechat_lua_api_infolist_new_item (lua_State *L)
{
const char *infolist;
char *result;
int n;
/* make C compiler happy */
(void) L;
if (!lua_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "infolist_new_item");
LUA_RETURN_EMPTY;
}
infolist = NULL;
n = lua_gettop (lua_current_interpreter);
if (n < 1)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "infolist_new_item");
LUA_RETURN_EMPTY;
}
infolist = lua_tostring (lua_current_interpreter, -1);
result = script_ptr2str (weechat_infolist_new_item (script_str2ptr (infolist)));
LUA_RETURN_STRING_FREE(result);
}
/*
* weechat_lua_api_infolist_new_var_integer: create new integer variable in
* infolist
@@ -7254,6 +7291,7 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
{ "command", &weechat_lua_api_command },
{ "info_get", &weechat_lua_api_info_get },
{ "infolist_new", &weechat_lua_api_infolist_new },
{ "infolist_new_item", &weechat_lua_api_infolist_new_item },
{ "infolist_new_var_integer", &weechat_lua_api_infolist_new_var_integer },
{ "infolist_new_var_string", &weechat_lua_api_infolist_new_var_string },
{ "infolist_new_var_pointer", &weechat_lua_api_infolist_new_var_pointer },
@@ -5092,6 +5092,37 @@ XS (XS_weechat_api_infolist_new)
PERL_RETURN_STRING_FREE(result);
}
/*
* weechat::infolist_new_item: create new item in infolist
*/
XS (XS_weechat_api_infolist_new_item)
{
char *infolist, *result;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "infolist_new_item");
PERL_RETURN_EMPTY;
}
if (items < 1)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "infolist_new_item");
PERL_RETURN_EMPTY;
}
infolist = SvPV (ST (0), PL_na);
result = script_ptr2str (weechat_infolist_new_item (script_str2ptr (infolist)));
PERL_RETURN_STRING_FREE(result);
}
/*
* weechat::infolist_new_var_integer: create new integer variable in infolist
*/
@@ -5830,6 +5861,7 @@ weechat_perl_api_init (pTHX)
newXS ("weechat::command", XS_weechat_api_command, "weechat");
newXS ("weechat::info_get", XS_weechat_api_info_get, "weechat");
newXS ("weechat::infolist_new", XS_weechat_api_infolist_new, "weechat");
newXS ("weechat::infolist_new_item", XS_weechat_api_infolist_new_item, "weechat");
newXS ("weechat::infolist_new_var_integer", XS_weechat_api_infolist_new_var_integer, "weechat");
newXS ("weechat::infolist_new_var_string", XS_weechat_api_infolist_new_var_string, "weechat");
newXS ("weechat::infolist_new_var_pointer", XS_weechat_api_infolist_new_var_pointer, "weechat");
@@ -5352,6 +5352,38 @@ weechat_python_api_infolist_new (PyObject *self, PyObject *args)
PYTHON_RETURN_STRING_FREE(result);
}
/*
* weechat_python_api_infolist_new_item: create new item in infolist
*/
static PyObject *
weechat_python_api_infolist_new_item (PyObject *self, PyObject *args)
{
char *infolist, *result;
PyObject *object;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "infolist_new_item");
PYTHON_RETURN_EMPTY;
}
infolist = NULL;
if (!PyArg_ParseTuple (args, "s", &infolist))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "infolist_new_item");
PYTHON_RETURN_EMPTY;
}
result = script_ptr2str (weechat_infolist_new_item (script_str2ptr (infolist)));
PYTHON_RETURN_STRING_FREE(result);
}
/*
* weechat_python_api_infolist_new_var_integer: create new integer variable in
* infolist
@@ -6118,6 +6150,7 @@ PyMethodDef weechat_python_funcs[] =
{ "command", &weechat_python_api_command, METH_VARARGS, "" },
{ "info_get", &weechat_python_api_info_get, METH_VARARGS, "" },
{ "infolist_new", &weechat_python_api_infolist_new, METH_VARARGS, "" },
{ "infolist_new_item", &weechat_python_api_infolist_new_item, METH_VARARGS, "" },
{ "infolist_new_var_integer", &weechat_python_api_infolist_new_var_integer, METH_VARARGS, "" },
{ "infolist_new_var_string", &weechat_python_api_infolist_new_var_string, METH_VARARGS, "" },
{ "infolist_new_var_pointer", &weechat_python_api_infolist_new_var_pointer, METH_VARARGS, "" },
@@ -6169,6 +6169,40 @@ weechat_ruby_api_infolist_new (VALUE class)
RUBY_RETURN_STRING_FREE(result);
}
/*
* weechat_ruby_api_infolist_new_item: create new item in infolist
*/
static VALUE
weechat_ruby_api_infolist_new_item (VALUE class, VALUE infolist)
{
char *c_infolist, *result;
VALUE return_value;
/* make C compiler happy */
(void) class;
if (!ruby_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "infolist_new_item");
RUBY_RETURN_EMPTY;
}
if (NIL_P (infolist))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "infolist_new_item");
RUBY_RETURN_EMPTY;
}
Check_Type (infolist, T_STRING);
c_infolist = STR2CSTR (infolist);
result = script_ptr2str (weechat_infolist_new_item (script_str2ptr (c_infolist)));
RUBY_RETURN_STRING_FREE(result);
}
/*
* weechat_ruby_api_infolist_new_var_integer: create new integer variable in
* infolist
@@ -7044,6 +7078,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
rb_define_module_function (ruby_mWeechat, "command", &weechat_ruby_api_command, 2);
rb_define_module_function (ruby_mWeechat, "info_get", &weechat_ruby_api_info_get, 2);
rb_define_module_function (ruby_mWeechat, "infolist_new", &weechat_ruby_api_infolist_new, 0);
rb_define_module_function (ruby_mWeechat, "infolist_new_item", &weechat_ruby_api_infolist_new_item, 1);
rb_define_module_function (ruby_mWeechat, "infolist_new_var_integer", &weechat_ruby_api_infolist_new_var_integer, 3);
rb_define_module_function (ruby_mWeechat, "infolist_new_var_string", &weechat_ruby_api_infolist_new_var_string, 3);
rb_define_module_function (ruby_mWeechat, "infolist_new_var_pointer", &weechat_ruby_api_infolist_new_var_pointer, 3);
+34
View File
@@ -5688,6 +5688,38 @@ weechat_tcl_api_infolist_new (ClientData clientData, Tcl_Interp *interp,
TCL_RETURN_STRING_FREE(result);
}
/*
* weechat_tcl_api_infolist_new_item: create new item in infolist
*/
static int
weechat_tcl_api_infolist_new_item (ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj *objp;
char *result;
int i;
/* make C compiler happy */
(void) clientData;
if (!tcl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "infolist_new_item");
TCL_RETURN_INT(0);
}
if (objc < 1)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "infolist_new_item");
TCL_RETURN_INT(0);
}
result = script_ptr2str (weechat_infolist_new_item (script_str2ptr (Tcl_GetStringFromObj (objv[1], &i)))); /* infolist */
TCL_RETURN_STRING_FREE(result);
}
/*
* weechat_tcl_api_infolist_new_var_integer: create new integer variable in
* infolist
@@ -6699,6 +6731,8 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
weechat_tcl_api_info_get, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::infolist_new",
weechat_tcl_api_infolist_new, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::infolist_new_item",
weechat_tcl_api_infolist_new_item, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::infolist_new_var_integer",
weechat_tcl_api_infolist_new_var_integer, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::infolist_new_var_string",
+1 -1
View File
@@ -34,7 +34,7 @@ struct t_weelist;
struct timeval;
/* API version (used to check that plugin has same API and can be loaded) */
#define WEECHAT_PLUGIN_API_VERSION "20091204-01"
#define WEECHAT_PLUGIN_API_VERSION "20091218-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \