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