]> git.proxmox.com Git - qemu.git/commitdiff
Fix qapi code generation fix
authorAvi Kivity <avi@redhat.com>
Wed, 28 Dec 2011 10:26:58 +0000 (12:26 +0200)
committerAnthony Liguori <aliguori@us.ibm.com>
Thu, 12 Jan 2012 16:03:28 +0000 (10:03 -0600)
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>
Makefile
scripts/qapi-commands.py
scripts/qapi-types.py
scripts/qapi-visit.py

index 9ce8768ce89069499da71791620904169dbb4cc3..21f8c76597704894b904f40d69936ec0a6c61db9 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -177,7 +177,7 @@ qapi-dir := $(BUILD_DIR)/qapi-generated
 test-qmp-input-visitor.o test-qmp-output-visitor.o test-qmp-commands.o qemu-ga$(EXESUF): QEMU_CFLAGS += -I $(qapi-dir)
 qemu-ga$(EXESUF): LIBS = $(LIBS_QGA)
 
-gen-out-type = $(subst .,-,$@)
+gen-out-type = $(subst .,-,$(suffix $@))
 
 $(qapi-dir)/test-qapi-types.c $(qapi-dir)/test-qapi-types.h :\
 $(SRC_PATH)/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-types.py
index bd7b207122a88b1b043caf6d2818865feae066f3..3aabf61491f45b5c8f13ea74e1fb871bc69f503b 100644 (file)
@@ -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)
index ae644bc06ff9e9037d5c14e9289d1678ea65b515..b56225bdaa9e0e708c5a54b66342a9a1df939636 100644 (file)
@@ -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')
index e9d0584c789eadaec690d04deba695abd2a6cd4e..5160d83c4f4ab4b037b873ae08df36abd9f80508 100644 (file)
@@ -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')