diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2020-01-10 19:30:19 +0400 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2020-01-24 20:59:12 +0100 |
commit | 2a1be4b34810c594b7f00e4b860df8d0c1cc6246 (patch) | |
tree | 5d8078d8b5a66eeecd78efaa8ddaa817182d4f32 /qom/object.c | |
parent | ba806ffbdf11a63993e4b5d64cca085d385dc1bc (diff) |
object: add class property initializer
This callback is used to set default value in following patch "object:
add object_property_set_defaut_{bool,str,int,uint}()".
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20200110153039.1379601-7-marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'qom/object.c')
-rw-r--r-- | qom/object.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/qom/object.c b/qom/object.c index e921363c0a..cd7ce81f50 100644 --- a/qom/object.c +++ b/qom/object.c @@ -478,6 +478,19 @@ void object_apply_compat_props(Object *obj) } } +static void object_class_property_init_all(Object *obj) +{ + ObjectPropertyIterator iter; + ObjectProperty *prop; + + object_class_property_iter_init(&iter, object_get_class(obj)); + while ((prop = object_property_iter_next(&iter))) { + if (prop->init) { + prop->init(obj, prop); + } + } +} + static void object_initialize_with_type(void *data, size_t size, TypeImpl *type) { Object *obj = data; @@ -491,6 +504,7 @@ static void object_initialize_with_type(void *data, size_t size, TypeImpl *type) memset(obj, 0, type->instance_size); obj->class = type->class; object_ref(obj); + object_class_property_init_all(obj); obj->properties = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, object_property_free); object_init_with_type(obj, type); |