After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 729762 - gdbus-codegen should support enums extention xml
gdbus-codegen should support enums extention xml
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: gdbus
unspecified
Other Linux
: Normal normal
: ---
Assigned To: David Zeuthen (not reading bugmail)
gtkdev
Depends on:
Blocks:
 
 
Reported: 2014-05-08 01:59 UTC by Xavier Claessens
Modified: 2018-05-24 16:30 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gdbus-codegen: Add support for enums (5.93 KB, patch)
2014-05-10 15:38 UTC, Xavier Claessens
none Details | Review

Description Xavier Claessens 2014-05-08 01:59:54 UTC
In telepathy spec we added extra enum fields in the dbus xml for generating enums.

For example
    <tp:enum name="Foo_Status" type="u">
      <tp:enumvalue suffix="Online" value="0" />
      <tp:enumvalue suffix="Offline" value="1" />
    </tp:enum>

generates in the .h

typedef enum {
    TP_FOO_STATUS_ONLINE = 0,
    TP_FOO_STATUS_OFFLINE = 1,
} TpFooStatus;
#define TP_NUM_FOO_STATUS (1+1)

Using xml namespace like that make it ignored from other parsers. Of course dbus-glib would use another ns, like gio:enum. That helps making sense for some "u" dbus types.
Comment 1 Xavier Claessens 2014-05-10 15:38:32 UTC
Created attachment 276286 [details] [review]
gdbus-codegen: Add support for enums
Comment 2 Xavier Claessens 2014-05-10 15:39:04 UTC
I'm not sure how the docbook stuff works, but that's a first step.
Comment 3 David Zeuthen (not reading bugmail) 2014-05-10 18:39:39 UTC
The gdbus-codegen(1) man page needs a patch too (including examples). Without it, it's hard to understand how this feature works by just looking at your patch... for example, what annotation do I use to say that the third parameter of the Frobnicate() method should use the enum? I would actually suggest writing the man page patch first since it will define exactly what needs to be done.

Drive-by comments:

 - you need to register the generated enum with the GLib type system
  - IOW, e.g. it needs a GType
  - it needs to be possible to generate both enum and flag types.
 - we should be using "glib:" namespace instead of "gio:"
 - this GType should be used instead G_TYPE_UINT/G_TYPE_INT
 - we should allow using enums in place of type 'i' and 'u'
   - why also 'i'?
     - because existing code using 'i' might want to move to use this.

So, I guess, lots of work remaining!
Comment 4 Xavier Claessens 2014-05-10 22:39:49 UTC
Yep, still more work needed indeed. But you're OK with the general idea so I'll try to find time to continue :D

As you know we ported telepathy to GDBus, so I'm looking at what can be moved down to gdbus-codegen to replace tp-glib's older codegen.
Comment 5 GNOME Infrastructure Team 2018-05-24 16:30:24 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/869.