Most IFEX data types translate well to D-Bus. We can follow the generic principles of Mapping primitive types. In a few cases we need to follow a widening or minor-difference coercion approach (see linked chapter for details).
…as defined in D-Bus Specification
Name | Meaning |
---|---|
BYTE | Unsigned 8-bit integer |
BOOLEAN | Boolean value: 0 is false, 1 is true |
INT16 | Signed (two’s complement) 16-bit integer |
UINT16 | Unsigned 16-bit integer |
INT32 | Signed (two’s complement) 32-bit integer |
UINT32 | Unsigned 32-bit integer |
INT64 | Signed (two’s complement) 64-bit integer |
UINT64 | Unsigned 64-bit integer |
DOUBLE | IEEE 754 double-precision floating point |
UNIX_FD | 32-bit index into array of file descriptors |
STRING | UTF-8 string (must be valid UTF-8). Must be nul terminated and contain no other nul bytes. |
Name | Meaning |
---|---|
OBJECT_PATH | Name of an object instance |
SIGNATURE | A type signature |
VARIANT | Variant type (the type of the value is part of the value itself) |
DICT | Key-value mapping |
Direction of IFEX Core IDL to D-Bus (represented by its introspection XML format):
uint8
maps to BYTE
and also int8 maps to BYTE
(coercion)string
, boolean
, int/uint of 16/32/64 bit varieties, as well as double
, have exact equivalences in D-Bus.float
must translate to double
(widening)map
translates to a D-Bus DICT
(see Comments below)set
can be transferred on (any) protocol as simply an array. The enforcement of the set semantics happens only on the side of the server and/or client implementation.variant
translates to D-Bus VARIANT
opaque
type translates to an array of BYTE
Translating an existing D-Bus interface to IFEX Core IDL:
Follow the reverse of the above, with these additional comments:
As always, types that do not exist in the source (D-Bus) will naturally not appear in the translation (IFEX). There could be some special situation where the use of additional metadata (a Layer), certain objects could be given more semantic meaning, for example “this array is actually is a set”, but IFEX users will have to propose a solution if the need for this arises.
UNIX_FD
is simply a 32-bit (unsigned) integer with special meaning. It is a low-level mechanism which also only makes sense within a single local UNIX system. Therefore, if an existing D-Bus interface is going to be translated to an IFEX description, it might be worthwhile to redesign the interface description to not use UNIX_FD (or in IFEX an equivalent integer). A shared file between server/client/peers might in theory be an “optimized” low-level solution in a particular translation of an IFEX interface, but that comes into play in the opposite direction: IFEX to -> D-Bus mapping. The type that is actually being transferred would be better described in the interface description using a higher-level type description, or at minimum as an array of bytes. If someone has a D-Bus interface that transfers UNIX_FDs, and the interface is to be translated into IFEX core IDL - please at that time analyze how you think it would best be treated. Ultimately, it could fall back to “just an integer” but that has limited use if the IFEX description is moved to a different environment.The D-Bus specification requires the key in a dict to be a basic type only. IFEX core IDL is unlikely to define this limitation, and it might be unsupported to translate IFEX maps that use non-primitive keys into D-Bus. On the other hand, it ought to be possible to “misuse” D-Bus by transferring it as an array of key-value structs, which has no such limitation (and on the wire protocol, an array of structs is basically how a dict is transferred in all cases). It would be required to generate comments in the D-Bus interface description to clarify this fact, and/or to create both sides of a server/client communication from the same generator to ensure that the map behavior can reappear in the code that uses it, after it has been transferred over as an “array”.
The D-Bus specification also describes some additional type codes but they are used only for the wire protocol, or seem generally not yet refined into a complete concept. (If something in D-Bus specification is missing and needs to be added to this document, please propose a change)
Method
s map to D-Bus method
.Properties
map to D-Bus properties. See the specification for some some particular conventions to follow.Event
s map to D-Bus Signal
concept. The behavior matches IFEX description (like a method call but without a reply).We ought to be able to convert IFEX Errors
into a D-Bus error in the implementation but it seems to be not described in the XML format
(TODO: investigate further)
D-Bus describes an Error message type that can be sent in different situations, but usually as a reply to a method call.
IFEX Error
s concept also defines errors individually for each method. There are few rules expressed in the D-Bus specification but this sentence seems most significant:
"_An ERROR may have any arguments, but if the first argument is a STRING, it must be an error message. The error message may be logged or shown to the user in some way._"
This means that if the IFEX interface has a string as its first argument, we ought to establish whether it is an error message and shall be treated as such in the D-Bus representation of the interface (it could be a safe assumption to make, but alternatively some user interaction is appropriate, and/or to require this to be a parameter to the code generator).
TODO: Is there an XML representation of the error, or not? (Cannot determine this from the D-Bus specification).