[C++-sig] Re: Re: Boost.Python v2: reference-counting and user-friendly conversions

David Abrahams david.abrahams at rcn.com
Fri Jun 14 03:03:21 CEST 2002


From: "Dave Hawkes" <daveh at cadlink.com>
> "David Abrahams" <david.abrahams at rcn.com> wrote in message
> news:01ef01c21321$6c19bdb0$6601a8c0 at boostconsulting.com...
> > From: "Dave Hawkes" <daveh at cadlink.com>
> > >
> > > I would prefer just to rely on the type conversion provided by
handle<>
> > etc.
> > >
> > >     PyTypeObject* p
> > >     handle<>(type_handle(p)).get()
> > >
> > > If the handle type conversion can be verified at compile time then
fine,
> >
> > How do you think the conversion above works? There's a traits class
called
> > base_type_traits<>, specialized for PyTypeObject.
>
> I was thinking of just letting handle use the traits rather than call use
> them as well, which would possibly add unnecessary complexity.


OK.

> >
> > > if
> > > it can't then we will have to rely on run-time exceptions.
> >
> > How would you do it at run-time?
>
> I wasn't sure if we could make use of  PyType_IsSubtype or
> PyObject_IsSubclass in some cases.

Not without crashing in the cases when it's not a Python object pointer.

> Will handle<> and object be able to be used interchangeably then?

Not neccessarily in all cases. I still need convincing to see the
importance of this NULL business.

-Dave






More information about the Cplusplus-sig mailing list