All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/9] docs: Convert QOM documentation to kernel-doc + Sphinx
@ 2020-09-10 22:15 Eduardo Habkost
  2020-09-10 22:15 ` [PATCH 1/9] qom: Document all function parameters in doc comments Eduardo Habkost
                   ` (9 more replies)
  0 siblings, 10 replies; 12+ messages in thread
From: Eduardo Habkost @ 2020-09-10 22:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Daniel P. Berrangé, Eduardo Habkost, Peter Maydell

This converts the existing gtk-doc markup in object.h (that
probably was never rendered into an actual document) to
kernel-doc + Sphinx syntax, and reference them at
docs/devel/qom.rst.

Eduardo Habkost (9):
  qom: Document all function parameters in doc comments
  qom: Use kernel-doc private/public tags in structs
  qom: Use ``code`` Sphinx syntax where appropriate
  qom: Add kernel-doc markup to introduction doc comment
  qom: Reformat section titles using Sphinx syntax
  qom: Indent existing code examples
  qom: Add code block markup to all code blocks
  docs: Create docs/devel/qom.rst
  docs: Move object.h overview doc comment to qom.rst

 docs/devel/index.rst |   1 +
 docs/devel/qom.rst   | 378 ++++++++++++++++++++++++++++++
 include/qom/object.h | 547 ++++++++-----------------------------------
 3 files changed, 475 insertions(+), 451 deletions(-)
 create mode 100644 docs/devel/qom.rst

-- 
2.26.2




^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/9] qom: Document all function parameters in doc comments
  2020-09-10 22:15 [PATCH 0/9] docs: Convert QOM documentation to kernel-doc + Sphinx Eduardo Habkost
@ 2020-09-10 22:15 ` Eduardo Habkost
  2020-09-10 22:15 ` [PATCH 2/9] qom: Use kernel-doc private/public tags in structs Eduardo Habkost
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Eduardo Habkost @ 2020-09-10 22:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Daniel P. Berrangé, Eduardo Habkost, Peter Maydell

kernel-doc requires all function parameters to be documented, so
document them all.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 include/qom/object.h | 47 ++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 45 insertions(+), 2 deletions(-)

diff --git a/include/qom/object.h b/include/qom/object.h
index 056f67ab3b..ad2b91ec6c 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -1176,6 +1176,11 @@ Object *object_dynamic_cast(Object *obj, const char *typename);
 
 /**
  * object_dynamic_cast_assert:
+ * @obj: The object to cast.
+ * @typename: The @typename to cast to.
+ * @file: Source code file where function was called
+ * @line: Source code line where function was called
+ * @func: Name of function where this function was called
  *
  * See object_dynamic_cast() for a description of the parameters of this
  * function.  The only difference in behavior is that this function asserts
@@ -1252,6 +1257,9 @@ type_init(do_qemu_init_ ## type_array)
  * object_class_dynamic_cast_assert:
  * @klass: The #ObjectClass to attempt to cast.
  * @typename: The QOM typename of the class to cast to.
+ * @file: Source code file where function was called
+ * @line: Source code line where function was called
+ * @func: Name of function where this function was called
  *
  * See object_class_dynamic_cast() for a description of the parameters
  * of this function.  The only difference in behavior is that this function
@@ -1403,6 +1411,23 @@ ObjectProperty *object_property_try_add(Object *obj, const char *name,
  * object_property_add:
  * Same as object_property_try_add() with @errp hardcoded to
  * &error_abort.
+ *
+ * @obj: the object to add a property to
+ * @name: the name of the property.  This can contain any character except for
+ *  a forward slash.  In general, you should use hyphens '-' instead of
+ *  underscores '_' when naming properties.
+ * @type: the type name of the property.  This namespace is pretty loosely
+ *   defined.  Sub namespaces are constructed by using a prefix and then
+ *   to angle brackets.  For instance, the type 'virtio-net-pci' in the
+ *   'link' namespace would be 'link<virtio-net-pci>'.
+ * @get: The getter to be called to read a property.  If this is NULL, then
+ *   the property cannot be read.
+ * @set: the setter to be called to write a property.  If this is NULL,
+ *   then the property cannot be written.
+ * @release: called when the property is removed from the object.  This is
+ *   meant to allow a property to free its opaque upon object
+ *   destruction.  This may be NULL.
+ * @opaque: an opaque pointer to pass to the callbacks for the property
  */
 ObjectProperty *object_property_add(Object *obj, const char *name,
                                     const char *type,
@@ -1476,6 +1501,7 @@ typedef struct ObjectPropertyIterator {
 
 /**
  * object_property_iter_init:
+ * @iter: the iterator instance
  * @obj: the object
  *
  * Initializes an iterator for traversing all properties
@@ -1504,6 +1530,7 @@ void object_property_iter_init(ObjectPropertyIterator *iter,
 
 /**
  * object_class_property_iter_init:
+ * @iter: the iterator instance
  * @klass: the class
  *
  * Initializes an iterator for traversing all properties
@@ -1551,6 +1578,7 @@ bool object_property_get(Object *obj, const char *name, Visitor *v,
 
 /**
  * object_property_set_str:
+ * @obj: the object
  * @name: the name of the property
  * @value: the value to be written to the property
  * @errp: returns an error if this function fails
@@ -1577,6 +1605,7 @@ char *object_property_get_str(Object *obj, const char *name,
 
 /**
  * object_property_set_link:
+ * @obj: the object
  * @name: the name of the property
  * @value: the value to be written to the property
  * @errp: returns an error if this function fails
@@ -1607,6 +1636,7 @@ Object *object_property_get_link(Object *obj, const char *name,
 
 /**
  * object_property_set_bool:
+ * @obj: the object
  * @name: the name of the property
  * @value: the value to be written to the property
  * @errp: returns an error if this function fails
@@ -1632,6 +1662,7 @@ bool object_property_get_bool(Object *obj, const char *name,
 
 /**
  * object_property_set_int:
+ * @obj: the object
  * @name: the name of the property
  * @value: the value to be written to the property
  * @errp: returns an error if this function fails
@@ -1657,6 +1688,7 @@ int64_t object_property_get_int(Object *obj, const char *name,
 
 /**
  * object_property_set_uint:
+ * @obj: the object
  * @name: the name of the property
  * @value: the value to be written to the property
  * @errp: returns an error if this function fails
@@ -1780,6 +1812,7 @@ Object *object_get_internal_root(void);
 
 /**
  * object_get_canonical_path_component:
+ * @obj: the object
  *
  * Returns: The final component in the object's canonical path.  The canonical
  * path is the path within the composition tree starting from the root.
@@ -1789,6 +1822,7 @@ const char *object_get_canonical_path_component(const Object *obj);
 
 /**
  * object_get_canonical_path:
+ * @obj: the object
  *
  * Returns: The canonical path for a object, newly allocated.  This is
  * the path within the composition tree starting from the root.  Use
@@ -1878,6 +1912,10 @@ ObjectProperty *object_property_try_add_child(Object *obj, const char *name,
 
 /**
  * object_property_add_child:
+ * @obj: the object to add a property to
+ * @name: the name of the property
+ * @child: the child object
+ *
  * Same as object_property_try_add_child() with @errp hardcoded to
  * &error_abort
  */
@@ -1895,13 +1933,17 @@ typedef enum {
 
 /**
  * object_property_allow_set_link:
+ * @obj: the object to add a property to
+ * @name: the name of the property
+ * @child: the child object
+ * @errp: pointer to error object
  *
  * The default implementation of the object_property_add_link() check()
  * callback function.  It allows the link property to be set and never returns
  * an error.
  */
-void object_property_allow_set_link(const Object *, const char *,
-                                    Object *, Error **);
+void object_property_allow_set_link(const Object *obj, const char *name,
+                                    Object *child, Error **errp);
 
 /**
  * object_property_add_link:
@@ -1995,6 +2037,7 @@ ObjectProperty *object_class_property_add_bool(ObjectClass *klass,
  * @obj: the object to add a property to
  * @name: the name of the property
  * @typename: the name of the enum data type
+ * @lookup: enum value namelookup table
  * @get: the getter or %NULL if the property is write-only.
  * @set: the setter or %NULL if the property is read-only
  *
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/9] qom: Use kernel-doc private/public tags in structs
  2020-09-10 22:15 [PATCH 0/9] docs: Convert QOM documentation to kernel-doc + Sphinx Eduardo Habkost
  2020-09-10 22:15 ` [PATCH 1/9] qom: Document all function parameters in doc comments Eduardo Habkost
@ 2020-09-10 22:15 ` Eduardo Habkost
  2020-09-10 22:15 ` [PATCH 3/9] qom: Use ``code`` Sphinx syntax where appropriate Eduardo Habkost
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Eduardo Habkost @ 2020-09-10 22:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Daniel P. Berrangé, Eduardo Habkost, Peter Maydell

Use kernel-doc syntax for indicating private and public struct
fields.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 include/qom/object.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/qom/object.h b/include/qom/object.h
index ad2b91ec6c..f85718380d 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -520,7 +520,7 @@ typedef void (ObjectFree)(void *obj);
  */
 struct ObjectClass
 {
-    /*< private >*/
+    /* private: */
     Type type;
     GSList *interfaces;
 
@@ -546,7 +546,7 @@ struct ObjectClass
  */
 struct Object
 {
-    /*< private >*/
+    /* private: */
     ObjectClass *class;
     ObjectFree *free;
     GHashTable *properties;
@@ -905,7 +905,7 @@ struct InterfaceInfo {
 struct InterfaceClass
 {
     ObjectClass parent_class;
-    /*< private >*/
+    /* private: */
     ObjectClass *concrete_class;
     Type interface_type;
 };
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/9] qom: Use ``code`` Sphinx syntax where appropriate
  2020-09-10 22:15 [PATCH 0/9] docs: Convert QOM documentation to kernel-doc + Sphinx Eduardo Habkost
  2020-09-10 22:15 ` [PATCH 1/9] qom: Document all function parameters in doc comments Eduardo Habkost
  2020-09-10 22:15 ` [PATCH 2/9] qom: Use kernel-doc private/public tags in structs Eduardo Habkost
@ 2020-09-10 22:15 ` Eduardo Habkost
  2020-09-10 22:15 ` [PATCH 4/9] qom: Add kernel-doc markup to introduction doc comment Eduardo Habkost
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Eduardo Habkost @ 2020-09-10 22:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Daniel P. Berrangé, Eduardo Habkost, Peter Maydell

Replace gtkdoc markup with Sphinx ``code`` syntax.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 include/qom/object.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/qom/object.h b/include/qom/object.h
index f85718380d..4fb528d841 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -203,8 +203,8 @@ typedef struct InterfaceInfo InterfaceInfo;
  * an interface instance should always be of incomplete type in order to be
  * sure it cannot be dereferenced.  That is, you should define the
  * 'typedef struct SomethingIf SomethingIf' so that you can pass around
- * 'SomethingIf *si' arguments, but not define a 'struct SomethingIf { ... }'.
- * The only things you can validly do with a 'SomethingIf *' are to pass it as
+ * ``SomethingIf *si`` arguments, but not define a ``struct SomethingIf { ... }``.
+ * The only things you can validly do with a ``SomethingIf *`` are to pass it as
  * an argument to a method on its corresponding SomethingIfClass, or to
  * dynamically cast it to an object that implements the interface.
  *
@@ -301,7 +301,7 @@ typedef struct InterfaceInfo InterfaceInfo;
  *
  * 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
- * |[ MyClass::method(...) ]| in C++.
+ * ``MyClass::method(...)`` in C++.
  *
  * The first example of such a QOM method was #CPUClass.reset,
  * another example is #DeviceClass.realize.
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 4/9] qom: Add kernel-doc markup to introduction doc comment
  2020-09-10 22:15 [PATCH 0/9] docs: Convert QOM documentation to kernel-doc + Sphinx Eduardo Habkost
                   ` (2 preceding siblings ...)
  2020-09-10 22:15 ` [PATCH 3/9] qom: Use ``code`` Sphinx syntax where appropriate Eduardo Habkost
@ 2020-09-10 22:15 ` Eduardo Habkost
  2020-09-10 22:15 ` [PATCH 5/9] qom: Reformat section titles using Sphinx syntax Eduardo Habkost
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Eduardo Habkost @ 2020-09-10 22:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Daniel P. Berrangé, Eduardo Habkost, Peter Maydell

Add DOC: section keyword to introduction doc comment, so it will
be rendered by kernel-doc.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 include/qom/object.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/include/qom/object.h b/include/qom/object.h
index 4fb528d841..d2eecdf872 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -29,9 +29,7 @@ typedef struct InterfaceInfo InterfaceInfo;
 #define TYPE_OBJECT "object"
 
 /**
- * SECTION:object.h
- * @title:Base Object Type System
- * @short_description: interfaces for creating new types and objects
+ * DOC:
  *
  * The QEMU Object Model provides a framework for registering user creatable
  * types and instantiating objects from those types.  QOM provides the following
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 5/9] qom: Reformat section titles using Sphinx syntax
  2020-09-10 22:15 [PATCH 0/9] docs: Convert QOM documentation to kernel-doc + Sphinx Eduardo Habkost
                   ` (3 preceding siblings ...)
  2020-09-10 22:15 ` [PATCH 4/9] qom: Add kernel-doc markup to introduction doc comment Eduardo Habkost
@ 2020-09-10 22:15 ` Eduardo Habkost
  2020-09-10 22:15 ` [PATCH 6/9] qom: Indent existing code examples Eduardo Habkost
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Eduardo Habkost @ 2020-09-10 22:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Daniel P. Berrangé, Eduardo Habkost, Peter Maydell

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 include/qom/object.h | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/include/qom/object.h b/include/qom/object.h
index d2eecdf872..da9ecb310f 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -120,7 +120,8 @@ typedef struct InterfaceInfo InterfaceInfo;
  *   </programlisting>
  * </example>
  *
- * # Class Initialization #
+ * Class Initialization
+ * ====================
  *
  * Before an object is initialized, the class for the object must be
  * initialized.  There is only one class object for all instance objects
@@ -193,7 +194,8 @@ typedef struct InterfaceInfo InterfaceInfo;
  *   </programlisting>
  * </example>
  *
- * # Interfaces #
+ * Interfaces
+ * ==========
  *
  * Interfaces allow a limited form of multiple inheritance.  Instances are
  * similar to normal types except for the fact that are only defined by
@@ -206,7 +208,8 @@ typedef struct InterfaceInfo InterfaceInfo;
  * an argument to a method on its corresponding SomethingIfClass, or to
  * dynamically cast it to an object that implements the interface.
  *
- * # Methods #
+ * Methods
+ * =======
  *
  * A <emphasis>method</emphasis> is a function within the namespace scope of
  * a class. It usually operates on the object instance by passing it as a
@@ -304,7 +307,8 @@ typedef struct InterfaceInfo InterfaceInfo;
  * The first example of such a QOM method was #CPUClass.reset,
  * another example is #DeviceClass.realize.
  *
- * # Standard type declaration and definition macros #
+ * Standard type declaration and definition macros
+ * ===============================================
  *
  * A lot of the code outlined above follows a standard pattern and naming
  * convention. To reduce the amount of boilerplate code that needs to be
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 6/9] qom: Indent existing code examples
  2020-09-10 22:15 [PATCH 0/9] docs: Convert QOM documentation to kernel-doc + Sphinx Eduardo Habkost
                   ` (4 preceding siblings ...)
  2020-09-10 22:15 ` [PATCH 5/9] qom: Reformat section titles using Sphinx syntax Eduardo Habkost
@ 2020-09-10 22:15 ` Eduardo Habkost
  2020-09-10 22:15 ` [PATCH 7/9] qom: Add code block markup to all code blocks Eduardo Habkost
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Eduardo Habkost @ 2020-09-10 22:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Daniel P. Berrangé, Eduardo Habkost, Peter Maydell

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>
---
 include/qom/object.h | 376 +++++++++++++++++++++----------------------
 1 file changed, 188 insertions(+), 188 deletions(-)

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



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 7/9] qom: Add code block markup to all code blocks
  2020-09-10 22:15 [PATCH 0/9] docs: Convert QOM documentation to kernel-doc + Sphinx Eduardo Habkost
                   ` (5 preceding siblings ...)
  2020-09-10 22:15 ` [PATCH 6/9] qom: Indent existing code examples Eduardo Habkost
@ 2020-09-10 22:15 ` Eduardo Habkost
  2020-09-10 22:15 ` [PATCH 8/9] docs: Create docs/devel/qom.rst Eduardo Habkost
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Eduardo Habkost @ 2020-09-10 22:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Daniel P. Berrangé, Eduardo Habkost, Peter Maydell

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>
---
 include/qom/object.h | 135 ++++++++++++++++++-------------------------
 1 file changed, 56 insertions(+), 79 deletions(-)

diff --git a/include/qom/object.h b/include/qom/object.h
index 5d22ec95b2..75ef97da31 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -31,6 +31,8 @@ typedef struct InterfaceInfo InterfaceInfo;
 /**
  * DOC:
  *
+ * .. highlight:: c
+ *
  * The QEMU Object Model provides a framework for registering user creatable
  * types and instantiating objects from those types.  QOM provides the following
  * features:
@@ -39,9 +41,9 @@ typedef struct InterfaceInfo InterfaceInfo;
  *  - Support for single-inheritance of types
  *  - Multiple inheritance of stateless interfaces
  *
- * <example>
- *   <title>Creating a minimal type</title>
- *      <programlisting>
+ * .. code-block::
+ *    :caption: Creating a minimal type
+ *
  *    #include "qdev.h"
  *
  *    #define TYPE_MY_DEVICE "my-device"
@@ -68,8 +70,6 @@ typedef struct InterfaceInfo InterfaceInfo;
  *    }
  *
  *    type_init(my_device_register_types)
- *      </programlisting>
- * </example>
  *
  * In the above example, we create a simple type that is described by #TypeInfo.
  * #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
  * DEFINE_TYPES()
  *
- * <example>
- *      <programlisting>
+ * .. code-block::
+ *
  *    static const TypeInfo device_types_info[] = {
  *        {
  *            .name = TYPE_MY_DEVICE_A,
@@ -94,8 +94,6 @@ typedef struct InterfaceInfo InterfaceInfo;
  *    };
  *
  *    DEFINE_TYPES(device_types_info)
- *      </programlisting>
- * </example>
  *
  * Every type has an #ObjectClass associated with it.  #ObjectClass derivatives
  * 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
  * specific type:
  *
- * <example>
- *   <title>Typecasting macros</title>
- *   <programlisting>
+ * .. kernel-doc messes up with the code block below because of the
+ *    backslash at the end of lines.  This will be fixes if we move this
+ *    content to qom.rst.
+ *
+ * .. code-block::
+ *    :caption: Typecasting macros
+ *
  *    #define MY_DEVICE_GET_CLASS(obj) \
  *       OBJECT_GET_CLASS(MyDeviceClass, obj, TYPE_MY_DEVICE)
  *    #define MY_DEVICE_CLASS(klass) \
  *       OBJECT_CLASS_CHECK(MyDeviceClass, klass, TYPE_MY_DEVICE)
  *    #define MY_DEVICE(obj) \
  *       OBJECT_CHECK(MyDevice, obj, TYPE_MY_DEVICE)
- *   </programlisting>
- * </example>
  *
  * Class Initialization
  * ====================
@@ -141,9 +141,9 @@ typedef struct InterfaceInfo InterfaceInfo;
  * its virtual functions.  Here is how the above example might be modified
  * to introduce an overridden virtual function:
  *
- * <example>
- *   <title>Overriding a virtual function</title>
- *      <programlisting>
+ * .. code-block::
+ *    :caption: Overriding a virtual function
+ *
  *    #include "qdev.h"
  *
  *    void my_device_class_init(ObjectClass *klass, void *class_data)
@@ -158,16 +158,14 @@ typedef struct InterfaceInfo InterfaceInfo;
  *        .instance_size = sizeof(MyDevice),
  *        .class_init = my_device_class_init,
  *    };
- *      </programlisting>
- * </example>
  *
  * Introducing new virtual methods requires a class to define its own
  * struct and to add a .class_size member to the #TypeInfo.  Each method
  * will also have a wrapper function to call it easily:
  *
- * <example>
- *   <title>Defining an abstract class</title>
- *      <programlisting>
+ * .. code-block::
+ *    :caption: Defining an abstract class
+ *
  *    #include "qdev.h"
  *
  *    typedef struct MyDeviceClass
@@ -191,8 +189,6 @@ typedef struct InterfaceInfo InterfaceInfo;
  *
  *        klass->frobnicate(obj);
  *    }
- *      </programlisting>
- * </example>
  *
  * Interfaces
  * ==========
@@ -230,13 +226,13 @@ typedef struct InterfaceInfo InterfaceInfo;
  *
  * To invoke the method being overridden, the preferred solution is to store
  * 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
  * class, which someone might choose to change at some point.
  *
- * <example>
- *   <title>Overriding a virtual method</title>
- *      <programlisting>
+ * .. code-block::
+ *    :caption: Overriding a virtual method
+ *
  *    typedef struct MyState MyState;
  *
  *    typedef void (*MyDoSomething)(MyState *obj);
@@ -297,8 +293,6 @@ typedef struct InterfaceInfo InterfaceInfo;
  *        .class_size = sizeof(DerivedClass),
  *        .class_init = derived_class_init,
  *    };
- *      </programlisting>
- * </example>
  *
  * 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
@@ -320,18 +314,16 @@ typedef struct InterfaceInfo InterfaceInfo;
  * OBJECT_DECLARE_SIMPLE_TYPE macro is suitable, and is commonly placed
  * in the header file:
  *
- * <example>
- *   <title>Declaring a simple type</title>
- *   <programlisting>
+ * .. code-block::
+ *    :caption: Declaring a simple type
+ *
  *     OBJECT_DECLARE_SIMPLE_TYPE(MyDevice, my_device, MY_DEVICE, DEVICE)
- *   </programlisting>
- * </example>
  *
  * This is equivalent to the following:
  *
- * <example>
- *   <title>Expansion from declaring a simple type</title>
- *   <programlisting>
+ * .. code-block::
+ *    :caption: Expansion from declaring a simple type
+ *
  *     typedef struct MyDevice MyDevice;
  *     typedef struct MyDeviceClass MyDeviceClass;
  *
@@ -347,8 +339,6 @@ typedef struct InterfaceInfo InterfaceInfo;
  *     struct MyDeviceClass {
  *         DeviceClass parent_class;
  *     };
- *   </programlisting>
- * </example>
  *
  * The 'struct MyDevice' needs to be declared separately.
  * 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.
  * In the simple case the OBJECT_DEFINE_TYPE macro is suitable:
  *
- * <example>
- *   <title>Defining a simple type</title>
- *   <programlisting>
+ * .. code-block::
+ *    :caption: Defining a simple type
+ *
  *     OBJECT_DEFINE_TYPE(MyDevice, my_device, MY_DEVICE, DEVICE)
- *   </programlisting>
- * </example>
  *
  * This is equivalent to the following:
  *
- * <example>
- *   <title>Expansion from defining a simple type</title>
- *   <programlisting>
+ * .. code-block::
+ *    :caption: Expansion from defining a simple type
+ *
  *     static void my_device_finalize(Object *obj);
  *     static void my_device_class_init(ObjectClass *oc, void *data);
  *     static void my_device_init(Object *obj);
@@ -391,8 +379,6 @@ typedef struct InterfaceInfo InterfaceInfo;
  *         type_register_static(&my_device_info);
  *     }
  *     type_init(my_device_register_types);
- *   </programlisting>
- * </example>
  *
  * This is sufficient to get the type registered with the type
  * 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.
  * This accepts an array of interface type names.
  *
- * <example>
- *   <title>Defining a simple type implementing interfaces</title>
- *   <programlisting>
+ * .. code-block::
+ *    :caption: Defining a simple type implementing interfaces
+ *
  *     OBJECT_DEFINE_TYPE_WITH_INTERFACES(MyDevice, my_device,
  *                                        MY_DEVICE, DEVICE,
  *                                        { TYPE_USER_CREATABLE }, { NULL })
- *   </programlisting>
- * </example>
  *
  * If the type is not intended to be instantiated, then then
  * the OBJECT_DEFINE_ABSTRACT_TYPE() macro can be used instead:
  *
- * <example>
- *   <title>Defining a simple type</title>
- *   <programlisting>
+ * .. code-block::
+ *    :caption: Defining a simple abstract type
+ *
  *     OBJECT_DEFINE_ABSTRACT_TYPE(MyDevice, my_device, MY_DEVICE, DEVICE)
- *   </programlisting>
- * </example>
  */
 
 
@@ -979,9 +961,9 @@ Object *object_new(const char *typename);
  * object will be marked complete once all the properties have been
  * processed.
  *
- * <example>
- *   <title>Creating an object with properties</title>
- *      <programlisting>
+ * .. code-block::
+ *    :caption: Creating an object with properties
+ *
  *      Error *err = NULL;
  *      Object *obj;
  *
@@ -998,8 +980,6 @@ Object *object_new(const char *typename);
  *      if (!obj) {
  *        error_reportf_err(err, "Cannot create memory backend: ");
  *      }
- *      </programlisting>
- * </example>
  *
  * The returned object will have one stable reference maintained
  * for as long as it is present in the object hierarchy.
@@ -1048,9 +1028,9 @@ void object_apply_compat_props(Object *obj);
  * strings. The propname of %NULL indicates the end of the property
  * list.
  *
- * <example>
- *   <title>Update an object's properties</title>
- *      <programlisting>
+ * .. code-block::
+ *    :caption: Update an object's properties
+ *
  *      Error *err = NULL;
  *      Object *obj = ...get / create object...;
  *
@@ -1063,8 +1043,6 @@ void object_apply_compat_props(Object *obj);
  *                            NULL)) {
  *        error_reportf_err(err, "Cannot set properties: ");
  *      }
- *      </programlisting>
- * </example>
  *
  * The returned object will have one stable reference maintained
  * for as long as it is present in the object hierarchy.
@@ -1152,10 +1130,11 @@ bool object_initialize_child_with_propsv(Object *parentobj,
  * object.
  * @type: The name of the type of the object to instantiate.
  *
- * This is like
- * object_initialize_child_with_props(parent, propname,
- *                                    child, sizeof(*child), type,
- *                                    &error_abort, NULL)
+ * This is like::
+ *
+ *   object_initialize_child_with_props(parent, propname,
+ *                                      child, sizeof(*child), type,
+ *                                      &error_abort, NULL)
  */
 #define object_initialize_child(parent, propname, child, type)          \
     object_initialize_child_internal((parent), (propname),              \
@@ -1514,9 +1493,9 @@ typedef struct ObjectPropertyIterator {
  *
  * Typical usage pattern would be
  *
- * <example>
- *   <title>Using object property iterators</title>
- *      <programlisting>
+ * .. code-block:: c
+ *    :caption: Using object property iterators
+ *
  *      ObjectProperty *prop;
  *      ObjectPropertyIterator iter;
  *
@@ -1524,8 +1503,6 @@ typedef struct ObjectPropertyIterator {
  *      while ((prop = object_property_iter_next(&iter))) {
  *        ... do something with prop ...
  *      }
- *      </programlisting>
- * </example>
  */
 void object_property_iter_init(ObjectPropertyIterator *iter,
                                Object *obj);
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 8/9] docs: Create docs/devel/qom.rst
  2020-09-10 22:15 [PATCH 0/9] docs: Convert QOM documentation to kernel-doc + Sphinx Eduardo Habkost
                   ` (6 preceding siblings ...)
  2020-09-10 22:15 ` [PATCH 7/9] qom: Add code block markup to all code blocks Eduardo Habkost
@ 2020-09-10 22:15 ` Eduardo Habkost
  2020-09-10 22:15 ` [PATCH 9/9] docs: Move object.h overview doc comment to qom.rst Eduardo Habkost
  2020-09-22  9:38 ` [PATCH 0/9] docs: Convert QOM documentation to kernel-doc + Sphinx Paolo Bonzini
  9 siblings, 0 replies; 12+ messages in thread
From: Eduardo Habkost @ 2020-09-10 22:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Daniel P. Berrangé, Eduardo Habkost, Peter Maydell

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 docs/devel/index.rst | 1 +
 docs/devel/qom.rst   | 5 +++++
 2 files changed, 6 insertions(+)
 create mode 100644 docs/devel/qom.rst

diff --git a/docs/devel/index.rst b/docs/devel/index.rst
index 04773ce076..c34b43ec28 100644
--- a/docs/devel/index.rst
+++ b/docs/devel/index.rst
@@ -31,3 +31,4 @@ Contents:
    reset
    s390-dasd-ipl
    clocks
+   qom
diff --git a/docs/devel/qom.rst b/docs/devel/qom.rst
new file mode 100644
index 0000000000..dc5be79a4a
--- /dev/null
+++ b/docs/devel/qom.rst
@@ -0,0 +1,5 @@
+===========================
+The QEMU Object Model (QOM)
+===========================
+
+.. kernel-doc:: include/qom/object.h
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 9/9] docs: Move object.h overview doc comment to qom.rst
  2020-09-10 22:15 [PATCH 0/9] docs: Convert QOM documentation to kernel-doc + Sphinx Eduardo Habkost
                   ` (7 preceding siblings ...)
  2020-09-10 22:15 ` [PATCH 8/9] docs: Create docs/devel/qom.rst Eduardo Habkost
@ 2020-09-10 22:15 ` Eduardo Habkost
  2020-09-11  0:23   ` fixup! " Eduardo Habkost
  2020-09-22  9:38 ` [PATCH 0/9] docs: Convert QOM documentation to kernel-doc + Sphinx Paolo Bonzini
  9 siblings, 1 reply; 12+ messages in thread
From: Eduardo Habkost @ 2020-09-10 22:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Daniel P. Berrangé, Eduardo Habkost, Peter Maydell

Move the whole contents of the overview doc comment from object.h
to qom.rst.

This makes the documentation source easier to read and edit, and
also solves the backslash escaping issue at the typecasting macro
examples.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 docs/devel/qom.rst   | 373 ++++++++++++++++++++++++++++++++++++++++++
 include/qom/object.h | 377 -------------------------------------------
 2 files changed, 373 insertions(+), 377 deletions(-)

diff --git a/docs/devel/qom.rst b/docs/devel/qom.rst
index dc5be79a4a..2070a2ced4 100644
--- a/docs/devel/qom.rst
+++ b/docs/devel/qom.rst
@@ -2,4 +2,377 @@
 The QEMU Object Model (QOM)
 ===========================
 
+.. highlight:: c
+
+The QEMU Object Model provides a framework for registering user creatable
+types and instantiating objects from those types.  QOM provides the following
+features:
+
+ - System for dynamically registering types
+ - Support for single-inheritance of types
+ - Multiple inheritance of stateless interfaces
+
+.. code-block::
+   :caption: Creating a minimal type
+
+   #include "qdev.h"
+
+   #define TYPE_MY_DEVICE "my-device"
+
+   // No new virtual functions: we can reuse the typedef for the
+   // superclass.
+   typedef DeviceClass MyDeviceClass;
+   typedef struct MyDevice
+   {
+       DeviceState parent;
+
+       int reg0, reg1, reg2;
+   } MyDevice;
+
+   static const TypeInfo my_device_info = {
+       .name = TYPE_MY_DEVICE,
+       .parent = TYPE_DEVICE,
+       .instance_size = sizeof(MyDevice),
+   };
+
+   static void my_device_register_types(void)
+   {
+       type_register_static(&my_device_info);
+   }
+
+   type_init(my_device_register_types)
+
+In the above example, we create a simple type that is described by #TypeInfo.
+#TypeInfo describes information about the type including what it inherits
+from, the instance and class size, and constructor/destructor hooks.
+
+Alternatively several static types could be registered using helper macro
+DEFINE_TYPES()
+
+.. code-block::
+
+   static const TypeInfo device_types_info[] = {
+       {
+           .name = TYPE_MY_DEVICE_A,
+           .parent = TYPE_DEVICE,
+           .instance_size = sizeof(MyDeviceA),
+       },
+       {
+           .name = TYPE_MY_DEVICE_B,
+           .parent = TYPE_DEVICE,
+           .instance_size = sizeof(MyDeviceB),
+       },
+   };
+
+   DEFINE_TYPES(device_types_info)
+
+Every type has an #ObjectClass associated with it.  #ObjectClass derivatives
+are instantiated dynamically but there is only ever one instance for any
+given type.  The #ObjectClass typically holds a table of function pointers
+for the virtual methods implemented by this type.
+
+Using object_new(), a new #Object derivative will be instantiated.  You can
+cast an #Object to a subclass (or base-class) type using
+object_dynamic_cast().  You typically want to define macro wrappers around
+OBJECT_CHECK() and OBJECT_CLASS_CHECK() to make it easier to convert to a
+specific type:
+
+.. code-block::
+   :caption: Typecasting macros
+
+#define MY_DEVICE_GET_CLASS(obj) \
+      OBJECT_GET_CLASS(MyDeviceClass, obj, TYPE_MY_DEVICE)
+   #define MY_DEVICE_CLASS(klass) \
+      OBJECT_CLASS_CHECK(MyDeviceClass, klass, TYPE_MY_DEVICE)
+   #define MY_DEVICE(obj) \
+      OBJECT_CHECK(MyDevice, obj, TYPE_MY_DEVICE)
+
+Class Initialization
+====================
+
+Before an object is initialized, the class for the object must be
+initialized.  There is only one class object for all instance objects
+that is created lazily.
+
+Classes are initialized by first initializing any parent classes (if
+necessary).  After the parent class object has initialized, it will be
+copied into the current class object and any additional storage in the
+class object is zero filled.
+
+The effect of this is that classes automatically inherit any virtual
+function pointers that the parent class has already initialized.  All
+other fields will be zero filled.
+
+Once all of the parent classes have been initialized, #TypeInfo::class_init
+is called to let the class being instantiated provide default initialize for
+its virtual functions.  Here is how the above example might be modified
+to introduce an overridden virtual function:
+
+.. code-block::
+   :caption: Overriding a virtual function
+
+   #include "qdev.h"
+
+   void my_device_class_init(ObjectClass *klass, void *class_data)
+   {
+       DeviceClass *dc = DEVICE_CLASS(klass);
+       dc->reset = my_device_reset;
+   }
+
+   static const TypeInfo my_device_info = {
+       .name = TYPE_MY_DEVICE,
+       .parent = TYPE_DEVICE,
+       .instance_size = sizeof(MyDevice),
+       .class_init = my_device_class_init,
+   };
+
+Introducing new virtual methods requires a class to define its own
+struct and to add a .class_size member to the #TypeInfo.  Each method
+will also have a wrapper function to call it easily:
+
+.. code-block::
+   :caption: Defining an abstract class
+
+   #include "qdev.h"
+
+   typedef struct MyDeviceClass
+   {
+       DeviceClass parent;
+
+       void (*frobnicate) (MyDevice *obj);
+   } MyDeviceClass;
+
+   static const TypeInfo my_device_info = {
+       .name = TYPE_MY_DEVICE,
+       .parent = TYPE_DEVICE,
+       .instance_size = sizeof(MyDevice),
+       .abstract = true, // or set a default in my_device_class_init
+       .class_size = sizeof(MyDeviceClass),
+   };
+
+   void my_device_frobnicate(MyDevice *obj)
+   {
+       MyDeviceClass *klass = MY_DEVICE_GET_CLASS(obj);
+
+       klass->frobnicate(obj);
+   }
+
+Interfaces
+==========
+
+Interfaces allow a limited form of multiple inheritance.  Instances are
+similar to normal types except for the fact that are only defined by
+their classes and never carry any state.  As a consequence, a pointer to
+an interface instance should always be of incomplete type in order to be
+sure it cannot be dereferenced.  That is, you should define the
+'typedef struct SomethingIf SomethingIf' so that you can pass around
+``SomethingIf *si`` arguments, but not define a ``struct SomethingIf { ... }``.
+The only things you can validly do with a ``SomethingIf *`` are to pass it as
+an argument to a method on its corresponding SomethingIfClass, or to
+dynamically cast it to an object that implements the interface.
+
+Methods
+=======
+
+A <emphasis>method</emphasis> is a function within the namespace scope of
+a class. It usually operates on the object instance by passing it as a
+strongly-typed first argument.
+If it does not operate on an object instance, it is dubbed
+<emphasis>class method</emphasis>.
+
+Methods cannot be overloaded. That is, the #ObjectClass and method name
+uniquely identity the function to be called; the signature does not vary
+except for trailing varargs.
+
+Methods are always <emphasis>virtual</emphasis>. Overriding a method in
+#TypeInfo.class_init of a subclass leads to any user of the class obtained
+via OBJECT_GET_CLASS() accessing the overridden function.
+The original function is not automatically invoked. It is the responsibility
+of the overriding class to determine whether and when to invoke the method
+being overridden.
+
+To invoke the method being overridden, the preferred solution is to store
+the original value in the overriding class before overriding the method.
+This corresponds to ``{super,base}.method(...)`` in Java and C#
+respectively; this frees the overriding class from hardcoding its parent
+class, which someone might choose to change at some point.
+
+.. code-block::
+   :caption: Overriding a virtual method
+
+   typedef struct MyState MyState;
+
+   typedef void (*MyDoSomething)(MyState *obj);
+
+   typedef struct MyClass {
+       ObjectClass parent_class;
+
+       MyDoSomething do_something;
+   } MyClass;
+
+   static void my_do_something(MyState *obj)
+   {
+       // do something
+   }
+
+   static void my_class_init(ObjectClass *oc, void *data)
+   {
+       MyClass *mc = MY_CLASS(oc);
+
+       mc->do_something = my_do_something;
+   }
+
+   static const TypeInfo my_type_info = {
+       .name = TYPE_MY,
+       .parent = TYPE_OBJECT,
+       .instance_size = sizeof(MyState),
+       .class_size = sizeof(MyClass),
+       .class_init = my_class_init,
+   };
+
+   typedef struct DerivedClass {
+       MyClass parent_class;
+
+       MyDoSomething parent_do_something;
+   } DerivedClass;
+
+   static void derived_do_something(MyState *obj)
+   {
+       DerivedClass *dc = DERIVED_GET_CLASS(obj);
+
+       // do something here
+       dc->parent_do_something(obj);
+       // do something else here
+   }
+
+   static void derived_class_init(ObjectClass *oc, void *data)
+   {
+       MyClass *mc = MY_CLASS(oc);
+       DerivedClass *dc = DERIVED_CLASS(oc);
+
+       dc->parent_do_something = mc->do_something;
+       mc->do_something = derived_do_something;
+   }
+
+   static const TypeInfo derived_type_info = {
+       .name = TYPE_DERIVED,
+       .parent = TYPE_MY,
+       .class_size = sizeof(DerivedClass),
+       .class_init = derived_class_init,
+   };
+
+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
+``MyClass::method(...)`` in C++.
+
+The first example of such a QOM method was #CPUClass.reset,
+another example is #DeviceClass.realize.
+
+Standard type declaration and definition macros
+===============================================
+
+A lot of the code outlined above follows a standard pattern and naming
+convention. To reduce the amount of boilerplate code that needs to be
+written for a new type there are two sets of macros to generate the
+common parts in a standard format.
+
+A type is declared using the OBJECT_DECLARE macro family. In types
+which do not require any virtual functions in the class, the
+OBJECT_DECLARE_SIMPLE_TYPE macro is suitable, and is commonly placed
+in the header file:
+
+.. code-block::
+   :caption: Declaring a simple type
+
+    OBJECT_DECLARE_SIMPLE_TYPE(MyDevice, my_device, MY_DEVICE, DEVICE)
+
+This is equivalent to the following:
+
+.. code-block::
+   :caption: Expansion from declaring a simple type
+
+    typedef struct MyDevice MyDevice;
+    typedef struct MyDeviceClass MyDeviceClass;
+
+    G_DEFINE_AUTOPTR_CLEANUP_FUNC(MyDeviceClass, object_unref)
+
+    #define MY_DEVICE_GET_CLASS(void *obj) \
+            OBJECT_GET_CLASS(MyDeviceClass, obj, TYPE_MY_DEVICE)
+    #define MY_DEVICE_CLASS(void *klass) \
+            OBJECT_CLASS_CHECK(MyDeviceClass, klass, TYPE_MY_DEVICE)
+    #define MY_DEVICE(void *obj)
+            OBJECT_CHECK(MyDevice, obj, TYPE_MY_DEVICE)
+
+    struct MyDeviceClass {
+        DeviceClass parent_class;
+    };
+
+The 'struct MyDevice' needs to be declared separately.
+If the type requires virtual functions to be declared in the class
+struct, then the alternative OBJECT_DECLARE_TYPE() macro can be
+used. This does the same as OBJECT_DECLARE_SIMPLE_TYPE(), but without
+the 'struct MyDeviceClass' definition.
+
+To implement the type, the OBJECT_DEFINE macro family is available.
+In the simple case the OBJECT_DEFINE_TYPE macro is suitable:
+
+.. code-block::
+   :caption: Defining a simple type
+
+    OBJECT_DEFINE_TYPE(MyDevice, my_device, MY_DEVICE, DEVICE)
+
+This is equivalent to the following:
+
+.. code-block::
+   :caption: Expansion from defining a simple type
+
+    static void my_device_finalize(Object *obj);
+    static void my_device_class_init(ObjectClass *oc, void *data);
+    static void my_device_init(Object *obj);
+
+    static const TypeInfo my_device_info = {
+        .parent = TYPE_DEVICE,
+        .name = TYPE_MY_DEVICE,
+        .instance_size = sizeof(MyDevice),
+        .instance_init = my_device_init,
+        .instance_finalize = my_device_finalize,
+        .class_size = sizeof(MyDeviceClass),
+        .class_init = my_device_class_init,
+    };
+
+    static void
+    my_device_register_types(void)
+    {
+        type_register_static(&my_device_info);
+    }
+    type_init(my_device_register_types);
+
+This is sufficient to get the type registered with the type
+system, and the three standard methods now need to be implemented
+along with any other logic required for the type.
+
+If the type needs to implement one or more interfaces, then the
+OBJECT_DEFINE_TYPE_WITH_INTERFACES() macro can be used instead.
+This accepts an array of interface type names.
+
+.. code-block::
+   :caption: Defining a simple type implementing interfaces
+
+    OBJECT_DEFINE_TYPE_WITH_INTERFACES(MyDevice, my_device,
+                                       MY_DEVICE, DEVICE,
+                                       { TYPE_USER_CREATABLE }, { NULL })
+
+If the type is not intended to be instantiated, then then
+the OBJECT_DEFINE_ABSTRACT_TYPE() macro can be used instead:
+
+.. code-block::
+   :caption: Defining a simple abstract type
+
+    OBJECT_DEFINE_ABSTRACT_TYPE(MyDevice, my_device, MY_DEVICE, DEVICE)
+
+
+
+API Reference
+-------------
+
 .. kernel-doc:: include/qom/object.h
diff --git a/include/qom/object.h b/include/qom/object.h
index 75ef97da31..8632484cc0 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -28,383 +28,6 @@ typedef struct InterfaceInfo InterfaceInfo;
 
 #define TYPE_OBJECT "object"
 
-/**
- * DOC:
- *
- * .. highlight:: c
- *
- * The QEMU Object Model provides a framework for registering user creatable
- * types and instantiating objects from those types.  QOM provides the following
- * features:
- *
- *  - System for dynamically registering types
- *  - Support for single-inheritance of types
- *  - Multiple inheritance of stateless interfaces
- *
- * .. code-block::
- *    :caption: Creating a minimal type
- *
- *    #include "qdev.h"
- *
- *    #define TYPE_MY_DEVICE "my-device"
- *
- *    // No new virtual functions: we can reuse the typedef for the
- *    // superclass.
- *    typedef DeviceClass MyDeviceClass;
- *    typedef struct MyDevice
- *    {
- *        DeviceState parent;
- *
- *        int reg0, reg1, reg2;
- *    } MyDevice;
- *
- *    static const TypeInfo my_device_info = {
- *        .name = TYPE_MY_DEVICE,
- *        .parent = TYPE_DEVICE,
- *        .instance_size = sizeof(MyDevice),
- *    };
- *
- *    static void my_device_register_types(void)
- *    {
- *        type_register_static(&my_device_info);
- *    }
- *
- *    type_init(my_device_register_types)
- *
- * In the above example, we create a simple type that is described by #TypeInfo.
- * #TypeInfo describes information about the type including what it inherits
- * from, the instance and class size, and constructor/destructor hooks.
- *
- * Alternatively several static types could be registered using helper macro
- * DEFINE_TYPES()
- *
- * .. code-block::
- *
- *    static const TypeInfo device_types_info[] = {
- *        {
- *            .name = TYPE_MY_DEVICE_A,
- *            .parent = TYPE_DEVICE,
- *            .instance_size = sizeof(MyDeviceA),
- *        },
- *        {
- *            .name = TYPE_MY_DEVICE_B,
- *            .parent = TYPE_DEVICE,
- *            .instance_size = sizeof(MyDeviceB),
- *        },
- *    };
- *
- *    DEFINE_TYPES(device_types_info)
- *
- * Every type has an #ObjectClass associated with it.  #ObjectClass derivatives
- * are instantiated dynamically but there is only ever one instance for any
- * given type.  The #ObjectClass typically holds a table of function pointers
- * for the virtual methods implemented by this type.
- *
- * Using object_new(), a new #Object derivative will be instantiated.  You can
- * cast an #Object to a subclass (or base-class) type using
- * object_dynamic_cast().  You typically want to define macro wrappers around
- * OBJECT_CHECK() and OBJECT_CLASS_CHECK() to make it easier to convert to a
- * specific type:
- *
- * .. kernel-doc messes up with the code block below because of the
- *    backslash at the end of lines.  This will be fixes if we move this
- *    content to qom.rst.
- *
- * .. code-block::
- *    :caption: Typecasting macros
- *
- *    #define MY_DEVICE_GET_CLASS(obj) \
- *       OBJECT_GET_CLASS(MyDeviceClass, obj, TYPE_MY_DEVICE)
- *    #define MY_DEVICE_CLASS(klass) \
- *       OBJECT_CLASS_CHECK(MyDeviceClass, klass, TYPE_MY_DEVICE)
- *    #define MY_DEVICE(obj) \
- *       OBJECT_CHECK(MyDevice, obj, TYPE_MY_DEVICE)
- *
- * Class Initialization
- * ====================
- *
- * Before an object is initialized, the class for the object must be
- * initialized.  There is only one class object for all instance objects
- * that is created lazily.
- *
- * Classes are initialized by first initializing any parent classes (if
- * necessary).  After the parent class object has initialized, it will be
- * copied into the current class object and any additional storage in the
- * class object is zero filled.
- *
- * The effect of this is that classes automatically inherit any virtual
- * function pointers that the parent class has already initialized.  All
- * other fields will be zero filled.
- *
- * Once all of the parent classes have been initialized, #TypeInfo::class_init
- * is called to let the class being instantiated provide default initialize for
- * its virtual functions.  Here is how the above example might be modified
- * to introduce an overridden virtual function:
- *
- * .. code-block::
- *    :caption: Overriding a virtual function
- *
- *    #include "qdev.h"
- *
- *    void my_device_class_init(ObjectClass *klass, void *class_data)
- *    {
- *        DeviceClass *dc = DEVICE_CLASS(klass);
- *        dc->reset = my_device_reset;
- *    }
- *
- *    static const TypeInfo my_device_info = {
- *        .name = TYPE_MY_DEVICE,
- *        .parent = TYPE_DEVICE,
- *        .instance_size = sizeof(MyDevice),
- *        .class_init = my_device_class_init,
- *    };
- *
- * Introducing new virtual methods requires a class to define its own
- * struct and to add a .class_size member to the #TypeInfo.  Each method
- * will also have a wrapper function to call it easily:
- *
- * .. code-block::
- *    :caption: Defining an abstract class
- *
- *    #include "qdev.h"
- *
- *    typedef struct MyDeviceClass
- *    {
- *        DeviceClass parent;
- *
- *        void (*frobnicate) (MyDevice *obj);
- *    } MyDeviceClass;
- *
- *    static const TypeInfo my_device_info = {
- *        .name = TYPE_MY_DEVICE,
- *        .parent = TYPE_DEVICE,
- *        .instance_size = sizeof(MyDevice),
- *        .abstract = true, // or set a default in my_device_class_init
- *        .class_size = sizeof(MyDeviceClass),
- *    };
- *
- *    void my_device_frobnicate(MyDevice *obj)
- *    {
- *        MyDeviceClass *klass = MY_DEVICE_GET_CLASS(obj);
- *
- *        klass->frobnicate(obj);
- *    }
- *
- * Interfaces
- * ==========
- *
- * Interfaces allow a limited form of multiple inheritance.  Instances are
- * similar to normal types except for the fact that are only defined by
- * their classes and never carry any state.  As a consequence, a pointer to
- * an interface instance should always be of incomplete type in order to be
- * sure it cannot be dereferenced.  That is, you should define the
- * 'typedef struct SomethingIf SomethingIf' so that you can pass around
- * ``SomethingIf *si`` arguments, but not define a ``struct SomethingIf { ... }``.
- * The only things you can validly do with a ``SomethingIf *`` are to pass it as
- * an argument to a method on its corresponding SomethingIfClass, or to
- * dynamically cast it to an object that implements the interface.
- *
- * Methods
- * =======
- *
- * A <emphasis>method</emphasis> is a function within the namespace scope of
- * a class. It usually operates on the object instance by passing it as a
- * strongly-typed first argument.
- * If it does not operate on an object instance, it is dubbed
- * <emphasis>class method</emphasis>.
- *
- * Methods cannot be overloaded. That is, the #ObjectClass and method name
- * uniquely identity the function to be called; the signature does not vary
- * except for trailing varargs.
- *
- * Methods are always <emphasis>virtual</emphasis>. Overriding a method in
- * #TypeInfo.class_init of a subclass leads to any user of the class obtained
- * via OBJECT_GET_CLASS() accessing the overridden function.
- * The original function is not automatically invoked. It is the responsibility
- * of the overriding class to determine whether and when to invoke the method
- * being overridden.
- *
- * To invoke the method being overridden, the preferred solution is to store
- * the original value in the overriding class before overriding the method.
- * This corresponds to ``{super,base}.method(...)`` in Java and C#
- * respectively; this frees the overriding class from hardcoding its parent
- * class, which someone might choose to change at some point.
- *
- * .. code-block::
- *    :caption: Overriding a virtual method
- *
- *    typedef struct MyState MyState;
- *
- *    typedef void (*MyDoSomething)(MyState *obj);
- *
- *    typedef struct MyClass {
- *        ObjectClass parent_class;
- *
- *        MyDoSomething do_something;
- *    } MyClass;
- *
- *    static void my_do_something(MyState *obj)
- *    {
- *        // do something
- *    }
- *
- *    static void my_class_init(ObjectClass *oc, void *data)
- *    {
- *        MyClass *mc = MY_CLASS(oc);
- *
- *        mc->do_something = my_do_something;
- *    }
- *
- *    static const TypeInfo my_type_info = {
- *        .name = TYPE_MY,
- *        .parent = TYPE_OBJECT,
- *        .instance_size = sizeof(MyState),
- *        .class_size = sizeof(MyClass),
- *        .class_init = my_class_init,
- *    };
- *
- *    typedef struct DerivedClass {
- *        MyClass parent_class;
- *
- *        MyDoSomething parent_do_something;
- *    } DerivedClass;
- *
- *    static void derived_do_something(MyState *obj)
- *    {
- *        DerivedClass *dc = DERIVED_GET_CLASS(obj);
- *
- *        // do something here
- *        dc->parent_do_something(obj);
- *        // do something else here
- *    }
- *
- *    static void derived_class_init(ObjectClass *oc, void *data)
- *    {
- *        MyClass *mc = MY_CLASS(oc);
- *        DerivedClass *dc = DERIVED_CLASS(oc);
- *
- *        dc->parent_do_something = mc->do_something;
- *        mc->do_something = derived_do_something;
- *    }
- *
- *    static const TypeInfo derived_type_info = {
- *        .name = TYPE_DERIVED,
- *        .parent = TYPE_MY,
- *        .class_size = sizeof(DerivedClass),
- *        .class_init = derived_class_init,
- *    };
- *
- * 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
- * ``MyClass::method(...)`` in C++.
- *
- * The first example of such a QOM method was #CPUClass.reset,
- * another example is #DeviceClass.realize.
- *
- * Standard type declaration and definition macros
- * ===============================================
- *
- * A lot of the code outlined above follows a standard pattern and naming
- * convention. To reduce the amount of boilerplate code that needs to be
- * written for a new type there are two sets of macros to generate the
- * common parts in a standard format.
- *
- * A type is declared using the OBJECT_DECLARE macro family. In types
- * which do not require any virtual functions in the class, the
- * OBJECT_DECLARE_SIMPLE_TYPE macro is suitable, and is commonly placed
- * in the header file:
- *
- * .. code-block::
- *    :caption: Declaring a simple type
- *
- *     OBJECT_DECLARE_SIMPLE_TYPE(MyDevice, my_device, MY_DEVICE, DEVICE)
- *
- * This is equivalent to the following:
- *
- * .. code-block::
- *    :caption: Expansion from declaring a simple type
- *
- *     typedef struct MyDevice MyDevice;
- *     typedef struct MyDeviceClass MyDeviceClass;
- *
- *     G_DEFINE_AUTOPTR_CLEANUP_FUNC(MyDeviceClass, object_unref)
- *
- *     #define MY_DEVICE_GET_CLASS(void *obj) \
- *             OBJECT_GET_CLASS(MyDeviceClass, obj, TYPE_MY_DEVICE)
- *     #define MY_DEVICE_CLASS(void *klass) \
- *             OBJECT_CLASS_CHECK(MyDeviceClass, klass, TYPE_MY_DEVICE)
- *     #define MY_DEVICE(void *obj)
- *             OBJECT_CHECK(MyDevice, obj, TYPE_MY_DEVICE)
- *
- *     struct MyDeviceClass {
- *         DeviceClass parent_class;
- *     };
- *
- * The 'struct MyDevice' needs to be declared separately.
- * If the type requires virtual functions to be declared in the class
- * struct, then the alternative OBJECT_DECLARE_TYPE() macro can be
- * used. This does the same as OBJECT_DECLARE_SIMPLE_TYPE(), but without
- * the 'struct MyDeviceClass' definition.
- *
- * To implement the type, the OBJECT_DEFINE macro family is available.
- * In the simple case the OBJECT_DEFINE_TYPE macro is suitable:
- *
- * .. code-block::
- *    :caption: Defining a simple type
- *
- *     OBJECT_DEFINE_TYPE(MyDevice, my_device, MY_DEVICE, DEVICE)
- *
- * This is equivalent to the following:
- *
- * .. code-block::
- *    :caption: Expansion from defining a simple type
- *
- *     static void my_device_finalize(Object *obj);
- *     static void my_device_class_init(ObjectClass *oc, void *data);
- *     static void my_device_init(Object *obj);
- *
- *     static const TypeInfo my_device_info = {
- *         .parent = TYPE_DEVICE,
- *         .name = TYPE_MY_DEVICE,
- *         .instance_size = sizeof(MyDevice),
- *         .instance_init = my_device_init,
- *         .instance_finalize = my_device_finalize,
- *         .class_size = sizeof(MyDeviceClass),
- *         .class_init = my_device_class_init,
- *     };
- *
- *     static void
- *     my_device_register_types(void)
- *     {
- *         type_register_static(&my_device_info);
- *     }
- *     type_init(my_device_register_types);
- *
- * This is sufficient to get the type registered with the type
- * system, and the three standard methods now need to be implemented
- * along with any other logic required for the type.
- *
- * If the type needs to implement one or more interfaces, then the
- * OBJECT_DEFINE_TYPE_WITH_INTERFACES() macro can be used instead.
- * This accepts an array of interface type names.
- *
- * .. code-block::
- *    :caption: Defining a simple type implementing interfaces
- *
- *     OBJECT_DEFINE_TYPE_WITH_INTERFACES(MyDevice, my_device,
- *                                        MY_DEVICE, DEVICE,
- *                                        { TYPE_USER_CREATABLE }, { NULL })
- *
- * If the type is not intended to be instantiated, then then
- * the OBJECT_DEFINE_ABSTRACT_TYPE() macro can be used instead:
- *
- * .. code-block::
- *    :caption: Defining a simple abstract type
- *
- *     OBJECT_DEFINE_ABSTRACT_TYPE(MyDevice, my_device, MY_DEVICE, DEVICE)
- */
-
-
 typedef struct ObjectProperty ObjectProperty;
 
 /**
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* fixup! docs: Move object.h overview doc comment to qom.rst
  2020-09-10 22:15 ` [PATCH 9/9] docs: Move object.h overview doc comment to qom.rst Eduardo Habkost
@ 2020-09-11  0:23   ` Eduardo Habkost
  0 siblings, 0 replies; 12+ messages in thread
From: Eduardo Habkost @ 2020-09-11  0:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Daniel P. Berrangé, Peter Maydell

On Thu, Sep 10, 2020 at 06:15:26PM -0400, Eduardo Habkost wrote:
> Move the whole contents of the overview doc comment from object.h
> to qom.rst.
> 
> This makes the documentation source easier to read and edit, and
> also solves the backslash escaping issue at the typecasting macro
> examples.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Fixup for a bug I introduced accidentally before sending the
series.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
diff --git a/docs/devel/qom.rst b/docs/devel/qom.rst
index 2070a2ced4..1a2e5dc661 100644
--- a/docs/devel/qom.rst
+++ b/docs/devel/qom.rst
@@ -80,7 +80,7 @@ specific type:
 .. code-block::
    :caption: Typecasting macros
 
-#define MY_DEVICE_GET_CLASS(obj) \
+    #define MY_DEVICE_GET_CLASS(obj) \
       OBJECT_GET_CLASS(MyDeviceClass, obj, TYPE_MY_DEVICE)
    #define MY_DEVICE_CLASS(klass) \
       OBJECT_CLASS_CHECK(MyDeviceClass, klass, TYPE_MY_DEVICE)

-- 
Eduardo



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/9] docs: Convert QOM documentation to kernel-doc + Sphinx
  2020-09-10 22:15 [PATCH 0/9] docs: Convert QOM documentation to kernel-doc + Sphinx Eduardo Habkost
                   ` (8 preceding siblings ...)
  2020-09-10 22:15 ` [PATCH 9/9] docs: Move object.h overview doc comment to qom.rst Eduardo Habkost
@ 2020-09-22  9:38 ` Paolo Bonzini
  9 siblings, 0 replies; 12+ messages in thread
From: Paolo Bonzini @ 2020-09-22  9:38 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel; +Cc: Peter Maydell, Daniel P. Berrangé

On 11/09/20 00:15, Eduardo Habkost wrote:
> This converts the existing gtk-doc markup in object.h (that
> probably was never rendered into an actual document) to
> kernel-doc + Sphinx syntax, and reference them at
> docs/devel/qom.rst.
> 
> Eduardo Habkost (9):
>   qom: Document all function parameters in doc comments
>   qom: Use kernel-doc private/public tags in structs
>   qom: Use ``code`` Sphinx syntax where appropriate
>   qom: Add kernel-doc markup to introduction doc comment
>   qom: Reformat section titles using Sphinx syntax
>   qom: Indent existing code examples
>   qom: Add code block markup to all code blocks
>   docs: Create docs/devel/qom.rst
>   docs: Move object.h overview doc comment to qom.rst
> 
>  docs/devel/index.rst |   1 +
>  docs/devel/qom.rst   | 378 ++++++++++++++++++++++++++++++
>  include/qom/object.h | 547 ++++++++-----------------------------------
>  3 files changed, 475 insertions(+), 451 deletions(-)
>  create mode 100644 docs/devel/qom.rst
> 

Queued, thanks.

Paolo



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-09-22  9:40 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-10 22:15 [PATCH 0/9] docs: Convert QOM documentation to kernel-doc + Sphinx Eduardo Habkost
2020-09-10 22:15 ` [PATCH 1/9] qom: Document all function parameters in doc comments Eduardo Habkost
2020-09-10 22:15 ` [PATCH 2/9] qom: Use kernel-doc private/public tags in structs Eduardo Habkost
2020-09-10 22:15 ` [PATCH 3/9] qom: Use ``code`` Sphinx syntax where appropriate Eduardo Habkost
2020-09-10 22:15 ` [PATCH 4/9] qom: Add kernel-doc markup to introduction doc comment Eduardo Habkost
2020-09-10 22:15 ` [PATCH 5/9] qom: Reformat section titles using Sphinx syntax Eduardo Habkost
2020-09-10 22:15 ` [PATCH 6/9] qom: Indent existing code examples Eduardo Habkost
2020-09-10 22:15 ` [PATCH 7/9] qom: Add code block markup to all code blocks Eduardo Habkost
2020-09-10 22:15 ` [PATCH 8/9] docs: Create docs/devel/qom.rst Eduardo Habkost
2020-09-10 22:15 ` [PATCH 9/9] docs: Move object.h overview doc comment to qom.rst Eduardo Habkost
2020-09-11  0:23   ` fixup! " Eduardo Habkost
2020-09-22  9:38 ` [PATCH 0/9] docs: Convert QOM documentation to kernel-doc + Sphinx Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.