summaryrefslogtreecommitdiff
path: root/src/plugins/scripts/python
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2011-06-26 18:15:42 +0200
committerSebastien Helleu <flashcode@flashtux.org>2011-06-26 18:15:42 +0200
commit19bc95b96189de5a645adbe7b3487d5de1b835e7 (patch)
treeb68d3d98d3d643bc02fba218db7f7ed6cd07ea2c /src/plugins/scripts/python
parent2a630031fd3c868733e3038c3e19ad4b53a8d8ce (diff)
downloadweechat-19bc95b96189de5a645adbe7b3487d5de1b835e7.zip
core: many improvements on hdata
New features: - add optional hdata name for variables in hdata - add plugin API functions: hdata_get_var_hdata - use hashtable to store hdata (created by WeeChat and plugins) - free hdata and infolists created by plugin on plugin unload - free all hdata on exit - add "free" option to command /debug hdata - remove hdata for hooks
Diffstat (limited to 'src/plugins/scripts/python')
-rw-r--r--src/plugins/scripts/python/weechat-python-api.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/plugins/scripts/python/weechat-python-api.c b/src/plugins/scripts/python/weechat-python-api.c
index 8a9ccfcab..05df01e70 100644
--- a/src/plugins/scripts/python/weechat-python-api.c
+++ b/src/plugins/scripts/python/weechat-python-api.c
@@ -6876,6 +6876,39 @@ weechat_python_api_hdata_get (PyObject *self, PyObject *args)
}
/*
+ * weechat_python_api_hdata_get_var_offset: get offset of variable in hdata
+ */
+
+static PyObject *
+weechat_python_api_hdata_get_var_offset (PyObject *self, PyObject *args)
+{
+ char *hdata, *name;
+ int value;
+
+ /* make C compiler happy */
+ (void) self;
+
+ if (!python_current_script || !python_current_script->name)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hdata_get_var_offset");
+ PYTHON_RETURN_INT(0);
+ }
+
+ hdata = NULL;
+ name = NULL;
+
+ if (!PyArg_ParseTuple (args, "ss", &hdata, &name))
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hdata_get_var_offset");
+ PYTHON_RETURN_INT(0);
+ }
+
+ value = weechat_hdata_get_var_offset (script_str2ptr (hdata), name);
+
+ PYTHON_RETURN_INT(value);
+}
+
+/*
* weechat_python_api_hdata_get_var_type_string: get type of variable as string
* in hdata
*/
@@ -6910,6 +6943,39 @@ weechat_python_api_hdata_get_var_type_string (PyObject *self, PyObject *args)
}
/*
+ * weechat_python_api_hdata_get_var_hdata: get hdata for variable in hdata
+ */
+
+static PyObject *
+weechat_python_api_hdata_get_var_hdata (PyObject *self, PyObject *args)
+{
+ char *hdata, *name;
+ const char *result;
+
+ /* make C compiler happy */
+ (void) self;
+
+ if (!python_current_script || !python_current_script->name)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hdata_get_var_hdata");
+ PYTHON_RETURN_EMPTY;
+ }
+
+ hdata = NULL;
+ name = NULL;
+
+ if (!PyArg_ParseTuple (args, "ss", &hdata, &name))
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hdata_get_var_hdata");
+ PYTHON_RETURN_EMPTY;
+ }
+
+ result = weechat_hdata_get_var_hdata (script_str2ptr (hdata), name);
+
+ PYTHON_RETURN_STRING(result);
+}
+
+/*
* weechat_python_api_hdata_get_list: get list pointer in hdata
*/
@@ -7555,7 +7621,9 @@ PyMethodDef weechat_python_funcs[] =
{ "infolist_time", &weechat_python_api_infolist_time, METH_VARARGS, "" },
{ "infolist_free", &weechat_python_api_infolist_free, METH_VARARGS, "" },
{ "hdata_get", &weechat_python_api_hdata_get, METH_VARARGS, "" },
+ { "hdata_get_var_offset", &weechat_python_api_hdata_get_var_offset, METH_VARARGS, "" },
{ "hdata_get_var_type_string", &weechat_python_api_hdata_get_var_type_string, METH_VARARGS, "" },
+ { "hdata_get_var_hdata", &weechat_python_api_hdata_get_var_hdata, METH_VARARGS, "" },
{ "hdata_get_list", &weechat_python_api_hdata_get_list, METH_VARARGS, "" },
{ "hdata_move", &weechat_python_api_hdata_move, METH_VARARGS, "" },
{ "hdata_integer", &weechat_python_api_hdata_integer, METH_VARARGS, "" },