[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH RFC V2 07/10] libxl/gentypes.py: generate JSON object for keyed-union discriminator



On Thu, 2014-04-17 at 12:13 +0100, Wei Liu wrote:

When $subject save "generate JSON object" does it really mean "include
discriminator in the json output"? It's not really an object in this
context is it?

> Parser relies on the discriminator to go to correct branch.
> 
> Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
> ---
>  tools/libxl/gentypes.py |    5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/tools/libxl/gentypes.py b/tools/libxl/gentypes.py
> index 61a2b3d..8d7183a 100644
> --- a/tools/libxl/gentypes.py
> +++ b/tools/libxl/gentypes.py
> @@ -229,6 +229,11 @@ def libxl_C_type_gen_json(ty, v, indent = "    ", parent 
> = None):
>                  s += "        goto out;\n"
>              s += "    break;\n"
>          s += "}\n"
> +        s += "s = yajl_gen_string(hand, (const unsigned char *)\"%s\", 
> sizeof(\"%s\")-1);\n" \
> +             % (ty.keyvar.name, ty.keyvar.name)

> +        s += "if (s != yajl_gen_status_ok)\n"
> +        s += "    goto out;\n"
> +        s += libxl_C_type_gen_json(ty.keyvar.type, (parent + 
> ty.keyvar.name), indent, parent)
>      elif isinstance(ty, idl.Struct) and (parent is None or ty.json_gen_fn is 
> None):
>          s += "s = yajl_gen_map_open(hand);\n"
>          s += "if (s != yajl_gen_status_ok)\n"



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.