Package: gir1.2-harfbuzz-0.0
Followup-For: Bug #1035669
X-Debbugs-Cc: abou.almonta...@sfr.fr
Control: tags -1 patch

Dear Maintainer and Abou,

The attached patch allows me to serialize GIR XML from the HarfBuzz-0.0.typelib
file contained in the resulting gir1.2-harfbuzz-0.0 package.

For more extensive details, please read the patch description; in short, it
removes a C typecast that appears to mislead the gobject build process into
treating the 'HB_LANGUAGE_INVALID' constant (value: zero) as an interface,
instead of a basic (and serializable) integer type.

Please be somewhat skeptical of the patch; I don't know whether it is the
best place for a fix, and it would benefit from awareness and discussion
upstream.  I think it helps identify the approximate area in which the problem
occurs, and my hope is that that is helpful at least.

Regards,
James
Description: Remove typecast from HB_LANGUAGE_INVALID definition
Author: James Addison <j...@jp-hosting.net>

The GObject Introspection tooling identifies the HB_LANGUAGE_INVALID
constant #define'd in hb-common.h as an interface[1] type, due to the
use of a C typecast to a struct type.

Subsequently, attempts to serialize the binary typelib database that
contains the type entry for HB_LANGUAGE_INVALID into an XML format
will fail during serialization[2].

In practice, the value is a constant used for direct comparison
purposes (as is evident in test cases that use '==' comparisons
between NULL and HB_LANGUAGE_INVALID).  Removing the typecast
and annotating it explicitly as a constant[3] value should make that
clearer and enable serialization to XML.

(the annotation is not strictly necessary, but makes it clearer that
the change is intentional and part of the API for the library)

[1] - 
https://gitlab.gnome.org/GNOME/gobject-introspection/-/blob/37bde613a7cb77e7399dafb25731e13208f0ae0b/girepository/gitypes.h#L410

[2] - 
https://gitlab.gnome.org/GNOME/gobject-introspection/-/blob/37bde613a7cb77e7399dafb25731e13208f0ae0b/girepository/girwriter.c#L784

[3] - https://gi.readthedocs.io/en/latest/annotations/giannotations.html

---
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1035669
Last-Update: 2023-06-04

--- harfbuzz-6.0.0+dfsg.orig/src/hb-common.h
+++ harfbuzz-6.0.0+dfsg/src/hb-common.h
@@ -315,13 +315,13 @@ HB_EXTERN const char *
 hb_language_to_string (hb_language_t language);
 
 /**
- * HB_LANGUAGE_INVALID:
+ * HB_LANGUAGE_INVALID: (value 0)
  *
  * An unset #hb_language_t.
  *
  * Since: 0.6.0
  */
-#define HB_LANGUAGE_INVALID ((hb_language_t) 0)
+#define HB_LANGUAGE_INVALID 0
 
 HB_EXTERN hb_language_t
 hb_language_get_default (void);

Reply via email to