mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-28 23:16:14 +01:00
Document the new GType boilerplate macros with an example.
Sat Jan 10 02:18:32 2004 Matthias Clasen <maclas@gmx.de> * gobject/tmpl/gtype.sgml: Document the new GType boilerplate macros with an example.
This commit is contained in:
parent
f05c39ab42
commit
43da83fdae
@ -1,3 +1,8 @@
|
|||||||
|
Sat Jan 10 02:18:32 2004 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* gobject/tmpl/gtype.sgml: Document the new GType boilerplate macros
|
||||||
|
with an example.
|
||||||
|
|
||||||
Sat Jan 10 01:36:01 2004 Matthias Clasen <maclas@gmx.de>
|
Sat Jan 10 01:36:01 2004 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
* gobject/tmpl/gtype.sgml: Document g_type_class_peek_static.
|
* gobject/tmpl/gtype.sgml: Document g_type_class_peek_static.
|
||||||
|
@ -1463,54 +1463,116 @@ that implements or has internal knowledge of the implementation of
|
|||||||
<!-- ##### MACRO G_DEFINE_TYPE ##### -->
|
<!-- ##### MACRO G_DEFINE_TYPE ##### -->
|
||||||
<para>
|
<para>
|
||||||
A convenience macro for type implementations.
|
A convenience macro for type implementations.
|
||||||
|
See G_DEFINE_TYPE_WITH_CODE() for an example.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@TypeName: The name of the new type, in Camel case.
|
@TN: The name of the new type, in Camel case.
|
||||||
@type_name: The name of the new type, in lowercase, with words
|
@t_n: The name of the new type, in lowercase, with words
|
||||||
separated by '_'.
|
separated by '_'.
|
||||||
@TYPE_PARENT: The #GType of the parent type.
|
@T_P: The #GType of the parent type.
|
||||||
|
@Since: 2.4
|
||||||
|
|
||||||
<!-- ##### MACRO G_DEFINE_TYPE_WITH_CODE ##### -->
|
<!-- ##### MACRO G_DEFINE_TYPE_WITH_CODE ##### -->
|
||||||
<para>
|
<para>
|
||||||
|
A convenience macro for type implementations.
|
||||||
</para>
|
</para>
|
||||||
|
<informalexample><programlisting>
|
||||||
|
G_DEFINE_TYPE_WITH_CODE (GtkGadget,
|
||||||
|
gtk_gadget,
|
||||||
|
GTK_TYPE_WIDGET,
|
||||||
|
G_IMPLEMENT_INTERFACE (TYPE_GIZMO,
|
||||||
|
gtk_gadget_gizmo_init));
|
||||||
|
</programlisting>
|
||||||
|
exands to
|
||||||
|
<programlisting>
|
||||||
|
static void gtk_gadget_init (GtkGadget *self);
|
||||||
|
static void gtk_gadget_class_init (GtkGadgetClass *klass);
|
||||||
|
static gpointer parent_class = NULL;
|
||||||
|
static void gtk_gadget_class_intern_init (gpointer klass)
|
||||||
|
{
|
||||||
|
parent_class = g_type_class_peek_parent (klass);
|
||||||
|
gtk_gadget_class_init ((GtkGadgetClass*) klass);
|
||||||
|
}
|
||||||
|
<!-- -->
|
||||||
|
GType
|
||||||
|
gtk_gadget_get_type (void)
|
||||||
|
{
|
||||||
|
static GType g_define_type_id = 0;
|
||||||
|
if (G_UNLIKELY (g_define_type_id == 0))
|
||||||
|
{
|
||||||
|
static const GTypeInfo g_define_type_info = {
|
||||||
|
sizeof (GtkGadgetClass),
|
||||||
|
(GBaseInitFunc) NULL,
|
||||||
|
(GBaseFinalizeFunc) NULL,
|
||||||
|
(GClassInitFunc) gtk_gadget_class_intern_init,
|
||||||
|
(GClassFinalizeFunc) NULL,
|
||||||
|
NULL, /* class_data */
|
||||||
|
sizeof (GtkGadget),
|
||||||
|
0, /* n_preallocs */
|
||||||
|
(GInstanceInitFunc) gtk_gadget_init,
|
||||||
|
};
|
||||||
|
g_define_type_id = g_type_register_static (GTK_TYPE_WIDGET, "GtkGadget", &g_define_type_info, 0);
|
||||||
|
{
|
||||||
|
static 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return g_define_type_id;
|
||||||
|
}
|
||||||
|
</programlisting>
|
||||||
|
The only pieces which have to be manually provided are the definitions of the
|
||||||
|
instance and class structure and the definitions of the instance and class
|
||||||
|
init functions.
|
||||||
|
</informalexample>
|
||||||
|
|
||||||
@TN:
|
@TN: The name of the new type, in Camel case.
|
||||||
@t_n:
|
@t_n: The name of the new type in lowercase, with words separated by '_'.
|
||||||
@T_P:
|
@T_P: The #GType of the parent type.
|
||||||
@_C_:
|
@_C_: Custom code that gets inserted in the *_get_type() function.
|
||||||
|
@Since: 2.4
|
||||||
|
|
||||||
|
|
||||||
<!-- ##### MACRO G_DEFINE_ABSTRACT_TYPE ##### -->
|
<!-- ##### MACRO G_DEFINE_ABSTRACT_TYPE ##### -->
|
||||||
<para>
|
<para>
|
||||||
|
A convenience macro for type implementations.
|
||||||
|
Similar to G_DEFINE_TYPE(), but defines an abstract type.
|
||||||
|
See G_DEFINE_TYPE_WITH_CODE() for an example.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@TN:
|
@TN: The name of the new type, in Camel case.
|
||||||
@t_n:
|
@t_n: The name of the new type, in lowercase, with words
|
||||||
@T_P:
|
separated by '_'.
|
||||||
|
@T_P: The #GType of the parent type.
|
||||||
|
@Since: 2.4
|
||||||
|
|
||||||
|
|
||||||
<!-- ##### MACRO G_DEFINE_ABSTRACT_TYPE_WITH_CODE ##### -->
|
<!-- ##### MACRO G_DEFINE_ABSTRACT_TYPE_WITH_CODE ##### -->
|
||||||
<para>
|
<para>
|
||||||
|
A convenience macro for type implementations.
|
||||||
|
Similar to G_DEFINE_TYPE_WITH_CODE(), but defines an abstract type.
|
||||||
|
See G_DEFINE_TYPE_WITH_CODE() for an example.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@TN:
|
@TN: The name of the new type, in Camel case.
|
||||||
@t_n:
|
@t_n: The name of the new type, in lowercase, with words
|
||||||
@T_P:
|
separated by '_'.
|
||||||
@_C_:
|
@T_P: The #GType of the parent type.
|
||||||
|
@_C_: Custom code that gets inserted in the @type_name_get_type() function.
|
||||||
|
@Since: 2.4
|
||||||
|
|
||||||
|
|
||||||
<!-- ##### MACRO G_IMPLEMENT_INTERFACE ##### -->
|
<!-- ##### MACRO G_IMPLEMENT_INTERFACE ##### -->
|
||||||
<para>
|
<para>
|
||||||
|
A convenience macro to ease interface addition in the @Code section
|
||||||
|
of G_DEFINE_TYPE_WITH_CODE() or G_DEFINE_ABSTRACT_TYPE_WITH_CODE().
|
||||||
|
See G_DEFINE_TYPE_WITH_CODE() for an example.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@TYPE_IFACE:
|
@TYPE_IFACE: The #GType of the interface to add
|
||||||
@iface_init:
|
@iface_init: The interface init function
|
||||||
|
@Since: 2.4
|
||||||
|
|
||||||
<!-- ##### MACRO G_TYPE_INVALID ##### -->
|
<!-- ##### MACRO G_TYPE_INVALID ##### -->
|
||||||
<para>
|
<para>
|
||||||
|
Loading…
Reference in New Issue
Block a user