]> xenbits.xensource.com Git - libvirt.git/commitdiff
esx: Improve list usage detection in the generator
authorMatthias Bolte <matthias.bolte@googlemail.com>
Sun, 1 May 2011 09:31:55 +0000 (11:31 +0200)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Sat, 14 May 2011 10:00:46 +0000 (12:00 +0200)
Detect it based on usage as parameter and return type too.

src/esx/esx_vi_generator.py

index 8ac1249f4cb40bcb23c704c8aa7e47f3fbcbb9e2..70cf2ee5ec52e064a0d5308333d8ead1519dc4fa 100755 (executable)
@@ -1428,7 +1428,7 @@ additional_enum_features = { "ManagedEntityStatus"      : Enum.FEATURE__ANY_TYPE
                              "VirtualMachinePowerState" : Enum.FEATURE__ANY_TYPE }
 
 additional_object_features = { "AutoStartDefaults"          : Object.FEATURE__ANY_TYPE,
-                               "AutoStartPowerInfo"         : Object.FEATURE__ANY_TYPE | Object.FEATURE__LIST,
+                               "AutoStartPowerInfo"         : Object.FEATURE__ANY_TYPE,
                                "DatastoreHostMount"         : Object.FEATURE__DEEP_COPY | Object.FEATURE__LIST | Object.FEATURE__ANY_TYPE,
                                "DatastoreInfo"              : Object.FEATURE__ANY_TYPE | Object.FEATURE__DYNAMIC_CAST,
                                "FileInfo"                   : Object.FEATURE__DYNAMIC_CAST,
@@ -1437,12 +1437,9 @@ additional_object_features = { "AutoStartDefaults"          : Object.FEATURE__AN
                                "HostCpuIdInfo"              : Object.FEATURE__ANY_TYPE | Object.FEATURE__LIST,
                                "HostDatastoreBrowserSearchResults" : Object.FEATURE__LIST | Object.FEATURE__ANY_TYPE,
                                "ManagedObjectReference"     : Object.FEATURE__ANY_TYPE,
-                               "ObjectContent"              : Object.FEATURE__DEEP_COPY | Object.FEATURE__LIST,
-                               "PerfCounterInfo"            : Object.FEATURE__LIST,
-                               "PerfEntityMetric"           : Object.FEATURE__LIST | Object.FEATURE__DYNAMIC_CAST,
-                               "PerfQuerySpec"              : Object.FEATURE__LIST,
+                               "ObjectContent"              : Object.FEATURE__DEEP_COPY,
+                               "PerfEntityMetric"           : Object.FEATURE__DYNAMIC_CAST,
                                "PerfMetricIntSeries"        : Object.FEATURE__DYNAMIC_CAST,
-                               "PropertyFilterSpec"         : Object.FEATURE__LIST,
                                "ResourcePoolResourceUsage"  : Object.FEATURE__ANY_TYPE,
                                "SelectionSpec"              : Object.FEATURE__DYNAMIC_CAST,
                                "ServiceContent"             : Object.FEATURE__DESERIALIZE,
@@ -1541,6 +1538,15 @@ for method in methods_by_name.values():
         else:
             objects_by_name[parameter.type].features |= Object.FEATURE__SERIALIZE
 
+        # detect list usage
+        if parameter.occurrence == OCCURRENCE__REQUIRED_LIST or \
+           parameter.occurrence == OCCURRENCE__OPTIONAL_LIST:
+            if parameter.is_enum():
+                report_error("unsupported usage of enum '%s' as list in '%s'"
+                             % (parameter.type, method.name))
+            else:
+                objects_by_name[parameter.type].features |= Object.FEATURE__LIST
+
     # method return types must be deserializable
     if method.returns and method.returns.is_type_generated():
         if method.returns.is_enum():
@@ -1548,6 +1554,15 @@ for method in methods_by_name.values():
         else:
             objects_by_name[method.returns.type].features |= Object.FEATURE__DESERIALIZE
 
+        # detect list usage
+        if method.returns.occurrence == OCCURRENCE__REQUIRED_LIST or \
+           method.returns.occurrence == OCCURRENCE__OPTIONAL_LIST:
+            if method.returns.is_enum():
+                report_error("unsupported usage of enum '%s' as list in '%s'"
+                             % (method.returns.type, method.name))
+            else:
+                objects_by_name[method.returns.type].features |= Object.FEATURE__LIST
+
 
 
 for enum in enums_by_name.values():
@@ -1572,10 +1587,16 @@ for obj in objects_by_name.values():
 
     # detect list usage
     for property in obj.properties:
-        if (property.occurrence == OCCURRENCE__REQUIRED_LIST or \
-            property.occurrence == OCCURRENCE__OPTIONAL_LIST) and \
-           property.type not in predefined_objects:
-            objects_by_name[property.type].features |= Object.FEATURE__LIST
+        if not property.is_type_generated():
+            continue
+
+        if property.occurrence == OCCURRENCE__REQUIRED_LIST or \
+           property.occurrence == OCCURRENCE__OPTIONAL_LIST:
+            if property.is_enum():
+                report_error("unsupported usage of enum '%s' as list in '%s'"
+                             % (property.type, obj.type))
+            else:
+                objects_by_name[property.type].features |= Object.FEATURE__LIST
 
     # apply/remove additional features
     if obj.name in additional_object_features: