WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] Re: [PATCH V6 2/3] libxl: Introduce JSON parsing stuff.

To: Anthony PERARD <anthony.perard@xxxxxxxxxx>
Subject: [Xen-devel] Re: [PATCH V6 2/3] libxl: Introduce JSON parsing stuff.
From: Ian Campbell <Ian.Campbell@xxxxxxxxxxxxx>
Date: Fri, 1 Jul 2011 09:14:34 +0100
Cc: Xen Devel <xen-devel@xxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <Stefano.Stabellini@xxxxxxxxxxxxx>
Delivery-date: Fri, 01 Jul 2011 01:15:32 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1309455045-3062-3-git-send-email-anthony.perard@xxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: Citrix Systems, Inc.
References: <1309455045-3062-1-git-send-email-anthony.perard@xxxxxxxxxx> <1309455045-3062-3-git-send-email-anthony.perard@xxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Thu, 2011-06-30 at 18:30 +0100, Anthony PERARD wrote:
> We use the yajl parser, but we need to make a tree from the parse result
> to use it outside the parser.
> 
> So this patch include json_object struct that is used to hold the JSON
> data.
> 
> Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
> ---
>  tools/libxl/Makefile         |    5 +-
>  tools/libxl/libxl_internal.h |   97 ++++++++
>  tools/libxl/libxl_json.c     |  521 
> ++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 622 insertions(+), 1 deletions(-)
>  create mode 100644 tools/libxl/libxl_json.c
> 
> diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
> index a95cd5d..0306cb0 100644
> --- a/tools/libxl/Makefile
> +++ b/tools/libxl/Makefile
> @@ -32,9 +32,12 @@ endif
>  LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o
>  LIBXL_OBJS-$(CONFIG_IA64) += libxl_nocpuid.o
> 
> +LIBXL_LIBS += -lyajl
> +
>  LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o libxl_pci.o \
>                         libxl_dom.o libxl_exec.o libxl_xshelp.o 
> libxl_device.o \
> -                       libxl_internal.o libxl_utils.o libxl_uuid.o 
> $(LIBXL_OBJS-y)
> +                       libxl_internal.o libxl_utils.o libxl_uuid.o 
> libxl_json.o \
> +                       $(LIBXL_OBJS-y)
>  LIBXL_OBJS += _libxl_types.o libxl_flask.o _libxl_types_internal.o
> 
>  $(LIBXL_OBJS): CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) 
> $(CFLAGS_libxenstore) $(CFLAGS_libblktapctl)
> diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
> index 71eb189..555d9f3 100644
> --- a/tools/libxl/libxl_internal.h
> +++ b/tools/libxl/libxl_internal.h
> @@ -381,4 +381,101 @@ _hidden int libxl__e820_alloc(libxl_ctx *ctx, uint32_t 
> domid, libxl_domain_confi
>  #define STRINGIFY(x) #x
>  #define TOSTRING(x) STRINGIFY(x)
> 
> +/* from libxl_json */
> +typedef enum {
> +    JSON_ERROR,
> +    JSON_NULL,
> +    JSON_TRUE,
> +    JSON_FALSE,
> +    JSON_INTEGER,
> +    JSON_DOUBLE,
> +    JSON_STRING,
> +    JSON_MAP,
> +    JSON_ARRAY,
> +    JSON_ANY
> +} libxl__json_node_type;

Could be internal IDL? Maybe no much point if you aren't using the
to_string functions etc?

> +
> +typedef struct libxl__json_object {
> +    libxl__json_node_type type;
> +    union {
> +        long i;
> +        double d;
> +        const char *string;

Is it really const? Seems to be malloc/freed?

> [...]+#ifdef DEBUG_ANSWER
> +#  define DEBUG_GEN_ALLOC(h) \
> +    if (h == NULL) { \
> +        yajl_gen_config conf = { 1, "  " }; \
> +        h = yajl_gen_alloc(&conf, NULL); \
> +    }

All the callers of these macros use ctx->g. I think you could push the
->g down into the macros.

[...]

Ian



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>