diff options
author | Christopher Davis <loafier@gmail.com> | 2006-06-23 03:51:52 +0000 |
---|---|---|
committer | Christopher Davis <loafier@gmail.com> | 2006-06-23 03:51:52 +0000 |
commit | 4d33c04f15e60e21a537edd635c9ac130312a3cb (patch) | |
tree | 9530c793afd67ef5c8319c452d33011c7f7fe197 /pymodule.c | |
parent | c76f11d4ead827d8e87e265131a3dee534bc0792 (diff) | |
download | irssi-python-4d33c04f15e60e21a537edd635c9ac130312a3cb.tar.gz irssi-python-4d33c04f15e60e21a537edd635c9ac130312a3cb.tar.xz irssi-python-4d33c04f15e60e21a537edd635c9ac130312a3cb.zip |
Began work on signal handler/map system. It seems to be working;
however, events with varying <cmd> text aren't handled because
it does a straight lookup in the hashtable with the signal name
to locate the argument list. Will need to change the system to
accomodate the <cmd> events.
The basics for reference arg support is there but not well tested.
git-svn-id: http://svn.irssi.org/repos/irssi-python@4289 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'pymodule.c')
-rw-r--r-- | pymodule.c | 75 |
1 files changed, 74 insertions, 1 deletions
@@ -773,11 +773,75 @@ static PyObject *py_notifylist_find(PyObject *self, PyObject *args, PyObject *kw rec = notifylist_find(mask, ircnet); if (rec) - pynotifylist_new(rec); + return pynotifylist_new(rec); Py_RETURN_NONE; } +PyDoc_STRVAR(py_commands_doc, + "Return a list of all commands." +); +static PyObject *py_commands(PyObject *self, PyObject *args) +{ + return py_irssi_objlist_new(commands, 1, (InitFunc)pycommand_new); +} + +PyDoc_STRVAR(py_level2bits_doc, + "Level string -> number" +); +static PyObject *py_level2bits(PyObject *self, PyObject *args, PyObject *kwds) +{ + static char *kwlist[] = {"level", NULL}; + char *level = ""; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", kwlist, + &level)) + return NULL; + + return PyLong_FromUnsignedLong(level2bits(level)); +} + +PyDoc_STRVAR(py_bits2level_doc, + "Level number -> string" +); +static PyObject *py_bits2level(PyObject *self, PyObject *args, PyObject *kwds) +{ + static char *kwlist[] = {"bits", NULL}; + unsigned bits; + char *str; + PyObject *ret; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "I", kwlist, + &bits)) + return NULL; + + str = bits2level(bits); + if (str) + { + ret = PyString_FromString(str); + g_free(str); + return ret; + } + + Py_RETURN_NONE; +} + +PyDoc_STRVAR(py_combine_level_doc, + "Combine level number to level string ('+level -level'). Return new level number." +); +static PyObject *py_combine_level(PyObject *self, PyObject *args, PyObject *kwds) +{ + static char *kwlist[] = {"level", "str", NULL}; + int level = 0; + char *str = ""; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "is", kwlist, + &level, &str)) + return NULL; + + return PyLong_FromUnsignedLong(combine_level(level, str)); +} + static PyMethodDef ModuleMethods[] = { {"prnt", (PyCFunction)py_prnt, METH_VARARGS|METH_KEYWORDS, py_prnt_doc}, {"get_script", (PyCFunction)py_get_script, METH_NOARGS, py_get_script_doc}, @@ -873,9 +937,18 @@ static PyMethodDef ModuleMethods[] = { py_notifylist_ison_doc}, {"notifylist_find", (PyCFunction)py_notifylist_find, METH_VARARGS | METH_KEYWORDS, py_notifylist_find_doc}, + {"commands", (PyCFunction)py_commands, METH_NOARGS, + py_commands_doc}, + {"level2bits", (PyCFunction)py_level2bits, METH_VARARGS | METH_KEYWORDS, + py_level2bits_doc}, + {"bits2level", (PyCFunction)py_bits2level, METH_VARARGS | METH_KEYWORDS, + py_bits2level_doc}, + {"combine_level", (PyCFunction)py_combine_level, METH_VARARGS | METH_KEYWORDS, + py_combine_level_doc}, {NULL, NULL, 0, NULL} /* Sentinel */ }; +/*XXX: move to pyloader.c??*/ /* Traverse stack backwards to find the nearest _script object in globals */ static PyObject *find_script(void) { |