[C++-sig] pyplusplus is alive :-)
s_sourceforge at nedprod.com
Fri Mar 31 15:07:57 CEST 2006
On 29 Mar 2006 at 23:55, Roman Yakovenko wrote:
> Problem number 1. pyplusplus generates invalid code mainly because of
> unions that have unnamed struct inside.
> struct FXAPI Header
> FXuint length;
> char guid;
> union Flags
> FXuint hasItemIdList : 1;
> FXuint pointsToFileOrDir : 1;
> FXuint hasDescription : 1;
> FXuint raw;
> } flags;
> I am almost sure, that it can not be exported to Python.
> First of all I am not sure how I should export unions? What do you
> expect to get?
The above is simply a technique for mapping bits to the same place as
an int. Unnamed structs simply push their members into the enclosing
namespace, therefore you'd access the above as
header.flags.pointsToFileOrDir. Right now, pyplusplus is putting a
$_x after flags because gccxml gives unnamed structs an internal
name. To generate correct code, all pyplusplus needs to do is ignore
any unnamed structs it sees.
> According to this http://lists.boost.org/Archives/boost/2002/11/39157.php
> it will not be supported.
> So I propose you to change union to struct, or to write some hand written code
> that will export it. May be I could learn from it and will implement automatic
> solution. But I don't promise.
Thing is, we're not exporting a union. We're exporting the *members*
of a union. Boost.Python does not need to know that the members refer
to the same memory space - it just needs to know they are there like
any other normal members of a struct.
Worst case scenario - let pyplusplus only support accessing the first
member of a union only.
> Second and I think very important problem is unnamed structs within union.
> In order to export bit fields pyplusplus creates wrapper that will
> expose set\get
> properties to the fields. In this case it do generates invalid code, because of
> unnamed struct.
> What do you propose?
pyplusplus should specifically filter out any unnamed structs it
encounters and pretend they're not there. This will generate correct
More information about the Cplusplus-sig