Fw: [C++-sig] Pyste and STL types
Nicodemus
nicodemus at globalite.com.br
Wed Mar 19 02:13:19 CET 2003
David Abrahams wrote:
>Nicodemus <nicodemus at globalite.com.br> writes:
>
>
>
>>This currently fails, apparently because of an internal mechanism of
>>Boost.Python involving polimorphism. From what I gather from the error
>>message, Boost.Python tries to derive from Test to check for
>>polimorphic behaviour, and unions can't be subclassed. So, a possible
>>solution would be to specialize a class_ to take in account the
>>details of a union (lack of polimorphism, no derivation):
>>
>> union_<Test>("Test")
>> .def_readwrite("d", &Test::d)
>> .def_readwrite("i", &Test::i) ;
>>
>>
>
>I just want to point out again that I don't think this is _usually_
>the best way to map a union to Python. For any union that could be
>used effectively from Python there has to be information somewhere
>saying which field is active. When converting the union to Python, it
>should use the information to convert the appropriate field to Python
>instead. When converting from python, it should set the information
>up based on the type of the Python object.
>
>
What do you mean by "active field"? I ask because my knowledge of unions
is limited.
More information about the Cplusplus-sig
mailing list