From: <jc...@gm...> - 2007-12-12 14:24:58
|
Hi all, I've used SWIG to make a Python wrapper for a C++ interface to an image processing library. I'd like to be able to intercept Python like this: my_object.an_undefined_method_name (a, b, c) and jump to some C along the lines of: PyObject *wrap_unknown_method (char *method_name, PyObject *args, PyObject *kwargs) then in that C function I can look up the image processing operation in a table, convert the Python arguments, call the operation, convert the results back to Python, and return. I want to do this so I can handle plugins nicely (new operations added to the image processing library at runtime) and so I can reduce the (currently *huge*) size of the wrapper. Can anyone suggest techniques for doing this? I'm thinking of using SWIG to generate a base Python class, then (by hand) subclassing that and doing the intercept myself in the derived class. Does that sound sensible? Is there a neater way? Could I inject some code into the right place in the SWIG-generated wrapper somehow? Many thanks for any ideas, John |