[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 59/74] qom: TYPE_INFO macro
From: |
Eduardo Habkost |
Subject: |
[PATCH v3 59/74] qom: TYPE_INFO macro |
Date: |
Tue, 25 Aug 2020 15:20:55 -0400 |
Provide a TYPE_INFO macro that can be used to register a TypeInfo
struct declaratively. This will allow QOM type registration to
be 100% declarative.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Changes v2 -> v3: none
Changes v1 -> v2: none
---
include/qom/object.h | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/include/qom/object.h b/include/qom/object.h
index 3626ae3c65..3c8fe1b603 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -653,6 +653,14 @@ struct Object
struct InstanceType##Class { ParentClassType parent_class; };
+#define TYPE_INFO(type_info_var) \
+ static void \
+ register_type_info_##type_info_var(void) \
+ { \
+ type_register_static(&type_info_var); \
+ } \
+ type_init(register_type_info_##type_info_var);
+
/**
* OBJECT_DEFINE_TYPE_EXTENDED:
* @ModuleObjName: the object name with initial caps
@@ -698,12 +706,7 @@ struct Object
.interfaces = (InterfaceInfo[]) { __VA_ARGS__ } , \
}; \
\
- static void \
- module_obj_name##_register_types(void) \
- { \
- type_register_static(&module_obj_name##_info); \
- } \
- type_init(module_obj_name##_register_types);
+ TYPE_INFO(module_obj_name##_info)
/**
* OBJECT_DEFINE_TYPE:
--
2.26.2
- [PATCH v3 49/74] swim: Rename struct SWIM to Swim, (continued)
- [PATCH v3 49/74] swim: Rename struct SWIM to Swim, Eduardo Habkost, 2020/08/25
- [PATCH v3 51/74] arm: Fix typo in AARCH64_CPU_GET_CLASS definition, Eduardo Habkost, 2020/08/25
- [PATCH v3 54/74] qom: make object_ref/unref use a void * instead of Object *., Eduardo Habkost, 2020/08/25
- [PATCH v3 52/74] rx: Rename QOM type check macros, Eduardo Habkost, 2020/08/25
- [PATCH v3 56/74] qom: Allow class type name to be specified in OBJECT_DECLARE*, Eduardo Habkost, 2020/08/25
- [PATCH v3 53/74] rx: Move typedef RXCPU to cpu-qom.h, Eduardo Habkost, 2020/08/25
- [PATCH v3 57/74] qom: DECLARE_*_CHECKERS macros, Eduardo Habkost, 2020/08/25
- [PATCH v3 55/74] qom: provide convenient macros for declaring and defining types, Eduardo Habkost, 2020/08/25
- [PATCH v3 61/74] [automated] Delete duplicate QOM typedefs, Eduardo Habkost, 2020/08/25
- [PATCH v3 58/74] qom: Make type checker functions accept const pointers, Eduardo Habkost, 2020/08/25
- [PATCH v3 59/74] qom: TYPE_INFO macro,
Eduardo Habkost <=
- [PATCH v3 60/74] codeconverter: script for automating QOM code cleanups, Eduardo Habkost, 2020/08/25
- [PATCH v3 63/74] [automated] Use TYPE_INFO macro (pass 2), Eduardo Habkost, 2020/08/25
- [PATCH v3 62/74] [automated] Use TYPE_INFO macro, Eduardo Habkost, 2020/08/25
- [PATCH v3 65/74] [automated] Move QOM typedefs and add missing includes (pass 2), Eduardo Habkost, 2020/08/25
- [PATCH v3 67/74] [automated] Use DECLARE_*CHECKER* macros (pass 2), Eduardo Habkost, 2020/08/25
- [PATCH v3 68/74] [semi-automated] Use DECLARE_*CHECKER* when possible (--force mode), Eduardo Habkost, 2020/08/25
- [PATCH v3 66/74] [automated] Use DECLARE_*CHECKER* macros, Eduardo Habkost, 2020/08/25