From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH RFC 3/9] libxl_internal: make JSON_* types or-able Date: Mon, 14 Apr 2014 18:03:03 +0100 Message-ID: <1397494983.7802.28.camel@dagon.hellion.org.uk> References: <1397144422-18906-1-git-send-email-wei.liu2@citrix.com> <1397144422-18906-5-git-send-email-wei.liu2@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1397144422-18906-5-git-send-email-wei.liu2@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Wei Liu Cc: ian.jackson@eu.citrix.com, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Thu, 2014-04-10 at 16:40 +0100, Wei Liu wrote: > Libxl can generate number as type JSON_INTEGER, JSON_DOUBLE or > JSON_NUMBER, Those are three distinct types, right? Rather than NUMBER being the union of INTERGERs and DOUBLEs? > string as type JSON_STRING or JSON_NULL (if string is > null). > > So make JSON_* type or-able I think the phrase you want is "make FOO a bit-field". > + JSON_ANY = (1 << 8) Is ANY here meaning "Any of the others" or is it a specific JSON type? If the former then should this be 0xff? (or whatever mask achieves the aim of matching all types) > } libxl__json_node_type; > > typedef struct libxl__json_object { > diff --git a/tools/libxl/libxl_json.c b/tools/libxl/libxl_json.c > index 002ae2d..da315f6 100644 > --- a/tools/libxl/libxl_json.c > +++ b/tools/libxl/libxl_json.c > @@ -363,7 +363,7 @@ const libxl__json_object *libxl__json_map_get(const char *key, > return NULL; > if (strcmp(key, node->map_key) == 0) { > if (expected_type == JSON_ANY > - || (node->obj && node->obj->type == expected_type)) { > + || (node->obj && (node->obj->type & expected_type))) { > return node->obj; > } else { > return NULL;