[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 31/41] qom: TYPE_INFO macro
From: |
Eduardo Habkost |
Subject: |
[PATCH 31/41] qom: TYPE_INFO macro |
Date: |
Thu, 13 Aug 2020 18:26:15 -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.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
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 1d6a520d35..81bea3b4ed 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -655,6 +655,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
@@ -700,12 +708,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
- Re: [PATCH 23/41] nubus: Delete unused NUBUS_BRIDGE macro, (continued)
- [PATCH 25/41] qom: make object_ref/unref use a void * instead of Object *., Eduardo Habkost, 2020/08/13
- [PATCH 26/41] qom: provide convenient macros for declaring and defining types, Eduardo Habkost, 2020/08/13
- [PATCH 30/41] qom: Make type checker functions accept const pointers, Eduardo Habkost, 2020/08/13
- [PATCH 29/41] qom: DECLARE_*_CHECKERS macros, Eduardo Habkost, 2020/08/13
- [PATCH 31/41] qom: TYPE_INFO macro,
Eduardo Habkost <=
- [PATCH 33/41] [automated] Delete duplicate QOM typedefs, Eduardo Habkost, 2020/08/13
- [PATCH 32/41] codeconverter: script for automating QOM code cleanups, Eduardo Habkost, 2020/08/13
- [PATCH 39/41] [automated] Use OBJECT_DECLARE_SIMPLE_TYPE when possible, Eduardo Habkost, 2020/08/13
- [PATCH 37/41] [automated] Use DECLARE_*CHECKER* when possible (--force mode), Eduardo Habkost, 2020/08/13
- [PATCH 38/41] [automated] Use OBJECT_DECLARE_TYPE where possible, Eduardo Habkost, 2020/08/13
- [PATCH 40/41] crypto: use QOM macros for declaration/definition of secret types, Eduardo Habkost, 2020/08/13