gir
gir copied to clipboard
GString related signature generation needs extra Option?
In the GStreamer MPEGTS library is a function:
GST_MPEGTS_API
gboolean gst_mpegts_descriptor_parse_dvb_short_event (const GstMpegtsDescriptor *descriptor,
gchar **language_code,
gchar **event_name,
gchar **text);
when gir is applied to the GstMpegts-1.0.gir file it generates a method in Descriptor
with signature:
parse_dvb_short_event(&self) -> Option<(GString, GString, GString>
There are though situations in which gboolean gst_mpegts_descriptor_parse_dvb_short_event
does not set event_name
and text
but instead leaves them null. This leads to a fail of is_null
in the GString
constructor which leads to a panic. Experiment indicates that the signature:
parse_dvb_short_event(&self) -> Option<(GString, Option<GString>, Option<GString>)>
solves all the problems I see in this situation. I guess consistency ought to lead to:
parse_dvb_short_event(&self) -> Option<(Option<GString>, Option<GString>, Option<GString>)>
so should signatures where there is a gchar*
out parameter leading to a GString
be Option<GString>
instead?
It's missing annotations in the C code: the nullable
annotation should be applied to the ones that can return NULL
, the not nullable
for the others. (And the current allow-none
annotation should become the non-deprecated optional
)
And then gir needs to be extended to actually handle this situation.
I'll have a look at doing the necessary annotation on the GStreamer MPEG-TS library, there are other GStreamer libraries already annotated to use as examples.