[C++-sig] Pyplusplus - anonymous union

Roman Yakovenko roman.yakovenko at gmail.com
Thu Jul 20 19:21:14 CEST 2006

On 7/20/06, Jan Langer <jan at langernetz.de> wrote:
> Hello,
> I'm using pyplusplus to generate python-bindings for a C API.

mb = module_builder_t( ... )
#The code in subversion does it for you
mb.classes( name='' ).exclude()

Next code is copied from Python-OGRE bindings:

def fix_unnamed_classes (mb):
    ogre_ns = mb.namespace  ('Ogre')
    print len (ogre_ns.classes ('')) / 2

    for unnamed_cls in ogre_ns.classes( '' ):
        named_parent = unnamed_cls.parent
        if not named_parent.name:
            named_parent = named_parent.parent

        for mvar in unnamed_cls.public_members:
            if not mvar.name:

            if declarations.is_array (mvar.type):
                template = '''def_readonly("%(mvar)s",
                template = '''def_readwrite("%(mvar)s",
            named_parent.add_code( template % dict( mvar=mvar.name,
parent=named_parent.name ) )

This should work.

P.S. You project is 3rd project that need this feature, may be this is a time
to implement it :-)

Roman Yakovenko
C++ Python language binding

More information about the Cplusplus-sig mailing list