esx: Change generated method parameter autobinding

Instead of specifying the type of the managed object directly specify
the ServiceContent member name. This way the mapping dictionary can be
removed.
This commit is contained in:
Matthias Bolte 2011-05-01 11:51:19 +02:00
parent 9cd16c0aa9
commit 1f6fc82bf3
2 changed files with 29 additions and 37 deletions

View File

@ -40,9 +40,9 @@
#
# The _this parameter can have a type attached to it:
#
# _this:<type>
# _this:<member>
#
# The <type> refers to one of the ServiceContent members. This make the
# The <member> refers to one of the ServiceContent members. This make the
# generator auto-bind _this to the corresponding ServiceContent member.
#
@ -782,7 +782,7 @@ end
method CopyVirtualDisk_Task returns ManagedObjectReference r
ManagedObjectReference _this:VirtualDiskManager r
ManagedObjectReference _this:virtualDiskManager r
String sourceName r
ManagedObjectReference sourceDatacenter o
String destName r
@ -793,7 +793,7 @@ end
method CreateFilter returns ManagedObjectReference r
ManagedObjectReference _this:PropertyCollector r
ManagedObjectReference _this:propertyCollector r
PropertyFilterSpec spec r
Boolean partialUpdates r
end
@ -809,7 +809,7 @@ end
method CreateVirtualDisk_Task returns ManagedObjectReference r
ManagedObjectReference _this:VirtualDiskManager r
ManagedObjectReference _this:virtualDiskManager r
String name r
ManagedObjectReference datacenter o
VirtualDiskSpec spec r
@ -817,7 +817,7 @@ end
method DeleteVirtualDisk_Task returns ManagedObjectReference r
ManagedObjectReference _this:VirtualDiskManager r
ManagedObjectReference _this:virtualDiskManager r
String name r
ManagedObjectReference datacenter o
end
@ -829,7 +829,7 @@ end
method FindByIp returns ManagedObjectReference o
ManagedObjectReference _this:SearchIndex r
ManagedObjectReference _this:searchIndex r
ManagedObjectReference datacenter o
String ip r
Boolean vmSearch r
@ -837,7 +837,7 @@ end
method FindByUuid returns ManagedObjectReference o
ManagedObjectReference _this:SearchIndex r
ManagedObjectReference _this:searchIndex r
ManagedObjectReference datacenter o
String uuid r
Boolean vmSearch r
@ -845,7 +845,7 @@ end
method Login returns UserSession r
ManagedObjectReference _this:SessionManager r
ManagedObjectReference _this:sessionManager r
String userName r
String password r
String locale o
@ -853,12 +853,12 @@ end
method Logout
ManagedObjectReference _this:SessionManager r
ManagedObjectReference _this:sessionManager r
end
method MakeDirectory
ManagedObjectReference _this:FileManager r
ManagedObjectReference _this:fileManager r
String name r
ManagedObjectReference datacenter o
Boolean createParentDirectories o
@ -886,7 +886,7 @@ end
method QueryAvailablePerfMetric returns PerfMetricId ol
ManagedObjectReference _this:PerformanceManager r
ManagedObjectReference _this:perfManager r
ManagedObjectReference entity r
DateTime beginTime o
DateTime endTime o
@ -895,19 +895,19 @@ end
method QueryPerf returns PerfEntityMetricBase ol
ManagedObjectReference _this:PerformanceManager r
ManagedObjectReference _this:perfManager r
PerfQuerySpec querySpec rl
end
method QueryPerfCounter returns PerfCounterInfo ol
ManagedObjectReference _this:PerformanceManager r
ManagedObjectReference _this:perfManager r
Int counterId rl
end
method QueryVirtualDiskUuid returns String r
ManagedObjectReference _this:VirtualDiskManager r
ManagedObjectReference _this:virtualDiskManager r
String name r
ManagedObjectReference datacenter o
end
@ -952,7 +952,7 @@ end
method RetrieveProperties returns ObjectContent ol
ManagedObjectReference _this:PropertyCollector r
ManagedObjectReference _this:propertyCollector r
PropertyFilterSpec specSet rl
end
@ -978,7 +978,7 @@ end
method SessionIsActive returns Boolean r
ManagedObjectReference _this:SessionManager r
ManagedObjectReference _this:sessionManager r
String sessionID r
String userName r
end
@ -1000,13 +1000,13 @@ end
method WaitForUpdates returns UpdateSet r
ManagedObjectReference _this:PropertyCollector r
ManagedObjectReference _this:propertyCollector r
String version o
end
method ZeroFillVirtualDisk_Task returns ManagedObjectReference r
ManagedObjectReference _this:VirtualDiskManager r
ManagedObjectReference _this:virtualDiskManager r
String name r
ManagedObjectReference datacenter o
end

View File

@ -38,14 +38,7 @@ valid_occurrences = [OCCURRENCE__REQUIRED_ITEM,
OCCURRENCE__OPTIONAL_LIST,
OCCURRENCE__IGNORED]
autobind_map = { "FileManager" : "fileManager",
"PerformanceManager" : "perfManager",
"PropertyCollector" : "propertyCollector",
"SearchIndex" : "searchIndex",
"SessionManager" : "sessionManager",
"VirtualDiskManager" : "virtualDiskManager" }
autobind_map_usage = set()
autobind_names = set()
@ -94,16 +87,16 @@ class Parameter(Member):
Member.__init__(self, type, occurrence)
if ':' in name and name.startswith("_this"):
self.name, self.autobind_type = name.split(":")
self.name, self.autobind_name = name.split(":")
else:
self.name = name
self.autobind_type = None
self.autobind_name = None
def generate_parameter(self, is_last = False, is_header = True, offset = 0):
if self.occurrence == OCCURRENCE__IGNORED:
raise ValueError("invalid function parameter occurrence value '%s'" % self.occurrence)
elif self.autobind_type is not None:
elif self.autobind_name is not None:
return ""
else:
string = " "
@ -193,7 +186,7 @@ class Method:
self.returns = returns
for parameter in parameters:
if parameter.autobind_type is None:
if parameter.autobind_name is None:
self.parameters.append(parameter)
else:
self.autobind_parameter = parameter
@ -227,8 +220,8 @@ class Method:
source += "ESX_VI__METHOD(%s," % self.name
if self.autobind_parameter is not None:
autobind_map_usage.add(self.autobind_parameter.autobind_type)
source += " %s,\n" % autobind_map[self.autobind_parameter.autobind_type]
autobind_names.add(self.autobind_parameter.autobind_name)
source += " %s,\n" % self.autobind_parameter.autobind_name
else:
source += " /* explicit _this */,\n"
@ -1785,11 +1778,10 @@ for name in names:
methods_header.write(methods_by_name[name].generate_header())
methods_source.write(methods_by_name[name].generate_source())
sorted_usage = list(autobind_map_usage)
sorted_usage.sort()
names = list(autobind_names)
names.sort()
for usage in sorted_usage:
name = autobind_map[usage]
for name in names:
string = aligned("#define ESX_VI__METHOD__PARAMETER__THIS__%s " % name, "\\\n", 78)
string += " ESX_VI__METHOD__PARAMETER__THIS_FROM_SERVICE(ManagedObjectReference, \\\n"
string += aligned("", "%s)\n\n\n\n" % name, 49)