aboutsummaryrefslogtreecommitdiff
path: root/qom
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2017-08-24 10:46:10 +0200
committerMarkus Armbruster <armbru@redhat.com>2017-09-04 13:09:13 +0200
commitf7abe0ecd4973dfe36944b916c5b9cf8ec199b8a (patch)
tree99ca676afbfcf2da0182b3bf99811d000cb69c58 /qom
parent788b305c91398f18e5952667b929d7f45e2c211c (diff)
downloadqemu-f7abe0ecd4973dfe36944b916c5b9cf8ec199b8a.zip
qemu-f7abe0ecd4973dfe36944b916c5b9cf8ec199b8a.tar.gz
qemu-f7abe0ecd4973dfe36944b916c5b9cf8ec199b8a.tar.bz2
qapi: Change data type of the FOO_lookup generated for enum FOO
Currently, a FOO_lookup is an array of strings terminated by a NULL sentinel. A future patch will generate enums with "holes". NULL-termination will cease to work then. To prepare for that, store the length in the FOO_lookup by wrapping it in a struct and adding a member for the length. The sentinel will be dropped next. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20170822132255.23945-13-marcandre.lureau@redhat.com> [Basically redone] Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <1503564371-26090-16-git-send-email-armbru@redhat.com> [Rebased]
Diffstat (limited to 'qom')
-rw-r--r--qom/object.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/qom/object.c b/qom/object.c
index fe6e744..3e18537 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1246,7 +1246,7 @@ uint64_t object_property_get_uint(Object *obj, const char *name,
}
typedef struct EnumProperty {
- const char * const *strings;
+ const QEnumLookup *lookup;
int (*get)(Object *, Error **);
void (*set)(Object *, int, Error **);
} EnumProperty;
@@ -1284,7 +1284,7 @@ int object_property_get_enum(Object *obj, const char *name,
visit_complete(v, &str);
visit_free(v);
v = string_input_visitor_new(str);
- visit_type_enum(v, name, &ret, enumprop->strings, errp);
+ visit_type_enum(v, name, &ret, enumprop->lookup, errp);
g_free(str);
visit_free(v);
@@ -1950,7 +1950,7 @@ static void property_get_enum(Object *obj, Visitor *v, const char *name,
return;
}
- visit_type_enum(v, name, &value, prop->strings, errp);
+ visit_type_enum(v, name, &value, prop->lookup, errp);
}
static void property_set_enum(Object *obj, Visitor *v, const char *name,
@@ -1960,7 +1960,7 @@ static void property_set_enum(Object *obj, Visitor *v, const char *name,
int value;
Error *err = NULL;
- visit_type_enum(v, name, &value, prop->strings, &err);
+ visit_type_enum(v, name, &value, prop->lookup, &err);
if (err) {
error_propagate(errp, err);
return;
@@ -1977,7 +1977,7 @@ static void property_release_enum(Object *obj, const char *name,
void object_property_add_enum(Object *obj, const char *name,
const char *typename,
- const char * const *strings,
+ const QEnumLookup *lookup,
int (*get)(Object *, Error **),
void (*set)(Object *, int, Error **),
Error **errp)
@@ -1985,7 +1985,7 @@ void object_property_add_enum(Object *obj, const char *name,
Error *local_err = NULL;
EnumProperty *prop = g_malloc(sizeof(*prop));
- prop->strings = strings;
+ prop->lookup = lookup;
prop->get = get;
prop->set = set;
@@ -2002,7 +2002,7 @@ void object_property_add_enum(Object *obj, const char *name,
void object_class_property_add_enum(ObjectClass *klass, const char *name,
const char *typename,
- const char * const *strings,
+ const QEnumLookup *lookup,
int (*get)(Object *, Error **),
void (*set)(Object *, int, Error **),
Error **errp)
@@ -2010,7 +2010,7 @@ void object_class_property_add_enum(ObjectClass *klass, const char *name,
Error *local_err = NULL;
EnumProperty *prop = g_malloc(sizeof(*prop));
- prop->strings = strings;
+ prop->lookup = lookup;
prop->get = get;
prop->set = set;