Message52327
It looks as though you may have code from python 2.3.4 -- readline.c has been updated somewhat since then, particularly around threading.
I'm not sure I fully understand what you're asking in step 3. It looks like on_hook(obj) will already call the python function well enough; you just need a way of keeping a reference to (and registering) a list of functions.
The module uses (single) static variables for the hooks it predefines, and you followed that model; you could just add a list of objects. Instead of
Then in set_custom_hook, instead of calling set_hook immediately,
/* Not tested, you might want a dict instead, you should error check,
you should pre-declare for C89, etc */
if (NULL == custom_hooks) custom_hooks=PyList_New(0); /* no initial elements */
PyList_Append(custom_hooks, args); /* add your custom func, etc to the list */
set_hook(" ", &(PyList_GET_ITEM(custom_hooks, PyList_GET_SIZE(custom_hooks))), *args);
(Or you could just inline the checks from set_hook.)
If you're feeling ambitious, you could fix set_hook itself to use a dictionary instead of specific pointers, or to get the name from the function.__name__, or to use a newer calling convention (As I understand it, the registration may really be METH_ONE, instead of METH_VARARGS.)
|
|
| Date |
User |
Action |
Args |
| 2007-08-23 15:57:48 | admin | link | issue1690201 messages |
| 2007-08-23 15:57:48 | admin | create | |
|