[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v6 32/36] qapi: Drop tests for inline nested str
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH v6 32/36] qapi: Drop tests for inline nested structs |
Date: |
Tue, 28 Apr 2015 15:00:39 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
Eric Blake <address@hidden> writes:
> A future patch will be using a 'name':{dictionary} entry in the
> QAPI schema to specify a default value for an optional argument;
> but existing use of inline nested structs conflicts with that goal.
>
> More precisely, a definition in the QAPI schema associates a name
> with a set of properties:
>
> Example 1: { 'struct': 'Foo', 'data': { MEMBERS... } }
> associates the global name 'Foo' with properties (meta-type struct)
> and MEMBERS...
>
> Example 2: 'mumble': TYPE
> within MEMBERS... above associates 'mumble' with properties (type
> TYPE) and (optional false) within type Foo
>
> The syntax of example 1 is extensible; if we need another property,
> we add another name/value pair to the dictionary (such as
> 'base':TYPE). The syntax of example 2 is not extensible, because
> the right hand side can only be a type.
>
> We have used name encoding to add a property: "'*mumble': 'int'"
> associates 'mumble' with (type int) and (optional true). Nice,
> but doesn't scale. So the solution is to change our existing uses
> to be syntactic sugar to an extensible form:
>
> NAME: TYPE --> NAME: { 'type': TYPE, 'optional': false }
> *ONAME: TYPE --> ONAME: { 'type': TYPE, 'optional': true }
>
> This patch fixes the testsuite to avoid inline nested types, by
> breaking the nesting into explicit types; it means that the type
> is now boxed instead of unboxed in C code, but makes no difference
> on the wire (and if desired, a later patch could change the
> generator to not do so much boxing in C). When touching code to
> add new allocations, also convert existing allocations to
> consistently prefer typesafe g_new0 over g_malloc0 when a type
> name is involved.
>
> Signed-off-by: Eric Blake <address@hidden>
> Reviewed-by: Markus Armbruster <address@hidden>
[...]
> diff --git a/tests/test-visitor-serialization.c
> b/tests/test-visitor-serialization.c
> index 1ccaaa9..52c8d1a 100644
> --- a/tests/test-visitor-serialization.c
> +++ b/tests/test-visitor-serialization.c
> @@ -1,7 +1,7 @@
> /*
> * Unit-tests for visitor-based serialization
> *
> - * Copyright IBM, Corp. 2012
> + * Copyright IBM, Corp. 2012, 2015
More accurate would be:
- * Copyright IBM, Corp. 2012,2013
+ * Copyright IBM, Corp. 2014, 2015
+ * Copyright (C) 2014, 2015 Red Hat Inc.
> *
> * Authors:
> * Michael Roth <address@hidden>
R-by stands all the same.
- Re: [Qemu-devel] [PATCH v6 28/36] qapi: Prefer 'struct' over 'type' in generator, (continued)
- [Qemu-devel] [PATCH v6 29/36] qapi: Document 'struct' metatype, Eric Blake, 2015/04/05
- [Qemu-devel] [PATCH v6 31/36] qapi: Merge UserDefTwo and UserDefNested in tests, Eric Blake, 2015/04/05
- [Qemu-devel] [PATCH v6 34/36] qapi: Drop inline nested structs in query-pci, Eric Blake, 2015/04/05
- [Qemu-devel] [PATCH v6 33/36] qapi: Drop inline nested struct in query-version, Eric Blake, 2015/04/05
- [Qemu-devel] [PATCH v6 35/36] qapi: Drop support for inline nested types, Eric Blake, 2015/04/05
- [Qemu-devel] [PATCH v6 36/36] qapi: Tweak doc references to QMP when QGA is also meant, Eric Blake, 2015/04/05
- [Qemu-devel] [PATCH v6 32/36] qapi: Drop tests for inline nested structs, Eric Blake, 2015/04/05
- Re: [Qemu-devel] [PATCH v6 32/36] qapi: Drop tests for inline nested structs,
Markus Armbruster <=
- [Qemu-devel] [PATCH v6 30/36] qapi: Use 'struct' instead of 'type' in schema, Eric Blake, 2015/04/05
- Re: [Qemu-devel] [PATCH v6 00/36] drop qapi nested structs, Eric Blake, 2015/04/06
- [Qemu-devel] [PATCH v6 38/36] qapi: Check for member name conflicts with a base class, Eric Blake, 2015/04/10
- [Qemu-devel] [PATCH v6 37/36] qapi: Support (subset of) \u escapes in strings, Eric Blake, 2015/04/10
- Re: [Qemu-devel] [PATCH v6 00/36] drop qapi nested structs, Markus Armbruster, 2015/04/28