diff options
author | Marc-André Lureau | 2020-01-10 16:30:23 +0100 |
---|---|---|
committer | Paolo Bonzini | 2020-01-24 20:59:13 +0100 |
commit | 0e76ed0a5da4c8540597c1ffac72705e04323f69 (patch) | |
tree | 6a5daf73b26ed25d72cc329ac23c29173d1905df /include/qom | |
parent | qstring: add qstring_free() (diff) | |
download | qemu-0e76ed0a5da4c8540597c1ffac72705e04323f69.tar.gz qemu-0e76ed0a5da4c8540597c1ffac72705e04323f69.tar.xz qemu-0e76ed0a5da4c8540597c1ffac72705e04323f69.zip |
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')
-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 |