Changeset 27646 in vbox for trunk/src/VBox/Main
- Timestamp:
- Mar 23, 2010 5:25:56 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/webservice/websrv-php.xsl
r25196 r27646 45 45 46 46 <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> 52 89 <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"/> 61 123 </xsl:otherwise> 62 124 </xsl:choose> … … 89 151 <xsl:variable name="fname"><xsl:call-template name="makeSetterName"><xsl:with-param name="attrname" select="$attrname"/></xsl:call-template></xsl:variable> 90 152 public function <xsl:value-of select="$fname"/>($value) { 91 $request = stdClass();153 $request = new stdClass(); 92 154 $request->_this = $this->handle; 93 155 if (is_int($value) || is_string($value) || is_bool($value)) { … … 187 249 protected $<xsl:value-of select="@name"/>; 188 250 </xsl:for-each> 189 public function __construct($connection, $handle) { 251 public function __construct($connection, $values) { 252 $this->connection = $connection; 190 253 <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> 192 255 </xsl:for-each> 193 256 } … … 195 258 <xsl:for-each select="attribute"> 196 259 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>; 198 266 } 199 267 </xsl:for-each> … … 287 355 */ 288 356 289 abstractclass VBox_ManagedObject357 class VBox_ManagedObject 290 358 { 291 359 protected $connection; … … 324 392 { 325 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'); 326 403 } 327 404 … … 337 414 } 338 415 339 abstract class VBox_ManagedObjectCollection implements Iterator{416 class VBox_ManagedObjectCollection implements Iterator, Countable { 340 417 protected $connection; 341 418 protected $handles; … … 374 451 return $handle; 375 452 } 453 454 public function count() { 455 return count($this->handles); 456 } 376 457 } 377 458 378 459 abstract class VBox_Struct { 460 protected $connection; 461 379 462 public function __get($attr) 380 463 { … … 415 498 <xsl:for-each select="//enum"> 416 499 <xsl:call-template name="enum"/> 500 <xsl:call-template name="collection"/> 417 501 </xsl:for-each> 418 502
Note:
See TracChangeset
for help on using the changeset viewer.