[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 11/32] qapi: Drop the options to generate only .
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [RFC PATCH 11/32] qapi: Drop the options to generate only .c or .h |
Date: |
Mon, 2 Oct 2017 17:25:31 +0200 |
Signed-off-by: Markus Armbruster <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
- Re: [Qemu-devel] [RFC PATCH 19/32] qapi: Accept double-quoted strings, (continued)
[Qemu-devel] [RFC PATCH 12/32] qapi: Use argparse to parse command line arguments, Markus Armbruster, 2017/10/02
[Qemu-devel] [RFC PATCH 17/32] qapi: Fix simple union lowering with multiple schemas, Markus Armbruster, 2017/10/02
[Qemu-devel] [RFC PATCH 15/32] tests/qapi-schema: Improve simple union coverage, Markus Armbruster, 2017/10/02
[Qemu-devel] [RFC PATCH 11/32] qapi: Drop the options to generate only .c or .h,
Markus Armbruster <=
[Qemu-devel] [RFC PATCH 07/32] qapi: Drop superfluous allow_optional=True, Markus Armbruster, 2017/10/02
[Qemu-devel] [RFC PATCH 03/32] qapi2texi: Fix for examples containing '@', Markus Armbruster, 2017/10/02
[Qemu-devel] [RFC PATCH 26/32] qapi2texi: Include command line options information, Markus Armbruster, 2017/10/02
[Qemu-devel] [RFC PATCH 27/32] os-posix: Drop misleading comment, Markus Armbruster, 2017/10/02
[Qemu-devel] [RFC PATCH 14/32] qapi: Rework generated code for built-in types, Markus Armbruster, 2017/10/02