From b18c64b69c8c048c640b5d9f6c45b1cfda605ae8 Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Sun, 16 Mar 2025 15:14:12 +0100
Subject: Update some core definitions for local GObjects.

---
 src/glibext/helpers.h     | 28 ++++++++++++++++++++++++++++
 src/glibext/objhole-int.h | 30 +++++++++++++++---------------
 2 files changed, 43 insertions(+), 15 deletions(-)

diff --git a/src/glibext/helpers.h b/src/glibext/helpers.h
index cfcc85b..6176245 100644
--- a/src/glibext/helpers.h
+++ b/src/glibext/helpers.h
@@ -29,6 +29,9 @@
 #include <glib-object.h>
 
 
+#include "../common/compiler.h"
+
+
 
 /**
  * Les définitions issues de <glib-2.80>/gobject/gtype.h fournissent des macros
@@ -118,6 +121,31 @@
     }
 
 
+/**
+ * Définition sous condition d'une inclusion d'interface. Cette inclusion se réalise
+ * lorsque la fonction d'initialisation renseignée est définie.
+ *
+ * Cette version étendue de la macro G_IMPLEMENT_INTERFACE d'origine est principalement
+ * pour les raffinements d'objets en forme graphique.
+ */
+
+#define G_IMPLEMENT_INTERFACE_IF_SYM(iface_tp_getter, iface_init)                           \
+    do                                                                                      \
+    {                                                                                       \
+        extern GType iface_tp_getter(void) __weak;                                          \
+        extern void iface_init(GTypeInterface *, gpointer) __weak;                          \
+        if (&iface_tp_getter != NULL && &iface_init != NULL)                                \
+        {                                                                                   \
+            GType iface_type = iface_tp_getter();                                           \
+            const GInterfaceInfo implementation_info = {                                    \
+                (GInterfaceInitFunc)(void (*)(void))iface_init, NULL, NULL                  \
+            };                                                                              \
+            g_type_add_interface_static(g_define_type_id, iface_type, &implementation_info);\
+        }                                                                                   \
+    }                                                                                       \
+    while (0);
+
+
 
 /**
  * Les principales fonctions incrémentant ou réduisant le nombre de références
diff --git a/src/glibext/objhole-int.h b/src/glibext/objhole-int.h
index b4abf6f..aa8a1f8 100644
--- a/src/glibext/objhole-int.h
+++ b/src/glibext/objhole-int.h
@@ -142,23 +142,23 @@ struct _GThickObjectClass
 /* GLib 2.83.0 - cfa36f5e9 */
 #define GOBJECT_RESERVED_EXTRA_BITS 5
 
-#define GET_GOBJECT_EXTRA(obj, tp)                      \
-    ({                                                  \
-        BUILD_BUG_ON(sizeof(tp) > sizeof(guint));       \
-        tp *___result;                                  \
-        guint __val;                                    \
-        __val = g_thick_object_get_extra(obj);          \
-        ___result = (tp *)(guint []){ __val };          \
-        ___result;                                      \
+#define GET_GOBJECT_EXTRA(obj, tp)                              \
+    ({                                                          \
+        BUILD_BUG_ON(sizeof(tp) > sizeof(guint));               \
+        tp ___result;                                           \
+        guint __val;                                            \
+        __val = g_thick_object_get_extra(G_THICK_OBJECT(obj));  \
+        ___result = *(tp *)(guint []){ __val };                 \
+        ___result;                                              \
     })
 
-#define SET_GOBJECT_EXTRA(obj, tp, data)                \
-    ({                                                  \
-        BUILD_BUG_ON(sizeof(tp) > sizeof(guint));       \
-        BUILD_BUG_ON(sizeof(data) > sizeof(guint *));   \
-        guint __val;                                    \
-        __val = *(guint *)data;                         \
-        g_thick_object_set_extra(obj, __val);           \
+#define SET_GOBJECT_EXTRA(obj, tp, data)                        \
+    ({                                                          \
+        BUILD_BUG_ON(sizeof(tp) > sizeof(guint));               \
+        BUILD_BUG_ON(sizeof(data) > sizeof(guint *));           \
+        guint __val;                                            \
+        __val = *(guint *)data;                                 \
+        g_thick_object_set_extra(G_THICK_OBJECT(obj), __val);   \
     })
 
 
-- 
cgit v0.11.2-87-g4458