VirtualBox

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

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

Automated rebranding to Oracle copyright/license strings via filemuncher

  • Property svn:eol-style set to native
File size: 27.3 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 Oracle Corporation
13
14 This file is part of VirtualBox Open Source Edition (OSE), as
15 available from http://www.virtualbox.org. This file is free software;
16 you can redistribute it and/or modify it under the terms of the GNU
17 General Public License (GPL) as published by the Free Software
18 Foundation, in version 2 as it comes in the "COPYING" file of the
19 VirtualBox OSE distribution. VirtualBox OSE is distributed in the
20 hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
21-->
22
23
24<xsl:output
25 method="text"
26 version="1.0"
27 encoding="utf-8"
28 indent="no"/>
29
30<xsl:include href="websrv-shared.inc.xsl" />
31
32<xsl:variable name="G_setSuppressedInterfaces"
33 select="//interface[@wsmap='suppress']" />
34
35<xsl:template name="emitConvertedType">
36 <xsl:param name="ifname" />
37 <xsl:param name="methodname" />
38 <xsl:param name="type" />
39 <xsl:choose>
40 <xsl:when test="$type='wstring'">String</xsl:when>
41 <xsl:when test="$type='uuid'">String</xsl:when>
42 <xsl:when test="$type='boolean'">Boolean</xsl:when>
43 <xsl:when test="$type='unsigned long'">UnsignedInt</xsl:when>
44 <xsl:when test="$type='double'">Double</xsl:when>
45 <xsl:when test="$type='float'">Float</xsl:when>
46 <xsl:when test="$type='long'">Int</xsl:when>
47 <xsl:when test="$type='long long'">Long</xsl:when>
48 <xsl:when test="$type='short'">Short</xsl:when>
49 <xsl:when test="$type='unsigned short'">UnsignedShort</xsl:when>
50 <xsl:when test="$type='unsigned long long'">UnsignedLong</xsl:when>
51 <xsl:when test="$type='result'">UnsignedInt</xsl:when>
52 <xsl:when test="$type='octet'">Octet</xsl:when>
53 <xsl:when test="$type='$unknown'">IUnknown</xsl:when>
54 <xsl:when test="$type='$dispatched'">IUnknown</xsl:when>
55 <xsl:otherwise><xsl:value-of select="$type" /></xsl:otherwise>
56 </xsl:choose>
57</xsl:template>
58
59<xsl:template name="emitOutParam">
60 <xsl:param name="ifname" />
61 <xsl:param name="methodname" />
62 <xsl:param name="type" />
63 <xsl:param name="value" />
64 <xsl:param name="safearray" />
65
66 <xsl:call-template name="emitConvertedType">
67 <xsl:with-param name="ifname" select="$ifname" />
68 <xsl:with-param name="methodname" select="$methodname" />
69 <xsl:with-param name="type" select="$type" />
70 </xsl:call-template>
71 <xsl:text>(</xsl:text>
72 <xsl:text>self.mgr,</xsl:text>
73 <xsl:value-of select="$value"/>
74 <xsl:if test="$safearray='yes'">
75 <xsl:value-of select="', True'"/>
76 </xsl:if>
77 <xsl:text>)</xsl:text>
78</xsl:template>
79
80
81<xsl:template name="emitGetAttribute">
82 <xsl:param name="ifname" />
83 <xsl:param name="attrname" />
84 <xsl:param name="attrtype" />
85 <xsl:param name="attrsafearray" />
86 <xsl:variable name="fname"><xsl:call-template name="makeGetterName"><xsl:with-param name="attrname" select="$attrname"/></xsl:call-template> </xsl:variable>
87 def <xsl:value-of select="$fname"/>(self):
88 req=<xsl:value-of select="$ifname"/>_<xsl:value-of select="$fname"/>RequestMsg()
89 req._this=self.handle
90 val=self.mgr.getPort().<xsl:value-of select="$ifname"/>_<xsl:value-of select="$fname"/>(req)
91 <xsl:text>return </xsl:text>
92 <xsl:call-template name="emitOutParam">
93 <xsl:with-param name="ifname" select="$ifname" />
94 <xsl:with-param name="methodname" select="@name" />
95 <xsl:with-param name="type" select="$attrtype" />
96 <xsl:with-param name="value" select="concat('val.','_returnval')" />
97 <xsl:with-param name="safearray" select="@safearray"/>
98 </xsl:call-template>
99</xsl:template>
100
101<xsl:template name="emitSetAttribute">
102 <xsl:param name="ifname" />
103 <xsl:param name="attrname" />
104 <xsl:param name="attrtype" />
105 <xsl:param name="attrsafearray" />
106 <xsl:variable name="fname"><xsl:call-template name="makeSetterName"><xsl:with-param name="attrname" select="$attrname"/></xsl:call-template> </xsl:variable>
107 def <xsl:value-of select="$fname"/>(self, value):
108 req=<xsl:value-of select="$ifname"/>_<xsl:value-of select="$fname"/>RequestMsg()
109 req._this=self.handle
110 if type(value) in [int, bool, basestring]:
111 req._<xsl:value-of select="$attrname"/> = value
112 else:
113 req._<xsl:value-of select="$attrname"/> = value.handle
114 self.mgr.getPort().<xsl:value-of select="$ifname"/>_<xsl:value-of select="$fname"/>(req)
115</xsl:template>
116
117<xsl:template name="collection">
118 <xsl:variable name="cname"><xsl:value-of select="@name" /></xsl:variable>
119 <xsl:variable name="ename"><xsl:value-of select="@type" /></xsl:variable>
120class <xsl:value-of select="$cname"/>:
121 def __init__(self, mgr, array):
122 self.array = array
123 self.mgr = mgr
124
125 def __next(self):
126 return self.array.__next()
127
128 def __size(self):
129 return self.array._array.__size()
130
131 def __len__(self):
132 return self.array._array.__len__()
133
134 def __getitem__(self, index):
135 return <xsl:value-of select="$ename"/>(self.mgr, self.array._array[index])
136
137</xsl:template>
138
139
140<xsl:template name="computeExtends">
141 <xsl:param name="base" />
142
143 <xsl:choose>
144 <xsl:when test="($base = '$unknown') or ($base = '$dispatched')">
145 <xsl:value-of select="'IUnknown'"/>
146 </xsl:when>
147 <xsl:when test="($base = '$errorinfo') ">
148 <xsl:value-of select="'IUnknown'"/>
149 </xsl:when>
150 <xsl:otherwise>
151 <xsl:value-of select="$base"/>
152 </xsl:otherwise>
153 </xsl:choose>
154</xsl:template>
155
156<xsl:template name="interface">
157 <xsl:variable name="base">
158 <xsl:call-template name="computeExtends">
159 <xsl:with-param name="base" select="@extends" />
160 </xsl:call-template>
161 </xsl:variable>
162 <xsl:variable name="ifname"><xsl:value-of select="@name" /></xsl:variable>
163
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 if isinstance(other,basestring):
415 return str(self) == other
416 return False
417
418 def __ne__(self,other):
419 if isinstance(other,<xsl:value-of select="@name"/>):
420 return self.handle != other.handle
421 if isinstance(other,int):
422 return self.handle != other
423 if isinstance(other,basestring):
424 return str(self) != other
425 return True
426
427 def __str__(self):
428 return <xsl:value-of select="@name"/>._NameMap[self.handle]
429
430 def __int__(self):
431 return self.handle
432
433 _NameMap={<xsl:for-each select="const">
434 <xsl:value-of select="@value"/>:'<xsl:value-of select="@name"/>'<xsl:if test="not(position()=last())">,</xsl:if>
435 </xsl:for-each>}
436 _ValueMap={<xsl:for-each select="const">
437 '<xsl:value-of select="@name"/>':<xsl:value-of select="@value"/><xsl:if test="not(position()=last())">,</xsl:if>
438 </xsl:for-each>}
439
440<xsl:for-each select="const"><xsl:text> </xsl:text><xsl:call-template name="makeConstantName"><xsl:with-param name="name" select="@name"/></xsl:call-template>=<xsl:value-of select="@value"/><xsl:text>&#xa;</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#
461from VirtualBox_services import *
462
463class 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
492class 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
543class 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
609class 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 def __lt__(self, other):
643 if self.isarray:
644 return NotImplemented
645 else:
646 return self.handle &lt; other
647
648 def __le__(self, other):
649 if self.isarray:
650 return NotImplemented
651 else:
652 return self.handle &lt;= other
653
654 def __eq__(self, other):
655 return self.handle == other
656
657 def __ne__(self, other):
658 return self.handle != other
659
660 def __gt__(self, other):
661 if self.isarray:
662 return NotImplemented
663 else:
664 return self.handle &gt; other
665
666 def __ge__(self, other):
667 if self.isarray:
668 return NotImplemented
669 else:
670 return self.handle &gt;= other
671
672import struct
673
674class Octet(Number):
675 def __init__(self, mgr, handle, isarray = False):
676 self.handle = handle
677 self.mgr = mgr
678 self.isarray = isarray
679
680 def __getitem__(self, index):
681 if self.isarray:
682 return Octet(self.mgr, self.handle[index])
683 raise TypeError, "iteration over non-sequence"
684
685 def __str__(self):
686 if self.isarray:
687 # array of octets is binary data
688 list = map (None, self.handle)
689 return struct.pack("%dB" % (len(list)), *list)
690 else:
691 return str(self.handle)
692
693class UnsignedInt(Number):
694 def __init__(self, mgr, handle, isarray = False):
695 self.handle = handle
696 self.mgr = mgr
697 self.isarray = isarray
698
699 def __getitem__(self, index):
700 if self.isarray:
701 return UnsignedInt(self.mgr, self.handle[index])
702 raise TypeError, "iteration over non-sequence"
703
704
705class Int(Number):
706 def __init__(self, mgr, handle, isarray = False):
707 self.handle = handle
708 self.mgr = mgr
709 self.isarray = isarray
710
711 def __getitem__(self, index):
712 if self.isarray:
713 return Int(self.mgr, self.handle[index])
714 raise TypeError, "iteration over non-sequence"
715
716class UnsignedShort(Number):
717 def __init__(self, mgr, handle, isarray = False):
718 self.handle = handle
719 self.mgr = mgr
720 self.isarray = isarray
721
722 def __getitem__(self, index):
723 if self.isarray:
724 return UnsignedShort(self.mgr, self.handle[index])
725 raise TypeError, "iteration over non-sequence"
726
727class Short(Number):
728 def __init__(self, mgr, handle, isarray = False):
729 self.handle = handle
730 self.mgr = mgr
731 self.isarray = isarray
732
733 def __getitem__(self, index):
734 if self.isarray:
735 return Short(self.mgr, self.handle[index])
736 raise TypeError, "iteration over non-sequence"
737
738class UnsignedLong(Number):
739 def __init__(self, mgr, handle, isarray = False):
740 self.handle = handle
741 self.mgr = mgr
742 self.isarray = isarray
743
744 def __getitem__(self, index):
745 if self.isarray:
746 return UnsignedLong(self.mgr, self.handle[index])
747 raise TypeError, "iteration over non-sequence"
748
749class Long(Number):
750 def __init__(self, mgr, handle, isarray = False):
751 self.handle = handle
752 self.mgr = mgr
753 self.isarray = isarray
754
755 def __getitem__(self, index):
756 if self.isarray:
757 return Long(self.mgr, self.handle[index])
758 raise TypeError, "iteration over non-sequence"
759
760class Double(Number):
761 def __init__(self, mgr, handle, isarray = False):
762 self.handle = handle
763 self.mgr = mgr
764 self.isarray = isarray
765
766 def __getitem__(self, index):
767 if self.isarray:
768 return Double(self.mgr, self.handle[index])
769 raise TypeError, "iteration over non-sequence"
770
771class Float(Number):
772 def __init__(self, mgr, handle, isarray = False):
773 self.handle = handle
774 self.mgr = mgr
775 self.isarray = isarray
776
777 def __getitem__(self, index):
778 if self.isarray:
779 return Float(self.mgr, self.handle[index])
780 raise TypeError, "iteration over non-sequence"
781
782class IUnknown:
783 def __init__(self, mgr, handle, isarray = False):
784 self.handle = handle
785 self.mgr = mgr
786 self.isarray = isarray
787
788 def __nonzero__(self):
789 if self.handle != "":
790 return True
791 else:
792 return False
793
794 def __next(self):
795 if self.isarray:
796 return self.handle.__next()
797 raise TypeError, "iteration over non-sequence"
798
799 def __size(self):
800 if self.isarray:
801 return self.handle.__size()
802 raise TypeError, "iteration over non-sequence"
803
804 def __len__(self):
805 if self.isarray:
806 return self.handle.__len__()
807 raise TypeError, "iteration over non-sequence"
808
809 def __getitem__(self, index):
810 if self.isarray:
811 return IUnknown(self.mgr, self.handle[index])
812 raise TypeError, "iteration over non-sequence"
813
814 def __str__(self):
815 return str(self.handle)
816
817 def __eq__(self, other):
818 return self.handle == other
819
820 def __ne__(self, other):
821 return self.handle != other
822
823 def __getattr__(self,attr):
824 if self.__class__.__dict__.get(attr) != None:
825 return self.__class__.__dict__.get(attr)
826 if self.__dict__.get(attr) != None:
827 return self.__dict__.get(attr)
828 raise AttributeError
829
830</xsl:text>
831 <xsl:for-each select="//interface[@wsmap='managed' or @wsmap='global']">
832 <xsl:call-template name="interface"/>
833 </xsl:for-each>
834 <xsl:for-each select="//interface[@wsmap='struct']">
835 <xsl:call-template name="interfacestruct"/>
836 </xsl:for-each>
837 <xsl:for-each select="//collection">
838 <xsl:call-template name="collection"/>
839 </xsl:for-each>
840 <xsl:for-each select="//enum">
841 <xsl:call-template name="enum"/>
842 </xsl:for-each>
843
844class IWebsessionManager2(IWebsessionManager):
845 def __init__(self, url):
846 self.url = url
847 self.port = None
848 self.handle = None
849 self.mgr = self
850
851 def getPort(self):
852 if self.port is None:
853 self.port = vboxServiceLocator().getvboxPortType(self.url)
854 return self.port
855
856</xsl:template>
857
858</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