GNOME Bugzilla – Bug 729762
gdbus-codegen should support enums extention xml
Last modified: 2018-05-24 16:30:24 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.
Created attachment 276286 [details] [review] gdbus-codegen: Add support for enums
I'm not sure how the docbook stuff works, but that's a first step.
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!
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.
-- 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.