diff options
| author | Igor Mammedov | 2017-10-09 21:50:50 +0200 |
|---|---|---|
| committer | David Gibson | 2017-10-17 01:34:00 +0200 |
| commit | 38b5d79b2e8cf6085324066d84e8bb3b3bbe8548 (patch) | |
| tree | 97b9f23f52fd0290d230cec1197a55057c1e19f1 /scripts/modules | |
| parent | qom: introduce type_register_static_array() (diff) | |
| download | qemu-38b5d79b2e8cf6085324066d84e8bb3b3bbe8548.tar.gz qemu-38b5d79b2e8cf6085324066d84e8bb3b3bbe8548.tar.xz qemu-38b5d79b2e8cf6085324066d84e8bb3b3bbe8548.zip | |
qom: add helper macro DEFINE_TYPES()
DEFINE_TYPES() will help to simplify following routine patterns:
static void foo_register_types(void)
{
type_register_static(&foo1_type_info);
type_register_static(&foo2_type_info);
...
}
type_init(foo_register_types)
or
static void foo_register_types(void)
{
int i;
for (i = 0; i < ARRAY_SIZE(type_infos); i++) {
type_register_static(&type_infos[i]);
}
}
type_init(foo_register_types)
with a single line
DEFINE_TYPES(type_infos)
where types have static definition which could be consolidated in
a single array of TypeInfo structures.
It saves us ~6-10LOC per use case and would help to replace
imperative foo_register_types() there with declarative style of
type registration.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'scripts/modules')
0 files changed, 0 insertions, 0 deletions
