1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>Non-instantiable non-classed fundamental types</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
7 <link rel="home" href="index.html" title="GObject Reference Manual">
8 <link rel="up" href="chapter-gtype.html" title="The GLib Dynamic Type System">
9 <link rel="prev" href="gtype-conventions.html" title="Conventions">
10 <link rel="next" href="gtype-instantiable-classed.html" title="Instantiable classed types: objects">
11 <meta name="generator" content="GTK-Doc V1.18 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
14 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
15 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
16 <td><a accesskey="p" href="gtype-conventions.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
17 <td><a accesskey="u" href="chapter-gtype.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
18 <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
19 <th width="100%" align="center">GObject Reference Manual</th>
20 <td><a accesskey="n" href="gtype-instantiable-classed.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
23 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
24 <a name="gtype-non-instantiable"></a>Non-instantiable non-classed fundamental types</h2></div></div></div>
26 A lot of types are not instantiable by the type system and do not have
27 a class. Most of these types are fundamental trivial types such as <span class="emphasis"><em>gchar</em></span>,
28 registered in <code class="function">_g_value_types_init</code> (in <code class="filename">gvaluetypes.c</code>).
31 To register such a type in the type system, you just need to fill the
32 <a class="link" href="gobject-Type-Information.html#GTypeInfo" title="struct GTypeInfo"><span class="type">GTypeInfo</span></a> structure with zeros since these types are also most of the time
35 <pre class="programlisting">
39 NULL, /* base_destroy */
40 NULL, /* class_init */
41 NULL, /* class_destroy */
42 NULL, /* class_data */
43 0, /* instance_size */
45 NULL, /* instance_init */
46 NULL, /* value_table */
48 static const GTypeValueTable value_table = {
49 value_init_long0, /* value_init */
50 NULL, /* value_free */
51 value_copy_long0, /* value_copy */
52 NULL, /* value_peek_pointer */
53 "i", /* collect_format */
54 value_collect_int, /* collect_value */
55 "p", /* lcopy_format */
56 value_lcopy_char, /* lcopy_value */
58 info.value_table = &value_table;
59 type = g_type_register_fundamental (G_TYPE_CHAR, "gchar", &info, &finfo, 0);
64 Having non-instantiable types might seem a bit useless: what good is a type
65 if you cannot instantiate an instance of that type ? Most of these types
66 are used in conjunction with <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a>s: a GValue is initialized
67 with an integer or a string and it is passed around by using the registered
68 type's value_table. <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a>s (and by extension these trivial fundamental
69 types) are most useful when used in conjunction with object properties and signals.
74 Generated by GTK-Doc V1.18</div>