|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v7 63/65] qom: remove old enum property registration API
Now that all callers use object_class_property_add_qapi_enum(), remove
the legacy object_property_add_enum() and object_class_property_add_enum()
functions along with their EnumProperty struct and property_get_enum /
property_set_enum helpers.
Simplify object_property_get_enum() to assert on qapi_type rather than
falling back to the old EnumProperty opaque data.
Signed-off-by: Markus Armbruster <armbru@xxxxxxxxxx>
Signed-off-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>
---
include/qom/object.h | 45 ++--------------------------
qom/object.c | 82 ++--------------------------------------------------
2 files changed, 4 insertions(+), 123 deletions(-)
diff --git a/include/qom/object.h b/include/qom/object.h
index 29cbd84b8d03..a9bbc44cfcc9 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -1697,12 +1697,12 @@ char *object_get_canonical_path(const Object *obj);
* because it was ambiguous, or %NULL. Set to %false on success.
*
* There are two types of supported paths--absolute paths and partial paths.
- *
+ *
* Absolute paths are derived from the root object and can follow child<> or
* link<> properties. Since they can follow link<> properties, they can be
* arbitrarily long. Absolute paths look like absolute filenames and are
* prefixed with a leading slash.
- *
+ *
* Partial paths look like relative filenames. They do not begin with a
* prefix. The matching rules for partial paths are subtle but designed to
make
* specifying objects easy. At each level of the composition tree, the partial
@@ -1986,47 +1986,6 @@ ObjectProperty
*object_class_property_add_bool(ObjectClass *klass,
bool (*get)(Object *, Error **),
void (*set)(Object *, bool, Error **));
-/**
- * object_property_add_enum:
- * @obj: the object to add a property to
- * @name: the name of the property
- * @typename: the name of the enum data type
- * @lookup: enum value namelookup table
- * @get: the getter or %NULL if the property is write-only.
- * @set: the setter or %NULL if the property is read-only
- *
- * Add an enum property using getters/setters. This function will add a
- * property of type '@typename'.
- *
- * Returns: The newly added property on success, or %NULL on failure.
- */
-ObjectProperty *object_property_add_enum(Object *obj, const char *name,
- const char *typename,
- const QEnumLookup *lookup,
- int (*get)(Object *, Error **),
- void (*set)(Object *, int, Error **));
-
-/**
- * object_class_property_add_enum:
- * @klass: the object class to add a property to
- * @name: the name of the property
- * @typename: the name of the enum data type
- * @lookup: enum value namelookup table
- * @get: the getter or %NULL if the property is write-only.
- * @set: the setter or %NULL if the property is read-only
- *
- * Add an enum property using getters/setters. This function will add a
- * property of type '@typename'.
- *
- * Returns: The newly added property on success, or %NULL on failure.
- */
-ObjectProperty *object_class_property_add_enum(ObjectClass *klass,
- const char *name,
- const char *typename,
- const QEnumLookup *lookup,
- int (*get)(Object *, Error **),
- void (*set)(Object *, int, Error **));
-
/**
* struct QapiEnumProp: Descriptor for a property backed by a QAPI enum type
*
diff --git a/qom/object.c b/qom/object.c
index cf18880c6c0c..791d981dc689 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1774,12 +1774,6 @@ uint64_t object_property_get_uint(Object *obj, const
char *name,
return retval;
}
-typedef struct EnumProperty {
- const QEnumLookup *lookup;
- int (*get)(Object *, Error **);
- void (*set)(Object *, int, Error **);
-} EnumProperty;
-
int object_property_get_enum(Object *obj, const char *name,
const char *typename, Error **errp)
{
@@ -1803,12 +1797,8 @@ int object_property_get_enum(Object *obj, const char
*name,
return -1;
}
- if (prop->qapi_type) {
- ret = qapi_enum_parse(prop->qapi_type->lookup, str, -1, errp);
- } else {
- EnumProperty *enumprop = prop->opaque;
- ret = qapi_enum_parse(enumprop->lookup, str, -1, errp);
- }
+ assert(prop->qapi_type);
+ ret = qapi_enum_parse(prop->qapi_type->lookup, str, -1, errp);
g_free(str);
return ret;
@@ -2543,74 +2533,6 @@ object_class_property_add_bool(ObjectClass *klass, const
char *name,
prop);
}
-static void property_get_enum(Object *obj, Visitor *v, const char *name,
- void *opaque, Error **errp)
-{
- EnumProperty *prop = opaque;
- int value;
- Error *err = NULL;
-
- value = prop->get(obj, &err);
- if (err) {
- error_propagate(errp, err);
- return;
- }
-
- visit_type_enum(v, name, &value, prop->lookup, errp);
-}
-
-static void property_set_enum(Object *obj, Visitor *v, const char *name,
- void *opaque, Error **errp)
-{
- EnumProperty *prop = opaque;
- int value;
-
- if (!visit_type_enum(v, name, &value, prop->lookup, errp)) {
- return;
- }
- prop->set(obj, value, errp);
-}
-
-ObjectProperty *
-object_property_add_enum(Object *obj, const char *name,
- const char *typename,
- const QEnumLookup *lookup,
- int (*get)(Object *, Error **),
- void (*set)(Object *, int, Error **))
-{
- EnumProperty *prop = g_malloc(sizeof(*prop));
-
- prop->lookup = lookup;
- prop->get = get;
- prop->set = set;
-
- return object_property_add(obj, name, typename,
- get ? property_get_enum : NULL,
- set ? property_set_enum : NULL,
- property_release_data,
- prop);
-}
-
-ObjectProperty *
-object_class_property_add_enum(ObjectClass *klass, const char *name,
- const char *typename,
- const QEnumLookup *lookup,
- int (*get)(Object *, Error **),
- void (*set)(Object *, int, Error **))
-{
- EnumProperty *prop = g_malloc(sizeof(*prop));
-
- prop->lookup = lookup;
- prop->get = get;
- prop->set = set;
-
- return object_class_property_add(klass, name, typename,
- get ? property_get_enum : NULL,
- set ? property_set_enum : NULL,
- NULL,
- prop);
-}
-
static void get_qapi_enum(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
--
2.56.0.116.g6de20f6092dc
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |