Re: [Qemu-devel] [PATCH v2 16/29] qapi: Generate in source order

2018-02-19 Thread Michael Roth
Quoting Markus Armbruster (2018-02-11 03:35:54)
> The generators' conversion to visitors (merge commit 9e72681d16)
> changed the processing order of entities from source order to
> alphabetical order.  The next commit needs source order, so change it
> back.
> 
> Signed-off-by: Markus Armbruster 
> Reviewed-by: Marc-André Lureau 

Reviewed-by: Michael Roth 

> ---
>  scripts/qapi/common.py   |   6 +-
>  tests/qapi-schema/comments.out   |   2 +-
>  tests/qapi-schema/doc-bad-section.out|   4 +-
>  tests/qapi-schema/doc-good.out   |  32 ++--
>  tests/qapi-schema/empty.out  |   2 +-
>  tests/qapi-schema/event-case.out |   2 +-
>  tests/qapi-schema/ident-with-escape.out  |   6 +-
>  tests/qapi-schema/include-relpath.out|   2 +-
>  tests/qapi-schema/include-repetition.out |   2 +-
>  tests/qapi-schema/include-simple.out |   2 +-
>  tests/qapi-schema/indented-expr.out  |   2 +-
>  tests/qapi-schema/qapi-schema-test.out   | 320 
> +++
>  12 files changed, 192 insertions(+), 190 deletions(-)
> 
> diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
> index 6d49709784..b531ab519f 100644
> --- a/scripts/qapi/common.py
> +++ b/scripts/qapi/common.py
> @@ -1475,6 +1475,7 @@ class QAPISchema(object):
>  parser = QAPISchemaParser(open(fname, 'r'))
>  exprs = check_exprs(parser.exprs)
>  self.docs = parser.docs
> +self._entity_list = []
>  self._entity_dict = {}
>  self._predefining = True
>  self._def_predefineds()
> @@ -1486,6 +1487,7 @@ class QAPISchema(object):
>  # Only the predefined types are allowed to not have info
>  assert ent.info or self._predefining
>  assert ent.name not in self._entity_dict
> +self._entity_list.append(ent)
>  self._entity_dict[ent.name] = ent
> 
>  def lookup_entity(self, name, typ=None):
> @@ -1684,12 +1686,12 @@ class QAPISchema(object):
>  assert False
> 
>  def check(self):
> -for (name, ent) in sorted(self._entity_dict.items()):
> +for ent in self._entity_list:
>  ent.check(self)
> 
>  def visit(self, visitor):
>  visitor.visit_begin(self)
> -for (name, entity) in sorted(self._entity_dict.items()):
> +for entity in self._entity_list:
>  if visitor.visit_needed(entity):
>  entity.visit(visitor)
>  visitor.visit_end()
> diff --git a/tests/qapi-schema/comments.out b/tests/qapi-schema/comments.out
> index 17e652535c..0261ddf202 100644
> --- a/tests/qapi-schema/comments.out
> +++ b/tests/qapi-schema/comments.out
> @@ -1,4 +1,4 @@
> +object q_empty
>  enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
>  prefix QTYPE
>  enum Status ['good', 'bad', 'ugly']
> -object q_empty
> diff --git a/tests/qapi-schema/doc-bad-section.out 
> b/tests/qapi-schema/doc-bad-section.out
> index 089bde1381..23bf8c71ab 100644
> --- a/tests/qapi-schema/doc-bad-section.out
> +++ b/tests/qapi-schema/doc-bad-section.out
> @@ -1,7 +1,7 @@
> -enum Enum ['one', 'two']
> +object q_empty
>  enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
>  prefix QTYPE
> -object q_empty
> +enum Enum ['one', 'two']
>  doc symbol=Enum
>  body=
>  == Produces *invalid* texinfo
> diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out
> index 1d2c250527..0c07301f07 100644
> --- a/tests/qapi-schema/doc-good.out
> +++ b/tests/qapi-schema/doc-good.out
> @@ -1,35 +1,35 @@
> +object q_empty
> +enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
> +prefix QTYPE
> +enum Enum ['one', 'two']
>  object Base
>  member base1: Enum optional=False
> -enum Enum ['one', 'two']
> +object Variant1
> +member var1: str optional=False
> +object Variant2
>  object Object
>  base Base
>  tag base1
>  case one: Variant1
>  case two: Variant2
> -enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
> -prefix QTYPE
> +object q_obj_Variant1-wrapper
> +member data: Variant1 optional=False
> +object q_obj_Variant2-wrapper
> +member data: Variant2 optional=False
> +enum SugaredUnionKind ['one', 'two']
>  object SugaredUnion
>  member type: SugaredUnionKind optional=False
>  tag type
>  case one: q_obj_Variant1-wrapper
>  case two: q_obj_Variant2-wrapper
> -enum SugaredUnionKind ['one', 'two']
> -object Variant1
> -member var1: str optional=False
> -object Variant2
> -command cmd q_obj_cmd-arg -> Object
> -   gen=True success_response=True boxed=False
> -command cmd-boxed Object -> None
> -   gen=True success_response=True boxed=True
> -object q_empty
> -object q_obj_Variant1-wrapper
> -member data: Variant1 optional=False
> -object q_obj_Variant2-wrapper
> -member data: Variant2 optional=False

Re: [Qemu-devel] [PATCH v2 16/29] qapi: Generate in source order

2018-02-12 Thread Eric Blake

On 02/11/2018 03:35 AM, Markus Armbruster wrote:

The generators' conversion to visitors (merge commit 9e72681d16)
changed the processing order of entities from source order to
alphabetical order.  The next commit needs source order, so change it
back.

Signed-off-by: Markus Armbruster 
Reviewed-by: Marc-André Lureau 
---


Reviewed-by: Eric Blake 

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3266
Virtualization:  qemu.org | libvirt.org