target-arm: Fix warn about implicit conversion
[qemu/cris-port.git] / include / qom / object.h
blob5ecc2d166d0847b4859c4486380bfdb5130a3603
1 /*
2 * QEMU Object Model
4 * Copyright IBM, Corp. 2011
6 * Authors:
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.
14 #ifndef QEMU_OBJECT_H
15 #define QEMU_OBJECT_H
17 #include "qapi-types.h"
18 #include "qemu/queue.h"
20 struct TypeImpl;
21 typedef struct TypeImpl *Type;
23 typedef struct ObjectClass ObjectClass;
24 typedef struct Object Object;
26 typedef struct TypeInfo TypeInfo;
28 typedef struct InterfaceClass InterfaceClass;
29 typedef struct InterfaceInfo InterfaceInfo;
31 #define TYPE_OBJECT "object"
33 /**
34 * SECTION:object.h
35 * @title:Base Object Type System
36 * @short_description: interfaces for creating new types and objects
38 * The QEMU Object Model provides a framework for registering user creatable
39 * types and instantiating objects from those types. QOM provides the following
40 * features:
42 * - System for dynamically registering types
43 * - Support for single-inheritance of types
44 * - Multiple inheritance of stateless interfaces
46 * <example>
47 * <title>Creating a minimal type</title>
48 * <programlisting>
49 * #include "qdev.h"
51 * #define TYPE_MY_DEVICE "my-device"
53 * // No new virtual functions: we can reuse the typedef for the
54 * // superclass.
55 * typedef DeviceClass MyDeviceClass;
56 * typedef struct MyDevice
57 * {
58 * DeviceState parent;
60 * int reg0, reg1, reg2;
61 * } MyDevice;
63 * static const TypeInfo my_device_info = {
64 * .name = TYPE_MY_DEVICE,
65 * .parent = TYPE_DEVICE,
66 * .instance_size = sizeof(MyDevice),
67 * };
69 * static void my_device_register_types(void)
70 * {
71 * type_register_static(&my_device_info);
72 * }
74 * type_init(my_device_register_types)
75 * </programlisting>
76 * </example>
78 * In the above example, we create a simple type that is described by #TypeInfo.
79 * #TypeInfo describes information about the type including what it inherits
80 * from, the instance and class size, and constructor/destructor hooks.
82 * Every type has an #ObjectClass associated with it. #ObjectClass derivatives
83 * are instantiated dynamically but there is only ever one instance for any
84 * given type. The #ObjectClass typically holds a table of function pointers
85 * for the virtual methods implemented by this type.
87 * Using object_new(), a new #Object derivative will be instantiated. You can
88 * cast an #Object to a subclass (or base-class) type using
89 * object_dynamic_cast(). You typically want to define macro wrappers around
90 * OBJECT_CHECK() and OBJECT_CLASS_CHECK() to make it easier to convert to a
91 * specific type:
93 * <example>
94 * <title>Typecasting macros</title>
95 * <programlisting>
96 * #define MY_DEVICE_GET_CLASS(obj) \
97 * OBJECT_GET_CLASS(MyDeviceClass, obj, TYPE_MY_DEVICE)
98 * #define MY_DEVICE_CLASS(klass) \
99 * OBJECT_CLASS_CHECK(MyDeviceClass, klass, TYPE_MY_DEVICE)
100 * #define MY_DEVICE(obj) \
101 * OBJECT_CHECK(MyDevice, obj, TYPE_MY_DEVICE)
102 * </programlisting>
103 * </example>
105 * # Class Initialization #
107 * Before an object is initialized, the class for the object must be
108 * initialized. There is only one class object for all instance objects
109 * that is created lazily.
111 * Classes are initialized by first initializing any parent classes (if
112 * necessary). After the parent class object has initialized, it will be
113 * copied into the current class object and any additional storage in the
114 * class object is zero filled.
116 * The effect of this is that classes automatically inherit any virtual
117 * function pointers that the parent class has already initialized. All
118 * other fields will be zero filled.
120 * Once all of the parent classes have been initialized, #TypeInfo::class_init
121 * is called to let the class being instantiated provide default initialize for
122 * its virtual functions. Here is how the above example might be modified
123 * to introduce an overridden virtual function:
125 * <example>
126 * <title>Overriding a virtual function</title>
127 * <programlisting>
128 * #include "qdev.h"
130 * void my_device_class_init(ObjectClass *klass, void *class_data)
132 * DeviceClass *dc = DEVICE_CLASS(klass);
133 * dc->reset = my_device_reset;
136 * static const TypeInfo my_device_info = {
137 * .name = TYPE_MY_DEVICE,
138 * .parent = TYPE_DEVICE,
139 * .instance_size = sizeof(MyDevice),
140 * .class_init = my_device_class_init,
141 * };
142 * </programlisting>
143 * </example>
145 * Introducing new virtual methods requires a class to define its own
146 * struct and to add a .class_size member to the #TypeInfo. Each method
147 * will also have a wrapper function to call it easily:
149 * <example>
150 * <title>Defining an abstract class</title>
151 * <programlisting>
152 * #include "qdev.h"
154 * typedef struct MyDeviceClass
156 * DeviceClass parent;
158 * void (*frobnicate) (MyDevice *obj);
159 * } MyDeviceClass;
161 * static const TypeInfo my_device_info = {
162 * .name = TYPE_MY_DEVICE,
163 * .parent = TYPE_DEVICE,
164 * .instance_size = sizeof(MyDevice),
165 * .abstract = true, // or set a default in my_device_class_init
166 * .class_size = sizeof(MyDeviceClass),
167 * };
169 * void my_device_frobnicate(MyDevice *obj)
171 * MyDeviceClass *klass = MY_DEVICE_GET_CLASS(obj);
173 * klass->frobnicate(obj);
175 * </programlisting>
176 * </example>
178 * # Interfaces #
180 * Interfaces allow a limited form of multiple inheritance. Instances are
181 * similar to normal types except for the fact that are only defined by
182 * their classes and never carry any state. You can dynamically cast an object
183 * to one of its #Interface types and vice versa.
185 * # Methods #
187 * A <emphasis>method</emphasis> is a function within the namespace scope of
188 * a class. It usually operates on the object instance by passing it as a
189 * strongly-typed first argument.
190 * If it does not operate on an object instance, it is dubbed
191 * <emphasis>class method</emphasis>.
193 * Methods cannot be overloaded. That is, the #ObjectClass and method name
194 * uniquely identity the function to be called; the signature does not vary
195 * except for trailing varargs.
197 * Methods are always <emphasis>virtual</emphasis>. Overriding a method in
198 * #TypeInfo.class_init of a subclass leads to any user of the class obtained
199 * via OBJECT_GET_CLASS() accessing the overridden function.
200 * The original function is not automatically invoked. It is the responsibility
201 * of the overriding class to determine whether and when to invoke the method
202 * being overridden.
204 * To invoke the method being overridden, the preferred solution is to store
205 * the original value in the overriding class before overriding the method.
206 * This corresponds to |[ {super,base}.method(...) ]| in Java and C#
207 * respectively; this frees the overriding class from hardcoding its parent
208 * class, which someone might choose to change at some point.
210 * <example>
211 * <title>Overriding a virtual method</title>
212 * <programlisting>
213 * typedef struct MyState MyState;
215 * typedef void (*MyDoSomething)(MyState *obj);
217 * typedef struct MyClass {
218 * ObjectClass parent_class;
220 * MyDoSomething do_something;
221 * } MyClass;
223 * static void my_do_something(MyState *obj)
225 * // do something
228 * static void my_class_init(ObjectClass *oc, void *data)
230 * MyClass *mc = MY_CLASS(oc);
232 * mc->do_something = my_do_something;
235 * static const TypeInfo my_type_info = {
236 * .name = TYPE_MY,
237 * .parent = TYPE_OBJECT,
238 * .instance_size = sizeof(MyState),
239 * .class_size = sizeof(MyClass),
240 * .class_init = my_class_init,
241 * };
243 * typedef struct DerivedClass {
244 * MyClass parent_class;
246 * MyDoSomething parent_do_something;
247 * } DerivedClass;
249 * static void derived_do_something(MyState *obj)
251 * DerivedClass *dc = DERIVED_GET_CLASS(obj);
253 * // do something here
254 * dc->parent_do_something(obj);
255 * // do something else here
258 * static void derived_class_init(ObjectClass *oc, void *data)
260 * MyClass *mc = MY_CLASS(oc);
261 * DerivedClass *dc = DERIVED_CLASS(oc);
263 * dc->parent_do_something = mc->do_something;
264 * mc->do_something = derived_do_something;
267 * static const TypeInfo derived_type_info = {
268 * .name = TYPE_DERIVED,
269 * .parent = TYPE_MY,
270 * .class_size = sizeof(DerivedClass),
271 * .class_init = derived_class_init,
272 * };
273 * </programlisting>
274 * </example>
276 * Alternatively, object_class_by_name() can be used to obtain the class and
277 * its non-overridden methods for a specific type. This would correspond to
278 * |[ MyClass::method(...) ]| in C++.
280 * The first example of such a QOM method was #CPUClass.reset,
281 * another example is #DeviceClass.realize.
286 * ObjectPropertyAccessor:
287 * @obj: the object that owns the property
288 * @v: the visitor that contains the property data
289 * @name: the name of the property
290 * @opaque: the object property opaque
291 * @errp: a pointer to an Error that is filled if getting/setting fails.
293 * Called when trying to get/set a property.
295 typedef void (ObjectPropertyAccessor)(Object *obj,
296 Visitor *v,
297 const char *name,
298 void *opaque,
299 Error **errp);
302 * ObjectPropertyResolve:
303 * @obj: the object that owns the property
304 * @opaque: the opaque registered with the property
305 * @part: the name of the property
307 * Resolves the #Object corresponding to property @part.
309 * The returned object can also be used as a starting point
310 * to resolve a relative path starting with "@part".
312 * Returns: If @path is the path that led to @obj, the function
313 * returns the #Object corresponding to "@path/@part".
314 * If "@path/@part" is not a valid object path, it returns #NULL.
316 typedef Object *(ObjectPropertyResolve)(Object *obj,
317 void *opaque,
318 const char *part);
321 * ObjectPropertyRelease:
322 * @obj: the object that owns the property
323 * @name: the name of the property
324 * @opaque: the opaque registered with the property
326 * Called when a property is removed from a object.
328 typedef void (ObjectPropertyRelease)(Object *obj,
329 const char *name,
330 void *opaque);
332 typedef struct ObjectProperty
334 gchar *name;
335 gchar *type;
336 gchar *description;
337 ObjectPropertyAccessor *get;
338 ObjectPropertyAccessor *set;
339 ObjectPropertyResolve *resolve;
340 ObjectPropertyRelease *release;
341 void *opaque;
342 } ObjectProperty;
345 * ObjectUnparent:
346 * @obj: the object that is being removed from the composition tree
348 * Called when an object is being removed from the QOM composition tree.
349 * The function should remove any backlinks from children objects to @obj.
351 typedef void (ObjectUnparent)(Object *obj);
354 * ObjectFree:
355 * @obj: the object being freed
357 * Called when an object's last reference is removed.
359 typedef void (ObjectFree)(void *obj);
361 #define OBJECT_CLASS_CAST_CACHE 4
364 * ObjectClass:
366 * The base for all classes. The only thing that #ObjectClass contains is an
367 * integer type handle.
369 struct ObjectClass
371 /*< private >*/
372 Type type;
373 GSList *interfaces;
375 const char *object_cast_cache[OBJECT_CLASS_CAST_CACHE];
376 const char *class_cast_cache[OBJECT_CLASS_CAST_CACHE];
378 ObjectUnparent *unparent;
380 GHashTable *properties;
384 * Object:
386 * The base for all objects. The first member of this object is a pointer to
387 * a #ObjectClass. Since C guarantees that the first member of a structure
388 * always begins at byte 0 of that structure, as long as any sub-object places
389 * its parent as the first member, we can cast directly to a #Object.
391 * As a result, #Object contains a reference to the objects type as its
392 * first member. This allows identification of the real type of the object at
393 * run time.
395 struct Object
397 /*< private >*/
398 ObjectClass *class;
399 ObjectFree *free;
400 GHashTable *properties;
401 uint32_t ref;
402 Object *parent;
406 * TypeInfo:
407 * @name: The name of the type.
408 * @parent: The name of the parent type.
409 * @instance_size: The size of the object (derivative of #Object). If
410 * @instance_size is 0, then the size of the object will be the size of the
411 * parent object.
412 * @instance_init: This function is called to initialize an object. The parent
413 * class will have already been initialized so the type is only responsible
414 * for initializing its own members.
415 * @instance_post_init: This function is called to finish initialization of
416 * an object, after all @instance_init functions were called.
417 * @instance_finalize: This function is called during object destruction. This
418 * is called before the parent @instance_finalize function has been called.
419 * An object should only free the members that are unique to its type in this
420 * function.
421 * @abstract: If this field is true, then the class is considered abstract and
422 * cannot be directly instantiated.
423 * @class_size: The size of the class object (derivative of #ObjectClass)
424 * for this object. If @class_size is 0, then the size of the class will be
425 * assumed to be the size of the parent class. This allows a type to avoid
426 * implementing an explicit class type if they are not adding additional
427 * virtual functions.
428 * @class_init: This function is called after all parent class initialization
429 * has occurred to allow a class to set its default virtual method pointers.
430 * This is also the function to use to override virtual methods from a parent
431 * class.
432 * @class_base_init: This function is called for all base classes after all
433 * parent class initialization has occurred, but before the class itself
434 * is initialized. This is the function to use to undo the effects of
435 * memcpy from the parent class to the descendents.
436 * @class_finalize: This function is called during class destruction and is
437 * meant to release and dynamic parameters allocated by @class_init.
438 * @class_data: Data to pass to the @class_init, @class_base_init and
439 * @class_finalize functions. This can be useful when building dynamic
440 * classes.
441 * @interfaces: The list of interfaces associated with this type. This
442 * should point to a static array that's terminated with a zero filled
443 * element.
445 struct TypeInfo
447 const char *name;
448 const char *parent;
450 size_t instance_size;
451 void (*instance_init)(Object *obj);
452 void (*instance_post_init)(Object *obj);
453 void (*instance_finalize)(Object *obj);
455 bool abstract;
456 size_t class_size;
458 void (*class_init)(ObjectClass *klass, void *data);
459 void (*class_base_init)(ObjectClass *klass, void *data);
460 void (*class_finalize)(ObjectClass *klass, void *data);
461 void *class_data;
463 InterfaceInfo *interfaces;
467 * OBJECT:
468 * @obj: A derivative of #Object
470 * Converts an object to a #Object. Since all objects are #Objects,
471 * this function will always succeed.
473 #define OBJECT(obj) \
474 ((Object *)(obj))
477 * OBJECT_CLASS:
478 * @class: A derivative of #ObjectClass.
480 * Converts a class to an #ObjectClass. Since all objects are #Objects,
481 * this function will always succeed.
483 #define OBJECT_CLASS(class) \
484 ((ObjectClass *)(class))
487 * OBJECT_CHECK:
488 * @type: The C type to use for the return value.
489 * @obj: A derivative of @type to cast.
490 * @name: The QOM typename of @type
492 * A type safe version of @object_dynamic_cast_assert. Typically each class
493 * will define a macro based on this type to perform type safe dynamic_casts to
494 * this object type.
496 * If an invalid object is passed to this function, a run time assert will be
497 * generated.
499 #define OBJECT_CHECK(type, obj, name) \
500 ((type *)object_dynamic_cast_assert(OBJECT(obj), (name), \
501 __FILE__, __LINE__, __func__))
504 * OBJECT_CLASS_CHECK:
505 * @class_type: The C type to use for the return value.
506 * @class: A derivative class of @class_type to cast.
507 * @name: the QOM typename of @class_type.
509 * A type safe version of @object_class_dynamic_cast_assert. This macro is
510 * typically wrapped by each type to perform type safe casts of a class to a
511 * specific class type.
513 #define OBJECT_CLASS_CHECK(class_type, class, name) \
514 ((class_type *)object_class_dynamic_cast_assert(OBJECT_CLASS(class), (name), \
515 __FILE__, __LINE__, __func__))
518 * OBJECT_GET_CLASS:
519 * @class: The C type to use for the return value.
520 * @obj: The object to obtain the class for.
521 * @name: The QOM typename of @obj.
523 * This function will return a specific class for a given object. Its generally
524 * used by each type to provide a type safe macro to get a specific class type
525 * from an object.
527 #define OBJECT_GET_CLASS(class, obj, name) \
528 OBJECT_CLASS_CHECK(class, object_get_class(OBJECT(obj)), name)
531 * InterfaceInfo:
532 * @type: The name of the interface.
534 * The information associated with an interface.
536 struct InterfaceInfo {
537 const char *type;
541 * InterfaceClass:
542 * @parent_class: the base class
544 * The class for all interfaces. Subclasses of this class should only add
545 * virtual methods.
547 struct InterfaceClass
549 ObjectClass parent_class;
550 /*< private >*/
551 ObjectClass *concrete_class;
552 Type interface_type;
555 #define TYPE_INTERFACE "interface"
558 * INTERFACE_CLASS:
559 * @klass: class to cast from
560 * Returns: An #InterfaceClass or raise an error if cast is invalid
562 #define INTERFACE_CLASS(klass) \
563 OBJECT_CLASS_CHECK(InterfaceClass, klass, TYPE_INTERFACE)
566 * INTERFACE_CHECK:
567 * @interface: the type to return
568 * @obj: the object to convert to an interface
569 * @name: the interface type name
571 * Returns: @obj casted to @interface if cast is valid, otherwise raise error.
573 #define INTERFACE_CHECK(interface, obj, name) \
574 ((interface *)object_dynamic_cast_assert(OBJECT((obj)), (name), \
575 __FILE__, __LINE__, __func__))
578 * object_new:
579 * @typename: The name of the type of the object to instantiate.
581 * This function will initialize a new object using heap allocated memory.
582 * The returned object has a reference count of 1, and will be freed when
583 * the last reference is dropped.
585 * Returns: The newly allocated and instantiated object.
587 Object *object_new(const char *typename);
590 * object_new_with_type:
591 * @type: The type of the object to instantiate.
593 * This function will initialize a new object using heap allocated memory.
594 * The returned object has a reference count of 1, and will be freed when
595 * the last reference is dropped.
597 * Returns: The newly allocated and instantiated object.
599 Object *object_new_with_type(Type type);
602 * object_new_with_props:
603 * @typename: The name of the type of the object to instantiate.
604 * @parent: the parent object
605 * @id: The unique ID of the object
606 * @errp: pointer to error object
607 * @...: list of property names and values
609 * This function will initialize a new object using heap allocated memory.
610 * The returned object has a reference count of 1, and will be freed when
611 * the last reference is dropped.
613 * The @id parameter will be used when registering the object as a
614 * child of @parent in the composition tree.
616 * The variadic parameters are a list of pairs of (propname, propvalue)
617 * strings. The propname of %NULL indicates the end of the property
618 * list. If the object implements the user creatable interface, the
619 * object will be marked complete once all the properties have been
620 * processed.
622 * <example>
623 * <title>Creating an object with properties</title>
624 * <programlisting>
625 * Error *err = NULL;
626 * Object *obj;
628 * obj = object_new_with_props(TYPE_MEMORY_BACKEND_FILE,
629 * object_get_objects_root(),
630 * "hostmem0",
631 * &err,
632 * "share", "yes",
633 * "mem-path", "/dev/shm/somefile",
634 * "prealloc", "yes",
635 * "size", "1048576",
636 * NULL);
638 * if (!obj) {
639 * g_printerr("Cannot create memory backend: %s\n",
640 * error_get_pretty(err));
642 * </programlisting>
643 * </example>
645 * The returned object will have one stable reference maintained
646 * for as long as it is present in the object hierarchy.
648 * Returns: The newly allocated, instantiated & initialized object.
650 Object *object_new_with_props(const char *typename,
651 Object *parent,
652 const char *id,
653 Error **errp,
654 ...) QEMU_SENTINEL;
657 * object_new_with_propv:
658 * @typename: The name of the type of the object to instantiate.
659 * @parent: the parent object
660 * @id: The unique ID of the object
661 * @errp: pointer to error object
662 * @vargs: list of property names and values
664 * See object_new_with_props() for documentation.
666 Object *object_new_with_propv(const char *typename,
667 Object *parent,
668 const char *id,
669 Error **errp,
670 va_list vargs);
673 * object_set_props:
674 * @obj: the object instance to set properties on
675 * @errp: pointer to error object
676 * @...: list of property names and values
678 * This function will set a list of properties on an existing object
679 * instance.
681 * The variadic parameters are a list of pairs of (propname, propvalue)
682 * strings. The propname of %NULL indicates the end of the property
683 * list.
685 * <example>
686 * <title>Update an object's properties</title>
687 * <programlisting>
688 * Error *err = NULL;
689 * Object *obj = ...get / create object...;
691 * obj = object_set_props(obj,
692 * &err,
693 * "share", "yes",
694 * "mem-path", "/dev/shm/somefile",
695 * "prealloc", "yes",
696 * "size", "1048576",
697 * NULL);
699 * if (!obj) {
700 * g_printerr("Cannot set properties: %s\n",
701 * error_get_pretty(err));
703 * </programlisting>
704 * </example>
706 * The returned object will have one stable reference maintained
707 * for as long as it is present in the object hierarchy.
709 * Returns: -1 on error, 0 on success
711 int object_set_props(Object *obj,
712 Error **errp,
713 ...) QEMU_SENTINEL;
716 * object_set_propv:
717 * @obj: the object instance to set properties on
718 * @errp: pointer to error object
719 * @vargs: list of property names and values
721 * See object_set_props() for documentation.
723 * Returns: -1 on error, 0 on success
725 int object_set_propv(Object *obj,
726 Error **errp,
727 va_list vargs);
730 * object_initialize_with_type:
731 * @data: A pointer to the memory to be used for the object.
732 * @size: The maximum size available at @data for the object.
733 * @type: The type of the object to instantiate.
735 * This function will initialize an object. The memory for the object should
736 * have already been allocated. The returned object has a reference count of 1,
737 * and will be finalized when the last reference is dropped.
739 void object_initialize_with_type(void *data, size_t size, Type type);
742 * object_initialize:
743 * @obj: A pointer to the memory to be used for the object.
744 * @size: The maximum size available at @obj for the object.
745 * @typename: The name of the type of the object to instantiate.
747 * This function will initialize an object. The memory for the object should
748 * have already been allocated. The returned object has a reference count of 1,
749 * and will be finalized when the last reference is dropped.
751 void object_initialize(void *obj, size_t size, const char *typename);
754 * object_dynamic_cast:
755 * @obj: The object to cast.
756 * @typename: The @typename to cast to.
758 * This function will determine if @obj is-a @typename. @obj can refer to an
759 * object or an interface associated with an object.
761 * Returns: This function returns @obj on success or #NULL on failure.
763 Object *object_dynamic_cast(Object *obj, const char *typename);
766 * object_dynamic_cast_assert:
768 * See object_dynamic_cast() for a description of the parameters of this
769 * function. The only difference in behavior is that this function asserts
770 * instead of returning #NULL on failure if QOM cast debugging is enabled.
771 * This function is not meant to be called directly, but only through
772 * the wrapper macro OBJECT_CHECK.
774 Object *object_dynamic_cast_assert(Object *obj, const char *typename,
775 const char *file, int line, const char *func);
778 * object_get_class:
779 * @obj: A derivative of #Object
781 * Returns: The #ObjectClass of the type associated with @obj.
783 ObjectClass *object_get_class(Object *obj);
786 * object_get_typename:
787 * @obj: A derivative of #Object.
789 * Returns: The QOM typename of @obj.
791 const char *object_get_typename(Object *obj);
794 * type_register_static:
795 * @info: The #TypeInfo of the new type.
797 * @info and all of the strings it points to should exist for the life time
798 * that the type is registered.
800 * Returns: 0 on failure, the new #Type on success.
802 Type type_register_static(const TypeInfo *info);
805 * type_register:
806 * @info: The #TypeInfo of the new type
808 * Unlike type_register_static(), this call does not require @info or its
809 * string members to continue to exist after the call returns.
811 * Returns: 0 on failure, the new #Type on success.
813 Type type_register(const TypeInfo *info);
816 * object_class_dynamic_cast_assert:
817 * @klass: The #ObjectClass to attempt to cast.
818 * @typename: The QOM typename of the class to cast to.
820 * See object_class_dynamic_cast() for a description of the parameters
821 * of this function. The only difference in behavior is that this function
822 * asserts instead of returning #NULL on failure if QOM cast debugging is
823 * enabled. This function is not meant to be called directly, but only through
824 * the wrapper macros OBJECT_CLASS_CHECK and INTERFACE_CHECK.
826 ObjectClass *object_class_dynamic_cast_assert(ObjectClass *klass,
827 const char *typename,
828 const char *file, int line,
829 const char *func);
832 * object_class_dynamic_cast:
833 * @klass: The #ObjectClass to attempt to cast.
834 * @typename: The QOM typename of the class to cast to.
836 * Returns: If @typename is a class, this function returns @klass if
837 * @typename is a subtype of @klass, else returns #NULL.
839 * If @typename is an interface, this function returns the interface
840 * definition for @klass if @klass implements it unambiguously; #NULL
841 * is returned if @klass does not implement the interface or if multiple
842 * classes or interfaces on the hierarchy leading to @klass implement
843 * it. (FIXME: perhaps this can be detected at type definition time?)
845 ObjectClass *object_class_dynamic_cast(ObjectClass *klass,
846 const char *typename);
849 * object_class_get_parent:
850 * @klass: The class to obtain the parent for.
852 * Returns: The parent for @klass or %NULL if none.
854 ObjectClass *object_class_get_parent(ObjectClass *klass);
857 * object_class_get_name:
858 * @klass: The class to obtain the QOM typename for.
860 * Returns: The QOM typename for @klass.
862 const char *object_class_get_name(ObjectClass *klass);
865 * object_class_is_abstract:
866 * @klass: The class to obtain the abstractness for.
868 * Returns: %true if @klass is abstract, %false otherwise.
870 bool object_class_is_abstract(ObjectClass *klass);
873 * object_class_by_name:
874 * @typename: The QOM typename to obtain the class for.
876 * Returns: The class for @typename or %NULL if not found.
878 ObjectClass *object_class_by_name(const char *typename);
880 void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque),
881 const char *implements_type, bool include_abstract,
882 void *opaque);
885 * object_class_get_list:
886 * @implements_type: The type to filter for, including its derivatives.
887 * @include_abstract: Whether to include abstract classes.
889 * Returns: A singly-linked list of the classes in reverse hashtable order.
891 GSList *object_class_get_list(const char *implements_type,
892 bool include_abstract);
895 * object_ref:
896 * @obj: the object
898 * Increase the reference count of a object. A object cannot be freed as long
899 * as its reference count is greater than zero.
901 void object_ref(Object *obj);
904 * object_unref:
905 * @obj: the object
907 * Decrease the reference count of a object. A object cannot be freed as long
908 * as its reference count is greater than zero.
910 void object_unref(Object *obj);
913 * object_property_add:
914 * @obj: the object to add a property to
915 * @name: the name of the property. This can contain any character except for
916 * a forward slash. In general, you should use hyphens '-' instead of
917 * underscores '_' when naming properties.
918 * @type: the type name of the property. This namespace is pretty loosely
919 * defined. Sub namespaces are constructed by using a prefix and then
920 * to angle brackets. For instance, the type 'virtio-net-pci' in the
921 * 'link' namespace would be 'link<virtio-net-pci>'.
922 * @get: The getter to be called to read a property. If this is NULL, then
923 * the property cannot be read.
924 * @set: the setter to be called to write a property. If this is NULL,
925 * then the property cannot be written.
926 * @release: called when the property is removed from the object. This is
927 * meant to allow a property to free its opaque upon object
928 * destruction. This may be NULL.
929 * @opaque: an opaque pointer to pass to the callbacks for the property
930 * @errp: returns an error if this function fails
932 * Returns: The #ObjectProperty; this can be used to set the @resolve
933 * callback for child and link properties.
935 ObjectProperty *object_property_add(Object *obj, const char *name,
936 const char *type,
937 ObjectPropertyAccessor *get,
938 ObjectPropertyAccessor *set,
939 ObjectPropertyRelease *release,
940 void *opaque, Error **errp);
942 void object_property_del(Object *obj, const char *name, Error **errp);
944 ObjectProperty *object_class_property_add(ObjectClass *klass, const char *name,
945 const char *type,
946 ObjectPropertyAccessor *get,
947 ObjectPropertyAccessor *set,
948 ObjectPropertyRelease *release,
949 void *opaque, Error **errp);
952 * object_property_find:
953 * @obj: the object
954 * @name: the name of the property
955 * @errp: returns an error if this function fails
957 * Look up a property for an object and return its #ObjectProperty if found.
959 ObjectProperty *object_property_find(Object *obj, const char *name,
960 Error **errp);
961 ObjectProperty *object_class_property_find(ObjectClass *klass, const char *name,
962 Error **errp);
964 typedef struct ObjectPropertyIterator {
965 ObjectClass *nextclass;
966 GHashTableIter iter;
967 } ObjectPropertyIterator;
970 * object_property_iter_init:
971 * @obj: the object
973 * Initializes an iterator for traversing all properties
974 * registered against an object instance, its class and all parent classes.
976 * It is forbidden to modify the property list while iterating,
977 * whether removing or adding properties.
979 * Typical usage pattern would be
981 * <example>
982 * <title>Using object property iterators</title>
983 * <programlisting>
984 * ObjectProperty *prop;
985 * ObjectPropertyIterator iter;
987 * object_property_iter_init(&iter, obj);
988 * while ((prop = object_property_iter_next(&iter))) {
989 * ... do something with prop ...
991 * </programlisting>
992 * </example>
994 void object_property_iter_init(ObjectPropertyIterator *iter,
995 Object *obj);
998 * object_property_iter_next:
999 * @iter: the iterator instance
1001 * Return the next available property. If no further properties
1002 * are available, a %NULL value will be returned and the @iter
1003 * pointer should not be used again after this point without
1004 * re-initializing it.
1006 * Returns: the next property, or %NULL when all properties
1007 * have been traversed.
1009 ObjectProperty *object_property_iter_next(ObjectPropertyIterator *iter);
1011 void object_unparent(Object *obj);
1014 * object_property_get:
1015 * @obj: the object
1016 * @v: the visitor that will receive the property value. This should be an
1017 * Output visitor and the data will be written with @name as the name.
1018 * @name: the name of the property
1019 * @errp: returns an error if this function fails
1021 * Reads a property from a object.
1023 void object_property_get(Object *obj, Visitor *v, const char *name,
1024 Error **errp);
1027 * object_property_set_str:
1028 * @value: the value to be written to the property
1029 * @name: the name of the property
1030 * @errp: returns an error if this function fails
1032 * Writes a string value to a property.
1034 void object_property_set_str(Object *obj, const char *value,
1035 const char *name, Error **errp);
1038 * object_property_get_str:
1039 * @obj: the object
1040 * @name: the name of the property
1041 * @errp: returns an error if this function fails
1043 * Returns: the value of the property, converted to a C string, or NULL if
1044 * an error occurs (including when the property value is not a string).
1045 * The caller should free the string.
1047 char *object_property_get_str(Object *obj, const char *name,
1048 Error **errp);
1051 * object_property_set_link:
1052 * @value: the value to be written to the property
1053 * @name: the name of the property
1054 * @errp: returns an error if this function fails
1056 * Writes an object's canonical path to a property.
1058 void object_property_set_link(Object *obj, Object *value,
1059 const char *name, Error **errp);
1062 * object_property_get_link:
1063 * @obj: the object
1064 * @name: the name of the property
1065 * @errp: returns an error if this function fails
1067 * Returns: the value of the property, resolved from a path to an Object,
1068 * or NULL if an error occurs (including when the property value is not a
1069 * string or not a valid object path).
1071 Object *object_property_get_link(Object *obj, const char *name,
1072 Error **errp);
1075 * object_property_set_bool:
1076 * @value: the value to be written to the property
1077 * @name: the name of the property
1078 * @errp: returns an error if this function fails
1080 * Writes a bool value to a property.
1082 void object_property_set_bool(Object *obj, bool value,
1083 const char *name, Error **errp);
1086 * object_property_get_bool:
1087 * @obj: the object
1088 * @name: the name of the property
1089 * @errp: returns an error if this function fails
1091 * Returns: the value of the property, converted to a boolean, or NULL if
1092 * an error occurs (including when the property value is not a bool).
1094 bool object_property_get_bool(Object *obj, const char *name,
1095 Error **errp);
1098 * object_property_set_int:
1099 * @value: the value to be written to the property
1100 * @name: the name of the property
1101 * @errp: returns an error if this function fails
1103 * Writes an integer value to a property.
1105 void object_property_set_int(Object *obj, int64_t value,
1106 const char *name, Error **errp);
1109 * object_property_get_int:
1110 * @obj: the object
1111 * @name: the name of the property
1112 * @errp: returns an error if this function fails
1114 * Returns: the value of the property, converted to an integer, or negative if
1115 * an error occurs (including when the property value is not an integer).
1117 int64_t object_property_get_int(Object *obj, const char *name,
1118 Error **errp);
1121 * object_property_get_enum:
1122 * @obj: the object
1123 * @name: the name of the property
1124 * @typename: the name of the enum data type
1125 * @errp: returns an error if this function fails
1127 * Returns: the value of the property, converted to an integer, or
1128 * undefined if an error occurs (including when the property value is not
1129 * an enum).
1131 int object_property_get_enum(Object *obj, const char *name,
1132 const char *typename, Error **errp);
1135 * object_property_get_uint16List:
1136 * @obj: the object
1137 * @name: the name of the property
1138 * @list: the returned int list
1139 * @errp: returns an error if this function fails
1141 * Returns: the value of the property, converted to integers, or
1142 * undefined if an error occurs (including when the property value is not
1143 * an list of integers).
1145 void object_property_get_uint16List(Object *obj, const char *name,
1146 uint16List **list, Error **errp);
1149 * object_property_set:
1150 * @obj: the object
1151 * @v: the visitor that will be used to write the property value. This should
1152 * be an Input visitor and the data will be first read with @name as the
1153 * name and then written as the property value.
1154 * @name: the name of the property
1155 * @errp: returns an error if this function fails
1157 * Writes a property to a object.
1159 void object_property_set(Object *obj, Visitor *v, const char *name,
1160 Error **errp);
1163 * object_property_parse:
1164 * @obj: the object
1165 * @string: the string that will be used to parse the property value.
1166 * @name: the name of the property
1167 * @errp: returns an error if this function fails
1169 * Parses a string and writes the result into a property of an object.
1171 void object_property_parse(Object *obj, const char *string,
1172 const char *name, Error **errp);
1175 * object_property_print:
1176 * @obj: the object
1177 * @name: the name of the property
1178 * @human: if true, print for human consumption
1179 * @errp: returns an error if this function fails
1181 * Returns a string representation of the value of the property. The
1182 * caller shall free the string.
1184 char *object_property_print(Object *obj, const char *name, bool human,
1185 Error **errp);
1188 * object_property_get_type:
1189 * @obj: the object
1190 * @name: the name of the property
1191 * @errp: returns an error if this function fails
1193 * Returns: The type name of the property.
1195 const char *object_property_get_type(Object *obj, const char *name,
1196 Error **errp);
1199 * object_get_root:
1201 * Returns: the root object of the composition tree
1203 Object *object_get_root(void);
1207 * object_get_objects_root:
1209 * Get the container object that holds user created
1210 * object instances. This is the object at path
1211 * "/objects"
1213 * Returns: the user object container
1215 Object *object_get_objects_root(void);
1218 * object_get_canonical_path_component:
1220 * Returns: The final component in the object's canonical path. The canonical
1221 * path is the path within the composition tree starting from the root.
1223 gchar *object_get_canonical_path_component(Object *obj);
1226 * object_get_canonical_path:
1228 * Returns: The canonical path for a object. This is the path within the
1229 * composition tree starting from the root.
1231 gchar *object_get_canonical_path(Object *obj);
1234 * object_resolve_path:
1235 * @path: the path to resolve
1236 * @ambiguous: returns true if the path resolution failed because of an
1237 * ambiguous match
1239 * There are two types of supported paths--absolute paths and partial paths.
1241 * Absolute paths are derived from the root object and can follow child<> or
1242 * link<> properties. Since they can follow link<> properties, they can be
1243 * arbitrarily long. Absolute paths look like absolute filenames and are
1244 * prefixed with a leading slash.
1246 * Partial paths look like relative filenames. They do not begin with a
1247 * prefix. The matching rules for partial paths are subtle but designed to make
1248 * specifying objects easy. At each level of the composition tree, the partial
1249 * path is matched as an absolute path. The first match is not returned. At
1250 * least two matches are searched for. A successful result is only returned if
1251 * only one match is found. If more than one match is found, a flag is
1252 * returned to indicate that the match was ambiguous.
1254 * Returns: The matched object or NULL on path lookup failure.
1256 Object *object_resolve_path(const char *path, bool *ambiguous);
1259 * object_resolve_path_type:
1260 * @path: the path to resolve
1261 * @typename: the type to look for.
1262 * @ambiguous: returns true if the path resolution failed because of an
1263 * ambiguous match
1265 * This is similar to object_resolve_path. However, when looking for a
1266 * partial path only matches that implement the given type are considered.
1267 * This restricts the search and avoids spuriously flagging matches as
1268 * ambiguous.
1270 * For both partial and absolute paths, the return value goes through
1271 * a dynamic cast to @typename. This is important if either the link,
1272 * or the typename itself are of interface types.
1274 * Returns: The matched object or NULL on path lookup failure.
1276 Object *object_resolve_path_type(const char *path, const char *typename,
1277 bool *ambiguous);
1280 * object_resolve_path_component:
1281 * @parent: the object in which to resolve the path
1282 * @part: the component to resolve.
1284 * This is similar to object_resolve_path with an absolute path, but it
1285 * only resolves one element (@part) and takes the others from @parent.
1287 * Returns: The resolved object or NULL on path lookup failure.
1289 Object *object_resolve_path_component(Object *parent, const gchar *part);
1292 * object_property_add_child:
1293 * @obj: the object to add a property to
1294 * @name: the name of the property
1295 * @child: the child object
1296 * @errp: if an error occurs, a pointer to an area to store the area
1298 * Child properties form the composition tree. All objects need to be a child
1299 * of another object. Objects can only be a child of one object.
1301 * There is no way for a child to determine what its parent is. It is not
1302 * a bidirectional relationship. This is by design.
1304 * The value of a child property as a C string will be the child object's
1305 * canonical path. It can be retrieved using object_property_get_str().
1306 * The child object itself can be retrieved using object_property_get_link().
1308 void object_property_add_child(Object *obj, const char *name,
1309 Object *child, Error **errp);
1311 typedef enum {
1312 /* Unref the link pointer when the property is deleted */
1313 OBJ_PROP_LINK_UNREF_ON_RELEASE = 0x1,
1314 } ObjectPropertyLinkFlags;
1317 * object_property_allow_set_link:
1319 * The default implementation of the object_property_add_link() check()
1320 * callback function. It allows the link property to be set and never returns
1321 * an error.
1323 void object_property_allow_set_link(Object *, const char *,
1324 Object *, Error **);
1327 * object_property_add_link:
1328 * @obj: the object to add a property to
1329 * @name: the name of the property
1330 * @type: the qobj type of the link
1331 * @child: a pointer to where the link object reference is stored
1332 * @check: callback to veto setting or NULL if the property is read-only
1333 * @flags: additional options for the link
1334 * @errp: if an error occurs, a pointer to an area to store the area
1336 * Links establish relationships between objects. Links are unidirectional
1337 * although two links can be combined to form a bidirectional relationship
1338 * between objects.
1340 * Links form the graph in the object model.
1342 * The <code>@check()</code> callback is invoked when
1343 * object_property_set_link() is called and can raise an error to prevent the
1344 * link being set. If <code>@check</code> is NULL, the property is read-only
1345 * and cannot be set.
1347 * Ownership of the pointer that @child points to is transferred to the
1348 * link property. The reference count for <code>*@child</code> is
1349 * managed by the property from after the function returns till the
1350 * property is deleted with object_property_del(). If the
1351 * <code>@flags</code> <code>OBJ_PROP_LINK_UNREF_ON_RELEASE</code> bit is set,
1352 * the reference count is decremented when the property is deleted.
1354 void object_property_add_link(Object *obj, const char *name,
1355 const char *type, Object **child,
1356 void (*check)(Object *obj, const char *name,
1357 Object *val, Error **errp),
1358 ObjectPropertyLinkFlags flags,
1359 Error **errp);
1362 * object_property_add_str:
1363 * @obj: the object to add a property to
1364 * @name: the name of the property
1365 * @get: the getter or NULL if the property is write-only. This function must
1366 * return a string to be freed by g_free().
1367 * @set: the setter or NULL if the property is read-only
1368 * @errp: if an error occurs, a pointer to an area to store the error
1370 * Add a string property using getters/setters. This function will add a
1371 * property of type 'string'.
1373 void object_property_add_str(Object *obj, const char *name,
1374 char *(*get)(Object *, Error **),
1375 void (*set)(Object *, const char *, Error **),
1376 Error **errp);
1378 void object_class_property_add_str(ObjectClass *klass, const char *name,
1379 char *(*get)(Object *, Error **),
1380 void (*set)(Object *, const char *,
1381 Error **),
1382 Error **errp);
1385 * object_property_add_bool:
1386 * @obj: the object to add a property to
1387 * @name: the name of the property
1388 * @get: the getter or NULL if the property is write-only.
1389 * @set: the setter or NULL if the property is read-only
1390 * @errp: if an error occurs, a pointer to an area to store the error
1392 * Add a bool property using getters/setters. This function will add a
1393 * property of type 'bool'.
1395 void object_property_add_bool(Object *obj, const char *name,
1396 bool (*get)(Object *, Error **),
1397 void (*set)(Object *, bool, Error **),
1398 Error **errp);
1400 void object_class_property_add_bool(ObjectClass *klass, const char *name,
1401 bool (*get)(Object *, Error **),
1402 void (*set)(Object *, bool, Error **),
1403 Error **errp);
1406 * object_property_add_enum:
1407 * @obj: the object to add a property to
1408 * @name: the name of the property
1409 * @typename: the name of the enum data type
1410 * @get: the getter or %NULL if the property is write-only.
1411 * @set: the setter or %NULL if the property is read-only
1412 * @errp: if an error occurs, a pointer to an area to store the error
1414 * Add an enum property using getters/setters. This function will add a
1415 * property of type '@typename'.
1417 void object_property_add_enum(Object *obj, const char *name,
1418 const char *typename,
1419 const char * const *strings,
1420 int (*get)(Object *, Error **),
1421 void (*set)(Object *, int, Error **),
1422 Error **errp);
1424 void object_class_property_add_enum(ObjectClass *klass, const char *name,
1425 const char *typename,
1426 const char * const *strings,
1427 int (*get)(Object *, Error **),
1428 void (*set)(Object *, int, Error **),
1429 Error **errp);
1432 * object_property_add_tm:
1433 * @obj: the object to add a property to
1434 * @name: the name of the property
1435 * @get: the getter or NULL if the property is write-only.
1436 * @errp: if an error occurs, a pointer to an area to store the error
1438 * Add a read-only struct tm valued property using a getter function.
1439 * This function will add a property of type 'struct tm'.
1441 void object_property_add_tm(Object *obj, const char *name,
1442 void (*get)(Object *, struct tm *, Error **),
1443 Error **errp);
1445 void object_class_property_add_tm(ObjectClass *klass, const char *name,
1446 void (*get)(Object *, struct tm *, Error **),
1447 Error **errp);
1450 * object_property_add_uint8_ptr:
1451 * @obj: the object to add a property to
1452 * @name: the name of the property
1453 * @v: pointer to value
1454 * @errp: if an error occurs, a pointer to an area to store the error
1456 * Add an integer property in memory. This function will add a
1457 * property of type 'uint8'.
1459 void object_property_add_uint8_ptr(Object *obj, const char *name,
1460 const uint8_t *v, Error **errp);
1461 void object_class_property_add_uint8_ptr(ObjectClass *klass, const char *name,
1462 const uint8_t *v, Error **errp);
1465 * object_property_add_uint16_ptr:
1466 * @obj: the object to add a property to
1467 * @name: the name of the property
1468 * @v: pointer to value
1469 * @errp: if an error occurs, a pointer to an area to store the error
1471 * Add an integer property in memory. This function will add a
1472 * property of type 'uint16'.
1474 void object_property_add_uint16_ptr(Object *obj, const char *name,
1475 const uint16_t *v, Error **errp);
1476 void object_class_property_add_uint16_ptr(ObjectClass *klass, const char *name,
1477 const uint16_t *v, Error **errp);
1480 * object_property_add_uint32_ptr:
1481 * @obj: the object to add a property to
1482 * @name: the name of the property
1483 * @v: pointer to value
1484 * @errp: if an error occurs, a pointer to an area to store the error
1486 * Add an integer property in memory. This function will add a
1487 * property of type 'uint32'.
1489 void object_property_add_uint32_ptr(Object *obj, const char *name,
1490 const uint32_t *v, Error **errp);
1491 void object_class_property_add_uint32_ptr(ObjectClass *klass, const char *name,
1492 const uint32_t *v, Error **errp);
1495 * object_property_add_uint64_ptr:
1496 * @obj: the object to add a property to
1497 * @name: the name of the property
1498 * @v: pointer to value
1499 * @errp: if an error occurs, a pointer to an area to store the error
1501 * Add an integer property in memory. This function will add a
1502 * property of type 'uint64'.
1504 void object_property_add_uint64_ptr(Object *obj, const char *name,
1505 const uint64_t *v, Error **Errp);
1506 void object_class_property_add_uint64_ptr(ObjectClass *klass, const char *name,
1507 const uint64_t *v, Error **Errp);
1510 * object_property_add_alias:
1511 * @obj: the object to add a property to
1512 * @name: the name of the property
1513 * @target_obj: the object to forward property access to
1514 * @target_name: the name of the property on the forwarded object
1515 * @errp: if an error occurs, a pointer to an area to store the error
1517 * Add an alias for a property on an object. This function will add a property
1518 * of the same type as the forwarded property.
1520 * The caller must ensure that <code>@target_obj</code> stays alive as long as
1521 * this property exists. In the case of a child object or an alias on the same
1522 * object this will be the case. For aliases to other objects the caller is
1523 * responsible for taking a reference.
1525 void object_property_add_alias(Object *obj, const char *name,
1526 Object *target_obj, const char *target_name,
1527 Error **errp);
1530 * object_property_add_const_link:
1531 * @obj: the object to add a property to
1532 * @name: the name of the property
1533 * @target: the object to be referred by the link
1534 * @errp: if an error occurs, a pointer to an area to store the error
1536 * Add an unmodifiable link for a property on an object. This function will
1537 * add a property of type link<TYPE> where TYPE is the type of @target.
1539 * The caller must ensure that @target stays alive as long as
1540 * this property exists. In the case @target is a child of @obj,
1541 * this will be the case. Otherwise, the caller is responsible for
1542 * taking a reference.
1544 void object_property_add_const_link(Object *obj, const char *name,
1545 Object *target, Error **errp);
1548 * object_property_set_description:
1549 * @obj: the object owning the property
1550 * @name: the name of the property
1551 * @description: the description of the property on the object
1552 * @errp: if an error occurs, a pointer to an area to store the error
1554 * Set an object property's description.
1557 void object_property_set_description(Object *obj, const char *name,
1558 const char *description, Error **errp);
1559 void object_class_property_set_description(ObjectClass *klass, const char *name,
1560 const char *description,
1561 Error **errp);
1564 * object_child_foreach:
1565 * @obj: the object whose children will be navigated
1566 * @fn: the iterator function to be called
1567 * @opaque: an opaque value that will be passed to the iterator
1569 * Call @fn passing each child of @obj and @opaque to it, until @fn returns
1570 * non-zero.
1572 * It is forbidden to add or remove children from @obj from the @fn
1573 * callback.
1575 * Returns: The last value returned by @fn, or 0 if there is no child.
1577 int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque),
1578 void *opaque);
1581 * object_child_foreach_recursive:
1582 * @obj: the object whose children will be navigated
1583 * @fn: the iterator function to be called
1584 * @opaque: an opaque value that will be passed to the iterator
1586 * Call @fn passing each child of @obj and @opaque to it, until @fn returns
1587 * non-zero. Calls recursively, all child nodes of @obj will also be passed
1588 * all the way down to the leaf nodes of the tree. Depth first ordering.
1590 * It is forbidden to add or remove children from @obj (or its
1591 * child nodes) from the @fn callback.
1593 * Returns: The last value returned by @fn, or 0 if there is no child.
1595 int object_child_foreach_recursive(Object *obj,
1596 int (*fn)(Object *child, void *opaque),
1597 void *opaque);
1599 * container_get:
1600 * @root: root of the #path, e.g., object_get_root()
1601 * @path: path to the container
1603 * Return a container object whose path is @path. Create more containers
1604 * along the path if necessary.
1606 * Returns: the container object.
1608 Object *container_get(Object *root, const char *path);
1611 * object_type_get_instance_size:
1612 * @typename: Name of the Type whose instance_size is required
1614 * Returns the instance_size of the given @typename.
1616 size_t object_type_get_instance_size(const char *typename);
1617 #endif