[22379] | 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 | websrv-php.xsl:
|
---|
| 7 | XSLT stylesheet that generates vboxServiceWrappers.php from
|
---|
| 8 | VirtualBox.xidl. This PHP file represents our
|
---|
| 9 | web service API. Depends on WSDL file for actual SOAP bindings.
|
---|
| 10 |
|
---|
[28823] | 11 | Contributed by James Lucas (mjlucas at eng.uts.edu.au).
|
---|
[96308] | 12 | -->
|
---|
| 13 | <!--
|
---|
[106061] | 14 | Copyright (C) 2008-2024 Oracle and/or its affiliates.
|
---|
[22379] | 15 |
|
---|
[96407] | 16 | This file is part of VirtualBox base platform packages, as
|
---|
| 17 | available from https://www.virtualbox.org.
|
---|
| 18 |
|
---|
| 19 | This program is free software; you can redistribute it and/or
|
---|
| 20 | modify it under the terms of the GNU General Public License
|
---|
| 21 | as published by the Free Software Foundation, in version 3 of the
|
---|
| 22 | License.
|
---|
| 23 |
|
---|
| 24 | This program is distributed in the hope that it will be useful, but
|
---|
| 25 | WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 26 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 27 | General Public License for more details.
|
---|
| 28 |
|
---|
| 29 | You should have received a copy of the GNU General Public License
|
---|
| 30 | along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
| 31 |
|
---|
| 32 | SPDX-License-Identifier: GPL-3.0-only
|
---|
[22379] | 33 | -->
|
---|
| 34 |
|
---|
| 35 |
|
---|
| 36 | <xsl:output
|
---|
| 37 | method="text"
|
---|
| 38 | version="1.0"
|
---|
| 39 | encoding="utf-8"
|
---|
| 40 | indent="no"/>
|
---|
| 41 |
|
---|
[45483] | 42 | <xsl:include href="../idl/typemap-shared.inc.xsl" />
|
---|
[22379] | 43 |
|
---|
[106065] | 44 | <!-- Global parameters. -->
|
---|
| 45 | <xsl:param name="g_uVBoxCopyrightYear">2024</xsl:param>
|
---|
| 46 |
|
---|
[22379] | 47 | <xsl:variable name="G_setSuppressedInterfaces"
|
---|
| 48 | select="//interface[@wsmap='suppress']" />
|
---|
| 49 |
|
---|
[53929] | 50 | <xsl:key name="G_keyInterfacesByName" match="//interface[@name]" use="@name"/>
|
---|
| 51 |
|
---|
[22379] | 52 | <xsl:template name="emitOutParam">
|
---|
| 53 | <xsl:param name="type" />
|
---|
| 54 | <xsl:param name="value" />
|
---|
| 55 | <xsl:param name="safearray" />
|
---|
| 56 |
|
---|
| 57 | <xsl:choose>
|
---|
[27646] | 58 | <xsl:when test="$type='wstring' or $type='uuid'">
|
---|
| 59 | <xsl:call-template name="emitPrimitive">
|
---|
| 60 | <xsl:with-param name="type">string</xsl:with-param>
|
---|
| 61 | <xsl:with-param name="value" select="$value" />
|
---|
| 62 | <xsl:with-param name="safearray" select="$safearray"/>
|
---|
| 63 | </xsl:call-template>
|
---|
| 64 | </xsl:when>
|
---|
| 65 | <xsl:when test="$type='boolean'">
|
---|
| 66 | <xsl:call-template name="emitPrimitive">
|
---|
| 67 | <xsl:with-param name="type">bool</xsl:with-param>
|
---|
| 68 | <xsl:with-param name="value" select="$value" />
|
---|
| 69 | <xsl:with-param name="safearray" select="$safearray"/>
|
---|
| 70 | </xsl:call-template>
|
---|
| 71 | </xsl:when>
|
---|
[28823] | 72 | <xsl:when test="$type='short' or $type='unsigned short' or $type='long' or $type='octet'">
|
---|
[27646] | 73 | <xsl:call-template name="emitPrimitive">
|
---|
| 74 | <xsl:with-param name="type">int</xsl:with-param>
|
---|
| 75 | <xsl:with-param name="value" select="$value" />
|
---|
| 76 | <xsl:with-param name="safearray" select="$safearray"/>
|
---|
| 77 | </xsl:call-template>
|
---|
| 78 | </xsl:when>
|
---|
[28823] | 79 | <xsl:when test="$type='double' or $type='float' or $type='unsigned long' or $type='long long' or $type='unsigned long long'">
|
---|
[27646] | 80 | <xsl:call-template name="emitPrimitive">
|
---|
| 81 | <xsl:with-param name="type">float</xsl:with-param>
|
---|
| 82 | <xsl:with-param name="value" select="$value" />
|
---|
| 83 | <xsl:with-param name="safearray" select="$safearray"/>
|
---|
| 84 | </xsl:call-template>
|
---|
| 85 | </xsl:when>
|
---|
| 86 | <xsl:when test="$type='$unknown'">
|
---|
| 87 | <xsl:call-template name="emitObject">
|
---|
| 88 | <xsl:with-param name="type">VBox_ManagedObject</xsl:with-param>
|
---|
| 89 | <xsl:with-param name="value" select="$value" />
|
---|
| 90 | <xsl:with-param name="safearray" select="$safearray"/>
|
---|
[28823] | 91 | </xsl:call-template>
|
---|
[27646] | 92 | </xsl:when>
|
---|
[22379] | 93 | <xsl:otherwise>
|
---|
[27646] | 94 | <xsl:call-template name="emitObject">
|
---|
| 95 | <xsl:with-param name="type" select="$type" />
|
---|
| 96 | <xsl:with-param name="value" select="$value" />
|
---|
| 97 | <xsl:with-param name="safearray" select="$safearray"/>
|
---|
[28823] | 98 | </xsl:call-template>
|
---|
[22379] | 99 | </xsl:otherwise>
|
---|
| 100 | </xsl:choose>
|
---|
| 101 | </xsl:template>
|
---|
| 102 |
|
---|
[27646] | 103 | <xsl:template name="emitObject">
|
---|
| 104 | <xsl:param name="type" />
|
---|
| 105 | <xsl:param name="value" />
|
---|
| 106 | <xsl:param name="safearray" />
|
---|
| 107 | <xsl:choose>
|
---|
| 108 | <xsl:when test="$safearray='yes'">
|
---|
| 109 | <xsl:text>new </xsl:text><xsl:value-of select="$type" />Collection ($this->connection, (array)<xsl:value-of select="$value"/><xsl:text>)</xsl:text>
|
---|
| 110 | </xsl:when>
|
---|
| 111 | <xsl:otherwise>
|
---|
| 112 | <xsl:text>new </xsl:text><xsl:value-of select="$type" /> ($this->connection, <xsl:value-of select="$value"/><xsl:text>)</xsl:text>
|
---|
| 113 | </xsl:otherwise>
|
---|
| 114 | </xsl:choose>
|
---|
| 115 | </xsl:template>
|
---|
| 116 |
|
---|
| 117 | <xsl:template name="emitPrimitive">
|
---|
| 118 | <xsl:param name="type" />
|
---|
| 119 | <xsl:param name="value" />
|
---|
| 120 | <xsl:param name="safearray" />
|
---|
| 121 | <xsl:choose>
|
---|
| 122 | <xsl:when test="$safearray='yes'">
|
---|
| 123 | <xsl:text>(array)</xsl:text><xsl:value-of select="$value"/>
|
---|
| 124 | </xsl:when>
|
---|
| 125 | <xsl:otherwise>
|
---|
| 126 | <xsl:text>(</xsl:text><xsl:value-of select="$type" /><xsl:text>)</xsl:text><xsl:value-of select="$value"/>
|
---|
| 127 | </xsl:otherwise>
|
---|
| 128 | </xsl:choose>
|
---|
| 129 | </xsl:template>
|
---|
| 130 |
|
---|
[22379] | 131 | <xsl:template name="emitGetAttribute">
|
---|
| 132 | <xsl:param name="ifname" />
|
---|
| 133 | <xsl:param name="attrname" />
|
---|
| 134 | <xsl:param name="attrtype" />
|
---|
| 135 | <xsl:param name="attrsafearray" />
|
---|
| 136 | <xsl:variable name="fname"><xsl:call-template name="makeGetterName"><xsl:with-param name="attrname" select="$attrname"/></xsl:call-template> </xsl:variable>
|
---|
[43546] | 137 | public function <xsl:value-of select="$fname"/>()
|
---|
| 138 | {
|
---|
| 139 | $request = new stdClass();
|
---|
| 140 | $request->_this = $this->handle;
|
---|
| 141 | $response = $this->connection->__soapCall('<xsl:value-of select="$ifname"/>_<xsl:value-of select="$fname"/>', array((array)$request));
|
---|
| 142 | <xsl:text>return </xsl:text>
|
---|
| 143 | <xsl:call-template name="emitOutParam">
|
---|
| 144 | <xsl:with-param name="type" select="$attrtype" />
|
---|
| 145 | <xsl:with-param name="value" select="concat('$response->','returnval')" />
|
---|
| 146 | <xsl:with-param name="safearray" select="@safearray"/>
|
---|
| 147 | </xsl:call-template><xsl:text>;</xsl:text>
|
---|
| 148 | }
|
---|
[22379] | 149 | </xsl:template>
|
---|
| 150 |
|
---|
| 151 | <xsl:template name="emitSetAttribute">
|
---|
| 152 | <xsl:param name="ifname" />
|
---|
| 153 | <xsl:param name="attrname" />
|
---|
| 154 | <xsl:param name="attrtype" />
|
---|
| 155 | <xsl:param name="attrsafearray" />
|
---|
[23887] | 156 | <xsl:variable name="fname"><xsl:call-template name="makeSetterName"><xsl:with-param name="attrname" select="$attrname"/></xsl:call-template></xsl:variable>
|
---|
[43546] | 157 | public function <xsl:value-of select="$fname"/>($value)
|
---|
| 158 | {
|
---|
| 159 | $request = new stdClass();
|
---|
| 160 | $request->_this = $this->handle;
|
---|
| 161 | <xsl:choose>
|
---|
| 162 | <xsl:when test="$attrsafearray='yes'"> if (is_array($value) || is_null($value) || is_scalar($value))</xsl:when>
|
---|
| 163 | <xsl:otherwise> if (is_null($value) || is_scalar($value))</xsl:otherwise>
|
---|
| 164 | </xsl:choose>
|
---|
| 165 | {
|
---|
[22379] | 166 | $request-><xsl:value-of select="$attrname"/> = $value;
|
---|
[43546] | 167 | }
|
---|
| 168 | else
|
---|
| 169 | {
|
---|
[22379] | 170 | $request-><xsl:value-of select="$attrname"/> = $value->handle;
|
---|
[43546] | 171 | }
|
---|
| 172 | $this->connection->__soapCall('<xsl:value-of select="$ifname"/>_<xsl:value-of select="$fname"/>', array((array)$request));
|
---|
| 173 | }
|
---|
[22379] | 174 | </xsl:template>
|
---|
| 175 |
|
---|
| 176 | <xsl:template name="interface">
|
---|
| 177 | <xsl:variable name="ifname"><xsl:value-of select="@name" /></xsl:variable>
|
---|
| 178 | <xsl:variable name="wsmap"><xsl:value-of select="@wsmap" /></xsl:variable>
|
---|
[23887] | 179 | <xsl:variable name="extends"><xsl:value-of select="@extends" /></xsl:variable>
|
---|
[22379] | 180 | <xsl:text>
|
---|
| 181 | /**
|
---|
[43546] | 182 | * Generated VBoxWebService Interface Wrapper
|
---|
| 183 | */
|
---|
[23887] | 184 | </xsl:text>
|
---|
| 185 | <xsl:choose>
|
---|
[50183] | 186 | <xsl:when test="($extends = '$unknown') or ($extends = '$errorinfo')">
|
---|
[43546] | 187 | <xsl:value-of select="concat('class ', $ifname, ' extends VBox_ManagedObject { ')" />
|
---|
[23887] | 188 | </xsl:when>
|
---|
[53929] | 189 | <xsl:when test="count(key('G_keyInterfacesByName', $extends)) > 0">
|
---|
[43546] | 190 | <xsl:value-of select="concat('class ', $ifname, ' extends ', $extends, ' { ')" />
|
---|
[23887] | 191 | </xsl:when>
|
---|
| 192 | </xsl:choose>
|
---|
[22379] | 193 | <xsl:for-each select="method">
|
---|
[24906] | 194 | <xsl:if test="not((param[@type=($G_setSuppressedInterfaces/@name)])
|
---|
| 195 | or (param[@mod='ptr']))" >
|
---|
| 196 | <xsl:call-template name="method">
|
---|
| 197 | <xsl:with-param name="wsmap" select="$wsmap" />
|
---|
| 198 | </xsl:call-template>
|
---|
| 199 | </xsl:if>
|
---|
[22379] | 200 | </xsl:for-each>
|
---|
| 201 | <xsl:for-each select="attribute">
|
---|
| 202 | <xsl:variable name="attrname"><xsl:value-of select="@name" /></xsl:variable>
|
---|
| 203 | <xsl:variable name="attrtype"><xsl:value-of select="@type" /></xsl:variable>
|
---|
| 204 | <xsl:variable name="attrreadonly"><xsl:value-of select="@readonly" /></xsl:variable>
|
---|
[43546] | 205 | <xsl:variable name="attrsafearray"><xsl:value-of select="@safearray" /></xsl:variable>
|
---|
[22379] | 206 | <!-- skip this attribute if it has parameters of a type that has wsmap="suppress" -->
|
---|
| 207 | <xsl:choose>
|
---|
| 208 | <xsl:when test="( $attrtype=($G_setSuppressedInterfaces/@name) )">
|
---|
| 209 | <xsl:comment><xsl:value-of select="concat('skipping attribute ', $attrtype, ' for it is of a suppressed type')" /></xsl:comment>
|
---|
| 210 | </xsl:when>
|
---|
| 211 | <xsl:otherwise>
|
---|
| 212 | <xsl:choose>
|
---|
| 213 | <xsl:when test="@readonly='yes'">
|
---|
| 214 | <xsl:comment> readonly attribute <xsl:copy-of select="$ifname" />::<xsl:copy-of select="$attrname" /> </xsl:comment>
|
---|
| 215 | </xsl:when>
|
---|
| 216 | <xsl:otherwise>
|
---|
| 217 | <xsl:comment> read/write attribute <xsl:copy-of select="$ifname" />::<xsl:copy-of select="$attrname" /> </xsl:comment>
|
---|
| 218 | </xsl:otherwise>
|
---|
| 219 | </xsl:choose>
|
---|
| 220 | <!-- aa) get method: emit request and result -->
|
---|
| 221 | <xsl:call-template name="emitGetAttribute">
|
---|
| 222 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
| 223 | <xsl:with-param name="attrname" select="$attrname" />
|
---|
| 224 | <xsl:with-param name="attrtype" select="$attrtype" />
|
---|
[43546] | 225 | <xsl:with-param name="attrsafearray" select="$attrsafearray" />
|
---|
[22379] | 226 | </xsl:call-template>
|
---|
| 227 | <!-- bb) emit a set method if the attribute is read/write -->
|
---|
| 228 | <xsl:if test="not($attrreadonly='yes')">
|
---|
| 229 | <xsl:call-template name="emitSetAttribute">
|
---|
| 230 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
| 231 | <xsl:with-param name="attrname" select="$attrname" />
|
---|
| 232 | <xsl:with-param name="attrtype" select="$attrtype" />
|
---|
[43546] | 233 | <xsl:with-param name="attrsafearray" select="$attrsafearray" />
|
---|
[22379] | 234 | </xsl:call-template>
|
---|
| 235 | </xsl:if>
|
---|
| 236 | </xsl:otherwise>
|
---|
| 237 | </xsl:choose>
|
---|
| 238 | </xsl:for-each>
|
---|
| 239 | <xsl:text>}
|
---|
[43546] | 240 | </xsl:text>
|
---|
[22379] | 241 | </xsl:template>
|
---|
| 242 |
|
---|
| 243 | <xsl:template name="collection">
|
---|
| 244 | <xsl:variable name="ifname"><xsl:value-of select="@name" /></xsl:variable>
|
---|
| 245 | <xsl:text>
|
---|
| 246 | /**
|
---|
[43546] | 247 | * Generated VBoxWebService Managed Object Collection
|
---|
| 248 | */</xsl:text>
|
---|
| 249 | class <xsl:value-of select="$ifname"/>Collection extends VBox_ManagedObjectCollection
|
---|
| 250 | {
|
---|
| 251 | protected $_interfaceName = "<xsl:value-of select="$ifname"/>";
|
---|
[22379] | 252 | }
|
---|
| 253 | </xsl:template>
|
---|
| 254 |
|
---|
| 255 | <xsl:template name="interfacestruct">
|
---|
| 256 | <xsl:variable name="ifname"><xsl:value-of select="@name" /></xsl:variable>
|
---|
| 257 | <xsl:text>
|
---|
| 258 | /**
|
---|
[43546] | 259 | * Generated VBoxWebService Struct
|
---|
| 260 | */</xsl:text>
|
---|
| 261 | class <xsl:value-of select="$ifname"/> extends VBox_Struct
|
---|
| 262 | {
|
---|
| 263 | <xsl:for-each select="attribute"> protected $<xsl:value-of select="@name"/>;
|
---|
| 264 | </xsl:for-each>
|
---|
| 265 | public function __construct($connection, $values)
|
---|
| 266 | {
|
---|
| 267 | $this->connection = $connection;
|
---|
| 268 | <xsl:for-each select="attribute"> $this-><xsl:value-of select="@name"/> = $values-><xsl:value-of select="@name"/>;
|
---|
| 269 | </xsl:for-each> }
|
---|
[22379] | 270 |
|
---|
[43546] | 271 | <xsl:for-each select="attribute"> public function <xsl:call-template name="makeGetterName"><xsl:with-param name="attrname" select="@name"/></xsl:call-template>()
|
---|
| 272 | {
|
---|
[27646] | 273 | <xsl:text>return </xsl:text>
|
---|
| 274 | <xsl:call-template name="emitOutParam">
|
---|
| 275 | <xsl:with-param name="type" select="@type" />
|
---|
| 276 | <xsl:with-param name="value" select="concat('$this->',@name)" />
|
---|
| 277 | <xsl:with-param name="safearray" select="@safearray"/>
|
---|
| 278 | </xsl:call-template>;
|
---|
[22379] | 279 | }
|
---|
[43546] | 280 | </xsl:for-each>}
|
---|
[22379] | 281 | </xsl:template>
|
---|
| 282 |
|
---|
[28775] | 283 | <xsl:template name="structcollection">
|
---|
| 284 | <xsl:variable name="ifname"><xsl:value-of select="@name" /></xsl:variable>
|
---|
| 285 | <xsl:text>
|
---|
| 286 | /**
|
---|
[43546] | 287 | * Generated VBoxWebService Struct Collection
|
---|
| 288 | */</xsl:text>
|
---|
| 289 | class <xsl:value-of select="$ifname"/>Collection extends VBox_StructCollection
|
---|
| 290 | {
|
---|
| 291 | protected $_interfaceName = "<xsl:value-of select="$ifname"/>";
|
---|
[28775] | 292 | }
|
---|
| 293 | </xsl:template>
|
---|
| 294 |
|
---|
[22379] | 295 | <xsl:template name="genreq">
|
---|
[43546] | 296 | <xsl:param name="wsmap" />
|
---|
| 297 | <xsl:text> $request = new stdClass();
|
---|
| 298 | </xsl:text>
|
---|
| 299 | <xsl:if test="$wsmap='managed'"> $request->_this = $this->handle;</xsl:if>
|
---|
| 300 | <xsl:for-each select="param[@dir='in']">
|
---|
| 301 | $request-><xsl:value-of select="@name" /> = $arg_<xsl:value-of select="@name" /><xsl:text>;</xsl:text>
|
---|
| 302 | </xsl:for-each>
|
---|
| 303 | $response = $this->connection->__soapCall('<xsl:value-of select="../@name"/>_<xsl:value-of select="@name"/>', array((array)$request));
|
---|
| 304 | return <xsl:if test="param[@dir='out']">
|
---|
| 305 | <xsl:text>array(</xsl:text>
|
---|
| 306 | </xsl:if>
|
---|
[22379] | 307 | <xsl:for-each select="param[@dir='return']">
|
---|
| 308 | <xsl:call-template name="emitOutParam">
|
---|
| 309 | <xsl:with-param name="type" select="@type" />
|
---|
| 310 | <xsl:with-param name="value" select="concat('$response->','returnval')" />
|
---|
| 311 | <xsl:with-param name="safearray" select="@safearray"/>
|
---|
| 312 | </xsl:call-template>
|
---|
| 313 | <xsl:if test="../param[@dir='out']">
|
---|
| 314 | <xsl:text>, </xsl:text>
|
---|
| 315 | </xsl:if>
|
---|
| 316 | </xsl:for-each>
|
---|
| 317 | <xsl:for-each select="param[@dir='out']">
|
---|
| 318 | <xsl:if test="not(position()=1)">
|
---|
| 319 | <xsl:text>, </xsl:text>
|
---|
| 320 | </xsl:if>
|
---|
| 321 | <xsl:call-template name="emitOutParam">
|
---|
| 322 | <xsl:with-param name="type" select="@type" />
|
---|
| 323 | <xsl:with-param name="value" select="concat('$response->',@name)" />
|
---|
| 324 | <xsl:with-param name="safearray" select="@safearray"/>
|
---|
| 325 | </xsl:call-template>
|
---|
| 326 | </xsl:for-each>
|
---|
| 327 | <xsl:if test="param[@dir='out']">
|
---|
| 328 | <xsl:text>)</xsl:text>
|
---|
| 329 | </xsl:if>
|
---|
[23887] | 330 | <xsl:text>; </xsl:text>
|
---|
[22379] | 331 | </xsl:template>
|
---|
| 332 |
|
---|
| 333 | <xsl:template name="method" >
|
---|
[43546] | 334 | <xsl:param name="wsmap" />
|
---|
| 335 | public function <xsl:value-of select="@name"/><xsl:text>(</xsl:text>
|
---|
| 336 | <xsl:for-each select="param[@dir='in']">
|
---|
| 337 | <xsl:if test="not(position()=1)">
|
---|
| 338 | <xsl:text>, </xsl:text>
|
---|
| 339 | </xsl:if>
|
---|
| 340 | <xsl:value-of select="concat('$arg_',@name)"/>
|
---|
| 341 | </xsl:for-each> <xsl:text>) { </xsl:text>
|
---|
| 342 | <xsl:call-template name="genreq"><xsl:with-param name="wsmap" select="$wsmap" /></xsl:call-template>
|
---|
| 343 | <xsl:text> } </xsl:text>
|
---|
[22379] | 344 | </xsl:template>
|
---|
| 345 |
|
---|
| 346 | <xsl:template name="enum">
|
---|
| 347 | <xsl:text>
|
---|
| 348 | /**
|
---|
[43546] | 349 | * Generated VBoxWebService ENUM
|
---|
| 350 | */</xsl:text>
|
---|
| 351 | class <xsl:value-of select="@name"/> extends VBox_Enum
|
---|
| 352 | {
|
---|
| 353 | 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>);
|
---|
| 354 | 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>);
|
---|
[22379] | 355 | }
|
---|
| 356 | </xsl:template>
|
---|
| 357 |
|
---|
[28775] | 358 | <xsl:template name="enumcollection">
|
---|
| 359 | <xsl:variable name="ifname"><xsl:value-of select="@name" /></xsl:variable>
|
---|
| 360 | <xsl:text>
|
---|
| 361 | /**
|
---|
[43546] | 362 | * Generated VBoxWebService Enum Collection
|
---|
| 363 | */</xsl:text>
|
---|
| 364 | class <xsl:value-of select="$ifname"/>Collection extends VBox_EnumCollection
|
---|
| 365 | {
|
---|
| 366 | protected $_interfaceName = "<xsl:value-of select="$ifname"/>";
|
---|
[28775] | 367 | }
|
---|
| 368 | </xsl:template>
|
---|
| 369 |
|
---|
[36676] | 370 | <xsl:template name="comResultCodes">
|
---|
[43546] | 371 | const <xsl:value-of select="@name"/> = <xsl:value-of select="@value"/>;
|
---|
[36676] | 372 | </xsl:template>
|
---|
| 373 |
|
---|
[22379] | 374 | <xsl:template match="/">
|
---|
| 375 | <xsl:text><?php
|
---|
| 376 |
|
---|
| 377 | /*
|
---|
[106065] | 378 | * Copyright (C) 2008-</xsl:text><xsl:value-of select="$g_uVBoxCopyrightYear"/><xsl:text> Oracle and/or its affiliates.
|
---|
[29835] | 379 | *
|
---|
| 380 | * This file is part of a free software library; you can redistribute
|
---|
| 381 | * it and/or modify it under the terms of the GNU Lesser General
|
---|
| 382 | * Public License version 2.1 as published by the Free Software
|
---|
| 383 | * Foundation and shipped in the "COPYING.LIB" file with this library.
|
---|
| 384 | * The library is distributed in the hope that it will be useful,
|
---|
| 385 | * but WITHOUT ANY WARRANTY of any kind.
|
---|
| 386 | *
|
---|
| 387 | * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if
|
---|
| 388 | * any license choice other than GPL or LGPL is available it will
|
---|
| 389 | * apply instead, Oracle elects to use only the Lesser General Public
|
---|
| 390 | * License version 2.1 (LGPLv2) at this time for any software where
|
---|
| 391 | * a choice of LGPL license versions is made available with the
|
---|
| 392 | * language indicating that LGPLv2 or any later version may be used,
|
---|
| 393 | * or where a choice of which version of the LGPL is applied is
|
---|
| 394 | * otherwise unspecified.
|
---|
| 395 | *
|
---|
[96417] | 396 | * SPDX-License-Identifier: LGPL-2.1-only
|
---|
| 397 | */
|
---|
| 398 | /*
|
---|
[29835] | 399 | * This file is autogenerated from VirtualBox.xidl, DO NOT EDIT!
|
---|
| 400 | */
|
---|
[22379] | 401 |
|
---|
[27646] | 402 | class VBox_ManagedObject
|
---|
[22379] | 403 | {
|
---|
| 404 | protected $connection;
|
---|
| 405 | protected $handle;
|
---|
| 406 |
|
---|
[28775] | 407 | public function __construct($soap, $handle = null)
|
---|
[22379] | 408 | {
|
---|
| 409 | $this->connection = $soap;
|
---|
| 410 | $this->handle = $handle;
|
---|
| 411 | }
|
---|
| 412 |
|
---|
| 413 | public function __toString()
|
---|
| 414 | {
|
---|
| 415 | return (string)$this->handle;
|
---|
| 416 | }
|
---|
| 417 |
|
---|
| 418 | public function __set($attr, $value)
|
---|
| 419 | {
|
---|
| 420 | $methodName = "set" . $attr;
|
---|
| 421 | if (method_exists($this, $methodName))
|
---|
| 422 | $this->$methodName($value);
|
---|
| 423 | else
|
---|
| 424 | throw new Exception("Attribute does not exist");
|
---|
| 425 | }
|
---|
| 426 |
|
---|
| 427 | public function __get($attr)
|
---|
| 428 | {
|
---|
| 429 | $methodName = "get" . $attr;
|
---|
| 430 | if (method_exists($this, $methodName))
|
---|
| 431 | return $this->$methodName();
|
---|
| 432 | else
|
---|
| 433 | throw new Exception("Attribute does not exist");
|
---|
| 434 | }
|
---|
| 435 |
|
---|
[43546] | 436 | public function getHandle()
|
---|
| 437 | {
|
---|
| 438 | return $this->handle;
|
---|
| 439 | }
|
---|
[22379] | 440 |
|
---|
[43546] | 441 | public function cast($class)
|
---|
| 442 | {
|
---|
| 443 | if (is_subclass_of($class, 'VBox_ManagedObject'))
|
---|
| 444 | {
|
---|
| 445 | return new $class($this->connection, $this->handle);
|
---|
| 446 | }
|
---|
| 447 | throw new Exception('Cannot cast VBox_ManagedObject to non-child class VBox_ManagedObject');
|
---|
| 448 | }
|
---|
[27646] | 449 |
|
---|
[43546] | 450 | public function releaseRemote()
|
---|
| 451 | {
|
---|
| 452 | try
|
---|
| 453 | {
|
---|
| 454 | $request = new stdClass();
|
---|
| 455 | $request->_this = $this->handle;
|
---|
| 456 | $this->connection->__soapCall('IManagedObjectRef_release', array((array)$request));
|
---|
| 457 | }
|
---|
| 458 | catch (Exception $ex)
|
---|
| 459 | {
|
---|
| 460 | }
|
---|
| 461 | }
|
---|
[22379] | 462 | }
|
---|
| 463 |
|
---|
[43546] | 464 | abstract class VBox_Collection implements ArrayAccess, Iterator, Countable
|
---|
| 465 | {
|
---|
[28775] | 466 | protected $_connection;
|
---|
| 467 | protected $_values;
|
---|
| 468 | protected $_objects;
|
---|
| 469 | protected $_interfaceName;
|
---|
[22379] | 470 |
|
---|
[43546] | 471 | public function __construct($soap, array $values = array())
|
---|
| 472 | {
|
---|
[28775] | 473 | $this->_connection = $soap;
|
---|
| 474 | $this->_values = $values;
|
---|
| 475 | $this->_soapToObject();
|
---|
[22379] | 476 | }
|
---|
| 477 |
|
---|
[43546] | 478 | protected function _soapToObject()
|
---|
| 479 | {
|
---|
[28775] | 480 | $this->_objects = array();
|
---|
| 481 | foreach($this->_values as $value)
|
---|
| 482 | {
|
---|
| 483 | $this->_objects[] = new $this->_interfaceName($this->_connection, $value);
|
---|
| 484 | }
|
---|
| 485 | }
|
---|
| 486 |
|
---|
[28823] | 487 | /** ArrayAccess Functions **/
|
---|
[43546] | 488 | public function offsetSet($offset, $value)
|
---|
| 489 | {
|
---|
[28775] | 490 | if ($value instanceof $this->_interfaceName)
|
---|
| 491 | {
|
---|
| 492 | if ($offset)
|
---|
| 493 | {
|
---|
| 494 | $this->_objects[$offset] = $value;
|
---|
| 495 | }
|
---|
| 496 | else
|
---|
| 497 | {
|
---|
| 498 | $this->_objects[] = $value;
|
---|
| 499 | }
|
---|
[28823] | 500 | }
|
---|
[28775] | 501 | else
|
---|
| 502 | {
|
---|
| 503 | throw new Exception("Value must be a instance of " . $this->_interfaceName);
|
---|
| 504 | }
|
---|
| 505 | }
|
---|
| 506 |
|
---|
[43546] | 507 | public function offsetExists($offset)
|
---|
| 508 | {
|
---|
[28775] | 509 | return isset($this->_objects[$offset]);
|
---|
| 510 | }
|
---|
| 511 |
|
---|
[43546] | 512 | public function offsetUnset($offset)
|
---|
| 513 | {
|
---|
[28775] | 514 | unset($this->_objects[$offset]);
|
---|
| 515 | }
|
---|
| 516 |
|
---|
[43546] | 517 | public function offsetGet($offset)
|
---|
| 518 | {
|
---|
[28775] | 519 | return isset($this->_objects[$offset]) ? $this->_objects[$offset] : null;
|
---|
| 520 | }
|
---|
| 521 |
|
---|
| 522 | /** Iterator Functions **/
|
---|
[43546] | 523 | public function rewind()
|
---|
| 524 | {
|
---|
[28775] | 525 | reset($this->_objects);
|
---|
[22379] | 526 | }
|
---|
| 527 |
|
---|
[43546] | 528 | public function current()
|
---|
| 529 | {
|
---|
[28775] | 530 | return current($this->_objects);
|
---|
[22379] | 531 | }
|
---|
| 532 |
|
---|
[43546] | 533 | public function key()
|
---|
| 534 | {
|
---|
[28775] | 535 | return key($this->_objects);
|
---|
[22379] | 536 | }
|
---|
| 537 |
|
---|
[43546] | 538 | public function next()
|
---|
| 539 | {
|
---|
[28775] | 540 | return next($this->_objects);
|
---|
[22379] | 541 | }
|
---|
| 542 |
|
---|
[43546] | 543 | public function valid()
|
---|
| 544 | {
|
---|
[28775] | 545 | return ($this->current() !== false);
|
---|
[22379] | 546 | }
|
---|
[27646] | 547 |
|
---|
[28775] | 548 | /** Countable Functions **/
|
---|
[43546] | 549 | public function count()
|
---|
| 550 | {
|
---|
[28775] | 551 | return count($this->_objects);
|
---|
[27646] | 552 | }
|
---|
[22379] | 553 | }
|
---|
| 554 |
|
---|
[43546] | 555 | class VBox_ManagedObjectCollection extends VBox_Collection
|
---|
| 556 | {
|
---|
[28775] | 557 | protected $_interfaceName = 'VBox_ManagedObject';
|
---|
| 558 |
|
---|
| 559 | // Result is undefined if this is called AFTER any call to VBox_Collection::offsetSet or VBox_Collection::offsetUnset
|
---|
[43546] | 560 | public function setInterfaceName($interface)
|
---|
| 561 | {
|
---|
| 562 | if (!is_subclass_of($interface, 'VBox_ManagedObject'))
|
---|
| 563 | {
|
---|
| 564 | throw new Exception('Cannot set collection interface to non-child class of VBox_ManagedObject');
|
---|
| 565 | }
|
---|
| 566 | $this->_interfaceName = $interface;
|
---|
| 567 | $this->_soapToObject();
|
---|
[28775] | 568 | }
|
---|
| 569 | }
|
---|
| 570 |
|
---|
[43546] | 571 | abstract class VBox_Struct
|
---|
| 572 | {
|
---|
[27646] | 573 | protected $connection;
|
---|
| 574 |
|
---|
[22379] | 575 | public function __get($attr)
|
---|
| 576 | {
|
---|
| 577 | $methodName = "get" . $attr;
|
---|
| 578 | if (method_exists($this, $methodName))
|
---|
| 579 | return $this->$methodName();
|
---|
| 580 | else
|
---|
| 581 | throw new Exception("Attribute does not exist");
|
---|
| 582 | }
|
---|
| 583 | }
|
---|
| 584 |
|
---|
[43546] | 585 | abstract class VBox_StructCollection extends VBox_Collection
|
---|
| 586 | {
|
---|
[28775] | 587 |
|
---|
| 588 | public function __construct($soap, array $values = array())
|
---|
| 589 | {
|
---|
| 590 | if (!(array_values($values) === $values))
|
---|
| 591 | {
|
---|
| 592 | $values = array((object)$values); //Fix for when struct return value only contains one list item (e.g. one medium attachment)
|
---|
| 593 | }
|
---|
| 594 | parent::__construct($soap, $values);
|
---|
| 595 | }
|
---|
| 596 | }
|
---|
| 597 |
|
---|
[43546] | 598 | abstract class VBox_Enum
|
---|
| 599 | {
|
---|
| 600 | protected $_handle;
|
---|
[22379] | 601 |
|
---|
[43546] | 602 | public function __construct($connection, $handle)
|
---|
| 603 | {
|
---|
| 604 | if (is_string($handle))
|
---|
| 605 | $this->_handle = $this->ValueMap[$handle];
|
---|
| 606 | else
|
---|
| 607 | $this->_handle = $handle;
|
---|
| 608 | }
|
---|
[22379] | 609 |
|
---|
[43546] | 610 | public function __toString()
|
---|
| 611 | {
|
---|
| 612 | return (string)$this->NameMap[$this->_handle];
|
---|
| 613 | }
|
---|
[22379] | 614 | }
|
---|
| 615 |
|
---|
[43546] | 616 | abstract class VBox_EnumCollection extends VBox_Collection
|
---|
| 617 | {
|
---|
[28775] | 618 | }
|
---|
| 619 |
|
---|
[22379] | 620 | </xsl:text>
|
---|
[36676] | 621 |
|
---|
| 622 | <xsl:text>
|
---|
| 623 | /**
|
---|
[43546] | 624 | * VirtualBox COM result codes
|
---|
| 625 | */
|
---|
| 626 | class VirtualBox_COM_result_codes
|
---|
| 627 | {
|
---|
[36676] | 628 | </xsl:text>
|
---|
| 629 | <xsl:for-each select="/idl/library/result">
|
---|
| 630 | <xsl:call-template name="comResultCodes"/>
|
---|
| 631 | </xsl:for-each>
|
---|
| 632 | <xsl:text>
|
---|
| 633 | }
|
---|
| 634 | </xsl:text>
|
---|
[22379] | 635 | <xsl:for-each select="//interface[@wsmap='managed' or @wsmap='global']">
|
---|
| 636 | <xsl:call-template name="interface"/>
|
---|
| 637 | <xsl:call-template name="collection"/>
|
---|
| 638 | </xsl:for-each>
|
---|
[43546] | 639 | <xsl:for-each select="//interface[@wsmap='struct']">
|
---|
[22379] | 640 | <xsl:call-template name="interfacestruct"/>
|
---|
[28775] | 641 | <xsl:call-template name="structcollection"/>
|
---|
[22379] | 642 | </xsl:for-each>
|
---|
| 643 | <xsl:for-each select="//enum">
|
---|
| 644 | <xsl:call-template name="enum"/>
|
---|
[28775] | 645 | <xsl:call-template name="enumcollection"/>
|
---|
[22379] | 646 | </xsl:for-each>
|
---|
| 647 |
|
---|
| 648 | </xsl:template>
|
---|
| 649 |
|
---|
| 650 | </xsl:stylesheet>
|
---|