* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
+#ifndef __G_TYPE_H__
+#define __G_TYPE_H__
+
#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
#error "Only <glib-object.h> can be included directly."
#endif
-#ifndef __G_TYPE_H__
-#define __G_TYPE_H__
-
#include <glib.h>
G_BEGIN_DECLS
#define G_TYPE_FUNDAMENTAL_MAX (255 << G_TYPE_FUNDAMENTAL_SHIFT)
/* Constant fundamental types,
- * introduced by g_type_init().
*/
/**
* G_TYPE_INVALID:
* G_TYPE_NONE:
*
* A fundamental type which is used as a replacement for the C
- * <literal>void</literal> return type.
+ * void return type.
*/
#define G_TYPE_NONE G_TYPE_MAKE_FUNDAMENTAL (1)
/**
* The fundamental type for #GObject.
*/
#define G_TYPE_OBJECT G_TYPE_MAKE_FUNDAMENTAL (20)
+/**
+ * G_TYPE_VARIANT:
+ *
+ * The fundamental type corresponding to #GVariant.
+ *
+ * All floating #GVariant instances passed through the #GType system are
+ * consumed.
+ *
+ * Note that callbacks in closures, and signal handlers
+ * for signals of return type %G_TYPE_VARIANT, must never return floating
+ * variants.
+ *
+ * Note: GLib 2.24 did include a boxed type with this name. It was replaced
+ * with this fundamental type in 2.26.
+ *
+ * Since: 2.26
+ */
+#define G_TYPE_VARIANT G_TYPE_MAKE_FUNDAMENTAL (21)
/* Reserved fundamental type numbers to create new fundamental
* First fundamental type number to create a new fundamental type id with
* G_TYPE_MAKE_FUNDAMENTAL() reserved for GLib.
*/
-#define G_TYPE_RESERVED_GLIB_FIRST (21)
+#define G_TYPE_RESERVED_GLIB_FIRST (22)
/**
* G_TYPE_RESERVED_GLIB_LAST:
*
* G_TYPE_IS_ABSTRACT:
* @type: A #GType value.
*
- * Checks if @type is an abstract type. An abstract type can not be
+ * Checks if @type is an abstract type. An abstract type cannot be
* instantiated and is normally used as an abstract base class for
* derived classes.
*
* @G_TYPE_DEBUG_OBJECTS: Print messages about object bookkeeping.
* @G_TYPE_DEBUG_SIGNALS: Print messages about signal emissions.
* @G_TYPE_DEBUG_MASK: Mask covering all debug flags.
- *
- * The <type>GTypeDebugFlags</type> enumeration values can be passed to
- * g_type_init_with_debug_flags() to trigger debugging messages during runtime.
- * Note that the messages can also be triggered by setting the
- * <envar>GOBJECT_DEBUG</envar> environment variable to a ':'-separated list of
- * "objects" and "signals".
+ *
+ * These flags used to be passed to g_type_init_with_debug_flags() which
+ * is now deprecated.
+ *
+ * If you need to enable debugging features, use the GOBJECT_DEBUG
+ * environment variable.
+ *
+ * Deprecated: 2.36: g_type_init() is now done automatically
*/
typedef enum /*< skip >*/
{
/* --- prototypes --- */
+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_CONST_RETURN gchar* g_type_name (GType type);
+GLIB_AVAILABLE_IN_ALL
+const gchar * g_type_name (GType type);
+GLIB_AVAILABLE_IN_ALL
GQuark g_type_qname (GType type);
+GLIB_AVAILABLE_IN_ALL
GType g_type_from_name (const gchar *name);
+GLIB_AVAILABLE_IN_ALL
GType g_type_parent (GType type);
+GLIB_AVAILABLE_IN_ALL
guint g_type_depth (GType type);
+GLIB_AVAILABLE_IN_ALL
GType g_type_next_base (GType leaf_type,
GType root_type);
+GLIB_AVAILABLE_IN_ALL
gboolean g_type_is_a (GType type,
GType is_a_type);
+GLIB_AVAILABLE_IN_ALL
gpointer g_type_class_ref (GType type);
+GLIB_AVAILABLE_IN_ALL
gpointer g_type_class_peek (GType type);
+GLIB_AVAILABLE_IN_ALL
gpointer g_type_class_peek_static (GType type);
+GLIB_AVAILABLE_IN_ALL
void g_type_class_unref (gpointer g_class);
+GLIB_AVAILABLE_IN_ALL
gpointer g_type_class_peek_parent (gpointer g_class);
+GLIB_AVAILABLE_IN_ALL
gpointer g_type_interface_peek (gpointer instance_class,
GType iface_type);
+GLIB_AVAILABLE_IN_ALL
gpointer g_type_interface_peek_parent (gpointer g_iface);
+GLIB_AVAILABLE_IN_ALL
gpointer g_type_default_interface_ref (GType g_type);
+GLIB_AVAILABLE_IN_ALL
gpointer g_type_default_interface_peek (GType g_type);
+GLIB_AVAILABLE_IN_ALL
void g_type_default_interface_unref (gpointer g_iface);
/* g_free() the returned arrays */
+GLIB_AVAILABLE_IN_ALL
GType* g_type_children (GType type,
guint *n_children);
+GLIB_AVAILABLE_IN_ALL
GType* g_type_interfaces (GType type,
guint *n_interfaces);
/* per-type _static_ data */
+GLIB_AVAILABLE_IN_ALL
void g_type_set_qdata (GType type,
GQuark quark,
gpointer data);
+GLIB_AVAILABLE_IN_ALL
gpointer g_type_get_qdata (GType type,
GQuark quark);
+GLIB_AVAILABLE_IN_ALL
void g_type_query (GType type,
GTypeQuery *query);
* It should be noted, that it is generally a bad idea to follow the
* #G_VALUE_NOCOPY_CONTENTS hint for reference counted types. Due to
* reentrancy requirements and reference count assertions performed
- * by the #GSignal code, reference counts should always be incremented
- * for reference counted contents stored in the value->data array.
- * To deviate from our string example for a moment, and taking a look
- * at an exemplary implementation for collect_value() of #GObject:
+ * by the signal emission code, reference counts should always be
+ * incremented for reference counted contents stored in the value->data
+ * array. To deviate from our string example for a moment, and taking
+ * a look at an exemplary implementation for collect_value() of
+ * #GObject:
* |[
* if (collect_values[0].v_pointer)
* {
* return g_strdup_printf ("object location passed as NULL");
* if (!value->data[0].v_pointer)
* *object_p = NULL;
- * else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) // always honour
+ * else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) /* always honour */
* *object_p = value->data[0].v_pointer;
* else
* *object_p = g_object_ref (value->data[0].v_pointer);
GValue *dest_value);
/* varargs functionality (optional) */
gpointer (*value_peek_pointer) (const GValue *value);
- gchar *collect_format;
+ const gchar *collect_format;
gchar* (*collect_value) (GValue *value,
guint n_collect_values,
GTypeCValue *collect_values,
guint collect_flags);
- gchar *lcopy_format;
+ const gchar *lcopy_format;
gchar* (*lcopy_value) (const GValue *value,
guint n_collect_values,
GTypeCValue *collect_values,
guint collect_flags);
};
+GLIB_AVAILABLE_IN_ALL
GType g_type_register_static (GType parent_type,
const gchar *type_name,
const GTypeInfo *info,
GTypeFlags flags);
+GLIB_AVAILABLE_IN_ALL
GType g_type_register_static_simple (GType parent_type,
const gchar *type_name,
guint class_size,
GInstanceInitFunc instance_init,
GTypeFlags flags);
+GLIB_AVAILABLE_IN_ALL
GType g_type_register_dynamic (GType parent_type,
const gchar *type_name,
GTypePlugin *plugin,
GTypeFlags flags);
+GLIB_AVAILABLE_IN_ALL
GType g_type_register_fundamental (GType type_id,
const gchar *type_name,
const GTypeInfo *info,
const GTypeFundamentalInfo *finfo,
GTypeFlags flags);
+GLIB_AVAILABLE_IN_ALL
void g_type_add_interface_static (GType instance_type,
GType interface_type,
const GInterfaceInfo *info);
+GLIB_AVAILABLE_IN_ALL
void g_type_add_interface_dynamic (GType instance_type,
GType interface_type,
GTypePlugin *plugin);
+GLIB_AVAILABLE_IN_ALL
void g_type_interface_add_prerequisite (GType interface_type,
GType prerequisite_type);
+GLIB_AVAILABLE_IN_ALL
GType*g_type_interface_prerequisites (GType interface_type,
guint *n_prerequisites);
+GLIB_AVAILABLE_IN_ALL
void g_type_class_add_private (gpointer g_class,
gsize private_size);
+GLIB_AVAILABLE_IN_2_38
+gint g_type_add_instance_private (GType class_type,
+ gsize private_size);
+GLIB_AVAILABLE_IN_ALL
gpointer g_type_instance_get_private (GTypeInstance *instance,
GType private_type);
+GLIB_AVAILABLE_IN_2_38
+void g_type_class_adjust_private_offset (gpointer g_class,
+ gint *private_size_or_offset);
+GLIB_AVAILABLE_IN_ALL
void g_type_add_class_private (GType class_type,
gsize private_size);
+GLIB_AVAILABLE_IN_ALL
gpointer g_type_class_get_private (GTypeClass *klass,
GType private_type);
+GLIB_AVAILABLE_IN_2_38
+gint g_type_class_get_instance_private_offset (gpointer g_class);
+
+GLIB_AVAILABLE_IN_2_34
+void g_type_ensure (GType type);
+GLIB_AVAILABLE_IN_2_36
+guint g_type_get_type_registration_serial (void);
/* --- GType boilerplate --- */
*/
#define G_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_) _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, 0) {_C_;} _G_DEFINE_TYPE_EXTENDED_END()
/**
+ * G_DEFINE_TYPE_WITH_PRIVATE:
+ * @TN: The name of the new type, in Camel case.
+ * @t_n: The name of the new type, in lowercase, with words
+ * separated by '_'.
+ * @T_P: The #GType of the parent type.
+ *
+ * A convenience macro for type implementations, which declares a
+ * class initialization function, an instance initialization function (see #GTypeInfo for information about
+ * these), a static variable named @t_n<!-- -->_parent_class pointing to the parent class, and adds private
+ * instance data to the type. Furthermore, it defines a *_get_type() function. See G_DEFINE_TYPE_EXTENDED()
+ * for an example.
+ *
+ * Note that private structs added with this macros must have a struct
+ * name of the form <replaceable>@TN</replaceable>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))
+/**
* G_DEFINE_ABSTRACT_TYPE:
* @TN: The name of the new type, in Camel case.
* @t_n: The name of the new type, in lowercase, with words
*/
#define G_DEFINE_ABSTRACT_TYPE_WITH_CODE(TN, t_n, T_P, _C_) _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT) {_C_;} _G_DEFINE_TYPE_EXTENDED_END()
/**
+ * G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE:
+ * @TN: The name of the new type, in Camel case.
+ * @t_n: The name of the new type, in lowercase, with words
+ * separated by '_'.
+ * @T_P: The #GType of the parent type.
+ *
+ * Similar to G_DEFINE_TYPE_WITH_PRIVATE(), but defines an abstract type.
+ * See G_DEFINE_TYPE_EXTENDED() for an example.
+ *
+ * Since: 2.38
+ */
+#define G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE(TN, t_n, T_P) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT, G_ADD_PRIVATE (TN))
+/**
* G_DEFINE_TYPE_EXTENDED:
* @TN: The name of the new type, in Camel case.
* @t_n: The name of the new type, in lowercase, with words
* (GClassInitFunc) gtk_gadget_class_intern_init,
* sizeof (GtkGadget),
* (GInstanceInitFunc) gtk_gadget_init,
- * (GTypeFlags) flags);
+ * 0);
* {
- * static const GInterfaceInfo g_implement_interface_info = {
+ * const GInterfaceInfo g_implement_interface_info = {
* (GInterfaceInitFunc) gtk_gadget_gizmo_init
* };
* g_type_add_interface_static (g_define_type_id, TYPE_GIZMO, &g_implement_interface_info);
* function.
*
* The macro expects the interface initialization function to have the
- * name <literal>t_n ## _default_init</literal>, and the interface
- * structure to have the name <literal>TN ## Interface</literal>.
+ * name `t_n ## _default_init`, and the interface structure to have the
+ * name `TN ## Interface`.
*
* Since: 2.24
*/
g_type_add_interface_static (g_define_type_id, TYPE_IFACE, &g_implement_interface_info); \
}
+/**
+ * G_ADD_PRIVATE:
+ * @TypeName: the name of the type in CamelCase
+ *
+ * A convenience macro to ease adding private data to instances of a new type
+ * in the @_C_ section of G_DEFINE_TYPE_WITH_CODE() or
+ * G_DEFINE_ABSTRACT_TYPE_WITH_CODE().
+ *
+ * For instance:
+ *
+ * |[
+ * typedef struct _MyObject MyObject;
+ * typedef struct _MyObjectClass MyObjectClass;
+ *
+ * typedef struct {
+ * gint foo;
+ * gint bar;
+ * } MyObjectPrivate;
+ *
+ * G_DEFINE_TYPE_WITH_CODE (MyObject, my_object, G_TYPE_OBJECT,
+ * G_ADD_PRIVATE (MyObject))
+ * ]|
+ *
+ * Will add MyObjectPrivate as the private data to any instance of the MyObject
+ * type.
+ *
+ * G_DEFINE_TYPE_* macros will automatically create a private function
+ * based on the arguments to this macro, which can be used to safely
+ * retrieve the private data from an instance of the type; for instance:
+ *
+ * |[
+ * gint
+ * my_object_get_foo (MyObject *obj)
+ * {
+ * MyObjectPrivate *priv = my_object_get_instance_private (obj);
+ *
+ * return priv->foo;
+ * }
+ *
+ * void
+ * my_object_set_bar (MyObject *obj,
+ * gint bar)
+ * {
+ * MyObjectPrivate *priv = my_object_get_instance_private (obj);
+ *
+ * if (priv->bar != bar)
+ * priv->bar = bar;
+ * }
+ * ]|
+ *
+ * Note that this macro can only be used together with the G_DEFINE_TYPE_*
+ * macros, since it depends on variable names from those macros.
+ *
+ * Also note that private structs added with these macros must have a struct
+ * name of the form <replaceable>TypeName</replaceable>Private.
+ *
+ * Since: 2.38
+ */
+#define G_ADD_PRIVATE(TypeName) { \
+ TypeName##_private_offset = \
+ 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)))
+
+/**
+ * G_PRIVATE_FIELD_P:
+ * @TypeName: the name of the type in CamelCase
+ * @inst: the instance of @TypeName you wish to access
+ * @field_name: the name of the field in the private data structure
+ *
+ * Evaluates to a pointer to the @field_name inside the @inst 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_FIELD_P(TypeName, inst, field_name) \
+ G_STRUCT_MEMBER_P (inst, G_PRIVATE_OFFSET (TypeName, field_name))
+
+/**
+ * G_PRIVATE_FIELD:
+ * @TypeName: the name of the type in CamelCase
+ * @inst: the instance of @TypeName you wish to access
+ * @field_type: the type of the field in the private data structure
+ * @field_name: the name of the field in the private data structure
+ *
+ * Evaluates to the @field_name inside the @inst 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_FIELD(TypeName, inst, field_type, field_name) \
+ G_STRUCT_MEMBER (field_type, inst, G_PRIVATE_OFFSET (TypeName, field_name))
+
+/* we need to have this macro under conditional expansion, as it references
+ * a function that has been added in 2.38. see bug:
+ * https://bugzilla.gnome.org/show_bug.cgi?id=703191
+ */
+#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
+#define _G_DEFINE_TYPE_EXTENDED_CLASS_INIT(TypeName, type_name) \
+static void type_name##_class_intern_init (gpointer klass) \
+{ \
+ type_name##_parent_class = g_type_class_peek_parent (klass); \
+ if (TypeName##_private_offset != 0) \
+ g_type_class_adjust_private_offset (klass, &TypeName##_private_offset); \
+ type_name##_class_init ((TypeName##Class*) klass); \
+}
+
+#else
+#define _G_DEFINE_TYPE_EXTENDED_CLASS_INIT(TypeName, type_name) \
+static void type_name##_class_intern_init (gpointer klass) \
+{ \
+ type_name##_parent_class = g_type_class_peek_parent (klass); \
+ type_name##_class_init ((TypeName##Class*) klass); \
+}
+#endif /* GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 */
+
#define _G_DEFINE_TYPE_EXTENDED_BEGIN(TypeName, type_name, TYPE_PARENT, flags) \
\
static void type_name##_init (TypeName *self); \
static void type_name##_class_init (TypeName##Class *klass); \
static gpointer type_name##_parent_class = NULL; \
-static void type_name##_class_intern_init (gpointer klass) \
+static gint TypeName##_private_offset; \
+\
+_G_DEFINE_TYPE_EXTENDED_CLASS_INIT(TypeName, type_name) \
+\
+static inline gpointer \
+type_name##_get_instance_private (TypeName *self) \
{ \
- type_name##_parent_class = g_type_class_peek_parent (klass); \
- type_name##_class_init ((TypeName##Class*) klass); \
+ return (G_STRUCT_MEMBER_P (self, TypeName##_private_offset)); \
} \
\
GType \
return g_define_type_id__volatile; \
} /* closes type_name##_get_type() */
+/**
+ * G_DEFINE_BOXED_TYPE:
+ * @TypeName: The name of the new type, in Camel case.
+ * @type_name: The name of the new type, in lowercase, with words
+ * separated by '_'.
+ * @copy_func: the #GBoxedCopyFunc for the new type
+ * @free_func: the #GBoxedFreeFunc for the new type
+ *
+ * A convenience macro for boxed type implementations, which defines a
+ * type_name_get_type() function registering the boxed type.
+ *
+ * Since: 2.26
+ */
+#define G_DEFINE_BOXED_TYPE(TypeName, type_name, copy_func, free_func) G_DEFINE_BOXED_TYPE_WITH_CODE (TypeName, type_name, copy_func, free_func, {})
+/**
+ * G_DEFINE_BOXED_TYPE_WITH_CODE:
+ * @TypeName: The name of the new type, in Camel case.
+ * @type_name: The name of the new type, in lowercase, with words
+ * separated by '_'.
+ * @copy_func: the #GBoxedCopyFunc for the new type
+ * @free_func: the #GBoxedFreeFunc for the new type
+ * @_C_: Custom code that gets inserted in the *_get_type() function.
+ *
+ * A convenience macro for boxed type implementations.
+ * Similar to G_DEFINE_BOXED_TYPE(), but allows to insert custom code into the
+ * type_name_get_type() function, e.g. to register value transformations with
+ * g_value_register_transform_func().
+ *
+ * Since: 2.26
+ */
+#define G_DEFINE_BOXED_TYPE_WITH_CODE(TypeName, type_name, copy_func, free_func, _C_) _G_DEFINE_BOXED_TYPE_BEGIN (TypeName, type_name, copy_func, free_func) {_C_;} _G_DEFINE_TYPE_EXTENDED_END()
+
+/* Only use this in non-C++ on GCC >= 2.7, except for Darwin/ppc64.
+ * See https://bugzilla.gnome.org/show_bug.cgi?id=647145
+ */
+#if !defined (__cplusplus) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)) && !(defined (__APPLE__) && defined (__ppc64__))
+#define _G_DEFINE_BOXED_TYPE_BEGIN(TypeName, type_name, copy_func, free_func) \
+GType \
+type_name##_get_type (void) \
+{ \
+ static volatile gsize g_define_type_id__volatile = 0; \
+ if (g_once_init_enter (&g_define_type_id__volatile)) \
+ { \
+ GType (* _g_register_boxed) \
+ (const gchar *, \
+ union \
+ { \
+ TypeName * (*do_copy_type) (TypeName *); \
+ TypeName * (*do_const_copy_type) (const TypeName *); \
+ GBoxedCopyFunc do_copy_boxed; \
+ } __attribute__((__transparent_union__)), \
+ union \
+ { \
+ void (* do_free_type) (TypeName *); \
+ GBoxedFreeFunc do_free_boxed; \
+ } __attribute__((__transparent_union__)) \
+ ) = g_boxed_type_register_static; \
+ GType g_define_type_id = \
+ _g_register_boxed (g_intern_static_string (#TypeName), copy_func, free_func); \
+ { /* custom code follows */
+#else
+#define _G_DEFINE_BOXED_TYPE_BEGIN(TypeName, type_name, copy_func, free_func) \
+GType \
+type_name##_get_type (void) \
+{ \
+ static volatile gsize g_define_type_id__volatile = 0; \
+ if (g_once_init_enter (&g_define_type_id__volatile)) \
+ { \
+ GType g_define_type_id = \
+ g_boxed_type_register_static (g_intern_static_string (#TypeName), \
+ (GBoxedCopyFunc) copy_func, \
+ (GBoxedFreeFunc) free_func); \
+ { /* custom code follows */
+#endif /* __GNUC__ */
+
+/**
+ * G_DEFINE_POINTER_TYPE:
+ * @TypeName: The name of the new type, in Camel case.
+ * @type_name: The name of the new type, in lowercase, with words
+ * separated by '_'.
+ *
+ * A convenience macro for pointer type implementations, which defines a
+ * type_name_get_type() function registering the pointer type.
+ *
+ * Since: 2.26
+ */
+#define G_DEFINE_POINTER_TYPE(TypeName, type_name) G_DEFINE_POINTER_TYPE_WITH_CODE (TypeName, type_name, {})
+/**
+ * G_DEFINE_POINTER_TYPE_WITH_CODE:
+ * @TypeName: The name of the new type, in Camel case.
+ * @type_name: The name of the new type, in lowercase, with words
+ * separated by '_'.
+ * @_C_: Custom code that gets inserted in the *_get_type() function.
+ *
+ * A convenience macro for pointer type implementations.
+ * Similar to G_DEFINE_POINTER_TYPE(), but allows to insert custom code into the
+ * type_name_get_type() function.
+ *
+ * Since: 2.26
+ */
+#define G_DEFINE_POINTER_TYPE_WITH_CODE(TypeName, type_name, _C_) _G_DEFINE_POINTER_TYPE_BEGIN (TypeName, type_name) {_C_;} _G_DEFINE_TYPE_EXTENDED_END()
+
+#define _G_DEFINE_POINTER_TYPE_BEGIN(TypeName, type_name) \
+GType \
+type_name##_get_type (void) \
+{ \
+ static volatile gsize g_define_type_id__volatile = 0; \
+ if (g_once_init_enter (&g_define_type_id__volatile)) \
+ { \
+ GType g_define_type_id = \
+ g_pointer_type_register_static (g_intern_static_string (#TypeName)); \
+ { /* custom code follows */
+
/* --- protected (for fundamental type implementations) --- */
+GLIB_AVAILABLE_IN_ALL
GTypePlugin* g_type_get_plugin (GType type);
+GLIB_AVAILABLE_IN_ALL
GTypePlugin* g_type_interface_get_plugin (GType instance_type,
GType interface_type);
+GLIB_AVAILABLE_IN_ALL
GType g_type_fundamental_next (void);
+GLIB_AVAILABLE_IN_ALL
GType g_type_fundamental (GType type_id);
+GLIB_AVAILABLE_IN_ALL
GTypeInstance* g_type_create_instance (GType type);
+GLIB_AVAILABLE_IN_ALL
void g_type_free_instance (GTypeInstance *instance);
+GLIB_AVAILABLE_IN_ALL
void g_type_add_class_cache_func (gpointer cache_data,
GTypeClassCacheFunc cache_func);
+GLIB_AVAILABLE_IN_ALL
void g_type_remove_class_cache_func (gpointer cache_data,
GTypeClassCacheFunc cache_func);
+GLIB_AVAILABLE_IN_ALL
void g_type_class_unref_uncached (gpointer g_class);
+GLIB_AVAILABLE_IN_ALL
void g_type_add_interface_check (gpointer check_data,
GTypeInterfaceCheckFunc check_func);
+GLIB_AVAILABLE_IN_ALL
void g_type_remove_interface_check (gpointer check_data,
GTypeInterfaceCheckFunc check_func);
+GLIB_AVAILABLE_IN_ALL
GTypeValueTable* g_type_value_table_peek (GType type);
/*< private >*/
+GLIB_AVAILABLE_IN_ALL
gboolean g_type_check_instance (GTypeInstance *instance) G_GNUC_PURE;
+GLIB_AVAILABLE_IN_ALL
GTypeInstance* g_type_check_instance_cast (GTypeInstance *instance,
GType iface_type);
+GLIB_AVAILABLE_IN_ALL
gboolean g_type_check_instance_is_a (GTypeInstance *instance,
GType iface_type) G_GNUC_PURE;
+GLIB_AVAILABLE_IN_ALL
GTypeClass* g_type_check_class_cast (GTypeClass *g_class,
GType is_a_type);
+GLIB_AVAILABLE_IN_ALL
gboolean g_type_check_class_is_a (GTypeClass *g_class,
GType is_a_type) G_GNUC_PURE;
+GLIB_AVAILABLE_IN_ALL
gboolean g_type_check_is_value_type (GType type) G_GNUC_CONST;
+GLIB_AVAILABLE_IN_ALL
gboolean g_type_check_value (GValue *value) G_GNUC_PURE;
+GLIB_AVAILABLE_IN_ALL
gboolean g_type_check_value_holds (GValue *value,
GType type) G_GNUC_PURE;
+GLIB_AVAILABLE_IN_ALL
gboolean g_type_test_flags (GType type,
guint flags) G_GNUC_CONST;
/* --- debugging functions --- */
-G_CONST_RETURN gchar* g_type_name_from_instance (GTypeInstance *instance);
-G_CONST_RETURN gchar* g_type_name_from_class (GTypeClass *g_class);
-
-
-/* --- internal functions --- */
-G_GNUC_INTERNAL void g_value_c_init (void); /* sync with gvalue.c */
-G_GNUC_INTERNAL void g_value_types_init (void); /* sync with gvaluetypes.c */
-G_GNUC_INTERNAL void g_enum_types_init (void); /* sync with genums.c */
-G_GNUC_INTERNAL void g_param_type_init (void); /* sync with gparam.c */
-G_GNUC_INTERNAL void g_boxed_type_init (void); /* sync with gboxed.c */
-G_GNUC_INTERNAL void g_object_type_init (void); /* sync with gobject.c */
-G_GNUC_INTERNAL void g_param_spec_types_init (void); /* sync with gparamspecs.c */
-G_GNUC_INTERNAL void g_value_transforms_init (void); /* sync with gvaluetransform.c */
-G_GNUC_INTERNAL void g_signal_init (void); /* sync with gsignal.c */
+GLIB_AVAILABLE_IN_ALL
+const gchar * g_type_name_from_instance (GTypeInstance *instance);
+GLIB_AVAILABLE_IN_ALL
+const gchar * g_type_name_from_class (GTypeClass *g_class);
/* --- implementation bits --- */