1
1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
5
<title>The GLib Dynamic Type System</title>
6
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
7
<link rel="start" href="index.html" title="GObject Reference Manual">
8
<link rel="up" href="pt01.html" title="Part I. Concepts">
6
<meta name="generator" content="DocBook XSL Stylesheets V1.74.0">
7
<link rel="home" href="index.html" title="GObject Reference Manual">
8
<link rel="up" href="pt01.html" title="Part I. Concepts">
9
9
<link rel="prev" href="ch01s02.html" title="Exporting a C API">
10
10
<link rel="next" href="gtype-conventions.html" title="Conventions">
11
<meta name="generator" content="GTK-Doc V1.9 (XML mode)">
11
<meta name="generator" content="GTK-Doc V1.11 (XML mode)">
12
12
<link rel="stylesheet" href="style.css" type="text/css">
13
13
<link rel="preface" href="pr01.html" title="Introduction">
14
<link rel="part" href="pt01.html" title="Part I. Concepts">
14
<link rel="part" href="pt01.html" title="Part I. Concepts">
15
15
<link rel="chapter" href="chapter-intro.html" title="Background">
16
16
<link rel="chapter" href="chapter-gtype.html" title="The GLib Dynamic Type System">
17
17
<link rel="chapter" href="chapter-gobject.html" title="The GObject base class">
18
18
<link rel="chapter" href="chapter-signal.html" title="The GObject messaging system">
19
19
<link rel="reference" href="rn01.html" title="API Reference">
20
20
<link rel="reference" href="rn02.html" title="Tools Reference">
21
<link rel="part" href="pt02.html" title="Part IV. Tutorial">
21
<link rel="part" href="pt02.html" title="Part IV. Tutorial">
22
22
<link rel="chapter" href="howto-gobject.html" title="How to define and implement a new GObject">
23
23
<link rel="chapter" href="howto-interface.html" title="How to define and implement interfaces">
24
24
<link rel="chapter" href="howto-signals.html" title="How to create and use signals">
25
<link rel="part" href="pt03.html" title="Part V. Related Tools">
25
<link rel="part" href="pt03.html" title="Part V. Related Tools">
26
<link rel="chapter" href="tools-vala.html" title="Vala">
26
27
<link rel="chapter" href="tools-gob.html" title="GObject builder">
27
28
<link rel="chapter" href="tools-ginspector.html" title="Graphical inspection of GObjects">
28
29
<link rel="chapter" href="tools-refdb.html" title="Debugging reference count problems">
36
37
<link rel="index" href="ix07.html" title="Index of new symbols in 2.10">
37
38
<link rel="index" href="ix08.html" title="Index of new symbols in 2.12">
38
39
<link rel="index" href="ix09.html" title="Index of new symbols in 2.14">
40
<link rel="index" href="ix10.html" title="Index of new symbols in 2.14">
40
42
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
41
43
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
104
<code class="function"><a class="link" href="gobject-Type-Information.html#g-type-register-static">g_type_register_static</a></code> and
105
<code class="function"><a class="link" href="gobject-Type-Information.html#g-type-register-fundamental">g_type_register_fundamental</a></code>
106
<code class="function"><a class="link" href="gobject-Type-Information.html#g-type-register-static" title="g_type_register_static ()">g_type_register_static</a></code> and
107
<code class="function"><a class="link" href="gobject-Type-Information.html#g-type-register-fundamental" title="g_type_register_fundamental ()">g_type_register_fundamental</a></code>
106
108
are the C functions, defined in
107
109
<code class="filename">gtype.h</code> and implemented in <code class="filename">gtype.c</code>
108
which you should use to register a new <span class="type"><a class="link" href="gobject-Type-Information.html#GType">GType</a></span> in the program's type system.
110
which you should use to register a new <span class="type"><a class="link" href="gobject-Type-Information.html#GType" title="GType">GType</a></span> in the program's type system.
109
111
It is not likely you will ever need to use
110
<code class="function"><a class="link" href="gobject-Type-Information.html#g-type-register-fundamental">g_type_register_fundamental</a></code> (you have to be Tim Janik
112
<code class="function"><a class="link" href="gobject-Type-Information.html#g-type-register-fundamental" title="g_type_register_fundamental ()">g_type_register_fundamental</a></code> (you have to be Tim Janik
111
113
to do that) but in case you want to, the last chapter explains how to create
112
114
new fundamental types.
113
<sup>[<a name="id2809261" href="#ftn.id2809261" class="footnote">2</a>]</sup>
115
<sup>[<a name="id3008332" href="#ftn.id3008332" class="footnote">2</a>]</sup>
116
118
Fundamental types are top-level types which do not derive from any other type
117
119
while other non-fundamental types derive from other types.
118
Upon initialization by <code class="function"><a class="link" href="gobject-Type-Information.html#g-type-init">g_type_init</a></code>, the type system not
120
Upon initialization by <code class="function"><a class="link" href="gobject-Type-Information.html#g-type-init" title="g_type_init ()">g_type_init</a></code>, the type system not
119
121
only initializes its internal data structures but it also registers a number of core
120
122
types: some of these are fundamental types. Others are types derived from these
121
123
fundamental types.
126
128
<div class="itemizedlist"><ul type="disc">
128
class size: the class_size field in <span class="type"><a class="link" href="gobject-Type-Information.html#GTypeInfo">GTypeInfo</a></span>.
130
class size: the class_size field in <span class="type"><a class="link" href="gobject-Type-Information.html#GTypeInfo" title="GTypeInfo">GTypeInfo</a></span>.
131
133
class initialization functions (C++ constructor): the base_init and
132
class_init fields in <span class="type"><a class="link" href="gobject-Type-Information.html#GTypeInfo">GTypeInfo</a></span>.
134
class_init fields in <span class="type"><a class="link" href="gobject-Type-Information.html#GTypeInfo" title="GTypeInfo">GTypeInfo</a></span>.
135
137
class destruction functions (C++ destructor): the base_finalize and
136
class_finalize fields in <span class="type"><a class="link" href="gobject-Type-Information.html#GTypeInfo">GTypeInfo</a></span>.
138
class_finalize fields in <span class="type"><a class="link" href="gobject-Type-Information.html#GTypeInfo" title="GTypeInfo">GTypeInfo</a></span>.
139
141
instance size (C++ parameter to new): the instance_size field in
140
<span class="type"><a class="link" href="gobject-Type-Information.html#GTypeInfo">GTypeInfo</a></span>.
142
<span class="type"><a class="link" href="gobject-Type-Information.html#GTypeInfo" title="GTypeInfo">GTypeInfo</a></span>.
143
145
instantiation policy (C++ type of new operator): the n_preallocs
144
field in <span class="type"><a class="link" href="gobject-Type-Information.html#GTypeInfo">GTypeInfo</a></span>.
146
field in <span class="type"><a class="link" href="gobject-Type-Information.html#GTypeInfo" title="GTypeInfo">GTypeInfo</a></span>.
147
149
copy functions (C++ copy operators): the value_table field in
148
<span class="type"><a class="link" href="gobject-Type-Information.html#GTypeInfo">GTypeInfo</a></span>.
150
<span class="type"><a class="link" href="gobject-Type-Information.html#GTypeInfo" title="GTypeInfo">GTypeInfo</a></span>.
151
type characteristic flags: <span class="type"><a class="link" href="gobject-Type-Information.html#GTypeFlags">GTypeFlags</a></span>.
153
type characteristic flags: <span class="type"><a class="link" href="gobject-Type-Information.html#GTypeFlags" title="enum GTypeFlags">GTypeFlags</a></span>.
155
Fundamental types are also defined by a set of <span class="type"><a class="link" href="gobject-Type-Information.html#GTypeFundamentalFlags">GTypeFundamentalFlags</a></span>
156
which are stored in a <span class="type"><a class="link" href="gobject-Type-Information.html#GTypeFundamentalInfo">GTypeFundamentalInfo</a></span>.
157
Fundamental types are also defined by a set of <span class="type"><a class="link" href="gobject-Type-Information.html#GTypeFundamentalFlags" title="enum GTypeFundamentalFlags">GTypeFundamentalFlags</a></span>
158
which are stored in a <span class="type"><a class="link" href="gobject-Type-Information.html#GTypeFundamentalInfo" title="GTypeFundamentalInfo">GTypeFundamentalInfo</a></span>.
157
159
Non-fundamental types are furthermore defined by the type of their parent which is
158
passed as the parent_type parameter to <code class="function"><a class="link" href="gobject-Type-Information.html#g-type-register-static">g_type_register_static</a></code>
159
and <code class="function"><a class="link" href="gobject-Type-Information.html#g-type-register-dynamic">g_type_register_dynamic</a></code>.
160
passed as the parent_type parameter to <code class="function"><a class="link" href="gobject-Type-Information.html#g-type-register-static" title="g_type_register_static ()">g_type_register_static</a></code>
161
and <code class="function"><a class="link" href="gobject-Type-Information.html#g-type-register-dynamic" title="g_type_register_dynamic ()">g_type_register_dynamic</a></code>.
161
163
<div class="sect1" lang="en">
162
164
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
167
169
they can all be manipulated through a single API to copy/assign them.
170
The <span class="type"><a class="link" href="gobject-Generic-values.html#GValue">GValue</a></span> structure is used as an abstract container for all of these
172
The <span class="type"><a class="link" href="gobject-Generic-values.html#GValue" title="GValue">GValue</a></span> structure is used as an abstract container for all of these
171
173
types. Its simplistic API (defined in <code class="filename">gobject/gvalue.h</code>) can be
172
174
used to invoke the value_table functions registered
173
during type registration: for example <code class="function"><a class="link" href="gobject-Generic-values.html#g-value-copy">g_value_copy</a></code> copies the
174
content of a <span class="type"><a class="link" href="gobject-Generic-values.html#GValue">GValue</a></span> to another <span class="type"><a class="link" href="gobject-Generic-values.html#GValue">GValue</a></span>. This is similar
175
during type registration: for example <code class="function"><a class="link" href="gobject-Generic-values.html#g-value-copy" title="g_value_copy ()">g_value_copy</a></code> copies the
176
content of a <span class="type"><a class="link" href="gobject-Generic-values.html#GValue" title="GValue">GValue</a></span> to another <span class="type"><a class="link" href="gobject-Generic-values.html#GValue" title="GValue">GValue</a></span>. This is similar
175
177
to a C++ assignment which invokes the C++ copy operator to modify the default
176
178
bit-by-bit copy semantics of C++/C structures/classes.
275
277
<div class="footnotes">
276
278
<br><hr width="100" align="left">
277
<div class="footnote"><p><sup>[<a name="ftn.id2809261" href="#id2809261" class="para">2</a>] </sup>
279
<div class="footnote"><p><sup>[<a name="ftn.id3008332" href="#id3008332" class="para">2</a>] </sup>
278
280
Please note that there exists another registration function: the
279
<code class="function"><a class="link" href="gobject-Type-Information.html#g-type-register-dynamic">g_type_register_dynamic</a></code>. We will not discuss this
281
<code class="function"><a class="link" href="gobject-Type-Information.html#g-type-register-dynamic" title="g_type_register_dynamic ()">g_type_register_dynamic</a></code>. We will not discuss this
280
282
function here since its use is very similar to the <code class="function">_static</code>
289
Generated by GTK-Doc V1.11</div>