Skip to content

build-aux,codegen: generate GIR compat helpers for arrays of structs

The original methods in libqmi-glib used GArrays of structs when it was required to return a collection of complex items. Some of these arrays of structs were so complex that contained inner arrays of other structs.

Using these methods from C was no problem, but the automatic language binding support given by GObject Introspection isn't capable of using such complex arrays of structs.

The simplest way forward is to switch those GArrays into GPtrArrays, so that we provide arrays of pointers to structs, instead of arrays of structs. This approach is fully supported right now by GIR, and doesn't give any additional problem.

The new GIR compat method introduced are all suffixed with '_gir' in their names, and renamed to the original method name for the language binding. The original method names are explicitly flagged to be skipped by the bindings.

E.g. the C method qmi_indication_uim_refresh_output_get_event() gets a new qmi_indication_uim_refresh_output_get_event_gir() compat method to be used by the bindings, and it's renamed to get_event() (without the _gir suffix) in the binding.

If the structs contained other arrays of structs, new struct types using GPtrArray are also introduced, renamed with the 'Gir' suffix. E.g. the QmiMessageDmsListStoredImagesOutputListImage struct contains a GArray of QmiMessageDmsListStoredImagesOutputListImageSublistSublistElement elements, while the new QmiMessageDmsListStoredImagesOutputListImageGir struct contains a GPtrArray of the same type of elements.

The use of GArrays and GPtrArrays in APIs is really not recommended by GIR, but in our case they're always transfer-none and so there is no much risk in binding getting that wrong. Whenever we rework these APIs completely, we can think on making sure we provide a single set of methods to be used both in C and bindings, and avoiding GArrays and GPtrArrays at the same time. This change was not done right now in order to keep the change as minimum as possible (e.g. the methods using GArrays of simple structs or GArrays of strings or bytes were not changed to have GIR compat methods).

Fixes #83 (closed)

Merge request reports