[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH v2 2/7] qapi: Allow true, false and null in sche
From: |
Fam Zheng |
Subject: |
[Qemu-devel] [RFC PATCH v2 2/7] qapi: Allow true, false and null in schema json |
Date: |
Tue, 20 May 2014 17:07:56 +0800 |
Signed-off-by: Fam Zheng <address@hidden>
---
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
- [Qemu-devel] [RFC PATCH v2 0/7] qapi: Specify default value for optional argument in schema json, Fam Zheng, 2014/05/20
- [Qemu-devel] [RFC PATCH v2 1/7] qapi: Allow decimal values, Fam Zheng, 2014/05/20
- [Qemu-devel] [RFC PATCH v2 2/7] qapi: Allow true, false and null in schema json,
Fam Zheng <=
- [Qemu-devel] [RFC PATCH v2 4/7] qapi: Add c_val(t, val) for int, Fam Zheng, 2014/05/20
- [Qemu-devel] [RFC PATCH v2 5/7] qapi: Add @arg property dictionary syntax, Fam Zheng, 2014/05/20
- [Qemu-devel] [RFC PATCH v2 6/7] qapi: Initialize argument value in generated code if has 'default', Fam Zheng, 2014/05/20
- [Qemu-devel] [RFC PATCH v2 3/7] tests: Add decimal test cases for qapi-schema, Fam Zheng, 2014/05/20
- [Qemu-devel] [RFC PATCH v2 7/7] qmp: Convert block-commit speed to arg property dict, Fam Zheng, 2014/05/20
- Re: [Qemu-devel] [RFC PATCH v2 0/7] qapi: Specify default value for optional argument in schema json, Fam Zheng, 2014/05/20
- Re: [Qemu-devel] [RFC PATCH v2 0/7] qapi: Specify default value for optional argument in schema json, Eric Blake, 2014/05/20