⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gtype.sgml

📁 This GLib version 2.16.1. GLib is the low-level core library that forms the basis for projects such
💻 SGML
📖 第 1 页 / 共 4 页
字号:
implementing a fundamental type. Also language bindings should <emphasis>not</emphasis>use this function but g_object_new() instead.</para>@type: 	  An instantiatable type to create an instance for.@Returns: An allocated and initialized instance, subject to further	  treatment by the fundamental type implementation.<!-- ##### FUNCTION g_type_free_instance ##### --><para>Frees an instance of a type, returning it to the instance pool for the type,if there is one.</para><para>Like g_type_create_instance(), this function is reserved for implementors of fundamental types.</para>@instance: an instance of a type.<!-- ##### FUNCTION g_type_add_class_cache_func ##### --><para>Adds a #GTypeClassCacheFunc to be called before the reference count of a class goes from one to zero. This can be used to prevent premature class destruction.All installed #GTypeClassCacheFunc functions will be chained until one of them returns %TRUE. The functions have to check the class id passed in to figure whether they actually want to cache the class of this type, since all classesare routed through the same #GTypeClassCacheFunc chain.</para>@cache_data: data to be passed to @cache_func@cache_func: a #GTypeClassCacheFunc<!-- ##### FUNCTION g_type_remove_class_cache_func ##### --><para>Removes a previously installed #GTypeClassCacheFunc. The cache maintained by @cache_func has to be empty when calling g_type_remove_class_cache_func() to avoid leaks.</para>@cache_data: data that was given when adding @cache_func@cache_func: a #GTypeClassCacheFunc<!-- ##### FUNCTION g_type_class_unref_uncached ##### --><para>A variant of g_type_class_unref() for use in #GTypeClassCacheFuncimplementations. It unreferences a class without consulting the chainof #GTypeClassCacheFunc<!-- -->s, avoiding the recursion which would occurotherwise.</para>@g_class: The #GTypeClass structure to unreference.<!-- ##### FUNCTION g_type_add_interface_check ##### --><para>Adds a function to be called after an interface vtable isinitialized for any class (i.e. after the @interface_initmember of #GInterfaceInfo has been called).</para><para>This function is useful when you want to check an invariantthat depends on the interfaces of a class. For instance,the implementation of #GObject uses this facility to checkthat an object implements all of the properties that aredefined on its interfaces.    </para>@check_data: data to pass to @check_func@check_func: function to be called after each interface   is initialized.@Since: 2.4<!-- ##### FUNCTION g_type_remove_interface_check ##### --><para>Removes an interface check function added withg_type_add_interface_check().</para>@check_data: callback data passed to g_type_add_interface_check()@check_func: callback function passed to g_type_add_interface_check()@Since: 2.4<!-- ##### USER_FUNCTION GTypeInterfaceCheckFunc ##### --><para>A callback called after an interface vtable is initialized.See g_type_add_interface_check().</para>@check_data: data passed to g_type_add_interface_check().@g_iface: the interface that has been initialized@Since: 2.4<!-- ##### FUNCTION g_type_value_table_peek ##### --><para>Returns the location of the #GTypeValueTable associated with @type.<emphasis>Note that this function should only be used from source codethat implements or has internal knowledge of the implementation of@type.</emphasis></para>@type:    A #GType value.@Returns: Location of the #GTypeValueTable associated with @type or          %NULL if there is no #GTypeValueTable associated with @type.<!-- ##### MACRO G_DEFINE_TYPE ##### --><para>A convenience macro for type implementations, which declares a class initialization function, an instance initialization function (see #GTypeInfo for information about these) and a static variable named @t_n<!-- -->_parent_class pointing to the parent class. Furthermore, it defines a *_get_type() function. See G_DEFINE_TYPE_EXTENDED() for an example.</para>@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.@Since: 2.4<!-- ##### MACRO G_DEFINE_TYPE_WITH_CODE ##### --><para>A convenience macro for type implementations.  Similar to G_DEFINE_TYPE(), but allows to insert custom code into the *_get_type() function, e.g. interface implementations via G_IMPLEMENT_INTERFACE().See G_DEFINE_TYPE_EXTENDED() for an example.</para>@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.@_C_: Custom code that gets inserted in the *_get_type() function.@Since: 2.4<!-- ##### MACRO G_DEFINE_ABSTRACT_TYPE ##### --><para>A convenience macro for type implementations. Similar to G_DEFINE_TYPE(), but defines an abstract type. See G_DEFINE_TYPE_EXTENDED() for an example.</para>@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.@Since: 2.4<!-- ##### MACRO G_DEFINE_ABSTRACT_TYPE_WITH_CODE ##### --><para>A convenience macro for type implementations.Similar to G_DEFINE_TYPE_WITH_CODE(), but defines an abstract type and allows to insert custom code into the *_get_type() function, e.g. interface implementations via G_IMPLEMENT_INTERFACE(). See G_DEFINE_TYPE_EXTENDED() for an example.</para>@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.@_C_: Custom code that gets inserted in the @type_name_get_type() function.@Since: 2.4<!-- ##### MACRO G_IMPLEMENT_INTERFACE ##### --><para>A convenience macro to ease interface addition in the @_C_ sectionof G_DEFINE_TYPE_WITH_CODE() or G_DEFINE_ABSTRACT_TYPE_WITH_CODE(). See G_DEFINE_TYPE_EXTENDED() for an example.</para><para>Note that this macro can only be used together with the G_DEFINE_TYPE_*macros, since it depends on variable names from those macros.</para>@TYPE_IFACE: The #GType of the interface to add@iface_init: The interface init function@Since: 2.4<!-- ##### MACRO G_DEFINE_TYPE_EXTENDED ##### --><para>The most general convenience macro for type implementations, on which G_DEFINE_TYPE(), etc are based. </para><informalexample><programlisting>G_DEFINE_TYPE_EXTENDED (GtkGadget,                         gtk_gadget,                         GTK_TYPE_WIDGET,                        0,                         G_IMPLEMENT_INTERFACE (TYPE_GIZMO,                                                gtk_gadget_gizmo_init));</programlisting>expands to<programlisting>static void     gtk_gadget_init       (GtkGadget      *self);static void     gtk_gadget_class_init (GtkGadgetClass *klass);static gpointer gtk_gadget_parent_class = NULL;static void     gtk_gadget_class_intern_init (gpointer klass){  gtk_gadget_parent_class = g_type_class_peek_parent (klass);  gtk_gadget_class_init ((GtkGadgetClass*) klass);}<!-- -->GTypegtk_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", &amp;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, &amp;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: 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.@_f_: #GTypeFlags to pass to g_type_register_static()@_C_: Custom code that gets inserted in the *_get_type() function.@Since: 2.4<!-- ##### MACRO G_TYPE_INVALID ##### --><para>An invalid #GType used as error return value in some functions which returna #GType. </para><!-- ##### MACRO G_TYPE_NONE ##### --><para>A fundamental type which is used as a replacement for the C<literal>void</literal> return type.</para><!-- ##### MACRO G_TYPE_INTERFACE ##### --><para>The fundamental type from which all interfaces are derived.</para><!-- ##### MACRO G_TYPE_CHAR ##### -->  <para>    The fundamental type corresponding to #gchar.    The type designated by G_TYPE_CHAR is unconditionally an 8-bit signed integer.    This may or may not be the same type a the C type "gchar".  </para><!-- ##### MACRO G_TYPE_UCHAR ##### --><para>The fundamental type corresponding to #guchar.</para><!-- ##### MACRO G_TYPE_BOOLEAN ##### --><para>The fundamental type corresponding to #gboolean.</para><!-- ##### MACRO G_TYPE_INT ##### --><para>The fundamental type corresponding to #gint.</para><!-- ##### MACRO G_TYPE_UINT ##### --><para>The fundamental type corresponding to #guint.</para><!-- ##### MACRO G_TYPE_LONG ##### --><para>The fundamental type corresponding to #glong.</para><!-- ##### MACRO G_TYPE_ULONG ##### --><para>The fundamental type corresponding to #gulong.</para><!-- ##### MACRO G_TYPE_INT64 ##### --><para>The fundamental type corresponding to #gint64.</para><!-- ##### MACRO G_TYPE_UINT64 ##### --><para>The fundamental type corresponding to #guint64.</para><!-- ##### MACRO G_TYPE_ENUM ##### --><para>The fundamental type from which all enumeration types are derived.</para><!-- ##### MACRO G_TYPE_FLAGS ##### --><para>The fundamental type from which all flags types are derived.</para><!-- ##### MACRO G_TYPE_FLOAT ##### --><para>The fundamental type corresponding to #gfloat.</para><!-- ##### MACRO G_TYPE_DOUBLE ##### --><para>The fundamental type corresponding to #gdouble.</para><!-- ##### MACRO G_TYPE_STRING ##### --><para>The fundamental type corresponding to nul-terminated C strings.</para><!-- ##### MACRO G_TYPE_POINTER ##### --><para>The fundamental type corresponding to #gpointer.</para><!-- ##### MACRO G_TYPE_BOXED ##### --><para>The fundamental type from which all boxed types are derived.</para><!-- ##### MACRO G_TYPE_PARAM ##### --><para>The fundamental type from which all #GParamSpec types are derived.</para><!-- ##### MACRO G_TYPE_OBJECT ##### --><para>The fundamental type for #GObject.</para><!-- ##### MACRO G_TYPE_GTYPE ##### --><para>The type for #GType.</para><!-- ##### MACRO G_TYPE_RESERVED_GLIB_FIRST ##### --><para>First fundamental type number to create a new fundamental type id withG_TYPE_MAKE_FUNDAMENTAL() reserved for GLib.</para><!-- ##### MACRO G_TYPE_RESERVED_GLIB_LAST ##### --><para>Last fundamental type number reserved for GLib.</para><!-- ##### MACRO G_TYPE_RESERVED_BSE_FIRST ##### --><para>First fundamental type number to create a new fundamental type id withG_TYPE_MAKE_FUNDAMENTAL() reserved for BSE.</para><!-- ##### MACRO G_TYPE_RESERVED_BSE_LAST ##### --><para>Last fundamental type number reserved for BSE.</para><!-- ##### MACRO G_TYPE_RESERVED_USER_FIRST ##### --><para>First available fundamental type number to create new fundamental type id with G_TYPE_MAKE_FUNDAMENTAL().</para><!--Local variables:mode: sgmlsgml-parent-document: ("../gobject-docs.sgml" "book" "refsect2" "")End:-->

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -