diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2020-01-10 19:30:23 +0400 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2020-01-24 20:59:13 +0100 |
commit | 0e76ed0a5da4c8540597c1ffac72705e04323f69 (patch) | |
tree | 6a5daf73b26ed25d72cc329ac23c29173d1905df /include/qom/object.h | |
parent | 164c374b75f87c6765a705c4418ab7005a2d356f (diff) |
object: add object_property_set_default
Add a default value to ObjectProperty and an implementation of
ObjectPropertyInit that uses it. This will make it easier to show the
default in help messages.
Also provide convenience functions object_property_set_default_{bool,
str, int, uint}().
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20200110153039.1379601-11-marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include/qom/object.h')
-rw-r--r-- | include/qom/object.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/include/qom/object.h b/include/qom/object.h index afe658c969..82cf20f441 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -378,6 +378,7 @@ struct ObjectProperty ObjectPropertyRelease *release; ObjectPropertyInit *init; void *opaque; + QObject *defval; }; /** @@ -1056,6 +1057,42 @@ ObjectProperty *object_class_property_add(ObjectClass *klass, const char *name, void *opaque, Error **errp); /** + * object_property_set_default_bool: + * @prop: the property to set + * @value: the value to be written to the property + * + * Set the property default value. + */ +void object_property_set_default_bool(ObjectProperty *prop, bool value); + +/** + * object_property_set_default_str: + * @prop: the property to set + * @value: the value to be written to the property + * + * Set the property default value. + */ +void object_property_set_default_str(ObjectProperty *prop, const char *value); + +/** + * object_property_set_default_int: + * @prop: the property to set + * @value: the value to be written to the property + * + * Set the property default value. + */ +void object_property_set_default_int(ObjectProperty *prop, int64_t value); + +/** + * object_property_set_default_uint: + * @prop: the property to set + * @value: the value to be written to the property + * + * Set the property default value. + */ +void object_property_set_default_uint(ObjectProperty *prop, uint64_t value); + +/** * object_property_find: * @obj: the object * @name: the name of the property |