On 09/17/2015 06:52 PM, Wen Congyang wrote: >> > > OK, I will try it. What is difference between start_struct() and > start_implicit_struct()?
If you have the following QDict: { "a":1, "b":2", "c:3" } start_struct() corresponds to the {, and end_struct() corresponds to the }. If the corresponding qapi type is completely inline, then that's all the more you need: struct Foo { int a; int b; int c; }; But oftentimes, we want some sub-structure in our qapi types. So suppose we want to always parse 'b' and 'c' together, in a reusable struct, as in: struct Bar { int b; int c; }; struct Foo { int a; Bar *sub; } With the above representation, we can do a boxed visit by using only start_struct()/end_struct(), but it maps to two levels of {} nesting, as in: { "a":1, "sub":{ "b":2, "c":3 } } But sometimes we want the C struct nesting while still keeping the QDict representation flat. And that's where start_implicit_struct() enters the picture. It says to start a new C struct while still keeping the QDict nesting unchanged. Right now, we use implicit structs for 'base' types and for flat unions, although some of my pending qapi patches get rid of the use of implicit structs for base types. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature