#
9cb54b18 |
| 23-Sep-2020 |
Paolo Bonzini <pbonzini@redhat.com> |
docs: Move object.h overview doc comment to qom.rst
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 al
docs: Move object.h overview doc comment to qom.rst
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> Message-Id: <20200910221526.10041-10-ehabkost@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
#
6cf164c0 |
| 10-Sep-2020 |
Eduardo Habkost <ehabkost@redhat.com> |
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 c
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>
show more ...
|
#
9bbfd245 |
| 10-Sep-2020 |
Eduardo Habkost <ehabkost@redhat.com> |
qom: Indent existing code examples
This indents existing code examples that are not indented yet, just to make future conversion to Sphinx markup easier to review.
Signed-off-by: Eduardo Habkost <e
qom: Indent existing code examples
This indents existing code examples that are not indented yet, just to make future conversion to Sphinx markup easier to review.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20200910221526.10041-7-ehabkost@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
#
88144468 |
| 10-Sep-2020 |
Eduardo Habkost <ehabkost@redhat.com> |
qom: Reformat section titles using Sphinx syntax
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20200910221526.10041-6-ehabkost@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@
qom: Reformat section titles using Sphinx syntax
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20200910221526.10041-6-ehabkost@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
#
ed799805 |
| 10-Sep-2020 |
Eduardo Habkost <ehabkost@redhat.com> |
qom: Add kernel-doc markup to introduction doc comment
Add DOC: section keyword to introduction doc comment, so it will be rendered by kernel-doc.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.co
qom: Add kernel-doc markup to introduction doc comment
Add DOC: section keyword to introduction doc comment, so it will be rendered by kernel-doc.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20200910221526.10041-5-ehabkost@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
#
78170df8 |
| 10-Sep-2020 |
Eduardo Habkost <ehabkost@redhat.com> |
qom: Use ``code`` Sphinx syntax where appropriate
Replace gtkdoc markup with Sphinx ``code`` syntax.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20200910221526.10041-4-ehabkos
qom: Use ``code`` Sphinx syntax where appropriate
Replace gtkdoc markup with Sphinx ``code`` syntax.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20200910221526.10041-4-ehabkost@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
#
11e1c3ad |
| 10-Sep-2020 |
Eduardo Habkost <ehabkost@redhat.com> |
qom: Use kernel-doc private/public tags in structs
Use kernel-doc syntax for indicating private and public struct fields.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <202009102
qom: Use kernel-doc private/public tags in structs
Use kernel-doc syntax for indicating private and public struct fields.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20200910221526.10041-3-ehabkost@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
#
1827c35b |
| 10-Sep-2020 |
Eduardo Habkost <ehabkost@redhat.com> |
qom: Document all function parameters in doc comments
kernel-doc requires all function parameters to be documented, so document them all.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Messag
qom: Document all function parameters in doc comments
kernel-doc requires all function parameters to be documented, so document them all.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20200910221526.10041-2-ehabkost@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
#
f7f1d916 |
| 24-Sep-2020 |
Peter Maydell <peter.maydell@linaro.org> |
Merge remote-tracking branch 'remotes/ehabkost/tags/machine-next-pull-request' into staging
machine + QOM queue, 2020-09-22
QOM cleanups: * Convert instance properties to class properties (Eduard
Merge remote-tracking branch 'remotes/ehabkost/tags/machine-next-pull-request' into staging
machine + QOM queue, 2020-09-22
QOM cleanups: * Convert instance properties to class properties (Eduardo Habkost) * simplify object_find_property / object_class_find_property (Daniel P. Berrangé)
Deprecated feature removal: * Drop support for invalid topologies (Igor Mammedov)
# gpg: Signature made Tue 22 Sep 2020 23:25:01 BST # gpg: using RSA key 5A322FD5ABC4D3DBACCFD1AA2807936F984DC5A6 # gpg: issuer "ehabkost@redhat.com" # gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>" [full] # Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF D1AA 2807 936F 984D C5A6
* remotes/ehabkost/tags/machine-next-pull-request: sifive_u: Register "start-in-flash" as class property sifive_e: Register "revb" as class property i440fx: Register i440FX-pcihost properties as class properties machine: Register "memory-backend" as class property xlnx-zcu102: Register properties as class properties cpu/core: Register core-id and nr-threads as class properties s390x: Register all CPU properties as class properties cryptodev-backend: Register "chardev" as class property cryptodev-vhost-user: Register "chardev" as class property smp: drop support for deprecated (invalid topologies) qom: simplify object_find_property / object_class_find_property
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
show more ...
|
#
efba1595 |
| 14-Sep-2020 |
Daniel P. Berrangé <berrange@redhat.com> |
qom: simplify object_find_property / object_class_find_property
When debugging QEMU it is often useful to put a breakpoint on the error_setg_internal method impl.
Unfortunately the object_property_
qom: simplify object_find_property / object_class_find_property
When debugging QEMU it is often useful to put a breakpoint on the error_setg_internal method impl.
Unfortunately the object_property_add / object_class_property_add methods call object_property_find / object_class_property_find methods to check if a property exists already before adding the new property.
As a result there are a huge number of calls to error_setg_internal on startup of most QEMU commands, making it very painful to set a breakpoint on this method.
Most callers of object_find_property and object_class_find_property, however, pass in a NULL for the Error parameter. This simplifies the methods to remove the Error parameter entirely, and then adds some new wrapper methods that are able to raise an Error when needed.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20200914135617.1493072-1-berrange@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
show more ...
|
#
4dad0a9a |
| 21-Sep-2020 |
Peter Maydell <peter.maydell@linaro.org> |
Merge remote-tracking branch 'remotes/ehabkost/tags/machine-next-pull-request' into staging
QOM queue, 2020-09-18
Fixes: * Error value corrections (Markus Armbruster) * Correct object_class_dynamic
Merge remote-tracking branch 'remotes/ehabkost/tags/machine-next-pull-request' into staging
QOM queue, 2020-09-18
Fixes: * Error value corrections (Markus Armbruster) * Correct object_class_dynamic_cast_assert() documentation (Eduardo Habkost) * Ensure objects using QEMU_ALIGNED are properly aligned (Richard Henderson)
QOM cleanups (Eduardo Habkost): * Rename some constants * Simplify parameters of OBJECT_DECLARE* macros * Additional DECLARE_*CHECKER* usage * Additional OBJECT_DECLARE_TYPE usage * Additional OBJECT_DECLARE_SIMPLE_TYPE usage
# gpg: Signature made Fri 18 Sep 2020 21:45:29 BST # gpg: using RSA key 5A322FD5ABC4D3DBACCFD1AA2807936F984DC5A6 # gpg: issuer "ehabkost@redhat.com" # gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>" [full] # Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF D1AA 2807 936F 984D C5A6
* remotes/ehabkost/tags/machine-next-pull-request: Use OBJECT_DECLARE_SIMPLE_TYPE when possible Use OBJECT_DECLARE_TYPE when possible qom: Remove module_obj_name parameter from OBJECT_DECLARE* macros qom: Remove ParentClassType argument from OBJECT_DECLARE_SIMPLE_TYPE scripts/codeconverter: Update to latest version target/s390x: Set instance_align on S390CPU TypeInfo target/riscv: Set instance_align on RISCVCPU TypeInfo target/ppc: Set instance_align on PowerPCCPU TypeInfo target/arm: Set instance_align on CPUARM TypeInfo qom: Allow objects to be allocated with increased alignment qom: Correct error values in two contracts qom: Clean up object_property_get_enum()'s error value qom: Correct object_class_dynamic_cast_assert() documentation sifive: Use DECLARE_*CHECKER* macros sifive: Move QOM typedefs and add missing includes sifive_u: Rename memmap enum constants sifive_e: Rename memmap enum constants
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
show more ...
|
#
30b5707c |
| 16-Sep-2020 |
Eduardo Habkost <ehabkost@redhat.com> |
qom: Remove module_obj_name parameter from OBJECT_DECLARE* macros
One of the goals of having less boilerplate on QOM declarations is to avoid human error. Requiring an extra argument that is never
qom: Remove module_obj_name parameter from OBJECT_DECLARE* macros
One of the goals of having less boilerplate on QOM declarations is to avoid human error. Requiring an extra argument that is never used is an opportunity for mistakes.
Remove the unused argument from OBJECT_DECLARE_TYPE and OBJECT_DECLARE_SIMPLE_TYPE.
Coccinelle patch used to convert all users of the macros:
@@ declarer name OBJECT_DECLARE_TYPE; identifier InstanceType, ClassType, lowercase, UPPERCASE; @@ OBJECT_DECLARE_TYPE(InstanceType, ClassType, - lowercase, UPPERCASE);
@@ declarer name OBJECT_DECLARE_SIMPLE_TYPE; identifier InstanceType, lowercase, UPPERCASE; @@ OBJECT_DECLARE_SIMPLE_TYPE(InstanceType, - lowercase, UPPERCASE);
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Cédric Le Goater <clg@kaod.org> Acked-by: Cornelia Huck <cohuck@redhat.com> Acked-by: Igor Mammedov <imammedo@redhat.com> Acked-by: Paul Durrant <paul@xen.org> Acked-by: Thomas Huth <thuth@redhat.com> Message-Id: <20200916182519.415636-4-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
show more ...
|
#
c734cd40 |
| 16-Sep-2020 |
Eduardo Habkost <ehabkost@redhat.com> |
qom: Remove ParentClassType argument from OBJECT_DECLARE_SIMPLE_TYPE
The requirement to specify the parent class type makes the macro harder to use and easy to misuse (silent bugs can be introduced
qom: Remove ParentClassType argument from OBJECT_DECLARE_SIMPLE_TYPE
The requirement to specify the parent class type makes the macro harder to use and easy to misuse (silent bugs can be introduced if the wrong struct type is specified).
Simplify the macro by just not declaring any class struct, allowing us to remove the class_size field from the TypeInfo variables for those types.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20200916182519.415636-3-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
show more ...
|
#
4c880f36 |
| 15-Sep-2020 |
Richard Henderson <richard.henderson@linaro.org> |
qom: Allow objects to be allocated with increased alignment
It turns out that some hosts have a default malloc alignment less than that required for vectors.
We assume that, with compiler annotatio
qom: Allow objects to be allocated with increased alignment
It turns out that some hosts have a default malloc alignment less than that required for vectors.
We assume that, with compiler annotation on CPUArchState, that we can properly align the vector portion of the guest state. Fix the alignment of the allocation by using qemu_memalloc when required.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20200916004638.2444147-3-richard.henderson@linaro.org> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
show more ...
|
#
a21e6607 |
| 17-Sep-2020 |
Markus Armbruster <armbru@redhat.com> |
qom: Correct error values in two contracts
object_property_get_bool()'s contract claims it returns NULL on error. Pasto; it returns false.
object_property_get_int()'s contract claims it returns "ne
qom: Correct error values in two contracts
object_property_get_bool()'s contract claims it returns NULL on error. Pasto; it returns false.
object_property_get_int()'s contract claims it returns "negative". It actually returns -1. All the other object_property_get_FOO() contracts specify the exact error value, so do the same here.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Greg Kurz <groug@kaod.org> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20200917125540.597786-3-armbru@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
show more ...
|
#
d20f616e |
| 17-Sep-2020 |
Markus Armbruster <armbru@redhat.com> |
qom: Clean up object_property_get_enum()'s error value
object_property_get_enum() is the only object_property_FOO() that is documented to return an undefined value on error. It does no such thing,
qom: Clean up object_property_get_enum()'s error value
object_property_get_enum() is the only object_property_FOO() that is documented to return an undefined value on error. It does no such thing, actually: it returns 0 on some errors, and -1 on others.
Needlessly complicated. Always return -1 on error, and adjust the contract.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Greg Kurz <groug@kaod.org> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20200917125540.597786-2-armbru@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
show more ...
|
#
04dcf4b5 |
| 16-Sep-2020 |
Eduardo Habkost <ehabkost@redhat.com> |
qom: Correct object_class_dynamic_cast_assert() documentation
object_class_dynamic_cast_assert() is not used by INTERFACE_CHECK, remove misleading mention of that function in the documentation.
Mes
qom: Correct object_class_dynamic_cast_assert() documentation
object_class_dynamic_cast_assert() is not used by INTERFACE_CHECK, remove misleading mention of that function in the documentation.
Message-Id: <20200916193101.511600-2-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
show more ...
|
#
f4ef8c9c |
| 11-Sep-2020 |
Peter Maydell <peter.maydell@linaro.org> |
Merge remote-tracking branch 'remotes/ehabkost/tags/machine-next-pull-request' into staging
QOM boilerplate cleanup
Documentation build fix: * memory: Remove kernel-doc comment marker (Eduardo Habk
Merge remote-tracking branch 'remotes/ehabkost/tags/machine-next-pull-request' into staging
QOM boilerplate cleanup
Documentation build fix: * memory: Remove kernel-doc comment marker (Eduardo Habkost)
QOM cleanups: * Rename QOM macros for consistency between TYPE_* and type checking constants (Eduardo Habkost)
QOM new macros: * OBJECT_DECLARE_* and OBJECT_DEFINE_* macros (Daniel P. Berrangé) * DECLARE_*_CHECKER macros (Eduardo Habkost)
Automated QOM boilerplate changes: * Automated changes to use DECLARE_*_CHECKER (Eduardo Habkost * Automated changes to use OBJECT_DECLARE* (Eduardo Habkost)
# gpg: Signature made Thu 10 Sep 2020 19:17:49 BST # gpg: using RSA key 5A322FD5ABC4D3DBACCFD1AA2807936F984DC5A6 # gpg: issuer "ehabkost@redhat.com" # gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>" [full] # Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF D1AA 2807 936F 984D C5A6
* remotes/ehabkost/tags/machine-next-pull-request: (33 commits) virtio-vga: Use typedef name for instance_size vhost-user-vga: Use typedef name for instance_size xilinx_axienet: Use typedef name for instance_size lpc_ich9: Use typedef name for instance_size omap_intc: Use typedef name for instance_size xilinx_axidma: Use typedef name for instance_size tusb6010: Rename TUSB to TUSB6010 pc87312: Rename TYPE_PC87312_SUPERIO to TYPE_PC87312 vfio: Rename PCI_VFIO to VFIO_PCI usb: Rename USB_SERIAL_DEV to USB_SERIAL sabre: Rename SABRE_DEVICE to SABRE rs6000_mc: Rename RS6000MC_DEVICE to RS6000MC filter-rewriter: Rename FILTER_COLO_REWRITER to FILTER_REWRITER esp: Rename ESP_STATE to ESP ahci: Rename ICH_AHCI to ICH9_AHCI vmgenid: Rename VMGENID_DEVICE to TYPE_VMGENID vfio: Rename VFIO_AP_DEVICE_TYPE to TYPE_VFIO_AP_DEVICE dev-smartcard-reader: Rename CCID_DEV_NAME to TYPE_USB_CCID_DEV ap-device: Rename AP_DEVICE_TYPE to TYPE_AP_DEVICE gpex: Fix type checking function name ...
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
show more ...
|
#
db1015e9 |
| 03-Sep-2020 |
Eduardo Habkost <ehabkost@redhat.com> |
Move QOM typedefs and add missing includes
Some typedefs and macros are defined after the type check macros. This makes it difficult to automatically replace their definitions with OBJECT_DECLARE_TY
Move QOM typedefs and add missing includes
Some typedefs and macros are defined after the type check macros. This makes it difficult to automatically replace their definitions with OBJECT_DECLARE_TYPE.
Patch generated using:
$ ./scripts/codeconverter/converter.py -i \ --pattern=QOMStructTypedefSplit $(git grep -l '' -- '*.[ch]')
which will split "typdef struct { ... } TypedefName" declarations.
Followed by:
$ ./scripts/codeconverter/converter.py -i --pattern=MoveSymbols \ $(git grep -l '' -- '*.[ch]')
which will: - move the typedefs and #defines above the type check macros - add missing #include "qom/object.h" lines if necessary
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Message-Id: <20200831210740.126168-9-ehabkost@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Message-Id: <20200831210740.126168-10-ehabkost@redhat.com> Message-Id: <20200831210740.126168-11-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
show more ...
|
#
ad09bed1 |
| 31-Aug-2020 |
Eduardo Habkost <ehabkost@redhat.com> |
qom: Make type checker functions accept const pointers
The existing type check macros all unconditionally drop const qualifiers from their arguments. Keep this behavior in the macros generated by D
qom: Make type checker functions accept const pointers
The existing type check macros all unconditionally drop const qualifiers from their arguments. Keep this behavior in the macros generated by DECLARE_*CHECKER* by now.
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20200831210740.126168-6-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
show more ...
|
#
7808a28f |
| 31-Aug-2020 |
Eduardo Habkost <ehabkost@redhat.com> |
qom: DECLARE_*_CHECKERS macros
Sometimes the typedefs are buried inside another header, but we want to benefit from the automatic definition of type cast functions. Introduce macros that will let t
qom: DECLARE_*_CHECKERS macros
Sometimes the typedefs are buried inside another header, but we want to benefit from the automatic definition of type cast functions. Introduce macros that will let type checkers be defined when typedefs are already available.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20200831210740.126168-5-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
show more ...
|
#
4a5f0545 |
| 31-Aug-2020 |
Eduardo Habkost <ehabkost@redhat.com> |
qom: Allow class type name to be specified in OBJECT_DECLARE*
Many QOM types don't follow the Type/TypeClass pattern on the instance/struct names. Let the class struct name be specified in the OBJE
qom: Allow class type name to be specified in OBJECT_DECLARE*
Many QOM types don't follow the Type/TypeClass pattern on the instance/struct names. Let the class struct name be specified in the OBJECT_DECLARE* macros.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20200831210740.126168-4-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
show more ...
|
#
f84203a8 |
| 31-Aug-2020 |
Daniel P. Berrangé <berrange@redhat.com> |
qom: provide convenient macros for declaring and defining types
When creating new QOM types, there is a lot of boilerplate code that must be repeated using a standard pattern. This is tedious to wri
qom: provide convenient macros for declaring and defining types
When creating new QOM types, there is a lot of boilerplate code that must be repeated using a standard pattern. This is tedious to write and liable to suffer from subtle inconsistencies. Thus it would benefit from some simple automation.
QOM was loosely inspired by GLib's GObject, and indeed GObject suffers from the same burden of boilerplate code, but has long provided a set of macros to eliminate this burden in the source implementation. More recently it has also provided a set of macros to eliminate this burden in the header declaration.
In GLib there are the G_DECLARE_* and G_DEFINE_* family of macros for the header declaration and source implementation respectively:
https://developer.gnome.org/gobject/stable/chapter-gobject.html https://developer.gnome.org/gobject/stable/howto-gobject.html
This patch takes inspiration from GObject to provide the equivalent functionality for QOM.
In the header file, instead of:
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; };
We now have
OBJECT_DECLARE_SIMPLE_TYPE(MyDevice, my_device, MY_DEVICE, DEVICE)
In cases where the class needs some virtual methods, it can be left to be implemented manually using
OBJECT_DECLARE_TYPE(MyDevice, my_device, MY_DEVICE)
Note that these macros are including support for g_autoptr() for the object types, which is something previously only supported for variables declared as the base Object * type.
Meanwhile in the source file, instead of:
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);
We now have
OBJECT_DEFINE_TYPE(MyDevice, my_device, MY_DEVICE, DEVICE)
Or, if a class needs to implement interfaces:
OBJECT_DEFINE_TYPE_WITH_INTERFACES(MyDevice, my_device, MY_DEVICE, DEVICE, { TYPE_USER_CREATABLE }, { NULL })
Or, if a class needs to be abstract
OBJECT_DEFINE_ABSTRACT_TYPE(MyDevice, my_device, MY_DEVICE, DEVICE)
IOW, in both cases the maintainer now only has to think about the interesting part of the code which implements useful functionality and avoids much of the boilerplate.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20200723181410.3145233-3-berrange@redhat.com> [ehabkost: Fix G_DEFINE_AUTOPTR_CLEANUP_FUNC usage] Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20200831210740.126168-3-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
show more ...
|
#
c5a61e5a |
| 31-Aug-2020 |
Daniel P. Berrangé <berrange@redhat.com> |
qom: make object_ref/unref use a void * instead of Object *.
The object_ref/unref methods are intended for use with any subclass of the base Object. Using "Object *" in the signature is not adding a
qom: make object_ref/unref use a void * instead of Object *.
The object_ref/unref methods are intended for use with any subclass of the base Object. Using "Object *" in the signature is not adding any meaningful level of type safety, since callers simply use "OBJECT(ptr)" and this expands to an unchecked cast "(Object *)".
By using "void *" we enable the object_unref() method to be used to provide support for g_autoptr() with any subclass.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20200723181410.3145233-2-berrange@redhat.com> Message-Id: <20200831210740.126168-2-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
show more ...
|
#
b50dab9e |
| 21-Jul-2020 |
Peter Maydell <peter.maydell@linaro.org> |
Merge remote-tracking branch 'remotes/armbru/tags/pull-qom-2020-07-21' into staging
QOM patches for 2020-07-21
# gpg: Signature made Tue 21 Jul 2020 16:40:27 BST # gpg: using RSA key
Merge remote-tracking branch 'remotes/armbru/tags/pull-qom-2020-07-21' into staging
QOM patches for 2020-07-21
# gpg: Signature made Tue 21 Jul 2020 16:40:27 BST # gpg: using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653 # gpg: issuer "armbru@redhat.com" # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full] # gpg: aka "Markus Armbruster <armbru@pond.sub.org>" [full] # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653
* remotes/armbru/tags/pull-qom-2020-07-21: qom: Make info qom-tree sort children more efficiently qom: Document object_get_canonical_path() returns malloced string qom: Change object_get_canonical_path_component() not to malloc
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
show more ...
|