]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
ESX: Fix DISPATCH_FREE generation code to free all extended objects
authorAta E Husain Bohra <ata.husain@hotmail.com>
Wed, 2 Jan 2013 06:22:28 +0000 (22:22 -0800)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Wed, 1 May 2013 12:14:09 +0000 (14:14 +0200)
Python code generator "generate_source" section that handles
code generation to "free" inherited objects needs to generate
DISPATCH_FREE calls for all extended_by objects.

src/esx/esx_vi_generator.py

index af4e7e8abec7d8b35d4dbae8edd30111cd501ce3..7130624ae6040f831bee127f3053e90663beed9d 100755 (executable)
@@ -4,6 +4,7 @@
 # esx_vi_generator.py: generates most of the SOAP type mapping code
 #
 # Copyright (C) 2010-2012 Matthias Bolte <matthias.bolte@googlemail.com>
+# Copyright (C) 2013 Ata E Husain Bohra <ata.husain@hotmail.com>
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -785,16 +786,14 @@ class Object(Type):
             source += "ESX_VI__TEMPLATE__DYNAMIC_FREE(%s,\n" % self.name
             source += "{\n"
 
-            for extended_by in self.extended_by:
-                source += "    ESX_VI__TEMPLATE__DISPATCH__FREE(%s)\n" \
-                          % extended_by
+            source += self.generate_dispatch('FREE')
 
             source += "},\n"
             source += "{\n"
 
             if self.features & Object.FEATURE__LIST:
                 if self.extends is not None:
-                    # avoid "dereferencing type-punned pointer will brea
+                    # avoid "dereferencing type-punned pointer will break
                     # strict-aliasing rules" warnings
                     source += "    esxVI_%s *next = (esxVI_%s *)item->_next;\n\n" \
                               % (self.extends, self.extends)
@@ -1004,6 +1003,26 @@ class ManagedObject(Type):
         return members
 
 
+    def generate_dispatch(self, suffix, is_first=True):
+        source = ""
+
+        if self.extended_by is not None:
+            if not is_first:
+                source += "\n"
+
+            source += "    /* %s */\n" % self.name
+
+            for extended_by in self.extended_by:
+                source += "    ESX_VI__TEMPLATE__DISPATCH__%s(%s)\n" \
+                          % (suffix, extended_by)
+
+            for extended_by in self.extended_by:
+                source += managed_objects_by_name[extended_by] \
+                          .generate_dispatch(suffix, False)
+
+        return source
+
+
     def generate_free_code(self, add_banner=False):
         source = ""
 
@@ -1220,13 +1239,12 @@ class ManagedObject(Type):
             source += "ESX_VI__TEMPLATE__DYNAMIC_FREE(%s,\n" % self.name
             source += "{\n"
 
-            for extended_by in self.extended_by:
-                source += "    ESX_VI__TEMPLATE__DISPATCH__FREE(%s)\n" % extended_by
+            source += self.generate_dispatch('FREE')
 
             source += "},\n"
             source += "{\n"
 
-            if self.features & Object.FEATURE__LIST:
+            if self.features & ManagedObject.FEATURE__LIST:
                 if self.extends is not None:
                     # avoid "dereferencing type-punned pointer will break
                     # strict-aliasing rules" warnings