[glib/wip/private-rework-3: 10/15] Add G_PRIVATE_OFFSET
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/private-rework-3: 10/15] Add G_PRIVATE_OFFSET
- Date: Wed, 19 Jun 2013 19:50:24 +0000 (UTC)
commit 6a461b8172b689c5b920afd0bbd923028141f7f5
Author: Emmanuele Bassi <ebassi gnome org>
Date: Wed Jun 19 20:41:02 2013 +0100
Add G_PRIVATE_OFFSET
A macro that evaluates to the offset of a field inside an instance
private data structure.
https://bugzilla.gnome.org/show_bug.cgi?id=700035
gobject/gtype.h | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/gobject/gtype.h b/gobject/gtype.h
index c275740..c21936d 100644
--- a/gobject/gtype.h
+++ b/gobject/gtype.h
@@ -1582,6 +1582,23 @@ guint g_type_get_type_registration_serial (void);
g_type_add_instance_private (g_define_type_id, sizeof (TypeName##Private)); \
}
+/**
+ * G_PRIVATE_OFFSET:
+ * @TypeName: the name of the type in CamelCase
+ * @field: the name of the field in the private data structure
+ *
+ * Evaluates to the offset of the @field inside the instance private data
+ * structure for @TypeName.
+ *
+ * Note that this macro can only be used together with the G_DEFINE_TYPE_*
+ * and G_ADD_PRIVATE() macros, since it depends on variable names from
+ * those macros.
+ *
+ * Since: 2.38
+ */
+#define G_PRIVATE_OFFSET(TypeName, field) \
+ (TypeName##_private_offset + (G_STRUCT_OFFSET (TypeName##Private, field)))
+
#define _G_DEFINE_TYPE_EXTENDED_BEGIN(TypeName, type_name, TYPE_PARENT, flags) \
\
static void type_name##_init (TypeName *self); \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]