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-php.xsl:
|
---|
8 | XSLT stylesheet that generates vboxServiceWrappers.php from
|
---|
9 | VirtualBox.xidl. This PHP file represents our
|
---|
10 | web service API. Depends on WSDL file for actual SOAP bindings.
|
---|
11 |
|
---|
12 | Contributed by James Lucas (mjlucas at eng.uts.edu.au).
|
---|
13 |
|
---|
14 | Copyright (C) 2009 Sun Microsystems, Inc.
|
---|
15 |
|
---|
16 | This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
17 | available from http://www.virtualbox.org. This file is free software;
|
---|
18 | you can redistribute it and/or modify it under the terms of the GNU
|
---|
19 | General Public License (GPL) as published by the Free Software
|
---|
20 | Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
21 | VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
22 | hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
23 |
|
---|
24 | Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
25 | Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
26 | additional information or have any questions.
|
---|
27 | -->
|
---|
28 |
|
---|
29 |
|
---|
30 | <xsl:output
|
---|
31 | method="text"
|
---|
32 | version="1.0"
|
---|
33 | encoding="utf-8"
|
---|
34 | indent="no"/>
|
---|
35 |
|
---|
36 | <xsl:include href="websrv-shared.inc.xsl" />
|
---|
37 |
|
---|
38 | <xsl:variable name="G_setSuppressedInterfaces"
|
---|
39 | select="//interface[@wsmap='suppress']" />
|
---|
40 |
|
---|
41 | <xsl:template name="emitOutParam">
|
---|
42 | <xsl:param name="type" />
|
---|
43 | <xsl:param name="value" />
|
---|
44 | <xsl:param name="safearray" />
|
---|
45 |
|
---|
46 | <xsl:choose>
|
---|
47 | <xsl:when test="$type='wstring' or $type='uuid'">
|
---|
48 | <xsl:call-template name="emitPrimitive">
|
---|
49 | <xsl:with-param name="type">string</xsl:with-param>
|
---|
50 | <xsl:with-param name="value" select="$value" />
|
---|
51 | <xsl:with-param name="safearray" select="$safearray"/>
|
---|
52 | </xsl:call-template>
|
---|
53 | </xsl:when>
|
---|
54 | <xsl:when test="$type='boolean'">
|
---|
55 | <xsl:call-template name="emitPrimitive">
|
---|
56 | <xsl:with-param name="type">bool</xsl:with-param>
|
---|
57 | <xsl:with-param name="value" select="$value" />
|
---|
58 | <xsl:with-param name="safearray" select="$safearray"/>
|
---|
59 | </xsl:call-template>
|
---|
60 | </xsl:when>
|
---|
61 | <xsl:when test="$type='long' or $type='unsigned long' or $type='long long' or $type='short' or $type='unsigned short' or $type='unsigned long long' or $type='result'">
|
---|
62 | <xsl:call-template name="emitPrimitive">
|
---|
63 | <xsl:with-param name="type">int</xsl:with-param>
|
---|
64 | <xsl:with-param name="value" select="$value" />
|
---|
65 | <xsl:with-param name="safearray" select="$safearray"/>
|
---|
66 | </xsl:call-template>
|
---|
67 | </xsl:when>
|
---|
68 | <xsl:when test="$type='double' or $type='float'">
|
---|
69 | <xsl:call-template name="emitPrimitive">
|
---|
70 | <xsl:with-param name="type">float</xsl:with-param>
|
---|
71 | <xsl:with-param name="value" select="$value" />
|
---|
72 | <xsl:with-param name="safearray" select="$safearray"/>
|
---|
73 | </xsl:call-template>
|
---|
74 | </xsl:when>
|
---|
75 | <xsl:when test="$type='octet'">
|
---|
76 | <xsl:call-template name="emitPrimitive">
|
---|
77 | <xsl:with-param name="type">octet</xsl:with-param>
|
---|
78 | <xsl:with-param name="value" select="$value" />
|
---|
79 | <xsl:with-param name="safearray" select="$safearray"/>
|
---|
80 | </xsl:call-template>
|
---|
81 | </xsl:when>
|
---|
82 | <xsl:when test="$type='$unknown'">
|
---|
83 | <xsl:call-template name="emitObject">
|
---|
84 | <xsl:with-param name="type">VBox_ManagedObject</xsl:with-param>
|
---|
85 | <xsl:with-param name="value" select="$value" />
|
---|
86 | <xsl:with-param name="safearray" select="$safearray"/>
|
---|
87 | </xsl:call-template>
|
---|
88 | </xsl:when>
|
---|
89 | <xsl:otherwise>
|
---|
90 | <xsl:call-template name="emitObject">
|
---|
91 | <xsl:with-param name="type" select="$type" />
|
---|
92 | <xsl:with-param name="value" select="$value" />
|
---|
93 | <xsl:with-param name="safearray" select="$safearray"/>
|
---|
94 | </xsl:call-template>
|
---|
95 | </xsl:otherwise>
|
---|
96 | </xsl:choose>
|
---|
97 | </xsl:template>
|
---|
98 |
|
---|
99 | <xsl:template name="emitObject">
|
---|
100 | <xsl:param name="type" />
|
---|
101 | <xsl:param name="value" />
|
---|
102 | <xsl:param name="safearray" />
|
---|
103 | <xsl:choose>
|
---|
104 | <xsl:when test="$safearray='yes'">
|
---|
105 | <xsl:text>new </xsl:text><xsl:value-of select="$type" />Collection ($this->connection, (array)<xsl:value-of select="$value"/><xsl:text>)</xsl:text>
|
---|
106 | </xsl:when>
|
---|
107 | <xsl:otherwise>
|
---|
108 | <xsl:text>new </xsl:text><xsl:value-of select="$type" /> ($this->connection, <xsl:value-of select="$value"/><xsl:text>)</xsl:text>
|
---|
109 | </xsl:otherwise>
|
---|
110 | </xsl:choose>
|
---|
111 | </xsl:template>
|
---|
112 |
|
---|
113 | <xsl:template name="emitPrimitive">
|
---|
114 | <xsl:param name="type" />
|
---|
115 | <xsl:param name="value" />
|
---|
116 | <xsl:param name="safearray" />
|
---|
117 | <xsl:choose>
|
---|
118 | <xsl:when test="$safearray='yes'">
|
---|
119 | <xsl:text>(array)</xsl:text><xsl:value-of select="$value"/>
|
---|
120 | </xsl:when>
|
---|
121 | <xsl:otherwise>
|
---|
122 | <xsl:text>(</xsl:text><xsl:value-of select="$type" /><xsl:text>)</xsl:text><xsl:value-of select="$value"/>
|
---|
123 | </xsl:otherwise>
|
---|
124 | </xsl:choose>
|
---|
125 | </xsl:template>
|
---|
126 |
|
---|
127 | <xsl:template name="emitGetAttribute">
|
---|
128 | <xsl:param name="ifname" />
|
---|
129 | <xsl:param name="attrname" />
|
---|
130 | <xsl:param name="attrtype" />
|
---|
131 | <xsl:param name="attrsafearray" />
|
---|
132 | <xsl:variable name="fname"><xsl:call-template name="makeGetterName"><xsl:with-param name="attrname" select="$attrname"/></xsl:call-template> </xsl:variable>
|
---|
133 | public function <xsl:value-of select="$fname"/>() {
|
---|
134 | $request = new stdClass();
|
---|
135 | $request->_this = $this->handle;
|
---|
136 | $response = $this->connection->__soapCall('<xsl:value-of select="$ifname"/>_<xsl:value-of select="$fname"/>', array((array)$request));
|
---|
137 | <xsl:text>return </xsl:text>
|
---|
138 | <xsl:call-template name="emitOutParam">
|
---|
139 | <xsl:with-param name="type" select="$attrtype" />
|
---|
140 | <xsl:with-param name="value" select="concat('$response->','returnval')" />
|
---|
141 | <xsl:with-param name="safearray" select="@safearray"/>
|
---|
142 | </xsl:call-template><xsl:text>;</xsl:text>
|
---|
143 | }
|
---|
144 | </xsl:template>
|
---|
145 |
|
---|
146 | <xsl:template name="emitSetAttribute">
|
---|
147 | <xsl:param name="ifname" />
|
---|
148 | <xsl:param name="attrname" />
|
---|
149 | <xsl:param name="attrtype" />
|
---|
150 | <xsl:param name="attrsafearray" />
|
---|
151 | <xsl:variable name="fname"><xsl:call-template name="makeSetterName"><xsl:with-param name="attrname" select="$attrname"/></xsl:call-template></xsl:variable>
|
---|
152 | public function <xsl:value-of select="$fname"/>($value) {
|
---|
153 | $request = new stdClass();
|
---|
154 | $request->_this = $this->handle;
|
---|
155 | if (is_int($value) || is_string($value) || is_bool($value)) {
|
---|
156 | $request-><xsl:value-of select="$attrname"/> = $value;
|
---|
157 | }
|
---|
158 | else
|
---|
159 | {
|
---|
160 | $request-><xsl:value-of select="$attrname"/> = $value->handle;
|
---|
161 | }
|
---|
162 | $this->connection->__soapCall('<xsl:value-of select="$ifname"/>_<xsl:value-of select="$fname"/>', array((array)$request));
|
---|
163 | }
|
---|
164 | </xsl:template>
|
---|
165 |
|
---|
166 | <xsl:template name="interface">
|
---|
167 | <xsl:variable name="ifname"><xsl:value-of select="@name" /></xsl:variable>
|
---|
168 | <xsl:variable name="wsmap"><xsl:value-of select="@wsmap" /></xsl:variable>
|
---|
169 | <xsl:variable name="extends"><xsl:value-of select="@extends" /></xsl:variable>
|
---|
170 | <xsl:text>
|
---|
171 | /**
|
---|
172 | * Generated VBoxWebService Interface Wrapper
|
---|
173 | */
|
---|
174 | </xsl:text>
|
---|
175 | <xsl:choose>
|
---|
176 | <xsl:when test="($extends = '$unknown') or ($extends = '$dispatched') or ($extends = '$errorinfo')">
|
---|
177 | <xsl:value-of select="concat('class ', $ifname, ' extends VBox_ManagedObject { ')" />
|
---|
178 | </xsl:when>
|
---|
179 | <xsl:when test="//interface[@name=$extends]">
|
---|
180 | <xsl:value-of select="concat('class ', $ifname, ' extends ', $extends, ' { ')" />
|
---|
181 | </xsl:when>
|
---|
182 | </xsl:choose>
|
---|
183 | <xsl:for-each select="method">
|
---|
184 | <xsl:if test="not((param[@type=($G_setSuppressedInterfaces/@name)])
|
---|
185 | or (param[@mod='ptr']))" >
|
---|
186 | <xsl:call-template name="method">
|
---|
187 | <xsl:with-param name="wsmap" select="$wsmap" />
|
---|
188 | </xsl:call-template>
|
---|
189 | </xsl:if>
|
---|
190 | </xsl:for-each>
|
---|
191 | <xsl:for-each select="attribute">
|
---|
192 | <xsl:variable name="attrname"><xsl:value-of select="@name" /></xsl:variable>
|
---|
193 | <xsl:variable name="attrtype"><xsl:value-of select="@type" /></xsl:variable>
|
---|
194 | <xsl:variable name="attrreadonly"><xsl:value-of select="@readonly" /></xsl:variable>
|
---|
195 | <!-- skip this attribute if it has parameters of a type that has wsmap="suppress" -->
|
---|
196 | <xsl:choose>
|
---|
197 | <xsl:when test="( $attrtype=($G_setSuppressedInterfaces/@name) )">
|
---|
198 | <xsl:comment><xsl:value-of select="concat('skipping attribute ', $attrtype, ' for it is of a suppressed type')" /></xsl:comment>
|
---|
199 | </xsl:when>
|
---|
200 | <xsl:otherwise>
|
---|
201 | <xsl:choose>
|
---|
202 | <xsl:when test="@readonly='yes'">
|
---|
203 | <xsl:comment> readonly attribute <xsl:copy-of select="$ifname" />::<xsl:copy-of select="$attrname" /> </xsl:comment>
|
---|
204 | </xsl:when>
|
---|
205 | <xsl:otherwise>
|
---|
206 | <xsl:comment> read/write attribute <xsl:copy-of select="$ifname" />::<xsl:copy-of select="$attrname" /> </xsl:comment>
|
---|
207 | </xsl:otherwise>
|
---|
208 | </xsl:choose>
|
---|
209 | <!-- aa) get method: emit request and result -->
|
---|
210 | <xsl:call-template name="emitGetAttribute">
|
---|
211 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
212 | <xsl:with-param name="attrname" select="$attrname" />
|
---|
213 | <xsl:with-param name="attrtype" select="$attrtype" />
|
---|
214 | </xsl:call-template>
|
---|
215 | <!-- bb) emit a set method if the attribute is read/write -->
|
---|
216 | <xsl:if test="not($attrreadonly='yes')">
|
---|
217 | <xsl:call-template name="emitSetAttribute">
|
---|
218 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
219 | <xsl:with-param name="attrname" select="$attrname" />
|
---|
220 | <xsl:with-param name="attrtype" select="$attrtype" />
|
---|
221 | </xsl:call-template>
|
---|
222 | </xsl:if>
|
---|
223 | </xsl:otherwise>
|
---|
224 | </xsl:choose>
|
---|
225 | </xsl:for-each>
|
---|
226 | <xsl:text>}
|
---|
227 | </xsl:text>
|
---|
228 | </xsl:template>
|
---|
229 |
|
---|
230 | <xsl:template name="collection">
|
---|
231 | <xsl:variable name="ifname"><xsl:value-of select="@name" /></xsl:variable>
|
---|
232 | <xsl:text>
|
---|
233 | /**
|
---|
234 | * Generated VBoxWebService Managed Object Collection
|
---|
235 | */</xsl:text>
|
---|
236 | class <xsl:value-of select="$ifname"/>Collection extends VBox_ManagedObjectCollection {
|
---|
237 | protected $_interfaceName = "<xsl:value-of select="$ifname"/>";
|
---|
238 | }
|
---|
239 | </xsl:template>
|
---|
240 |
|
---|
241 | <xsl:template name="interfacestruct">
|
---|
242 | <xsl:variable name="ifname"><xsl:value-of select="@name" /></xsl:variable>
|
---|
243 | <xsl:text>
|
---|
244 | /**
|
---|
245 | * Generated VBoxWebService Struct
|
---|
246 | */</xsl:text>
|
---|
247 | class <xsl:value-of select="$ifname"/> extends VBox_Struct {
|
---|
248 | <xsl:for-each select="attribute">
|
---|
249 | protected $<xsl:value-of select="@name"/>;
|
---|
250 | </xsl:for-each>
|
---|
251 | public function __construct($connection, $values) {
|
---|
252 | $this->connection = $connection;
|
---|
253 | <xsl:for-each select="attribute">
|
---|
254 | $this-><xsl:value-of select="@name"/> = $values-><xsl:value-of select="@name"/><xsl:text>;</xsl:text>
|
---|
255 | </xsl:for-each>
|
---|
256 | }
|
---|
257 |
|
---|
258 | <xsl:for-each select="attribute">
|
---|
259 | public function <xsl:call-template name="makeGetterName"><xsl:with-param name="attrname" select="@name"/></xsl:call-template>() {
|
---|
260 | <xsl:text>return </xsl:text>
|
---|
261 | <xsl:call-template name="emitOutParam">
|
---|
262 | <xsl:with-param name="type" select="@type" />
|
---|
263 | <xsl:with-param name="value" select="concat('$this->',@name)" />
|
---|
264 | <xsl:with-param name="safearray" select="@safearray"/>
|
---|
265 | </xsl:call-template>;
|
---|
266 | }
|
---|
267 | </xsl:for-each>
|
---|
268 |
|
---|
269 | }
|
---|
270 | </xsl:template>
|
---|
271 |
|
---|
272 | <xsl:template name="genreq">
|
---|
273 | <xsl:param name="wsmap" />
|
---|
274 | <xsl:text>$request = new stdClass()</xsl:text>;
|
---|
275 | <xsl:if test="$wsmap='managed'">
|
---|
276 | $request->_this = $this->handle;
|
---|
277 | </xsl:if>
|
---|
278 | <xsl:for-each select="param[@dir='in']">
|
---|
279 | $request-><xsl:value-of select="@name" /> = $arg_<xsl:value-of select="@name" /><xsl:text>;</xsl:text>
|
---|
280 | </xsl:for-each>
|
---|
281 | $response = $this->connection->__soapCall('<xsl:value-of select="../@name"/>_<xsl:value-of select="@name"/>', array((array)$request));
|
---|
282 | <!-- return needs to be the first one -->
|
---|
283 | return <xsl:if test="param[@dir='out']">
|
---|
284 | <xsl:text>array(</xsl:text>
|
---|
285 | </xsl:if>
|
---|
286 | <xsl:for-each select="param[@dir='return']">
|
---|
287 | <xsl:call-template name="emitOutParam">
|
---|
288 | <xsl:with-param name="type" select="@type" />
|
---|
289 | <xsl:with-param name="value" select="concat('$response->','returnval')" />
|
---|
290 | <xsl:with-param name="safearray" select="@safearray"/>
|
---|
291 | </xsl:call-template>
|
---|
292 | <xsl:if test="../param[@dir='out']">
|
---|
293 | <xsl:text>, </xsl:text>
|
---|
294 | </xsl:if>
|
---|
295 | </xsl:for-each>
|
---|
296 | <xsl:for-each select="param[@dir='out']">
|
---|
297 | <xsl:if test="not(position()=1)">
|
---|
298 | <xsl:text>, </xsl:text>
|
---|
299 | </xsl:if>
|
---|
300 | <xsl:call-template name="emitOutParam">
|
---|
301 | <xsl:with-param name="type" select="@type" />
|
---|
302 | <xsl:with-param name="value" select="concat('$response->',@name)" />
|
---|
303 | <xsl:with-param name="safearray" select="@safearray"/>
|
---|
304 | </xsl:call-template>
|
---|
305 | </xsl:for-each>
|
---|
306 | <xsl:if test="param[@dir='out']">
|
---|
307 | <xsl:text>)</xsl:text>
|
---|
308 | </xsl:if>
|
---|
309 | <xsl:text>; </xsl:text>
|
---|
310 | </xsl:template>
|
---|
311 |
|
---|
312 | <xsl:template name="method" >
|
---|
313 | <xsl:param name="wsmap" />
|
---|
314 | public function <xsl:value-of select="@name"/><xsl:text>(</xsl:text>
|
---|
315 | <xsl:for-each select="param[@dir='in']">
|
---|
316 | <xsl:if test="not(position()=1)">
|
---|
317 | <xsl:text>, </xsl:text>
|
---|
318 | </xsl:if>
|
---|
319 | <xsl:value-of select="concat('$arg_',@name)"/>
|
---|
320 | </xsl:for-each><xsl:text>) { </xsl:text>
|
---|
321 | <xsl:call-template name="genreq"><xsl:with-param name="wsmap" select="$wsmap" /></xsl:call-template>
|
---|
322 | <xsl:text> } </xsl:text>
|
---|
323 | </xsl:template>
|
---|
324 |
|
---|
325 | <xsl:template name="enum">
|
---|
326 | <xsl:text>
|
---|
327 | /**
|
---|
328 | * Generated VBoxWebService ENUM
|
---|
329 | */</xsl:text>
|
---|
330 | class <xsl:value-of select="@name"/> extends VBox_Enum {
|
---|
331 | public $NameMap = array(<xsl:for-each select="const"><xsl:if test="not(@wsmap='suppress')"><xsl:value-of select="@value"/> => '<xsl:value-of select="@name"/>'<xsl:if test="not(position()=last())">, </xsl:if></xsl:if></xsl:for-each>);
|
---|
332 | public $ValueMap = array(<xsl:for-each select="const"><xsl:if test="not(@wsmap='suppress')">'<xsl:value-of select="@name"/>' => <xsl:value-of select="@value"/><xsl:if test="not(position()=last())">, </xsl:if></xsl:if></xsl:for-each>);
|
---|
333 | }
|
---|
334 | </xsl:template>
|
---|
335 |
|
---|
336 | <xsl:template match="/">
|
---|
337 | <xsl:text><?php
|
---|
338 |
|
---|
339 | /*
|
---|
340 | * Copyright (C) 2009 Sun Microsystems, Inc.
|
---|
341 | *
|
---|
342 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
343 | * available from http://www.virtualbox.org. This file is free software;
|
---|
344 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
345 | * General Public License (GPL) as published by the Free Software
|
---|
346 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
347 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
348 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
349 | *
|
---|
350 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
351 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
352 | * additional information or have any questions.
|
---|
353 | *
|
---|
354 | * This file is autogenerated from VirtualBox.xidl, DO NOT EDIT!
|
---|
355 | */
|
---|
356 |
|
---|
357 | class VBox_ManagedObject
|
---|
358 | {
|
---|
359 | protected $connection;
|
---|
360 | protected $handle;
|
---|
361 |
|
---|
362 | public function __construct($soap, $handle = null)
|
---|
363 | {
|
---|
364 | $this->connection = $soap;
|
---|
365 | $this->handle = $handle;
|
---|
366 | }
|
---|
367 |
|
---|
368 | public function __toString()
|
---|
369 | {
|
---|
370 | return (string)$this->handle;
|
---|
371 | }
|
---|
372 |
|
---|
373 | public function __set($attr, $value)
|
---|
374 | {
|
---|
375 | $methodName = "set" . $attr;
|
---|
376 | if (method_exists($this, $methodName))
|
---|
377 | $this->$methodName($value);
|
---|
378 | else
|
---|
379 | throw new Exception("Attribute does not exist");
|
---|
380 | }
|
---|
381 |
|
---|
382 | public function __get($attr)
|
---|
383 | {
|
---|
384 | $methodName = "get" . $attr;
|
---|
385 | if (method_exists($this, $methodName))
|
---|
386 | return $this->$methodName();
|
---|
387 | else
|
---|
388 | throw new Exception("Attribute does not exist");
|
---|
389 | }
|
---|
390 |
|
---|
391 | public function getHandle()
|
---|
392 | {
|
---|
393 | return $this->handle;
|
---|
394 | }
|
---|
395 |
|
---|
396 | public function cast($class)
|
---|
397 | {
|
---|
398 | if (is_subclass_of($class, 'VBox_ManagedObject'))
|
---|
399 | {
|
---|
400 | return new $class($this->connection, $this->handle);
|
---|
401 | }
|
---|
402 | throw new Exception('Cannot cast VBox_ManagedObject to non-child class VBox_ManagedObject');
|
---|
403 | }
|
---|
404 |
|
---|
405 | public function releaseRemote()
|
---|
406 | {
|
---|
407 | try
|
---|
408 | {
|
---|
409 | $request = new stdClass();
|
---|
410 | $request->_this = $this->handle;
|
---|
411 | $this->connection->__soapCall('IManagedObjectRef_release', array((array)$request));
|
---|
412 | } catch (Exception $ex) {}
|
---|
413 | }
|
---|
414 | }
|
---|
415 |
|
---|
416 | class VBox_ManagedObjectCollection implements Iterator, Countable {
|
---|
417 | protected $connection;
|
---|
418 | protected $handles;
|
---|
419 | protected $_interfaceName = null;
|
---|
420 |
|
---|
421 | public function __construct($soap, array $handles = array())
|
---|
422 | {
|
---|
423 | $this->connection = $soap;
|
---|
424 | $this->handles = $handles;
|
---|
425 | }
|
---|
426 |
|
---|
427 | public function rewind() {
|
---|
428 | reset($this->handles);
|
---|
429 | }
|
---|
430 |
|
---|
431 | public function current() {
|
---|
432 | $handle = current($this->handles);
|
---|
433 | if ($handle !== false && !$handle instanceof $this->_interfaceName) {
|
---|
434 | $handle = new $this->_interfaceName($this->connection, $handle);
|
---|
435 | }
|
---|
436 | return $handle;
|
---|
437 | }
|
---|
438 |
|
---|
439 | public function key() {
|
---|
440 | $handle = key($this->handles);
|
---|
441 | return $handle;
|
---|
442 | }
|
---|
443 |
|
---|
444 | public function next() {
|
---|
445 | $handle = next($this->handles);
|
---|
446 | return $handle;
|
---|
447 | }
|
---|
448 |
|
---|
449 | public function valid() {
|
---|
450 | $handle = $this->current() !== false;
|
---|
451 | return $handle;
|
---|
452 | }
|
---|
453 |
|
---|
454 | public function count() {
|
---|
455 | return count($this->handles);
|
---|
456 | }
|
---|
457 | }
|
---|
458 |
|
---|
459 | abstract class VBox_Struct {
|
---|
460 | protected $connection;
|
---|
461 |
|
---|
462 | public function __get($attr)
|
---|
463 | {
|
---|
464 | $methodName = "get" . $attr;
|
---|
465 | if (method_exists($this, $methodName))
|
---|
466 | return $this->$methodName();
|
---|
467 | else
|
---|
468 | throw new Exception("Attribute does not exist");
|
---|
469 | }
|
---|
470 | }
|
---|
471 |
|
---|
472 | abstract class VBox_Enum {
|
---|
473 | protected $handle;
|
---|
474 |
|
---|
475 | public function __construct($connection, $handle)
|
---|
476 | {
|
---|
477 | if (is_string($handle))
|
---|
478 | $this->handle = $this->ValueMap[$handle];
|
---|
479 | else
|
---|
480 | $this->handle = $handle;
|
---|
481 | }
|
---|
482 |
|
---|
483 | public function __toString()
|
---|
484 | {
|
---|
485 | return (string)$this->NameMap[$this->handle];
|
---|
486 | }
|
---|
487 | }
|
---|
488 |
|
---|
489 | </xsl:text>
|
---|
490 | <xsl:for-each select="//interface[@wsmap='managed' or @wsmap='global']">
|
---|
491 | <xsl:call-template name="interface"/>
|
---|
492 | <xsl:call-template name="collection"/>
|
---|
493 | </xsl:for-each>
|
---|
494 | <xsl:for-each select="//interface[@wsmap='struct']">
|
---|
495 | <xsl:call-template name="interfacestruct"/>
|
---|
496 | <xsl:call-template name="collection"/>
|
---|
497 | </xsl:for-each>
|
---|
498 | <xsl:for-each select="//enum">
|
---|
499 | <xsl:call-template name="enum"/>
|
---|
500 | <xsl:call-template name="collection"/>
|
---|
501 | </xsl:for-each>
|
---|
502 |
|
---|
503 | </xsl:template>
|
---|
504 |
|
---|
505 | </xsl:stylesheet>
|
---|