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