Setting throw annotation when there are not throw specification in source code
Hi,
I've used Py++ on previous project, which worked out Ok, but was a bit dissapointed with size of resulting compiled binding as well as compile time. I'm quite thrilled with possibility to avoid these problems with PyBindGen + (py)gccxml, however struggling a bit at the moment.
One of the problems I have is that exception translation works fine if there is an exception specification in C++ header, however when there is no specification, then exception is not translated, not caught and ultimately ends up in terminate()! I understand that if it is not known what exception types can be thrown out of a function it is not easy to translate them, however would expect at least std::exception being handled in this case. Anyways, I tried to add pre_scan_hook to add 'throw' annotation like this:
if isinstance(
or isinstance( pygccxml_
where exc is defined right after call to parse_init in a following way:
exc = module_
This however had no effect -- I've got a warning during generation, and exception still not translated. The warning reads like this:
Another thing I've tried is hacking gccxmlparser.py by adding right before clause where this warning raised (line 1703):
With this hack a generated code fails to compile with "error: ‘retval’ was not declared in this scope"
Is there any way to enable exception translation without adding exception specification to source code?
Another problem I'm facing is support for boost::shared_ptr. I've seen another question where a partial solution involving object copying is introduced. Unfortunately it is not an option for me, even if I was willing to sacrifice performance, as many classes are noncopyable by design (copy ctor is private). I'm willing to try to implement it myself (and contribute patch) if it is not too difficult. Would you be able to provide some guidance? I see two ways -- hacking it in by somehow gaining access to boost::shared_ptr counter (not nice and may break in future if shared_ptr redesigned), or ideally make Python object hold a reference to C++ object via shared_ptr, not raw pointer as I believe current implementation does. Not sure how much of a redesign is required to implement it properly.
Kind regards,
Kirill Lapshin
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- PyBindGen Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask Kirill Lapshin for more information if necessary.