[C++-sig] Re: Custom by value type to python type conversion

Niall Douglas s_sourceforge at nedprod.com
Fri Nov 7 04:05:59 CET 2003


On 6 Nov 2003 at 16:15, Ralf W. Grosse-Kunstleve wrote:

> > 	class_< FX::MappedData >("FXMappedData")
> > 		.def_readwrite("name", &FX::MappedData::name);
> 
> Oh, this looks like a very well known problem. You have to use
> .add_property instead. E.g. (untested):
>         typedef return_value_policy<return_by_value> rbv;
>         typedef default_call_policies dcp;
> 
>         .add_property("name", make_getter(&FX::MappedData::name,
>         rbv()),
>                               make_setter(&FX::MappedData::name,
>                               dcp()))
> 
> Adjust the policies as necessary.

If it's so well known, then why the hell isn't it in the FAQ so 
everyone who uses BPL doesn't keep making the same mistake again & 
again???

(I am grateful for the info - thanks - it just annoys me when this 
happens, and it's not been the first time either).

Bruno - looks like another change to pyste will be needed!

Cheers,
Niall




-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 208 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20031107/e27c2c14/attachment.pgp>


More information about the Cplusplus-sig mailing list