summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2010-01-12 10:33:13 +0100
committerSebastien Helleu <flashcode@flashtux.org>2010-01-12 10:33:13 +0100
commit63aaf9dc01fef850ba5a00d11073c9d8a17b3b82 (patch)
tree71b262dd3074d1ea892e0a0ee37758a51ac2a4a9
parentAdd prefix "irc_" in some links of asciidoc files (diff)
downloadweechat-63aaf9dc01fef850ba5a00d11073c9d8a17b3b82.tar.xz
weechat-63aaf9dc01fef850ba5a00d11073c9d8a17b3b82.zip
Add function "buffer_string_replace_local_var" in script API (patch #7061)
-rw-r--r--src/plugins/scripts/lua/weechat-lua-api.c41
-rw-r--r--src/plugins/scripts/perl/weechat-perl-api.c34
-rw-r--r--src/plugins/scripts/python/weechat-python-api.c35
-rw-r--r--src/plugins/scripts/ruby/weechat-ruby-api.c41
-rw-r--r--src/plugins/scripts/tcl/weechat-tcl-api.c38
5 files changed, 189 insertions, 0 deletions
diff --git a/src/plugins/scripts/lua/weechat-lua-api.c b/src/plugins/scripts/lua/weechat-lua-api.c
index 45a987913..ff2db2fd1 100644
--- a/src/plugins/scripts/lua/weechat-lua-api.c
+++ b/src/plugins/scripts/lua/weechat-lua-api.c
@@ -5006,6 +5006,46 @@ weechat_lua_api_buffer_set (lua_State *L)
}
/*
+ * weechat_lua_api_buffer_string_replace_local_var: replace local variables ($var) in a string,
+ * using value of local variables
+ */
+
+static int
+weechat_lua_api_buffer_string_replace_local_var (lua_State *L)
+{
+ const char *buffer, *string;
+ char *result;
+ int n;
+
+ /* make C compiler happy */
+ (void) L;
+
+ if (!lua_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "buffer_string_replace_local_var");
+ LUA_RETURN_ERROR;
+ }
+
+ buffer = NULL;
+ string = NULL;
+
+ n = lua_gettop (lua_current_interpreter);
+
+ if (n < 2)
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "buffer_string_replace_local_var");
+ LUA_RETURN_ERROR;
+ }
+
+ buffer = lua_tostring (lua_current_interpreter, -2);
+ string = lua_tostring (lua_current_interpreter, -1);
+
+ result = weechat_buffer_string_replace_local_var (script_str2ptr (buffer), string);
+
+ LUA_RETURN_STRING_FREE(result);
+}
+
+/*
* weechat_lua_api_current_window: get current window
*/
@@ -7267,6 +7307,7 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
{ "buffer_get_string", &weechat_lua_api_buffer_get_string },
{ "buffer_get_pointer", &weechat_lua_api_buffer_get_pointer },
{ "buffer_set", &weechat_lua_api_buffer_set },
+ { "buffer_string_replace_local_var", &weechat_lua_api_buffer_string_replace_local_var },
{ "current_window", &weechat_lua_api_current_window },
{ "window_get_integer", &weechat_lua_api_window_get_integer },
{ "window_get_string", &weechat_lua_api_window_get_string },
diff --git a/src/plugins/scripts/perl/weechat-perl-api.c b/src/plugins/scripts/perl/weechat-perl-api.c
index 2400d4900..cd420b905 100644
--- a/src/plugins/scripts/perl/weechat-perl-api.c
+++ b/src/plugins/scripts/perl/weechat-perl-api.c
@@ -4266,6 +4266,39 @@ XS (XS_weechat_api_buffer_set)
}
/*
+ * weechat::buffer_string_replace_local_var: replace local variables ($var) in a string,
+ * using value of local variables
+ */
+
+XS (XS_weechat_api_buffer_string_replace_local_var)
+{
+ char *buffer, *string, *result;
+ dXSARGS;
+
+ /* make C compiler happy */
+ (void) cv;
+
+ if (!perl_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "buffer_string_replace_local_var");
+ PERL_RETURN_ERROR;
+ }
+
+ if (items < 2)
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "buffer_string_replace_local_var");
+ PERL_RETURN_ERROR;
+ }
+
+ buffer = SvPV (ST (0), PL_na);
+ string = SvPV (ST (1), PL_na);
+
+ result = weechat_buffer_string_replace_local_var (script_str2ptr (buffer), string);
+
+ PERL_RETURN_STRING_FREE(result);
+}
+
+/*
* weechat::current_window: get current window
*/
@@ -5837,6 +5870,7 @@ weechat_perl_api_init (pTHX)
newXS ("weechat::buffer_get_string", XS_weechat_api_buffer_get_string, "weechat");
newXS ("weechat::buffer_get_pointer", XS_weechat_api_buffer_get_pointer, "weechat");
newXS ("weechat::buffer_set", XS_weechat_api_buffer_set, "weechat");
+ newXS ("weechat::buffer_string_replace_local_var", XS_weechat_api_buffer_string_replace_local_var, "weechat");
newXS ("weechat::current_window", XS_weechat_api_current_window, "weechat");
newXS ("weechat::window_get_integer", XS_weechat_api_window_get_integer, "weechat");
newXS ("weechat::window_get_string", XS_weechat_api_window_get_string, "weechat");
diff --git a/src/plugins/scripts/python/weechat-python-api.c b/src/plugins/scripts/python/weechat-python-api.c
index e6e9cb870..f54772f55 100644
--- a/src/plugins/scripts/python/weechat-python-api.c
+++ b/src/plugins/scripts/python/weechat-python-api.c
@@ -4483,6 +4483,40 @@ weechat_python_api_buffer_set (PyObject *self, PyObject *args)
}
/*
+ * weechat_python_api_buffer_string_replace_local_var: replace local variables ($var) in a string,
+ * using value of local variables
+ */
+
+static PyObject *
+weechat_python_api_buffer_string_replace_local_var (PyObject *self, PyObject *args)
+{
+ char *buffer, *string, *result;
+ PyObject *object;
+
+ /* make C compiler happy */
+ (void) self;
+
+ if (!python_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "buffer_string_replace_local_var");
+ PYTHON_RETURN_ERROR;
+ }
+
+ buffer = NULL;
+ string = NULL;
+
+ if (!PyArg_ParseTuple (args, "ss", &buffer, &string))
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "buffer_string_replace_local_var");
+ PYTHON_RETURN_ERROR;
+ }
+
+ result = weechat_buffer_string_replace_local_var (script_str2ptr (buffer), string);
+
+ PYTHON_RETURN_STRING_FREE(result);
+}
+
+/*
* weechat_python_api_current_window: get current window
*/
@@ -6126,6 +6160,7 @@ PyMethodDef weechat_python_funcs[] =
{ "buffer_get_string", &weechat_python_api_buffer_get_string, METH_VARARGS, "" },
{ "buffer_get_pointer", &weechat_python_api_buffer_get_pointer, METH_VARARGS, "" },
{ "buffer_set", &weechat_python_api_buffer_set, METH_VARARGS, "" },
+ { "buffer_string_replace_local_var", &weechat_python_api_buffer_string_replace_local_var, METH_VARARGS, "" },
{ "current_window", &weechat_python_api_current_window, METH_VARARGS, "" },
{ "window_get_integer", &weechat_python_api_window_get_integer, METH_VARARGS, "" },
{ "window_get_string", &weechat_python_api_window_get_string, METH_VARARGS, "" },
diff --git a/src/plugins/scripts/ruby/weechat-ruby-api.c b/src/plugins/scripts/ruby/weechat-ruby-api.c
index c40c2184b..f81be474b 100644
--- a/src/plugins/scripts/ruby/weechat-ruby-api.c
+++ b/src/plugins/scripts/ruby/weechat-ruby-api.c
@@ -5155,6 +5155,46 @@ weechat_ruby_api_buffer_set (VALUE class, VALUE buffer, VALUE property,
}
/*
+ * weechat_ruby_api_buffer_string_replace_local_var: replace local variables ($var) in a string,
+ * using value of local variables
+ */
+
+static VALUE
+weechat_ruby_api_buffer_string_replace_local_var (VALUE class, VALUE buffer, VALUE string)
+{
+ char *c_buffer, *c_string, *result;
+ VALUE return_value;
+
+ /* make C compiler happy */
+ (void) class;
+
+ if (!ruby_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "buffer_string_replace_local_var");
+ RUBY_RETURN_ERROR;
+ }
+
+ c_buffer = NULL;
+ c_string = NULL;
+
+ if (NIL_P (buffer) || NIL_P (string))
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "buffer_string_replace_local_var");
+ RUBY_RETURN_ERROR;
+ }
+
+ Check_Type (buffer, T_STRING);
+ Check_Type (string, T_STRING);
+
+ c_buffer = STR2CSTR (buffer);
+ c_string = STR2CSTR (string);
+
+ result = weechat_buffer_string_replace_local_var (script_str2ptr (c_buffer), c_string);
+
+ RUBY_RETURN_STRING_FREE(result);
+}
+
+/*
* weechat_ruby_api_current_window: get current window
*/
@@ -7054,6 +7094,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
rb_define_module_function (ruby_mWeechat, "buffer_get_string", &weechat_ruby_api_buffer_get_string, 2);
rb_define_module_function (ruby_mWeechat, "buffer_get_pointer", &weechat_ruby_api_buffer_get_pointer, 2);
rb_define_module_function (ruby_mWeechat, "buffer_set", &weechat_ruby_api_buffer_set, 3);
+ rb_define_module_function (ruby_mWeechat, "buffer_string_replace_local_var", &weechat_ruby_api_buffer_string_replace_local_var, 2);
rb_define_module_function (ruby_mWeechat, "current_window", &weechat_ruby_api_current_window, 0);
rb_define_module_function (ruby_mWeechat, "window_get_integer", &weechat_ruby_api_window_get_integer, 2);
rb_define_module_function (ruby_mWeechat, "window_get_string", &weechat_ruby_api_window_get_string, 2);
diff --git a/src/plugins/scripts/tcl/weechat-tcl-api.c b/src/plugins/scripts/tcl/weechat-tcl-api.c
index 6e7e1a53a..2e3553256 100644
--- a/src/plugins/scripts/tcl/weechat-tcl-api.c
+++ b/src/plugins/scripts/tcl/weechat-tcl-api.c
@@ -4778,6 +4778,42 @@ weechat_tcl_api_buffer_set (ClientData clientData, Tcl_Interp *interp,
}
/*
+ * weechat_tcl_api_buffer_string_replace_local_var: replace local variables ($var) in a string,
+ * using value of local variables
+ */
+
+static int
+weechat_tcl_api_buffer_string_replace_local_var (ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
+{
+ Tcl_Obj *objp;
+ char *buffer, *string, *result;
+ int i;
+
+ /* make C compiler happy */
+ (void) clientData;
+
+ if (!tcl_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "buffer_string_replace_local_var");
+ TCL_RETURN_ERROR;
+ }
+
+ if (objc < 3)
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "buffer_string_replace_local_var");
+ TCL_RETURN_ERROR;
+ }
+
+ buffer = Tcl_GetStringFromObj (objv[1], &i);
+ string = Tcl_GetStringFromObj (objv[2], &i);
+
+ result = weechat_buffer_string_replace_local_var (script_str2ptr (buffer), string);
+
+ TCL_RETURN_STRING_FREE(result);
+}
+
+/*
* weechat_tcl_api_current_window: get current window
*/
@@ -6683,6 +6719,8 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
weechat_tcl_api_buffer_get_pointer, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::buffer_set",
weechat_tcl_api_buffer_set, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
+ Tcl_CreateObjCommand (interp, "weechat::buffer_string_replace_local_var",
+ weechat_tcl_api_buffer_string_replace_local_var, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::current_window",
weechat_tcl_api_current_window, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::window_get_integer",