From: Patrick A. <pa...@ic...> - 2013-12-24 18:23:18
|
Hello David, Thank you so much for your extremely detailed code example. I’ll need a few days to wrap (pun intended) my head around it, but I’ll report back my findings once I do. Patrick On Dec 24, 2013, at 12:21 PM, David Froger <dav...@in...> wrote: > Here is an example attached. > > Hope it helps! > > Quoting David Froger (2013-12-24 11:37:09) >> Hi Patrick, >> >> I did something similar using capsule [1], I'll went a examle soon. >> >> David >> >> [1] http://docs.python.org/2/c-api/capsule.html >> >> >> Quoting Patrick Abeya (2013-12-19 20:03:19) >>> Hello there >>> >>> I’m trying to make a C++ sdk available via Python using SWIG. This sdk has a >>> crazy and illogical exception hierarchy, which I would like to fix so that it >>> looks sane from Python. The idea is that all of the exceptions that are thrown >>> by the sdk will be converted to my own exceptions. >>> >>> At this point I have 2 options, either create those exceptions in Python or >>> create them in C++ and create wrappers for them. I’m under the impression that >>> it makes more sense to create them in C++ since it will make them easier to >>> deal with in the %exception block. >>> >>> So I went ahead and did the following: >>> >>> %exception >>> { >>> try >>> { >>> $action >>> } >>> catch (AnException &e) >>> { >>> AnotherException *ecopy = new AnotherException(e.what()); >>> PyObject *err = SWIG_NewPointerObj(ecopy, SWIGTYPE_p_AnotherException, >>> 1); >>> PyErr_SetObject(SWIG_Python_ExceptionType(SWIGTYPE_p_AnotherException), >>> err); >>> SWIG_fail; >>> >>> } >>> } >>> >>> My problem is that SWIGTYPE_p_AnotherException is defined in a different >>> module, so it is obviously not available from the current wrapper. I tried >>> >>> %import (module="anotherModule") “AnotherException.h" >>> >>> but that did not work. There was a suggestion in the doc of using >>> >>> -DSWIG_TYPE_TABLE=myproject >>> >>> but I couldn’t see how this would help and it did not work indeed. Any ideas? >> >> ------------------------------------------------------------------------------ >> Rapidly troubleshoot problems before they affect your business. Most IT >> organizations don't have a clear picture of how application performance >> affects their revenue. With AppDynamics, you get 100% visibility into your >> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! >> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk >> _______________________________________________ >> Swig-user mailing list >> Swi...@li... >> https://lists.sourceforge.net/lists/listinfo/swig-user > <exceptions_in_capsule.tar.gz>------------------------------------------------------------------------------ > Rapidly troubleshoot problems before they affect your business. Most IT > organizations don't have a clear picture of how application performance > affects their revenue. With AppDynamics, you get 100% visibility into your > Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! > http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk_______________________________________________ > Swig-user mailing list > Swi...@li... > https://lists.sourceforge.net/lists/listinfo/swig-user |