diff options
author | Avi Kivity <avi@redhat.com> | 2011-12-28 12:26:58 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2012-01-12 10:03:28 -0600 |
commit | 19bf7c87081835449d5683ecb0858255bf5a0546 (patch) | |
tree | e1512adf58be067fdb20a6b83ce0e5d03d8c2a98 /scripts | |
parent | 73a511decc9c87cbc1bac0012d990e4e74a648bf (diff) |
Fix qapi code generation fix
The fixes to qapi code generation had multiple bugs:
- the Null class used to drop output was missing some methods
- in some scripts it was never instantiated, leading to a None return,
which is missing even more methods
- the --source and --header options were swapped
Luckily, all those bugs were hidden by a makefile bug which caused the
old behaviour (with the race) to be invoked.
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/qapi-commands.py | 12 | ||||
-rw-r--r-- | scripts/qapi-types.py | 12 | ||||
-rw-r--r-- | scripts/qapi-visit.py | 12 |
3 files changed, 14 insertions, 22 deletions
diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py index bd7b207122..3aabf61491 100644 --- a/scripts/qapi-commands.py +++ b/scripts/qapi-commands.py @@ -399,9 +399,9 @@ for o, a in opts: elif o in ("-m", "--middle"): middle_mode = True elif o in ("-c", "--source"): - do_h = True - elif o in ("-h", "--header"): do_c = True + elif o in ("-h", "--header"): + do_h = True if not do_c and not do_h: do_c = True @@ -411,15 +411,11 @@ c_file = output_dir + prefix + c_file h_file = output_dir + prefix + h_file def maybe_open(really, name, opt): - class Null(object): - def write(self, str): - pass - def read(self): - return '' if really: return open(name, opt) else: - return Null() + import StringIO + return StringIO.StringIO() try: os.makedirs(output_dir) diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py index ae644bc06f..b56225bdaa 100644 --- a/scripts/qapi-types.py +++ b/scripts/qapi-types.py @@ -183,9 +183,9 @@ for o, a in opts: elif o in ("-o", "--output-dir"): output_dir = a + "/" elif o in ("-c", "--source"): - do_h = True - elif o in ("-h", "--header"): do_c = True + elif o in ("-h", "--header"): + do_h = True if not do_c and not do_h: do_c = True @@ -201,13 +201,11 @@ except os.error, e: raise def maybe_open(really, name, opt): - class Null(object): - def write(self, str): - pass - def read(self): - return '' 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') diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py index e9d0584c78..5160d83c4f 100644 --- a/scripts/qapi-visit.py +++ b/scripts/qapi-visit.py @@ -159,9 +159,9 @@ for o, a in opts: elif o in ("-o", "--output-dir"): output_dir = a + "/" elif o in ("-c", "--source"): - do_h = True - elif o in ("-h", "--header"): do_c = True + elif o in ("-h", "--header"): + do_h = True if not do_c and not do_h: do_c = True @@ -177,13 +177,11 @@ except os.error, e: raise def maybe_open(really, name, opt): - class Null(object): - def write(self, str): - pass - def read(self): - return '' 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') |