@@ -242,7 +242,7 @@ extern const PropertyInfo prop_info_link;
*/
#define FIELD_PROP(def) \
- ({ static Property _p = def; &p; })
+ ({ static Property _p = def; &_p; })
#define PROP_SIGNED(...) \
FIELD_PROP(DEFINE_PROP_SIGNED(NULL, __VA_ARGS__))
@@ -26,6 +26,9 @@
#include "qemu/option.h"
#include "qemu/config-file.h"
#include "qom/object_interfaces.h"
+#include "qom/field-property.h"
+#include "qom/field-property-internal.h"
+#include "qom/property-types.h"
#define TYPE_DUMMY "qemu-dummy"
@@ -68,24 +71,6 @@ struct DummyObjectClass {
};
-static void dummy_set_bv(Object *obj,
- bool value,
- Error **errp)
-{
- DummyObject *dobj = DUMMY_OBJECT(obj);
-
- dobj->bv = value;
-}
-
-static bool dummy_get_bv(Object *obj,
- Error **errp)
-{
- DummyObject *dobj = DUMMY_OBJECT(obj);
-
- return dobj->bv;
-}
-
-
static void dummy_set_av(Object *obj,
int value,
Error **errp)
@@ -103,39 +88,18 @@ static int dummy_get_av(Object *obj,
return dobj->av;
}
-
-static void dummy_set_sv(Object *obj,
- const char *value,
- Error **errp)
-{
- DummyObject *dobj = DUMMY_OBJECT(obj);
-
- g_free(dobj->sv);
- dobj->sv = g_strdup(value);
-}
-
-static char *dummy_get_sv(Object *obj,
- Error **errp)
-{
- DummyObject *dobj = DUMMY_OBJECT(obj);
-
- return g_strdup(dobj->sv);
-}
-
-
static void dummy_init(Object *obj)
{
- object_property_add_bool(obj, "bv",
- dummy_get_bv,
- dummy_set_bv);
+ object_property_add_field(obj, "bv",
+ PROP_BOOL(DummyObject, bv, false),
+ prop_allow_set_always);
}
-
static void dummy_class_init(ObjectClass *cls, void *data)
{
- object_class_property_add_str(cls, "sv",
- dummy_get_sv,
- dummy_set_sv);
+ object_class_property_add_field(cls, "sv",
+ PROP_STRING(DummyObject, sv),
+ prop_allow_set_always);
object_class_property_add_enum(cls, "av",
"DummyAnimal",
&dummy_animal_map,
@@ -143,21 +107,11 @@ static void dummy_class_init(ObjectClass *cls, void *data)
dummy_set_av);
}
-
-static void dummy_finalize(Object *obj)
-{
- DummyObject *dobj = DUMMY_OBJECT(obj);
-
- g_free(dobj->sv);
-}
-
-
static const TypeInfo dummy_info = {
.name = TYPE_DUMMY,
.parent = TYPE_OBJECT,
.instance_size = sizeof(DummyObject),
.instance_init = dummy_init,
- .instance_finalize = dummy_finalize,
.class_size = sizeof(DummyObjectClass),
.class_init = dummy_class_init,
.interfaces = (InterfaceInfo[]) {
Use field properties for the bool and string properties used at check-qom-proplist. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- Changes v2: * Redone patch using PROP_* instead of DEFINE_PROP_* --- Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: "Daniel P. Berrangé" <berrange@redhat.com> Cc: Eduardo Habkost <ehabkost@redhat.com> Cc: qemu-devel@nongnu.org --- include/qom/property-types.h | 2 +- tests/check-qom-proplist.c | 64 +++++------------------------------- 2 files changed, 10 insertions(+), 56 deletions(-)