2 #include <glib-object.h>
8 #define G_TYPE_TEST (my_test_get_type ())
9 #define MY_TEST(test) (G_TYPE_CHECK_INSTANCE_CAST ((test), G_TYPE_TEST, GTest))
10 #define MY_IS_TEST(test) (G_TYPE_CHECK_INSTANCE_TYPE ((test), G_TYPE_TEST))
11 #define MY_TEST_CLASS(tclass) (G_TYPE_CHECK_CLASS_CAST ((tclass), G_TYPE_TEST, GTestClass))
12 #define MY_IS_TEST_CLASS(tclass) (G_TYPE_CHECK_CLASS_TYPE ((tclass), G_TYPE_TEST))
13 #define MY_TEST_GET_CLASS(test) (G_TYPE_INSTANCE_GET_CLASS ((test), G_TYPE_TEST, GTestClass))
15 typedef struct _GTest GTest
;
16 typedef struct _GTestClass GTestClass
;
25 GObjectClass parent_class
;
28 static GType
my_test_get_type (void);
30 static void my_test_class_init (GTestClass
* klass
);
31 static void my_test_init (GTest
* test
);
32 static void my_test_dispose (GObject
* object
);
34 static GObjectClass
*parent_class
= NULL
;
37 my_test_get_type (void)
39 static GType test_type
= 0;
42 const GTypeInfo test_info
= {
46 (GClassInitFunc
) my_test_class_init
,
51 (GInstanceInitFunc
) my_test_init
,
55 test_type
= g_type_register_static (G_TYPE_OBJECT
, "GTest",
62 my_test_class_init (GTestClass
* klass
)
64 GObjectClass
*gobject_class
;
66 gobject_class
= (GObjectClass
*) klass
;
68 parent_class
= g_type_class_ref (G_TYPE_OBJECT
);
70 gobject_class
->dispose
= my_test_dispose
;
74 my_test_init (GTest
* test
)
76 g_print ("init %p\n", test
);
80 my_test_dispose (GObject
* object
)
84 test
= MY_TEST (object
);
86 g_print ("dispose %p!\n", test
);
88 G_OBJECT_CLASS (parent_class
)->dispose (object
);
92 my_test_do_refcount (GTest
* test
)
95 if (i
++ % 100000 == 0)
98 g_object_unref (test
);
102 main (int argc
, char **argv
)
107 g_print ("START: %s\n", argv
[0]);
108 g_log_set_always_fatal (G_LOG_LEVEL_WARNING
| G_LOG_LEVEL_CRITICAL
| g_log_set_always_fatal (G_LOG_FATAL_MASK
));
110 test
= g_object_new (G_TYPE_TEST
, NULL
);
112 for (i
=0; i
<100000000; i
++) {
113 my_test_do_refcount (test
);
116 g_object_unref (test
);