summaryrefslogtreecommitdiff
path: root/src/glibext
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2025-03-16 14:14:12 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2025-03-16 14:14:12 (GMT)
commitb18c64b69c8c048c640b5d9f6c45b1cfda605ae8 (patch)
tree70c293e0c6f5b39bf8b672c01480baf5625fb1c1 /src/glibext
parentc0c06b9e1cbb760b661a7adf4163cc6ba19828b3 (diff)
Update some core definitions for local GObjects.
Diffstat (limited to 'src/glibext')
-rw-r--r--src/glibext/helpers.h28
-rw-r--r--src/glibext/objhole-int.h30
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); \
})