diff options
Diffstat (limited to 'gobject/gtype.h')
-rw-r--r-- | gobject/gtype.h | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/gobject/gtype.h b/gobject/gtype.h index a3a07c6a3..a4c777c56 100644 --- a/gobject/gtype.h +++ b/gobject/gtype.h @@ -638,7 +638,7 @@ struct _GTypeQuery * `your_type_get_instance_private()` function instead * Returns: (not nullable): a pointer to the private data structure */ -#define G_TYPE_INSTANCE_GET_PRIVATE(instance, g_type, c_type) ((c_type*) g_type_instance_get_private ((GTypeInstance*) (instance), (g_type))) +#define G_TYPE_INSTANCE_GET_PRIVATE(instance, g_type, c_type) ((c_type*) g_type_instance_get_private ((GTypeInstance*) (instance), (g_type))) GLIB_DEPRECATED_MACRO_IN_2_58_FOR(G_ADD_PRIVATE) /** * G_TYPE_CLASS_GET_PRIVATE: @@ -680,14 +680,17 @@ typedef enum /*< skip >*/ G_TYPE_DEBUG_SIGNALS = 1 << 1, G_TYPE_DEBUG_INSTANCE_COUNT = 1 << 2, G_TYPE_DEBUG_MASK = 0x07 -} GTypeDebugFlags; +} GTypeDebugFlags GLIB_DEPRECATED_TYPE_IN_2_36; /* --- prototypes --- */ +G_GNUC_BEGIN_IGNORE_DEPRECATIONS GLIB_DEPRECATED_IN_2_36 void g_type_init (void); GLIB_DEPRECATED_IN_2_36 void g_type_init_with_debug_flags (GTypeDebugFlags debug_flags); +G_GNUC_END_IGNORE_DEPRECATIONS + GLIB_AVAILABLE_IN_ALL const gchar * g_type_name (GType type); GLIB_AVAILABLE_IN_ALL @@ -1417,8 +1420,8 @@ guint g_type_get_type_registration_serial (void); * @OBJ_NAME: The bare name of the type, in all caps (like 'WIDGET') * @ParentName: the name of the parent type, in camel case (like GtkWidget) * - * A convenience macro for emitting the usual declarations in the header file for a type which will is intended - * to be subclassed. + * A convenience macro for emitting the usual declarations in the + * header file for a type which is intended to be subclassed. * * You might use it in a header as follows: * @@ -1627,6 +1630,11 @@ guint g_type_get_type_registration_serial (void); * Note that private structs added with this macros must have a struct * name of the form @TN Private. * + * The private instance data can be retrieved using the automatically generated + * getter function `t_n_get_instance_private()`. + * + * See also: G_ADD_PRIVATE() + * * Since: 2.38 */ #define G_DEFINE_TYPE_WITH_PRIVATE(TN, t_n, T_P) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, 0, G_ADD_PRIVATE (TN)) @@ -1691,6 +1699,7 @@ guint g_type_get_type_registration_serial (void); * gtk_gadget, * GTK_TYPE_WIDGET, * 0, + * G_ADD_PRIVATE (GtkGadget) * G_IMPLEMENT_INTERFACE (TYPE_GIZMO, * gtk_gadget_gizmo_init)); * ]| @@ -1699,11 +1708,18 @@ guint g_type_get_type_registration_serial (void); * static void gtk_gadget_init (GtkGadget *self); * static void gtk_gadget_class_init (GtkGadgetClass *klass); * static gpointer gtk_gadget_parent_class = NULL; + * static gint GtkGadget_private_offset; * static void gtk_gadget_class_intern_init (gpointer klass) * { * gtk_gadget_parent_class = g_type_class_peek_parent (klass); + * if (GtkGadget_private_offset != 0) + * g_type_class_adjust_private_offset (klass, &GtkGadget_private_offset); * gtk_gadget_class_init ((GtkGadgetClass*) klass); * } + * static inline gpointer gtk_gadget_get_instance_private (GtkGadget *self) + * { + * return (G_STRUCT_MEMBER_P (self, GtkGadget_private_offset)); + * } * * GType * gtk_gadget_get_type (void) @@ -1720,6 +1736,10 @@ guint g_type_get_type_registration_serial (void); * (GInstanceInitFunc) gtk_gadget_init, * 0); * { + * GtkGadget_private_offset = + * g_type_add_instance_private (g_define_type_id, sizeof (GtkGadgetPrivate)); + * } + * { * const GInterfaceInfo g_implement_interface_info = { * (GInterfaceInitFunc) gtk_gadget_gizmo_init * }; @@ -1863,9 +1883,9 @@ guint g_type_get_type_registration_serial (void); * Also note that private structs added with these macros must have a struct * name of the form `TypeNamePrivate`. * - * It is safe to call _get_instance_private on %NULL or invalid object since - * it's only adding an offset to the instance pointer. In that case the returned - * pointer must not be dereferenced. + * It is safe to call the `_get_instance_private` function on %NULL or invalid + * objects since it's only adding an offset to the instance pointer. In that + * case the returned pointer must not be dereferenced. * * Since: 2.38 */ |