qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC PATCH 11/32] qapi: Drop the options to generate on


From: Marc-André Lureau
Subject: Re: [Qemu-devel] [RFC PATCH 11/32] qapi: Drop the options to generate only .c or .h
Date: Wed, 4 Oct 2017 13:07:46 +0200

On Mon, Oct 2, 2017 at 5:25 PM, Markus Armbruster <address@hidden> wrote:
> Signed-off-by: Markus Armbruster <address@hidden>

Reviewed-by: Marc-André Lureau <address@hidden>


> ---
>  scripts/qapi-commands.py   |  4 ++--
>  scripts/qapi-event.py      |  4 ++--
>  scripts/qapi-introspect.py |  4 ++--
>  scripts/qapi-types.py      |  4 ++--
>  scripts/qapi-visit.py      |  4 ++--
>  scripts/qapi.py            | 25 ++++---------------------
>  6 files changed, 14 insertions(+), 31 deletions(-)
>
> diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
> index 974d0a4a80..56a1009564 100644
> --- a/scripts/qapi-commands.py
> +++ b/scripts/qapi-commands.py
> @@ -253,7 +253,7 @@ class QAPISchemaGenCommandVisitor(QAPISchemaVisitor):
>          self._regy += gen_register_command(name, success_response)
>
>
> -(input_file, output_dir, do_c, do_h, prefix, opts) = parse_command_line()
> +(input_file, output_dir, prefix, opts) = parse_command_line()
>
>  c_comment = '''
>  /*
> @@ -284,7 +284,7 @@ h_comment = '''
>   */
>  '''
>
> -(fdef, fdecl) = open_output(output_dir, do_c, do_h, prefix,
> +(fdef, fdecl) = open_output(output_dir, prefix,
>                              'qmp-marshal.c', 'qmp-commands.h',
>                              c_comment, h_comment)
>
> diff --git a/scripts/qapi-event.py b/scripts/qapi-event.py
> index 07b4b70199..0a308e6b69 100644
> --- a/scripts/qapi-event.py
> +++ b/scripts/qapi-event.py
> @@ -169,7 +169,7 @@ class QAPISchemaGenEventVisitor(QAPISchemaVisitor):
>          self._event_names.append(name)
>
>
> -(input_file, output_dir, do_c, do_h, prefix, dummy) = parse_command_line()
> +(input_file, output_dir, prefix, dummy) = parse_command_line()
>
>  c_comment = '''
>  /*
> @@ -200,7 +200,7 @@ h_comment = '''
>   */
>  '''
>
> -(fdef, fdecl) = open_output(output_dir, do_c, do_h, prefix,
> +(fdef, fdecl) = open_output(output_dir, prefix,
>                              'qapi-event.c', 'qapi-event.h',
>                              c_comment, h_comment)
>
> diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py
> index 032bcea491..c2e46182c8 100644
> --- a/scripts/qapi-introspect.py
> +++ b/scripts/qapi-introspect.py
> @@ -169,7 +169,7 @@ const char %(c_name)s[] = %(c_string)s;
>  # We normally mask them, because they're not QMP wire ABI
>  opt_unmask = False
>
> -(input_file, output_dir, do_c, do_h, prefix, opts) = \
> +(input_file, output_dir, prefix, opts) = \
>      parse_command_line('u', ['unmask-non-abi-names'])
>
>  for o, a in opts:
> @@ -199,7 +199,7 @@ h_comment = '''
>   */
>  '''
>
> -(fdef, fdecl) = open_output(output_dir, do_c, do_h, prefix,
> +(fdef, fdecl) = open_output(output_dir, prefix,
>                              'qmp-introspect.c', 'qmp-introspect.h',
>                              c_comment, h_comment)
>
> diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
> index 7e3051dbb9..dc7dd08512 100644
> --- a/scripts/qapi-types.py
> +++ b/scripts/qapi-types.py
> @@ -243,7 +243,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
>  # QAPISchemaGenTypeVisitor.visit_end().
>  do_builtins = False
>
> -(input_file, output_dir, do_c, do_h, prefix, opts) = \
> +(input_file, output_dir, prefix, opts) = \
>      parse_command_line('b', ['builtins'])
>
>  for o, a in opts:
> @@ -280,7 +280,7 @@ h_comment = '''
>   */
>  '''
>
> -(fdef, fdecl) = open_output(output_dir, do_c, do_h, prefix,
> +(fdef, fdecl) = open_output(output_dir, prefix,
>                              'qapi-types.c', 'qapi-types.h',
>                              c_comment, h_comment)
>
> diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
> index 7e1cfc13f0..9757911d2d 100644
> --- a/scripts/qapi-visit.py
> +++ b/scripts/qapi-visit.py
> @@ -327,7 +327,7 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor):
>  # QAPISchemaGenVisitVisitor.visit_end().
>  do_builtins = False
>
> -(input_file, output_dir, do_c, do_h, prefix, opts) = \
> +(input_file, output_dir, prefix, opts) = \
>      parse_command_line('b', ['builtins'])
>
>  for o, a in opts:
> @@ -363,7 +363,7 @@ h_comment = '''
>   */
>  '''
>
> -(fdef, fdecl) = open_output(output_dir, do_c, do_h, prefix,
> +(fdef, fdecl) = open_output(output_dir, prefix,
>                              'qapi-visit.c', 'qapi-visit.h',
>                              c_comment, h_comment)
>
> diff --git a/scripts/qapi.py b/scripts/qapi.py
> index 8f9c5666bd..5434987108 100644
> --- a/scripts/qapi.py
> +++ b/scripts/qapi.py
> @@ -1931,8 +1931,6 @@ def parse_command_line(extra_options='', 
> extra_long_options=[]):
>
>      output_dir = ''
>      prefix = ''
> -    do_c = False
> -    do_h = False
>      extra_opts = []
>
>      for oa in opts:
> @@ -1947,30 +1945,22 @@ def parse_command_line(extra_options='', 
> extra_long_options=[]):
>              prefix = a
>          elif o in ('-o', '--output-dir'):
>              output_dir = a + '/'
> -        elif o in ('-c', '--source'):
> -            do_c = True
> -        elif o in ('-h', '--header'):
> -            do_h = True
>          else:
>              extra_opts.append(oa)
>
> -    if not do_c and not do_h:
> -        do_c = True
> -        do_h = True
> -
>      if len(args) != 1:
>          print >>sys.stderr, "%s: need exactly one argument" % sys.argv[0]
>          sys.exit(1)
>      fname = args[0]
>
> -    return (fname, output_dir, do_c, do_h, prefix, extra_opts)
> +    return (fname, output_dir, prefix, extra_opts)
>
>  #
>  # Generate output files with boilerplate
>  #
>
>
> -def open_output(output_dir, do_c, do_h, prefix, c_file, h_file,
> +def open_output(output_dir, prefix, c_file, h_file,
>                  c_comment, h_comment):
>      guard = guardname(prefix + h_file)
>      c_file = output_dir + prefix + c_file
> @@ -1983,15 +1973,8 @@ def open_output(output_dir, do_c, do_h, prefix, 
> c_file, h_file,
>              if e.errno != errno.EEXIST:
>                  raise
>
> -    def maybe_open(really, name, opt):
> -        if really:
> -            return open(name, opt)
> -        else:
> -            import StringIO
> -            return StringIO.StringIO()
> -
> -    fdef = maybe_open(do_c, c_file, 'w')
> -    fdecl = maybe_open(do_h, h_file, 'w')
> +    fdef = open(c_file, 'w')
> +    fdecl = open(h_file, 'w')
>
>      fdef.write(mcgen('''
>  /* AUTOMATICALLY GENERATED, DO NOT MODIFY */
> --
> 2.13.6
>
>



-- 
Marc-André Lureau



reply via email to

[Prev in Thread] Current Thread [Next in Thread]