[C++-sig] shared_ptr converters
David Abrahams
dave at boost-consulting.com
Tue Apr 22 00:22:08 CEST 2003
Nicodemus <nicodemus at globalite.com.br> writes:
> David Abrahams wrote:
>
>>Nicodemus <nicodemus at globalite.com.br> writes:
>>
>>
>>>To resume, pyste is generating the following code when the user requests
>>>shared_ptr support for a class X:
>>>
>>> // Temporary code for smart pointers
>>> objects::class_value_wrapper<
>>> boost::shared_ptr< X >, objects::make_ptr_instance<
>>> X, objects::pointer_holder<
>>> boost::shared_ptr< X >, X >
>>> >
>>> >();
>>>
>>
>>Perhaps you'd like to contribute a nice wrapper function for this to
>>the Boost.Python codebase, e.g.:
>>
>> template <class P>
>> void register_ptr_to_python(P* = 0)
>> {
>> typedef pointee<P>::type X;
>> objects::class_value_wrapper<
>> P
>> , objects::make_ptr_instance<
>> X
>> , objects::pointer_holder<P,X>
>> >
>> >();
>> }
>>
>>??
>>
>
> Well, you already did all the work! ;)
Haha, gotcha! Still needs documentation and tests...
I just did the easy part.
> Attached are the needed changes to the current CVS:
> register_ptr_to_python.hpp should go to boost/python/converter, and a
> diff for boost/python.hpp. I tested in my example like so:
>
> class_< A, boost::noncopyable, A_Wrapper >("A");
> register_ptr_to_python< boost::shared_ptr<A> >();
>
> and it seems to work fine.
>
Thanks for testing. When you post a doc patch, I'll commit the whole wad ;-)
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
More information about the Cplusplus-sig
mailing list