[Bug 27204] New: Codegen erroneously uses enums' value-prefix as the name for the C++ enum

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Fri Mar 19 20:08:48 CET 2010


http://bugs.freedesktop.org/show_bug.cgi?id=27204

           Summary: Codegen erroneously uses enums' value-prefix as the name
                    for the C++ enum
           Product: Telepathy
           Version: git master
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: medium
         Component: tp-qt4
        AssignedTo: telepathy-bugs at lists.freedesktop.org
        ReportedBy: will.thompson at collabora.co.uk


So, I'm designing types to represent affiliations to PubSub nodes. This is what
I want in half-C++-half-DBus:

struct Affiliation {
  QString jid;
  AffiliationType affiliation;
};

enum AffiliationType {
  AffiliationOwner,
  AffiliationPublisher,
  AffiliationPublishOnly,
  ...
};

So I wrote this spec. XML:

    <tp:struct name="Affiliation">
      <tp:member name="JID" type="s"/>
      <tp:member name="Type" type="u" tp:type="Affiliation_Type"/>
    </tp:struct>

    <tp:enum name="Affiliation_Type"
             type="u"
             value-prefix="Affiliation">
      <tp:enumvalue suffix="Owner" value="0"/>
      <tp:enumvalue suffix="Publisher" value="1"/>
      <tp:enumvalue suffix="Publish_Only" value="2"/>
      <!-- ... -->
    </tp:enum>

and was horrified to discover that the code generator named the C++ enum
'Affiliation', which of course collides with the name of the struct.

This turns out to be because tpqt4-constants-gen.py does this:

    def do_enum(self, enum):
        singular = enum.getAttribute('singular') or \
                   enum.getAttribute('value-prefix') or \
                   enum.getAttribute('name')

I'm pretty sure that the use of value-prefix here shouldn't be there, given
that the whole point of it is to be able to use a different prefix for values
than the name of the type. Sadly we can't fix this without breaking the tp-qt4
API, so I guess I'm about to become the first person to use this
newly-discovered 'singular' attribute.


-- 
Configure bugmail: http://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the telepathy-bugs mailing list