* [Qemu-devel] [PATCH] qapi: store raw expressions to QAPISchema
@ 2014-01-23 7:30 Amos Kong
2014-01-23 10:53 ` Markus Armbruster
0 siblings, 1 reply; 3+ messages in thread
From: Amos Kong @ 2014-01-23 7:30 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, mdroth, aliguori, lcapitulino
After cleaning up the comments of qapi-schema.json file, we get
an range of raw expressions, they are also converted to ordered
dictionaries.
This patch just addes a member to QAPISchema to store the raw
expressions.
Actually this patch was split from QMP introspection patchset,
it's no longer needed in that patchset. I would like to post
this patch singly, we can apply it if it's useful.
Signed-off-by: Amos Kong <akong@redhat.com>
---
scripts/qapi.py | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/scripts/qapi.py b/scripts/qapi.py
index 750e9fb..7b92689 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -61,10 +61,13 @@ class QAPISchema:
self.src += '\n'
self.cursor = 0
self.exprs = []
+ self.raw_exprs = []
self.accept()
while self.tok != None:
- self.exprs.append(self.get_expr(False))
+ self.cur_entry= ''
+ self.exprs.append(self.get_expr(False, True))
+ self.raw_exprs.append(self.cur_entry)
def accept(self):
while True:
@@ -103,9 +106,11 @@ class QAPISchema:
elif not self.tok.isspace():
raise QAPISchemaError(self, 'Stray "%s"' % self.tok)
- def get_members(self):
+ def get_members(self, start=None):
expr = OrderedDict()
if self.tok == '}':
+ if start != None:
+ self.cur_entry = self.src[start:self.cursor]
self.accept()
return expr
if self.tok != "'":
@@ -118,6 +123,8 @@ class QAPISchema:
self.accept()
expr[key] = self.get_expr(True)
if self.tok == '}':
+ if start != None:
+ self.cur_entry = self.src[start:self.cursor]
self.accept()
return expr
if self.tok != ',':
@@ -142,12 +149,15 @@ class QAPISchema:
raise QAPISchemaError(self, 'Expected "," or "]"')
self.accept()
- def get_expr(self, nested):
+ def get_expr(self, nested, first=False):
if self.tok != '{' and not nested:
raise QAPISchemaError(self, 'Expected "{"')
if self.tok == '{':
+ start = None
+ if first:
+ start = self.cursor - 1
self.accept()
- expr = self.get_members()
+ expr = self.get_members(start)
elif self.tok == '[':
self.accept()
expr = self.get_values()
--
1.8.4.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] qapi: store raw expressions to QAPISchema
2014-01-23 7:30 [Qemu-devel] [PATCH] qapi: store raw expressions to QAPISchema Amos Kong
@ 2014-01-23 10:53 ` Markus Armbruster
2014-01-23 11:53 ` Amos Kong
0 siblings, 1 reply; 3+ messages in thread
From: Markus Armbruster @ 2014-01-23 10:53 UTC (permalink / raw)
To: Amos Kong; +Cc: lcapitulino, qemu-devel, aliguori, mdroth
Amos Kong <akong@redhat.com> writes:
> After cleaning up the comments of qapi-schema.json file, we get
> an range of raw expressions, they are also converted to ordered
> dictionaries.
>
> This patch just addes a member to QAPISchema to store the raw
> expressions.
>
> Actually this patch was split from QMP introspection patchset,
> it's no longer needed in that patchset. I would like to post
> this patch singly, we can apply it if it's useful.
It'll be useful when it has a user, or if it eases maintenance. Neither
is obvious to me at a quick, superficial glance.
Happy to hear a more verbose explanation of what raw expressions might
be good for.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] qapi: store raw expressions to QAPISchema
2014-01-23 10:53 ` Markus Armbruster
@ 2014-01-23 11:53 ` Amos Kong
0 siblings, 0 replies; 3+ messages in thread
From: Amos Kong @ 2014-01-23 11:53 UTC (permalink / raw)
To: Markus Armbruster; +Cc: lcapitulino, qemu-devel, aliguori, mdroth
On Thu, Jan 23, 2014 at 11:53:24AM +0100, Markus Armbruster wrote:
> Amos Kong <akong@redhat.com> writes:
>
> > After cleaning up the comments of qapi-schema.json file, we get
> > an range of raw expressions, they are also converted to ordered
> > dictionaries.
> >
> > This patch just addes a member to QAPISchema to store the raw
> > expressions.
> >
> > Actually this patch was split from QMP introspection patchset,
> > it's no longer needed in that patchset. I would like to post
> > this patch singly, we can apply it if it's useful.
>
> It'll be useful when it has a user, or if it eases maintenance. Neither
> is obvious to me at a quick, superficial glance.
The patch didn't change original parse logic, it just repeatedly
save each single clear schema to a list in existed loop. I think
it's easy to maintain.
In the introspection patchset, I want to pass raw json expressions
to C code by a head file, then convert the json expressions to
qobject, then ...
At the end, I generated a expression with more metadata when visit
Ordered Dictionaries. So raw expressions were not used.
> Happy to hear a more verbose explanation of what raw expressions might
> be good for.
--
Amos.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-01-23 11:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-23 7:30 [Qemu-devel] [PATCH] qapi: store raw expressions to QAPISchema Amos Kong
2014-01-23 10:53 ` Markus Armbruster
2014-01-23 11:53 ` Amos Kong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).