Repository navigation
Expand file tree
/
Copy pathexample3.c
More file actions
64 lines (52 loc) · 1.35 KB
/
Copy pathexample3.c
File metadata and controls
64 lines (52 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <glib-object.h>
#define T_TYPE_DOUBLE (t_double_get_type ())
typedef struct _TDouble TDouble;
struct _TDouble {
GObject parent;
double value;
};
typedef struct _TDoubleClass TDoubleClass;
struct _TDoubleClass {
GObjectClass parent_class;
};
static void
t_double_class_init (TDoubleClass *class) {
}
static void
t_double_init (TDouble *d) {
}
GType
t_double_get_type (void) {
static GType type = 0;
GTypeInfo info;
if (type == 0) {
info.class_size = sizeof (TDoubleClass);
info.base_init = NULL;
info.base_finalize = NULL;
info.class_init = (GClassInitFunc) t_double_class_init;
info.class_finalize = NULL;
info.class_data = NULL;
info.instance_size = sizeof (TDouble);
info.n_preallocs = 0;
info.instance_init = (GInstanceInitFunc) t_double_init;
info.value_table = NULL;
type = g_type_register_static (G_TYPE_OBJECT, "TDouble", &info, 0);
}
return type;
}
int
main (int argc, char **argv) {
GType dtype;
TDouble *d;
dtype = t_double_get_type (); /* or d = T_TYPE_DOUBLE */
if (dtype)
g_print ("Registration was a success. The type is %lx.\n", dtype);
else
g_print ("Registration failed.\n");
d = g_object_new (T_TYPE_DOUBLE, NULL);
if (d)
g_print ("Instantiation was a success. The instance address is %p.\n", d);
else
g_print ("Instantiation failed.\n");
return 0;
}