Sorry, Roman, I really meant to send to the mailing list! :-)

---------- Forwarded message ----------
From: Gustavo Carneiro <gjcarneiro@gmail.com>
Date: 2008/10/15
Subject: instance attribute with anonymous enum type
To: Roman Yakovenko <roman.yakovenko@gmail.com>


Hello, I am hitting a problem in pygccxml regarding anonymous enums used as class member variables.

Something like this:

class SomeObject
{
public:
  
    enum {
        TYPE_FOO,
        TYPE_BAR,
    } type;
};

When I scan this, pygccxml tells me the attribute 'type' of 'SomeObject' is of type 'SomeObject'.  I happily try to generate code for this, and of course the generated code does not even compile:

[14/25] cxx: build/default/tests/foomodule2.cc -> build/default/tests/foomodule2_9.o
default/tests/foomodule2.cc: In function 'int _wrap_PySomeObject__set_type(PySomeObject*, PyObject*)':
default/tests/foomodule2.cc:6211: error: cannot convert 'SomeObject' to 'SomeObject::<anonymous enum>' in assignment
Build failed

It would be better if pygccxml reported the type as  "SomeObject::<anonymous enum>", like GCC does.  This way at least I will not be lead me to generate invalid code (I prefer no code at all than erroneous code).

This with pygccxml 0.9.5, gccxml 2008-04-20.

My work around for the moment is:

                real_type = type_traits.remove_declarated(member.type)
                if hasattr(real_type, 'name') and not real_type.name:
                    print >> sys.stderr, ">>>>>>>>>>>>>> skip anonymous type"
                    continue

Take care,

--
Gustavo J. A. M. Carneiro
INESC Porto, Telecommunications and Multimedia Unit
"The universe is always one step beyond logic." -- Frank Herbert




--
Gustavo J. A. M. Carneiro
INESC Porto, Telecommunications and Multimedia Unit
"The universe is always one step beyond logic." -- Frank Herbert