[C++-sig] BPL and Py_Clear()
Niall Douglas
s_sourceforge at nedprod.com
Mon Jun 13 02:40:38 CEST 2005
On 12 Jun 2005 at 15:25, David Abrahams wrote:
> > As it turned out, pyste already supported auto_ptr. And it also
> > seems that BPL treats auto_ptr quite sensibly, so it "just works".
> > Wish I had known as it would have saved me a day's work :(
>
> You could have taken my word for it :)
Unfortunately Dave what's easy to you is not so easy for the rest of
us mere mortals. You have previously told me to do things which I am
sure are very easy for you, but took me days of head scratching.
Hence you see my hesitation!
> > My current problem is when running through virtual function wrappers
> > in that call_method<> tries converting an unsigned int * to an
> > unsigned int which I don't want. I tried putting ptr() round it like
> > this:
> >
> > void setData(FX::FXColor* p0, FX::FXuint p1) {
> > call_method< void >(py_self, "setData", ptr(p0), p1);
> > }
> >
> > (here FXColor is a typedef for unsigned int)
> >
> > ... but BPL won't take pointers to integral types in ptr(), and thus
> > I can't see how to pass the pointer as-is.
> >
> >
> > Why doesn't BPL's ptr() accept pointers to integral types?
>
> Think about how you would implement such a thing. What would a
> an overriden virtual function written in Python see?
A single item of whatever type eg; long * would mean the python code
sees a python integer.
Sure, it's not very useful to the python code itself. However, the
python code could go call some C which produces an iterable list from
the pointer which saves having to pack and unpack such a list through
each and every virtual function invocation.
Cheers,
Niall
More information about the Cplusplus-sig
mailing list