mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-09-06 18:05:37 +00:00
qapi: add explicit null to string input and output visitors
This may be used for deprecated object properties that are kept for backwards compatibility. Signed-off-by: Greg Kurz <groug@kaod.org> Reviewed-by: Markus Armbruster <armbru@redhat.com> Tested-by: Andrea Bolognani <abologna@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
6d034b7bf8
commit
a733371214
|
@ -326,6 +326,16 @@ static void parse_type_number(Visitor *v, const char *name, double *obj,
|
||||||
*obj = val;
|
*obj = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void parse_type_null(Visitor *v, const char *name, Error **errp)
|
||||||
|
{
|
||||||
|
StringInputVisitor *siv = to_siv(v);
|
||||||
|
|
||||||
|
if (!siv->string || siv->string[0]) {
|
||||||
|
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
|
||||||
|
"null");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void string_input_free(Visitor *v)
|
static void string_input_free(Visitor *v)
|
||||||
{
|
{
|
||||||
StringInputVisitor *siv = to_siv(v);
|
StringInputVisitor *siv = to_siv(v);
|
||||||
|
@ -349,6 +359,7 @@ Visitor *string_input_visitor_new(const char *str)
|
||||||
v->visitor.type_bool = parse_type_bool;
|
v->visitor.type_bool = parse_type_bool;
|
||||||
v->visitor.type_str = parse_type_str;
|
v->visitor.type_str = parse_type_str;
|
||||||
v->visitor.type_number = parse_type_number;
|
v->visitor.type_number = parse_type_number;
|
||||||
|
v->visitor.type_null = parse_type_null;
|
||||||
v->visitor.start_list = start_list;
|
v->visitor.start_list = start_list;
|
||||||
v->visitor.next_list = next_list;
|
v->visitor.next_list = next_list;
|
||||||
v->visitor.check_list = check_list;
|
v->visitor.check_list = check_list;
|
||||||
|
|
|
@ -256,6 +256,19 @@ static void print_type_number(Visitor *v, const char *name, double *obj,
|
||||||
string_output_set(sov, g_strdup_printf("%f", *obj));
|
string_output_set(sov, g_strdup_printf("%f", *obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void print_type_null(Visitor *v, const char *name, Error **errp)
|
||||||
|
{
|
||||||
|
StringOutputVisitor *sov = to_sov(v);
|
||||||
|
char *out;
|
||||||
|
|
||||||
|
if (sov->human) {
|
||||||
|
out = g_strdup("<null>");
|
||||||
|
} else {
|
||||||
|
out = g_strdup("");
|
||||||
|
}
|
||||||
|
string_output_set(sov, out);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
start_list(Visitor *v, const char *name, GenericList **list, size_t size,
|
start_list(Visitor *v, const char *name, GenericList **list, size_t size,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
|
@ -341,6 +354,7 @@ Visitor *string_output_visitor_new(bool human, char **result)
|
||||||
v->visitor.type_bool = print_type_bool;
|
v->visitor.type_bool = print_type_bool;
|
||||||
v->visitor.type_str = print_type_str;
|
v->visitor.type_str = print_type_str;
|
||||||
v->visitor.type_number = print_type_number;
|
v->visitor.type_number = print_type_number;
|
||||||
|
v->visitor.type_null = print_type_null;
|
||||||
v->visitor.start_list = start_list;
|
v->visitor.start_list = start_list;
|
||||||
v->visitor.next_list = next_list;
|
v->visitor.next_list = next_list;
|
||||||
v->visitor.end_list = end_list;
|
v->visitor.end_list = end_list;
|
||||||
|
|
Loading…
Reference in a new issue