GNOME Bugzilla – Bug 662693
New ValueName substitution in glib-mkenums
Last modified: 2018-05-24 13:28:56 UTC
It would be great if glib-mkenums had a "ValueName" susbtitution, so that from the following example: typedef enum { PREFIX_THE_FIRST_VALUE = 1, PREFIX_ANOTHER_VALUE = 2, } PrefixTheXEnum; We could get "TheFirstValue" and "AnotherValue". It would be very handy to setup glib-mkenums to generate error type information with error domain registration in GDBus, something like: GQuark @enum_name@_quark (void) { static volatile gsize quark_volatile = 0; static const GDBusErrorEntry @enum_name@_entries[] = { { @VALUENAME@, "org.project.Foo.Bar.Error.@ValueName@"}, }; g_dbus_error_register_error_domain ("@enum_name@_quark", &quark_volatile, @enum_name@_entries, G_N_ELEMENTS (@enum_name@_entries)); return (GQuark) quark_volatile; } Note: this wouldn't be enough to get it useful for GDBusErrorEntry generations, as usually errors in DBus are given with the error domain, like "org.project.Foo.Bar.Error.Domain.@ValueName@", and the Domain part usually also comes from the enum name... that's another issue to handle.
Another, and probably better, option would be to make gdbus-codegen(1) generate error the domain ... maybe you'd specify errors in the introspection XML, maybe some other file, maybe on the command-line, I don't know. With this, we'd also have a chance to make sure the generated call-glue (e.g. foo_bar_call_xyz() and foo_bar_call_xyz_sync() wrappers) call the foo_bar_error_quark() method so the error domain is properly registered before transcoding the D-Bus error to a GError (cf. bug 662396)
-- 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/471.