changing the enum type
David Zeuthen
david at fubar.dk
Fri Feb 27 05:29:43 PST 2009
On Fri, 2009-02-27 at 11:04 +0000, Richard Hughes wrote:
> At the moment DeviceKit-power has the "wire" type of string for state.
> Internally, this is represented by:
>
> typedef enum {
> DKP_DEVICE_STATE_CHARGING,
> DKP_DEVICE_STATE_DISCHARGING,
> DKP_DEVICE_STATE_EMPTY,
> DKP_DEVICE_STATE_FULLY_CHARGED,
> DKP_DEVICE_STATE_UNKNOWN
> } DkpDeviceState;
>
> I'm intending to change the DBus interface so that I can use
> g_object_set and g_object_get internally without doing _to_string()
> _from_string() all over the code tree.
>
> As long as I document the enum values, this is okay, right?
Please hold off with this until we port DeviceKit-power to EggDBus/GBus
(or whatever it will end up being called).
With that binding you'd be able to declare enums (and flags and error
domains) directly in the introspection XML (which will be a real IDL
language at some point) like this
http://cgit.freedesktop.org/~david/eggdbus/tree/src/eggdbus/org.freedesktop.DBus.xml?id=0.3#n31
The C/GObject code generator will give you a registered GEnumType
http://people.freedesktop.org/~david/eggdbus-HEAD/eggdbus-eggdbusbus.html#EggDBusRequestNameReply
The Docbook doc generator will also do the right thing
http://people.freedesktop.org/~david/eggdbus-HEAD/eggdbus-interface-org.freedesktop.DBus.html#eggdbus-enum-RequestNameReply
with references in the IDL being properly rewritten in the method docs,
e.g.
http://cgit.freedesktop.org/~david/eggdbus/tree/src/eggdbus/org.freedesktop.DBus.xml?id=0.3#n101
will turn into
http://people.freedesktop.org/~david/eggdbus-HEAD/eggdbus-interface-org.freedesktop.DBus.html#eggdbus-method-org.freedesktop.DBus.RequestName
http://people.freedesktop.org/~david/eggdbus-HEAD/eggdbus-eggdbusbus.html#egg-dbus-bus-request-name-sync
David
More information about the devkit-devel
mailing list