[C++-sig] Re: Boost... Exception safe (can I turn it off?), and controlled object construction?

Adrian Bentley adruab at hotmail.com
Wed Mar 3 03:55:08 CET 2004


Sorry about being somewhat unclear.

In terms of what I wanted to do with exceptions, I was under the impression
that the boost python code boiled down to using the C Python API (which
allows you to set a python global exception handler... I think).  There are
alternative ways I can wrap the interpreting calls to prevent exceptions
from being thrown.  However, I want to compile the code without exceptions
turned on, which would prevent me from being able to use try catch blocks.

In terms of my object madness:
> > //In pyobject file class BaseObject { void *data; //where the
> > variables will all go //All it's stuff in here, some which requires
> > manual construction and such
> > };
> >
> > Pythonclass : BaseObject { //add stuff here
> > }
> >
> > //in actual program class Py_wrapper : public BaseObject { PyObject
> > *pyo; //gotten from embedded python
> >
> >     //forward variable requests to python object etc....
> > };
> >
> > // End example
>
> That doesn't illustrate very much, but I don't know why anyone would
> use PyObject* when they could use boost::python::object.

Heh, yeah, I'm not sure why I spontaneously forgot to write
boost::python::object instead.

> > Ok, now that you all know I'm crazy the reason why I want to do this
> > is that the base object is designed to communicate a certain way with
> > things it's attached to, which probably wouldn't cooperate with the
> > way python works
>
> Maybe you should find out for sure before deciding.
>
> > , so I need to manually construct the base object (also not sure how
> > to do this in boost python).
>
> I've no clue what you're asking about, sorry.

To elaborate, and clarify (since I don't seem to be very good at that):

> > Basically what I'd like is to have python override things like a class
> > normally would, and track it in my object system.  I'm kind of
> > doubting there's a way to do that, hence then extra layer of
> > indirection py_wrapper (which should work).

Clarification: I don't imagine there is any way to "cast" the python object
to a BaseObject * or the like, is there?  I'd imagine there wouldn't be,
given that python must use a method of inheritance incompatible with C++.
In the case that I would NOT be able to cast as such, if I wanted to
register any python derived BaseObjects with my system, I'd have to use the
wrapping class with the object inside.

Thanks for the pointers (and being patient with me :P),
Adruab > Adrian Bentley




More information about the Cplusplus-sig mailing list