VirtualBox

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

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

Python WS: docs update, minor build changes

  • Property svn:eol-style set to native
File size: 29.5 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='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='$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:when test="($base = '$errorinfo') ">
151 <xsl:value-of select="'IUnknown'"/>
152 </xsl:when>
153 <xsl:otherwise>
154 <xsl:value-of select="$base"/>
155 </xsl:otherwise>
156 </xsl:choose>
157</xsl:template>
158
159<xsl:template name="interface">
160 <xsl:variable name="base">
161 <xsl:call-template name="computeExtends">
162 <xsl:with-param name="base" select="@extends" />
163 </xsl:call-template>
164 </xsl:variable>
165 <xsl:variable name="ifname"><xsl:value-of select="@name" /></xsl:variable>
166
167class <xsl:value-of select="$ifname"/>(<xsl:value-of select="$base" />):
168 def __init__(self, mgr, handle, isarray = False):
169 self.mgr = mgr
170 if handle is None:
171 raise Exception("bad handle: "+str(handle))
172 self.handle = handle
173 self.isarray = isarray
174<!--
175 This doesn't work now
176 mgr.register(handle)
177
178 def __del__(self):
179 mgr.unregister(self.handle)
180-->
181 def releaseRemote(self):
182 try:
183 req=IManagedObjectRef_releaseRequestMsg()
184 req._this=handle
185 self.mgr.getPort().IManagedObjectRef_release(req)
186 except:
187 pass
188
189 def __next(self):
190 if self.isarray:
191 return self.handle.__next()
192 raise TypeError, "iteration over non-sequence"
193
194 def __size(self):
195 if self.isarray:
196 return self.handle.__size()
197 raise TypeError, "iteration over non-sequence"
198
199 def __len__(self):
200 if self.isarray:
201 return self.handle.__len__()
202 raise TypeError, "iteration over non-sequence"
203
204 def __getitem__(self, index):
205 if self.isarray:
206 return <xsl:value-of select="$ifname" />(self.mgr, self.handle[index])
207 raise TypeError, "iteration over non-sequence"
208
209 def __str__(self):
210 return self.handle
211
212 def isValid(self):
213 return self.handle != None and self.handle != ''
214
215 def __getattr__(self,name):
216 hndl = <xsl:value-of select="$ifname" />._Attrs_.get(name, None)
217 if hndl != None:
218 if hndl[0] != None:
219 return hndl[0](self)
220 else:
221 raise AttributeError
222 else:
223 return <xsl:value-of select="$base" />.__getattr__(self, name)
224
225 def __setattr__(self, name, val):
226 hndl = <xsl:value-of select="$ifname" />._Attrs_.get(name, None)
227 if (hndl != None and hndl[1] != None):
228 hndl[1](self,val)
229 else:
230 self.__dict__[name] = val
231
232 <xsl:for-each select="method">
233 <xsl:call-template name="method"/>
234 </xsl:for-each>
235
236 <xsl:for-each select="attribute">
237 <xsl:variable name="attrname"><xsl:value-of select="@name" /></xsl:variable>
238 <xsl:variable name="attrtype"><xsl:value-of select="@type" /></xsl:variable>
239 <xsl:variable name="attrreadonly"><xsl:value-of select="@readonly" /></xsl:variable>
240 <!-- skip this attribute if it has parameters of a type that has wsmap="suppress" -->
241 <xsl:choose>
242 <xsl:when test="( $attrtype=($G_setSuppressedInterfaces/@name) )">
243 <xsl:comment><xsl:value-of select="concat('skipping attribute ', $attrtype, ' for it is of a suppressed type')" /></xsl:comment>
244 </xsl:when>
245 <xsl:otherwise>
246 <xsl:choose>
247 <xsl:when test="@readonly='yes'">
248 <xsl:comment> readonly attribute <xsl:copy-of select="$ifname" />::<xsl:copy-of select="$attrname" /> </xsl:comment>
249 </xsl:when>
250 <xsl:otherwise>
251 <xsl:comment> read/write attribute <xsl:copy-of select="$ifname" />::<xsl:copy-of select="$attrname" /> </xsl:comment>
252 </xsl:otherwise>
253 </xsl:choose>
254 <!-- aa) get method: emit request and result -->
255 <xsl:call-template name="emitGetAttribute">
256 <xsl:with-param name="ifname" select="$ifname" />
257 <xsl:with-param name="attrname" select="$attrname" />
258 <xsl:with-param name="attrtype" select="$attrtype" />
259 </xsl:call-template>
260 <!-- bb) emit a set method if the attribute is read/write -->
261 <xsl:if test="not($attrreadonly='yes')">
262 <xsl:call-template name="emitSetAttribute">
263 <xsl:with-param name="ifname" select="$ifname" />
264 <xsl:with-param name="attrname" select="$attrname" />
265 <xsl:with-param name="attrtype" select="$attrtype" />
266 </xsl:call-template>
267 </xsl:if>
268 </xsl:otherwise>
269 </xsl:choose>
270 </xsl:for-each>
271
272
273 _Attrs_=<xsl:text>{</xsl:text>
274 <xsl:for-each select="attribute">
275 <xsl:if test="not( @type=($G_setSuppressedInterfaces/@name) )">
276 <xsl:text> </xsl:text>'<xsl:value-of select="@name"/>'<xsl:text>:[</xsl:text>
277 <xsl:call-template name="makeGetterName">
278 <xsl:with-param name="attrname" select="@name"/>
279 </xsl:call-template>
280 <xsl:text>,</xsl:text>
281 <xsl:choose>
282 <xsl:when test="@readonly='yes'">
283 <xsl:text>None</xsl:text>
284 </xsl:when>
285 <xsl:otherwise>
286 <xsl:call-template name="makeSetterName">
287 <xsl:with-param name="attrname" select="@name"/>
288 </xsl:call-template>,
289 </xsl:otherwise>
290 </xsl:choose>
291 <xsl:text>]</xsl:text>
292 <xsl:if test="not(position()=last())"><xsl:text>,&#10;</xsl:text></xsl:if>
293 </xsl:if>
294 </xsl:for-each>
295 <xsl:text>}</xsl:text>
296</xsl:template>
297
298<xsl:template name="interfacestruct">
299 <xsl:variable name="ifname"><xsl:value-of select="@name" /></xsl:variable>
300class <xsl:value-of select="$ifname"/>:
301 def __init__(self, mgr, handle, isarray = False):
302 self.mgr = mgr
303 self.isarray = isarray
304 if isarray:
305 self.handle = handle
306 else:
307<xsl:for-each select="attribute">
308 self.<xsl:value-of select="@name"/> = <xsl:call-template name="emitConvertedType">
309 <xsl:with-param name="ifname" select="$ifname" />
310 <xsl:with-param name="methodname" select="''" />
311 <xsl:with-param name="type" select="@type" />
312 </xsl:call-template>(self.mgr, handle._<xsl:value-of select="@name"/>)
313 </xsl:for-each>
314 pass
315
316 <!-- also do getters/setters -->
317 <xsl:for-each select="attribute">
318 def <xsl:call-template name="makeGetterName"><xsl:with-param name="attrname" select="@name"/></xsl:call-template>(self):
319 return self.<xsl:value-of select="@name"/>
320
321 def <xsl:call-template name="makeSetterName"><xsl:with-param name="attrname" select="@name"/></xsl:call-template>(self):
322 raise Error, 'setters not supported'
323 </xsl:for-each>
324
325 def __next(self):
326 if self.isarray:
327 return self.handle.__next()
328 raise TypeError, "iteration over non-sequence"
329
330 def __size(self):
331 if self.isarray:
332 return self.handle.__size()
333 raise TypeError, "iteration over non-sequence"
334
335 def __len__(self):
336 if self.isarray:
337 return self.handle.__len__()
338 raise TypeError, "iteration over non-sequence"
339
340 def __getitem__(self, index):
341 if self.isarray:
342 return <xsl:value-of select="$ifname" />(self.mgr, self.handle[index])
343 raise TypeError, "iteration over non-sequence"
344
345</xsl:template>
346
347<xsl:template name="genreq">
348 <xsl:text>req=</xsl:text><xsl:value-of select="../@name"/>_<xsl:value-of select="@name"/>RequestMsg()
349 req._this=self.handle
350 <xsl:for-each select="param[@dir='in']">
351 req._<xsl:value-of select="@name" />=_arg_<xsl:value-of select="@name" />
352 </xsl:for-each>
353 val=self.mgr.getPort().<xsl:value-of select="../@name"/>_<xsl:value-of select="@name"/>(req)
354 <!-- return needs to be the first one -->
355 return <xsl:for-each select="param[@dir='return']">
356 <xsl:call-template name="emitOutParam">
357 <xsl:with-param name="ifname" select="../@name" />
358 <xsl:with-param name="methodname" select="@name" />
359 <xsl:with-param name="type" select="@type" />
360 <xsl:with-param name="value" select="concat('val.','_returnval')" />
361 <xsl:with-param name="safearray" select="@safearray"/>
362 </xsl:call-template>
363 <xsl:if test="../param[@dir='out']">
364 <xsl:text>, </xsl:text>
365 </xsl:if>
366 </xsl:for-each>
367 <xsl:for-each select="param[@dir='out']">
368 <xsl:if test="not(position()=1)">
369 <xsl:text>, </xsl:text>
370 </xsl:if>
371 <xsl:call-template name="emitOutParam">
372 <xsl:with-param name="ifname" select="../@name" />
373 <xsl:with-param name="methodname" select="@name" />
374 <xsl:with-param name="type" select="@type" />
375 <xsl:with-param name="value" select="concat('val._',@name)" />
376 <xsl:with-param name="safearray" select="@safearray"/>
377 </xsl:call-template>
378 </xsl:for-each>
379 <xsl:text>&#10;&#10;</xsl:text>
380</xsl:template>
381
382<xsl:template name="method" >
383 def <xsl:value-of select="@name"/><xsl:text>(self</xsl:text>
384 <xsl:for-each select="param[@dir='in']">
385 <xsl:text>, </xsl:text>
386 <xsl:value-of select="concat('_arg_',@name)"/>
387 </xsl:for-each><xsl:text>):&#10; </xsl:text>
388 <xsl:call-template name="genreq"/>
389</xsl:template>
390
391<xsl:template name="makeConstantName" >
392 <xsl:choose>
393 <!-- special case for reserved word, maybe will need more in the future -->
394 <xsl:when test="@name='None'">
395 <xsl:text>_None</xsl:text>
396 </xsl:when>
397 <xsl:otherwise>
398 <xsl:value-of select="@name"/>
399 </xsl:otherwise>
400 </xsl:choose>
401</xsl:template>
402
403<xsl:template name="enum">
404class <xsl:value-of select="@name"/>:
405 def __init__(self,mgr,handle):
406 self.mgr=mgr
407 if isinstance(handle,basestring):
408 self.handle=<xsl:value-of select="@name"/>._ValueMap[handle]
409 else:
410 self.handle=handle
411
412 def __eq__(self,other):
413 if isinstance(other,<xsl:value-of select="@name"/>):
414 return self.handle == other.handle
415 if isinstance(other,int):
416 return self.handle == other
417 return False
418
419 def __ne__(self,other):
420 if isinstance(other,<xsl:value-of select="@name"/>):
421 return self.handle != other.handle
422 if isinstance(other,int):
423 return self.handle != other
424 return True
425
426 def __str__(self):
427 return <xsl:value-of select="@name"/>._NameMap[self.handle]
428
429 def __int__(self):
430 return self.handle
431
432 _NameMap={<xsl:for-each select="const">
433 <xsl:value-of select="@value"/>:'<xsl:value-of select="@name"/>'<xsl:if test="not(position()=last())">,</xsl:if>
434 </xsl:for-each>}
435 _ValueMap={<xsl:for-each select="const">
436 '<xsl:value-of select="@name"/>':<xsl:value-of select="@value"/><xsl:if test="not(position()=last())">,</xsl:if>
437 </xsl:for-each>}
438
439<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>
440</xsl:for-each>
441</xsl:template>
442
443<xsl:template match="/">
444<xsl:text># Copyright (C) 2008-2009 Sun Microsystems, Inc.
445#
446# This file is part of VirtualBox Open Source Edition (OSE), as
447# available from http://www.virtualbox.org. This file is free software;
448# you can redistribute it and/or modify it under the terms of the GNU
449# General Public License (GPL) as published by the Free Software
450# Foundation, in version 2 as it comes in the "COPYING" file of the
451# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
452# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
453#
454# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
455# Clara, CA 95054 USA or visit http://www.sun.com if you need
456# additional information or have any questions.
457#
458# This file is autogenerated from VirtualBox.xidl, DO NOT EDIT!
459#
460from VirtualBox_services import *
461
462class ManagedManager:
463 def __init__(self):
464 self.map = {}
465
466 def register(self,handle):
467 if handle == None:
468 return
469 c = self.map.get(handle,0)
470 c = c + 1
471 self.map[handle]=c
472
473 def unregister(self,handle):
474 if handle == None:
475 return
476 c = self.map.get(handle,-1)
477 if c == -1:
478 raise Error, 'wrong refcount'
479 c = c - 1
480 if c == 0:
481 try:
482 req=IManagedObjectRef_releaseRequestMsg()
483 req._this=handle
484 self.mgr.getPort().IManagedObjectRef_release(req)
485 except:
486 pass
487 self.map[handle] = -1
488 else:
489 self.map[handle] = c
490
491class String:
492 def __init__(self, mgr, handle, isarray = False):
493 self.handle = handle
494 self.mgr = mgr
495 self.isarray = isarray
496
497 def __next(self):
498 if self.isarray:
499 return self.handle.__next()
500 raise TypeError, "iteration over non-sequence"
501
502 def __size(self):
503 if self.isarray:
504 return self.handle.__size()
505 raise TypeError, "iteration over non-sequence"
506
507 def __len__(self):
508 if self.isarray:
509 return self.handle.__len__()
510 raise TypeError, "iteration over non-sequence"
511
512 def __getitem__(self, index):
513 if self.isarray:
514 return String(self.mgr, self.handle[index])
515 raise TypeError, "iteration over non-sequence"
516
517 def __str__(self):
518 return str(self.handle)
519
520 def __eq__(self,other):
521 if self.isarray:
522 return isinstance(other,String) and self.handle == other.handle
523 if isinstance(other,String):
524 return self.handle == other.handle
525 if isinstance(other,basestring):
526 return self.handle == other
527 return False
528
529 def __ne__(self,other):
530 if self.isarray:
531 return not isinstance(other,String) or self.handle == other.handle
532 if isinstance(other,String):
533 return self.handle != other.handle
534 if isinstance(other,basestring):
535 return self.handle != other
536 return True
537
538 def __add__(self,other):
539 return str(self.handle)+str(other)
540
541
542class Boolean:
543 def __init__(self, mgr, handle, isarray = False):
544 self.handle = handle
545 if self.handle == "false":
546 self.handle = None
547 self.mgr = mgr
548 self.isarray = isarray
549
550 def __str__(self):
551 if self.handle:
552 return "true"
553 else:
554 return "false"
555
556 def __eq__(self,other):
557 if isinstance(other,Bool):
558 return self.handle == other.value
559 if isinstance(other,bool):
560 return self.handle == other
561 return False
562
563 def __ne__(self,other):
564 if isinstance(other,Bool):
565 return self.handle != other.handle
566 if isinstance(other,bool):
567 return self.handle != other
568 return True
569
570 def __int__(self):
571 if self.handle:
572 return 1
573 else:
574 return 0
575
576 def __long__(self):
577 if self.handle:
578 return 1
579 else:
580 return 0
581
582 def __nonzero__(self):
583 if self.handle:
584 return True
585 else:
586 return False
587
588 def __next(self):
589 if self.isarray:
590 return self.handle.__next()
591 raise TypeError, "iteration over non-sequence"
592
593 def __size(self):
594 if self.isarray:
595 return self.handle.__size()
596 raise TypeError, "iteration over non-sequence"
597
598 def __len__(self):
599 if self.isarray:
600 return self.handle.__len__()
601 raise TypeError, "iteration over non-sequence"
602
603 def __getitem__(self, index):
604 if self.isarray:
605 return Boolean(self.mgr, self.handle[index])
606 raise TypeError, "iteration over non-sequence"
607
608class UnsignedInt:
609 def __init__(self, mgr, handle, isarray = False):
610 self.handle = handle
611 self.mgr = mgr
612 self.isarray = isarray
613
614 def __str__(self):
615 return str(self.handle)
616
617 def __int__(self):
618 return int(self.handle)
619
620 def __long__(self):
621 return long(self.handle)
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 UnsignedInt(self.mgr, self.handle[index])
641 raise TypeError, "iteration over non-sequence"
642
643
644class Int:
645 def __init__(self, mgr, handle, isarray = False):
646 self.handle = handle
647 self.mgr = mgr
648 self.isarray = isarray
649
650 def __next(self):
651 if self.isarray:
652 return self.handle.__next()
653 raise TypeError, "iteration over non-sequence"
654
655 def __size(self):
656 if self.isarray:
657 return self.handle.__size()
658 raise TypeError, "iteration over non-sequence"
659
660 def __len__(self):
661 if self.isarray:
662 return self.handle.__len__()
663 raise TypeError, "iteration over non-sequence"
664
665 def __getitem__(self, index):
666 if self.isarray:
667 return Int(self.mgr, self.handle[index])
668 raise TypeError, "iteration over non-sequence"
669
670 def __str__(self):
671 return str(self.handle)
672
673 def __int__(self):
674 return int(self.handle)
675
676 def __long__(self):
677 return long(self.handle)
678
679class UnsignedShort:
680 def __init__(self, mgr, handle, isarray = False):
681 self.handle = handle
682 self.mgr = mgr
683 self.isarray = isarray
684
685 def __str__(self):
686 return str(self.handle)
687
688 def __int__(self):
689 return int(self.handle)
690
691 def __long__(self):
692 return long(self.handle)
693
694 def __next(self):
695 if self.isarray:
696 return self.handle.__next()
697 raise TypeError, "iteration over non-sequence"
698
699 def __size(self):
700 if self.isarray:
701 return self.handle.__size()
702 raise TypeError, "iteration over non-sequence"
703
704 def __len__(self):
705 if self.isarray:
706 return self.handle.__len__()
707 raise TypeError, "iteration over non-sequence"
708
709 def __getitem__(self, index):
710 if self.isarray:
711 return UnsignedShort(self.mgr, self.handle[index])
712 raise TypeError, "iteration over non-sequence"
713
714class Short:
715 def __init__(self, mgr, handle, isarray = False):
716 self.handle = handle
717 self.mgr = mgr
718 self.isarray = isarray
719
720 def __str__(self):
721 return str(self.handle)
722
723 def __int__(self):
724 return int(self.handle)
725
726 def __long__(self):
727 return long(self.handle)
728
729 def __next(self):
730 if self.isarray:
731 return self.handle.__next()
732 raise TypeError, "iteration over non-sequence"
733
734 def __size(self):
735 if self.isarray:
736 return self.handle.__size()
737 raise TypeError, "iteration over non-sequence"
738
739 def __len__(self):
740 if self.isarray:
741 return self.handle.__len__()
742 raise TypeError, "iteration over non-sequence"
743
744 def __getitem__(self, index):
745 if self.isarray:
746 return Short(self.mgr, self.handle[index])
747 raise TypeError, "iteration over non-sequence"
748
749class UnsignedLong:
750 def __init__(self, mgr, handle, isarray = False):
751 self.handle = handle
752 self.mgr = mgr
753 self.isarray = isarray
754
755 def __str__(self):
756 return str(self.handle)
757
758 def __int__(self):
759 return int(self.handle)
760
761 def __long__(self):
762 return long(self.handle)
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 UnsignedLong(self.mgr, self.handle[index])
782 raise TypeError, "iteration over non-sequence"
783
784class Long:
785 def __init__(self, mgr, handle, isarray = False):
786 self.handle = handle
787 self.mgr = mgr
788 self.isarray = isarray
789
790 def __str__(self):
791 return str(self.handle)
792
793 def __int__(self):
794 return int(self.handle)
795
796 def __long__(self):
797 return int(self.handle)
798
799 def __next(self):
800 if self.isarray:
801 return self.handle.__next()
802 raise TypeError, "iteration over non-sequence"
803
804 def __size(self):
805 if self.isarray:
806 return self.handle.__size()
807 raise TypeError, "iteration over non-sequence"
808
809 def __len__(self):
810 if self.isarray:
811 return self.handle.__len__()
812 raise TypeError, "iteration over non-sequence"
813
814 def __getitem__(self, index):
815 if self.isarray:
816 return Long(self.mgr, self.handle[index])
817 raise TypeError, "iteration over non-sequence"
818
819class Double:
820 def __init__(self, mgr, handle, isarray = False):
821 self.handle = handle
822 self.mgr = mgr
823 self.isarray = isarray
824
825 def __str__(self):
826 return str(self.handle)
827
828 def __int__(self):
829 return int(self.handle)
830
831 def __float__(self):
832 return float(self.handle)
833
834 def __next(self):
835 if self.isarray:
836 return self.handle.__next()
837 raise TypeError, "iteration over non-sequence"
838
839 def __size(self):
840 if self.isarray:
841 return self.handle.__size()
842 raise TypeError, "iteration over non-sequence"
843
844 def __len__(self):
845 if self.isarray:
846 return self.handle.__len__()
847 raise TypeError, "iteration over non-sequence"
848
849 def __getitem__(self, index):
850 if self.isarray:
851 return Double(self.mgr, self.handle[index])
852 raise TypeError, "iteration over non-sequence"
853
854class Float:
855 def __init__(self, mgr, handle, isarray = False):
856 self.handle = handle
857 self.mgr = mgr
858 self.isarray = isarray
859
860 def __str__(self):
861 return str(self.handle)
862
863 def __int__(self):
864 return int(self.handle)
865
866 def __float__(self):
867 return float(self.handle)
868
869 def __next(self):
870 if self.isarray:
871 return self.handle.__next()
872 raise TypeError, "iteration over non-sequence"
873
874 def __size(self):
875 if self.isarray:
876 return self.handle.__size()
877 raise TypeError, "iteration over non-sequence"
878
879 def __len__(self):
880 if self.isarray:
881 return self.handle.__len__()
882 raise TypeError, "iteration over non-sequence"
883
884 def __getitem__(self, index):
885 if self.isarray:
886 return Float(self.mgr, self.handle[index])
887 raise TypeError, "iteration over non-sequence"
888
889class IUnknown:
890 def __init__(self, mgr, handle, isarray = False):
891 self.handle = handle
892 self.mgr = mgr
893 self.isarray = isarray
894
895 def __nonzero__(self):
896 if self.handle != "":
897 return True
898 else:
899 return False
900
901 def __next(self):
902 if self.isarray:
903 return self.handle.__next()
904 raise TypeError, "iteration over non-sequence"
905
906 def __size(self):
907 if self.isarray:
908 return self.handle.__size()
909 raise TypeError, "iteration over non-sequence"
910
911 def __len__(self):
912 if self.isarray:
913 return self.handle.__len__()
914 raise TypeError, "iteration over non-sequence"
915
916 def __getitem__(self, index):
917 if self.isarray:
918 return IUnknown(self.mgr, self.handle[index])
919 raise TypeError, "iteration over non-sequence"
920
921 def __str__(self):
922 return str(self.handle)
923
924 def __getattr__(self,attr):
925 if self.__class__.__dict__.get(attr) != None:
926 return self.__class__.__dict__.get(attr)
927 if self.__dict__.get(attr) != None:
928 return self.__dict__.get(attr)
929 raise AttributeError
930
931</xsl:text>
932 <xsl:for-each select="//interface[@wsmap='managed' or @wsmap='global']">
933 <xsl:call-template name="interface"/>
934 </xsl:for-each>
935 <xsl:for-each select="//interface[@wsmap='struct']">
936 <xsl:call-template name="interfacestruct"/>
937 </xsl:for-each>
938 <xsl:for-each select="//collection">
939 <xsl:call-template name="collection"/>
940 </xsl:for-each>
941 <xsl:for-each select="//enum">
942 <xsl:call-template name="enum"/>
943 </xsl:for-each>
944
945class IWebsessionManager2(IWebsessionManager):
946 def __init__(self, url):
947 self.url = url
948 self.port = None
949 self.handle = None
950 self.mgr = self
951
952 def getPort(self):
953 if self.port is None:
954 self.port = vboxServiceLocator().getvboxPortType(self.url)
955 return self.port
956
957</xsl:template>
958
959</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