qom: Indent existing code examples

This indents existing code examples that are not indented yet,
just to make future conversion to Sphinx markup easier to review.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <20200910221526.10041-7-ehabkost@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Eduardo Habkost 2020-09-10 18:15:23 -04:00 committed by Paolo Bonzini
parent 8814446875
commit 9bbfd245c3

View File

@ -41,34 +41,34 @@ typedef struct InterfaceInfo InterfaceInfo;
* *
* <example> * <example>
* <title>Creating a minimal type</title> * <title>Creating a minimal type</title>
* <programlisting> * <programlisting>
* #include "qdev.h" * #include "qdev.h"
* *
* #define TYPE_MY_DEVICE "my-device" * #define TYPE_MY_DEVICE "my-device"
* *
* // No new virtual functions: we can reuse the typedef for the * // No new virtual functions: we can reuse the typedef for the
* // superclass. * // superclass.
* typedef DeviceClass MyDeviceClass; * typedef DeviceClass MyDeviceClass;
* typedef struct MyDevice * typedef struct MyDevice
* { * {
* DeviceState parent; * DeviceState parent;
* *
* int reg0, reg1, reg2; * int reg0, reg1, reg2;
* } MyDevice; * } MyDevice;
* *
* static const TypeInfo my_device_info = { * static const TypeInfo my_device_info = {
* .name = TYPE_MY_DEVICE, * .name = TYPE_MY_DEVICE,
* .parent = TYPE_DEVICE, * .parent = TYPE_DEVICE,
* .instance_size = sizeof(MyDevice), * .instance_size = sizeof(MyDevice),
* }; * };
* *
* static void my_device_register_types(void) * static void my_device_register_types(void)
* { * {
* type_register_static(&my_device_info); * type_register_static(&my_device_info);
* } * }
* *
* type_init(my_device_register_types) * type_init(my_device_register_types)
* </programlisting> * </programlisting>
* </example> * </example>
* *
* In the above example, we create a simple type that is described by #TypeInfo. * In the above example, we create a simple type that is described by #TypeInfo.
@ -79,22 +79,22 @@ typedef struct InterfaceInfo InterfaceInfo;
* DEFINE_TYPES() * DEFINE_TYPES()
* *
* <example> * <example>
* <programlisting> * <programlisting>
* static const TypeInfo device_types_info[] = { * static const TypeInfo device_types_info[] = {
* { * {
* .name = TYPE_MY_DEVICE_A, * .name = TYPE_MY_DEVICE_A,
* .parent = TYPE_DEVICE, * .parent = TYPE_DEVICE,
* .instance_size = sizeof(MyDeviceA), * .instance_size = sizeof(MyDeviceA),
* }, * },
* { * {
* .name = TYPE_MY_DEVICE_B, * .name = TYPE_MY_DEVICE_B,
* .parent = TYPE_DEVICE, * .parent = TYPE_DEVICE,
* .instance_size = sizeof(MyDeviceB), * .instance_size = sizeof(MyDeviceB),
* }, * },
* }; * };
* *
* DEFINE_TYPES(device_types_info) * DEFINE_TYPES(device_types_info)
* </programlisting> * </programlisting>
* </example> * </example>
* *
* Every type has an #ObjectClass associated with it. #ObjectClass derivatives * Every type has an #ObjectClass associated with it. #ObjectClass derivatives
@ -143,22 +143,22 @@ typedef struct InterfaceInfo InterfaceInfo;
* *
* <example> * <example>
* <title>Overriding a virtual function</title> * <title>Overriding a virtual function</title>
* <programlisting> * <programlisting>
* #include "qdev.h" * #include "qdev.h"
* *
* void my_device_class_init(ObjectClass *klass, void *class_data) * void my_device_class_init(ObjectClass *klass, void *class_data)
* { * {
* DeviceClass *dc = DEVICE_CLASS(klass); * DeviceClass *dc = DEVICE_CLASS(klass);
* dc->reset = my_device_reset; * dc->reset = my_device_reset;
* } * }
* *
* static const TypeInfo my_device_info = { * static const TypeInfo my_device_info = {
* .name = TYPE_MY_DEVICE, * .name = TYPE_MY_DEVICE,
* .parent = TYPE_DEVICE, * .parent = TYPE_DEVICE,
* .instance_size = sizeof(MyDevice), * .instance_size = sizeof(MyDevice),
* .class_init = my_device_class_init, * .class_init = my_device_class_init,
* }; * };
* </programlisting> * </programlisting>
* </example> * </example>
* *
* Introducing new virtual methods requires a class to define its own * Introducing new virtual methods requires a class to define its own
@ -167,31 +167,31 @@ typedef struct InterfaceInfo InterfaceInfo;
* *
* <example> * <example>
* <title>Defining an abstract class</title> * <title>Defining an abstract class</title>
* <programlisting> * <programlisting>
* #include "qdev.h" * #include "qdev.h"
* *
* typedef struct MyDeviceClass * typedef struct MyDeviceClass
* { * {
* DeviceClass parent; * DeviceClass parent;
* *
* void (*frobnicate) (MyDevice *obj); * void (*frobnicate) (MyDevice *obj);
* } MyDeviceClass; * } MyDeviceClass;
* *
* static const TypeInfo my_device_info = { * static const TypeInfo my_device_info = {
* .name = TYPE_MY_DEVICE, * .name = TYPE_MY_DEVICE,
* .parent = TYPE_DEVICE, * .parent = TYPE_DEVICE,
* .instance_size = sizeof(MyDevice), * .instance_size = sizeof(MyDevice),
* .abstract = true, // or set a default in my_device_class_init * .abstract = true, // or set a default in my_device_class_init
* .class_size = sizeof(MyDeviceClass), * .class_size = sizeof(MyDeviceClass),
* }; * };
* *
* void my_device_frobnicate(MyDevice *obj) * void my_device_frobnicate(MyDevice *obj)
* { * {
* MyDeviceClass *klass = MY_DEVICE_GET_CLASS(obj); * MyDeviceClass *klass = MY_DEVICE_GET_CLASS(obj);
* *
* klass->frobnicate(obj); * klass->frobnicate(obj);
* } * }
* </programlisting> * </programlisting>
* </example> * </example>
* *
* Interfaces * Interfaces
@ -236,68 +236,68 @@ typedef struct InterfaceInfo InterfaceInfo;
* *
* <example> * <example>
* <title>Overriding a virtual method</title> * <title>Overriding a virtual method</title>
* <programlisting> * <programlisting>
* typedef struct MyState MyState; * typedef struct MyState MyState;
* *
* typedef void (*MyDoSomething)(MyState *obj); * typedef void (*MyDoSomething)(MyState *obj);
* *
* typedef struct MyClass { * typedef struct MyClass {
* ObjectClass parent_class; * ObjectClass parent_class;
* *
* MyDoSomething do_something; * MyDoSomething do_something;
* } MyClass; * } MyClass;
* *
* static void my_do_something(MyState *obj) * static void my_do_something(MyState *obj)
* { * {
* // do something * // do something
* } * }
* *
* static void my_class_init(ObjectClass *oc, void *data) * static void my_class_init(ObjectClass *oc, void *data)
* { * {
* MyClass *mc = MY_CLASS(oc); * MyClass *mc = MY_CLASS(oc);
* *
* mc->do_something = my_do_something; * mc->do_something = my_do_something;
* } * }
* *
* static const TypeInfo my_type_info = { * static const TypeInfo my_type_info = {
* .name = TYPE_MY, * .name = TYPE_MY,
* .parent = TYPE_OBJECT, * .parent = TYPE_OBJECT,
* .instance_size = sizeof(MyState), * .instance_size = sizeof(MyState),
* .class_size = sizeof(MyClass), * .class_size = sizeof(MyClass),
* .class_init = my_class_init, * .class_init = my_class_init,
* }; * };
* *
* typedef struct DerivedClass { * typedef struct DerivedClass {
* MyClass parent_class; * MyClass parent_class;
* *
* MyDoSomething parent_do_something; * MyDoSomething parent_do_something;
* } DerivedClass; * } DerivedClass;
* *
* static void derived_do_something(MyState *obj) * static void derived_do_something(MyState *obj)
* { * {
* DerivedClass *dc = DERIVED_GET_CLASS(obj); * DerivedClass *dc = DERIVED_GET_CLASS(obj);
* *
* // do something here * // do something here
* dc->parent_do_something(obj); * dc->parent_do_something(obj);
* // do something else here * // do something else here
* } * }
* *
* static void derived_class_init(ObjectClass *oc, void *data) * static void derived_class_init(ObjectClass *oc, void *data)
* { * {
* MyClass *mc = MY_CLASS(oc); * MyClass *mc = MY_CLASS(oc);
* DerivedClass *dc = DERIVED_CLASS(oc); * DerivedClass *dc = DERIVED_CLASS(oc);
* *
* dc->parent_do_something = mc->do_something; * dc->parent_do_something = mc->do_something;
* mc->do_something = derived_do_something; * mc->do_something = derived_do_something;
* } * }
* *
* static const TypeInfo derived_type_info = { * static const TypeInfo derived_type_info = {
* .name = TYPE_DERIVED, * .name = TYPE_DERIVED,
* .parent = TYPE_MY, * .parent = TYPE_MY,
* .class_size = sizeof(DerivedClass), * .class_size = sizeof(DerivedClass),
* .class_init = derived_class_init, * .class_init = derived_class_init,
* }; * };
* </programlisting> * </programlisting>
* </example> * </example>
* *
* Alternatively, object_class_by_name() can be used to obtain the class and * Alternatively, object_class_by_name() can be used to obtain the class and
@ -984,24 +984,24 @@ Object *object_new(const char *typename);
* *
* <example> * <example>
* <title>Creating an object with properties</title> * <title>Creating an object with properties</title>
* <programlisting> * <programlisting>
* Error *err = NULL; * Error *err = NULL;
* Object *obj; * Object *obj;
* *
* obj = object_new_with_props(TYPE_MEMORY_BACKEND_FILE, * obj = object_new_with_props(TYPE_MEMORY_BACKEND_FILE,
* object_get_objects_root(), * object_get_objects_root(),
* "hostmem0", * "hostmem0",
* &err, * &err,
* "share", "yes", * "share", "yes",
* "mem-path", "/dev/shm/somefile", * "mem-path", "/dev/shm/somefile",
* "prealloc", "yes", * "prealloc", "yes",
* "size", "1048576", * "size", "1048576",
* NULL); * NULL);
* *
* if (!obj) { * if (!obj) {
* error_reportf_err(err, "Cannot create memory backend: "); * error_reportf_err(err, "Cannot create memory backend: ");
* } * }
* </programlisting> * </programlisting>
* </example> * </example>
* *
* The returned object will have one stable reference maintained * The returned object will have one stable reference maintained
@ -1053,20 +1053,20 @@ void object_apply_compat_props(Object *obj);
* *
* <example> * <example>
* <title>Update an object's properties</title> * <title>Update an object's properties</title>
* <programlisting> * <programlisting>
* Error *err = NULL; * Error *err = NULL;
* Object *obj = ...get / create object...; * Object *obj = ...get / create object...;
* *
* if (!object_set_props(obj, * if (!object_set_props(obj,
* &err, * &err,
* "share", "yes", * "share", "yes",
* "mem-path", "/dev/shm/somefile", * "mem-path", "/dev/shm/somefile",
* "prealloc", "yes", * "prealloc", "yes",
* "size", "1048576", * "size", "1048576",
* NULL)) { * NULL)) {
* error_reportf_err(err, "Cannot set properties: "); * error_reportf_err(err, "Cannot set properties: ");
* } * }
* </programlisting> * </programlisting>
* </example> * </example>
* *
* The returned object will have one stable reference maintained * The returned object will have one stable reference maintained
@ -1557,15 +1557,15 @@ typedef struct ObjectPropertyIterator {
* *
* <example> * <example>
* <title>Using object property iterators</title> * <title>Using object property iterators</title>
* <programlisting> * <programlisting>
* ObjectProperty *prop; * ObjectProperty *prop;
* ObjectPropertyIterator iter; * ObjectPropertyIterator iter;
* *
* object_property_iter_init(&iter, obj); * object_property_iter_init(&iter, obj);
* while ((prop = object_property_iter_next(&iter))) { * while ((prop = object_property_iter_next(&iter))) {
* ... do something with prop ... * ... do something with prop ...
* } * }
* </programlisting> * </programlisting>
* </example> * </example>
*/ */
void object_property_iter_init(ObjectPropertyIterator *iter, void object_property_iter_init(ObjectPropertyIterator *iter,