[C++-sig] An issue with wrapping class trees (BPL V2)

David Abrahams david.abrahams at rcn.com
Tue May 28 22:48:02 CEST 2002


You haven't told Boost.Python that variable and symbol are derived from
basic, so it can't convert the first argument to the exposed __repr__
function to basic*.

You need to use bases<basic> in the class_ argument lists, or you need to
re-expose repr() separately for each derived class.

-Dave

----- Original Message -----
From: "Pearu Peterson" <pearu at cens.ioc.ee>
To: <c++-sig at python.org>
Sent: Tuesday, May 28, 2002 3:24 PM
Subject: [C++-sig] An issue with wrapping class trees (BPL V2)


>
> Hi David,
>
> On Tue, 28 May 2002, David Abrahams wrote:
>
> > ----- Original Message -----
> > From: "Pearu Peterson" <pearu at cens.ioc.ee>
> >
> > > Yes, I see it. However, currently my show stopper is how to insert
> > > wrapped classes into a class inheritance tree in a 'natural' way :-(.
> > > See the end of this message:
> > >
> > > http://mail.python.org/pipermail/c++-sig/2002-May/001058.html
> >
> > Can you send me a minimal, complete example which demonstrates the
problem
> > you're having?
>
> Sure, please find attached three files:
>
>   cltree.cpp, test_cltree.py, setup_cltree.py
>
> When I run
>
>   python setup_cltree.py build --build-platlib=.
>   # I am not using jam as you may notice ;-)
>   python test_cltree.py
>
> I get
>
> b= cltree.basic()
> s= <__main__.symbol object at 0x80fcd64>
> c= cltree.constant()
> v=
> Traceback (most recent call last):
>   File "test_cltree.py", line 36, in ?
>     print 'v=',v
> TypeError: bad argument type for built-in operation
>
>
> Expected behaviour would be the following output
>
> b= cltree.basic()
> s= <__main__.symbol object at 0x80fcd64>
> c= cltree.constant()
> v= cltree.wrapped_variable()
> ok
>
>
> If you look cltree.cpp then I am basically interested in exposing classes
> `basic' and `variable' to Python under the following conditions:
>
> 1) class `variable' is a subclass of `basic' also in Python
> 2) class `variable' is exposed to Python using `variable_wrapper' (so
that
>    I can re-define constructors)
>
> Classes `symbol' and `constant' are there only for testing, you can
> ignore them. In some sense, exposing `variable' is a combination of
> exposing `symbol' and `constant' so that different features
> (conditions (1) and (2), respectively) of the latter ones are combined in
> `variable'.
>
> There is another issue with the usage of boost::noncopyable (see
> comments in cltree.cpp) but that is not important to me at this moment.
>
> Pearu
>






More information about the Cplusplus-sig mailing list