VirtualBox

source: vbox/trunk/src/VBox/Main/webservice/websrv-python.xsl@ 21640

Last change on this file since 21640 was 21640, checked in by vboxsync, 15 years ago

Python: WS Python bindings fully usable, extend shell to control remote VMs

  • Property svn:eol-style set to native
File size: 30.9 KB
Line 
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='boolean'">Boolean</xsl:when>
46 <xsl:when test="$type='unsigned long'">UnsignedInt</xsl:when>
47 <xsl:when test="$type='double'">Double</xsl:when>
48 <xsl:when test="$type='float'">Float</xsl:when>
49 <xsl:when test="$type='long'">Int</xsl:when>
50 <xsl:when test="$type='long long'">Long</xsl:when>
51 <xsl:when test="$type='short'">Short</xsl:when>
52 <xsl:when test="$type='unsigned short'">UnsignedShort</xsl:when>
53 <xsl:when test="$type='unsigned long long'">UnsignedLong</xsl:when>
54 <xsl:when test="$type='result'">UnsignedInt</xsl:when>
55 <xsl:when test="$type='uuid'">UUID</xsl:when>
56 <xsl:when test="$type='$unknown'">IUnknown</xsl:when>
57 <xsl:when test="$type='$dispatched'">IUnknown</xsl:when>
58 <xsl:otherwise><xsl:value-of select="$type" /></xsl:otherwise>
59 </xsl:choose>
60</xsl:template>
61
62<xsl:template name="emitOutParam">
63 <xsl:param name="ifname" />
64 <xsl:param name="methodname" />
65 <xsl:param name="type" />
66 <xsl:param name="value" />
67 <xsl:param name="safearray" />
68
69 <xsl:call-template name="emitConvertedType">
70 <xsl:with-param name="ifname" select="$ifname" />
71 <xsl:with-param name="methodname" select="$methodname" />
72 <xsl:with-param name="type" select="$type" />
73 </xsl:call-template>
74 <xsl:text>(</xsl:text>
75 <xsl:text>self.mgr,</xsl:text>
76 <xsl:value-of select="$value"/>
77 <xsl:if test="$safearray='yes'">
78 <xsl:value-of select="', True'"/>
79 </xsl:if>
80 <xsl:text>)</xsl:text>
81</xsl:template>
82
83
84<xsl:template name="emitGetAttribute">
85 <xsl:param name="ifname" />
86 <xsl:param name="attrname" />
87 <xsl:param name="attrtype" />
88 <xsl:param name="attrsafearray" />
89 <xsl:variable name="fname"><xsl:call-template name="makeGetterName"><xsl:with-param name="attrname" select="$attrname"/></xsl:call-template> </xsl:variable>
90 def <xsl:value-of select="$fname"/>(self):
91 req=<xsl:value-of select="$ifname"/>_<xsl:value-of select="$fname"/>RequestMsg()
92 req._this=self.handle
93 val=self.mgr.getPort().<xsl:value-of select="$ifname"/>_<xsl:value-of select="$fname"/>(req)
94 <xsl:text>return </xsl:text>
95 <xsl:call-template name="emitOutParam">
96 <xsl:with-param name="ifname" select="$ifname" />
97 <xsl:with-param name="methodname" select="@name" />
98 <xsl:with-param name="type" select="$attrtype" />
99 <xsl:with-param name="value" select="concat('val.','_returnval')" />
100 <xsl:with-param name="safearray" select="@safearray"/>
101 </xsl:call-template>
102</xsl:template>
103
104<xsl:template name="emitSetAttribute">
105 <xsl:param name="ifname" />
106 <xsl:param name="attrname" />
107 <xsl:param name="attrtype" />
108 <xsl:param name="attrsafearray" />
109 <xsl:variable name="fname"><xsl:call-template name="makeSetterName"><xsl:with-param name="attrname" select="$attrname"/></xsl:call-template> </xsl:variable>
110 def <xsl:value-of select="$fname"/>(self, value):
111 req=<xsl:value-of select="$ifname"/>_<xsl:value-of select="$fname"/>RequestMsg()
112 req._this=self.handle
113 if type(value) in [int, bool, basestring]:
114 req._<xsl:value-of select="$attrname"/> = value
115 else:
116 req._<xsl:value-of select="$attrname"/> = value.handle
117 self.mgr.getPort().<xsl:value-of select="$ifname"/>_<xsl:value-of select="$fname"/>(req)
118</xsl:template>
119
120<xsl:template name="collection">
121 <xsl:variable name="cname"><xsl:value-of select="@name" /></xsl:variable>
122 <xsl:variable name="ename"><xsl:value-of select="@type" /></xsl:variable>
123class <xsl:value-of select="$cname"/>:
124 def __init__(self, mgr, array):
125 self.array = array
126 self.mgr = mgr
127
128 def __next(self):
129 return self.array.__next()
130
131 def __size(self):
132 return self.array._array.__size()
133
134 def __len__(self):
135 return self.array._array.__len__()
136
137 def __getitem__(self, index):
138 return <xsl:value-of select="$ename"/>(self.mgr, self.array._array[index])
139
140</xsl:template>
141
142
143<xsl:template name="computeExtends">
144 <xsl:param name="base" />
145
146 <xsl:choose>
147 <xsl:when test="($base = '$unknown') or ($base = '$dispatched')">
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
164class <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>,&#10;</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>
297class <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>&#10;&#10;</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>):&#10; </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">
401class <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 return False
415
416 def __ne__(self,other):
417 if isinstance(other,<xsl:value-of select="@name"/>):
418 return self.handle != other.handle
419 if isinstance(other,int):
420 return self.handle != other
421 return True
422
423 def __str__(self):
424 return <xsl:value-of select="@name"/>._NameMap[self.handle]
425
426 def __int__(self):
427 return self.handle
428
429 _NameMap={<xsl:for-each select="const">
430 <xsl:value-of select="@value"/>:'<xsl:value-of select="@name"/>'<xsl:if test="not(position()=last())">,</xsl:if>
431 </xsl:for-each>}
432 _ValueMap={<xsl:for-each select="const">
433 '<xsl:value-of select="@name"/>':<xsl:value-of select="@value"/><xsl:if test="not(position()=last())">,</xsl:if>
434 </xsl:for-each>}
435
436<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>&#xa;</xsl:text>
437</xsl:for-each>
438</xsl:template>
439
440<xsl:template match="/">
441<xsl:text># Copyright (C) 2008-2009 Sun Microsystems, Inc.
442#
443# This file is part of VirtualBox Open Source Edition (OSE), as
444# available from http://www.virtualbox.org. This file is free software;
445# you can redistribute it and/or modify it under the terms of the GNU
446# General Public License (GPL) as published by the Free Software
447# Foundation, in version 2 as it comes in the "COPYING" file of the
448# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
449# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
450#
451# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
452# Clara, CA 95054 USA or visit http://www.sun.com if you need
453# additional information or have any questions.
454#
455# This file is autogenerated from VirtualBox.xidl, DO NOT EDIT!
456#
457from VirtualBox_services import *
458
459class ManagedManager:
460 def __init__(self):
461 self.map = {}
462
463 def register(self,handle):
464 if handle == None:
465 return
466 c = self.map.get(handle,0)
467 c = c + 1
468 self.map[handle]=c
469
470 def unregister(self,handle):
471 if handle == None:
472 return
473 c = self.map.get(handle,-1)
474 if c == -1:
475 raise Error, 'wrong refcount'
476 c = c - 1
477 if c == 0:
478 try:
479 req=IManagedObjectRef_releaseRequestMsg()
480 req._this=handle
481 self.mgr.getPort().IManagedObjectRef_release(req)
482 except:
483 pass
484 finally:
485 self.map[handle] = -1
486 else:
487 self.map[handle] = c
488
489class String:
490 def __init__(self, mgr, handle, isarray = False):
491 self.handle = handle
492 self.mgr = mgr
493 self.isarray = isarray
494
495 def __next(self):
496 if self.isarray:
497 return self.handle.__next()
498 raise TypeError, "iteration over non-sequence"
499
500 def __size(self):
501 if self.isarray:
502 return self.handle.__size()
503 raise TypeError, "iteration over non-sequence"
504
505 def __len__(self):
506 if self.isarray:
507 return self.handle.__len__()
508 raise TypeError, "iteration over non-sequence"
509
510 def __getitem__(self, index):
511 if self.isarray:
512 return String(self.mgr, self.handle[index])
513 raise TypeError, "iteration over non-sequence"
514
515 def __str__(self):
516 return str(self.handle)
517
518 def __eq__(self,other):
519 if self.isarray:
520 return isinstance(other,String) and self.handle == other.handle
521 if isinstance(other,String):
522 return self.handle == other.handle
523 if isinstance(other,basestring):
524 return self.handle == other
525 return False
526
527 def __ne__(self,other):
528 if self.isarray:
529 return not isinstance(other,String) or self.handle == other.handle
530 if isinstance(other,String):
531 return self.handle != other.handle
532 if isinstance(other,basestring):
533 return self.handle != other
534 return True
535
536 def __add__(self,other):
537 return str(self.handle)+str(other)
538
539
540class UUID:
541 def __init__(self, mgr, handle, isarray = False):
542 self.handle = handle
543 self.mgr = mgr
544 self.isarray = isarray
545
546 def __next(self):
547 if self.isarray:
548 return self.handle.__next()
549 raise TypeError, "iteration over non-sequence"
550
551 def __size(self):
552 if self.isarray:
553 return self.handle.__size()
554 raise TypeError, "iteration over non-sequence"
555
556 def __len__(self):
557 if self.isarray:
558 return self.handle.__len__()
559 raise TypeError, "iteration over non-sequence"
560
561 def __getitem__(self, index):
562 if self.isarray:
563 return UUID(self.mgr, self.handle[index])
564 raise TypeError, "iteration over non-sequence"
565
566 def __str__(self):
567 return self.handle
568
569 def __eq__(self,other):
570 if self.isarray:
571 return isinstance(other,UUID) and self.handle == other.handle
572 if isinstance(other,UUID):
573 return self.handle == other.handle
574 if isinstance(other,basestring):
575 return self.handle == other
576 return False
577
578 def __ne__(self,other):
579 if self.isarray:
580 return not isinstance(other,UUID) or self.handle == other.handle
581 if isinstance(other,UUID):
582 return self.handle != other.handle
583 if isinstance(other,basestring):
584 return self.handle != other
585 return True
586
587class Boolean:
588 def __init__(self, mgr, handle, isarray = False):
589 self.handle = handle
590 if self.handle == "false":
591 self.handle = None
592 self.mgr = mgr
593 self.isarray = isarray
594
595 def __str__(self):
596 return "true" if self.handle else "false"
597
598 def __eq__(self,other):
599 if isinstance(other,Bool):
600 return self.handle == other.value
601 if isinstance(other,bool):
602 return self.handle == other
603 return False
604
605 def __ne__(self,other):
606 if isinstance(other,Bool):
607 return self.handle != other.handle
608 if isinstance(other,bool):
609 return self.handle != other
610 return True
611
612 def __int__(self):
613 return 1 if self.handle else 0
614
615 def __long__(self):
616 return 1 if self.handle else 0
617
618 def __nonzero__(self):
619 return True if self.handle else False
620
621 def __next(self):
622 if self.isarray:
623 return self.handle.__next()
624 raise TypeError, "iteration over non-sequence"
625
626 def __size(self):
627 if self.isarray:
628 return self.handle.__size()
629 raise TypeError, "iteration over non-sequence"
630
631 def __len__(self):
632 if self.isarray:
633 return self.handle.__len__()
634 raise TypeError, "iteration over non-sequence"
635
636 def __getitem__(self, index):
637 if self.isarray:
638 return Boolean(self.mgr, self.handle[index])
639 raise TypeError, "iteration over non-sequence"
640
641class UnsignedInt:
642 def __init__(self, mgr, handle, isarray = False):
643 self.handle = handle
644 self.mgr = mgr
645 self.isarray = isarray
646
647 def __str__(self):
648 return str(self.handle)
649
650 def __int__(self):
651 return int(self.handle)
652
653 def __long__(self):
654 return long(self.handle)
655
656 def __next(self):
657 if self.isarray:
658 return self.handle.__next()
659 raise TypeError, "iteration over non-sequence"
660
661 def __size(self):
662 if self.isarray:
663 return self.handle.__size()
664 raise TypeError, "iteration over non-sequence"
665
666 def __len__(self):
667 if self.isarray:
668 return self.handle.__len__()
669 raise TypeError, "iteration over non-sequence"
670
671 def __getitem__(self, index):
672 if self.isarray:
673 return UnsignedInt(self.mgr, self.handle[index])
674 raise TypeError, "iteration over non-sequence"
675
676
677class Int:
678 def __init__(self, mgr, handle, isarray = False):
679 self.handle = handle
680 self.mgr = mgr
681 self.isarray = isarray
682
683 def __next(self):
684 if self.isarray:
685 return self.handle.__next()
686 raise TypeError, "iteration over non-sequence"
687
688 def __size(self):
689 if self.isarray:
690 return self.handle.__size()
691 raise TypeError, "iteration over non-sequence"
692
693 def __len__(self):
694 if self.isarray:
695 return self.handle.__len__()
696 raise TypeError, "iteration over non-sequence"
697
698 def __getitem__(self, index):
699 if self.isarray:
700 return Int(self.mgr, self.handle[index])
701 raise TypeError, "iteration over non-sequence"
702
703 def __str__(self):
704 return str(self.handle)
705
706 def __int__(self):
707 return int(self.handle)
708
709 def __long__(self):
710 return long(self.handle)
711
712class UnsignedShort:
713 def __init__(self, mgr, handle, isarray = False):
714 self.handle = handle
715 self.mgr = mgr
716 self.isarray = isarray
717
718 def __str__(self):
719 return str(self.handle)
720
721 def __int__(self):
722 return int(self.handle)
723
724 def __long__(self):
725 return long(self.handle)
726
727 def __next(self):
728 if self.isarray:
729 return self.handle.__next()
730 raise TypeError, "iteration over non-sequence"
731
732 def __size(self):
733 if self.isarray:
734 return self.handle.__size()
735 raise TypeError, "iteration over non-sequence"
736
737 def __len__(self):
738 if self.isarray:
739 return self.handle.__len__()
740 raise TypeError, "iteration over non-sequence"
741
742 def __getitem__(self, index):
743 if self.isarray:
744 return UnsignedShort(self.mgr, self.handle[index])
745 raise TypeError, "iteration over non-sequence"
746
747class Short:
748 def __init__(self, mgr, handle, isarray = False):
749 self.handle = handle
750 self.mgr = mgr
751 self.isarray = isarray
752
753 def __str__(self):
754 return str(self.handle)
755
756 def __int__(self):
757 return int(self.handle)
758
759 def __long__(self):
760 return long(self.handle)
761
762 def __next(self):
763 if self.isarray:
764 return self.handle.__next()
765 raise TypeError, "iteration over non-sequence"
766
767 def __size(self):
768 if self.isarray:
769 return self.handle.__size()
770 raise TypeError, "iteration over non-sequence"
771
772 def __len__(self):
773 if self.isarray:
774 return self.handle.__len__()
775 raise TypeError, "iteration over non-sequence"
776
777 def __getitem__(self, index):
778 if self.isarray:
779 return Short(self.mgr, self.handle[index])
780 raise TypeError, "iteration over non-sequence"
781
782class UnsignedLong:
783 def __init__(self, mgr, handle, isarray = False):
784 self.handle = handle
785 self.mgr = mgr
786 self.isarray = isarray
787
788 def __str__(self):
789 return str(self.handle)
790
791 def __int__(self):
792 return int(self.handle)
793
794 def __long__(self):
795 return long(self.handle)
796
797 def __next(self):
798 if self.isarray:
799 return self.handle.__next()
800 raise TypeError, "iteration over non-sequence"
801
802 def __size(self):
803 if self.isarray:
804 return self.handle.__size()
805 raise TypeError, "iteration over non-sequence"
806
807 def __len__(self):
808 if self.isarray:
809 return self.handle.__len__()
810 raise TypeError, "iteration over non-sequence"
811
812 def __getitem__(self, index):
813 if self.isarray:
814 return UnsignedLong(self.mgr, self.handle[index])
815 raise TypeError, "iteration over non-sequence"
816
817class Long:
818 def __init__(self, mgr, handle, isarray = False):
819 self.handle = handle
820 self.mgr = mgr
821 self.isarray = isarray
822
823 def __str__(self):
824 return str(self.handle)
825
826 def __int__(self):
827 return int(self.handle)
828
829 def __long__(self):
830 return int(self.handle)
831
832 def __next(self):
833 if self.isarray:
834 return self.handle.__next()
835 raise TypeError, "iteration over non-sequence"
836
837 def __size(self):
838 if self.isarray:
839 return self.handle.__size()
840 raise TypeError, "iteration over non-sequence"
841
842 def __len__(self):
843 if self.isarray:
844 return self.handle.__len__()
845 raise TypeError, "iteration over non-sequence"
846
847 def __getitem__(self, index):
848 if self.isarray:
849 return Long(self.mgr, self.handle[index])
850 raise TypeError, "iteration over non-sequence"
851
852class Double:
853 def __init__(self, mgr, handle, isarray = False):
854 self.handle = handle
855 self.mgr = mgr
856 self.isarray = isarray
857
858 def __str__(self):
859 return str(self.handle)
860
861 def __int__(self):
862 return int(self.handle)
863
864 def __float__(self):
865 return float(self.handle)
866
867 def __next(self):
868 if self.isarray:
869 return self.handle.__next()
870 raise TypeError, "iteration over non-sequence"
871
872 def __size(self):
873 if self.isarray:
874 return self.handle.__size()
875 raise TypeError, "iteration over non-sequence"
876
877 def __len__(self):
878 if self.isarray:
879 return self.handle.__len__()
880 raise TypeError, "iteration over non-sequence"
881
882 def __getitem__(self, index):
883 if self.isarray:
884 return Double(self.mgr, self.handle[index])
885 raise TypeError, "iteration over non-sequence"
886
887class Float:
888 def __init__(self, mgr, handle, isarray = False):
889 self.handle = handle
890 self.mgr = mgr
891 self.isarray = isarray
892
893 def __str__(self):
894 return str(self.handle)
895
896 def __int__(self):
897 return int(self.handle)
898
899 def __float__(self):
900 return float(self.handle)
901
902 def __next(self):
903 if self.isarray:
904 return self.handle.__next()
905 raise TypeError, "iteration over non-sequence"
906
907 def __size(self):
908 if self.isarray:
909 return self.handle.__size()
910 raise TypeError, "iteration over non-sequence"
911
912 def __len__(self):
913 if self.isarray:
914 return self.handle.__len__()
915 raise TypeError, "iteration over non-sequence"
916
917 def __getitem__(self, index):
918 if self.isarray:
919 return Float(self.mgr, self.handle[index])
920 raise TypeError, "iteration over non-sequence"
921
922class IUnknown:
923 def __init__(self, mgr, handle, isarray = False):
924 self.handle = handle
925 self.mgr = mgr
926 self.isarray = isarray
927
928 def __nonzero__(self):
929 return True if self.handle != "" else False
930
931 def __next(self):
932 if self.isarray:
933 return self.handle.__next()
934 raise TypeError, "iteration over non-sequence"
935
936 def __size(self):
937 if self.isarray:
938 return self.handle.__size()
939 raise TypeError, "iteration over non-sequence"
940
941 def __len__(self):
942 if self.isarray:
943 return self.handle.__len__()
944 raise TypeError, "iteration over non-sequence"
945
946 def __getitem__(self, index):
947 if self.isarray:
948 return IUnknown(self.mgr, self.handle[index])
949 raise TypeError, "iteration over non-sequence"
950
951 def __str__(self):
952 return str(self.handle)
953
954 def __getattr__(self,attr):
955 if self.__class__.__dict__.get(attr) != None:
956 return self.__class__.__dict__.get(attr)
957 if self.__dict__.get(attr) != None:
958 return self.__dict__.get(attr)
959 raise AttributeError
960
961</xsl:text>
962 <xsl:for-each select="//interface[@wsmap='managed' or @wsmap='global']">
963 <xsl:call-template name="interface"/>
964 </xsl:for-each>
965 <xsl:for-each select="//interface[@wsmap='struct']">
966 <xsl:call-template name="interfacestruct"/>
967 </xsl:for-each>
968 <xsl:for-each select="//collection">
969 <xsl:call-template name="collection"/>
970 </xsl:for-each>
971 <xsl:for-each select="//enum">
972 <xsl:call-template name="enum"/>
973 </xsl:for-each>
974
975class IWebsessionManager2(IWebsessionManager):
976 def __init__(self, url):
977 self.url = url
978 self.port = None
979 self.handle = None
980 self.mgr = self
981
982 def getPort(self):
983 if self.port is None:
984 self.port = vboxServiceLocator().getvboxPortType(self.url)
985 return self.port
986
987</xsl:template>
988
989</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette