I believe also some of the systems used to ease creating bindings/python extensions can allow calling python code or having python functions for callback functions. I'm quite certain pyrex does allow this, I'm not so sure whether swig does (although with swig you could go to telling it to insert the C code as suggested by Mario).
What system is used for creating the brltty bindings? Michael Whapples On 03/07/09 09:08, Mario Lang wrote: > Samuel Thibault<[email protected]> writes: > > >> Willie Walker, le Thu 02 Jul 2009 15:29:45 -0400, a écrit : >> >>> BrlAPI provides a brlapi_setExceptionHandler method, but I'm not sure >>> how to get to it from Python. Can you BrlTTY folks offer some guidance? >>> >> We haven't implemented anything for this yet. The issue is being able >> to call python code from the C code, I don't know how this is allowed to >> be done. >> > The following article is probably pretty helpful: > http://www.codeproject.com/KB/cpp/embedpython_1.aspx > > #include<Python.h> > > int main(int argc, char *argv[]) > { > PyObject *pName, *pModule, *pDict, *pFunc, *pValue; > > if (argc< 3) { > printf("Usage: %s python_source function_name\n", argv[0]); > return 1; > } > > Py_Initialize(); > pName = PyString_FromString(argv[1]); > pModule = PyImport_Import(pName); > pDict = PyModule_GetDict(pModule); > pFunc = PyDict_GetItemString(pDict, argv[2]); > if (PyCallable_Check(pFunc)) { > PyObject_CallObject(pFunc, NULL); > } else { > PyErr_Print(); > } > > /* Clean up */ > Py_DECREF(pModule); > Py_DECREF(pName); > Py_Finalize(); > > return 0; > } > > _______________________________________________ This message was sent via the BRLTTY mailing list. To post a message, send an e-mail to: [email protected] For general information, go to: http://mielke.cc/mailman/listinfo/brltty
