mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
esx: Improve list usage detection in the generator
Detect it based on usage as parameter and return type too.
This commit is contained in:
parent
59f1f5f151
commit
35cdab71e4
@ -1428,7 +1428,7 @@ additional_enum_features = { "ManagedEntityStatus" : Enum.FEATURE__ANY_TYPE
|
|||||||
"VirtualMachinePowerState" : Enum.FEATURE__ANY_TYPE }
|
"VirtualMachinePowerState" : Enum.FEATURE__ANY_TYPE }
|
||||||
|
|
||||||
additional_object_features = { "AutoStartDefaults" : Object.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,
|
"DatastoreHostMount" : Object.FEATURE__DEEP_COPY | Object.FEATURE__LIST | Object.FEATURE__ANY_TYPE,
|
||||||
"DatastoreInfo" : Object.FEATURE__ANY_TYPE | Object.FEATURE__DYNAMIC_CAST,
|
"DatastoreInfo" : Object.FEATURE__ANY_TYPE | Object.FEATURE__DYNAMIC_CAST,
|
||||||
"FileInfo" : 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,
|
"HostCpuIdInfo" : Object.FEATURE__ANY_TYPE | Object.FEATURE__LIST,
|
||||||
"HostDatastoreBrowserSearchResults" : Object.FEATURE__LIST | Object.FEATURE__ANY_TYPE,
|
"HostDatastoreBrowserSearchResults" : Object.FEATURE__LIST | Object.FEATURE__ANY_TYPE,
|
||||||
"ManagedObjectReference" : Object.FEATURE__ANY_TYPE,
|
"ManagedObjectReference" : Object.FEATURE__ANY_TYPE,
|
||||||
"ObjectContent" : Object.FEATURE__DEEP_COPY | Object.FEATURE__LIST,
|
"ObjectContent" : Object.FEATURE__DEEP_COPY,
|
||||||
"PerfCounterInfo" : Object.FEATURE__LIST,
|
"PerfEntityMetric" : Object.FEATURE__DYNAMIC_CAST,
|
||||||
"PerfEntityMetric" : Object.FEATURE__LIST | Object.FEATURE__DYNAMIC_CAST,
|
|
||||||
"PerfQuerySpec" : Object.FEATURE__LIST,
|
|
||||||
"PerfMetricIntSeries" : Object.FEATURE__DYNAMIC_CAST,
|
"PerfMetricIntSeries" : Object.FEATURE__DYNAMIC_CAST,
|
||||||
"PropertyFilterSpec" : Object.FEATURE__LIST,
|
|
||||||
"ResourcePoolResourceUsage" : Object.FEATURE__ANY_TYPE,
|
"ResourcePoolResourceUsage" : Object.FEATURE__ANY_TYPE,
|
||||||
"SelectionSpec" : Object.FEATURE__DYNAMIC_CAST,
|
"SelectionSpec" : Object.FEATURE__DYNAMIC_CAST,
|
||||||
"ServiceContent" : Object.FEATURE__DESERIALIZE,
|
"ServiceContent" : Object.FEATURE__DESERIALIZE,
|
||||||
@ -1541,6 +1538,15 @@ for method in methods_by_name.values():
|
|||||||
else:
|
else:
|
||||||
objects_by_name[parameter.type].features |= Object.FEATURE__SERIALIZE
|
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
|
# method return types must be deserializable
|
||||||
if method.returns and method.returns.is_type_generated():
|
if method.returns and method.returns.is_type_generated():
|
||||||
if method.returns.is_enum():
|
if method.returns.is_enum():
|
||||||
@ -1548,6 +1554,15 @@ for method in methods_by_name.values():
|
|||||||
else:
|
else:
|
||||||
objects_by_name[method.returns.type].features |= Object.FEATURE__DESERIALIZE
|
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():
|
for enum in enums_by_name.values():
|
||||||
@ -1572,10 +1587,16 @@ for obj in objects_by_name.values():
|
|||||||
|
|
||||||
# detect list usage
|
# detect list usage
|
||||||
for property in obj.properties:
|
for property in obj.properties:
|
||||||
if (property.occurrence == OCCURRENCE__REQUIRED_LIST or \
|
if not property.is_type_generated():
|
||||||
property.occurrence == OCCURRENCE__OPTIONAL_LIST) and \
|
continue
|
||||||
property.type not in predefined_objects:
|
|
||||||
objects_by_name[property.type].features |= Object.FEATURE__LIST
|
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
|
# apply/remove additional features
|
||||||
if obj.name in additional_object_features:
|
if obj.name in additional_object_features:
|
||||||
|
Loading…
Reference in New Issue
Block a user