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