VirtualBox

Changeset 27646 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Mar 23, 2010 5:25:56 PM (15 years ago)
Author:
vboxsync
Message:

SDK: update PHP webservice bindings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/webservice/websrv-php.xsl

    r25196 r27646  
    4545
    4646  <xsl:choose>
    47     <xsl:when test="$type='wstring' or $type='uuid'">(string)<xsl:value-of select="$value" /></xsl:when>
    48     <xsl:when test="$type='boolean'">(bool)<xsl:value-of select="$value" /></xsl:when>
    49     <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'">(int)<xsl:value-of select="$value" /></xsl:when>
    50     <xsl:when test="$type='double' or $type='float'">(float)<xsl:value-of select="$value" /></xsl:when>
    51     <xsl:when test="$type='octet'"><xsl:value-of select="$value" /></xsl:when>
     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>
    5289    <xsl:otherwise>
    53         <xsl:choose>
    54             <xsl:when test="$safearray='yes'">
    55                 <xsl:text>new </xsl:text><xsl:value-of select="$type" />Collection ($this->connection, <xsl:value-of select="$value"/><xsl:text>)</xsl:text>
    56             </xsl:when>
    57             <xsl:otherwise>
    58                 <xsl:text>new </xsl:text><xsl:value-of select="$type" /> ($this->connection, <xsl:value-of select="$value"/><xsl:text>)</xsl:text>
    59             </xsl:otherwise>
    60         </xsl:choose>
     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"/>
    61123    </xsl:otherwise>
    62124  </xsl:choose>
     
    89151  <xsl:variable name="fname"><xsl:call-template name="makeSetterName"><xsl:with-param name="attrname" select="$attrname"/></xsl:call-template></xsl:variable>
    90152   public function <xsl:value-of select="$fname"/>($value) {
    91        $request = stdClass();
     153       $request = new stdClass();
    92154       $request->_this = $this->handle;
    93155       if (is_int($value) || is_string($value) || is_bool($value)) {
     
    187249       protected $<xsl:value-of select="@name"/>;
    188250    </xsl:for-each>
    189     public function __construct($connection, $handle) {
     251    public function __construct($connection, $values) {
     252       $this->connection = $connection;
    190253    <xsl:for-each select="attribute">
    191        $this-><xsl:value-of select="@name"/> = $handle-><xsl:value-of select="@name"/><xsl:text>;</xsl:text>
     254       $this-><xsl:value-of select="@name"/> = $values-><xsl:value-of select="@name"/><xsl:text>;</xsl:text>
    192255    </xsl:for-each>
    193256    }
     
    195258    <xsl:for-each select="attribute">
    196259    public function <xsl:call-template name="makeGetterName"><xsl:with-param name="attrname" select="@name"/></xsl:call-template>() {
    197        return $this-><xsl:value-of select="@name"/>;
     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>;
    198266    }
    199267    </xsl:for-each>
     
    287355*/
    288356
    289 abstract class VBox_ManagedObject
     357class VBox_ManagedObject
    290358{
    291359    protected $connection;
     
    324392   {
    325393       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');
    326403   }
    327404
     
    337414}
    338415
    339 abstract class VBox_ManagedObjectCollection implements Iterator {
     416class VBox_ManagedObjectCollection implements Iterator, Countable {
    340417    protected $connection;
    341418    protected $handles;
     
    374451        return $handle;
    375452    }
     453
     454    public function count() {
     455        return count($this->handles);
     456    }
    376457}
    377458
    378459abstract class VBox_Struct {
     460    protected $connection;
     461
    379462    public function __get($attr)
    380463    {
     
    415498  <xsl:for-each select="//enum">
    416499       <xsl:call-template name="enum"/>
     500       <xsl:call-template name="collection"/>
    417501  </xsl:for-each>
    418502
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette