mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-19 08:02:15 -06:00
qom: Add code block markup to all code blocks
Convert all example/codelisting markup to Sphinx code-block. There are a few sections where backslashes at the end of lines break code formatting. A comment was added noting that this is an issue. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20200910221526.10041-8-ehabkost@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
9bbfd245c3
commit
6cf164c00f
1 changed files with 56 additions and 79 deletions
|
@ -31,6 +31,8 @@ typedef struct InterfaceInfo InterfaceInfo;
|
||||||
/**
|
/**
|
||||||
* DOC:
|
* DOC:
|
||||||
*
|
*
|
||||||
|
* .. highlight:: c
|
||||||
|
*
|
||||||
* The QEMU Object Model provides a framework for registering user creatable
|
* The QEMU Object Model provides a framework for registering user creatable
|
||||||
* types and instantiating objects from those types. QOM provides the following
|
* types and instantiating objects from those types. QOM provides the following
|
||||||
* features:
|
* features:
|
||||||
|
@ -39,9 +41,9 @@ typedef struct InterfaceInfo InterfaceInfo;
|
||||||
* - Support for single-inheritance of types
|
* - Support for single-inheritance of types
|
||||||
* - Multiple inheritance of stateless interfaces
|
* - Multiple inheritance of stateless interfaces
|
||||||
*
|
*
|
||||||
* <example>
|
* .. code-block:: c
|
||||||
* <title>Creating a minimal type</title>
|
* :caption: Creating a minimal type
|
||||||
* <programlisting>
|
*
|
||||||
* #include "qdev.h"
|
* #include "qdev.h"
|
||||||
*
|
*
|
||||||
* #define TYPE_MY_DEVICE "my-device"
|
* #define TYPE_MY_DEVICE "my-device"
|
||||||
|
@ -68,8 +70,6 @@ typedef struct InterfaceInfo InterfaceInfo;
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* type_init(my_device_register_types)
|
* type_init(my_device_register_types)
|
||||||
* </programlisting>
|
|
||||||
* </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.
|
||||||
* #TypeInfo describes information about the type including what it inherits
|
* #TypeInfo describes information about the type including what it inherits
|
||||||
|
@ -78,8 +78,8 @@ typedef struct InterfaceInfo InterfaceInfo;
|
||||||
* Alternatively several static types could be registered using helper macro
|
* Alternatively several static types could be registered using helper macro
|
||||||
* DEFINE_TYPES()
|
* DEFINE_TYPES()
|
||||||
*
|
*
|
||||||
* <example>
|
* .. code-block:: c
|
||||||
* <programlisting>
|
*
|
||||||
* static const TypeInfo device_types_info[] = {
|
* static const TypeInfo device_types_info[] = {
|
||||||
* {
|
* {
|
||||||
* .name = TYPE_MY_DEVICE_A,
|
* .name = TYPE_MY_DEVICE_A,
|
||||||
|
@ -94,8 +94,6 @@ typedef struct InterfaceInfo InterfaceInfo;
|
||||||
* };
|
* };
|
||||||
*
|
*
|
||||||
* DEFINE_TYPES(device_types_info)
|
* DEFINE_TYPES(device_types_info)
|
||||||
* </programlisting>
|
|
||||||
* </example>
|
|
||||||
*
|
*
|
||||||
* Every type has an #ObjectClass associated with it. #ObjectClass derivatives
|
* Every type has an #ObjectClass associated with it. #ObjectClass derivatives
|
||||||
* are instantiated dynamically but there is only ever one instance for any
|
* are instantiated dynamically but there is only ever one instance for any
|
||||||
|
@ -108,17 +106,19 @@ typedef struct InterfaceInfo InterfaceInfo;
|
||||||
* OBJECT_CHECK() and OBJECT_CLASS_CHECK() to make it easier to convert to a
|
* OBJECT_CHECK() and OBJECT_CLASS_CHECK() to make it easier to convert to a
|
||||||
* specific type:
|
* specific type:
|
||||||
*
|
*
|
||||||
* <example>
|
* .. kernel-doc messes up with the code block below because of the
|
||||||
* <title>Typecasting macros</title>
|
* backslash at the end of lines. This will be fixes if we move this
|
||||||
* <programlisting>
|
* content to qom.rst.
|
||||||
|
*
|
||||||
|
* .. code-block:: c
|
||||||
|
* :caption: Typecasting macros
|
||||||
|
*
|
||||||
* #define MY_DEVICE_GET_CLASS(obj) \
|
* #define MY_DEVICE_GET_CLASS(obj) \
|
||||||
* OBJECT_GET_CLASS(MyDeviceClass, obj, TYPE_MY_DEVICE)
|
* OBJECT_GET_CLASS(MyDeviceClass, obj, TYPE_MY_DEVICE)
|
||||||
* #define MY_DEVICE_CLASS(klass) \
|
* #define MY_DEVICE_CLASS(klass) \
|
||||||
* OBJECT_CLASS_CHECK(MyDeviceClass, klass, TYPE_MY_DEVICE)
|
* OBJECT_CLASS_CHECK(MyDeviceClass, klass, TYPE_MY_DEVICE)
|
||||||
* #define MY_DEVICE(obj) \
|
* #define MY_DEVICE(obj) \
|
||||||
* OBJECT_CHECK(MyDevice, obj, TYPE_MY_DEVICE)
|
* OBJECT_CHECK(MyDevice, obj, TYPE_MY_DEVICE)
|
||||||
* </programlisting>
|
|
||||||
* </example>
|
|
||||||
*
|
*
|
||||||
* Class Initialization
|
* Class Initialization
|
||||||
* ====================
|
* ====================
|
||||||
|
@ -141,9 +141,9 @@ typedef struct InterfaceInfo InterfaceInfo;
|
||||||
* its virtual functions. Here is how the above example might be modified
|
* its virtual functions. Here is how the above example might be modified
|
||||||
* to introduce an overridden virtual function:
|
* to introduce an overridden virtual function:
|
||||||
*
|
*
|
||||||
* <example>
|
* .. code-block:: c
|
||||||
* <title>Overriding a virtual function</title>
|
* :caption: Overriding a virtual function
|
||||||
* <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)
|
||||||
|
@ -158,16 +158,14 @@ typedef struct InterfaceInfo InterfaceInfo;
|
||||||
* .instance_size = sizeof(MyDevice),
|
* .instance_size = sizeof(MyDevice),
|
||||||
* .class_init = my_device_class_init,
|
* .class_init = my_device_class_init,
|
||||||
* };
|
* };
|
||||||
* </programlisting>
|
|
||||||
* </example>
|
|
||||||
*
|
*
|
||||||
* Introducing new virtual methods requires a class to define its own
|
* Introducing new virtual methods requires a class to define its own
|
||||||
* struct and to add a .class_size member to the #TypeInfo. Each method
|
* struct and to add a .class_size member to the #TypeInfo. Each method
|
||||||
* will also have a wrapper function to call it easily:
|
* will also have a wrapper function to call it easily:
|
||||||
*
|
*
|
||||||
* <example>
|
* .. code-block:: c
|
||||||
* <title>Defining an abstract class</title>
|
* :caption: Defining an abstract class
|
||||||
* <programlisting>
|
*
|
||||||
* #include "qdev.h"
|
* #include "qdev.h"
|
||||||
*
|
*
|
||||||
* typedef struct MyDeviceClass
|
* typedef struct MyDeviceClass
|
||||||
|
@ -191,8 +189,6 @@ typedef struct InterfaceInfo InterfaceInfo;
|
||||||
*
|
*
|
||||||
* klass->frobnicate(obj);
|
* klass->frobnicate(obj);
|
||||||
* }
|
* }
|
||||||
* </programlisting>
|
|
||||||
* </example>
|
|
||||||
*
|
*
|
||||||
* Interfaces
|
* Interfaces
|
||||||
* ==========
|
* ==========
|
||||||
|
@ -230,13 +226,13 @@ typedef struct InterfaceInfo InterfaceInfo;
|
||||||
*
|
*
|
||||||
* To invoke the method being overridden, the preferred solution is to store
|
* To invoke the method being overridden, the preferred solution is to store
|
||||||
* the original value in the overriding class before overriding the method.
|
* the original value in the overriding class before overriding the method.
|
||||||
* This corresponds to |[ {super,base}.method(...) ]| in Java and C#
|
* This corresponds to ``{super,base}.method(...)`` in Java and C#
|
||||||
* respectively; this frees the overriding class from hardcoding its parent
|
* respectively; this frees the overriding class from hardcoding its parent
|
||||||
* class, which someone might choose to change at some point.
|
* class, which someone might choose to change at some point.
|
||||||
*
|
*
|
||||||
* <example>
|
* .. code-block:: c
|
||||||
* <title>Overriding a virtual method</title>
|
* :caption: Overriding a virtual method
|
||||||
* <programlisting>
|
*
|
||||||
* typedef struct MyState MyState;
|
* typedef struct MyState MyState;
|
||||||
*
|
*
|
||||||
* typedef void (*MyDoSomething)(MyState *obj);
|
* typedef void (*MyDoSomething)(MyState *obj);
|
||||||
|
@ -297,8 +293,6 @@ typedef struct InterfaceInfo InterfaceInfo;
|
||||||
* .class_size = sizeof(DerivedClass),
|
* .class_size = sizeof(DerivedClass),
|
||||||
* .class_init = derived_class_init,
|
* .class_init = derived_class_init,
|
||||||
* };
|
* };
|
||||||
* </programlisting>
|
|
||||||
* </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
|
||||||
* its non-overridden methods for a specific type. This would correspond to
|
* its non-overridden methods for a specific type. This would correspond to
|
||||||
|
@ -320,18 +314,16 @@ typedef struct InterfaceInfo InterfaceInfo;
|
||||||
* OBJECT_DECLARE_SIMPLE_TYPE macro is suitable, and is commonly placed
|
* OBJECT_DECLARE_SIMPLE_TYPE macro is suitable, and is commonly placed
|
||||||
* in the header file:
|
* in the header file:
|
||||||
*
|
*
|
||||||
* <example>
|
* .. code-block:: c
|
||||||
* <title>Declaring a simple type</title>
|
* :caption: Declaring a simple type
|
||||||
* <programlisting>
|
*
|
||||||
* OBJECT_DECLARE_SIMPLE_TYPE(MyDevice, my_device, MY_DEVICE, DEVICE)
|
* OBJECT_DECLARE_SIMPLE_TYPE(MyDevice, my_device, MY_DEVICE, DEVICE)
|
||||||
* </programlisting>
|
|
||||||
* </example>
|
|
||||||
*
|
*
|
||||||
* This is equivalent to the following:
|
* This is equivalent to the following:
|
||||||
*
|
*
|
||||||
* <example>
|
* .. code-block:: c
|
||||||
* <title>Expansion from declaring a simple type</title>
|
* :caption: Expansion from declaring a simple type
|
||||||
* <programlisting>
|
*
|
||||||
* typedef struct MyDevice MyDevice;
|
* typedef struct MyDevice MyDevice;
|
||||||
* typedef struct MyDeviceClass MyDeviceClass;
|
* typedef struct MyDeviceClass MyDeviceClass;
|
||||||
*
|
*
|
||||||
|
@ -347,8 +339,6 @@ typedef struct InterfaceInfo InterfaceInfo;
|
||||||
* struct MyDeviceClass {
|
* struct MyDeviceClass {
|
||||||
* DeviceClass parent_class;
|
* DeviceClass parent_class;
|
||||||
* };
|
* };
|
||||||
* </programlisting>
|
|
||||||
* </example>
|
|
||||||
*
|
*
|
||||||
* The 'struct MyDevice' needs to be declared separately.
|
* The 'struct MyDevice' needs to be declared separately.
|
||||||
* If the type requires virtual functions to be declared in the class
|
* If the type requires virtual functions to be declared in the class
|
||||||
|
@ -359,18 +349,16 @@ typedef struct InterfaceInfo InterfaceInfo;
|
||||||
* To implement the type, the OBJECT_DEFINE macro family is available.
|
* To implement the type, the OBJECT_DEFINE macro family is available.
|
||||||
* In the simple case the OBJECT_DEFINE_TYPE macro is suitable:
|
* In the simple case the OBJECT_DEFINE_TYPE macro is suitable:
|
||||||
*
|
*
|
||||||
* <example>
|
* .. code-block:: c
|
||||||
* <title>Defining a simple type</title>
|
* :caption: Defining a simple type
|
||||||
* <programlisting>
|
*
|
||||||
* OBJECT_DEFINE_TYPE(MyDevice, my_device, MY_DEVICE, DEVICE)
|
* OBJECT_DEFINE_TYPE(MyDevice, my_device, MY_DEVICE, DEVICE)
|
||||||
* </programlisting>
|
|
||||||
* </example>
|
|
||||||
*
|
*
|
||||||
* This is equivalent to the following:
|
* This is equivalent to the following:
|
||||||
*
|
*
|
||||||
* <example>
|
* .. code-block:: c
|
||||||
* <title>Expansion from defining a simple type</title>
|
* :caption: Expansion from defining a simple type
|
||||||
* <programlisting>
|
*
|
||||||
* static void my_device_finalize(Object *obj);
|
* static void my_device_finalize(Object *obj);
|
||||||
* static void my_device_class_init(ObjectClass *oc, void *data);
|
* static void my_device_class_init(ObjectClass *oc, void *data);
|
||||||
* static void my_device_init(Object *obj);
|
* static void my_device_init(Object *obj);
|
||||||
|
@ -391,8 +379,6 @@ typedef struct InterfaceInfo InterfaceInfo;
|
||||||
* 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>
|
|
||||||
* </example>
|
|
||||||
*
|
*
|
||||||
* This is sufficient to get the type registered with the type
|
* This is sufficient to get the type registered with the type
|
||||||
* system, and the three standard methods now need to be implemented
|
* system, and the three standard methods now need to be implemented
|
||||||
|
@ -402,24 +388,20 @@ typedef struct InterfaceInfo InterfaceInfo;
|
||||||
* OBJECT_DEFINE_TYPE_WITH_INTERFACES() macro can be used instead.
|
* OBJECT_DEFINE_TYPE_WITH_INTERFACES() macro can be used instead.
|
||||||
* This accepts an array of interface type names.
|
* This accepts an array of interface type names.
|
||||||
*
|
*
|
||||||
* <example>
|
* .. code-block:: c
|
||||||
* <title>Defining a simple type implementing interfaces</title>
|
* :caption: Defining a simple type implementing interfaces
|
||||||
* <programlisting>
|
*
|
||||||
* OBJECT_DEFINE_TYPE_WITH_INTERFACES(MyDevice, my_device,
|
* OBJECT_DEFINE_TYPE_WITH_INTERFACES(MyDevice, my_device,
|
||||||
* MY_DEVICE, DEVICE,
|
* MY_DEVICE, DEVICE,
|
||||||
* { TYPE_USER_CREATABLE }, { NULL })
|
* { TYPE_USER_CREATABLE }, { NULL })
|
||||||
* </programlisting>
|
|
||||||
* </example>
|
|
||||||
*
|
*
|
||||||
* If the type is not intended to be instantiated, then then
|
* If the type is not intended to be instantiated, then then
|
||||||
* the OBJECT_DEFINE_ABSTRACT_TYPE() macro can be used instead:
|
* the OBJECT_DEFINE_ABSTRACT_TYPE() macro can be used instead:
|
||||||
*
|
*
|
||||||
* <example>
|
* .. code-block:: c
|
||||||
* <title>Defining a simple type</title>
|
* :caption: Defining a simple abstract type
|
||||||
* <programlisting>
|
*
|
||||||
* OBJECT_DEFINE_ABSTRACT_TYPE(MyDevice, my_device, MY_DEVICE, DEVICE)
|
* OBJECT_DEFINE_ABSTRACT_TYPE(MyDevice, my_device, MY_DEVICE, DEVICE)
|
||||||
* </programlisting>
|
|
||||||
* </example>
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -982,9 +964,9 @@ Object *object_new(const char *typename);
|
||||||
* object will be marked complete once all the properties have been
|
* object will be marked complete once all the properties have been
|
||||||
* processed.
|
* processed.
|
||||||
*
|
*
|
||||||
* <example>
|
* .. code-block:: c
|
||||||
* <title>Creating an object with properties</title>
|
* :caption: Creating an object with properties
|
||||||
* <programlisting>
|
*
|
||||||
* Error *err = NULL;
|
* Error *err = NULL;
|
||||||
* Object *obj;
|
* Object *obj;
|
||||||
*
|
*
|
||||||
|
@ -1001,8 +983,6 @@ Object *object_new(const char *typename);
|
||||||
* if (!obj) {
|
* if (!obj) {
|
||||||
* error_reportf_err(err, "Cannot create memory backend: ");
|
* error_reportf_err(err, "Cannot create memory backend: ");
|
||||||
* }
|
* }
|
||||||
* </programlisting>
|
|
||||||
* </example>
|
|
||||||
*
|
*
|
||||||
* The returned object will have one stable reference maintained
|
* The returned object will have one stable reference maintained
|
||||||
* for as long as it is present in the object hierarchy.
|
* for as long as it is present in the object hierarchy.
|
||||||
|
@ -1051,9 +1031,9 @@ void object_apply_compat_props(Object *obj);
|
||||||
* strings. The propname of %NULL indicates the end of the property
|
* strings. The propname of %NULL indicates the end of the property
|
||||||
* list.
|
* list.
|
||||||
*
|
*
|
||||||
* <example>
|
* .. code-block:: c
|
||||||
* <title>Update an object's properties</title>
|
* :caption: Update an object's properties
|
||||||
* <programlisting>
|
*
|
||||||
* Error *err = NULL;
|
* Error *err = NULL;
|
||||||
* Object *obj = ...get / create object...;
|
* Object *obj = ...get / create object...;
|
||||||
*
|
*
|
||||||
|
@ -1066,8 +1046,6 @@ void object_apply_compat_props(Object *obj);
|
||||||
* NULL)) {
|
* NULL)) {
|
||||||
* error_reportf_err(err, "Cannot set properties: ");
|
* error_reportf_err(err, "Cannot set properties: ");
|
||||||
* }
|
* }
|
||||||
* </programlisting>
|
|
||||||
* </example>
|
|
||||||
*
|
*
|
||||||
* The returned object will have one stable reference maintained
|
* The returned object will have one stable reference maintained
|
||||||
* for as long as it is present in the object hierarchy.
|
* for as long as it is present in the object hierarchy.
|
||||||
|
@ -1155,7 +1133,8 @@ bool object_initialize_child_with_propsv(Object *parentobj,
|
||||||
* object.
|
* object.
|
||||||
* @type: The name of the type of the object to instantiate.
|
* @type: The name of the type of the object to instantiate.
|
||||||
*
|
*
|
||||||
* This is like
|
* This is like::
|
||||||
|
*
|
||||||
* object_initialize_child_with_props(parent, propname,
|
* object_initialize_child_with_props(parent, propname,
|
||||||
* child, sizeof(*child), type,
|
* child, sizeof(*child), type,
|
||||||
* &error_abort, NULL)
|
* &error_abort, NULL)
|
||||||
|
@ -1555,9 +1534,9 @@ typedef struct ObjectPropertyIterator {
|
||||||
*
|
*
|
||||||
* Typical usage pattern would be
|
* Typical usage pattern would be
|
||||||
*
|
*
|
||||||
* <example>
|
* .. code-block:: c
|
||||||
* <title>Using object property iterators</title>
|
* :caption: Using object property iterators
|
||||||
* <programlisting>
|
*
|
||||||
* ObjectProperty *prop;
|
* ObjectProperty *prop;
|
||||||
* ObjectPropertyIterator iter;
|
* ObjectPropertyIterator iter;
|
||||||
*
|
*
|
||||||
|
@ -1565,8 +1544,6 @@ typedef struct ObjectPropertyIterator {
|
||||||
* while ((prop = object_property_iter_next(&iter))) {
|
* while ((prop = object_property_iter_next(&iter))) {
|
||||||
* ... do something with prop ...
|
* ... do something with prop ...
|
||||||
* }
|
* }
|
||||||
* </programlisting>
|
|
||||||
* </example>
|
|
||||||
*/
|
*/
|
||||||
void object_property_iter_init(ObjectPropertyIterator *iter,
|
void object_property_iter_init(ObjectPropertyIterator *iter,
|
||||||
Object *obj);
|
Object *obj);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue