1 | <xsl:stylesheet version = '1.0'
|
---|
2 | xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
|
---|
3 | xmlns:vbox="http://www.virtualbox.org/">
|
---|
4 |
|
---|
5 | <!--
|
---|
6 |
|
---|
7 | websrv-python.xsl:
|
---|
8 | XSLT stylesheet that generates VirtualBox_services.py from
|
---|
9 | VirtualBox.xidl. This Python file represents our
|
---|
10 | web service API. Depends on WSDL file for actual SOAP bindings.
|
---|
11 |
|
---|
12 | Copyright (C) 2008-2010 Oracle Corporation
|
---|
13 |
|
---|
14 | This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
15 | available from http://www.virtualbox.org. This file is free software;
|
---|
16 | you can redistribute it and/or modify it under the terms of the GNU
|
---|
17 | General Public License (GPL) as published by the Free Software
|
---|
18 | Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
19 | VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
20 | hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
21 | -->
|
---|
22 |
|
---|
23 |
|
---|
24 | <xsl:output
|
---|
25 | method="text"
|
---|
26 | version="1.0"
|
---|
27 | encoding="utf-8"
|
---|
28 | indent="no"/>
|
---|
29 |
|
---|
30 | <xsl:include href="websrv-shared.inc.xsl" />
|
---|
31 |
|
---|
32 | <xsl:variable name="G_setSuppressedInterfaces"
|
---|
33 | select="//interface[@wsmap='suppress']" />
|
---|
34 |
|
---|
35 | <xsl:template name="emitConvertedType">
|
---|
36 | <xsl:param name="ifname" />
|
---|
37 | <xsl:param name="methodname" />
|
---|
38 | <xsl:param name="type" />
|
---|
39 | <xsl:choose>
|
---|
40 | <xsl:when test="$type='wstring'">String</xsl:when>
|
---|
41 | <xsl:when test="$type='uuid'">String</xsl:when>
|
---|
42 | <xsl:when test="$type='boolean'">Boolean</xsl:when>
|
---|
43 | <xsl:when test="$type='unsigned long'">UnsignedInt</xsl:when>
|
---|
44 | <xsl:when test="$type='double'">Double</xsl:when>
|
---|
45 | <xsl:when test="$type='float'">Float</xsl:when>
|
---|
46 | <xsl:when test="$type='long'">Int</xsl:when>
|
---|
47 | <xsl:when test="$type='long long'">Long</xsl:when>
|
---|
48 | <xsl:when test="$type='short'">Short</xsl:when>
|
---|
49 | <xsl:when test="$type='unsigned short'">UnsignedShort</xsl:when>
|
---|
50 | <xsl:when test="$type='unsigned long long'">UnsignedLong</xsl:when>
|
---|
51 | <xsl:when test="$type='result'">UnsignedInt</xsl:when>
|
---|
52 | <xsl:when test="$type='octet'">Octet</xsl:when>
|
---|
53 | <xsl:when test="$type='$unknown'">IUnknown</xsl:when>
|
---|
54 | <xsl:when test="$type='$dispatched'">IUnknown</xsl:when>
|
---|
55 | <xsl:otherwise><xsl:value-of select="$type" /></xsl:otherwise>
|
---|
56 | </xsl:choose>
|
---|
57 | </xsl:template>
|
---|
58 |
|
---|
59 | <xsl:template name="emitOutParam">
|
---|
60 | <xsl:param name="ifname" />
|
---|
61 | <xsl:param name="methodname" />
|
---|
62 | <xsl:param name="type" />
|
---|
63 | <xsl:param name="value" />
|
---|
64 | <xsl:param name="safearray" />
|
---|
65 |
|
---|
66 | <xsl:call-template name="emitConvertedType">
|
---|
67 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
68 | <xsl:with-param name="methodname" select="$methodname" />
|
---|
69 | <xsl:with-param name="type" select="$type" />
|
---|
70 | </xsl:call-template>
|
---|
71 | <xsl:text>(</xsl:text>
|
---|
72 | <xsl:text>self.mgr,</xsl:text>
|
---|
73 | <xsl:value-of select="$value"/>
|
---|
74 | <xsl:if test="$safearray='yes'">
|
---|
75 | <xsl:value-of select="', True'"/>
|
---|
76 | </xsl:if>
|
---|
77 | <xsl:text>)</xsl:text>
|
---|
78 | </xsl:template>
|
---|
79 |
|
---|
80 |
|
---|
81 | <xsl:template name="emitGetAttribute">
|
---|
82 | <xsl:param name="ifname" />
|
---|
83 | <xsl:param name="attrname" />
|
---|
84 | <xsl:param name="attrtype" />
|
---|
85 | <xsl:param name="attrsafearray" />
|
---|
86 | <xsl:variable name="fname"><xsl:call-template name="makeGetterName"><xsl:with-param name="attrname" select="$attrname"/></xsl:call-template> </xsl:variable>
|
---|
87 | def <xsl:value-of select="$fname"/>(self):
|
---|
88 | req=<xsl:value-of select="$ifname"/>_<xsl:value-of select="$fname"/>RequestMsg()
|
---|
89 | req._this=self.handle
|
---|
90 | val=self.mgr.getPort().<xsl:value-of select="$ifname"/>_<xsl:value-of select="$fname"/>(req)
|
---|
91 | <xsl:text>return </xsl:text>
|
---|
92 | <xsl:call-template name="emitOutParam">
|
---|
93 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
94 | <xsl:with-param name="methodname" select="@name" />
|
---|
95 | <xsl:with-param name="type" select="$attrtype" />
|
---|
96 | <xsl:with-param name="value" select="concat('val.','_returnval')" />
|
---|
97 | <xsl:with-param name="safearray" select="@safearray"/>
|
---|
98 | </xsl:call-template>
|
---|
99 | </xsl:template>
|
---|
100 |
|
---|
101 | <xsl:template name="emitSetAttribute">
|
---|
102 | <xsl:param name="ifname" />
|
---|
103 | <xsl:param name="attrname" />
|
---|
104 | <xsl:param name="attrtype" />
|
---|
105 | <xsl:param name="attrsafearray" />
|
---|
106 | <xsl:variable name="fname"><xsl:call-template name="makeSetterName"><xsl:with-param name="attrname" select="$attrname"/></xsl:call-template> </xsl:variable>
|
---|
107 | def <xsl:value-of select="$fname"/>(self, value):
|
---|
108 | req=<xsl:value-of select="$ifname"/>_<xsl:value-of select="$fname"/>RequestMsg()
|
---|
109 | req._this=self.handle
|
---|
110 | if type(value) in [int, bool, basestring, str]:
|
---|
111 | req._<xsl:value-of select="$attrname"/> = value
|
---|
112 | else:
|
---|
113 | req._<xsl:value-of select="$attrname"/> = value.handle
|
---|
114 | self.mgr.getPort().<xsl:value-of select="$ifname"/>_<xsl:value-of select="$fname"/>(req)
|
---|
115 | </xsl:template>
|
---|
116 |
|
---|
117 | <xsl:template name="collection">
|
---|
118 | <xsl:variable name="cname"><xsl:value-of select="@name" /></xsl:variable>
|
---|
119 | <xsl:variable name="ename"><xsl:value-of select="@type" /></xsl:variable>
|
---|
120 | class <xsl:value-of select="$cname"/>:
|
---|
121 | def __init__(self, mgr, array):
|
---|
122 | self.array = array
|
---|
123 | self.mgr = mgr
|
---|
124 |
|
---|
125 | def __next(self):
|
---|
126 | return self.array.__next()
|
---|
127 |
|
---|
128 | def __size(self):
|
---|
129 | return self.array._array.__size()
|
---|
130 |
|
---|
131 | def __len__(self):
|
---|
132 | return self.array._array.__len__()
|
---|
133 |
|
---|
134 | def __getitem__(self, index):
|
---|
135 | return <xsl:value-of select="$ename"/>(self.mgr, self.array._array[index])
|
---|
136 |
|
---|
137 | </xsl:template>
|
---|
138 |
|
---|
139 |
|
---|
140 | <xsl:template name="computeExtends">
|
---|
141 | <xsl:param name="base" />
|
---|
142 |
|
---|
143 | <xsl:choose>
|
---|
144 | <xsl:when test="($base = '$unknown') or ($base = '$dispatched')">
|
---|
145 | <xsl:value-of select="'IUnknown'"/>
|
---|
146 | </xsl:when>
|
---|
147 | <xsl:when test="($base = '$errorinfo') ">
|
---|
148 | <xsl:value-of select="'IUnknown'"/>
|
---|
149 | </xsl:when>
|
---|
150 | <xsl:otherwise>
|
---|
151 | <xsl:value-of select="$base"/>
|
---|
152 | </xsl:otherwise>
|
---|
153 | </xsl:choose>
|
---|
154 | </xsl:template>
|
---|
155 |
|
---|
156 | <xsl:template name="interface">
|
---|
157 | <xsl:variable name="base">
|
---|
158 | <xsl:call-template name="computeExtends">
|
---|
159 | <xsl:with-param name="base" select="@extends" />
|
---|
160 | </xsl:call-template>
|
---|
161 | </xsl:variable>
|
---|
162 | <xsl:variable name="ifname"><xsl:value-of select="@name" /></xsl:variable>
|
---|
163 |
|
---|
164 | class <xsl:value-of select="$ifname"/>(<xsl:value-of select="$base" />):
|
---|
165 | def __init__(self, mgr, handle, isarray = False):
|
---|
166 | self.mgr = mgr
|
---|
167 | if handle is None:
|
---|
168 | raise Exception("bad handle: "+str(handle))
|
---|
169 | self.handle = handle
|
---|
170 | self.isarray = isarray
|
---|
171 | <!--
|
---|
172 | This doesn't work now
|
---|
173 | mgr.register(handle)
|
---|
174 |
|
---|
175 | def __del__(self):
|
---|
176 | mgr.unregister(self.handle)
|
---|
177 | -->
|
---|
178 | def releaseRemote(self):
|
---|
179 | try:
|
---|
180 | req=IManagedObjectRef_releaseRequestMsg()
|
---|
181 | req._this=handle
|
---|
182 | self.mgr.getPort().IManagedObjectRef_release(req)
|
---|
183 | except:
|
---|
184 | pass
|
---|
185 |
|
---|
186 | def __next(self):
|
---|
187 | if self.isarray:
|
---|
188 | return self.handle.__next()
|
---|
189 | raise TypeError, "iteration over non-sequence"
|
---|
190 |
|
---|
191 | def __size(self):
|
---|
192 | if self.isarray:
|
---|
193 | return self.handle.__size()
|
---|
194 | raise TypeError, "iteration over non-sequence"
|
---|
195 |
|
---|
196 | def __len__(self):
|
---|
197 | if self.isarray:
|
---|
198 | return self.handle.__len__()
|
---|
199 | raise TypeError, "iteration over non-sequence"
|
---|
200 |
|
---|
201 | def __getitem__(self, index):
|
---|
202 | if self.isarray:
|
---|
203 | return <xsl:value-of select="$ifname" />(self.mgr, self.handle[index])
|
---|
204 | raise TypeError, "iteration over non-sequence"
|
---|
205 |
|
---|
206 | def __str__(self):
|
---|
207 | return self.handle
|
---|
208 |
|
---|
209 | def isValid(self):
|
---|
210 | return self.handle != None and self.handle != ''
|
---|
211 |
|
---|
212 | def __getattr__(self,name):
|
---|
213 | hndl = <xsl:value-of select="$ifname" />._Attrs_.get(name, None)
|
---|
214 | if hndl != None:
|
---|
215 | if hndl[0] != None:
|
---|
216 | return hndl[0](self)
|
---|
217 | else:
|
---|
218 | raise AttributeError
|
---|
219 | else:
|
---|
220 | return <xsl:value-of select="$base" />.__getattr__(self, name)
|
---|
221 |
|
---|
222 | def __setattr__(self, name, val):
|
---|
223 | hndl = <xsl:value-of select="$ifname" />._Attrs_.get(name, None)
|
---|
224 | if (hndl != None and hndl[1] != None):
|
---|
225 | hndl[1](self,val)
|
---|
226 | else:
|
---|
227 | self.__dict__[name] = val
|
---|
228 |
|
---|
229 | <xsl:for-each select="method">
|
---|
230 | <xsl:call-template name="method"/>
|
---|
231 | </xsl:for-each>
|
---|
232 |
|
---|
233 | <xsl:for-each select="attribute">
|
---|
234 | <xsl:variable name="attrname"><xsl:value-of select="@name" /></xsl:variable>
|
---|
235 | <xsl:variable name="attrtype"><xsl:value-of select="@type" /></xsl:variable>
|
---|
236 | <xsl:variable name="attrreadonly"><xsl:value-of select="@readonly" /></xsl:variable>
|
---|
237 | <!-- skip this attribute if it has parameters of a type that has wsmap="suppress" -->
|
---|
238 | <xsl:choose>
|
---|
239 | <xsl:when test="( $attrtype=($G_setSuppressedInterfaces/@name) )">
|
---|
240 | <xsl:comment><xsl:value-of select="concat('skipping attribute ', $attrtype, ' for it is of a suppressed type')" /></xsl:comment>
|
---|
241 | </xsl:when>
|
---|
242 | <xsl:otherwise>
|
---|
243 | <xsl:choose>
|
---|
244 | <xsl:when test="@readonly='yes'">
|
---|
245 | <xsl:comment> readonly attribute <xsl:copy-of select="$ifname" />::<xsl:copy-of select="$attrname" /> </xsl:comment>
|
---|
246 | </xsl:when>
|
---|
247 | <xsl:otherwise>
|
---|
248 | <xsl:comment> read/write attribute <xsl:copy-of select="$ifname" />::<xsl:copy-of select="$attrname" /> </xsl:comment>
|
---|
249 | </xsl:otherwise>
|
---|
250 | </xsl:choose>
|
---|
251 | <!-- aa) get method: emit request and result -->
|
---|
252 | <xsl:call-template name="emitGetAttribute">
|
---|
253 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
254 | <xsl:with-param name="attrname" select="$attrname" />
|
---|
255 | <xsl:with-param name="attrtype" select="$attrtype" />
|
---|
256 | </xsl:call-template>
|
---|
257 | <!-- bb) emit a set method if the attribute is read/write -->
|
---|
258 | <xsl:if test="not($attrreadonly='yes')">
|
---|
259 | <xsl:call-template name="emitSetAttribute">
|
---|
260 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
261 | <xsl:with-param name="attrname" select="$attrname" />
|
---|
262 | <xsl:with-param name="attrtype" select="$attrtype" />
|
---|
263 | </xsl:call-template>
|
---|
264 | </xsl:if>
|
---|
265 | </xsl:otherwise>
|
---|
266 | </xsl:choose>
|
---|
267 | </xsl:for-each>
|
---|
268 |
|
---|
269 |
|
---|
270 | _Attrs_=<xsl:text>{</xsl:text>
|
---|
271 | <xsl:for-each select="attribute">
|
---|
272 | <xsl:if test="not( @type=($G_setSuppressedInterfaces/@name) )">
|
---|
273 | <xsl:text> </xsl:text>'<xsl:value-of select="@name"/>'<xsl:text>:[</xsl:text>
|
---|
274 | <xsl:call-template name="makeGetterName">
|
---|
275 | <xsl:with-param name="attrname" select="@name"/>
|
---|
276 | </xsl:call-template>
|
---|
277 | <xsl:text>,</xsl:text>
|
---|
278 | <xsl:choose>
|
---|
279 | <xsl:when test="@readonly='yes'">
|
---|
280 | <xsl:text>None</xsl:text>
|
---|
281 | </xsl:when>
|
---|
282 | <xsl:otherwise>
|
---|
283 | <xsl:call-template name="makeSetterName">
|
---|
284 | <xsl:with-param name="attrname" select="@name"/>
|
---|
285 | </xsl:call-template>,
|
---|
286 | </xsl:otherwise>
|
---|
287 | </xsl:choose>
|
---|
288 | <xsl:text>]</xsl:text>
|
---|
289 | <xsl:if test="not(position()=last())"><xsl:text>, </xsl:text></xsl:if>
|
---|
290 | </xsl:if>
|
---|
291 | </xsl:for-each>
|
---|
292 | <xsl:text>}</xsl:text>
|
---|
293 | </xsl:template>
|
---|
294 |
|
---|
295 | <xsl:template name="interfacestruct">
|
---|
296 | <xsl:variable name="ifname"><xsl:value-of select="@name" /></xsl:variable>
|
---|
297 | class <xsl:value-of select="$ifname"/>:
|
---|
298 | def __init__(self, mgr, handle, isarray = False):
|
---|
299 | self.mgr = mgr
|
---|
300 | self.isarray = isarray
|
---|
301 | if isarray:
|
---|
302 | self.handle = handle
|
---|
303 | else:
|
---|
304 | <xsl:for-each select="attribute">
|
---|
305 | self.<xsl:value-of select="@name"/> = <xsl:call-template name="emitConvertedType">
|
---|
306 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
307 | <xsl:with-param name="methodname" select="''" />
|
---|
308 | <xsl:with-param name="type" select="@type" />
|
---|
309 | </xsl:call-template>(self.mgr, handle._<xsl:value-of select="@name"/>)
|
---|
310 | </xsl:for-each>
|
---|
311 | pass
|
---|
312 |
|
---|
313 | <!-- also do getters/setters -->
|
---|
314 | <xsl:for-each select="attribute">
|
---|
315 | def <xsl:call-template name="makeGetterName"><xsl:with-param name="attrname" select="@name"/></xsl:call-template>(self):
|
---|
316 | return self.<xsl:value-of select="@name"/>
|
---|
317 |
|
---|
318 | def <xsl:call-template name="makeSetterName"><xsl:with-param name="attrname" select="@name"/></xsl:call-template>(self):
|
---|
319 | raise Error, 'setters not supported'
|
---|
320 | </xsl:for-each>
|
---|
321 |
|
---|
322 | def __next(self):
|
---|
323 | if self.isarray:
|
---|
324 | return self.handle.__next()
|
---|
325 | raise TypeError, "iteration over non-sequence"
|
---|
326 |
|
---|
327 | def __size(self):
|
---|
328 | if self.isarray:
|
---|
329 | return self.handle.__size()
|
---|
330 | raise TypeError, "iteration over non-sequence"
|
---|
331 |
|
---|
332 | def __len__(self):
|
---|
333 | if self.isarray:
|
---|
334 | return self.handle.__len__()
|
---|
335 | raise TypeError, "iteration over non-sequence"
|
---|
336 |
|
---|
337 | def __getitem__(self, index):
|
---|
338 | if self.isarray:
|
---|
339 | return <xsl:value-of select="$ifname" />(self.mgr, self.handle[index])
|
---|
340 | raise TypeError, "iteration over non-sequence"
|
---|
341 |
|
---|
342 | </xsl:template>
|
---|
343 |
|
---|
344 | <xsl:template name="genreq">
|
---|
345 | <xsl:text>req=</xsl:text><xsl:value-of select="../@name"/>_<xsl:value-of select="@name"/>RequestMsg()
|
---|
346 | req._this=self.handle
|
---|
347 | <xsl:for-each select="param[@dir='in']">
|
---|
348 | req._<xsl:value-of select="@name" />=_arg_<xsl:value-of select="@name" />
|
---|
349 | </xsl:for-each>
|
---|
350 | val=self.mgr.getPort().<xsl:value-of select="../@name"/>_<xsl:value-of select="@name"/>(req)
|
---|
351 | <!-- return needs to be the first one -->
|
---|
352 | return <xsl:for-each select="param[@dir='return']">
|
---|
353 | <xsl:call-template name="emitOutParam">
|
---|
354 | <xsl:with-param name="ifname" select="../@name" />
|
---|
355 | <xsl:with-param name="methodname" select="@name" />
|
---|
356 | <xsl:with-param name="type" select="@type" />
|
---|
357 | <xsl:with-param name="value" select="concat('val.','_returnval')" />
|
---|
358 | <xsl:with-param name="safearray" select="@safearray"/>
|
---|
359 | </xsl:call-template>
|
---|
360 | <xsl:if test="../param[@dir='out']">
|
---|
361 | <xsl:text>, </xsl:text>
|
---|
362 | </xsl:if>
|
---|
363 | </xsl:for-each>
|
---|
364 | <xsl:for-each select="param[@dir='out']">
|
---|
365 | <xsl:if test="not(position()=1)">
|
---|
366 | <xsl:text>, </xsl:text>
|
---|
367 | </xsl:if>
|
---|
368 | <xsl:call-template name="emitOutParam">
|
---|
369 | <xsl:with-param name="ifname" select="../@name" />
|
---|
370 | <xsl:with-param name="methodname" select="@name" />
|
---|
371 | <xsl:with-param name="type" select="@type" />
|
---|
372 | <xsl:with-param name="value" select="concat('val._',@name)" />
|
---|
373 | <xsl:with-param name="safearray" select="@safearray"/>
|
---|
374 | </xsl:call-template>
|
---|
375 | </xsl:for-each>
|
---|
376 | <xsl:text> </xsl:text>
|
---|
377 | </xsl:template>
|
---|
378 |
|
---|
379 | <xsl:template name="method" >
|
---|
380 | def <xsl:value-of select="@name"/><xsl:text>(self</xsl:text>
|
---|
381 | <xsl:for-each select="param[@dir='in']">
|
---|
382 | <xsl:text>, </xsl:text>
|
---|
383 | <xsl:value-of select="concat('_arg_',@name)"/>
|
---|
384 | </xsl:for-each><xsl:text>): </xsl:text>
|
---|
385 | <xsl:call-template name="genreq"/>
|
---|
386 | </xsl:template>
|
---|
387 |
|
---|
388 | <xsl:template name="makeConstantName" >
|
---|
389 | <xsl:choose>
|
---|
390 | <!-- special case for reserved word, maybe will need more in the future -->
|
---|
391 | <xsl:when test="@name='None'">
|
---|
392 | <xsl:text>_None</xsl:text>
|
---|
393 | </xsl:when>
|
---|
394 | <xsl:otherwise>
|
---|
395 | <xsl:value-of select="@name"/>
|
---|
396 | </xsl:otherwise>
|
---|
397 | </xsl:choose>
|
---|
398 | </xsl:template>
|
---|
399 |
|
---|
400 | <xsl:template name="enum">
|
---|
401 | class <xsl:value-of select="@name"/>:
|
---|
402 | def __init__(self,mgr,handle):
|
---|
403 | self.mgr=mgr
|
---|
404 | if isinstance(handle,basestring):
|
---|
405 | self.handle=<xsl:value-of select="@name"/>._ValueMap[handle]
|
---|
406 | else:
|
---|
407 | self.handle=handle
|
---|
408 |
|
---|
409 | def __eq__(self,other):
|
---|
410 | if isinstance(other,<xsl:value-of select="@name"/>):
|
---|
411 | return self.handle == other.handle
|
---|
412 | if isinstance(other,int):
|
---|
413 | return self.handle == other
|
---|
414 | if isinstance(other,basestring):
|
---|
415 | return str(self) == other
|
---|
416 | return False
|
---|
417 |
|
---|
418 | def __ne__(self,other):
|
---|
419 | if isinstance(other,<xsl:value-of select="@name"/>):
|
---|
420 | return self.handle != other.handle
|
---|
421 | if isinstance(other,int):
|
---|
422 | return self.handle != other
|
---|
423 | if isinstance(other,basestring):
|
---|
424 | return str(self) != other
|
---|
425 | return True
|
---|
426 |
|
---|
427 | def __str__(self):
|
---|
428 | return <xsl:value-of select="@name"/>._NameMap[self.handle]
|
---|
429 |
|
---|
430 | def __int__(self):
|
---|
431 | return self.handle
|
---|
432 |
|
---|
433 | _NameMap={<xsl:for-each select="const">
|
---|
434 | <xsl:value-of select="@value"/>:'<xsl:value-of select="@name"/>'<xsl:if test="not(position()=last())">,</xsl:if>
|
---|
435 | </xsl:for-each>}
|
---|
436 | _ValueMap={<xsl:for-each select="const">
|
---|
437 | '<xsl:value-of select="@name"/>':<xsl:value-of select="@value"/><xsl:if test="not(position()=last())">,</xsl:if>
|
---|
438 | </xsl:for-each>}
|
---|
439 |
|
---|
440 | <xsl:for-each select="const"><xsl:text> </xsl:text><xsl:call-template name="makeConstantName"><xsl:with-param name="name" select="@name"/></xsl:call-template>=<xsl:value-of select="@value"/><xsl:text>
</xsl:text>
|
---|
441 | </xsl:for-each>
|
---|
442 | </xsl:template>
|
---|
443 |
|
---|
444 | <xsl:template match="/">
|
---|
445 | <xsl:text># Copyright (C) 2008-2010 Oracle Corporation
|
---|
446 | #
|
---|
447 | # This file is part of a free software library; you can redistribute
|
---|
448 | # it and/or modify it under the terms of the GNU Lesser General
|
---|
449 | # Public License version 2.1 as published by the Free Software
|
---|
450 | # Foundation and shipped in the "COPYING.LIB" file with this library.
|
---|
451 | # The library is distributed in the hope that it will be useful,
|
---|
452 | # but WITHOUT ANY WARRANTY of any kind.
|
---|
453 | #
|
---|
454 | # Oracle LGPL Disclaimer: For the avoidance of doubt, except that if
|
---|
455 | # any license choice other than GPL or LGPL is available it will
|
---|
456 | # apply instead, Oracle elects to use only the Lesser General Public
|
---|
457 | # License version 2.1 (LGPLv2) at this time for any software where
|
---|
458 | # a choice of LGPL license versions is made available with the
|
---|
459 | # language indicating that LGPLv2 or any later version may be used,
|
---|
460 | # or where a choice of which version of the LGPL is applied is
|
---|
461 | # otherwise unspecified.
|
---|
462 | #
|
---|
463 | # This file is autogenerated from VirtualBox.xidl, DO NOT EDIT!
|
---|
464 | #
|
---|
465 | from VirtualBox_services import *
|
---|
466 |
|
---|
467 | class ManagedManager:
|
---|
468 | def __init__(self):
|
---|
469 | self.map = {}
|
---|
470 |
|
---|
471 | def register(self,handle):
|
---|
472 | if handle == None:
|
---|
473 | return
|
---|
474 | c = self.map.get(handle,0)
|
---|
475 | c = c + 1
|
---|
476 | self.map[handle]=c
|
---|
477 |
|
---|
478 | def unregister(self,handle):
|
---|
479 | if handle == None:
|
---|
480 | return
|
---|
481 | c = self.map.get(handle,-1)
|
---|
482 | if c == -1:
|
---|
483 | raise Error, 'wrong refcount'
|
---|
484 | c = c - 1
|
---|
485 | if c == 0:
|
---|
486 | try:
|
---|
487 | req=IManagedObjectRef_releaseRequestMsg()
|
---|
488 | req._this=handle
|
---|
489 | self.mgr.getPort().IManagedObjectRef_release(req)
|
---|
490 | except:
|
---|
491 | pass
|
---|
492 | self.map[handle] = -1
|
---|
493 | else:
|
---|
494 | self.map[handle] = c
|
---|
495 |
|
---|
496 | class String:
|
---|
497 | def __init__(self, mgr, handle, isarray = False):
|
---|
498 | self.handle = handle
|
---|
499 | self.mgr = mgr
|
---|
500 | self.isarray = isarray
|
---|
501 |
|
---|
502 | def __next(self):
|
---|
503 | if self.isarray:
|
---|
504 | return self.handle.__next()
|
---|
505 | raise TypeError, "iteration over non-sequence"
|
---|
506 |
|
---|
507 | def __size(self):
|
---|
508 | if self.isarray:
|
---|
509 | return self.handle.__size()
|
---|
510 | raise TypeError, "iteration over non-sequence"
|
---|
511 |
|
---|
512 | def __len__(self):
|
---|
513 | if self.isarray:
|
---|
514 | return self.handle.__len__()
|
---|
515 | raise TypeError, "iteration over non-sequence"
|
---|
516 |
|
---|
517 | def __getitem__(self, index):
|
---|
518 | if self.isarray:
|
---|
519 | return String(self.mgr, self.handle[index])
|
---|
520 | raise TypeError, "iteration over non-sequence"
|
---|
521 |
|
---|
522 | def __str__(self):
|
---|
523 | return str(self.handle)
|
---|
524 |
|
---|
525 | def __eq__(self,other):
|
---|
526 | if self.isarray:
|
---|
527 | return isinstance(other,String) and self.handle == other.handle
|
---|
528 | if isinstance(other,String):
|
---|
529 | return self.handle == other.handle
|
---|
530 | if isinstance(other,basestring):
|
---|
531 | return self.handle == other
|
---|
532 | return False
|
---|
533 |
|
---|
534 | def __ne__(self,other):
|
---|
535 | if self.isarray:
|
---|
536 | return not isinstance(other,String) or self.handle != other.handle
|
---|
537 | if isinstance(other,String):
|
---|
538 | return self.handle != other.handle
|
---|
539 | if isinstance(other,basestring):
|
---|
540 | return self.handle != other
|
---|
541 | return True
|
---|
542 |
|
---|
543 | def __add__(self,other):
|
---|
544 | return str(self.handle)+str(other)
|
---|
545 |
|
---|
546 |
|
---|
547 | class Boolean:
|
---|
548 | def __init__(self, mgr, handle, isarray = False):
|
---|
549 | self.handle = handle
|
---|
550 | if self.handle == "false":
|
---|
551 | self.handle = None
|
---|
552 | self.mgr = mgr
|
---|
553 | self.isarray = isarray
|
---|
554 |
|
---|
555 | def __str__(self):
|
---|
556 | if self.handle:
|
---|
557 | return "true"
|
---|
558 | else:
|
---|
559 | return "false"
|
---|
560 |
|
---|
561 | def __eq__(self,other):
|
---|
562 | if isinstance(other,Bool):
|
---|
563 | return self.handle == other.value
|
---|
564 | if isinstance(other,bool):
|
---|
565 | return self.handle == other
|
---|
566 | return False
|
---|
567 |
|
---|
568 | def __ne__(self,other):
|
---|
569 | if isinstance(other,Bool):
|
---|
570 | return self.handle != other.handle
|
---|
571 | if isinstance(other,bool):
|
---|
572 | return self.handle != other
|
---|
573 | return True
|
---|
574 |
|
---|
575 | def __int__(self):
|
---|
576 | if self.handle:
|
---|
577 | return 1
|
---|
578 | else:
|
---|
579 | return 0
|
---|
580 |
|
---|
581 | def __long__(self):
|
---|
582 | if self.handle:
|
---|
583 | return 1
|
---|
584 | else:
|
---|
585 | return 0
|
---|
586 |
|
---|
587 | def __nonzero__(self):
|
---|
588 | if self.handle:
|
---|
589 | return True
|
---|
590 | else:
|
---|
591 | return False
|
---|
592 |
|
---|
593 | def __next(self):
|
---|
594 | if self.isarray:
|
---|
595 | return self.handle.__next()
|
---|
596 | raise TypeError, "iteration over non-sequence"
|
---|
597 |
|
---|
598 | def __size(self):
|
---|
599 | if self.isarray:
|
---|
600 | return self.handle.__size()
|
---|
601 | raise TypeError, "iteration over non-sequence"
|
---|
602 |
|
---|
603 | def __len__(self):
|
---|
604 | if self.isarray:
|
---|
605 | return self.handle.__len__()
|
---|
606 | raise TypeError, "iteration over non-sequence"
|
---|
607 |
|
---|
608 | def __getitem__(self, index):
|
---|
609 | if self.isarray:
|
---|
610 | return Boolean(self.mgr, self.handle[index])
|
---|
611 | raise TypeError, "iteration over non-sequence"
|
---|
612 |
|
---|
613 | class Number:
|
---|
614 | def __init__(self, mgr, handle, isarray = False):
|
---|
615 | self.handle = handle
|
---|
616 | self.mgr = mgr
|
---|
617 | self.isarray = isarray
|
---|
618 |
|
---|
619 | def __next(self):
|
---|
620 | if self.isarray:
|
---|
621 | return self.handle.__next()
|
---|
622 | raise TypeError, "iteration over non-sequence"
|
---|
623 |
|
---|
624 | def __size(self):
|
---|
625 | if self.isarray:
|
---|
626 | return self.handle.__size()
|
---|
627 | raise TypeError, "iteration over non-sequence"
|
---|
628 |
|
---|
629 | def __len__(self):
|
---|
630 | if self.isarray:
|
---|
631 | return self.handle.__len__()
|
---|
632 | raise TypeError, "iteration over non-sequence"
|
---|
633 |
|
---|
634 | def __str__(self):
|
---|
635 | return str(self.handle)
|
---|
636 |
|
---|
637 | def __int__(self):
|
---|
638 | return int(self.handle)
|
---|
639 |
|
---|
640 | def __long__(self):
|
---|
641 | return long(self.handle)
|
---|
642 |
|
---|
643 | def __float__(self):
|
---|
644 | return float(self.handle)
|
---|
645 |
|
---|
646 | def __lt__(self, other):
|
---|
647 | if self.isarray:
|
---|
648 | return NotImplemented
|
---|
649 | else:
|
---|
650 | return self.handle < other
|
---|
651 |
|
---|
652 | def __le__(self, other):
|
---|
653 | if self.isarray:
|
---|
654 | return NotImplemented
|
---|
655 | else:
|
---|
656 | return self.handle <= other
|
---|
657 |
|
---|
658 | def __eq__(self, other):
|
---|
659 | return self.handle == other
|
---|
660 |
|
---|
661 | def __ne__(self, other):
|
---|
662 | return self.handle != other
|
---|
663 |
|
---|
664 | def __gt__(self, other):
|
---|
665 | if self.isarray:
|
---|
666 | return NotImplemented
|
---|
667 | else:
|
---|
668 | return self.handle > other
|
---|
669 |
|
---|
670 | def __ge__(self, other):
|
---|
671 | if self.isarray:
|
---|
672 | return NotImplemented
|
---|
673 | else:
|
---|
674 | return self.handle >= other
|
---|
675 |
|
---|
676 | import struct
|
---|
677 |
|
---|
678 | class Octet(Number):
|
---|
679 | def __init__(self, mgr, handle, isarray = False):
|
---|
680 | self.handle = handle
|
---|
681 | self.mgr = mgr
|
---|
682 | self.isarray = isarray
|
---|
683 |
|
---|
684 | def __getitem__(self, index):
|
---|
685 | if self.isarray:
|
---|
686 | return Octet(self.mgr, self.handle[index])
|
---|
687 | raise TypeError, "iteration over non-sequence"
|
---|
688 |
|
---|
689 | def __str__(self):
|
---|
690 | if self.isarray:
|
---|
691 | # array of octets is binary data
|
---|
692 | list = map (None, self.handle)
|
---|
693 | return struct.pack("%dB" % (len(list)), *list)
|
---|
694 | else:
|
---|
695 | return str(self.handle)
|
---|
696 |
|
---|
697 | class UnsignedInt(Number):
|
---|
698 | def __init__(self, mgr, handle, isarray = False):
|
---|
699 | self.handle = handle
|
---|
700 | self.mgr = mgr
|
---|
701 | self.isarray = isarray
|
---|
702 |
|
---|
703 | def __getitem__(self, index):
|
---|
704 | if self.isarray:
|
---|
705 | return UnsignedInt(self.mgr, self.handle[index])
|
---|
706 | raise TypeError, "iteration over non-sequence"
|
---|
707 |
|
---|
708 |
|
---|
709 | class Int(Number):
|
---|
710 | def __init__(self, mgr, handle, isarray = False):
|
---|
711 | self.handle = handle
|
---|
712 | self.mgr = mgr
|
---|
713 | self.isarray = isarray
|
---|
714 |
|
---|
715 | def __getitem__(self, index):
|
---|
716 | if self.isarray:
|
---|
717 | return Int(self.mgr, self.handle[index])
|
---|
718 | raise TypeError, "iteration over non-sequence"
|
---|
719 |
|
---|
720 | class UnsignedShort(Number):
|
---|
721 | def __init__(self, mgr, handle, isarray = False):
|
---|
722 | self.handle = handle
|
---|
723 | self.mgr = mgr
|
---|
724 | self.isarray = isarray
|
---|
725 |
|
---|
726 | def __getitem__(self, index):
|
---|
727 | if self.isarray:
|
---|
728 | return UnsignedShort(self.mgr, self.handle[index])
|
---|
729 | raise TypeError, "iteration over non-sequence"
|
---|
730 |
|
---|
731 | class Short(Number):
|
---|
732 | def __init__(self, mgr, handle, isarray = False):
|
---|
733 | self.handle = handle
|
---|
734 | self.mgr = mgr
|
---|
735 | self.isarray = isarray
|
---|
736 |
|
---|
737 | def __getitem__(self, index):
|
---|
738 | if self.isarray:
|
---|
739 | return Short(self.mgr, self.handle[index])
|
---|
740 | raise TypeError, "iteration over non-sequence"
|
---|
741 |
|
---|
742 | class UnsignedLong(Number):
|
---|
743 | def __init__(self, mgr, handle, isarray = False):
|
---|
744 | self.handle = handle
|
---|
745 | self.mgr = mgr
|
---|
746 | self.isarray = isarray
|
---|
747 |
|
---|
748 | def __getitem__(self, index):
|
---|
749 | if self.isarray:
|
---|
750 | return UnsignedLong(self.mgr, self.handle[index])
|
---|
751 | raise TypeError, "iteration over non-sequence"
|
---|
752 |
|
---|
753 | class Long(Number):
|
---|
754 | def __init__(self, mgr, handle, isarray = False):
|
---|
755 | self.handle = handle
|
---|
756 | self.mgr = mgr
|
---|
757 | self.isarray = isarray
|
---|
758 |
|
---|
759 | def __getitem__(self, index):
|
---|
760 | if self.isarray:
|
---|
761 | return Long(self.mgr, self.handle[index])
|
---|
762 | raise TypeError, "iteration over non-sequence"
|
---|
763 |
|
---|
764 | class Double(Number):
|
---|
765 | def __init__(self, mgr, handle, isarray = False):
|
---|
766 | self.handle = handle
|
---|
767 | self.mgr = mgr
|
---|
768 | self.isarray = isarray
|
---|
769 |
|
---|
770 | def __getitem__(self, index):
|
---|
771 | if self.isarray:
|
---|
772 | return Double(self.mgr, self.handle[index])
|
---|
773 | raise TypeError, "iteration over non-sequence"
|
---|
774 |
|
---|
775 | class Float(Number):
|
---|
776 | def __init__(self, mgr, handle, isarray = False):
|
---|
777 | self.handle = handle
|
---|
778 | self.mgr = mgr
|
---|
779 | self.isarray = isarray
|
---|
780 |
|
---|
781 | def __getitem__(self, index):
|
---|
782 | if self.isarray:
|
---|
783 | return Float(self.mgr, self.handle[index])
|
---|
784 | raise TypeError, "iteration over non-sequence"
|
---|
785 |
|
---|
786 | class IUnknown:
|
---|
787 | def __init__(self, mgr, handle, isarray = False):
|
---|
788 | self.handle = handle
|
---|
789 | self.mgr = mgr
|
---|
790 | self.isarray = isarray
|
---|
791 |
|
---|
792 | def __nonzero__(self):
|
---|
793 | if self.handle != "":
|
---|
794 | return True
|
---|
795 | else:
|
---|
796 | return False
|
---|
797 |
|
---|
798 | def __next(self):
|
---|
799 | if self.isarray:
|
---|
800 | return self.handle.__next()
|
---|
801 | raise TypeError, "iteration over non-sequence"
|
---|
802 |
|
---|
803 | def __size(self):
|
---|
804 | if self.isarray:
|
---|
805 | return self.handle.__size()
|
---|
806 | raise TypeError, "iteration over non-sequence"
|
---|
807 |
|
---|
808 | def __len__(self):
|
---|
809 | if self.isarray:
|
---|
810 | return self.handle.__len__()
|
---|
811 | raise TypeError, "iteration over non-sequence"
|
---|
812 |
|
---|
813 | def __getitem__(self, index):
|
---|
814 | if self.isarray:
|
---|
815 | return IUnknown(self.mgr, self.handle[index])
|
---|
816 | raise TypeError, "iteration over non-sequence"
|
---|
817 |
|
---|
818 | def __str__(self):
|
---|
819 | return str(self.handle)
|
---|
820 |
|
---|
821 | def __eq__(self, other):
|
---|
822 | return self.handle == other
|
---|
823 |
|
---|
824 | def __ne__(self, other):
|
---|
825 | return self.handle != other
|
---|
826 |
|
---|
827 | def __getattr__(self,attr):
|
---|
828 | if self.__class__.__dict__.get(attr) != None:
|
---|
829 | return self.__class__.__dict__.get(attr)
|
---|
830 | if self.__dict__.get(attr) != None:
|
---|
831 | return self.__dict__.get(attr)
|
---|
832 | raise AttributeError
|
---|
833 |
|
---|
834 | </xsl:text>
|
---|
835 | <xsl:for-each select="//interface[@wsmap='managed' or @wsmap='global']">
|
---|
836 | <xsl:call-template name="interface"/>
|
---|
837 | </xsl:for-each>
|
---|
838 | <xsl:for-each select="//interface[@wsmap='struct']">
|
---|
839 | <xsl:call-template name="interfacestruct"/>
|
---|
840 | </xsl:for-each>
|
---|
841 | <xsl:for-each select="//collection">
|
---|
842 | <xsl:call-template name="collection"/>
|
---|
843 | </xsl:for-each>
|
---|
844 | <xsl:for-each select="//enum">
|
---|
845 | <xsl:call-template name="enum"/>
|
---|
846 | </xsl:for-each>
|
---|
847 |
|
---|
848 | class IWebsessionManager2(IWebsessionManager):
|
---|
849 | def __init__(self, url):
|
---|
850 | self.url = url
|
---|
851 | self.port = None
|
---|
852 | self.handle = None
|
---|
853 | self.mgr = self
|
---|
854 |
|
---|
855 | def getPort(self):
|
---|
856 | if self.port is None:
|
---|
857 | self.port = vboxServiceLocator().getvboxPortType(self.url)
|
---|
858 | return self.port
|
---|
859 |
|
---|
860 | </xsl:template>
|
---|
861 |
|
---|
862 | </xsl:stylesheet>
|
---|