summaryrefslogtreecommitdiff
path: root/src/plugins/python/weechat-python.c
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2012-11-02 09:37:15 +0100
committerSebastien Helleu <flashcode@flashtux.org>2012-11-02 09:37:15 +0100
commit32c93b5c0a3abd2525677e0e2615abde8460d693 (patch)
treebb7377366ff48325d31cc2c3caecc1be3c88400f /src/plugins/python/weechat-python.c
parent3ec0ad7c62279af13fcc6ee3ef78b11dcc3be382 (diff)
downloadweechat-32c93b5c0a3abd2525677e0e2615abde8460d693.zip
core: add command /eval, use expression in conditions for bars, add function "string_eval_expression" in plugin API
Diffstat (limited to 'src/plugins/python/weechat-python.c')
-rw-r--r--src/plugins/python/weechat-python.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/plugins/python/weechat-python.c b/src/plugins/python/weechat-python.c
index 2eba42de4..d1a6d4185 100644
--- a/src/plugins/python/weechat-python.c
+++ b/src/plugins/python/weechat-python.c
@@ -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