4 * Copyright IBM, Corp. 2011
7 * Anthony Liguori <aliguori@us.ibm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
13 #include "qemu/object.h"
14 #include "qemu-common.h"
15 #include "qapi/qapi-visit-core.h"
16 #include "qapi/string-input-visitor.h"
17 #include "qapi/string-output-visitor.h"
19 /* TODO: replace QObject with a simpler visitor to avoid a dependency
20 * of the QOM core on QObject? */
21 #include "qemu/qom-qobject.h"
27 #define MAX_INTERFACES 32
29 typedef struct InterfaceImpl InterfaceImpl
;
30 typedef struct TypeImpl TypeImpl
;
45 void (*class_init
)(ObjectClass
*klass
, void *data
);
46 void (*class_base_init
)(ObjectClass
*klass
, void *data
);
47 void (*class_finalize
)(ObjectClass
*klass
, void *data
);
51 void (*instance_init
)(Object
*obj
);
52 void (*instance_finalize
)(Object
*obj
);
57 TypeImpl
*parent_type
;
62 InterfaceImpl interfaces
[MAX_INTERFACES
];
65 static Type type_interface
;
67 static GHashTable
*type_table_get(void)
69 static GHashTable
*type_table
;
71 if (type_table
== NULL
) {
72 type_table
= g_hash_table_new(g_str_hash
, g_str_equal
);
78 static void type_table_add(TypeImpl
*ti
)
80 g_hash_table_insert(type_table_get(), (void *)ti
->name
, ti
);
83 static TypeImpl
*type_table_lookup(const char *name
)
85 return g_hash_table_lookup(type_table_get(), name
);
88 static TypeImpl
*type_register_internal(const TypeInfo
*info
)
90 TypeImpl
*ti
= g_malloc0(sizeof(*ti
));
93 g_assert(info
->name
!= NULL
);
95 if (type_table_lookup(info
->name
) != NULL
) {
96 fprintf(stderr
, "Registering `%s' which already exists\n", info
->name
);
100 ti
->name
= g_strdup(info
->name
);
101 ti
->parent
= g_strdup(info
->parent
);
103 ti
->class_size
= info
->class_size
;
104 ti
->instance_size
= info
->instance_size
;
106 ti
->class_init
= info
->class_init
;
107 ti
->class_base_init
= info
->class_base_init
;
108 ti
->class_finalize
= info
->class_finalize
;
109 ti
->class_data
= info
->class_data
;
111 ti
->instance_init
= info
->instance_init
;
112 ti
->instance_finalize
= info
->instance_finalize
;
114 ti
->abstract
= info
->abstract
;
116 for (i
= 0; info
->interfaces
&& info
->interfaces
[i
].type
; i
++) {
117 ti
->interfaces
[i
].typename
= g_strdup(info
->interfaces
[i
].type
);
119 ti
->num_interfaces
= i
;
126 TypeImpl
*type_register(const TypeInfo
*info
)
128 assert(info
->parent
);
129 return type_register_internal(info
);
132 TypeImpl
*type_register_static(const TypeInfo
*info
)
134 return type_register(info
);
137 static TypeImpl
*type_get_by_name(const char *name
)
143 return type_table_lookup(name
);
146 static TypeImpl
*type_get_parent(TypeImpl
*type
)
148 if (!type
->parent_type
&& type
->parent
) {
149 type
->parent_type
= type_get_by_name(type
->parent
);
150 g_assert(type
->parent_type
!= NULL
);
153 return type
->parent_type
;
156 static bool type_has_parent(TypeImpl
*type
)
158 return (type
->parent
!= NULL
);
161 static size_t type_class_get_size(TypeImpl
*ti
)
163 if (ti
->class_size
) {
164 return ti
->class_size
;
167 if (type_has_parent(ti
)) {
168 return type_class_get_size(type_get_parent(ti
));
171 return sizeof(ObjectClass
);
174 static size_t type_object_get_size(TypeImpl
*ti
)
176 if (ti
->instance_size
) {
177 return ti
->instance_size
;
180 if (type_has_parent(ti
)) {
181 return type_object_get_size(type_get_parent(ti
));
187 static bool type_is_ancestor(TypeImpl
*type
, TypeImpl
*target_type
)
191 /* Check if typename is a direct ancestor of type */
193 if (type
== target_type
) {
197 type
= type_get_parent(type
);
203 static void type_initialize(TypeImpl
*ti
);
205 static void type_initialize_interface(TypeImpl
*ti
, const char *parent
)
207 InterfaceClass
*new_iface
;
209 TypeImpl
*iface_impl
;
211 info
.parent
= parent
;
212 info
.name
= g_strdup_printf("%s::%s", ti
->name
, info
.parent
);
213 info
.abstract
= true;
215 iface_impl
= type_register(&info
);
216 type_initialize(iface_impl
);
217 g_free((char *)info
.name
);
219 new_iface
= (InterfaceClass
*)iface_impl
->class;
220 new_iface
->concrete_class
= ti
->class;
222 ti
->class->interfaces
= g_slist_append(ti
->class->interfaces
,
226 static void type_initialize(TypeImpl
*ti
)
234 ti
->class_size
= type_class_get_size(ti
);
235 ti
->instance_size
= type_object_get_size(ti
);
237 ti
->class = g_malloc0(ti
->class_size
);
239 parent
= type_get_parent(ti
);
241 type_initialize(parent
);
245 g_assert(parent
->class_size
<= ti
->class_size
);
246 memcpy(ti
->class, parent
->class, parent
->class_size
);
248 for (e
= parent
->class->interfaces
; e
; e
= e
->next
) {
249 ObjectClass
*iface
= e
->data
;
250 type_initialize_interface(ti
, object_class_get_name(iface
));
253 for (i
= 0; i
< ti
->num_interfaces
; i
++) {
254 TypeImpl
*t
= type_get_by_name(ti
->interfaces
[i
].typename
);
255 for (e
= ti
->class->interfaces
; e
; e
= e
->next
) {
256 TypeImpl
*target_type
= OBJECT_CLASS(e
->data
)->type
;
258 if (type_is_ancestor(target_type
, t
)) {
267 type_initialize_interface(ti
, ti
->interfaces
[i
].typename
);
271 ti
->class->type
= ti
;
274 if (parent
->class_base_init
) {
275 parent
->class_base_init(ti
->class, ti
->class_data
);
277 parent
= type_get_parent(parent
);
280 if (ti
->class_init
) {
281 ti
->class_init(ti
->class, ti
->class_data
);
287 static void object_init_with_type(Object
*obj
, TypeImpl
*ti
)
289 if (type_has_parent(ti
)) {
290 object_init_with_type(obj
, type_get_parent(ti
));
293 if (ti
->instance_init
) {
294 ti
->instance_init(obj
);
298 void object_initialize_with_type(void *data
, TypeImpl
*type
)
302 g_assert(type
!= NULL
);
303 type_initialize(type
);
305 g_assert(type
->instance_size
>= sizeof(Object
));
306 g_assert(type
->abstract
== false);
308 memset(obj
, 0, type
->instance_size
);
309 obj
->class = type
->class;
310 QTAILQ_INIT(&obj
->properties
);
311 object_init_with_type(obj
, type
);
314 void object_initialize(void *data
, const char *typename
)
316 TypeImpl
*type
= type_get_by_name(typename
);
318 object_initialize_with_type(data
, type
);
321 static inline bool object_property_is_child(ObjectProperty
*prop
)
323 return strstart(prop
->type
, "child<", NULL
);
326 static inline bool object_property_is_link(ObjectProperty
*prop
)
328 return strstart(prop
->type
, "link<", NULL
);
331 static void object_property_del_all(Object
*obj
)
333 while (!QTAILQ_EMPTY(&obj
->properties
)) {
334 ObjectProperty
*prop
= QTAILQ_FIRST(&obj
->properties
);
336 QTAILQ_REMOVE(&obj
->properties
, prop
, node
);
339 prop
->release(obj
, prop
->name
, prop
->opaque
);
348 static void object_property_del_child(Object
*obj
, Object
*child
, Error
**errp
)
350 ObjectProperty
*prop
;
352 QTAILQ_FOREACH(prop
, &obj
->properties
, node
) {
353 if (object_property_is_child(prop
) && prop
->opaque
== child
) {
354 object_property_del(obj
, prop
->name
, errp
);
360 void object_unparent(Object
*obj
)
363 object_property_del_child(obj
->parent
, obj
, NULL
);
367 static void object_deinit(Object
*obj
, TypeImpl
*type
)
369 if (type
->instance_finalize
) {
370 type
->instance_finalize(obj
);
373 if (type_has_parent(type
)) {
374 object_deinit(obj
, type_get_parent(type
));
378 void object_finalize(void *data
)
381 TypeImpl
*ti
= obj
->class->type
;
383 object_deinit(obj
, ti
);
384 object_property_del_all(obj
);
386 g_assert(obj
->ref
== 0);
389 Object
*object_new_with_type(Type type
)
393 g_assert(type
!= NULL
);
394 type_initialize(type
);
396 obj
= g_malloc(type
->instance_size
);
397 object_initialize_with_type(obj
, type
);
403 Object
*object_new(const char *typename
)
405 TypeImpl
*ti
= type_get_by_name(typename
);
407 return object_new_with_type(ti
);
410 void object_delete(Object
*obj
)
412 object_unparent(obj
);
413 g_assert(obj
->ref
== 1);
418 Object
*object_dynamic_cast(Object
*obj
, const char *typename
)
420 if (object_class_dynamic_cast(object_get_class(obj
), typename
)) {
427 Object
*object_dynamic_cast_assert(Object
*obj
, const char *typename
)
431 inst
= object_dynamic_cast(obj
, typename
);
434 fprintf(stderr
, "Object %p is not an instance of type %s\n",
442 ObjectClass
*object_class_dynamic_cast(ObjectClass
*class,
443 const char *typename
)
445 TypeImpl
*target_type
= type_get_by_name(typename
);
446 TypeImpl
*type
= class->type
;
447 ObjectClass
*ret
= NULL
;
449 if (type
->num_interfaces
&& type_is_ancestor(target_type
, type_interface
)) {
453 for (i
= class->interfaces
; i
; i
= i
->next
) {
454 ObjectClass
*target_class
= i
->data
;
456 if (type_is_ancestor(target_class
->type
, target_type
)) {
462 /* The match was ambiguous, don't allow a cast */
466 } else if (type_is_ancestor(type
, target_type
)) {
473 ObjectClass
*object_class_dynamic_cast_assert(ObjectClass
*class,
474 const char *typename
)
476 ObjectClass
*ret
= object_class_dynamic_cast(class, typename
);
479 fprintf(stderr
, "Object %p is not an instance of type %s\n",
487 const char *object_get_typename(Object
*obj
)
489 return obj
->class->type
->name
;
492 ObjectClass
*object_get_class(Object
*obj
)
497 const char *object_class_get_name(ObjectClass
*klass
)
499 return klass
->type
->name
;
502 ObjectClass
*object_class_by_name(const char *typename
)
504 TypeImpl
*type
= type_get_by_name(typename
);
510 type_initialize(type
);
515 ObjectClass
*object_class_get_parent(ObjectClass
*class)
517 TypeImpl
*type
= type_get_parent(class->type
);
523 type_initialize(type
);
528 typedef struct OCFData
530 void (*fn
)(ObjectClass
*klass
, void *opaque
);
531 const char *implements_type
;
532 bool include_abstract
;
536 static void object_class_foreach_tramp(gpointer key
, gpointer value
,
539 OCFData
*data
= opaque
;
540 TypeImpl
*type
= value
;
543 type_initialize(type
);
546 if (!data
->include_abstract
&& type
->abstract
) {
550 if (data
->implements_type
&&
551 !object_class_dynamic_cast(k
, data
->implements_type
)) {
555 data
->fn(k
, data
->opaque
);
558 void object_class_foreach(void (*fn
)(ObjectClass
*klass
, void *opaque
),
559 const char *implements_type
, bool include_abstract
,
562 OCFData data
= { fn
, implements_type
, include_abstract
, opaque
};
564 g_hash_table_foreach(type_table_get(), object_class_foreach_tramp
, &data
);
567 int object_child_foreach(Object
*obj
, int (*fn
)(Object
*child
, void *opaque
),
570 ObjectProperty
*prop
;
573 QTAILQ_FOREACH(prop
, &obj
->properties
, node
) {
574 if (object_property_is_child(prop
)) {
575 ret
= fn(prop
->opaque
, opaque
);
584 static void object_class_get_list_tramp(ObjectClass
*klass
, void *opaque
)
586 GSList
**list
= opaque
;
588 *list
= g_slist_prepend(*list
, klass
);
591 GSList
*object_class_get_list(const char *implements_type
,
592 bool include_abstract
)
596 object_class_foreach(object_class_get_list_tramp
,
597 implements_type
, include_abstract
, &list
);
601 void object_ref(Object
*obj
)
606 void object_unref(Object
*obj
)
608 g_assert(obj
->ref
> 0);
611 /* parent always holds a reference to its children */
613 object_finalize(obj
);
617 void object_property_add(Object
*obj
, const char *name
, const char *type
,
618 ObjectPropertyAccessor
*get
,
619 ObjectPropertyAccessor
*set
,
620 ObjectPropertyRelease
*release
,
621 void *opaque
, Error
**errp
)
623 ObjectProperty
*prop
= g_malloc0(sizeof(*prop
));
625 prop
->name
= g_strdup(name
);
626 prop
->type
= g_strdup(type
);
630 prop
->release
= release
;
631 prop
->opaque
= opaque
;
633 QTAILQ_INSERT_TAIL(&obj
->properties
, prop
, node
);
636 ObjectProperty
*object_property_find(Object
*obj
, const char *name
,
639 ObjectProperty
*prop
;
641 QTAILQ_FOREACH(prop
, &obj
->properties
, node
) {
642 if (strcmp(prop
->name
, name
) == 0) {
647 error_set(errp
, QERR_PROPERTY_NOT_FOUND
, "", name
);
651 void object_property_del(Object
*obj
, const char *name
, Error
**errp
)
653 ObjectProperty
*prop
= object_property_find(obj
, name
, errp
);
659 prop
->release(obj
, name
, prop
->opaque
);
662 QTAILQ_REMOVE(&obj
->properties
, prop
, node
);
669 void object_property_get(Object
*obj
, Visitor
*v
, const char *name
,
672 ObjectProperty
*prop
= object_property_find(obj
, name
, errp
);
678 error_set(errp
, QERR_PERMISSION_DENIED
);
680 prop
->get(obj
, v
, prop
->opaque
, name
, errp
);
684 void object_property_set(Object
*obj
, Visitor
*v
, const char *name
,
687 ObjectProperty
*prop
= object_property_find(obj
, name
, errp
);
693 error_set(errp
, QERR_PERMISSION_DENIED
);
695 prop
->set(obj
, v
, prop
->opaque
, name
, errp
);
699 void object_property_set_str(Object
*obj
, const char *value
,
700 const char *name
, Error
**errp
)
702 QString
*qstr
= qstring_from_str(value
);
703 object_property_set_qobject(obj
, QOBJECT(qstr
), name
, errp
);
708 char *object_property_get_str(Object
*obj
, const char *name
,
711 QObject
*ret
= object_property_get_qobject(obj
, name
, errp
);
718 qstring
= qobject_to_qstring(ret
);
720 error_set(errp
, QERR_INVALID_PARAMETER_TYPE
, name
, "string");
723 retval
= g_strdup(qstring_get_str(qstring
));
730 void object_property_set_link(Object
*obj
, Object
*value
,
731 const char *name
, Error
**errp
)
733 object_property_set_str(obj
, object_get_canonical_path(value
),
737 Object
*object_property_get_link(Object
*obj
, const char *name
,
740 char *str
= object_property_get_str(obj
, name
, errp
);
741 Object
*target
= NULL
;
744 target
= object_resolve_path(str
, NULL
);
746 error_set(errp
, QERR_DEVICE_NOT_FOUND
, str
);
754 void object_property_set_bool(Object
*obj
, bool value
,
755 const char *name
, Error
**errp
)
757 QBool
*qbool
= qbool_from_int(value
);
758 object_property_set_qobject(obj
, QOBJECT(qbool
), name
, errp
);
763 bool object_property_get_bool(Object
*obj
, const char *name
,
766 QObject
*ret
= object_property_get_qobject(obj
, name
, errp
);
773 qbool
= qobject_to_qbool(ret
);
775 error_set(errp
, QERR_INVALID_PARAMETER_TYPE
, name
, "boolean");
778 retval
= qbool_get_int(qbool
);
785 void object_property_set_int(Object
*obj
, int64_t value
,
786 const char *name
, Error
**errp
)
788 QInt
*qint
= qint_from_int(value
);
789 object_property_set_qobject(obj
, QOBJECT(qint
), name
, errp
);
794 int64_t object_property_get_int(Object
*obj
, const char *name
,
797 QObject
*ret
= object_property_get_qobject(obj
, name
, errp
);
804 qint
= qobject_to_qint(ret
);
806 error_set(errp
, QERR_INVALID_PARAMETER_TYPE
, name
, "int");
809 retval
= qint_get_int(qint
);
816 void object_property_parse(Object
*obj
, const char *string
,
817 const char *name
, Error
**errp
)
819 StringInputVisitor
*mi
;
820 mi
= string_input_visitor_new(string
);
821 object_property_set(obj
, string_input_get_visitor(mi
), name
, errp
);
823 string_input_visitor_cleanup(mi
);
826 char *object_property_print(Object
*obj
, const char *name
,
829 StringOutputVisitor
*mo
;
832 mo
= string_output_visitor_new();
833 object_property_get(obj
, string_output_get_visitor(mo
), name
, errp
);
834 string
= string_output_get_string(mo
);
835 string_output_visitor_cleanup(mo
);
839 const char *object_property_get_type(Object
*obj
, const char *name
, Error
**errp
)
841 ObjectProperty
*prop
= object_property_find(obj
, name
, errp
);
849 Object
*object_get_root(void)
854 root
= object_new("container");
860 static void object_get_child_property(Object
*obj
, Visitor
*v
, void *opaque
,
861 const char *name
, Error
**errp
)
863 Object
*child
= opaque
;
866 path
= object_get_canonical_path(child
);
867 visit_type_str(v
, &path
, name
, errp
);
871 static void object_finalize_child_property(Object
*obj
, const char *name
,
874 Object
*child
= opaque
;
879 void object_property_add_child(Object
*obj
, const char *name
,
880 Object
*child
, Error
**errp
)
884 type
= g_strdup_printf("child<%s>", object_get_typename(OBJECT(child
)));
886 object_property_add(obj
, name
, type
, object_get_child_property
,
887 NULL
, object_finalize_child_property
, child
, errp
);
890 g_assert(child
->parent
== NULL
);
896 static void object_get_link_property(Object
*obj
, Visitor
*v
, void *opaque
,
897 const char *name
, Error
**errp
)
899 Object
**child
= opaque
;
903 path
= object_get_canonical_path(*child
);
904 visit_type_str(v
, &path
, name
, errp
);
908 visit_type_str(v
, &path
, name
, errp
);
912 static void object_set_link_property(Object
*obj
, Visitor
*v
, void *opaque
,
913 const char *name
, Error
**errp
)
915 Object
**child
= opaque
;
917 bool ambiguous
= false;
922 type
= object_property_get_type(obj
, name
, NULL
);
924 visit_type_str(v
, &path
, name
, errp
);
929 if (strcmp(path
, "") != 0) {
932 /* Go from link<FOO> to FOO. */
933 target_type
= g_strndup(&type
[5], strlen(type
) - 6);
934 target
= object_resolve_path_type(path
, target_type
, &ambiguous
);
937 error_set(errp
, QERR_AMBIGUOUS_PATH
, path
);
942 target
= object_resolve_path(path
, &ambiguous
);
943 if (target
|| ambiguous
) {
944 error_set(errp
, QERR_INVALID_PARAMETER_TYPE
, name
, target_type
);
946 error_set(errp
, QERR_DEVICE_NOT_FOUND
, path
);
954 if (old_target
!= NULL
) {
955 object_unref(old_target
);
959 void object_property_add_link(Object
*obj
, const char *name
,
960 const char *type
, Object
**child
,
965 full_type
= g_strdup_printf("link<%s>", type
);
967 object_property_add(obj
, name
, full_type
,
968 object_get_link_property
,
969 object_set_link_property
,
975 gchar
*object_get_canonical_path(Object
*obj
)
977 Object
*root
= object_get_root();
978 char *newpath
= NULL
, *path
= NULL
;
980 while (obj
!= root
) {
981 ObjectProperty
*prop
= NULL
;
983 g_assert(obj
->parent
!= NULL
);
985 QTAILQ_FOREACH(prop
, &obj
->parent
->properties
, node
) {
986 if (!object_property_is_child(prop
)) {
990 if (prop
->opaque
== obj
) {
992 newpath
= g_strdup_printf("%s/%s", prop
->name
, path
);
996 path
= g_strdup(prop
->name
);
1002 g_assert(prop
!= NULL
);
1007 newpath
= g_strdup_printf("/%s", path
);
1013 Object
*object_resolve_path_component(Object
*parent
, gchar
*part
)
1015 ObjectProperty
*prop
= object_property_find(parent
, part
, NULL
);
1020 if (object_property_is_link(prop
)) {
1021 return *(Object
**)prop
->opaque
;
1022 } else if (object_property_is_child(prop
)) {
1023 return prop
->opaque
;
1029 static Object
*object_resolve_abs_path(Object
*parent
,
1031 const char *typename
,
1036 if (parts
[index
] == NULL
) {
1037 return object_dynamic_cast(parent
, typename
);
1040 if (strcmp(parts
[index
], "") == 0) {
1041 return object_resolve_abs_path(parent
, parts
, typename
, index
+ 1);
1044 child
= object_resolve_path_component(parent
, parts
[index
]);
1049 return object_resolve_abs_path(child
, parts
, typename
, index
+ 1);
1052 static Object
*object_resolve_partial_path(Object
*parent
,
1054 const char *typename
,
1058 ObjectProperty
*prop
;
1060 obj
= object_resolve_abs_path(parent
, parts
, typename
, 0);
1062 QTAILQ_FOREACH(prop
, &parent
->properties
, node
) {
1065 if (!object_property_is_child(prop
)) {
1069 found
= object_resolve_partial_path(prop
->opaque
, parts
,
1070 typename
, ambiguous
);
1081 if (ambiguous
&& *ambiguous
) {
1089 Object
*object_resolve_path_type(const char *path
, const char *typename
,
1092 bool partial_path
= true;
1096 parts
= g_strsplit(path
, "/", 0);
1097 if (parts
== NULL
|| parts
[0] == NULL
) {
1099 return object_get_root();
1102 if (strcmp(parts
[0], "") == 0) {
1103 partial_path
= false;
1110 obj
= object_resolve_partial_path(object_get_root(), parts
,
1111 typename
, ambiguous
);
1113 obj
= object_resolve_abs_path(object_get_root(), parts
, typename
, 1);
1121 Object
*object_resolve_path(const char *path
, bool *ambiguous
)
1123 return object_resolve_path_type(path
, TYPE_OBJECT
, ambiguous
);
1126 typedef struct StringProperty
1128 char *(*get
)(Object
*, Error
**);
1129 void (*set
)(Object
*, const char *, Error
**);
1132 static void property_get_str(Object
*obj
, Visitor
*v
, void *opaque
,
1133 const char *name
, Error
**errp
)
1135 StringProperty
*prop
= opaque
;
1138 value
= prop
->get(obj
, errp
);
1140 visit_type_str(v
, &value
, name
, errp
);
1145 static void property_set_str(Object
*obj
, Visitor
*v
, void *opaque
,
1146 const char *name
, Error
**errp
)
1148 StringProperty
*prop
= opaque
;
1150 Error
*local_err
= NULL
;
1152 visit_type_str(v
, &value
, name
, &local_err
);
1154 error_propagate(errp
, local_err
);
1158 prop
->set(obj
, value
, errp
);
1162 static void property_release_str(Object
*obj
, const char *name
,
1165 StringProperty
*prop
= opaque
;
1169 void object_property_add_str(Object
*obj
, const char *name
,
1170 char *(*get
)(Object
*, Error
**),
1171 void (*set
)(Object
*, const char *, Error
**),
1174 StringProperty
*prop
= g_malloc0(sizeof(*prop
));
1179 object_property_add(obj
, name
, "string",
1180 get
? property_get_str
: NULL
,
1181 set
? property_set_str
: NULL
,
1182 property_release_str
,
1186 static char *qdev_get_type(Object
*obj
, Error
**errp
)
1188 return g_strdup(object_get_typename(obj
));
1191 static void object_instance_init(Object
*obj
)
1193 object_property_add_str(obj
, "type", qdev_get_type
, NULL
, NULL
);
1196 static void register_types(void)
1198 static TypeInfo interface_info
= {
1199 .name
= TYPE_INTERFACE
,
1200 .class_size
= sizeof(InterfaceClass
),
1204 static TypeInfo object_info
= {
1205 .name
= TYPE_OBJECT
,
1206 .instance_size
= sizeof(Object
),
1207 .instance_init
= object_instance_init
,
1211 type_interface
= type_register_internal(&interface_info
);
1212 type_register_internal(&object_info
);
1215 type_init(register_types
)