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
This commit is contained in:
Emmanuele Bassi 2013-06-19 20:41:02 +01:00
parent d3dec6ec80
commit d91d114a54

View File

@ -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); \