1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-08 10:43:13 +02:00

core: add command /eval, use expression in conditions for bars, add function "string_eval_expression" in plugin API

This commit is contained in:
Sebastien Helleu
2012-11-02 09:37:15 +01:00
parent 3ec0ad7c62
commit 32c93b5c0a
67 changed files with 4141 additions and 462 deletions
+54 -5
View File
@@ -420,6 +420,44 @@ weechat_guile_api_string_input_for_buffer (SCM string)
API_RETURN_STRING(result);
}
/*
* weechat_guile_api_string_eval_expression: evaluate an expression and return
* result
*/
SCM
weechat_guile_api_string_eval_expression (SCM expr, SCM pointers,
SCM extra_vars)
{
char *result;
SCM return_value;
struct t_hashtable *c_pointers, *c_extra_vars;
API_FUNC(1, "string_eval_expression", API_RETURN_EMPTY);
if (!scm_is_string (expr) || !scm_list_p (pointers)
|| !scm_list_p (extra_vars))
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);
result = weechat_string_eval_expression (scm_i_string_chars (expr),
c_pointers, c_extra_vars);
if (c_pointers)
weechat_hashtable_free (c_pointers);
if (c_extra_vars)
weechat_hashtable_free (c_extra_vars);
API_RETURN_STRING_FREE(result);
}
/*
* weechat_guile_api_mkdir_home: create a directory in WeeChat home
*/
@@ -1933,7 +1971,9 @@ weechat_guile_api_key_bind (SCM context, SCM keys)
API_WRONG_ARGS(API_RETURN_INT(0));
c_keys = weechat_guile_alist_to_hashtable (keys,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
num_keys = weechat_key_bind (scm_i_string_chars (context), c_keys);
@@ -2454,7 +2494,9 @@ weechat_guile_api_hook_process_hashtable (SCM command, SCM options, SCM timeout,
API_WRONG_ARGS(API_RETURN_EMPTY);
c_options = weechat_guile_alist_to_hashtable (options,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
result = API_PTR2STR(plugin_script_api_hook_process_hashtable (weechat_guile_plugin,
guile_current_script,
@@ -2861,7 +2903,9 @@ weechat_guile_api_hook_hsignal_send (SCM signal, SCM hashtable)
API_WRONG_ARGS(API_RETURN_ERROR);
c_hashtable = weechat_guile_alist_to_hashtable (hashtable,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
weechat_hook_hsignal_send (scm_i_string_chars (signal), c_hashtable);
@@ -4462,7 +4506,9 @@ weechat_guile_api_info_get_hashtable (SCM info_name, SCM hash)
API_WRONG_ARGS(API_RETURN_EMPTY);
c_hashtable = weechat_guile_alist_to_hashtable (hash,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
result_hashtable = weechat_info_get_hashtable (scm_i_string_chars (info_name),
c_hashtable);
@@ -5160,7 +5206,9 @@ weechat_guile_api_hdata_update (SCM hdata, SCM pointer, SCM hashtable)
API_WRONG_ARGS(API_RETURN_INT(0));
c_hashtable = weechat_guile_alist_to_hashtable (hashtable,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
value = weechat_hdata_update (API_STR2PTR(scm_i_string_chars (hdata)),
API_STR2PTR(scm_i_string_chars (pointer)),
@@ -5358,6 +5406,7 @@ weechat_guile_api_module_init (void *data)
API_DEF_FUNC(string_remove_color, 2);
API_DEF_FUNC(string_is_command_char, 1);
API_DEF_FUNC(string_input_for_buffer, 1);
API_DEF_FUNC(string_eval_expression, 3);
API_DEF_FUNC(mkdir_home, 2);
API_DEF_FUNC(mkdir, 2);
API_DEF_FUNC(mkdir_parents, 2);
+26 -12
View File
@@ -198,22 +198,21 @@ weechat_guile_hashtable_to_alist (struct t_hashtable *hashtable)
/*
* weechat_guile_alist_to_hashtable: get WeeChat hashtable with Guile alist
* Hashtable returned has type string for
* both keys and values
* Note: hashtable has to be released after
* use with call to weechat_hashtable_free()
*/
struct t_hashtable *
weechat_guile_alist_to_hashtable (SCM alist, int hashtable_size)
weechat_guile_alist_to_hashtable (SCM alist, int size, const char *type_keys,
const char *type_values)
{
struct t_hashtable *hashtable;
int length, i;
SCM pair;
hashtable = weechat_hashtable_new (hashtable_size,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
hashtable = weechat_hashtable_new (size,
type_keys,
type_values,
NULL,
NULL);
if (!hashtable)
@@ -223,11 +222,24 @@ weechat_guile_alist_to_hashtable (SCM alist, int hashtable_size)
for (i = 0; i < length; i++)
{
pair = scm_list_ref (alist, scm_from_int (i));
weechat_hashtable_set (hashtable,
scm_i_string_chars (scm_list_ref (pair,
scm_from_int (0))),
scm_i_string_chars (scm_list_ref (pair,
scm_from_int (1))));
if (strcmp (type_values, WEECHAT_HASHTABLE_STRING) == 0)
{
weechat_hashtable_set (hashtable,
scm_i_string_chars (scm_list_ref (pair,
scm_from_int (0))),
scm_i_string_chars (scm_list_ref (pair,
scm_from_int (1))));
}
else if (strcmp (type_values, WEECHAT_HASHTABLE_POINTER) == 0)
{
weechat_hashtable_set (hashtable,
scm_i_string_chars (scm_list_ref (pair,
scm_from_int (0))),
plugin_script_str2ptr (weechat_guile_plugin,
NULL, NULL,
scm_i_string_chars (scm_list_ref (pair,
scm_from_int (1)))));
}
}
return hashtable;
@@ -305,7 +317,9 @@ weechat_guile_exec (struct t_plugin_script *script,
else if (ret_type == WEECHAT_SCRIPT_EXEC_HASHTABLE)
{
ret_value = weechat_guile_alist_to_hashtable (rc,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
}
else
{
+3 -1
View File
@@ -37,7 +37,9 @@ extern SCM guile_port;
extern SCM weechat_guile_hashtable_to_alist (struct t_hashtable *hashtable);
extern struct t_hashtable *weechat_guile_alist_to_hashtable (SCM dict,
int hashtable_size);
int size,
const char *type_keys,
const char *type_values);
extern void *weechat_guile_exec (struct t_plugin_script *script,
int ret_type, const char *function,
char *format, void **argv);
+52 -5
View File
@@ -460,6 +460,42 @@ weechat_lua_api_string_input_for_buffer (lua_State *L)
API_RETURN_STRING(result);
}
/*
* weechat_lua_api_string_eval_expression: evaluate an expression and return
* result
*/
static int
weechat_lua_api_string_eval_expression (lua_State *L)
{
const char *expr;
struct t_hashtable *pointers, *extra_vars;
char *result;
API_FUNC(1, "string_eval_expression", API_RETURN_EMPTY);
if (lua_gettop (lua_current_interpreter) < 3)
API_WRONG_ARGS(API_RETURN_EMPTY);
expr = lua_tostring (lua_current_interpreter, -3);
pointers = weechat_lua_tohashtable (lua_current_interpreter, -2,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_POINTER);
extra_vars = weechat_lua_tohashtable (lua_current_interpreter, -1,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
result = weechat_string_eval_expression (expr, pointers, extra_vars);
if (pointers)
weechat_hashtable_free (pointers);
if (extra_vars)
weechat_hashtable_free (extra_vars);
API_RETURN_STRING_FREE(result);
}
/*
* weechat_lua_api_mkdir_home: create a directory in WeeChat home
*/
@@ -2133,7 +2169,9 @@ weechat_lua_api_key_bind (lua_State *L)
context = lua_tostring (lua_current_interpreter, -2);
hashtable = weechat_lua_tohashtable (lua_current_interpreter, -1,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
num_keys = weechat_key_bind (context, hashtable);
@@ -2702,7 +2740,9 @@ weechat_lua_api_hook_process_hashtable (lua_State *L)
command = lua_tostring (lua_current_interpreter, -5);
options = weechat_lua_tohashtable (lua_current_interpreter, -4,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
timeout = lua_tonumber (lua_current_interpreter, -3);
function = lua_tostring (lua_current_interpreter, -2);
data = lua_tostring (lua_current_interpreter, -1);
@@ -3127,7 +3167,9 @@ weechat_lua_api_hook_hsignal_send (lua_State *L)
signal = lua_tostring (lua_current_interpreter, -2);
hashtable = weechat_lua_tohashtable (lua_current_interpreter, -1,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
weechat_hook_hsignal_send (signal, hashtable);
@@ -4899,7 +4941,9 @@ weechat_lua_api_info_get_hashtable (lua_State *L)
info_name = lua_tostring (lua_current_interpreter, -2);
table = weechat_lua_tohashtable (lua_current_interpreter, -1,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
result_hashtable = weechat_info_get_hashtable (info_name, table);
@@ -5695,7 +5739,9 @@ weechat_lua_api_hdata_update (lua_State *L)
hdata = lua_tostring (lua_current_interpreter, -3);
pointer = lua_tostring (lua_current_interpreter, -2);
hashtable = weechat_lua_tohashtable (lua_current_interpreter, -1,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
value = weechat_hdata_update (API_STR2PTR(hdata),
API_STR2PTR(pointer),
@@ -6296,6 +6342,7 @@ const struct luaL_Reg weechat_lua_api_funcs[] = {
API_DEF_FUNC(string_remove_color),
API_DEF_FUNC(string_is_command_char),
API_DEF_FUNC(string_input_for_buffer),
API_DEF_FUNC(string_eval_expression),
API_DEF_FUNC(mkdir_home),
API_DEF_FUNC(mkdir),
API_DEF_FUNC(mkdir_parents),
+22 -10
View File
@@ -108,20 +108,19 @@ weechat_lua_pushhashtable (lua_State *interpreter, struct t_hashtable *hashtable
/*
* weechat_lua_hash_to_hashtable: get WeeChat hashtable with lua hash (on stack)
* Hashtable returned has type string for
* both keys and values
* Note: hashtable has to be released after use
* with call to weechat_hashtable_free()
*/
struct t_hashtable *
weechat_lua_tohashtable (lua_State *interpreter, int index, int hashtable_size)
weechat_lua_tohashtable (lua_State *interpreter, int index, int size,
const char *type_keys, const char *type_values)
{
struct t_hashtable *hashtable;
hashtable = weechat_hashtable_new (hashtable_size,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
hashtable = weechat_hashtable_new (size,
type_keys,
type_values,
NULL,
NULL);
if (!hashtable)
@@ -130,9 +129,20 @@ weechat_lua_tohashtable (lua_State *interpreter, int index, int hashtable_size)
lua_pushnil (interpreter);
while (lua_next (interpreter, index - 1) != 0)
{
weechat_hashtable_set (hashtable,
lua_tostring (interpreter, -2),
lua_tostring (interpreter, -1));
if (strcmp (type_values, WEECHAT_HASHTABLE_STRING) == 0)
{
weechat_hashtable_set (hashtable,
lua_tostring (interpreter, -2),
lua_tostring (interpreter, -1));
}
else if (strcmp (type_values, WEECHAT_HASHTABLE_POINTER) == 0)
{
weechat_hashtable_set (hashtable,
lua_tostring (interpreter, -2),
plugin_script_str2ptr (weechat_lua_plugin,
NULL, NULL,
lua_tostring (interpreter, -1)));
}
/* remove value from stack (keep key for next iteration) */
lua_pop (interpreter, 1);
}
@@ -209,7 +219,9 @@ weechat_lua_exec (struct t_plugin_script *script, int ret_type,
else if (ret_type == WEECHAT_SCRIPT_EXEC_HASHTABLE)
{
ret_value = weechat_lua_tohashtable (lua_current_interpreter, -1,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
}
else
{
+3 -1
View File
@@ -40,7 +40,9 @@ extern void weechat_lua_pushhashtable (lua_State *interpreter,
struct t_hashtable *hashtable);
extern struct t_hashtable *weechat_lua_tohashtable (lua_State *interpreter,
int index,
int hashtable_size);
int size,
const char *type_keys,
const char *type_values);
extern void *weechat_lua_exec (struct t_plugin_script *script, int ret_type,
const char *function,
const char *format, void **argv);
+50 -5
View File
@@ -436,6 +436,40 @@ XS (XS_weechat_api_string_input_for_buffer)
API_RETURN_STRING(result);
}
/*
* weechat::string_eval_expression: evaluate expression and return result
*/
XS (XS_weechat_api_string_eval_expression)
{
char *expr, *result;
struct t_hashtable *pointers, *extra_vars;
dXSARGS;
API_FUNC(1, "string_eval_expression", API_RETURN_EMPTY);
if (items < 3)
API_WRONG_ARGS(API_RETURN_EMPTY);
expr = SvPV_nolen (ST (0));
pointers = weechat_perl_hash_to_hashtable (ST (1),
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_POINTER);
extra_vars = weechat_perl_hash_to_hashtable (ST (2),
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
result = weechat_string_eval_expression (expr, pointers, extra_vars);
if (pointers)
weechat_hashtable_free (pointers);
if (extra_vars)
weechat_hashtable_free (extra_vars);
API_RETURN_STRING_FREE(result);
}
/*
* weechat::mkdir_home: create a directory in WeeChat home
*/
@@ -2003,7 +2037,9 @@ XS (XS_weechat_api_key_bind)
context = SvPV_nolen (ST (0));
hashtable = weechat_perl_hash_to_hashtable (ST (1),
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
num_keys = weechat_key_bind (context, hashtable);
@@ -2537,7 +2573,9 @@ XS (XS_weechat_api_hook_process_hashtable)
command = SvPV_nolen (ST (0));
options = weechat_perl_hash_to_hashtable (ST (1),
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
function = SvPV_nolen (ST (3));
data = SvPV_nolen (ST (4));
@@ -2951,7 +2989,9 @@ XS (XS_weechat_api_hook_hsignal_send)
signal = SvPV_nolen (ST (0));
hashtable = weechat_perl_hash_to_hashtable (ST (1),
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
weechat_hook_hsignal_send (signal, hashtable);
@@ -4663,7 +4703,9 @@ XS (XS_weechat_api_info_get_hashtable)
info_name = SvPV_nolen (ST (0));
hashtable = weechat_perl_hash_to_hashtable (ST (1),
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
result_hashtable = weechat_info_get_hashtable (info_name, hashtable);
result_hash = weechat_perl_hashtable_to_hash (result_hashtable);
@@ -5428,7 +5470,9 @@ XS (XS_weechat_api_hdata_update)
hdata = SvPV_nolen (ST (0));
pointer = SvPV_nolen (ST (1));
hashtable = weechat_perl_hash_to_hashtable (ST (2),
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
value = weechat_hdata_update (API_STR2PTR(hdata),
API_STR2PTR(pointer),
@@ -5630,6 +5674,7 @@ weechat_perl_api_init (pTHX)
API_DEF_FUNC(string_remove_color);
API_DEF_FUNC(string_is_command_char);
API_DEF_FUNC(string_input_for_buffer);
API_DEF_FUNC(string_eval_expression);
API_DEF_FUNC(mkdir_home);
API_DEF_FUNC(mkdir);
API_DEF_FUNC(mkdir_parents);
+17 -8
View File
@@ -169,14 +169,13 @@ weechat_perl_hashtable_to_hash (struct t_hashtable *hashtable)
/*
* weechat_perl_hash_to_hashtable: get WeeChat hashtable with perl hash
* Hashtable returned has type string for
* both keys and values
* Note: hashtable has to be released after use
* with call to weechat_hashtable_free()
*/
struct t_hashtable *
weechat_perl_hash_to_hashtable (SV *hash, int hashtable_size)
weechat_perl_hash_to_hashtable (SV *hash, int size, const char *type_keys,
const char *type_values)
{
struct t_hashtable *hashtable;
HV *hash2;
@@ -184,9 +183,9 @@ weechat_perl_hash_to_hashtable (SV *hash, int hashtable_size)
char *str_key;
I32 retlen;
hashtable = weechat_hashtable_new (hashtable_size,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
hashtable = weechat_hashtable_new (size,
type_keys,
type_values,
NULL,
NULL);
if (!hashtable)
@@ -198,7 +197,15 @@ weechat_perl_hash_to_hashtable (SV *hash, int hashtable_size)
hv_iterinit (hash2);
while ((value = hv_iternextsv (hash2, &str_key, &retlen)))
{
weechat_hashtable_set (hashtable, str_key, SvPV (value, PL_na));
if (strcmp (type_values, WEECHAT_HASHTABLE_STRING) == 0)
weechat_hashtable_set (hashtable, str_key, SvPV (value, PL_na));
else if (strcmp (type_values, WEECHAT_HASHTABLE_POINTER) == 0)
{
weechat_hashtable_set (hashtable, str_key,
plugin_script_str2ptr (weechat_perl_plugin,
NULL, NULL,
SvPV (value, PL_na)));
}
}
}
@@ -316,7 +323,9 @@ weechat_perl_exec (struct t_plugin_script *script,
else if (ret_type == WEECHAT_SCRIPT_EXEC_HASHTABLE)
{
ret_value = weechat_perl_hash_to_hashtable (POPs,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
}
else
{
+3 -2
View File
@@ -35,8 +35,9 @@ extern struct t_plugin_script *perl_registered_script;
extern const char *perl_current_script_filename;
extern HV *weechat_perl_hashtable_to_hash (struct t_hashtable *hashtable);
extern struct t_hashtable *weechat_perl_hash_to_hashtable (SV *hash,
int hashtable_size);
extern struct t_hashtable *weechat_perl_hash_to_hashtable (SV *hash, int size,
const char *type_keys,
const char *type_values);
extern void *weechat_perl_exec (struct t_plugin_script *script,
int ret_type, const char *function,
const char *format, void **argv);
+1 -1
View File
@@ -286,7 +286,7 @@ plugin_script_str2ptr (struct t_weechat_plugin *weechat_plugin,
return (void *)value;
invalid:
if (weechat_plugin->debug >= 1)
if ((weechat_plugin->debug >= 1) && script_name && function_name)
{
ptr_buffer = weechat_buffer_search_main ();
if (ptr_buffer)
+2
View File
@@ -39,6 +39,7 @@
#include "../core/weechat.h"
#include "../core/wee-config.h"
#include "../core/wee-eval.h"
#include "../core/wee-hashtable.h"
#include "../core/wee-hdata.h"
#include "../core/wee-hook.h"
@@ -521,6 +522,7 @@ plugin_load (const char *filename, int argc, char **argv)
new_plugin->string_decode_base64 = &string_decode_base64;
new_plugin->string_is_command_char = &string_is_command_char;
new_plugin->string_input_for_buffer = &string_input_for_buffer;
new_plugin->string_eval_expression = &eval_expression;
new_plugin->utf8_has_8bits = &utf8_has_8bits;
new_plugin->utf8_is_valid = &utf8_is_valid;
+53 -5
View File
@@ -443,6 +443,43 @@ weechat_python_api_string_input_for_buffer (PyObject *self, PyObject *args)
API_RETURN_STRING(result);
}
/*
* weechat_python_api_string_eval_expression: evaluate expression and return
* result
*/
static PyObject *
weechat_python_api_string_eval_expression (PyObject *self, PyObject *args)
{
char *expr, *result;
struct t_hashtable *pointers, *extra_vars;
PyObject *dict, *dict2, *return_value;
API_FUNC(1, "string_eval_expression", API_RETURN_EMPTY);
expr = NULL;
pointers = NULL;
extra_vars = NULL;
if (!PyArg_ParseTuple (args, "sOO", &expr, &dict, &dict2))
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);
result = weechat_string_eval_expression (expr, pointers, extra_vars);
if (pointers)
weechat_hashtable_free (pointers);
if (extra_vars)
weechat_hashtable_free (extra_vars);
API_RETURN_STRING_FREE(result);
}
/*
* weechat_python_api_mkdir_home: create a directory in WeeChat home
*/
@@ -2081,7 +2118,9 @@ weechat_python_api_key_bind (PyObject *self, PyObject *args)
API_WRONG_ARGS(API_RETURN_INT(0));
hashtable = weechat_python_dict_to_hashtable (dict,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
num_keys = weechat_key_bind (context, hashtable);
@@ -2652,7 +2691,9 @@ weechat_python_api_hook_process_hashtable (PyObject *self, PyObject *args)
&data))
API_WRONG_ARGS(API_RETURN_EMPTY);
options = weechat_python_dict_to_hashtable (dict,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
result = API_PTR2STR(plugin_script_api_hook_process_hashtable (weechat_python_plugin,
python_current_script,
@@ -3077,7 +3118,9 @@ weechat_python_api_hook_hsignal_send (PyObject *self, PyObject *args)
API_WRONG_ARGS(API_RETURN_ERROR);
hashtable = weechat_python_dict_to_hashtable (dict,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
weechat_hook_hsignal_send (signal, hashtable);
@@ -4840,7 +4883,9 @@ weechat_python_api_info_get_hashtable (PyObject *self, PyObject *args)
if (!PyArg_ParseTuple (args, "sO", &info_name, &dict))
API_WRONG_ARGS(API_RETURN_EMPTY);
hashtable = weechat_python_dict_to_hashtable (dict,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
result_hashtable = weechat_info_get_hashtable (info_name, hashtable);
result_dict = weechat_python_hashtable_to_dict (result_hashtable);
@@ -5613,7 +5658,9 @@ weechat_python_api_hdata_update (PyObject *self, PyObject *args)
if (!PyArg_ParseTuple (args, "ssO", &hdata, &pointer, &dict))
API_WRONG_ARGS(API_RETURN_INT(0));
hashtable = weechat_python_dict_to_hashtable (dict,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
value = weechat_hdata_update (API_STR2PTR(hdata),
API_STR2PTR(pointer),
@@ -5807,6 +5854,7 @@ PyMethodDef weechat_python_funcs[] =
API_DEF_FUNC(string_remove_color),
API_DEF_FUNC(string_is_command_char),
API_DEF_FUNC(string_input_for_buffer),
API_DEF_FUNC(string_eval_expression),
API_DEF_FUNC(mkdir_home),
API_DEF_FUNC(mkdir),
API_DEF_FUNC(mkdir_parents),
+20 -8
View File
@@ -232,23 +232,23 @@ weechat_python_hashtable_to_dict (struct t_hashtable *hashtable)
/*
* weechat_python_dict_to_hashtable: get WeeChat hashtable with python
* dictionary
* Hashtable returned has type string for
* both keys and values
* Note: hashtable has to be released after
* use with call to weechat_hashtable_free()
*/
struct t_hashtable *
weechat_python_dict_to_hashtable (PyObject *dict, int hashtable_size)
weechat_python_dict_to_hashtable (PyObject *dict, int size,
const char *type_keys,
const char *type_values)
{
struct t_hashtable *hashtable;
PyObject *key, *value;
Py_ssize_t pos;
char *str_key, *str_value;
hashtable = weechat_hashtable_new (hashtable_size,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
hashtable = weechat_hashtable_new (size,
type_keys,
type_values,
NULL,
NULL);
if (!hashtable)
@@ -275,7 +275,17 @@ weechat_python_dict_to_hashtable (PyObject *dict, int hashtable_size)
str_value = weechat_python_unicode_to_string (value);
if (str_key)
weechat_hashtable_set (hashtable, str_key, str_value);
{
if (strcmp (type_values, WEECHAT_HASHTABLE_STRING) == 0)
weechat_hashtable_set (hashtable, str_key, str_value);
else if (strcmp (type_values, WEECHAT_HASHTABLE_POINTER) == 0)
{
weechat_hashtable_set (hashtable, str_key,
plugin_script_str2ptr (weechat_python_plugin,
NULL, NULL,
str_value));
}
}
if (str_key)
free (str_key);
@@ -388,7 +398,9 @@ weechat_python_exec (struct t_plugin_script *script,
else if (ret_type == WEECHAT_SCRIPT_EXEC_HASHTABLE)
{
ret_value = weechat_python_dict_to_hashtable (rc,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
Py_XDECREF(rc);
}
else
+3 -1
View File
@@ -45,7 +45,9 @@ extern const char *python_current_script_filename;
extern PyObject *weechat_python_hashtable_to_dict (struct t_hashtable *hashtable);
extern struct t_hashtable *weechat_python_dict_to_hashtable (PyObject *dict,
int hashtable_size);
int size,
const char *type_keys,
const char *type_values);
extern void *weechat_python_exec (struct t_plugin_script *script,
int ret_type, const char *function,
char *format, void **argv);
+57 -5
View File
@@ -507,6 +507,47 @@ weechat_ruby_api_string_input_for_buffer (VALUE class, VALUE string)
API_RETURN_STRING(result);
}
/*
* weechat_ruby_api_string_eval_expression: evaluate an expression and return
* result
*/
static VALUE
weechat_ruby_api_string_eval_expression (VALUE class, VALUE expr,
VALUE pointers, VALUE extra_vars)
{
char *c_expr, *result;
struct t_hashtable *c_pointers, *c_extra_vars;
VALUE return_value;
API_FUNC(1, "string_eval_expression", API_RETURN_EMPTY);
if (NIL_P (expr) || NIL_P (pointers) || NIL_P (extra_vars))
API_WRONG_ARGS(API_RETURN_EMPTY);
Check_Type (expr, T_STRING);
Check_Type (pointers, T_HASH);
Check_Type (extra_vars, T_HASH);
c_expr = StringValuePtr (expr);
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);
result = weechat_string_eval_expression (c_expr, c_pointers, c_extra_vars);
if (c_pointers)
weechat_hashtable_free (c_pointers);
if (c_extra_vars)
weechat_hashtable_free (c_extra_vars);
API_RETURN_STRING_FREE(result);
}
/*
* weechat_ruby_api_mkdir_home: create a directory in WeeChat home
*/
@@ -2389,7 +2430,9 @@ weechat_ruby_api_key_bind (VALUE class, VALUE context, VALUE keys)
c_context = StringValuePtr (context);
c_keys = weechat_ruby_hash_to_hashtable (keys,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
num_keys = weechat_key_bind (c_context, c_keys);
@@ -3031,7 +3074,9 @@ weechat_ruby_api_hook_process_hashtable (VALUE class, VALUE command,
c_command = StringValuePtr (command);
c_options = weechat_ruby_hash_to_hashtable (options,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
c_timeout = FIX2INT (timeout);
c_function = StringValuePtr (function);
c_data = StringValuePtr (data);
@@ -3498,7 +3543,9 @@ weechat_ruby_api_hook_hsignal_send (VALUE class, VALUE signal, VALUE hashtable)
c_signal = StringValuePtr (signal);
c_hashtable = weechat_ruby_hash_to_hashtable (hashtable,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
weechat_hook_hsignal_send (c_signal, c_hashtable);
@@ -5543,7 +5590,9 @@ weechat_ruby_api_info_get_hashtable (VALUE class, VALUE info_name,
c_info_name = StringValuePtr (info_name);
c_hashtable = weechat_ruby_hash_to_hashtable (hash,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
result_hashtable = weechat_info_get_hashtable (c_info_name, c_hashtable);
result_hash = weechat_ruby_hashtable_to_hash (result_hashtable);
@@ -6465,7 +6514,9 @@ weechat_ruby_api_hdata_update (VALUE class, VALUE hdata, VALUE pointer,
c_hdata = StringValuePtr (hdata);
c_pointer = StringValuePtr (pointer);
c_hashtable = weechat_ruby_hash_to_hashtable (hashtable,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
value = weechat_hdata_update (API_STR2PTR(c_hdata),
API_STR2PTR(c_pointer),
@@ -6732,6 +6783,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
API_DEF_FUNC(string_remove_color, 2);
API_DEF_FUNC(string_is_command_char, 1);
API_DEF_FUNC(string_input_for_buffer, 1);
API_DEF_FUNC(string_eval_expression, 3);
API_DEF_FUNC(mkdir_home, 2);
API_DEF_FUNC(mkdir, 2);
API_DEF_FUNC(mkdir_parents, 2);
+22 -9
View File
@@ -147,32 +147,43 @@ int
weechat_ruby_hash_foreach_cb (VALUE key, VALUE value, void *arg)
{
struct t_hashtable *hashtable;
const char *type_values;
hashtable = (struct t_hashtable *)arg;
if ((TYPE(key) == T_STRING) && (TYPE(value) == T_STRING))
{
weechat_hashtable_set (hashtable, StringValuePtr(key),
StringValuePtr(value));
type_values = weechat_hashtable_get_string (hashtable, "type_values");
if (strcmp (type_values, WEECHAT_HASHTABLE_STRING) == 0)
{
weechat_hashtable_set (hashtable, StringValuePtr(key),
StringValuePtr(value));
}
else if (strcmp (type_values, WEECHAT_HASHTABLE_POINTER) == 0)
{
weechat_hashtable_set (hashtable, StringValuePtr(key),
plugin_script_str2ptr (weechat_ruby_plugin,
NULL, NULL,
StringValuePtr(value)));
}
}
return 0;
}
/*
* weechat_ruby_hash_to_hashtable: get WeeChat hashtable with ruby hashtable
* Hashtable returned has type string for
* both keys and values
* Note: hashtable has to be released after use
* with call to weechat_hashtable_free()
*/
struct t_hashtable *
weechat_ruby_hash_to_hashtable (VALUE hash, int hashtable_size)
weechat_ruby_hash_to_hashtable (VALUE hash, int size, const char *type_keys,
const char *type_values)
{
struct t_hashtable *hashtable;
hashtable = weechat_hashtable_new (hashtable_size,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
hashtable = weechat_hashtable_new (size,
type_keys,
type_values,
NULL,
NULL);
if (!hashtable)
@@ -375,7 +386,9 @@ weechat_ruby_exec (struct t_plugin_script *script,
else if (ret_type == WEECHAT_SCRIPT_EXEC_HASHTABLE)
{
ret_value = weechat_ruby_hash_to_hashtable (rc,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
}
else
{
+3 -1
View File
@@ -37,7 +37,9 @@ extern const char *ruby_current_script_filename;
extern VALUE weechat_ruby_hashtable_to_hash (struct t_hashtable *hashtable);
extern struct t_hashtable *weechat_ruby_hash_to_hashtable (VALUE dict,
int hashtable_size);
int size,
const char *type_keys,
const char *type_values);
void *weechat_ruby_exec (struct t_plugin_script *script,
int ret_type, const char *function,
const char *format, void **argv);
+55 -5
View File
@@ -611,6 +611,45 @@ weechat_tcl_api_string_input_for_buffer (ClientData clientData, Tcl_Interp *inte
API_RETURN_STRING(result);
}
/*
* weechat_tcl_api_string_eval_expression: evaluate an expression and return
* result
*/
static int
weechat_tcl_api_string_eval_expression (ClientData clientData,
Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj *objp;
char *expr, *result;
struct t_hashtable *pointers, *extra_vars;
int i;
API_FUNC(1, "string_eval_expression", API_RETURN_EMPTY);
if (objc < 4)
API_WRONG_ARGS(API_RETURN_EMPTY);
expr = Tcl_GetStringFromObj (objv[1], &i);
pointers = weechat_tcl_dict_to_hashtable (interp, objv[2],
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_POINTER);
extra_vars = weechat_tcl_dict_to_hashtable (interp, objv[3],
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
result = weechat_string_eval_expression (expr, pointers, extra_vars);
if (pointers)
weechat_hashtable_free (pointers);
if (extra_vars)
weechat_hashtable_free (extra_vars);
API_RETURN_STRING_FREE(result);
}
/*
* weechat_tcl_api_mkdir_home: create a directory in WeeChat home
*/
@@ -2372,7 +2411,9 @@ weechat_tcl_api_key_bind (ClientData clientData, Tcl_Interp *interp,
context = Tcl_GetStringFromObj (objv[1], &i);
hashtable = weechat_tcl_dict_to_hashtable (interp, objv[2],
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
num_keys = weechat_key_bind (context, hashtable);
@@ -2973,7 +3014,9 @@ weechat_tcl_api_hook_process_hashtable (ClientData clientData,
command = Tcl_GetStringFromObj (objv[1], &i);
options = weechat_tcl_dict_to_hashtable (interp, objv[2],
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
function = Tcl_GetStringFromObj (objv[4], &i);
data = Tcl_GetStringFromObj (objv[5], &i);
@@ -3416,7 +3459,9 @@ weechat_tcl_api_hook_hsignal_send (ClientData clientData, Tcl_Interp *interp,
signal = Tcl_GetStringFromObj (objv[1], &i);
hashtable = weechat_tcl_dict_to_hashtable (interp, objv[2],
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
weechat_hook_hsignal_send (signal, hashtable);
@@ -5320,7 +5365,9 @@ weechat_tcl_api_info_get_hashtable (ClientData clientData, Tcl_Interp *interp,
API_WRONG_ARGS(API_RETURN_EMPTY);
hashtable = weechat_tcl_dict_to_hashtable (interp, objv[2],
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
result_hashtable = weechat_info_get_hashtable (Tcl_GetStringFromObj (objv[1], &i),
hashtable);
@@ -6178,7 +6225,9 @@ weechat_tcl_api_hdata_update (ClientData clientData, Tcl_Interp *interp,
hdata = Tcl_GetStringFromObj (objv[1], &i);
pointer = Tcl_GetStringFromObj (objv[2], &i);
hashtable = weechat_tcl_dict_to_hashtable (interp, objv[3],
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
value = weechat_hdata_update (API_STR2PTR(hdata),
API_STR2PTR(pointer),
@@ -6495,6 +6544,7 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
API_DEF_FUNC(string_remove_color);
API_DEF_FUNC(string_is_command_char);
API_DEF_FUNC(string_input_for_buffer);
API_DEF_FUNC(string_eval_expression);
API_DEF_FUNC(mkdir_home);
API_DEF_FUNC(mkdir);
API_DEF_FUNC(mkdir_parents);
+22 -10
View File
@@ -125,24 +125,23 @@ weechat_tcl_hashtable_to_dict (Tcl_Interp *interp,
/*
* weechat_tcl_dict_to_hashtable: get WeeChat hashtable with tcl dict
* Hashtable returned has type string for
* both keys and values
* Note: hashtable has to be released after
* use with call to weechat_hashtable_free()
*/
struct t_hashtable *
weechat_tcl_dict_to_hashtable (Tcl_Interp *interp, Tcl_Obj *dict,
int hashtable_size)
int size, const char *type_keys,
const char *type_values)
{
struct t_hashtable *hashtable;
Tcl_DictSearch search;
Tcl_Obj *key, *value;
int done;
hashtable = weechat_hashtable_new (hashtable_size,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
hashtable = weechat_hashtable_new (size,
type_keys,
type_values,
NULL,
NULL);
if (!hashtable)
@@ -152,9 +151,20 @@ weechat_tcl_dict_to_hashtable (Tcl_Interp *interp, Tcl_Obj *dict,
{
for (; !done ; Tcl_DictObjNext(&search, &key, &value, &done))
{
weechat_hashtable_set (hashtable,
Tcl_GetString (key),
Tcl_GetString (value));
if (strcmp (type_values, WEECHAT_HASHTABLE_STRING) == 0)
{
weechat_hashtable_set (hashtable,
Tcl_GetString (key),
Tcl_GetString (value));
}
else if (strcmp (type_values, WEECHAT_HASHTABLE_POINTER) == 0)
{
weechat_hashtable_set (hashtable,
Tcl_GetString (key),
plugin_script_str2ptr (weechat_tcl_plugin,
NULL, NULL,
Tcl_GetString (value)));
}
}
}
Tcl_DictObjDone(&search);
@@ -246,7 +256,9 @@ weechat_tcl_exec (struct t_plugin_script *script,
{
ret_val = weechat_tcl_dict_to_hashtable (interp,
Tcl_GetObjResult (interp),
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
}
tcl_current_script = old_tcl_script;
+3 -1
View File
@@ -39,7 +39,9 @@ extern Tcl_Obj *weechat_tcl_hashtable_to_dict (Tcl_Interp *interp,
struct t_hashtable *hashtable);
extern struct t_hashtable *weechat_tcl_dict_to_hashtable (Tcl_Interp *interp,
Tcl_Obj *dict,
int hashtable_size);
int size,
const char *type_keys,
const char *type_values);
extern void *weechat_tcl_exec (struct t_plugin_script *script,
int ret_type, const char *function,
const char *format, void **argv);
+8 -1
View File
@@ -50,7 +50,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 "20121014-01"
#define WEECHAT_PLUGIN_API_VERSION "20121102-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
@@ -251,6 +251,9 @@ struct t_weechat_plugin
int (*string_decode_base64) (const char *from, char *to);
int (*string_is_command_char) (const char *string);
const char *(*string_input_for_buffer) (const char *string);
char *(*string_eval_expression )(const char *expr,
struct t_hashtable *pointers,
struct t_hashtable *extra_vars);
/* UTF-8 strings */
int (*utf8_has_8bits) (const char *string);
@@ -1009,6 +1012,10 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
weechat_plugin->string_is_command_char(__string)
#define weechat_string_input_for_buffer(__string) \
weechat_plugin->string_input_for_buffer(__string)
#define weechat_string_eval_expression(__expr, __pointers, \
__extra_vars) \
weechat_plugin->string_eval_expression(__expr, __pointers, \
__extra_vars) \
/* UTF-8 strings */
#define weechat_utf8_has_8bits(__string) \