Received: from eggs.gnu.org ([2001:4830:134:3::10]:43386) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wmg1i-0003OY-Ei for qemu-devel@nongnu.org; Tue, 20 May 2014 05:08:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wmg1b-00080g-O2 for qemu-devel@nongnu.org; Tue, 20 May 2014 05:08:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58907) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wmg1b-00080W-Fi for qemu-devel@nongnu.org; Tue, 20 May 2014 05:07:55 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s4K97sJH008634 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 20 May 2014 05:07:54 -0400 From: Fam Zheng Date: Tue, 20 May 2014 17:07:56 +0800 Message-Id: <1400576881-6954-3-git-send-email-famz@redhat.com> In-Reply-To: <1400576881-6954-1-git-send-email-famz@redhat.com> References: <1400576881-6954-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [RFC PATCH v2 2/7] qapi: Allow true, false and null in schema json List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi Signed-off-by: Fam Zheng --- scripts/qapi.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/scripts/qapi.py b/scripts/qapi.py index 4c945ad..0f275f3 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -171,7 +171,20 @@ class QAPISchema: return except Exception, e: raise QAPISchemaError(self, 'Invalid number "%s": %s' % (val, e)) - + elif self.tok in "tfn": + val = self.src[self.cursor - 1:] + if val.startswith("true"): + self.val = True + self.cursor += 3 + return + elif val.startswith("false"): + self.val = False + self.cursor += 4 + return + elif val.startswith("null"): + self.val = None + self.cursor += 3 + return elif self.tok == '\n': if self.cursor == len(self.src): self.tok = None @@ -211,8 +224,8 @@ class QAPISchema: if self.tok == ']': self.accept() return expr - if not self.tok in "{['-0123456789": - raise QAPISchemaError(self, 'Expected "{", "[", "]", string or number') + if not self.tok in "{['-0123456789tfn": + raise QAPISchemaError(self, 'Expected "{", "[", "]", string, number, boolean or "null"') while True: expr.append(self.get_expr(True)) if self.tok == ']': @@ -231,10 +244,7 @@ class QAPISchema: elif self.tok == '[': self.accept() expr = self.get_values() - elif self.tok == "'": - expr = self.val - self.accept() - elif self.tok in "-0123456789": + elif self.tok in "'0123456789-tfn": expr = self.val self.accept() else: -- 1.9.2