[30987] | 1 | <xsl:stylesheet version = '1.0'
|
---|
[46478] | 2 | xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
|
---|
| 3 | xmlns:vbox="http://www.virtualbox.org/"
|
---|
| 4 | xmlns:exsl="http://exslt.org/common"
|
---|
| 5 | extension-element-prefixes="exsl">
|
---|
[30987] | 6 |
|
---|
| 7 | <!--
|
---|
| 8 | glue-java.xsl:
|
---|
| 9 | XSLT stylesheet that generates Java glue code for XPCOM, MSCOM and JAX-WS from
|
---|
| 10 | VirtualBox.xidl.
|
---|
[96308] | 11 | -->
|
---|
| 12 | <!--
|
---|
[98103] | 13 | Copyright (C) 2010-2023 Oracle and/or its affiliates.
|
---|
[30987] | 14 |
|
---|
[96407] | 15 | This file is part of VirtualBox base platform packages, as
|
---|
| 16 | available from https://www.virtualbox.org.
|
---|
| 17 |
|
---|
| 18 | This program is free software; you can redistribute it and/or
|
---|
| 19 | modify it under the terms of the GNU General Public License
|
---|
| 20 | as published by the Free Software Foundation, in version 3 of the
|
---|
| 21 | License.
|
---|
| 22 |
|
---|
| 23 | This program is distributed in the hope that it will be useful, but
|
---|
| 24 | WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 25 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 26 | General Public License for more details.
|
---|
| 27 |
|
---|
| 28 | You should have received a copy of the GNU General Public License
|
---|
| 29 | along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
| 30 |
|
---|
| 31 | SPDX-License-Identifier: GPL-3.0-only
|
---|
[30987] | 32 | -->
|
---|
| 33 |
|
---|
| 34 | <xsl:output
|
---|
| 35 | method="text"
|
---|
| 36 | version="1.0"
|
---|
| 37 | encoding="utf-8"
|
---|
| 38 | indent="no"/>
|
---|
| 39 |
|
---|
| 40 | <!-- - - - - - - - - - - - - - - - - - - - - - -
|
---|
| 41 | global XSLT variables
|
---|
| 42 | - - - - - - - - - - - - - - - - - - - - - - -->
|
---|
| 43 |
|
---|
| 44 | <xsl:variable name="G_xsltFilename" select="'glue-java.xsl'" />
|
---|
[46478] | 45 | <xsl:variable name="G_virtualBoxPackage" select="concat('org.virtualbox', $G_vboxApiSuffix)" />
|
---|
| 46 | <xsl:variable name="G_virtualBoxPackageCom" select="concat('org.virtualbox', $G_vboxApiSuffix, '.', $G_vboxGlueStyle)" />
|
---|
| 47 | <xsl:variable name="G_virtualBoxWsdl" select="concat('"vboxwebService', $G_vboxApiSuffix, '.wsdl"')" />
|
---|
| 48 | <!-- collect all interfaces with "wsmap='suppress'" in a global variable for quick lookup -->
|
---|
[30987] | 49 | <xsl:variable name="G_setSuppressedInterfaces"
|
---|
| 50 | select="//interface[@wsmap='suppress']" />
|
---|
| 51 |
|
---|
[45483] | 52 | <xsl:include href="../idl/typemap-shared.inc.xsl" />
|
---|
[30987] | 53 |
|
---|
[38796] | 54 | <xsl:strip-space elements="*"/>
|
---|
| 55 |
|
---|
[53922] | 56 |
|
---|
| 57 | <!-- - - - - - - - - - - - - - - - - - - - - - -
|
---|
| 58 | Keys for more efficiently looking up of types.
|
---|
| 59 | - - - - - - - - - - - - - - - - - - - - - - -->
|
---|
| 60 |
|
---|
| 61 | <xsl:key name="G_keyEnumsByName" match="//enum[@name]" use="@name"/>
|
---|
| 62 | <xsl:key name="G_keyInterfacesByName" match="//interface[@name]" use="@name"/>
|
---|
| 63 |
|
---|
| 64 |
|
---|
| 65 | <!-- - - - - - - - - - - - - - - - - - - - - - -
|
---|
| 66 | - - - - - - - - - - - - - - - - - - - - - - -->
|
---|
| 67 |
|
---|
[30987] | 68 | <xsl:template name="fileheader">
|
---|
| 69 | <xsl:param name="name" />
|
---|
[38796] | 70 | <xsl:text>/*
|
---|
[98108] | 71 | * Copyright (C) 2010-2023 Oracle and/or its affiliates.
|
---|
[30987] | 72 | *
|
---|
[96417] | 73 | * This file is part of a free software library; you can redistribute
|
---|
| 74 | * it and/or modify it under the terms of the GNU Lesser General
|
---|
| 75 | * Public License version 2.1 as published by the Free Software
|
---|
| 76 | * Foundation and shipped in the \"COPYING.LIB\" file with this library.
|
---|
| 77 | * The library is distributed in the hope that it will be useful,
|
---|
| 78 | * but WITHOUT ANY WARRANTY of any kind.
|
---|
| 79 | *
|
---|
| 80 | * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if
|
---|
| 81 | * any license choice other than GPL or LGPL is available it will
|
---|
| 82 | * apply instead, Oracle elects to use only the Lesser General Public
|
---|
| 83 | * License version 2.1 (LGPLv2) at this time for any software where
|
---|
| 84 | * a choice of LGPL license versions is made available with the
|
---|
| 85 | * language indicating that LGPLv2 or any later version may be used,
|
---|
| 86 | * or where a choice of which version of the LGPL is applied is
|
---|
| 87 | * otherwise unspecified.
|
---|
| 88 |
|
---|
[46478] | 89 | * http://www.virtualbox.org. This library is free software; you can
|
---|
| 90 | * redistribute it and/or modify it under the terms of the GNU Lesser General
|
---|
| 91 | * Public License as published by the Free Software Foundation, in version 2.1
|
---|
| 92 | * as it comes in the "COPYING.LIB" file of the VirtualBox SDK distribution.
|
---|
| 93 | * This library is distributed in the hope that it will be useful, but WITHOUT
|
---|
| 94 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
---|
| 95 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
---|
| 96 | * License for more details.
|
---|
[30987] | 97 | *
|
---|
[96417] | 98 | * SPDX-License-Identifier: LGPL-2.1-only
|
---|
| 99 | */
|
---|
| 100 |
|
---|
| 101 | /*
|
---|
[30987] | 102 | </xsl:text>
|
---|
[46478] | 103 | <xsl:value-of select="concat(' * ', $name)"/>
|
---|
[30987] | 104 | <xsl:text>
|
---|
| 105 | *
|
---|
| 106 | * DO NOT EDIT! This is a generated file.
|
---|
| 107 | * Generated from: src/VBox/Main/idl/VirtualBox.xidl (VirtualBox's interface definitions in XML)
|
---|
| 108 | * Generator: src/VBox/Main/glue/glue-java.xsl
|
---|
| 109 | */
|
---|
| 110 |
|
---|
| 111 | </xsl:text>
|
---|
| 112 | </xsl:template>
|
---|
| 113 |
|
---|
| 114 | <xsl:template name="startFile">
|
---|
| 115 | <xsl:param name="file" />
|
---|
| 116 | <xsl:param name="package" />
|
---|
| 117 |
|
---|
[46478] | 118 | <xsl:choose>
|
---|
| 119 | <xsl:when test="$filelistonly=''">
|
---|
| 120 | <xsl:value-of select="concat(' // ##### BEGINFILE "', $G_vboxDirPrefix, $file, '" ')" />
|
---|
| 121 | <xsl:call-template name="fileheader">
|
---|
| 122 | <xsl:with-param name="name" select="$file" />
|
---|
| 123 | </xsl:call-template>
|
---|
[30987] | 124 |
|
---|
[46478] | 125 | <xsl:value-of select="concat('package ', $package, '; ')" />
|
---|
| 126 | <xsl:value-of select="concat('import ', $G_virtualBoxPackageCom, '.*; ')" />
|
---|
[30987] | 127 |
|
---|
[46478] | 128 | <xsl:choose>
|
---|
| 129 | <xsl:when test="$G_vboxGlueStyle='xpcom'">
|
---|
| 130 | <xsl:text>import org.mozilla.interfaces.*; </xsl:text>
|
---|
| 131 | </xsl:when>
|
---|
[30987] | 132 |
|
---|
[46478] | 133 | <xsl:when test="$G_vboxGlueStyle='mscom'">
|
---|
| 134 | <xsl:text>import com.jacob.com.*; </xsl:text>
|
---|
| 135 | <xsl:text>import com.jacob.activeX.ActiveXComponent; </xsl:text>
|
---|
| 136 | </xsl:when>
|
---|
[30987] | 137 |
|
---|
[46478] | 138 | <xsl:when test="$G_vboxGlueStyle='jaxws'">
|
---|
| 139 | <xsl:text>import javax.xml.ws.*; </xsl:text>
|
---|
| 140 | </xsl:when>
|
---|
| 141 |
|
---|
| 142 | <xsl:otherwise>
|
---|
| 143 | <xsl:call-template name="fatalError">
|
---|
| 144 | <xsl:with-param name="msg" select="'no header rule (startFile)'" />
|
---|
| 145 | </xsl:call-template>
|
---|
| 146 | </xsl:otherwise>
|
---|
| 147 | </xsl:choose>
|
---|
[30987] | 148 | </xsl:when>
|
---|
| 149 | <xsl:otherwise>
|
---|
[53936] | 150 | <xsl:value-of select="concat(' \', $G_sNewLine, '	', $G_vboxDirPrefix, $file)"/>
|
---|
[30987] | 151 | </xsl:otherwise>
|
---|
| 152 | </xsl:choose>
|
---|
| 153 | </xsl:template>
|
---|
| 154 |
|
---|
| 155 | <xsl:template name="endFile">
|
---|
[46478] | 156 | <xsl:param name="file" />
|
---|
| 157 | <xsl:if test="$filelistonly=''">
|
---|
[53922] | 158 | <xsl:value-of select="concat(' // ##### ENDFILE "', $file, '" ')" />
|
---|
| 159 | <xsl:call-template name="xsltprocNewlineOutputHack"/>
|
---|
[46478] | 160 | </xsl:if>
|
---|
[30987] | 161 | </xsl:template>
|
---|
| 162 |
|
---|
[53934] | 163 | <!-- strip-and-normalize-desc
|
---|
| 164 | Removes leading and trailing white space on each line in the given text.
|
---|
| 165 | -->
|
---|
| 166 | <xsl:template name="strip-and-normalize-desc">
|
---|
| 167 | <xsl:param name="text"/>
|
---|
[38796] | 168 |
|
---|
[53934] | 169 | <!-- Strip the whole string first so we won't leave trailing new line chars behind. -->
|
---|
| 170 | <xsl:variable name="sStrippedText">
|
---|
| 171 | <xsl:call-template name="strip-string">
|
---|
| 172 | <xsl:with-param name="text" select="$text"/>
|
---|
| 173 | </xsl:call-template>
|
---|
| 174 | </xsl:variable>
|
---|
| 175 |
|
---|
[38796] | 176 | <xsl:choose>
|
---|
[53934] | 177 | <!-- If there are multiple lines, strip them one by one on a recursive fasion. -->
|
---|
| 178 | <xsl:when test="contains($sStrippedText, ' ')">
|
---|
| 179 | <xsl:call-template name="strip-string-right">
|
---|
| 180 | <xsl:with-param name="text" select="substring-before($sStrippedText, ' ')"/>
|
---|
| 181 | </xsl:call-template>
|
---|
| 182 | <xsl:value-of select="' '"/>
|
---|
| 183 | <xsl:call-template name="strip-and-normalize-desc-recursive">
|
---|
| 184 | <xsl:with-param name="text" select="substring-after($sStrippedText, ' ')"/>
|
---|
| 185 | </xsl:call-template>
|
---|
[38796] | 186 | </xsl:when>
|
---|
[53934] | 187 |
|
---|
| 188 | <!-- Single line, we're done. -->
|
---|
[38796] | 189 | <xsl:otherwise>
|
---|
[53934] | 190 | <xsl:value-of select="$sStrippedText"/>
|
---|
[38796] | 191 | </xsl:otherwise>
|
---|
| 192 | </xsl:choose>
|
---|
[53934] | 193 |
|
---|
[38796] | 194 | </xsl:template>
|
---|
| 195 |
|
---|
[53934] | 196 | <!-- Internal worker for strip-and-normalize-desc, don't use. -->
|
---|
| 197 | <xsl:template name="strip-and-normalize-desc-recursive">
|
---|
[46478] | 198 | <xsl:param name="text"/>
|
---|
| 199 |
|
---|
| 200 | <xsl:choose>
|
---|
[53934] | 201 | <!-- If there are multiple lines, strip them one by one on a recursive fasion. -->
|
---|
| 202 | <xsl:when test="contains($text, ' ')">
|
---|
| 203 | <xsl:call-template name="strip-string">
|
---|
| 204 | <xsl:with-param name="text" select="substring-before($text, ' ')"/>
|
---|
[46478] | 205 | </xsl:call-template>
|
---|
[53934] | 206 | <xsl:value-of select="' '"/>
|
---|
| 207 | <xsl:call-template name="strip-and-normalize-desc-recursive">
|
---|
| 208 | <xsl:with-param name="text" select="substring-after($text, ' ')"/>
|
---|
| 209 | </xsl:call-template>
|
---|
[46478] | 210 | </xsl:when>
|
---|
[53934] | 211 |
|
---|
| 212 | <!-- Single line: Left strip it. -->
|
---|
[46478] | 213 | <xsl:otherwise>
|
---|
[53934] | 214 | <xsl:call-template name="strip-string-left">
|
---|
| 215 | <xsl:with-param name="text" select="$text"/>
|
---|
| 216 | </xsl:call-template>
|
---|
[46478] | 217 | </xsl:otherwise>
|
---|
| 218 | </xsl:choose>
|
---|
[53934] | 219 |
|
---|
[46478] | 220 | </xsl:template>
|
---|
| 221 |
|
---|
[38796] | 222 | <!-- descriptions -->
|
---|
| 223 |
|
---|
| 224 | <xsl:template match="*/text()">
|
---|
| 225 | <!-- TODO: strip out @c/@a for now. long term solution is changing that to a
|
---|
| 226 | tag in the xidl file, and translate it when generating doxygen etc. -->
|
---|
| 227 | <xsl:variable name="rep1">
|
---|
| 228 | <xsl:call-template name="string-replace">
|
---|
| 229 | <xsl:with-param name="haystack" select="."/>
|
---|
| 230 | <xsl:with-param name="needle" select="'@c'"/>
|
---|
| 231 | <xsl:with-param name="replacement" select="''"/>
|
---|
| 232 | </xsl:call-template>
|
---|
| 233 | </xsl:variable>
|
---|
| 234 |
|
---|
| 235 | <xsl:variable name="rep2">
|
---|
| 236 | <xsl:call-template name="string-replace">
|
---|
| 237 | <xsl:with-param name="haystack" select="$rep1"/>
|
---|
| 238 | <xsl:with-param name="needle" select="'@a'"/>
|
---|
| 239 | <xsl:with-param name="replacement" select="''"/>
|
---|
| 240 | </xsl:call-template>
|
---|
| 241 | </xsl:variable>
|
---|
| 242 |
|
---|
| 243 | <xsl:variable name="rep3">
|
---|
| 244 | <xsl:call-template name="string-replace">
|
---|
| 245 | <xsl:with-param name="haystack" select="$rep2"/>
|
---|
| 246 | <xsl:with-param name="needle" select="'@todo'"/>
|
---|
| 247 | <xsl:with-param name="replacement" select="'TODO'"/>
|
---|
| 248 | </xsl:call-template>
|
---|
| 249 | </xsl:variable>
|
---|
| 250 |
|
---|
[53385] | 251 | <!-- &, < and > must remain as they are or javadoc 8 throws a fit. -->
|
---|
[46478] | 252 | <xsl:variable name="rep4">
|
---|
[53385] | 253 | <xsl:call-template name="string-replace">
|
---|
| 254 | <xsl:with-param name="haystack" select="$rep3"/>
|
---|
| 255 | <xsl:with-param name="needle" select="'&'"/>
|
---|
| 256 | <xsl:with-param name="replacement" select="'&amp;'"/>
|
---|
| 257 | </xsl:call-template>
|
---|
| 258 | </xsl:variable>
|
---|
| 259 | <xsl:variable name="rep5">
|
---|
| 260 | <xsl:call-template name="string-replace">
|
---|
| 261 | <xsl:with-param name="haystack" select="$rep4"/>
|
---|
| 262 | <xsl:with-param name="needle" select="'<'"/>
|
---|
| 263 | <xsl:with-param name="replacement" select="'&lt;'"/>
|
---|
| 264 | </xsl:call-template>
|
---|
| 265 | </xsl:variable>
|
---|
| 266 | <xsl:variable name="rep6">
|
---|
| 267 | <xsl:call-template name="string-replace">
|
---|
| 268 | <xsl:with-param name="haystack" select="$rep5"/>
|
---|
| 269 | <xsl:with-param name="needle" select="'>'"/>
|
---|
| 270 | <xsl:with-param name="replacement" select="'&gt;'"/>
|
---|
| 271 | </xsl:call-template>
|
---|
| 272 | </xsl:variable>
|
---|
| 273 |
|
---|
| 274 | <xsl:variable name="rep7">
|
---|
[53934] | 275 | <xsl:call-template name="strip-and-normalize-desc">
|
---|
[53385] | 276 | <xsl:with-param name="text" select="$rep6"/>
|
---|
[46478] | 277 | </xsl:call-template>
|
---|
| 278 | </xsl:variable>
|
---|
| 279 |
|
---|
[53385] | 280 | <xsl:value-of select="$rep7"/>
|
---|
[38796] | 281 | </xsl:template>
|
---|
| 282 |
|
---|
| 283 | <!--
|
---|
[46478] | 284 | * all sub-elements that are not explicitly matched are considered to be
|
---|
| 285 | * html tags and copied w/o modifications
|
---|
[38796] | 286 | -->
|
---|
| 287 | <xsl:template match="desc//*">
|
---|
| 288 | <xsl:variable name="tagname" select="local-name()"/>
|
---|
[97677] | 289 | <xsl:choose>
|
---|
| 290 | <xsl:when test="$tagname = 'tt'">
|
---|
[97709] | 291 | <xsl:text><code></xsl:text>
|
---|
[97677] | 292 | </xsl:when>
|
---|
[97686] | 293 | <xsl:when test="$tagname = 'h3'">
|
---|
[97709] | 294 | <xsl:text><h2></xsl:text>
|
---|
[97686] | 295 | </xsl:when>
|
---|
[97677] | 296 | <xsl:otherwise>
|
---|
[97709] | 297 | <xsl:value-of select="concat('<', $tagname, '>')"/>
|
---|
[97677] | 298 | </xsl:otherwise>
|
---|
| 299 | </xsl:choose>
|
---|
[38796] | 300 | <xsl:apply-templates/>
|
---|
[97677] | 301 | <xsl:choose>
|
---|
| 302 | <xsl:when test="$tagname = 'tt'">
|
---|
| 303 | <xsl:text></code></xsl:text>
|
---|
| 304 | </xsl:when>
|
---|
[97686] | 305 | <xsl:when test="$tagname = 'h3'">
|
---|
| 306 | <xsl:text></h2></xsl:text>
|
---|
| 307 | </xsl:when>
|
---|
[97677] | 308 | <xsl:otherwise>
|
---|
| 309 | <xsl:value-of select="concat('</', $tagname, '>')"/>
|
---|
| 310 | </xsl:otherwise>
|
---|
| 311 | </xsl:choose>
|
---|
[38796] | 312 | </xsl:template>
|
---|
| 313 |
|
---|
| 314 | <xsl:template name="emit_refsig">
|
---|
| 315 | <xsl:param name="context"/>
|
---|
| 316 | <xsl:param name="identifier"/>
|
---|
| 317 |
|
---|
| 318 | <xsl:choose>
|
---|
[53922] | 319 | <xsl:when test="key('G_keyEnumsByName', $context)/const[@name=$identifier]">
|
---|
[38796] | 320 | <xsl:value-of select="$identifier"/>
|
---|
| 321 | </xsl:when>
|
---|
[53922] | 322 | <xsl:when test="key('G_keyInterfacesByName', $context)/method[@name=$identifier]">
|
---|
[38796] | 323 | <xsl:value-of select="$identifier"/>
|
---|
| 324 | <xsl:text>(</xsl:text>
|
---|
[53922] | 325 | <xsl:for-each select="key('G_keyInterfacesByName', $context)/method[@name=$identifier]/param">
|
---|
[38796] | 326 | <xsl:if test="@dir!='return'">
|
---|
| 327 | <xsl:if test="position() > 1">
|
---|
| 328 | <xsl:text>,</xsl:text>
|
---|
| 329 | </xsl:if>
|
---|
| 330 | <xsl:choose>
|
---|
| 331 | <xsl:when test="@dir='out'">
|
---|
| 332 | <xsl:text>Holder</xsl:text>
|
---|
| 333 | </xsl:when>
|
---|
| 334 | <xsl:otherwise>
|
---|
| 335 | <xsl:call-template name="typeIdl2Glue">
|
---|
| 336 | <xsl:with-param name="type" select="@type"/>
|
---|
| 337 | <xsl:with-param name="safearray" select="@safearray"/>
|
---|
| 338 | <xsl:with-param name="skiplisttype" select="'yes'"/>
|
---|
| 339 | </xsl:call-template>
|
---|
| 340 | </xsl:otherwise>
|
---|
| 341 | </xsl:choose>
|
---|
| 342 | </xsl:if>
|
---|
| 343 | </xsl:for-each>
|
---|
| 344 | <xsl:text>)</xsl:text>
|
---|
| 345 | </xsl:when>
|
---|
[53922] | 346 | <xsl:when test="key('G_keyInterfacesByName', $context)/attribute[@name=$identifier]">
|
---|
[38796] | 347 | <xsl:call-template name="makeGetterName">
|
---|
| 348 | <xsl:with-param name="attrname" select="$identifier" />
|
---|
| 349 | </xsl:call-template>
|
---|
| 350 | <xsl:text>()</xsl:text>
|
---|
| 351 | </xsl:when>
|
---|
| 352 | <xsl:otherwise>
|
---|
| 353 | <xsl:call-template name="fatalError">
|
---|
[46478] | 354 | <xsl:with-param name="msg" select="concat('unknown reference destination in @see/@link: context=', $context, ' identifier=', $identifier)" />
|
---|
[38796] | 355 | </xsl:call-template>
|
---|
| 356 | </xsl:otherwise>
|
---|
| 357 | </xsl:choose>
|
---|
| 358 | </xsl:template>
|
---|
| 359 |
|
---|
| 360 | <!--
|
---|
[46478] | 361 | * link
|
---|
[38796] | 362 | -->
|
---|
| 363 | <xsl:template match="desc//link">
|
---|
| 364 | <xsl:text>{@link </xsl:text>
|
---|
| 365 | <xsl:apply-templates select="." mode="middle"/>
|
---|
| 366 | <xsl:text>}</xsl:text>
|
---|
| 367 | </xsl:template>
|
---|
| 368 |
|
---|
| 369 | <xsl:template match="link" mode="middle">
|
---|
| 370 | <xsl:variable name="linktext">
|
---|
[53934] | 371 | <xsl:call-template name="string-replace-first">
|
---|
[46478] | 372 | <xsl:with-param name="haystack" select="@to"/>
|
---|
| 373 | <xsl:with-param name="needle" select="'_'"/>
|
---|
| 374 | <xsl:with-param name="replacement" select="'#'"/>
|
---|
| 375 | </xsl:call-template>
|
---|
[38796] | 376 | </xsl:variable>
|
---|
| 377 | <xsl:choose>
|
---|
[46478] | 378 | <xsl:when test="substring($linktext, 1, 1)='#'">
|
---|
[38796] | 379 | <xsl:variable name="context">
|
---|
| 380 | <xsl:choose>
|
---|
| 381 | <xsl:when test="local-name(../..)='interface' or local-name(../..)='enum'">
|
---|
| 382 | <xsl:value-of select="../../@name"/>
|
---|
| 383 | </xsl:when>
|
---|
| 384 | <xsl:when test="local-name(../../..)='interface' or local-name(../../..)='enum'">
|
---|
| 385 | <xsl:value-of select="../../../@name"/>
|
---|
| 386 | </xsl:when>
|
---|
| 387 | <xsl:when test="local-name(../../../..)='interface' or local-name(../../../..)='enum'">
|
---|
| 388 | <xsl:value-of select="../../../../@name"/>
|
---|
| 389 | </xsl:when>
|
---|
| 390 | <xsl:when test="local-name(../../../../..)='interface' or local-name(../../../../..)='enum'">
|
---|
| 391 | <xsl:value-of select="../../../../../@name"/>
|
---|
| 392 | </xsl:when>
|
---|
| 393 | <xsl:when test="local-name(../../../../../..)='interface' or local-name(../../../../../..)='enum'">
|
---|
| 394 | <xsl:value-of select="../../../../../../@name"/>
|
---|
| 395 | </xsl:when>
|
---|
| 396 | <xsl:otherwise>
|
---|
| 397 | <xsl:call-template name="fatalError">
|
---|
[46478] | 398 | <xsl:with-param name="msg" select="concat('cannot determine context for identifier ', $linktext)" />
|
---|
[38796] | 399 | </xsl:call-template>
|
---|
| 400 | </xsl:otherwise>
|
---|
| 401 | </xsl:choose>
|
---|
| 402 | </xsl:variable>
|
---|
| 403 | <xsl:variable name="linkname">
|
---|
[46478] | 404 | <xsl:value-of select="substring($linktext, 2)"/>
|
---|
[38796] | 405 | </xsl:variable>
|
---|
| 406 | <xsl:text>#</xsl:text>
|
---|
| 407 | <xsl:call-template name="emit_refsig">
|
---|
| 408 | <xsl:with-param name="context" select="$context"/>
|
---|
| 409 | <xsl:with-param name="identifier" select="$linkname"/>
|
---|
| 410 | </xsl:call-template>
|
---|
| 411 | </xsl:when>
|
---|
[46478] | 412 | <xsl:when test="contains($linktext, '::')">
|
---|
[38796] | 413 | <xsl:variable name="context">
|
---|
[46478] | 414 | <xsl:value-of select="substring-before($linktext, '::')"/>
|
---|
[38796] | 415 | </xsl:variable>
|
---|
| 416 | <xsl:variable name="linkname">
|
---|
[46478] | 417 | <xsl:value-of select="substring-after($linktext, '::')"/>
|
---|
[38796] | 418 | </xsl:variable>
|
---|
[46478] | 419 | <xsl:value-of select="concat($G_virtualBoxPackage, '.', $context, '#')"/>
|
---|
[38796] | 420 | <xsl:call-template name="emit_refsig">
|
---|
| 421 | <xsl:with-param name="context" select="$context"/>
|
---|
| 422 | <xsl:with-param name="identifier" select="$linkname"/>
|
---|
| 423 | </xsl:call-template>
|
---|
| 424 | </xsl:when>
|
---|
| 425 | <xsl:otherwise>
|
---|
[46478] | 426 | <xsl:value-of select="concat($G_virtualBoxPackage, '.', $linktext)"/>
|
---|
[38796] | 427 | </xsl:otherwise>
|
---|
| 428 | </xsl:choose>
|
---|
| 429 | </xsl:template>
|
---|
| 430 | <!--
|
---|
[46478] | 431 | * note
|
---|
[38796] | 432 | -->
|
---|
| 433 | <xsl:template match="desc/note">
|
---|
| 434 | <xsl:if test="not(@internal='yes')">
|
---|
| 435 | <xsl:text> NOTE: </xsl:text>
|
---|
| 436 | <xsl:apply-templates/>
|
---|
| 437 | <xsl:text> </xsl:text>
|
---|
| 438 | </xsl:if>
|
---|
| 439 | </xsl:template>
|
---|
| 440 |
|
---|
| 441 | <!--
|
---|
[46478] | 442 | * see
|
---|
[38796] | 443 | -->
|
---|
| 444 | <xsl:template match="desc/see">
|
---|
| 445 | <!-- TODO: quirk in our xidl file: only one <see> tag with <link> nested
|
---|
| 446 | into it, translate this to multiple @see lines and strip the rest.
|
---|
[46478] | 447 | Should be replaced in the xidl by multiple <see> without nested tag -->
|
---|
[38796] | 448 | <xsl:text> </xsl:text>
|
---|
| 449 | <xsl:apply-templates match="link"/>
|
---|
| 450 | </xsl:template>
|
---|
| 451 |
|
---|
| 452 | <xsl:template match="desc/see/text()"/>
|
---|
| 453 |
|
---|
| 454 | <xsl:template match="desc/see/link">
|
---|
| 455 | <xsl:text>@see </xsl:text>
|
---|
| 456 | <xsl:apply-templates select="." mode="middle"/>
|
---|
| 457 | <xsl:text> </xsl:text>
|
---|
| 458 | </xsl:template>
|
---|
| 459 |
|
---|
| 460 | <!--
|
---|
[46478] | 461 | * common comment prologue (handles group IDs)
|
---|
[38796] | 462 | -->
|
---|
| 463 | <xsl:template match="desc" mode="begin">
|
---|
[53934] | 464 | <!-- TODO,XXX: This is a hot spot. The whole $id crap isn't working though,
|
---|
| 465 | so it's been disabled to save precious time. -->
|
---|
| 466 | <!--
|
---|
[38796] | 467 | <xsl:param name="id" select="@group | preceding::descGroup[1]/@id"/>
|
---|
[46478] | 468 | <xsl:text> /** </xsl:text>
|
---|
[38796] | 469 | <xsl:if test="$id">
|
---|
[46478] | 470 | <xsl:value-of select="concat(' @ingroup ', $id, ' ')"/>
|
---|
[38796] | 471 | </xsl:if>
|
---|
[53934] | 472 | -->
|
---|
| 473 | <xsl:value-of select="concat($G_sNewLine, '/**', $G_sNewLine)"/>
|
---|
[38796] | 474 | </xsl:template>
|
---|
| 475 |
|
---|
| 476 | <!--
|
---|
[46478] | 477 | * common middle part of the comment block
|
---|
[38796] | 478 | -->
|
---|
| 479 | <xsl:template match="desc" mode="middle">
|
---|
| 480 | <xsl:apply-templates select="text() | *[not(self::note or self::see)]"/>
|
---|
| 481 | <xsl:apply-templates select="note"/>
|
---|
| 482 | <xsl:apply-templates select="see"/>
|
---|
| 483 | </xsl:template>
|
---|
| 484 |
|
---|
| 485 | <!--
|
---|
[46478] | 486 | * result part of the comment block
|
---|
[38796] | 487 | -->
|
---|
| 488 | <xsl:template match="desc" mode="results">
|
---|
| 489 | <xsl:if test="result">
|
---|
[97711] | 490 | <xsl:text> <p></p><dl><dt><b>Expected result codes:</b></dt> </xsl:text>
|
---|
[38796] | 491 | <xsl:for-each select="result">
|
---|
[97709] | 492 | <xsl:text><dd><code></xsl:text>
|
---|
[38796] | 493 | <xsl:choose>
|
---|
| 494 | <xsl:when test="ancestor::library/result[@name=current()/@name]">
|
---|
[97710] | 495 | <xsl:value-of select="concat('@link ::', @name, ' ', @name)"/>
|
---|
[38796] | 496 | </xsl:when>
|
---|
| 497 | <xsl:otherwise>
|
---|
[97710] | 498 | <xsl:value-of select="@name"/>
|
---|
[38796] | 499 | </xsl:otherwise>
|
---|
| 500 | </xsl:choose>
|
---|
[97709] | 501 | <xsl:text></code> - </xsl:text>
|
---|
[38796] | 502 | <xsl:apply-templates select="text() | *[not(self::note or self::see or
|
---|
| 503 | self::result)]"/>
|
---|
[97709] | 504 | <xsl:text></dd> </xsl:text>
|
---|
[38796] | 505 | </xsl:for-each>
|
---|
[97711] | 506 | <xsl:text></dl> </xsl:text>
|
---|
[38796] | 507 | </xsl:if>
|
---|
| 508 | </xsl:template>
|
---|
| 509 |
|
---|
| 510 | <!--
|
---|
[46478] | 511 | * comment for interfaces
|
---|
[38796] | 512 | -->
|
---|
| 513 | <xsl:template match="desc" mode="interface">
|
---|
| 514 | <xsl:apply-templates select="." mode="begin"/>
|
---|
| 515 | <xsl:apply-templates select="." mode="middle"/>
|
---|
[97677] | 516 | <xsl:text> Interface ID: <code>{</xsl:text>
|
---|
[53939] | 517 | <xsl:call-template name="string-to-upper">
|
---|
[38796] | 518 | <xsl:with-param name="str" select="../@uuid"/>
|
---|
| 519 | </xsl:call-template>
|
---|
[97677] | 520 | <xsl:text>}</code> */ </xsl:text>
|
---|
[38796] | 521 | </xsl:template>
|
---|
| 522 |
|
---|
| 523 | <!--
|
---|
[46478] | 524 | * comment for attribute getters
|
---|
[38796] | 525 | -->
|
---|
| 526 | <xsl:template match="desc" mode="attribute_get">
|
---|
| 527 | <xsl:apply-templates select="." mode="begin"/>
|
---|
| 528 | <xsl:apply-templates select="text() | *[not(self::note or self::see or self::result)]"/>
|
---|
| 529 | <xsl:apply-templates select="." mode="results"/>
|
---|
| 530 | <xsl:apply-templates select="note"/>
|
---|
| 531 | <xsl:text> @return </xsl:text>
|
---|
| 532 | <xsl:call-template name="typeIdl2Glue">
|
---|
| 533 | <xsl:with-param name="type" select="../@type"/>
|
---|
| 534 | <xsl:with-param name="safearray" select="../@safearray"/>
|
---|
[53385] | 535 | <xsl:with-param name="doubleescape">yes</xsl:with-param>
|
---|
[38796] | 536 | </xsl:call-template>
|
---|
| 537 | <xsl:text> </xsl:text>
|
---|
| 538 | <xsl:apply-templates select="see"/>
|
---|
[46478] | 539 | <xsl:text>*/ </xsl:text>
|
---|
[38796] | 540 | </xsl:template>
|
---|
| 541 |
|
---|
| 542 | <!--
|
---|
[46478] | 543 | * comment for attribute setters
|
---|
[38796] | 544 | -->
|
---|
| 545 | <xsl:template match="desc" mode="attribute_set">
|
---|
| 546 | <xsl:apply-templates select="." mode="begin"/>
|
---|
| 547 | <xsl:apply-templates select="text() | *[not(self::note or self::see or self::result)]"/>
|
---|
| 548 | <xsl:apply-templates select="." mode="results"/>
|
---|
| 549 | <xsl:apply-templates select="note"/>
|
---|
| 550 | <xsl:text> @param value </xsl:text>
|
---|
| 551 | <xsl:call-template name="typeIdl2Glue">
|
---|
| 552 | <xsl:with-param name="type" select="../@type"/>
|
---|
| 553 | <xsl:with-param name="safearray" select="../@safearray"/>
|
---|
[53385] | 554 | <xsl:with-param name="doubleescape">yes</xsl:with-param>
|
---|
[38796] | 555 | </xsl:call-template>
|
---|
| 556 | <xsl:text> </xsl:text>
|
---|
| 557 | <xsl:apply-templates select="see"/>
|
---|
| 558 | <xsl:text> */ </xsl:text>
|
---|
| 559 | </xsl:template>
|
---|
| 560 |
|
---|
| 561 | <!--
|
---|
[46478] | 562 | * comment for methods
|
---|
[38796] | 563 | -->
|
---|
| 564 | <xsl:template match="desc" mode="method">
|
---|
| 565 | <xsl:apply-templates select="." mode="begin"/>
|
---|
| 566 | <xsl:apply-templates select="text() | *[not(self::note or self::see or self::result)]"/>
|
---|
[97709] | 567 | <xsl:apply-templates select="." mode="results"/>
|
---|
[38796] | 568 | <xsl:for-each select="../param">
|
---|
| 569 | <xsl:apply-templates select="desc"/>
|
---|
| 570 | </xsl:for-each>
|
---|
| 571 | <xsl:apply-templates select="note"/>
|
---|
| 572 | <xsl:apply-templates select="../param/desc/note"/>
|
---|
| 573 | <xsl:apply-templates select="see"/>
|
---|
| 574 | <xsl:text> */ </xsl:text>
|
---|
| 575 | </xsl:template>
|
---|
| 576 |
|
---|
| 577 | <!--
|
---|
[46478] | 578 | * comment for method parameters
|
---|
[38796] | 579 | -->
|
---|
| 580 | <xsl:template match="method/param/desc">
|
---|
| 581 | <xsl:if test="text() | *[not(self::note or self::see)]">
|
---|
| 582 | <xsl:choose>
|
---|
| 583 | <xsl:when test="../@dir='return'">
|
---|
| 584 | <xsl:text> @return </xsl:text>
|
---|
| 585 | </xsl:when>
|
---|
| 586 | <xsl:otherwise>
|
---|
| 587 | <xsl:text> @param </xsl:text>
|
---|
| 588 | <xsl:value-of select="../@name"/>
|
---|
| 589 | <xsl:text> </xsl:text>
|
---|
| 590 | </xsl:otherwise>
|
---|
| 591 | </xsl:choose>
|
---|
| 592 | <xsl:apply-templates select="text() | *[not(self::note or self::see)]"/>
|
---|
| 593 | <xsl:text> </xsl:text>
|
---|
| 594 | </xsl:if>
|
---|
| 595 | </xsl:template>
|
---|
| 596 |
|
---|
| 597 | <!--
|
---|
[46478] | 598 | * comment for enums
|
---|
[38796] | 599 | -->
|
---|
| 600 | <xsl:template match="desc" mode="enum">
|
---|
| 601 | <xsl:apply-templates select="." mode="begin"/>
|
---|
| 602 | <xsl:apply-templates select="." mode="middle"/>
|
---|
[97677] | 603 | <xsl:text> Interface ID: <code>{</xsl:text>
|
---|
[53939] | 604 | <xsl:call-template name="string-to-upper">
|
---|
[38796] | 605 | <xsl:with-param name="str" select="../@uuid"/>
|
---|
| 606 | </xsl:call-template>
|
---|
[97677] | 607 | <xsl:text>}</code> */ </xsl:text>
|
---|
[38796] | 608 | </xsl:template>
|
---|
| 609 |
|
---|
| 610 | <!--
|
---|
[46478] | 611 | * comment for enum values
|
---|
[38796] | 612 | -->
|
---|
| 613 | <xsl:template match="desc" mode="enum_const">
|
---|
| 614 | <xsl:apply-templates select="." mode="begin"/>
|
---|
| 615 | <xsl:apply-templates select="." mode="middle"/>
|
---|
| 616 | <xsl:text> */ </xsl:text>
|
---|
| 617 | </xsl:template>
|
---|
| 618 |
|
---|
| 619 | <!--
|
---|
[46478] | 620 | * ignore descGroups by default (processed in /idl)
|
---|
[38796] | 621 | -->
|
---|
| 622 | <xsl:template match="descGroup"/>
|
---|
| 623 |
|
---|
| 624 |
|
---|
| 625 |
|
---|
| 626 | <!-- actual code generation -->
|
---|
| 627 |
|
---|
[30987] | 628 | <xsl:template name="genEnum">
|
---|
| 629 | <xsl:param name="enumname" />
|
---|
| 630 | <xsl:param name="filename" />
|
---|
| 631 |
|
---|
| 632 | <xsl:call-template name="startFile">
|
---|
| 633 | <xsl:with-param name="file" select="$filename" />
|
---|
| 634 | <xsl:with-param name="package" select="$G_virtualBoxPackage" />
|
---|
| 635 | </xsl:call-template>
|
---|
| 636 |
|
---|
[46478] | 637 | <xsl:if test="$filelistonly=''">
|
---|
| 638 | <xsl:apply-templates select="desc" mode="enum"/>
|
---|
| 639 | <xsl:value-of select="concat('public enum ', $enumname, ' ')" />
|
---|
| 640 | <xsl:text>{ </xsl:text>
|
---|
| 641 | <xsl:for-each select="const">
|
---|
| 642 | <xsl:apply-templates select="desc" mode="enum_const"/>
|
---|
| 643 | <xsl:variable name="enumconst" select="@name" />
|
---|
| 644 | <xsl:value-of select="concat(' ', $enumconst, '(', @value, ')')" />
|
---|
| 645 | <xsl:choose>
|
---|
| 646 | <xsl:when test="not(position()=last())">
|
---|
| 647 | <xsl:text>, </xsl:text>
|
---|
| 648 | </xsl:when>
|
---|
| 649 | <xsl:otherwise>
|
---|
| 650 | <xsl:text>; </xsl:text>
|
---|
| 651 | </xsl:otherwise>
|
---|
| 652 | </xsl:choose>
|
---|
| 653 | </xsl:for-each>
|
---|
[30987] | 654 |
|
---|
[46478] | 655 | <xsl:text> </xsl:text>
|
---|
| 656 | <xsl:text> private final int value; </xsl:text>
|
---|
[30987] | 657 |
|
---|
[46478] | 658 | <xsl:value-of select="concat(' ', $enumname, '(int v) ')" />
|
---|
| 659 | <xsl:text> { </xsl:text>
|
---|
| 660 | <xsl:text> value = v; </xsl:text>
|
---|
| 661 | <xsl:text> } </xsl:text>
|
---|
[30987] | 662 |
|
---|
[46478] | 663 | <xsl:text> public int value() </xsl:text>
|
---|
| 664 | <xsl:text> { </xsl:text>
|
---|
| 665 | <xsl:text> return value; </xsl:text>
|
---|
| 666 | <xsl:text> } </xsl:text>
|
---|
[30987] | 667 |
|
---|
[46478] | 668 | <xsl:value-of select="concat(' public static ', $enumname, ' fromValue(long v) ')" />
|
---|
| 669 | <xsl:text> { </xsl:text>
|
---|
| 670 | <xsl:value-of select="concat(' for (', $enumname, ' c: ', $enumname, '.values()) ')" />
|
---|
| 671 | <xsl:text> { </xsl:text>
|
---|
| 672 | <xsl:text> if (c.value == (int)v) </xsl:text>
|
---|
| 673 | <xsl:text> { </xsl:text>
|
---|
| 674 | <xsl:text> return c; </xsl:text>
|
---|
| 675 | <xsl:text> } </xsl:text>
|
---|
| 676 | <xsl:text> } </xsl:text>
|
---|
| 677 | <xsl:text> throw new IllegalArgumentException(Long.toString(v)); </xsl:text>
|
---|
| 678 | <xsl:text> } </xsl:text>
|
---|
[30987] | 679 |
|
---|
[46478] | 680 | <xsl:value-of select="concat(' public static ', $enumname, ' fromValue(String v) ')" />
|
---|
| 681 | <xsl:text> { </xsl:text>
|
---|
| 682 | <xsl:value-of select="concat(' return valueOf(', $enumname, '.class, v); ')" />
|
---|
| 683 | <xsl:text> } </xsl:text>
|
---|
| 684 | <xsl:text>} </xsl:text>
|
---|
| 685 | </xsl:if>
|
---|
[30987] | 686 |
|
---|
| 687 | <xsl:call-template name="endFile">
|
---|
| 688 | <xsl:with-param name="file" select="$filename" />
|
---|
| 689 | </xsl:call-template>
|
---|
| 690 |
|
---|
| 691 | </xsl:template>
|
---|
| 692 |
|
---|
| 693 | <xsl:template name="startExcWrapper">
|
---|
[61203] | 694 | <xsl:param name="preventObjRelease" />
|
---|
| 695 |
|
---|
| 696 | <xsl:if test="$G_vboxGlueStyle='jaxws' and $preventObjRelease">
|
---|
| 697 | <xsl:text> this.getObjMgr().preventObjRelease(); </xsl:text>
|
---|
| 698 | </xsl:if>
|
---|
[46478] | 699 | <xsl:text> try </xsl:text>
|
---|
| 700 | <xsl:text> { </xsl:text>
|
---|
[30987] | 701 | </xsl:template>
|
---|
| 702 |
|
---|
| 703 | <xsl:template name="endExcWrapper">
|
---|
[61203] | 704 | <xsl:param name="allowObjRelease" />
|
---|
[30987] | 705 |
|
---|
| 706 | <xsl:choose>
|
---|
| 707 | <xsl:when test="$G_vboxGlueStyle='xpcom'">
|
---|
[46478] | 708 | <xsl:text> } </xsl:text>
|
---|
| 709 | <xsl:text> catch (org.mozilla.xpcom.XPCOMException e) </xsl:text>
|
---|
| 710 | <xsl:text> { </xsl:text>
|
---|
| 711 | <xsl:text> throw new VBoxException(e.getMessage(), e); </xsl:text>
|
---|
| 712 | <xsl:text> } </xsl:text>
|
---|
[30987] | 713 | </xsl:when>
|
---|
| 714 |
|
---|
| 715 | <xsl:when test="$G_vboxGlueStyle='mscom'">
|
---|
[46478] | 716 | <xsl:text> } </xsl:text>
|
---|
| 717 | <xsl:text> catch (com.jacob.com.ComException e) </xsl:text>
|
---|
| 718 | <xsl:text> { </xsl:text>
|
---|
| 719 | <xsl:text> throw new VBoxException(e.getMessage(), e); </xsl:text>
|
---|
| 720 | <xsl:text> } </xsl:text>
|
---|
[30987] | 721 | </xsl:when>
|
---|
| 722 |
|
---|
| 723 | <xsl:when test="$G_vboxGlueStyle='jaxws'">
|
---|
[46478] | 724 | <xsl:text> } </xsl:text>
|
---|
| 725 | <xsl:text> catch (InvalidObjectFaultMsg e) </xsl:text>
|
---|
| 726 | <xsl:text> { </xsl:text>
|
---|
[61203] | 727 | <xsl:text> throw new VBoxException(e.getMessage(), e, this.getObjMgr(), this.port); </xsl:text>
|
---|
[46478] | 728 | <xsl:text> } </xsl:text>
|
---|
| 729 | <xsl:text> catch (RuntimeFaultMsg e) </xsl:text>
|
---|
| 730 | <xsl:text> { </xsl:text>
|
---|
[61203] | 731 | <xsl:text> throw new VBoxException(e.getMessage(), e, this.getObjMgr(), this.port); </xsl:text>
|
---|
[46478] | 732 | <xsl:text> } </xsl:text>
|
---|
[61203] | 733 | <xsl:if test="$allowObjRelease">
|
---|
| 734 | <xsl:text> finally </xsl:text>
|
---|
| 735 | <xsl:text> { </xsl:text>
|
---|
| 736 | <xsl:text> getObjMgr().allowObjRelease(); </xsl:text>
|
---|
| 737 | <xsl:text> } </xsl:text>
|
---|
| 738 | </xsl:if>
|
---|
[30987] | 739 | </xsl:when>
|
---|
| 740 |
|
---|
| 741 | <xsl:otherwise>
|
---|
| 742 | <xsl:call-template name="fatalError">
|
---|
| 743 | <xsl:with-param name="msg" select="'no header rule (startFile)'" />
|
---|
| 744 | </xsl:call-template>
|
---|
| 745 | </xsl:otherwise>
|
---|
| 746 | </xsl:choose>
|
---|
| 747 | </xsl:template>
|
---|
| 748 |
|
---|
| 749 | <xsl:template name="wrappedName">
|
---|
| 750 | <xsl:param name="ifname" />
|
---|
| 751 |
|
---|
| 752 | <xsl:choose>
|
---|
| 753 | <xsl:when test="$G_vboxGlueStyle='xpcom'">
|
---|
[46478] | 754 | <xsl:value-of select="concat('org.mozilla.interfaces.', $ifname)" />
|
---|
[30987] | 755 | </xsl:when>
|
---|
| 756 |
|
---|
| 757 | <xsl:when test="$G_vboxGlueStyle='mscom'">
|
---|
[46478] | 758 | <xsl:text>com.jacob.com.Dispatch</xsl:text>
|
---|
[30987] | 759 | </xsl:when>
|
---|
| 760 |
|
---|
| 761 | <xsl:when test="$G_vboxGlueStyle='jaxws'">
|
---|
[46478] | 762 | <xsl:text>String</xsl:text>
|
---|
[30987] | 763 | </xsl:when>
|
---|
| 764 |
|
---|
| 765 | <xsl:otherwise>
|
---|
| 766 | <xsl:call-template name="fatalError">
|
---|
| 767 | <xsl:with-param name="msg" select="'no wrapper naming rule defined (wrappedName)'" />
|
---|
| 768 | </xsl:call-template>
|
---|
| 769 | </xsl:otherwise>
|
---|
| 770 |
|
---|
| 771 | </xsl:choose>
|
---|
| 772 | </xsl:template>
|
---|
| 773 |
|
---|
| 774 | <xsl:template name="fullClassName">
|
---|
| 775 | <xsl:param name="name" />
|
---|
| 776 | <xsl:param name="origname" />
|
---|
| 777 | <xsl:param name="collPrefix" />
|
---|
[46478] | 778 |
|
---|
| 779 | <xsl:choose>
|
---|
[53922] | 780 | <xsl:when test="(count(key('G_keyEnumsByName', $name)) > 0) or (count(key('G_keyEnumsByName', $origname)) > 0)">
|
---|
[46478] | 781 | <xsl:value-of select="concat($G_virtualBoxPackage, concat('.', $name))" />
|
---|
| 782 | </xsl:when>
|
---|
[53922] | 783 | <xsl:when test="count(key('G_keyInterfacesByName', $name)) > 0">
|
---|
[46478] | 784 | <xsl:value-of select="concat($G_virtualBoxPackage, concat('.', $name))" />
|
---|
| 785 | </xsl:when>
|
---|
| 786 | <xsl:otherwise>
|
---|
[30987] | 787 | <xsl:call-template name="fatalError">
|
---|
| 788 | <xsl:with-param name="msg" select="concat('fullClassName: Type "', $name, '" is not supported.')" />
|
---|
| 789 | </xsl:call-template>
|
---|
[46478] | 790 | </xsl:otherwise>
|
---|
| 791 | </xsl:choose>
|
---|
[30987] | 792 | </xsl:template>
|
---|
| 793 |
|
---|
| 794 | <xsl:template name="typeIdl2Glue">
|
---|
| 795 | <xsl:param name="type" />
|
---|
| 796 | <xsl:param name="safearray" />
|
---|
| 797 | <xsl:param name="forceelem" />
|
---|
[38796] | 798 | <xsl:param name="skiplisttype" />
|
---|
[53385] | 799 | <xsl:param name="doubleescape" />
|
---|
[30987] | 800 |
|
---|
| 801 | <xsl:variable name="needarray" select="($safearray='yes') and not($forceelem='yes')" />
|
---|
[31708] | 802 | <xsl:variable name="needlist" select="($needarray) and not($type='octet')" />
|
---|
[30987] | 803 |
|
---|
[31708] | 804 | <xsl:if test="($needlist)">
|
---|
[46478] | 805 | <xsl:text>List</xsl:text>
|
---|
[38796] | 806 | <xsl:if test="not($skiplisttype='yes')">
|
---|
[53385] | 807 | <xsl:choose>
|
---|
| 808 | <xsl:when test="$doubleescape='yes'">
|
---|
| 809 | <xsl:text>&lt;</xsl:text>
|
---|
| 810 | </xsl:when>
|
---|
| 811 | <xsl:otherwise>
|
---|
| 812 | <xsl:text><</xsl:text>
|
---|
| 813 | </xsl:otherwise>
|
---|
| 814 | </xsl:choose>
|
---|
[38796] | 815 | </xsl:if>
|
---|
[30987] | 816 | </xsl:if>
|
---|
| 817 |
|
---|
[38796] | 818 | <xsl:if test="not($needlist) or not($skiplisttype='yes')">
|
---|
[45483] | 819 | <!-- look up Java type from IDL type from table array in typemap-shared.inc.xsl -->
|
---|
[38796] | 820 | <xsl:variable name="javatypefield" select="exsl:node-set($G_aSharedTypes)/type[@idlname=$type]/@javaname" />
|
---|
[30987] | 821 |
|
---|
[38796] | 822 | <xsl:choose>
|
---|
| 823 | <xsl:when test="string-length($javatypefield)">
|
---|
| 824 | <xsl:value-of select="$javatypefield" />
|
---|
| 825 | </xsl:when>
|
---|
| 826 | <!-- not a standard type: then it better be one of the types defined in the XIDL -->
|
---|
| 827 | <xsl:when test="$type='$unknown'">IUnknown</xsl:when>
|
---|
| 828 | <xsl:otherwise>
|
---|
| 829 | <xsl:call-template name="fullClassName">
|
---|
| 830 | <xsl:with-param name="name" select="$type" />
|
---|
| 831 | <xsl:with-param name="collPrefix" select="''"/>
|
---|
| 832 | </xsl:call-template>
|
---|
| 833 | </xsl:otherwise>
|
---|
| 834 | </xsl:choose>
|
---|
| 835 | </xsl:if>
|
---|
[30987] | 836 |
|
---|
[31708] | 837 | <xsl:choose>
|
---|
| 838 | <xsl:when test="($needlist)">
|
---|
[38796] | 839 | <xsl:if test="not($skiplisttype='yes')">
|
---|
[53385] | 840 | <xsl:choose>
|
---|
| 841 | <xsl:when test="$doubleescape='yes'">
|
---|
| 842 | <xsl:text>&gt;</xsl:text>
|
---|
| 843 | </xsl:when>
|
---|
| 844 | <xsl:otherwise>
|
---|
| 845 | <xsl:text>></xsl:text>
|
---|
| 846 | </xsl:otherwise>
|
---|
| 847 | </xsl:choose>
|
---|
[38796] | 848 | </xsl:if>
|
---|
[31708] | 849 | </xsl:when>
|
---|
| 850 | <xsl:when test="($needarray)">
|
---|
[46478] | 851 | <xsl:text>[]</xsl:text>
|
---|
[31708] | 852 | </xsl:when>
|
---|
| 853 | </xsl:choose>
|
---|
[30987] | 854 | </xsl:template>
|
---|
| 855 |
|
---|
| 856 | <!--
|
---|
| 857 | typeIdl2Back: converts $type into a type as used by the backend.
|
---|
| 858 | -->
|
---|
| 859 | <xsl:template name="typeIdl2Back">
|
---|
| 860 | <xsl:param name="type" />
|
---|
| 861 | <xsl:param name="safearray" />
|
---|
[38912] | 862 | <xsl:param name="forceelem" />
|
---|
[30987] | 863 |
|
---|
[38912] | 864 | <xsl:choose>
|
---|
[36883] | 865 | <xsl:when test="($G_vboxGlueStyle='xpcom')">
|
---|
| 866 | <xsl:variable name="needarray" select="($safearray='yes') and not($forceelem='yes')" />
|
---|
[30987] | 867 |
|
---|
| 868 | <xsl:choose>
|
---|
| 869 | <xsl:when test="$type='long long'">
|
---|
[46478] | 870 | <xsl:text>long</xsl:text>
|
---|
[30987] | 871 | </xsl:when>
|
---|
| 872 |
|
---|
| 873 | <xsl:when test="$type='unsigned long'">
|
---|
[46478] | 874 | <xsl:text>long</xsl:text>
|
---|
[30987] | 875 | </xsl:when>
|
---|
| 876 |
|
---|
| 877 | <xsl:when test="$type='long'">
|
---|
[46478] | 878 | <xsl:text>int</xsl:text>
|
---|
[30987] | 879 | </xsl:when>
|
---|
| 880 |
|
---|
| 881 | <xsl:when test="$type='unsigned short'">
|
---|
[46478] | 882 | <xsl:text>int</xsl:text>
|
---|
[30987] | 883 | </xsl:when>
|
---|
| 884 |
|
---|
| 885 | <xsl:when test="$type='short'">
|
---|
[46478] | 886 | <xsl:text>short</xsl:text>
|
---|
[30987] | 887 | </xsl:when>
|
---|
| 888 |
|
---|
| 889 | <xsl:when test="$type='octet'">
|
---|
[46478] | 890 | <xsl:text>byte</xsl:text>
|
---|
[30987] | 891 | </xsl:when>
|
---|
| 892 |
|
---|
| 893 | <xsl:when test="$type='boolean'">
|
---|
[46478] | 894 | <xsl:text>boolean</xsl:text>
|
---|
[30987] | 895 | </xsl:when>
|
---|
| 896 |
|
---|
| 897 | <xsl:when test="$type='$unknown'">
|
---|
[46478] | 898 | <xsl:text>nsISupports</xsl:text>
|
---|
[30987] | 899 | </xsl:when>
|
---|
| 900 |
|
---|
| 901 | <xsl:when test="$type='wstring'">
|
---|
[46478] | 902 | <xsl:text>String</xsl:text>
|
---|
[30987] | 903 | </xsl:when>
|
---|
| 904 |
|
---|
| 905 | <xsl:when test="$type='uuid'">
|
---|
[46478] | 906 | <xsl:text>String</xsl:text>
|
---|
[30987] | 907 | </xsl:when>
|
---|
| 908 |
|
---|
[53922] | 909 | <xsl:when test="key('G_keyInterfacesByName', $type)/@wsmap='struct'">
|
---|
[30987] | 910 | <xsl:call-template name="wrappedName">
|
---|
| 911 | <xsl:with-param name="ifname" select="$type" />
|
---|
| 912 | </xsl:call-template>
|
---|
| 913 | </xsl:when>
|
---|
| 914 |
|
---|
[53922] | 915 | <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
|
---|
[30987] | 916 | <xsl:call-template name="wrappedName">
|
---|
| 917 | <xsl:with-param name="ifname" select="$type" />
|
---|
| 918 | </xsl:call-template>
|
---|
| 919 | </xsl:when>
|
---|
| 920 |
|
---|
[53922] | 921 | <xsl:when test="count(key('G_keyEnumsByName', $type)) > 0">
|
---|
[46478] | 922 | <xsl:text>long</xsl:text>
|
---|
[30987] | 923 | </xsl:when>
|
---|
| 924 |
|
---|
| 925 | <xsl:otherwise>
|
---|
| 926 | <xsl:call-template name="fullClassName">
|
---|
| 927 | <xsl:with-param name="name" select="$type" />
|
---|
| 928 | </xsl:call-template>
|
---|
| 929 | </xsl:otherwise>
|
---|
| 930 |
|
---|
| 931 | </xsl:choose>
|
---|
| 932 | <xsl:if test="$needarray">
|
---|
[46478] | 933 | <xsl:text>[]</xsl:text>
|
---|
[30987] | 934 | </xsl:if>
|
---|
| 935 | </xsl:when>
|
---|
| 936 |
|
---|
| 937 | <xsl:when test="($G_vboxGlueStyle='mscom')">
|
---|
[46478] | 938 | <xsl:text>Variant</xsl:text>
|
---|
[30987] | 939 | </xsl:when>
|
---|
| 940 |
|
---|
| 941 | <xsl:when test="($G_vboxGlueStyle='jaxws')">
|
---|
[36883] | 942 | <xsl:variable name="needarray" select="($safearray='yes' and not($type='octet')) and not($forceelem='yes')" />
|
---|
[38912] | 943 |
|
---|
[30987] | 944 | <xsl:if test="$needarray">
|
---|
[46478] | 945 | <xsl:text>List<</xsl:text>
|
---|
[30987] | 946 | </xsl:if>
|
---|
| 947 | <xsl:choose>
|
---|
| 948 | <xsl:when test="$type='$unknown'">
|
---|
[46478] | 949 | <xsl:text>String</xsl:text>
|
---|
[30987] | 950 | </xsl:when>
|
---|
| 951 |
|
---|
[53922] | 952 | <xsl:when test="key('G_keyInterfacesByName', $type)/@wsmap='managed'">
|
---|
[46478] | 953 | <xsl:text>String</xsl:text>
|
---|
[30987] | 954 | </xsl:when>
|
---|
| 955 |
|
---|
[53922] | 956 | <xsl:when test="key('G_keyInterfacesByName', $type)/@wsmap='struct'">
|
---|
[30987] | 957 | <xsl:value-of select="concat($G_virtualBoxPackageCom, '.', $type)" />
|
---|
| 958 | </xsl:when>
|
---|
| 959 |
|
---|
[53922] | 960 | <xsl:when test="count(key('G_keyEnumsByName', $type)) > 0">
|
---|
[30987] | 961 | <xsl:value-of select="concat($G_virtualBoxPackageCom, '.', $type)" />
|
---|
| 962 | </xsl:when>
|
---|
| 963 |
|
---|
[36883] | 964 | <!-- we encode byte arrays as Base64 strings. -->
|
---|
| 965 | <xsl:when test="$type='octet'">
|
---|
[46478] | 966 | <xsl:text>/*base64*/String</xsl:text>
|
---|
[36883] | 967 | </xsl:when>
|
---|
| 968 |
|
---|
[30987] | 969 | <xsl:when test="$type='long long'">
|
---|
[46478] | 970 | <xsl:text>Long</xsl:text>
|
---|
[30987] | 971 | </xsl:when>
|
---|
| 972 |
|
---|
| 973 | <xsl:when test="$type='unsigned long'">
|
---|
[46478] | 974 | <xsl:text>Long</xsl:text>
|
---|
[30987] | 975 | </xsl:when>
|
---|
| 976 |
|
---|
| 977 | <xsl:when test="$type='long'">
|
---|
[46478] | 978 | <xsl:text>Integer</xsl:text>
|
---|
[30987] | 979 | </xsl:when>
|
---|
| 980 |
|
---|
| 981 | <xsl:when test="$type='unsigned short'">
|
---|
[46478] | 982 | <xsl:text>Integer</xsl:text>
|
---|
[30987] | 983 | </xsl:when>
|
---|
| 984 |
|
---|
| 985 | <xsl:when test="$type='short'">
|
---|
[46478] | 986 | <xsl:text>Short</xsl:text>
|
---|
[30987] | 987 | </xsl:when>
|
---|
| 988 |
|
---|
| 989 | <xsl:when test="$type='boolean'">
|
---|
[46478] | 990 | <xsl:text>Boolean</xsl:text>
|
---|
[30987] | 991 | </xsl:when>
|
---|
| 992 |
|
---|
| 993 | <xsl:when test="$type='wstring'">
|
---|
[46478] | 994 | <xsl:text>String</xsl:text>
|
---|
[30987] | 995 | </xsl:when>
|
---|
| 996 |
|
---|
| 997 | <xsl:when test="$type='uuid'">
|
---|
[46478] | 998 | <xsl:text>String</xsl:text>
|
---|
[30987] | 999 | </xsl:when>
|
---|
| 1000 |
|
---|
| 1001 | <xsl:otherwise>
|
---|
| 1002 | <xsl:call-template name="fatalError">
|
---|
[46478] | 1003 | <xsl:with-param name="msg" select="concat('Unhandled type ', $type, ' (typeIdl2Back)')" />
|
---|
[30987] | 1004 | </xsl:call-template>
|
---|
| 1005 | </xsl:otherwise>
|
---|
| 1006 |
|
---|
| 1007 | </xsl:choose>
|
---|
| 1008 |
|
---|
| 1009 | <xsl:if test="$needarray">
|
---|
[46478] | 1010 | <xsl:text>></xsl:text>
|
---|
[30987] | 1011 | </xsl:if>
|
---|
| 1012 | </xsl:when>
|
---|
| 1013 |
|
---|
| 1014 | <xsl:otherwise>
|
---|
| 1015 | <xsl:call-template name="fatalError">
|
---|
| 1016 | <xsl:with-param name="msg" select="'Write typeIdl2Back for this style (typeIdl2Back)'" />
|
---|
| 1017 | </xsl:call-template>
|
---|
| 1018 | </xsl:otherwise>
|
---|
| 1019 |
|
---|
| 1020 | </xsl:choose>
|
---|
| 1021 | </xsl:template>
|
---|
| 1022 |
|
---|
| 1023 | <xsl:template name="cookOutParamXpcom">
|
---|
| 1024 | <xsl:param name="value"/>
|
---|
| 1025 | <xsl:param name="idltype"/>
|
---|
| 1026 | <xsl:param name="safearray"/>
|
---|
| 1027 | <xsl:variable name="isstruct"
|
---|
[53922] | 1028 | select="key('G_keyInterfacesByName', $idltype)/@wsmap='struct'" />
|
---|
[30987] | 1029 |
|
---|
| 1030 | <xsl:variable name="gluetype">
|
---|
| 1031 | <xsl:call-template name="typeIdl2Glue">
|
---|
| 1032 | <xsl:with-param name="type" select="$idltype" />
|
---|
| 1033 | <xsl:with-param name="safearray" select="$safearray" />
|
---|
| 1034 | </xsl:call-template>
|
---|
| 1035 | </xsl:variable>
|
---|
| 1036 |
|
---|
| 1037 | <xsl:variable name="elemgluetype">
|
---|
| 1038 | <xsl:if test="$safearray='yes'">
|
---|
| 1039 | <xsl:call-template name="typeIdl2Glue">
|
---|
| 1040 | <xsl:with-param name="type" select="$idltype" />
|
---|
| 1041 | <xsl:with-param name="safearray" select="'no'" />
|
---|
| 1042 | <xsl:with-param name="forceelem" select="'yes'" />
|
---|
| 1043 | </xsl:call-template>
|
---|
| 1044 | </xsl:if>
|
---|
| 1045 | </xsl:variable>
|
---|
| 1046 |
|
---|
| 1047 | <xsl:choose>
|
---|
[53922] | 1048 | <xsl:when test="$idltype = '$unknown' or (count(key('G_keyInterfacesByName', $idltype)) > 0)">
|
---|
[30987] | 1049 | <xsl:choose>
|
---|
| 1050 | <xsl:when test="$safearray='yes'">
|
---|
| 1051 | <xsl:variable name="elembacktype">
|
---|
| 1052 | <xsl:call-template name="typeIdl2Back">
|
---|
| 1053 | <xsl:with-param name="type" select="$idltype" />
|
---|
| 1054 | <xsl:with-param name="safearray" select="$safearray" />
|
---|
| 1055 | <xsl:with-param name="forceelem" select="'yes'" />
|
---|
| 1056 | </xsl:call-template>
|
---|
| 1057 | </xsl:variable>
|
---|
[46478] | 1058 | <xsl:value-of select="concat('Helper.wrap2(', $elemgluetype, '.class, ', $elembacktype, '.class, ', $value, ')')"/>
|
---|
[30987] | 1059 | </xsl:when>
|
---|
| 1060 | <xsl:otherwise>
|
---|
[46478] | 1061 | <xsl:value-of select="concat('(', $value, ' != null) ? new ', $gluetype, '(', $value, ') : null')" />
|
---|
[30987] | 1062 | </xsl:otherwise>
|
---|
| 1063 | </xsl:choose>
|
---|
| 1064 | </xsl:when>
|
---|
| 1065 |
|
---|
[53922] | 1066 | <xsl:when test="count(key('G_keyEnumsByName', $idltype)) > 0">
|
---|
[46478] | 1067 | <xsl:choose>
|
---|
[30987] | 1068 | <xsl:when test="$safearray='yes'">
|
---|
| 1069 | <xsl:variable name="elembacktype">
|
---|
| 1070 | <xsl:call-template name="typeIdl2Back">
|
---|
| 1071 | <xsl:with-param name="type" select="$idltype" />
|
---|
| 1072 | <xsl:with-param name="safearray" select="$safearray" />
|
---|
| 1073 | <xsl:with-param name="forceelem" select="'yes'" />
|
---|
| 1074 | </xsl:call-template>
|
---|
| 1075 | </xsl:variable>
|
---|
[46478] | 1076 | <xsl:value-of select="concat('Helper.wrapEnum(', $elemgluetype, '.class, ', $value, ')')"/>
|
---|
[30987] | 1077 | </xsl:when>
|
---|
| 1078 | <xsl:otherwise>
|
---|
[46478] | 1079 | <xsl:value-of select="concat($gluetype, '.fromValue(', $value, ')')"/>
|
---|
[30987] | 1080 | </xsl:otherwise>
|
---|
[46478] | 1081 | </xsl:choose>
|
---|
[30987] | 1082 | </xsl:when>
|
---|
| 1083 |
|
---|
[31708] | 1084 | <xsl:otherwise>
|
---|
[30987] | 1085 | <xsl:choose>
|
---|
[31708] | 1086 | <xsl:when test="($safearray='yes') and ($idltype='octet')">
|
---|
| 1087 | <xsl:value-of select="$value"/>
|
---|
[30987] | 1088 | </xsl:when>
|
---|
| 1089 | <xsl:when test="$safearray='yes'">
|
---|
[46478] | 1090 | <xsl:value-of select="concat('Helper.wrap(', $value, ')')"/>
|
---|
[30987] | 1091 | </xsl:when>
|
---|
| 1092 | <xsl:otherwise>
|
---|
| 1093 | <xsl:value-of select="$value"/>
|
---|
| 1094 | </xsl:otherwise>
|
---|
| 1095 | </xsl:choose>
|
---|
| 1096 | </xsl:otherwise>
|
---|
| 1097 | </xsl:choose>
|
---|
| 1098 | </xsl:template>
|
---|
| 1099 |
|
---|
| 1100 | <xsl:template name="cookOutParamMscom">
|
---|
| 1101 | <xsl:param name="value"/>
|
---|
| 1102 | <xsl:param name="idltype"/>
|
---|
| 1103 | <xsl:param name="safearray"/>
|
---|
| 1104 |
|
---|
| 1105 | <xsl:variable name="gluetype">
|
---|
| 1106 | <xsl:call-template name="typeIdl2Glue">
|
---|
| 1107 | <xsl:with-param name="type" select="$idltype" />
|
---|
| 1108 | <xsl:with-param name="safearray" select="$safearray" />
|
---|
| 1109 | </xsl:call-template>
|
---|
| 1110 | </xsl:variable>
|
---|
| 1111 |
|
---|
| 1112 | <xsl:choose>
|
---|
| 1113 | <xsl:when test="$safearray='yes'">
|
---|
| 1114 | <xsl:variable name="elemgluetype">
|
---|
| 1115 | <xsl:call-template name="typeIdl2Glue">
|
---|
| 1116 | <xsl:with-param name="type" select="$idltype" />
|
---|
| 1117 | <xsl:with-param name="safearray" select="'no'" />
|
---|
| 1118 | <xsl:with-param name="forceelem" select="'yes'" />
|
---|
| 1119 | </xsl:call-template>
|
---|
| 1120 | </xsl:variable>
|
---|
[31711] | 1121 | <xsl:choose>
|
---|
| 1122 | <xsl:when test="($idltype='octet')">
|
---|
| 1123 | <xsl:value-of select="concat('Helper.wrapBytes(', $value, '.toSafeArray())')"/>
|
---|
| 1124 | </xsl:when>
|
---|
| 1125 | <xsl:otherwise>
|
---|
[46478] | 1126 | <xsl:value-of select="concat('Helper.wrap(', $elemgluetype, '.class, ', $value, '.toSafeArray())')"/>
|
---|
[31711] | 1127 | </xsl:otherwise>
|
---|
| 1128 | </xsl:choose>
|
---|
[30987] | 1129 | </xsl:when>
|
---|
| 1130 |
|
---|
[53922] | 1131 | <xsl:when test="$idltype = '$unknown' or (count(key('G_keyInterfacesByName', $idltype)) > 0)">
|
---|
[46478] | 1132 | <xsl:value-of select="concat('Helper.wrapDispatch(', $gluetype, '.class, ', $value, '.getDispatch())')"/>
|
---|
[30987] | 1133 | </xsl:when>
|
---|
| 1134 |
|
---|
[53922] | 1135 | <xsl:when test="count(key('G_keyEnumsByName', $idltype)) > 0">
|
---|
[46478] | 1136 | <xsl:value-of select="concat($gluetype, '.fromValue(', $value, '.getInt())')"/>
|
---|
[30987] | 1137 | </xsl:when>
|
---|
| 1138 |
|
---|
| 1139 | <xsl:when test="$idltype='wstring'">
|
---|
[46478] | 1140 | <xsl:value-of select="concat($value, '.getString()')"/>
|
---|
[30987] | 1141 | </xsl:when>
|
---|
| 1142 |
|
---|
| 1143 | <xsl:when test="$idltype='uuid'">
|
---|
[46478] | 1144 | <xsl:value-of select="concat($value, '.getString()')"/>
|
---|
[30987] | 1145 | </xsl:when>
|
---|
| 1146 |
|
---|
[46478] | 1147 | <xsl:when test="$idltype='boolean'">
|
---|
| 1148 | <xsl:value-of select="concat($value, '.toBoolean()')"/>
|
---|
[30987] | 1149 | </xsl:when>
|
---|
| 1150 |
|
---|
| 1151 | <xsl:when test="$idltype='unsigned short'">
|
---|
[46478] | 1152 | <xsl:value-of select="concat('(int)', $value, '.getShort()')"/>
|
---|
[30987] | 1153 | </xsl:when>
|
---|
| 1154 |
|
---|
[46478] | 1155 | <xsl:when test="$idltype='short'">
|
---|
| 1156 | <xsl:value-of select="concat($value, '.getShort()')"/>
|
---|
[30987] | 1157 | </xsl:when>
|
---|
| 1158 |
|
---|
| 1159 | <xsl:when test="$idltype='long'">
|
---|
[46478] | 1160 | <xsl:value-of select="concat($value, '.getInt()')"/>
|
---|
[30987] | 1161 | </xsl:when>
|
---|
| 1162 |
|
---|
| 1163 |
|
---|
| 1164 | <xsl:when test="$idltype='unsigned long'">
|
---|
[46478] | 1165 | <xsl:value-of select="concat('(long)', $value, '.getInt()')"/>
|
---|
[30987] | 1166 | </xsl:when>
|
---|
| 1167 |
|
---|
| 1168 | <xsl:when test="$idltype='long'">
|
---|
[46478] | 1169 | <xsl:value-of select="concat($value, '.getInt()')"/>
|
---|
[30987] | 1170 | </xsl:when>
|
---|
| 1171 |
|
---|
| 1172 | <xsl:when test="$idltype='long long'">
|
---|
[46478] | 1173 | <xsl:value-of select="concat($value, '.getLong()')"/>
|
---|
[30987] | 1174 | </xsl:when>
|
---|
| 1175 |
|
---|
| 1176 | <xsl:otherwise>
|
---|
| 1177 | <xsl:call-template name="fatalError">
|
---|
| 1178 | <xsl:with-param name="msg" select="concat('Unhandled type' , $idltype, ' (cookOutParamMscom)')" />
|
---|
| 1179 | </xsl:call-template>
|
---|
| 1180 | </xsl:otherwise>
|
---|
| 1181 | </xsl:choose>
|
---|
| 1182 |
|
---|
| 1183 | </xsl:template>
|
---|
| 1184 |
|
---|
| 1185 | <xsl:template name="cookOutParamJaxws">
|
---|
| 1186 | <xsl:param name="value"/>
|
---|
| 1187 | <xsl:param name="idltype"/>
|
---|
| 1188 | <xsl:param name="safearray"/>
|
---|
| 1189 |
|
---|
| 1190 | <xsl:variable name="isstruct"
|
---|
[53922] | 1191 | select="key('G_keyInterfacesByName', $idltype)/@wsmap='struct'" />
|
---|
[30987] | 1192 |
|
---|
| 1193 | <xsl:variable name="gluetype">
|
---|
| 1194 | <xsl:call-template name="typeIdl2Glue">
|
---|
| 1195 | <xsl:with-param name="type" select="$idltype" />
|
---|
| 1196 | <xsl:with-param name="safearray" select="$safearray" />
|
---|
| 1197 | </xsl:call-template>
|
---|
| 1198 | </xsl:variable>
|
---|
| 1199 |
|
---|
| 1200 | <xsl:choose>
|
---|
| 1201 | <xsl:when test="$safearray='yes'">
|
---|
| 1202 | <xsl:variable name="elemgluetype">
|
---|
| 1203 | <xsl:call-template name="typeIdl2Glue">
|
---|
| 1204 | <xsl:with-param name="type" select="$idltype" />
|
---|
| 1205 | <xsl:with-param name="safearray" select="''" />
|
---|
| 1206 | <xsl:with-param name="forceelem" select="'yes'" />
|
---|
| 1207 | </xsl:call-template>
|
---|
| 1208 | </xsl:variable>
|
---|
| 1209 | <xsl:variable name="elembacktype">
|
---|
| 1210 | <xsl:call-template name="typeIdl2Back">
|
---|
| 1211 | <xsl:with-param name="type" select="$idltype" />
|
---|
| 1212 | <xsl:with-param name="safearray" select="''" />
|
---|
| 1213 | <xsl:with-param name="forceelem" select="'yes'" />
|
---|
| 1214 | </xsl:call-template>
|
---|
| 1215 | </xsl:variable>
|
---|
| 1216 | <xsl:choose>
|
---|
| 1217 | <xsl:when test="$isstruct">
|
---|
[61203] | 1218 | <xsl:value-of select="concat('Helper.wrap2(', $elemgluetype, '.class, ', $elembacktype, '.class, objMgr, port, ', $value, ')')"/>
|
---|
[30987] | 1219 | </xsl:when>
|
---|
[53922] | 1220 | <xsl:when test="count(key('G_keyEnumsByName', $idltype)) > 0">
|
---|
[46478] | 1221 | <xsl:value-of select="concat('Helper.convertEnums(', $elembacktype, '.class, ', $elemgluetype, '.class, ', $value, ')')"/>
|
---|
[30987] | 1222 | </xsl:when>
|
---|
[53922] | 1223 | <xsl:when test="$idltype = '$unknown' or (count(key('G_keyInterfacesByName', $idltype)) > 0)">
|
---|
[61203] | 1224 | <xsl:value-of select="concat('Helper.wrap(', $elemgluetype, '.class, getObjMgr(), port, ', $value, ')')"/>
|
---|
[30987] | 1225 | </xsl:when>
|
---|
[31708] | 1226 | <xsl:when test="$idltype='octet'">
|
---|
[46478] | 1227 | <xsl:value-of select="concat('Helper.decodeBase64(', $value, ')')"/>
|
---|
[31708] | 1228 | </xsl:when>
|
---|
[30987] | 1229 | <xsl:otherwise>
|
---|
[46478] | 1230 | <xsl:value-of select="$value" />
|
---|
[30987] | 1231 | </xsl:otherwise>
|
---|
| 1232 | </xsl:choose>
|
---|
| 1233 | </xsl:when>
|
---|
| 1234 |
|
---|
| 1235 | <xsl:otherwise>
|
---|
| 1236 | <xsl:choose>
|
---|
[53922] | 1237 | <xsl:when test="count(key('G_keyEnumsByName', $idltype)) > 0">
|
---|
[46478] | 1238 | <xsl:value-of select="concat($gluetype, '.fromValue(', $value, '.value())')"/>
|
---|
[30987] | 1239 | </xsl:when>
|
---|
| 1240 | <xsl:when test="$idltype='boolean'">
|
---|
| 1241 | <xsl:value-of select="$value"/>
|
---|
| 1242 | </xsl:when>
|
---|
| 1243 | <xsl:when test="$idltype='long long'">
|
---|
| 1244 | <xsl:value-of select="$value"/>
|
---|
| 1245 | </xsl:when>
|
---|
| 1246 | <xsl:when test="$idltype='unsigned long long'">
|
---|
| 1247 | <xsl:value-of select="$value"/>
|
---|
| 1248 | </xsl:when>
|
---|
| 1249 | <xsl:when test="$idltype='long'">
|
---|
| 1250 | <xsl:value-of select="$value"/>
|
---|
| 1251 | </xsl:when>
|
---|
| 1252 | <xsl:when test="$idltype='unsigned long'">
|
---|
| 1253 | <xsl:value-of select="$value"/>
|
---|
| 1254 | </xsl:when>
|
---|
| 1255 | <xsl:when test="$idltype='short'">
|
---|
| 1256 | <xsl:value-of select="$value"/>
|
---|
| 1257 | </xsl:when>
|
---|
| 1258 | <xsl:when test="$idltype='unsigned short'">
|
---|
| 1259 | <xsl:value-of select="$value"/>
|
---|
| 1260 | </xsl:when>
|
---|
| 1261 | <xsl:when test="$idltype='wstring'">
|
---|
| 1262 | <xsl:value-of select="$value"/>
|
---|
| 1263 | </xsl:when>
|
---|
| 1264 | <xsl:when test="$idltype='uuid'">
|
---|
| 1265 | <xsl:value-of select="$value"/>
|
---|
| 1266 | </xsl:when>
|
---|
| 1267 | <xsl:when test="$isstruct">
|
---|
[61203] | 1268 | <xsl:value-of select="concat('(', $value, ' != null) ? new ', $gluetype, '(', $value, ', getObjMgr(), port) : null')" />
|
---|
[30987] | 1269 | </xsl:when>
|
---|
[53922] | 1270 | <xsl:when test="$idltype = '$unknown' or (count(key('G_keyInterfacesByName', $idltype)) > 0)">
|
---|
[30987] | 1271 | <!-- if the MOR string is empty, that means NULL, so return NULL instead of an object then -->
|
---|
[61203] | 1272 | <xsl:value-of select="concat('(', $value, '.length() > 0) ? new ', $gluetype, '(', $value, ', getObjMgr(), port) : null')" />
|
---|
[30987] | 1273 | </xsl:when>
|
---|
| 1274 | <xsl:otherwise>
|
---|
| 1275 | <xsl:call-template name="fatalError">
|
---|
[46478] | 1276 | <xsl:with-param name="msg" select="concat('Unhandled type ', $idltype, ' (cookOutParamJaxws)')" />
|
---|
[30987] | 1277 | </xsl:call-template>
|
---|
| 1278 | </xsl:otherwise>
|
---|
| 1279 | </xsl:choose>
|
---|
| 1280 | </xsl:otherwise>
|
---|
| 1281 | </xsl:choose>
|
---|
| 1282 |
|
---|
| 1283 | </xsl:template>
|
---|
| 1284 |
|
---|
| 1285 | <xsl:template name="cookOutParam">
|
---|
| 1286 | <xsl:param name="value"/>
|
---|
| 1287 | <xsl:param name="idltype"/>
|
---|
| 1288 | <xsl:param name="safearray"/>
|
---|
| 1289 | <xsl:choose>
|
---|
| 1290 | <xsl:when test="($G_vboxGlueStyle='xpcom')">
|
---|
| 1291 | <xsl:call-template name="cookOutParamXpcom">
|
---|
| 1292 | <xsl:with-param name="value" select="$value" />
|
---|
| 1293 | <xsl:with-param name="idltype" select="$idltype" />
|
---|
| 1294 | <xsl:with-param name="safearray" select="$safearray" />
|
---|
| 1295 | </xsl:call-template>
|
---|
| 1296 | </xsl:when>
|
---|
| 1297 | <xsl:when test="($G_vboxGlueStyle='mscom')">
|
---|
| 1298 | <xsl:call-template name="cookOutParamMscom">
|
---|
| 1299 | <xsl:with-param name="value" select="$value" />
|
---|
| 1300 | <xsl:with-param name="idltype" select="$idltype" />
|
---|
| 1301 | <xsl:with-param name="safearray" select="$safearray" />
|
---|
| 1302 | </xsl:call-template>
|
---|
| 1303 | </xsl:when>
|
---|
| 1304 | <xsl:when test="($G_vboxGlueStyle='jaxws')">
|
---|
| 1305 | <xsl:call-template name="cookOutParamJaxws">
|
---|
| 1306 | <xsl:with-param name="value" select="$value" />
|
---|
| 1307 | <xsl:with-param name="idltype" select="$idltype" />
|
---|
| 1308 | <xsl:with-param name="safearray" select="$safearray" />
|
---|
| 1309 | </xsl:call-template>
|
---|
| 1310 | </xsl:when>
|
---|
| 1311 | <xsl:otherwise>
|
---|
| 1312 | <xsl:call-template name="fatalError">
|
---|
| 1313 | <xsl:with-param name="msg" select="'Unhandled style(cookOutParam)'" />
|
---|
| 1314 | </xsl:call-template>
|
---|
| 1315 | </xsl:otherwise>
|
---|
| 1316 | </xsl:choose>
|
---|
| 1317 | </xsl:template>
|
---|
| 1318 |
|
---|
| 1319 | <xsl:template name="cookInParamXpcom">
|
---|
| 1320 | <xsl:param name="value"/>
|
---|
| 1321 | <xsl:param name="idltype"/>
|
---|
| 1322 | <xsl:param name="safearray"/>
|
---|
| 1323 | <xsl:variable name="isstruct"
|
---|
[53922] | 1324 | select="key('G_keyInterfacesByName', $idltype)/@wsmap='struct'" />
|
---|
[30987] | 1325 | <xsl:variable name="gluetype">
|
---|
| 1326 | <xsl:call-template name="typeIdl2Glue">
|
---|
| 1327 | <xsl:with-param name="type" select="$idltype" />
|
---|
| 1328 | <xsl:with-param name="safearray" select="$safearray" />
|
---|
| 1329 | </xsl:call-template>
|
---|
| 1330 | </xsl:variable>
|
---|
| 1331 |
|
---|
| 1332 | <xsl:variable name="backtype">
|
---|
| 1333 | <xsl:call-template name="typeIdl2Back">
|
---|
| 1334 | <xsl:with-param name="type" select="$idltype" />
|
---|
| 1335 | <xsl:with-param name="safearray" select="$safearray" />
|
---|
| 1336 | </xsl:call-template>
|
---|
| 1337 | </xsl:variable>
|
---|
| 1338 |
|
---|
| 1339 | <xsl:variable name="elemgluetype">
|
---|
| 1340 | <xsl:if test="$safearray='yes'">
|
---|
| 1341 | <xsl:call-template name="typeIdl2Glue">
|
---|
| 1342 | <xsl:with-param name="type" select="$idltype" />
|
---|
| 1343 | <xsl:with-param name="safearray" select="'no'" />
|
---|
| 1344 | <xsl:with-param name="forceelem" select="'yes'" />
|
---|
| 1345 | </xsl:call-template>
|
---|
| 1346 | </xsl:if>
|
---|
| 1347 | </xsl:variable>
|
---|
| 1348 |
|
---|
| 1349 | <xsl:choose>
|
---|
[53922] | 1350 | <xsl:when test="count(key('G_keyInterfacesByName', $idltype)) > 0">
|
---|
[30987] | 1351 | <xsl:choose>
|
---|
| 1352 | <xsl:when test="$safearray='yes'">
|
---|
| 1353 | <xsl:variable name="elembacktype">
|
---|
| 1354 | <xsl:call-template name="typeIdl2Back">
|
---|
| 1355 | <xsl:with-param name="type" select="$idltype" />
|
---|
| 1356 | <xsl:with-param name="safearray" select="$safearray" />
|
---|
| 1357 | <xsl:with-param name="forceelem" select="'yes'" />
|
---|
| 1358 | </xsl:call-template>
|
---|
| 1359 | </xsl:variable>
|
---|
[46478] | 1360 | <xsl:value-of select="concat('Helper.unwrap2(', $elemgluetype, '.class, ', $elembacktype, '.class, ', $value, ')')"/>
|
---|
[30987] | 1361 | </xsl:when>
|
---|
| 1362 | <xsl:otherwise>
|
---|
[46478] | 1363 | <xsl:value-of select="concat('(', $value, ' != null) ? ', $value, '.getTypedWrapped() : null')" />
|
---|
[30987] | 1364 | </xsl:otherwise>
|
---|
| 1365 | </xsl:choose>
|
---|
| 1366 | </xsl:when>
|
---|
| 1367 |
|
---|
[46478] | 1368 | <xsl:when test="$idltype='$unknown'">
|
---|
| 1369 | <xsl:choose>
|
---|
[30987] | 1370 | <xsl:when test="$safearray='yes'">
|
---|
[46478] | 1371 | <xsl:value-of select="concat('Helper.unwrap2(', $elemgluetype, '.class, nsISupports.class, ', $value, ')')"/>
|
---|
[30987] | 1372 | </xsl:when>
|
---|
| 1373 | <xsl:otherwise>
|
---|
[46478] | 1374 | <xsl:value-of select="concat('(', $value, ' != null) ? (nsISupports)', $value, '.getWrapped() : null')" />
|
---|
[30987] | 1375 | </xsl:otherwise>
|
---|
| 1376 | </xsl:choose>
|
---|
| 1377 | </xsl:when>
|
---|
| 1378 |
|
---|
[53922] | 1379 | <xsl:when test="count(key('G_keyEnumsByName', $idltype)) > 0">
|
---|
[30987] | 1380 | <xsl:choose>
|
---|
| 1381 | <xsl:when test="$safearray='yes'">
|
---|
[46478] | 1382 | <xsl:value-of select="concat('Helper.unwrapEnum(', $elemgluetype, '.class, ', $value, ')')"/>
|
---|
[30987] | 1383 | </xsl:when>
|
---|
| 1384 | <xsl:otherwise>
|
---|
[46478] | 1385 | <xsl:value-of select="concat($value, '.value()')"/>
|
---|
[30987] | 1386 | </xsl:otherwise>
|
---|
| 1387 | </xsl:choose>
|
---|
| 1388 | </xsl:when>
|
---|
| 1389 |
|
---|
[33069] | 1390 | <xsl:when test="($idltype='octet') and ($safearray='yes')">
|
---|
| 1391 | <xsl:value-of select="$value"/>
|
---|
| 1392 | </xsl:when>
|
---|
| 1393 |
|
---|
[30987] | 1394 | <xsl:otherwise>
|
---|
| 1395 | <xsl:choose>
|
---|
| 1396 | <xsl:when test="$safearray='yes'">
|
---|
[39979] | 1397 | <xsl:choose>
|
---|
| 1398 | <xsl:when test="$idltype='boolean'">
|
---|
[46478] | 1399 | <xsl:value-of select="concat('Helper.unwrapBoolean(', $value, ')')"/>
|
---|
[39979] | 1400 | </xsl:when>
|
---|
| 1401 | <xsl:when test="($idltype='long') or ($idltype='unsigned long') or ($idltype='integer')">
|
---|
[46478] | 1402 | <xsl:value-of select="concat('Helper.unwrapInteger(', $value, ')')"/>
|
---|
[39979] | 1403 | </xsl:when>
|
---|
| 1404 | <xsl:when test="($idltype='short') or ($idltype='unsigned short')">
|
---|
[46478] | 1405 | <xsl:value-of select="concat('Helper.unwrapUShort(', $value, ')')"/>
|
---|
[39979] | 1406 | </xsl:when>
|
---|
| 1407 | <xsl:when test="($idltype='unsigned long long') or ($idltype='long long')">
|
---|
[46478] | 1408 | <xsl:value-of select="concat('Helper.unwrapULong(', $value, ')')"/>
|
---|
[39979] | 1409 | </xsl:when>
|
---|
| 1410 | <xsl:when test="($idltype='wstring') or ($idltype='uuid')">
|
---|
[46478] | 1411 | <xsl:value-of select="concat('Helper.unwrapStr(', $value, ')')"/>
|
---|
[39979] | 1412 | </xsl:when>
|
---|
| 1413 | <xsl:otherwise>
|
---|
| 1414 | <xsl:value-of select="$value"/>
|
---|
| 1415 | </xsl:otherwise>
|
---|
| 1416 | </xsl:choose>
|
---|
[30987] | 1417 | </xsl:when>
|
---|
| 1418 | <xsl:otherwise>
|
---|
| 1419 | <xsl:value-of select="$value"/>
|
---|
| 1420 | </xsl:otherwise>
|
---|
| 1421 | </xsl:choose>
|
---|
| 1422 | </xsl:otherwise>
|
---|
| 1423 | </xsl:choose>
|
---|
| 1424 | </xsl:template>
|
---|
| 1425 |
|
---|
| 1426 | <xsl:template name="cookInParamMscom">
|
---|
| 1427 | <xsl:param name="value"/>
|
---|
| 1428 | <xsl:param name="idltype"/>
|
---|
| 1429 | <xsl:param name="safearray"/>
|
---|
| 1430 |
|
---|
| 1431 | <xsl:variable name="gluetype">
|
---|
| 1432 | <xsl:call-template name="typeIdl2Glue">
|
---|
| 1433 | <xsl:with-param name="type" select="$idltype" />
|
---|
| 1434 | <xsl:with-param name="safearray" select="$safearray" />
|
---|
| 1435 | </xsl:call-template>
|
---|
| 1436 | </xsl:variable>
|
---|
| 1437 |
|
---|
| 1438 | <xsl:variable name="backtype">
|
---|
| 1439 | <xsl:call-template name="typeIdl2Back">
|
---|
| 1440 | <xsl:with-param name="type" select="$idltype" />
|
---|
| 1441 | <xsl:with-param name="safearray" select="$safearray" />
|
---|
| 1442 | </xsl:call-template>
|
---|
| 1443 | </xsl:variable>
|
---|
| 1444 |
|
---|
| 1445 | <xsl:variable name="elemgluetype">
|
---|
| 1446 | <xsl:if test="$safearray='yes'">
|
---|
| 1447 | <xsl:call-template name="typeIdl2Glue">
|
---|
| 1448 | <xsl:with-param name="type" select="$idltype" />
|
---|
| 1449 | <xsl:with-param name="safearray" select="'no'" />
|
---|
| 1450 | <xsl:with-param name="forceelem" select="'yes'" />
|
---|
| 1451 | </xsl:call-template>
|
---|
| 1452 | </xsl:if>
|
---|
| 1453 | </xsl:variable>
|
---|
| 1454 |
|
---|
| 1455 | <xsl:choose>
|
---|
[53922] | 1456 | <xsl:when test="count(key('G_keyInterfacesByName', $idltype)) > 0">
|
---|
[30987] | 1457 | <xsl:choose>
|
---|
| 1458 | <xsl:when test="$safearray='yes'">
|
---|
| 1459 | <xsl:variable name="elembacktype">
|
---|
| 1460 | <xsl:call-template name="typeIdl2Back">
|
---|
| 1461 | <xsl:with-param name="type" select="$idltype" />
|
---|
| 1462 | <xsl:with-param name="safearray" select="$safearray" />
|
---|
| 1463 | <xsl:with-param name="forceelem" select="'yes'" />
|
---|
| 1464 | </xsl:call-template>
|
---|
| 1465 | </xsl:variable>
|
---|
[51416] | 1466 | <!-- Sometimes javac needs a boost of self-confidence regarding
|
---|
| 1467 | varargs calls, and this (Object) cast makes sure that it calls
|
---|
| 1468 | the varargs method - as if there is any other. -->
|
---|
| 1469 | <xsl:value-of select="concat('(Object)Helper.unwrap2(', $elemgluetype, '.class, ', $elembacktype, '.class, ', $value, ')')"/>
|
---|
[30987] | 1470 | </xsl:when>
|
---|
| 1471 | <xsl:otherwise>
|
---|
[46478] | 1472 | <xsl:value-of select="concat('(', $value, ' != null) ? ', $value, '.getTypedWrapped() : null')" />
|
---|
[30987] | 1473 | </xsl:otherwise>
|
---|
| 1474 | </xsl:choose>
|
---|
| 1475 | </xsl:when>
|
---|
| 1476 |
|
---|
[46478] | 1477 | <xsl:when test="$idltype='$unknown'">
|
---|
| 1478 | <xsl:choose>
|
---|
[30987] | 1479 | <xsl:when test="$safearray='yes'">
|
---|
[46478] | 1480 | <xsl:value-of select="concat('Helper.unwrap2(', $elemgluetype, '.class, Dispatch.class, ', $value, ')')"/>
|
---|
[30987] | 1481 | </xsl:when>
|
---|
| 1482 | <xsl:otherwise>
|
---|
[46478] | 1483 | <xsl:value-of select="concat('(', $value, ' != null) ? (Dispatch)', $value, '.getWrapped() : null')" />
|
---|
[30987] | 1484 | </xsl:otherwise>
|
---|
| 1485 | </xsl:choose>
|
---|
| 1486 | </xsl:when>
|
---|
| 1487 |
|
---|
[53922] | 1488 | <xsl:when test="count(key('G_keyEnumsByName', $idltype)) > 0">
|
---|
[30987] | 1489 | <xsl:choose>
|
---|
| 1490 | <xsl:when test="$safearray='yes'">
|
---|
[46478] | 1491 | <xsl:value-of select="concat('Helper.unwrapEnum(', $elemgluetype, '.class, ', $value, ')')"/>
|
---|
[30987] | 1492 | </xsl:when>
|
---|
| 1493 | <xsl:otherwise>
|
---|
[46478] | 1494 | <xsl:value-of select="concat($value, '.value()')"/>
|
---|
[30987] | 1495 | </xsl:otherwise>
|
---|
| 1496 | </xsl:choose>
|
---|
| 1497 | </xsl:when>
|
---|
| 1498 |
|
---|
| 1499 | <xsl:when test="$idltype='boolean'">
|
---|
| 1500 | <xsl:choose>
|
---|
| 1501 | <xsl:when test="$safearray='yes'">
|
---|
[46478] | 1502 | <xsl:value-of select="concat('Helper.unwrapBool(', $value, ')')"/>
|
---|
[30987] | 1503 | </xsl:when>
|
---|
| 1504 | <xsl:otherwise>
|
---|
[46478] | 1505 | <xsl:value-of select="concat('new Variant(', $value, ')')"/>
|
---|
[30987] | 1506 | </xsl:otherwise>
|
---|
| 1507 | </xsl:choose>
|
---|
| 1508 | </xsl:when>
|
---|
| 1509 |
|
---|
| 1510 | <xsl:when test="($idltype='short') or ($idltype='unsigned short')">
|
---|
| 1511 | <xsl:choose>
|
---|
| 1512 | <xsl:when test="$safearray='yes'">
|
---|
[46478] | 1513 | <xsl:value-of select="concat('Helper.unwrapShort(', $value, ')')"/>
|
---|
[30987] | 1514 | </xsl:when>
|
---|
| 1515 | <xsl:otherwise>
|
---|
[46478] | 1516 | <xsl:value-of select="concat('new Variant(', $value, ')')"/>
|
---|
[30987] | 1517 | </xsl:otherwise>
|
---|
| 1518 | </xsl:choose>
|
---|
| 1519 | </xsl:when>
|
---|
| 1520 |
|
---|
| 1521 |
|
---|
| 1522 | <xsl:when test="($idltype='long') or ($idltype='unsigned long')">
|
---|
| 1523 | <xsl:choose>
|
---|
| 1524 | <xsl:when test="$safearray='yes'">
|
---|
[46478] | 1525 | <xsl:value-of select="concat('Helper.unwrapInt(', $value, ')')"/>
|
---|
[30987] | 1526 | </xsl:when>
|
---|
| 1527 | <xsl:otherwise>
|
---|
[46478] | 1528 | <xsl:value-of select="concat('new Variant(', $value, ')')"/>
|
---|
[30987] | 1529 | </xsl:otherwise>
|
---|
| 1530 | </xsl:choose>
|
---|
| 1531 | </xsl:when>
|
---|
| 1532 |
|
---|
| 1533 | <xsl:when test="($idltype='wstring') or ($idltype='uuid')">
|
---|
| 1534 | <xsl:choose>
|
---|
| 1535 | <xsl:when test="$safearray='yes'">
|
---|
[46478] | 1536 | <xsl:value-of select="concat('Helper.unwrapString(', $value, ')')"/>
|
---|
[30987] | 1537 | </xsl:when>
|
---|
| 1538 | <xsl:otherwise>
|
---|
[46478] | 1539 | <xsl:value-of select="concat('new Variant(', $value, ')')"/>
|
---|
[30987] | 1540 | </xsl:otherwise>
|
---|
| 1541 | </xsl:choose>
|
---|
| 1542 | </xsl:when>
|
---|
| 1543 |
|
---|
| 1544 | <xsl:when test="($idltype='unsigned long long') or ($idltype='long long')">
|
---|
| 1545 | <xsl:choose>
|
---|
| 1546 | <xsl:when test="$safearray='yes'">
|
---|
[46478] | 1547 | <xsl:value-of select="concat('Helper.unwrapLong(', $value, ')')"/>
|
---|
[30987] | 1548 | </xsl:when>
|
---|
| 1549 | <xsl:otherwise>
|
---|
[46478] | 1550 | <xsl:value-of select="concat('new Variant(', $value, '.longValue())')"/>
|
---|
[30987] | 1551 | </xsl:otherwise>
|
---|
| 1552 | </xsl:choose>
|
---|
| 1553 | </xsl:when>
|
---|
| 1554 |
|
---|
[36270] | 1555 | <xsl:when test="($idltype='octet') and ($safearray='yes')">
|
---|
[51416] | 1556 | <xsl:value-of select="$value"/>
|
---|
[36270] | 1557 | </xsl:when>
|
---|
| 1558 |
|
---|
[30987] | 1559 | <xsl:otherwise>
|
---|
| 1560 | <xsl:call-template name="fatalError">
|
---|
| 1561 | <xsl:with-param name="msg" select="concat('Unhandled type: ', $idltype)" />
|
---|
| 1562 | </xsl:call-template>
|
---|
| 1563 | </xsl:otherwise>
|
---|
| 1564 | </xsl:choose>
|
---|
| 1565 |
|
---|
| 1566 | </xsl:template>
|
---|
| 1567 |
|
---|
| 1568 | <xsl:template name="cookInParamJaxws">
|
---|
| 1569 | <xsl:param name="value"/>
|
---|
| 1570 | <xsl:param name="idltype"/>
|
---|
| 1571 | <xsl:param name="safearray"/>
|
---|
| 1572 | <xsl:variable name="isstruct"
|
---|
[53922] | 1573 | select="key('G_keyInterfacesByName', $idltype)/@wsmap='struct'" />
|
---|
[30987] | 1574 |
|
---|
| 1575 | <xsl:variable name="gluetype">
|
---|
| 1576 | <xsl:call-template name="typeIdl2Glue">
|
---|
| 1577 | <xsl:with-param name="type" select="$idltype" />
|
---|
| 1578 | <xsl:with-param name="safearray" select="$safearray" />
|
---|
| 1579 | </xsl:call-template>
|
---|
| 1580 | </xsl:variable>
|
---|
| 1581 |
|
---|
| 1582 | <xsl:variable name="elemgluetype">
|
---|
| 1583 | <xsl:if test="$safearray='yes'">
|
---|
| 1584 | <xsl:call-template name="typeIdl2Glue">
|
---|
| 1585 | <xsl:with-param name="type" select="$idltype" />
|
---|
| 1586 | <xsl:with-param name="safearray" select="'no'" />
|
---|
| 1587 | <xsl:with-param name="forceelem" select="'yes'" />
|
---|
| 1588 | </xsl:call-template>
|
---|
| 1589 | </xsl:if>
|
---|
| 1590 | </xsl:variable>
|
---|
| 1591 |
|
---|
| 1592 | <xsl:choose>
|
---|
[53922] | 1593 | <xsl:when test="$idltype = '$unknown' or (count(key('G_keyInterfacesByName', $idltype)) > 0)">
|
---|
[30987] | 1594 | <xsl:choose>
|
---|
| 1595 | <xsl:when test="@safearray='yes'">
|
---|
[46478] | 1596 | <xsl:value-of select="concat('Helper.unwrap(', $value, ')')"/>
|
---|
[30987] | 1597 | </xsl:when>
|
---|
| 1598 | <xsl:otherwise>
|
---|
| 1599 | <xsl:value-of select="concat('((', $value, ' == null) ? null :', $value, '.getWrapped())')" />
|
---|
| 1600 | </xsl:otherwise>
|
---|
| 1601 | </xsl:choose>
|
---|
[46478] | 1602 | </xsl:when>
|
---|
[30987] | 1603 |
|
---|
[53922] | 1604 | <xsl:when test="count(key('G_keyEnumsByName', $idltype)) > 0">
|
---|
[46478] | 1605 | <xsl:choose>
|
---|
| 1606 | <xsl:when test="$safearray='yes'">
|
---|
| 1607 | <xsl:variable name="elembacktype">
|
---|
| 1608 | <xsl:call-template name="typeIdl2Back">
|
---|
| 1609 | <xsl:with-param name="type" select="$idltype" />
|
---|
| 1610 | <xsl:with-param name="safearray" select="'no'" />
|
---|
| 1611 | <xsl:with-param name="forceelem" select="'yes'" />
|
---|
| 1612 | </xsl:call-template>
|
---|
| 1613 | </xsl:variable>
|
---|
| 1614 | <xsl:value-of select="concat('Helper.convertEnums(', $elemgluetype, '.class, ', $elembacktype, '.class, ', $value, ')')"/>
|
---|
| 1615 | </xsl:when>
|
---|
| 1616 | <xsl:otherwise>
|
---|
| 1617 | <xsl:variable name="backtype">
|
---|
| 1618 | <xsl:call-template name="typeIdl2Back">
|
---|
| 1619 | <xsl:with-param name="type" select="$idltype" />
|
---|
| 1620 | <xsl:with-param name="safearray" select="'no'" />
|
---|
| 1621 | <xsl:with-param name="forceelem" select="'yes'" />
|
---|
| 1622 | </xsl:call-template>
|
---|
| 1623 | </xsl:variable>
|
---|
| 1624 | <xsl:value-of select="concat($backtype, '.fromValue(', $value, '.name())')"/>
|
---|
| 1625 | </xsl:otherwise>
|
---|
| 1626 | </xsl:choose>
|
---|
| 1627 | </xsl:when>
|
---|
[30987] | 1628 |
|
---|
[46478] | 1629 | <xsl:when test="($idltype='octet') and ($safearray='yes')">
|
---|
| 1630 | <xsl:value-of select="concat('Helper.encodeBase64(', $value, ')')"/>
|
---|
| 1631 | </xsl:when>
|
---|
[33069] | 1632 |
|
---|
[46478] | 1633 | <xsl:otherwise>
|
---|
| 1634 | <xsl:value-of select="$value"/>
|
---|
| 1635 | </xsl:otherwise>
|
---|
[30987] | 1636 | </xsl:choose>
|
---|
| 1637 |
|
---|
| 1638 | </xsl:template>
|
---|
| 1639 |
|
---|
| 1640 | <xsl:template name="cookInParam">
|
---|
| 1641 | <xsl:param name="value"/>
|
---|
| 1642 | <xsl:param name="idltype"/>
|
---|
| 1643 | <xsl:param name="safearray"/>
|
---|
| 1644 | <xsl:choose>
|
---|
| 1645 | <xsl:when test="($G_vboxGlueStyle='xpcom')">
|
---|
| 1646 | <xsl:call-template name="cookInParamXpcom">
|
---|
| 1647 | <xsl:with-param name="value" select="$value" />
|
---|
| 1648 | <xsl:with-param name="idltype" select="$idltype" />
|
---|
| 1649 | <xsl:with-param name="safearray" select="$safearray" />
|
---|
| 1650 | </xsl:call-template>
|
---|
| 1651 | </xsl:when>
|
---|
| 1652 | <xsl:when test="($G_vboxGlueStyle='mscom')">
|
---|
| 1653 | <xsl:call-template name="cookInParamMscom">
|
---|
| 1654 | <xsl:with-param name="value" select="$value" />
|
---|
| 1655 | <xsl:with-param name="idltype" select="$idltype" />
|
---|
| 1656 | <xsl:with-param name="safearray" select="$safearray" />
|
---|
| 1657 | </xsl:call-template>
|
---|
| 1658 | </xsl:when>
|
---|
| 1659 | <xsl:when test="($G_vboxGlueStyle='jaxws')">
|
---|
| 1660 | <xsl:call-template name="cookInParamJaxws">
|
---|
| 1661 | <xsl:with-param name="value" select="$value" />
|
---|
| 1662 | <xsl:with-param name="idltype" select="$idltype" />
|
---|
| 1663 | <xsl:with-param name="safearray" select="$safearray" />
|
---|
| 1664 | </xsl:call-template>
|
---|
| 1665 | </xsl:when>
|
---|
| 1666 | <xsl:otherwise>
|
---|
| 1667 | <xsl:call-template name="fatalError">
|
---|
| 1668 | <xsl:with-param name="msg" select="'Unhandled style (cookInParam)'" />
|
---|
| 1669 | </xsl:call-template>
|
---|
| 1670 | </xsl:otherwise>
|
---|
| 1671 | </xsl:choose>
|
---|
| 1672 | </xsl:template>
|
---|
| 1673 |
|
---|
| 1674 | <!-- Invoke backend method, including parameter conversion -->
|
---|
| 1675 | <xsl:template name="genBackMethodCall">
|
---|
| 1676 | <xsl:param name="ifname"/>
|
---|
| 1677 | <xsl:param name="methodname"/>
|
---|
| 1678 | <xsl:param name="retval"/>
|
---|
| 1679 |
|
---|
| 1680 | <xsl:choose>
|
---|
| 1681 | <xsl:when test="($G_vboxGlueStyle='xpcom')">
|
---|
[51416] | 1682 | <xsl:text> </xsl:text>
|
---|
[30987] | 1683 | <xsl:if test="param[@dir='return']">
|
---|
| 1684 | <xsl:value-of select="concat($retval, ' = ')" />
|
---|
| 1685 | </xsl:if>
|
---|
[46478] | 1686 | <xsl:value-of select="concat('getTypedWrapped().', $methodname, '(')"/>
|
---|
[30987] | 1687 | <xsl:for-each select="param">
|
---|
[46478] | 1688 | <xsl:choose>
|
---|
| 1689 | <xsl:when test="@dir='return'">
|
---|
| 1690 | <xsl:if test="@safearray='yes'">
|
---|
| 1691 | <xsl:text>null</xsl:text>
|
---|
| 1692 | </xsl:if>
|
---|
| 1693 | </xsl:when>
|
---|
| 1694 | <xsl:when test="@dir='out'">
|
---|
| 1695 | <xsl:if test="@safearray='yes'">
|
---|
| 1696 | <xsl:text>null, </xsl:text>
|
---|
| 1697 | </xsl:if>
|
---|
| 1698 | <xsl:value-of select="concat('tmp_', @name)" />
|
---|
| 1699 | </xsl:when>
|
---|
| 1700 | <xsl:when test="@dir='in'">
|
---|
| 1701 | <xsl:if test="(@safearray='yes') and not(@type = 'octet')">
|
---|
[50417] | 1702 | <xsl:value-of select="concat(@name, ' != null ? ', @name, '.size() : 0, ')" />
|
---|
[46478] | 1703 | </xsl:if>
|
---|
| 1704 | <xsl:variable name="unwrapped">
|
---|
| 1705 | <xsl:call-template name="cookInParam">
|
---|
| 1706 | <xsl:with-param name="value" select="@name" />
|
---|
| 1707 | <xsl:with-param name="idltype" select="@type" />
|
---|
| 1708 | <xsl:with-param name="safearray" select="@safearray" />
|
---|
[30987] | 1709 | </xsl:call-template>
|
---|
[46478] | 1710 | </xsl:variable>
|
---|
| 1711 | <xsl:value-of select="$unwrapped"/>
|
---|
| 1712 | </xsl:when>
|
---|
| 1713 | <xsl:otherwise>
|
---|
| 1714 | <xsl:call-template name="fatalError">
|
---|
| 1715 | <xsl:with-param name="msg" select="concat('Unsupported param dir: ', @dir, '".')" />
|
---|
| 1716 | </xsl:call-template>
|
---|
| 1717 | </xsl:otherwise>
|
---|
| 1718 | </xsl:choose>
|
---|
| 1719 | <xsl:if test="not(position()=last()) and not(following-sibling::param[1]/@dir='return' and not(following-sibling::param[1]/@safearray='yes'))">
|
---|
| 1720 | <xsl:text>, </xsl:text>
|
---|
| 1721 | </xsl:if>
|
---|
[30987] | 1722 | </xsl:for-each>
|
---|
[46478] | 1723 | <xsl:text>); </xsl:text>
|
---|
[30987] | 1724 | </xsl:when>
|
---|
| 1725 |
|
---|
| 1726 | <xsl:when test="($G_vboxGlueStyle='mscom')">
|
---|
[51416] | 1727 | <xsl:text> </xsl:text>
|
---|
[30987] | 1728 | <xsl:if test="param[@dir='return']">
|
---|
| 1729 | <xsl:value-of select="concat($retval, ' = ')" />
|
---|
| 1730 | </xsl:if>
|
---|
[46478] | 1731 | <xsl:value-of select="concat('Helper.invoke(getTypedWrapped(), "', $methodname, '" ')"/>
|
---|
[30987] | 1732 | <xsl:for-each select="param[not(@dir='return')]">
|
---|
[46478] | 1733 | <xsl:text>, </xsl:text>
|
---|
[30987] | 1734 | <xsl:choose>
|
---|
[46478] | 1735 | <xsl:when test="@dir='out'">
|
---|
| 1736 | <xsl:value-of select="concat('tmp_', @name)" />
|
---|
| 1737 | </xsl:when>
|
---|
| 1738 | <xsl:when test="@dir='in'">
|
---|
| 1739 | <xsl:variable name="unwrapped">
|
---|
| 1740 | <xsl:call-template name="cookInParam">
|
---|
| 1741 | <xsl:with-param name="value" select="@name" />
|
---|
| 1742 | <xsl:with-param name="idltype" select="@type" />
|
---|
| 1743 | <xsl:with-param name="safearray" select="@safearray" />
|
---|
| 1744 | </xsl:call-template>
|
---|
| 1745 | </xsl:variable>
|
---|
| 1746 | <xsl:value-of select="$unwrapped"/>
|
---|
| 1747 | </xsl:when>
|
---|
[30987] | 1748 | </xsl:choose>
|
---|
| 1749 | </xsl:for-each>
|
---|
[46478] | 1750 | <xsl:text>); </xsl:text>
|
---|
[30987] | 1751 | </xsl:when>
|
---|
| 1752 |
|
---|
[46478] | 1753 | <xsl:when test="($G_vboxGlueStyle='jaxws')">
|
---|
| 1754 | <xsl:variable name="jaxwsmethod">
|
---|
| 1755 | <xsl:call-template name="makeJaxwsMethod">
|
---|
| 1756 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
| 1757 | <xsl:with-param name="methodname" select="$methodname" />
|
---|
| 1758 | </xsl:call-template>
|
---|
| 1759 | </xsl:variable>
|
---|
| 1760 | <xsl:variable name="portArg">
|
---|
[53922] | 1761 | <xsl:if test="not(key('G_keyInterfacesByName', $ifname)/@wsmap='global')">
|
---|
[46478] | 1762 | <xsl:text>obj</xsl:text>
|
---|
| 1763 | </xsl:if>
|
---|
| 1764 | </xsl:variable>
|
---|
| 1765 | <xsl:variable name="paramsinout" select="param[@dir='in' or @dir='out']" />
|
---|
[30987] | 1766 |
|
---|
[46478] | 1767 | <xsl:text> </xsl:text>
|
---|
| 1768 | <xsl:if test="param[@dir='return'] and not(param[@dir='out'])">
|
---|
| 1769 | <xsl:value-of select="concat($retval, ' = ')" />
|
---|
| 1770 | </xsl:if>
|
---|
| 1771 | <xsl:value-of select="concat('port.', $jaxwsmethod, '(', $portArg)" />
|
---|
| 1772 | <xsl:if test="$paramsinout and not($portArg='')">
|
---|
| 1773 | <xsl:text>, </xsl:text>
|
---|
| 1774 | </xsl:if>
|
---|
[30987] | 1775 |
|
---|
[46478] | 1776 | <!-- jax-ws has an oddity: if both out params and a return value exist,
|
---|
| 1777 | then the return value is moved to the function's argument list... -->
|
---|
| 1778 | <xsl:choose>
|
---|
| 1779 | <xsl:when test="param[@dir='out'] and param[@dir='return']">
|
---|
| 1780 | <xsl:for-each select="param">
|
---|
| 1781 | <xsl:choose>
|
---|
| 1782 | <xsl:when test="@dir='return'">
|
---|
| 1783 | <xsl:value-of select="$retval"/>
|
---|
| 1784 | </xsl:when>
|
---|
| 1785 | <xsl:when test="@dir='out'">
|
---|
| 1786 | <xsl:value-of select="concat('tmp_', @name)" />
|
---|
| 1787 | </xsl:when>
|
---|
| 1788 | <xsl:otherwise>
|
---|
| 1789 | <xsl:call-template name="cookInParam">
|
---|
| 1790 | <xsl:with-param name="value" select="@name" />
|
---|
| 1791 | <xsl:with-param name="idltype" select="@type" />
|
---|
| 1792 | <xsl:with-param name="safearray" select="@safearray" />
|
---|
| 1793 | </xsl:call-template>
|
---|
| 1794 | </xsl:otherwise>
|
---|
| 1795 | </xsl:choose>
|
---|
| 1796 | <xsl:if test="not(position()=last())">
|
---|
| 1797 | <xsl:text>, </xsl:text>
|
---|
| 1798 | </xsl:if>
|
---|
| 1799 | </xsl:for-each>
|
---|
| 1800 | </xsl:when>
|
---|
| 1801 | <xsl:otherwise>
|
---|
| 1802 | <xsl:for-each select="$paramsinout">
|
---|
| 1803 | <xsl:choose>
|
---|
| 1804 | <xsl:when test="@dir='return'">
|
---|
| 1805 | <xsl:value-of select="$retval"/>
|
---|
| 1806 | </xsl:when>
|
---|
| 1807 | <xsl:when test="@dir='out'">
|
---|
| 1808 | <xsl:value-of select="concat('tmp_', @name)" />
|
---|
| 1809 | </xsl:when>
|
---|
| 1810 | <xsl:otherwise>
|
---|
| 1811 | <xsl:call-template name="cookInParam">
|
---|
| 1812 | <xsl:with-param name="value" select="@name" />
|
---|
| 1813 | <xsl:with-param name="idltype" select="@type" />
|
---|
| 1814 | <xsl:with-param name="safearray" select="@safearray" />
|
---|
| 1815 | </xsl:call-template>
|
---|
| 1816 | </xsl:otherwise>
|
---|
| 1817 | </xsl:choose>
|
---|
| 1818 | <xsl:if test="not(position()=last())">
|
---|
| 1819 | <xsl:text>, </xsl:text>
|
---|
| 1820 | </xsl:if>
|
---|
| 1821 | </xsl:for-each>
|
---|
| 1822 | </xsl:otherwise>
|
---|
| 1823 | </xsl:choose>
|
---|
| 1824 | <xsl:text>); </xsl:text>
|
---|
| 1825 | </xsl:when>
|
---|
[30987] | 1826 |
|
---|
| 1827 | <xsl:otherwise>
|
---|
| 1828 | <xsl:call-template name="fatalError">
|
---|
| 1829 | <xsl:with-param name="msg" select="'Style unknown (genBackMethodCall)'" />
|
---|
| 1830 | </xsl:call-template>
|
---|
| 1831 | </xsl:otherwise>
|
---|
| 1832 |
|
---|
| 1833 | </xsl:choose>
|
---|
| 1834 | </xsl:template>
|
---|
| 1835 |
|
---|
| 1836 | <xsl:template name="genGetterCall">
|
---|
| 1837 | <xsl:param name="ifname"/>
|
---|
| 1838 | <xsl:param name="gettername"/>
|
---|
| 1839 | <xsl:param name="backtype"/>
|
---|
| 1840 | <xsl:param name="retval"/>
|
---|
| 1841 |
|
---|
| 1842 | <xsl:choose>
|
---|
[46478] | 1843 | <xsl:when test="$G_vboxGlueStyle='xpcom'">
|
---|
| 1844 | <xsl:value-of select="concat(' ', $backtype, ' ', $retval, ' = getTypedWrapped().', $gettername, '(')" />
|
---|
[94374] | 1845 | <xsl:if test="@safearray='yes'">
|
---|
[46478] | 1846 | <xsl:text>null</xsl:text>
|
---|
| 1847 | </xsl:if>
|
---|
| 1848 | <xsl:text>); </xsl:text>
|
---|
| 1849 | </xsl:when>
|
---|
[30987] | 1850 |
|
---|
[46478] | 1851 | <xsl:when test="$G_vboxGlueStyle='mscom'">
|
---|
| 1852 | <xsl:value-of select="concat(' ', $backtype, ' ', $retval, ' = Dispatch.get(getTypedWrapped(), "', @name, '"); ')" />
|
---|
| 1853 | </xsl:when>
|
---|
[30987] | 1854 |
|
---|
[46478] | 1855 | <xsl:when test="$G_vboxGlueStyle='jaxws'">
|
---|
| 1856 | <xsl:variable name="jaxwsGetter">
|
---|
| 1857 | <xsl:call-template name="makeJaxwsMethod">
|
---|
| 1858 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
| 1859 | <xsl:with-param name="methodname" select="$gettername" />
|
---|
| 1860 | </xsl:call-template>
|
---|
| 1861 | </xsl:variable>
|
---|
| 1862 | <xsl:value-of select="concat(' ', $backtype, ' ', $retval, ' = port.', $jaxwsGetter, '(obj); ')" />
|
---|
| 1863 | </xsl:when>
|
---|
[30987] | 1864 |
|
---|
[46478] | 1865 | <xsl:otherwise>
|
---|
| 1866 | <xsl:call-template name="fatalError">
|
---|
| 1867 | <xsl:with-param name="msg" select="'Style unknown (genGetterCall)'" />
|
---|
| 1868 | </xsl:call-template>
|
---|
| 1869 | </xsl:otherwise>
|
---|
[30987] | 1870 | </xsl:choose>
|
---|
| 1871 | </xsl:template>
|
---|
| 1872 |
|
---|
| 1873 | <xsl:template name="genSetterCall">
|
---|
| 1874 | <xsl:param name="ifname"/>
|
---|
| 1875 | <xsl:param name="settername"/>
|
---|
| 1876 | <xsl:param name="value"/>
|
---|
| 1877 |
|
---|
| 1878 | <xsl:choose>
|
---|
[46478] | 1879 | <xsl:when test="$G_vboxGlueStyle='xpcom'">
|
---|
| 1880 | <xsl:value-of select="concat(' getTypedWrapped().', $settername, '(', $value, '); ')" />
|
---|
| 1881 | </xsl:when>
|
---|
[30987] | 1882 |
|
---|
[46478] | 1883 | <xsl:when test="$G_vboxGlueStyle='mscom'">
|
---|
| 1884 | <xsl:value-of select="concat(' Dispatch.put(getTypedWrapped(), "', @name, '", ', $value, '); ')" />
|
---|
| 1885 | </xsl:when>
|
---|
[30987] | 1886 |
|
---|
[46478] | 1887 | <xsl:when test="$G_vboxGlueStyle='jaxws'">
|
---|
[30987] | 1888 | <xsl:variable name="jaxwsSetter">
|
---|
| 1889 | <xsl:call-template name="makeJaxwsMethod">
|
---|
| 1890 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
| 1891 | <xsl:with-param name="methodname" select="$settername" />
|
---|
| 1892 | </xsl:call-template>
|
---|
| 1893 | </xsl:variable>
|
---|
[46478] | 1894 | <xsl:value-of select="concat(' port.', $jaxwsSetter, '(obj, ', $value, '); ')" />
|
---|
| 1895 | </xsl:when>
|
---|
[30987] | 1896 |
|
---|
[46478] | 1897 | <xsl:otherwise>
|
---|
| 1898 | <xsl:call-template name="fatalError">
|
---|
| 1899 | <xsl:with-param name="msg" select="'Style unknown (genSetterCall)'" />
|
---|
| 1900 | </xsl:call-template>
|
---|
| 1901 | </xsl:otherwise>
|
---|
[30987] | 1902 | </xsl:choose>
|
---|
| 1903 | </xsl:template>
|
---|
| 1904 |
|
---|
| 1905 | <xsl:template name="genStructWrapperJaxws">
|
---|
| 1906 | <xsl:param name="ifname"/>
|
---|
| 1907 |
|
---|
[46478] | 1908 | <xsl:value-of select="concat(' private ', $G_virtualBoxPackageCom, '.', $ifname, ' real; ')"/>
|
---|
[61203] | 1909 | <xsl:text> private VboxPortType port; </xsl:text>
|
---|
| 1910 | <xsl:text> private ObjectRefManager objMgr; </xsl:text>
|
---|
[30987] | 1911 |
|
---|
[61203] | 1912 | <!-- For structs which contain references to other objects we have to create the stub object during construction time
|
---|
| 1913 | or it is possible that the reference was released by the garbage collector because the reference is not
|
---|
| 1914 | accounted for. -->
|
---|
| 1915 | <!-- Create the private members for containing objects here. -->
|
---|
| 1916 | <xsl:for-each select="attribute">
|
---|
| 1917 | <xsl:variable name="attrname"><xsl:value-of select="@name" /></xsl:variable>
|
---|
| 1918 | <xsl:variable name="attrtype"><xsl:value-of select="@type" /></xsl:variable>
|
---|
| 1919 | <xsl:variable name="attrsafearray"><xsl:value-of select="@safearray" /></xsl:variable>
|
---|
| 1920 |
|
---|
| 1921 | <xsl:if test="(not(@wsmap = 'suppress')) and ($attrtype = '$unknown' or (count(key('G_keyInterfacesByName', $attrtype)) > 0))">
|
---|
| 1922 | <xsl:variable name="gluegettertype">
|
---|
| 1923 | <xsl:call-template name="typeIdl2Glue">
|
---|
| 1924 | <xsl:with-param name="type" select="$attrtype" />
|
---|
| 1925 | <xsl:with-param name="safearray" select="@safearray" />
|
---|
| 1926 | </xsl:call-template>
|
---|
| 1927 | </xsl:variable>
|
---|
| 1928 | <xsl:value-of select="concat(' private ', $gluegettertype, ' ', $attrname, '; ')" />
|
---|
| 1929 | </xsl:if>
|
---|
| 1930 | </xsl:for-each>
|
---|
| 1931 |
|
---|
| 1932 | <xsl:value-of select="concat(' public ', $ifname, '(', $G_virtualBoxPackageCom, '.', $ifname, ' real, ObjectRefManager objMgr, VboxPortType port) ')" />
|
---|
[46478] | 1933 | <xsl:text> { </xsl:text>
|
---|
| 1934 | <xsl:text> this.real = real; </xsl:text>
|
---|
| 1935 | <xsl:text> this.port = port; </xsl:text>
|
---|
[61203] | 1936 | <xsl:text> this.objMgr = objMgr; </xsl:text>
|
---|
| 1937 | <!-- Construct stub objects for every attribute containing a reference to a webserver side object -->
|
---|
| 1938 | <xsl:for-each select="attribute">
|
---|
| 1939 | <xsl:variable name="attrname"><xsl:value-of select="@name" /></xsl:variable>
|
---|
| 1940 | <xsl:variable name="attrtype"><xsl:value-of select="@type" /></xsl:variable>
|
---|
| 1941 | <xsl:variable name="attrsafearray"><xsl:value-of select="@safearray" /></xsl:variable>
|
---|
| 1942 |
|
---|
| 1943 | <xsl:if test="(not(@wsmap = 'suppress')) and ($attrtype = '$unknown' or (count(key('G_keyInterfacesByName', $attrtype)) > 0))">
|
---|
| 1944 | <xsl:variable name="backgettername">
|
---|
| 1945 | <xsl:choose>
|
---|
| 1946 | <!-- Stupid, but backend boolean getters called isFoo(), not getFoo() -->
|
---|
| 1947 | <xsl:when test="$attrtype = 'boolean'">
|
---|
| 1948 | <xsl:variable name="capsname">
|
---|
| 1949 | <xsl:call-template name="capitalize">
|
---|
| 1950 | <xsl:with-param name="str" select="$attrname" />
|
---|
| 1951 | </xsl:call-template>
|
---|
| 1952 | </xsl:variable>
|
---|
| 1953 | <xsl:value-of select="concat('is', $capsname)" />
|
---|
| 1954 | </xsl:when>
|
---|
| 1955 | <xsl:otherwise>
|
---|
| 1956 | <xsl:call-template name="makeGetterName">
|
---|
| 1957 | <xsl:with-param name="attrname" select="$attrname" />
|
---|
| 1958 | </xsl:call-template>
|
---|
| 1959 | </xsl:otherwise>
|
---|
| 1960 | </xsl:choose>
|
---|
| 1961 | </xsl:variable>
|
---|
| 1962 |
|
---|
| 1963 | <xsl:variable name="wrapped">
|
---|
| 1964 | <xsl:call-template name="cookOutParam">
|
---|
| 1965 | <xsl:with-param name="value" select="concat('real.', $backgettername, '()')" />
|
---|
| 1966 | <xsl:with-param name="idltype" select="$attrtype" />
|
---|
| 1967 | <xsl:with-param name="safearray" select="@safearray" />
|
---|
| 1968 | </xsl:call-template>
|
---|
| 1969 | </xsl:variable>
|
---|
[69378] | 1970 | <xsl:value-of select="concat(' ', $attrname, ' = ', $wrapped, '; ')" />
|
---|
[61203] | 1971 | </xsl:if>
|
---|
| 1972 | </xsl:for-each>
|
---|
[46478] | 1973 | <xsl:text> } </xsl:text>
|
---|
[30987] | 1974 |
|
---|
[61203] | 1975 | <xsl:text><![CDATA[ private ObjectRefManager getObjMgr()
|
---|
| 1976 | {
|
---|
| 1977 | return this.objMgr;
|
---|
| 1978 | }
|
---|
| 1979 | ]]></xsl:text>
|
---|
| 1980 |
|
---|
[30987] | 1981 | <xsl:for-each select="attribute">
|
---|
| 1982 | <xsl:variable name="attrname"><xsl:value-of select="@name" /></xsl:variable>
|
---|
| 1983 | <xsl:variable name="attrtype"><xsl:value-of select="@type" /></xsl:variable>
|
---|
| 1984 | <xsl:variable name="attrsafearray"><xsl:value-of select="@safearray" /></xsl:variable>
|
---|
| 1985 |
|
---|
[46478] | 1986 | <xsl:if test="not(@wsmap = 'suppress')">
|
---|
[30987] | 1987 |
|
---|
[46478] | 1988 | <xsl:if test="not(@readonly = 'yes')">
|
---|
| 1989 | <xsl:call-template name="fatalError">
|
---|
| 1990 | <xsl:with-param name="msg" select="concat('Non read-only struct (genStructWrapperJaxws) in interface ', $ifname, ', attribute ', $attrname)" />
|
---|
| 1991 | </xsl:call-template>
|
---|
| 1992 | </xsl:if>
|
---|
| 1993 |
|
---|
[43869] | 1994 | <!-- Emit getter -->
|
---|
| 1995 | <xsl:variable name="backgettername">
|
---|
| 1996 | <xsl:choose>
|
---|
| 1997 | <!-- Stupid, but backend boolean getters called isFoo(), not getFoo() -->
|
---|
| 1998 | <xsl:when test="$attrtype = 'boolean'">
|
---|
| 1999 | <xsl:variable name="capsname">
|
---|
| 2000 | <xsl:call-template name="capitalize">
|
---|
| 2001 | <xsl:with-param name="str" select="$attrname" />
|
---|
| 2002 | </xsl:call-template>
|
---|
| 2003 | </xsl:variable>
|
---|
| 2004 | <xsl:value-of select="concat('is', $capsname)" />
|
---|
| 2005 | </xsl:when>
|
---|
| 2006 | <xsl:otherwise>
|
---|
| 2007 | <xsl:call-template name="makeGetterName">
|
---|
| 2008 | <xsl:with-param name="attrname" select="$attrname" />
|
---|
[30987] | 2009 | </xsl:call-template>
|
---|
[43869] | 2010 | </xsl:otherwise>
|
---|
| 2011 | </xsl:choose>
|
---|
| 2012 | </xsl:variable>
|
---|
[46478] | 2013 |
|
---|
[43869] | 2014 | <xsl:variable name="gluegettername">
|
---|
| 2015 | <xsl:call-template name="makeGetterName">
|
---|
| 2016 | <xsl:with-param name="attrname" select="$attrname" />
|
---|
| 2017 | </xsl:call-template>
|
---|
| 2018 | </xsl:variable>
|
---|
[30987] | 2019 |
|
---|
[43869] | 2020 | <xsl:variable name="gluegettertype">
|
---|
| 2021 | <xsl:call-template name="typeIdl2Glue">
|
---|
| 2022 | <xsl:with-param name="type" select="$attrtype" />
|
---|
| 2023 | <xsl:with-param name="safearray" select="@safearray" />
|
---|
| 2024 | </xsl:call-template>
|
---|
| 2025 | </xsl:variable>
|
---|
[46478] | 2026 |
|
---|
[43869] | 2027 | <xsl:variable name="backgettertype">
|
---|
| 2028 | <xsl:call-template name="typeIdl2Back">
|
---|
| 2029 | <xsl:with-param name="type" select="$attrtype" />
|
---|
| 2030 | <xsl:with-param name="safearray" select="@safearray" />
|
---|
| 2031 | </xsl:call-template>
|
---|
| 2032 | </xsl:variable>
|
---|
[46478] | 2033 |
|
---|
[61203] | 2034 | <!-- For attributes containing a reference to another object just return the already cerated stub -->
|
---|
[46478] | 2035 | <xsl:apply-templates select="desc" mode="attribute_get"/>
|
---|
| 2036 | <xsl:value-of select="concat(' public ', $gluegettertype, ' ', $gluegettername, '() ')" />
|
---|
| 2037 | <xsl:text> { </xsl:text>
|
---|
[61203] | 2038 | <xsl:choose>
|
---|
| 2039 | <xsl:when test="$attrtype = '$unknown' or (count(key('G_keyInterfacesByName', $attrtype)) > 0)">
|
---|
| 2040 | <xsl:value-of select="concat(' return ', $attrname, '; ')" />
|
---|
| 2041 | </xsl:when>
|
---|
| 2042 | <xsl:otherwise>
|
---|
| 2043 | <xsl:value-of select="concat(' ', $backgettertype, ' retVal = real.', $backgettername, '(); ')" />
|
---|
| 2044 | <xsl:variable name="wrapped">
|
---|
| 2045 | <xsl:call-template name="cookOutParam">
|
---|
| 2046 | <xsl:with-param name="value" select="'retVal'" />
|
---|
| 2047 | <xsl:with-param name="idltype" select="$attrtype" />
|
---|
| 2048 | <xsl:with-param name="safearray" select="@safearray" />
|
---|
| 2049 | </xsl:call-template>
|
---|
| 2050 | </xsl:variable>
|
---|
| 2051 | <xsl:value-of select="concat(' return ', $wrapped, '; ')" />
|
---|
| 2052 | </xsl:otherwise>
|
---|
| 2053 | </xsl:choose>
|
---|
[46478] | 2054 | <xsl:text> } </xsl:text>
|
---|
[43869] | 2055 | </xsl:if>
|
---|
[30987] | 2056 |
|
---|
| 2057 | </xsl:for-each>
|
---|
| 2058 |
|
---|
| 2059 | </xsl:template>
|
---|
| 2060 |
|
---|
| 2061 | <!-- Interface method wrapper -->
|
---|
| 2062 | <xsl:template name="genMethod">
|
---|
| 2063 | <xsl:param name="ifname"/>
|
---|
| 2064 | <xsl:param name="methodname"/>
|
---|
| 2065 |
|
---|
| 2066 | <xsl:choose>
|
---|
| 2067 | <xsl:when test="(param[@mod='ptr']) or (($G_vboxGlueStyle='jaxws') and (param[@type=($G_setSuppressedInterfaces/@name)]))" >
|
---|
[43869] | 2068 | <xsl:value-of select="concat(' // Skipping method ', $methodname, ' for it has parameters with suppressed types ')" />
|
---|
[30987] | 2069 | </xsl:when>
|
---|
[43869] | 2070 | <xsl:when test="($G_vboxGlueStyle='jaxws') and (@wsmap = 'suppress')" >
|
---|
| 2071 | <xsl:value-of select="concat(' // Skipping method ', $methodname, ' for it is suppressed ')" />
|
---|
| 2072 | </xsl:when>
|
---|
[30987] | 2073 | <xsl:otherwise>
|
---|
| 2074 | <xsl:variable name="hasReturnParms" select="param[@dir='return']" />
|
---|
[51448] | 2075 | <xsl:variable name="hasOutParms" select="count(param[@dir='out']) > 0" />
|
---|
[30987] | 2076 | <xsl:variable name="returnidltype" select="param[@dir='return']/@type" />
|
---|
| 2077 | <xsl:variable name="returnidlsafearray" select="param[@dir='return']/@safearray" />
|
---|
[51448] | 2078 | <xsl:if test="$hasOutParms and not($hasReturnParms) and (string-length(@wsmap) = 0) and (count(param[@dir='out']) = 1)">
|
---|
[51444] | 2079 | <xsl:call-template name="fatalError">
|
---|
[51448] | 2080 | <xsl:with-param name="msg" select="concat('genMethod: ', $ifname, $hasOutParms, not($hasReturnParms), 'a', string-length(@wsmap) = 0, 'b', @wsmap, (count(param[@dir='out']) = 1), '::', $methodname, ' has exactly one out parameter and no return parameter, this causes trouble with JAX-WS and the out parameter needs to be converted to return')" />
|
---|
[51444] | 2081 | </xsl:call-template>
|
---|
| 2082 | </xsl:if>
|
---|
[30987] | 2083 | <xsl:variable name="returngluetype">
|
---|
| 2084 | <xsl:choose>
|
---|
| 2085 | <xsl:when test="$returnidltype">
|
---|
| 2086 | <xsl:call-template name="typeIdl2Glue">
|
---|
| 2087 | <xsl:with-param name="type" select="$returnidltype" />
|
---|
| 2088 | <xsl:with-param name="safearray" select="$returnidlsafearray" />
|
---|
| 2089 | </xsl:call-template>
|
---|
| 2090 | </xsl:when>
|
---|
| 2091 | <xsl:otherwise>
|
---|
| 2092 | <xsl:text>void</xsl:text>
|
---|
| 2093 | </xsl:otherwise>
|
---|
| 2094 | </xsl:choose>
|
---|
| 2095 | </xsl:variable>
|
---|
| 2096 | <xsl:variable name="retValValue">
|
---|
| 2097 | <xsl:choose>
|
---|
| 2098 | <xsl:when test="(param[@dir='out']) and ($G_vboxGlueStyle='jaxws')">
|
---|
[46478] | 2099 | <xsl:text>retVal.value</xsl:text>
|
---|
[30987] | 2100 | </xsl:when>
|
---|
| 2101 | <xsl:otherwise>
|
---|
[46478] | 2102 | <xsl:text>retVal</xsl:text>
|
---|
[30987] | 2103 | </xsl:otherwise>
|
---|
| 2104 | </xsl:choose>
|
---|
| 2105 | </xsl:variable>
|
---|
[38796] | 2106 | <xsl:apply-templates select="desc" mode="method"/>
|
---|
[30987] | 2107 | <xsl:value-of select="concat(' public ', $returngluetype, ' ', $methodname, '(')" />
|
---|
| 2108 | <xsl:variable name="paramsinout" select="param[@dir='in' or @dir='out']" />
|
---|
| 2109 | <xsl:for-each select="exsl:node-set($paramsinout)">
|
---|
| 2110 | <xsl:variable name="paramgluetype">
|
---|
| 2111 | <xsl:call-template name="typeIdl2Glue">
|
---|
| 2112 | <xsl:with-param name="type" select="@type" />
|
---|
| 2113 | <xsl:with-param name="safearray" select="@safearray" />
|
---|
| 2114 | </xsl:call-template>
|
---|
| 2115 | </xsl:variable>
|
---|
| 2116 | <xsl:choose>
|
---|
| 2117 | <xsl:when test="@dir='out'">
|
---|
| 2118 | <xsl:value-of select="concat('Holder<', $paramgluetype, '> ', @name)" />
|
---|
| 2119 | </xsl:when>
|
---|
| 2120 | <xsl:otherwise>
|
---|
| 2121 | <xsl:value-of select="concat($paramgluetype, ' ', @name)" />
|
---|
| 2122 | </xsl:otherwise>
|
---|
| 2123 | </xsl:choose>
|
---|
| 2124 | <xsl:if test="not(position()=last())">
|
---|
[46478] | 2125 | <xsl:text>, </xsl:text>
|
---|
[30987] | 2126 | </xsl:if>
|
---|
| 2127 | </xsl:for-each>
|
---|
[46478] | 2128 | <xsl:text>) </xsl:text>
|
---|
| 2129 | <xsl:text> { </xsl:text>
|
---|
[30987] | 2130 |
|
---|
[61203] | 2131 | <xsl:call-template name="startExcWrapper">
|
---|
| 2132 | <xsl:with-param name="preventObjRelease" select="$hasReturnParms and ($returnidltype = '$unknown' or (count(key('G_keyInterfacesByName', $returnidltype)) > 0))" />
|
---|
| 2133 | </xsl:call-template>
|
---|
[30987] | 2134 |
|
---|
| 2135 | <!-- declare temp out params -->
|
---|
| 2136 | <xsl:for-each select="param[@dir='out']">
|
---|
| 2137 | <xsl:variable name="backouttype">
|
---|
| 2138 | <xsl:call-template name="typeIdl2Back">
|
---|
| 2139 | <xsl:with-param name="type" select="@type" />
|
---|
| 2140 | <xsl:with-param name="safearray" select="@safearray" />
|
---|
| 2141 | </xsl:call-template>
|
---|
| 2142 | </xsl:variable>
|
---|
| 2143 | <xsl:choose>
|
---|
| 2144 | <xsl:when test="$G_vboxGlueStyle='xpcom'">
|
---|
[46478] | 2145 | <xsl:value-of select="concat(' ', $backouttype, '[] tmp_', @name, ' = (', $backouttype, '[])java.lang.reflect.Array.newInstance(', $backouttype, '.class, 1); ')"/>
|
---|
[30987] | 2146 | </xsl:when>
|
---|
| 2147 | <xsl:when test="$G_vboxGlueStyle='mscom'">
|
---|
[46478] | 2148 | <xsl:value-of select="concat(' Variant tmp_', @name, ' = new Variant(); ')"/>
|
---|
[30987] | 2149 | </xsl:when>
|
---|
| 2150 | <xsl:when test="$G_vboxGlueStyle='jaxws'">
|
---|
[46478] | 2151 | <xsl:value-of select="concat(' javax.xml.ws.Holder<', $backouttype, '> tmp_', @name, ' = new javax.xml.ws.Holder<', $backouttype, '>(); ')"/>
|
---|
[30987] | 2152 | </xsl:when>
|
---|
| 2153 | <xsl:otherwise>
|
---|
| 2154 | <xsl:call-template name="fatalError">
|
---|
| 2155 | <xsl:with-param name="msg" select="'Handle out param (genMethod)'" />
|
---|
| 2156 | </xsl:call-template>
|
---|
| 2157 | </xsl:otherwise>
|
---|
| 2158 | </xsl:choose>
|
---|
| 2159 | </xsl:for-each>
|
---|
| 2160 |
|
---|
| 2161 | <!-- declare return param, if any -->
|
---|
| 2162 | <xsl:if test="$hasReturnParms">
|
---|
| 2163 | <xsl:variable name="backrettype">
|
---|
| 2164 | <xsl:call-template name="typeIdl2Back">
|
---|
| 2165 | <xsl:with-param name="type" select="$returnidltype" />
|
---|
| 2166 | <xsl:with-param name="safearray" select="$returnidlsafearray" />
|
---|
| 2167 | </xsl:call-template>
|
---|
| 2168 | </xsl:variable>
|
---|
| 2169 | <xsl:choose>
|
---|
| 2170 | <xsl:when test="(param[@dir='out']) and ($G_vboxGlueStyle='jaxws')">
|
---|
| 2171 | <xsl:value-of select="concat(' javax.xml.ws.Holder<', $backrettype, '>',
|
---|
| 2172 | ' retVal = new javax.xml.ws.Holder<', $backrettype,
|
---|
| 2173 | '>(); ')"/>
|
---|
| 2174 | </xsl:when>
|
---|
| 2175 | <xsl:otherwise>
|
---|
[51416] | 2176 | <xsl:value-of select="concat(' ', $backrettype, ' retVal; ')"/>
|
---|
[30987] | 2177 | </xsl:otherwise>
|
---|
| 2178 | </xsl:choose>
|
---|
| 2179 | </xsl:if>
|
---|
| 2180 |
|
---|
| 2181 | <!-- Method call -->
|
---|
| 2182 | <xsl:call-template name="genBackMethodCall">
|
---|
| 2183 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
| 2184 | <xsl:with-param name="methodname" select="$methodname" />
|
---|
| 2185 | <xsl:with-param name="retval" select="'retVal'" />
|
---|
| 2186 | </xsl:call-template>
|
---|
| 2187 |
|
---|
[46478] | 2188 | <!-- return out params -->
|
---|
[30987] | 2189 | <xsl:for-each select="param[@dir='out']">
|
---|
| 2190 | <xsl:variable name="varval">
|
---|
| 2191 | <xsl:choose>
|
---|
| 2192 | <xsl:when test="$G_vboxGlueStyle='xpcom'">
|
---|
[46478] | 2193 | <xsl:value-of select="concat('tmp_', @name, '[0]')" />
|
---|
[30987] | 2194 | </xsl:when>
|
---|
| 2195 | <xsl:when test="$G_vboxGlueStyle='mscom'">
|
---|
[46478] | 2196 | <xsl:value-of select="concat('tmp_', @name)" />
|
---|
[30987] | 2197 | </xsl:when>
|
---|
| 2198 | <xsl:when test="$G_vboxGlueStyle='jaxws'">
|
---|
[46478] | 2199 | <xsl:value-of select="concat('tmp_', @name, '.value')" />
|
---|
[30987] | 2200 | </xsl:when>
|
---|
| 2201 | <xsl:otherwise>
|
---|
| 2202 | <xsl:call-template name="fatalError">
|
---|
| 2203 | <xsl:with-param name="msg" select="'Style unknown (genMethod, outparam)'" />
|
---|
| 2204 | </xsl:call-template>
|
---|
| 2205 | </xsl:otherwise>
|
---|
| 2206 | </xsl:choose>
|
---|
| 2207 | </xsl:variable>
|
---|
| 2208 | <xsl:variable name="wrapped">
|
---|
| 2209 | <xsl:call-template name="cookOutParam">
|
---|
| 2210 | <xsl:with-param name="value" select="$varval" />
|
---|
| 2211 | <xsl:with-param name="idltype" select="@type" />
|
---|
| 2212 | <xsl:with-param name="safearray" select="@safearray" />
|
---|
| 2213 | </xsl:call-template>
|
---|
| 2214 | </xsl:variable>
|
---|
[46478] | 2215 | <xsl:value-of select="concat(' ', @name, '.value = ', $wrapped, '; ')"/>
|
---|
[30987] | 2216 | </xsl:for-each>
|
---|
| 2217 |
|
---|
| 2218 | <xsl:if test="$hasReturnParms">
|
---|
| 2219 | <!-- actual 'return' statement -->
|
---|
| 2220 | <xsl:variable name="wrapped">
|
---|
| 2221 | <xsl:call-template name="cookOutParam">
|
---|
| 2222 | <xsl:with-param name="value" select="$retValValue" />
|
---|
| 2223 | <xsl:with-param name="idltype" select="$returnidltype" />
|
---|
| 2224 | <xsl:with-param name="safearray" select="$returnidlsafearray" />
|
---|
| 2225 | </xsl:call-template>
|
---|
| 2226 | </xsl:variable>
|
---|
[61203] | 2227 | <xsl:value-of select="concat(' return ', $wrapped, '; ')" />
|
---|
[30987] | 2228 | </xsl:if>
|
---|
[61203] | 2229 | <xsl:call-template name="endExcWrapper">
|
---|
| 2230 | <xsl:with-param name="allowObjRelease" select="$hasReturnParms and ($returnidltype = '$unknown' or (count(key('G_keyInterfacesByName', $returnidltype)) > 0))" />
|
---|
| 2231 | </xsl:call-template>
|
---|
[30987] | 2232 |
|
---|
[46478] | 2233 | <xsl:text> } </xsl:text>
|
---|
[30987] | 2234 | </xsl:otherwise>
|
---|
| 2235 | </xsl:choose>
|
---|
| 2236 |
|
---|
| 2237 | </xsl:template>
|
---|
| 2238 |
|
---|
| 2239 | <!-- Callback interface method -->
|
---|
| 2240 | <xsl:template name="genCbMethodDecl">
|
---|
| 2241 | <xsl:param name="ifname"/>
|
---|
| 2242 | <xsl:param name="methodname"/>
|
---|
| 2243 |
|
---|
| 2244 | <xsl:choose>
|
---|
| 2245 | <xsl:when test="(param[@mod='ptr'])" >
|
---|
[43869] | 2246 | <xsl:value-of select="concat(' // Skipping method ', $methodname, ' for it has parameters with suppressed types ')" />
|
---|
[30987] | 2247 | </xsl:when>
|
---|
| 2248 | <xsl:otherwise>
|
---|
| 2249 | <xsl:variable name="returnidltype" select="param[@dir='return']/@type" />
|
---|
| 2250 | <xsl:variable name="returnidlsafearray" select="param[@dir='return']/@safearray" />
|
---|
| 2251 | <xsl:variable name="returngluetype">
|
---|
| 2252 | <xsl:choose>
|
---|
| 2253 | <xsl:when test="$returnidltype">
|
---|
| 2254 | <xsl:call-template name="typeIdl2Glue">
|
---|
| 2255 | <xsl:with-param name="type" select="$returnidltype" />
|
---|
| 2256 | <xsl:with-param name="safearray" select="$returnidlsafearray" />
|
---|
| 2257 | </xsl:call-template>
|
---|
| 2258 | </xsl:when>
|
---|
| 2259 | <xsl:otherwise>
|
---|
| 2260 | <xsl:text>void</xsl:text>
|
---|
| 2261 | </xsl:otherwise>
|
---|
| 2262 | </xsl:choose>
|
---|
| 2263 | </xsl:variable>
|
---|
| 2264 | <xsl:value-of select="concat(' public ', $returngluetype, ' ', $methodname, '(')" />
|
---|
| 2265 | <xsl:variable name="paramsinout" select="param[@dir='in' or @dir='out']" />
|
---|
| 2266 | <xsl:for-each select="exsl:node-set($paramsinout)">
|
---|
| 2267 | <xsl:variable name="paramgluetype">
|
---|
| 2268 | <xsl:call-template name="typeIdl2Glue">
|
---|
| 2269 | <xsl:with-param name="type" select="@type" />
|
---|
| 2270 | <xsl:with-param name="safearray" select="@safearray" />
|
---|
| 2271 | </xsl:call-template>
|
---|
| 2272 | </xsl:variable>
|
---|
| 2273 | <xsl:choose>
|
---|
| 2274 | <xsl:when test="@dir='out'">
|
---|
| 2275 | <xsl:value-of select="concat('Holder<', $paramgluetype, '> ', @name)" />
|
---|
| 2276 | </xsl:when>
|
---|
| 2277 | <xsl:otherwise>
|
---|
| 2278 | <xsl:value-of select="concat($paramgluetype, ' ', @name)" />
|
---|
| 2279 | </xsl:otherwise>
|
---|
| 2280 | </xsl:choose>
|
---|
| 2281 | <xsl:if test="not(position()=last())">
|
---|
| 2282 | <xsl:text>, </xsl:text>
|
---|
| 2283 | </xsl:if>
|
---|
| 2284 | </xsl:for-each>
|
---|
[46478] | 2285 | <xsl:text>); </xsl:text>
|
---|
[30987] | 2286 | </xsl:otherwise>
|
---|
| 2287 | </xsl:choose>
|
---|
| 2288 | </xsl:template>
|
---|
| 2289 |
|
---|
| 2290 | <!-- queryInterface wrapper -->
|
---|
| 2291 | <xsl:template name="genQI">
|
---|
| 2292 | <xsl:param name="ifname"/>
|
---|
| 2293 | <xsl:param name="uuid" />
|
---|
| 2294 |
|
---|
[46478] | 2295 | <xsl:value-of select="concat(' public static ', $ifname, ' queryInterface(IUnknown obj) ')" />
|
---|
| 2296 | <xsl:text> { </xsl:text>
|
---|
[30987] | 2297 | <xsl:choose>
|
---|
| 2298 | <xsl:when test="$G_vboxGlueStyle='xpcom'">
|
---|
| 2299 | <xsl:variable name="backtype">
|
---|
| 2300 | <xsl:call-template name="typeIdl2Back">
|
---|
| 2301 | <xsl:with-param name="type" select="$ifname" />
|
---|
| 2302 | </xsl:call-template>
|
---|
| 2303 | </xsl:variable>
|
---|
[51416] | 2304 | <xsl:text> nsISupports nsobj = obj != null ? (nsISupports)obj.getWrapped() : null; </xsl:text>
|
---|
| 2305 | <xsl:text> if (nsobj == null) return null; </xsl:text>
|
---|
| 2306 | <xsl:value-of select="concat(' ', $backtype, ' qiobj = Helper.queryInterface(nsobj, "{', $uuid, '}", ', $backtype, '.class); ')" />
|
---|
| 2307 | <xsl:value-of select="concat(' return qiobj == null ? null : new ', $ifname, '(qiobj); ')" />
|
---|
[30987] | 2308 | </xsl:when>
|
---|
| 2309 |
|
---|
| 2310 | <xsl:when test="$G_vboxGlueStyle='mscom'">
|
---|
[51416] | 2311 | <xsl:value-of select="concat(' return', ' obj == null ? null : new ', $ifname, '((com.jacob.com.Dispatch)obj.getWrapped()); ')" />
|
---|
[30987] | 2312 | </xsl:when>
|
---|
| 2313 |
|
---|
| 2314 | <xsl:when test="$G_vboxGlueStyle='jaxws'">
|
---|
| 2315 | <!-- bad, need to check that we really can be casted to this type -->
|
---|
[61203] | 2316 | <xsl:value-of select="concat(' return obj == null ? null : new ', $ifname, '(obj.getWrapped(), obj.getObjMgr(), obj.getRemoteWSPort()); ')" />
|
---|
[30987] | 2317 | </xsl:when>
|
---|
| 2318 |
|
---|
| 2319 | <xsl:otherwise>
|
---|
| 2320 | <xsl:call-template name="fatalError">
|
---|
| 2321 | <xsl:with-param name="msg" select="'Style unknown (genQI)'" />
|
---|
| 2322 | </xsl:call-template>
|
---|
| 2323 | </xsl:otherwise>
|
---|
| 2324 |
|
---|
| 2325 | </xsl:choose>
|
---|
[46478] | 2326 | <xsl:text> } </xsl:text>
|
---|
[30987] | 2327 | </xsl:template>
|
---|
| 2328 |
|
---|
| 2329 |
|
---|
| 2330 | <xsl:template name="genCbMethodImpl">
|
---|
| 2331 | <xsl:param name="ifname"/>
|
---|
| 2332 | <xsl:param name="methodname"/>
|
---|
| 2333 |
|
---|
| 2334 | <xsl:choose>
|
---|
| 2335 | <xsl:when test="(param[@mod='ptr'])" >
|
---|
[43869] | 2336 | <xsl:value-of select="concat(' // Skipping method ', $methodname, ' for it has parameters with suppressed types ')" />
|
---|
[30987] | 2337 | </xsl:when>
|
---|
| 2338 | <xsl:otherwise>
|
---|
| 2339 | <xsl:variable name="hasReturnParms" select="param[@dir='return']" />
|
---|
| 2340 | <xsl:variable name="returnidltype" select="param[@dir='return']/@type" />
|
---|
| 2341 | <xsl:variable name="returnidlsafearray" select="param[@dir='return']/@safearray" />
|
---|
| 2342 | <xsl:variable name="returnbacktype">
|
---|
| 2343 | <xsl:choose>
|
---|
| 2344 | <xsl:when test="$returnidltype">
|
---|
| 2345 | <xsl:call-template name="typeIdl2Back">
|
---|
| 2346 | <xsl:with-param name="type" select="$returnidltype" />
|
---|
| 2347 | <xsl:with-param name="safearray" select="$returnidlsafearray" />
|
---|
| 2348 | </xsl:call-template>
|
---|
| 2349 | </xsl:when>
|
---|
| 2350 | <xsl:otherwise>
|
---|
| 2351 | <xsl:text>void</xsl:text>
|
---|
| 2352 | </xsl:otherwise>
|
---|
| 2353 | </xsl:choose>
|
---|
| 2354 | </xsl:variable>
|
---|
| 2355 | <xsl:variable name="paramsinout" select="param[@dir='in' or @dir='out']" />
|
---|
| 2356 | <xsl:choose>
|
---|
| 2357 | <xsl:when test="$G_vboxGlueStyle='xpcom'">
|
---|
| 2358 | <xsl:value-of select="concat(' public ', $returnbacktype, ' ', $methodname, '(')" />
|
---|
| 2359 | <xsl:for-each select="exsl:node-set($paramsinout)">
|
---|
| 2360 | <xsl:variable name="parambacktype">
|
---|
| 2361 | <xsl:call-template name="typeIdl2Back">
|
---|
| 2362 | <xsl:with-param name="type" select="@type" />
|
---|
| 2363 | <xsl:with-param name="safearray" select="@safearray" />
|
---|
| 2364 | </xsl:call-template>
|
---|
| 2365 | </xsl:variable>
|
---|
| 2366 | <xsl:choose>
|
---|
| 2367 | <xsl:when test="@dir='out'">
|
---|
| 2368 | <xsl:value-of select="concat($parambacktype, '[] ', @name)" />
|
---|
| 2369 | </xsl:when>
|
---|
| 2370 | <xsl:otherwise>
|
---|
[94375] | 2371 | <xsl:if test="@safearray='yes'">
|
---|
[46478] | 2372 | <xsl:value-of select="concat('long len_', @name, ', ')" />
|
---|
[30987] | 2373 | </xsl:if>
|
---|
| 2374 | <xsl:value-of select="concat($parambacktype, ' ', @name)" />
|
---|
| 2375 | </xsl:otherwise>
|
---|
| 2376 | </xsl:choose>
|
---|
| 2377 | <xsl:if test="not(position()=last())">
|
---|
| 2378 | <xsl:text>, </xsl:text>
|
---|
| 2379 | </xsl:if>
|
---|
| 2380 | </xsl:for-each>
|
---|
[46478] | 2381 | <xsl:text>) </xsl:text>
|
---|
| 2382 | <xsl:text> { </xsl:text>
|
---|
[30987] | 2383 | </xsl:when>
|
---|
| 2384 |
|
---|
| 2385 | <xsl:when test="$G_vboxGlueStyle='mscom'">
|
---|
| 2386 | <xsl:variable name="capsname">
|
---|
| 2387 | <xsl:call-template name="capitalize">
|
---|
| 2388 | <xsl:with-param name="str" select="$methodname" />
|
---|
| 2389 | </xsl:call-template>
|
---|
| 2390 | </xsl:variable>
|
---|
| 2391 | <xsl:value-of select="concat(' public ', $returnbacktype, ' ', $capsname, '(')" />
|
---|
[46478] | 2392 | <xsl:text>Variant _args[]) </xsl:text>
|
---|
| 2393 | <xsl:text> { </xsl:text>
|
---|
[30987] | 2394 | <xsl:for-each select="exsl:node-set($paramsinout)">
|
---|
| 2395 | <xsl:variable name="parambacktype">
|
---|
| 2396 | <xsl:call-template name="typeIdl2Back">
|
---|
| 2397 | <xsl:with-param name="type" select="@type" />
|
---|
| 2398 | <xsl:with-param name="safearray" select="@safearray" />
|
---|
| 2399 | </xsl:call-template>
|
---|
| 2400 | </xsl:variable>
|
---|
[46478] | 2401 | <xsl:value-of select="concat(' ', $parambacktype, ' ', @name, '=_args[', count(preceding-sibling::param), ']; ')" />
|
---|
[30987] | 2402 | </xsl:for-each>
|
---|
| 2403 | </xsl:when>
|
---|
| 2404 |
|
---|
[46478] | 2405 | <xsl:otherwise>
|
---|
| 2406 | <xsl:call-template name="fatalError">
|
---|
| 2407 | <xsl:with-param name="msg" select="'Style unknown (genSetterCall)'" />
|
---|
| 2408 | </xsl:call-template>
|
---|
| 2409 | </xsl:otherwise>
|
---|
[30987] | 2410 | </xsl:choose>
|
---|
| 2411 |
|
---|
| 2412 | <!-- declare temp out params -->
|
---|
| 2413 | <xsl:for-each select="param[@dir='out']">
|
---|
| 2414 | <xsl:variable name="glueouttype">
|
---|
| 2415 | <xsl:call-template name="typeIdl2Glue">
|
---|
| 2416 | <xsl:with-param name="type" select="@type" />
|
---|
| 2417 | <xsl:with-param name="safearray" select="@safearray" />
|
---|
| 2418 | </xsl:call-template>
|
---|
| 2419 | </xsl:variable>
|
---|
| 2420 | <xsl:value-of select="concat(' Holder<', $glueouttype, '> tmp_', @name, ' = new Holder<', $glueouttype, '>(); ')"/>
|
---|
| 2421 | </xsl:for-each>
|
---|
| 2422 |
|
---|
| 2423 | <!-- declare return param, if any -->
|
---|
| 2424 | <xsl:if test="$hasReturnParms">
|
---|
| 2425 | <xsl:variable name="gluerettype">
|
---|
| 2426 | <xsl:call-template name="typeIdl2Glue">
|
---|
| 2427 | <xsl:with-param name="type" select="$returnidltype" />
|
---|
| 2428 | <xsl:with-param name="safearray" select="$returnidlsafearray" />
|
---|
| 2429 | </xsl:call-template>
|
---|
| 2430 | </xsl:variable>
|
---|
| 2431 | <xsl:value-of select="concat(' ', $gluerettype, ' retVal = ')"/>
|
---|
| 2432 | </xsl:if>
|
---|
| 2433 |
|
---|
| 2434 | <!-- Method call -->
|
---|
[46478] | 2435 | <xsl:value-of select="concat(' sink.', $methodname, '(')"/>
|
---|
[30987] | 2436 | <xsl:for-each select="param[not(@dir='return')]">
|
---|
[46478] | 2437 | <xsl:choose>
|
---|
| 2438 | <xsl:when test="@dir='out'">
|
---|
| 2439 | <xsl:value-of select="concat('tmp_', @name)" />
|
---|
| 2440 | </xsl:when>
|
---|
| 2441 | <xsl:when test="@dir='in'">
|
---|
| 2442 | <xsl:variable name="wrapped">
|
---|
| 2443 | <xsl:call-template name="cookOutParam">
|
---|
| 2444 | <xsl:with-param name="value" select="@name" />
|
---|
| 2445 | <xsl:with-param name="idltype" select="@type" />
|
---|
| 2446 | <xsl:with-param name="safearray" select="@safearray" />
|
---|
[30987] | 2447 | </xsl:call-template>
|
---|
[46478] | 2448 | </xsl:variable>
|
---|
| 2449 | <xsl:value-of select="$wrapped"/>
|
---|
| 2450 | </xsl:when>
|
---|
| 2451 | <xsl:otherwise>
|
---|
| 2452 | <xsl:call-template name="fatalError">
|
---|
| 2453 | <xsl:with-param name="msg" select="concat('Unsupported param dir: ', @dir, '".')" />
|
---|
| 2454 | </xsl:call-template>
|
---|
| 2455 | </xsl:otherwise>
|
---|
| 2456 | </xsl:choose>
|
---|
| 2457 | <xsl:if test="not(position()=last())">
|
---|
| 2458 | <xsl:text>, </xsl:text>
|
---|
| 2459 | </xsl:if>
|
---|
[30987] | 2460 | </xsl:for-each>
|
---|
[46478] | 2461 | <xsl:text>); </xsl:text>
|
---|
[30987] | 2462 |
|
---|
[46478] | 2463 | <!-- return out params -->
|
---|
[30987] | 2464 | <xsl:for-each select="param[@dir='out']">
|
---|
| 2465 |
|
---|
| 2466 | <xsl:variable name="unwrapped">
|
---|
| 2467 | <xsl:call-template name="cookInParam">
|
---|
[46478] | 2468 | <xsl:with-param name="value" select="concat('tmp_', @name, '.value')" />
|
---|
[30987] | 2469 | <xsl:with-param name="idltype" select="@type" />
|
---|
| 2470 | <xsl:with-param name="safearray" select="@safearray" />
|
---|
| 2471 | </xsl:call-template>
|
---|
| 2472 | </xsl:variable>
|
---|
| 2473 | <xsl:choose>
|
---|
| 2474 | <xsl:when test="$G_vboxGlueStyle='xpcom'">
|
---|
[46478] | 2475 | <xsl:value-of select="concat(' ', @name, '[0] = ', $unwrapped, '; ')"/>
|
---|
[30987] | 2476 | </xsl:when>
|
---|
| 2477 | <xsl:when test="$G_vboxGlueStyle='mscom'">
|
---|
[46478] | 2478 | <xsl:value-of select="concat(' _args[', count(preceding-sibling::param), '] = ', $unwrapped, '; ')"/>
|
---|
[30987] | 2479 | </xsl:when>
|
---|
| 2480 | </xsl:choose>
|
---|
| 2481 | </xsl:for-each>
|
---|
| 2482 |
|
---|
| 2483 | <xsl:if test="$hasReturnParms">
|
---|
| 2484 | <!-- actual 'return' statement -->
|
---|
| 2485 | <xsl:variable name="unwrapped">
|
---|
| 2486 | <xsl:call-template name="cookInParam">
|
---|
| 2487 | <xsl:with-param name="value" select="'retVal'" />
|
---|
| 2488 | <xsl:with-param name="idltype" select="$returnidltype" />
|
---|
| 2489 | <xsl:with-param name="safearray" select="$returnidlsafearray" />
|
---|
| 2490 | </xsl:call-template>
|
---|
| 2491 | </xsl:variable>
|
---|
| 2492 | <xsl:value-of select="concat(' return ', $unwrapped, '; ')" />
|
---|
| 2493 | </xsl:if>
|
---|
[46478] | 2494 | <xsl:text> } </xsl:text>
|
---|
[30987] | 2495 | </xsl:otherwise>
|
---|
| 2496 | </xsl:choose>
|
---|
| 2497 | </xsl:template>
|
---|
| 2498 |
|
---|
| 2499 | <!-- Interface method -->
|
---|
| 2500 | <xsl:template name="genIfaceWrapper">
|
---|
| 2501 | <xsl:param name="ifname"/>
|
---|
| 2502 |
|
---|
| 2503 | <xsl:variable name="wrappedType">
|
---|
| 2504 | <xsl:call-template name="wrappedName">
|
---|
| 2505 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
| 2506 | </xsl:call-template>
|
---|
| 2507 | </xsl:variable>
|
---|
| 2508 |
|
---|
| 2509 | <!-- Constructor -->
|
---|
| 2510 | <xsl:choose>
|
---|
| 2511 | <xsl:when test="($G_vboxGlueStyle='jaxws')">
|
---|
[61203] | 2512 | <xsl:value-of select="concat(' public ', $ifname, '(String wrapped, ObjectRefManager objMgr, VboxPortType port) ')" />
|
---|
[46478] | 2513 | <xsl:text> { </xsl:text>
|
---|
[61203] | 2514 | <xsl:text> super(wrapped, objMgr, port); </xsl:text>
|
---|
[46478] | 2515 | <xsl:text> } </xsl:text>
|
---|
[30987] | 2516 | </xsl:when>
|
---|
| 2517 |
|
---|
| 2518 | <xsl:when test="($G_vboxGlueStyle='xpcom') or ($G_vboxGlueStyle='mscom')">
|
---|
[46478] | 2519 | <xsl:value-of select="concat(' public ', $ifname, '(', $wrappedType, ' wrapped) ')" />
|
---|
| 2520 | <xsl:text> { </xsl:text>
|
---|
[51416] | 2521 | <xsl:text> super(wrapped); </xsl:text>
|
---|
[46478] | 2522 | <xsl:text> } </xsl:text>
|
---|
[30987] | 2523 |
|
---|
| 2524 | <!-- Typed wrapped object accessor -->
|
---|
[46478] | 2525 | <xsl:value-of select="concat(' public ', $wrappedType, ' getTypedWrapped() ')" />
|
---|
| 2526 | <xsl:text> { </xsl:text>
|
---|
| 2527 | <xsl:value-of select="concat(' return (', $wrappedType, ') getWrapped(); ')" />
|
---|
| 2528 | <xsl:text> } </xsl:text>
|
---|
[30987] | 2529 | </xsl:when>
|
---|
| 2530 |
|
---|
| 2531 | <xsl:otherwise>
|
---|
| 2532 | <xsl:call-template name="fatalError">
|
---|
| 2533 | <xsl:with-param name="msg" select="'Style unknown (root, ctr)'" />
|
---|
| 2534 | </xsl:call-template>
|
---|
| 2535 | </xsl:otherwise>
|
---|
| 2536 | </xsl:choose>
|
---|
| 2537 | <!-- Attributes -->
|
---|
| 2538 | <xsl:for-each select="attribute[not(@mod='ptr')]">
|
---|
| 2539 | <xsl:variable name="attrname"><xsl:value-of select="@name" /></xsl:variable>
|
---|
| 2540 | <xsl:variable name="attrtype"><xsl:value-of select="@type" /></xsl:variable>
|
---|
| 2541 | <xsl:variable name="attrsafearray"><xsl:value-of select="@safearray" /></xsl:variable>
|
---|
| 2542 |
|
---|
| 2543 | <xsl:choose>
|
---|
| 2544 | <xsl:when test="($G_vboxGlueStyle='jaxws') and ($attrtype=($G_setSuppressedInterfaces/@name))">
|
---|
[46478] | 2545 | <xsl:value-of select="concat(' // Skipping attribute ', $attrname, ' of suppressed type ', $attrtype, ' ')" />
|
---|
[30987] | 2546 | </xsl:when>
|
---|
[43869] | 2547 | <xsl:when test="($G_vboxGlueStyle='jaxws') and (@wsmap = 'suppress')" >
|
---|
| 2548 | <xsl:value-of select="concat(' // Skipping attribute ', $attrname, ' for it is suppressed ')" />
|
---|
| 2549 | </xsl:when>
|
---|
[30987] | 2550 |
|
---|
| 2551 | <xsl:otherwise>
|
---|
| 2552 | <!-- emit getter method -->
|
---|
[38796] | 2553 | <xsl:apply-templates select="desc" mode="attribute_get"/>
|
---|
[30987] | 2554 | <xsl:variable name="gettername">
|
---|
| 2555 | <xsl:call-template name="makeGetterName">
|
---|
| 2556 | <xsl:with-param name="attrname" select="$attrname" />
|
---|
| 2557 | </xsl:call-template>
|
---|
| 2558 | </xsl:variable>
|
---|
| 2559 | <xsl:variable name="gluetype">
|
---|
| 2560 | <xsl:call-template name="typeIdl2Glue">
|
---|
| 2561 | <xsl:with-param name="type" select="$attrtype" />
|
---|
| 2562 | <xsl:with-param name="safearray" select="@safearray" />
|
---|
| 2563 | </xsl:call-template>
|
---|
| 2564 | </xsl:variable>
|
---|
| 2565 | <xsl:variable name="backtype">
|
---|
| 2566 | <xsl:call-template name="typeIdl2Back">
|
---|
| 2567 | <xsl:with-param name="type" select="$attrtype" />
|
---|
| 2568 | <xsl:with-param name="safearray" select="@safearray" />
|
---|
| 2569 | </xsl:call-template>
|
---|
| 2570 | </xsl:variable>
|
---|
| 2571 | <xsl:variable name="wrapped">
|
---|
| 2572 | <xsl:call-template name="cookOutParam">
|
---|
| 2573 | <xsl:with-param name="value" select="'retVal'" />
|
---|
| 2574 | <xsl:with-param name="idltype" select="$attrtype" />
|
---|
| 2575 | <xsl:with-param name="safearray" select="@safearray" />
|
---|
| 2576 | </xsl:call-template>
|
---|
| 2577 | </xsl:variable>
|
---|
[46478] | 2578 | <xsl:value-of select="concat(' public ', $gluetype, ' ', $gettername, '() ')" />
|
---|
| 2579 | <xsl:text> { </xsl:text>
|
---|
[30987] | 2580 |
|
---|
| 2581 |
|
---|
[61203] | 2582 | <xsl:call-template name="startExcWrapper">
|
---|
| 2583 | <xsl:with-param name="preventObjRelease" select="$attrtype = '$unknown' or (count(key('G_keyInterfacesByName', $attrtype)) > 0)" />
|
---|
| 2584 | </xsl:call-template>
|
---|
| 2585 |
|
---|
[30987] | 2586 | <!-- Actual getter implementation -->
|
---|
| 2587 | <xsl:call-template name="genGetterCall">
|
---|
| 2588 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
| 2589 | <xsl:with-param name="gettername" select="$gettername" />
|
---|
| 2590 | <xsl:with-param name="backtype" select="$backtype" />
|
---|
| 2591 | <xsl:with-param name="retval" select="'retVal'" />
|
---|
| 2592 | </xsl:call-template>
|
---|
| 2593 |
|
---|
[46478] | 2594 | <xsl:value-of select="concat(' return ', $wrapped, '; ')" />
|
---|
[30987] | 2595 |
|
---|
[61203] | 2596 | <xsl:call-template name="endExcWrapper">
|
---|
| 2597 | <xsl:with-param name="allowObjRelease" select="$attrtype = '$unknown' or (count(key('G_keyInterfacesByName', $attrtype)) > 0)" />
|
---|
| 2598 | </xsl:call-template>
|
---|
| 2599 |
|
---|
[46478] | 2600 | <xsl:text> } </xsl:text>
|
---|
| 2601 | <xsl:if test="not(@readonly = 'yes')">
|
---|
[30987] | 2602 | <!-- emit setter method -->
|
---|
[38796] | 2603 | <xsl:apply-templates select="desc" mode="attribute_set"/>
|
---|
[30987] | 2604 | <xsl:variable name="settername"><xsl:call-template name="makeSetterName"><xsl:with-param name="attrname" select="$attrname" /></xsl:call-template></xsl:variable>
|
---|
| 2605 | <xsl:variable name="unwrapped">
|
---|
| 2606 | <xsl:call-template name="cookInParam">
|
---|
| 2607 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
| 2608 | <xsl:with-param name="value" select="'value'" />
|
---|
| 2609 | <xsl:with-param name="idltype" select="$attrtype" />
|
---|
| 2610 | <xsl:with-param name="safearray" select="@safearray" />
|
---|
| 2611 | </xsl:call-template>
|
---|
| 2612 | </xsl:variable>
|
---|
[46478] | 2613 | <xsl:value-of select="concat(' public void ', $settername, '(', $gluetype, ' value) ')" />
|
---|
| 2614 | <xsl:text> { </xsl:text>
|
---|
[30987] | 2615 | <xsl:call-template name="startExcWrapper"/>
|
---|
| 2616 | <!-- Actual setter implementation -->
|
---|
| 2617 | <xsl:call-template name="genSetterCall">
|
---|
| 2618 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
| 2619 | <xsl:with-param name="settername" select="$settername" />
|
---|
| 2620 | <xsl:with-param name="value" select="$unwrapped" />
|
---|
| 2621 | </xsl:call-template>
|
---|
| 2622 | <xsl:call-template name="endExcWrapper"/>
|
---|
[46478] | 2623 | <xsl:text> } </xsl:text>
|
---|
[30987] | 2624 | </xsl:if>
|
---|
| 2625 |
|
---|
| 2626 | </xsl:otherwise>
|
---|
| 2627 | </xsl:choose>
|
---|
| 2628 |
|
---|
| 2629 | </xsl:for-each>
|
---|
| 2630 |
|
---|
| 2631 | <!-- emit queryInterface() *to* this class -->
|
---|
| 2632 | <xsl:call-template name="genQI">
|
---|
| 2633 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
| 2634 | <xsl:with-param name="uuid" select="@uuid" />
|
---|
| 2635 | </xsl:call-template>
|
---|
| 2636 |
|
---|
| 2637 | <!-- emit methods -->
|
---|
| 2638 | <xsl:for-each select="method">
|
---|
| 2639 | <xsl:call-template name="genMethod">
|
---|
| 2640 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
| 2641 | <xsl:with-param name="methodname" select="@name" />
|
---|
| 2642 | </xsl:call-template>
|
---|
| 2643 | </xsl:for-each>
|
---|
| 2644 |
|
---|
| 2645 | </xsl:template>
|
---|
| 2646 |
|
---|
| 2647 | <xsl:template name="genIface">
|
---|
| 2648 | <xsl:param name="ifname" />
|
---|
| 2649 | <xsl:param name="filename" />
|
---|
| 2650 |
|
---|
| 2651 | <xsl:variable name="wsmap" select="@wsmap" />
|
---|
| 2652 |
|
---|
| 2653 | <xsl:call-template name="startFile">
|
---|
| 2654 | <xsl:with-param name="file" select="$filename" />
|
---|
| 2655 | <xsl:with-param name="package" select="$G_virtualBoxPackage" />
|
---|
| 2656 | </xsl:call-template>
|
---|
| 2657 |
|
---|
[46478] | 2658 | <xsl:if test="$filelistonly=''">
|
---|
| 2659 | <xsl:text>import java.util.List; </xsl:text>
|
---|
[30987] | 2660 |
|
---|
[46478] | 2661 | <xsl:apply-templates select="desc" mode="interface"/>
|
---|
[38796] | 2662 |
|
---|
[46478] | 2663 | <xsl:choose>
|
---|
| 2664 | <xsl:when test="($wsmap='struct') and ($G_vboxGlueStyle='jaxws')">
|
---|
| 2665 | <xsl:value-of select="concat('public class ', $ifname, ' ')" />
|
---|
| 2666 | <xsl:text>{ </xsl:text>
|
---|
| 2667 | <xsl:call-template name="genStructWrapperJaxws">
|
---|
| 2668 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
| 2669 | </xsl:call-template>
|
---|
| 2670 | </xsl:when>
|
---|
[38796] | 2671 |
|
---|
[46478] | 2672 | <xsl:otherwise>
|
---|
[53922] | 2673 | <xsl:variable name="extends" select="key('G_keyInterfacesByName', $ifname)/@extends" />
|
---|
[46478] | 2674 | <xsl:choose>
|
---|
[50183] | 2675 | <xsl:when test="($extends = '$unknown') or ($extends = '$errorinfo')">
|
---|
[46478] | 2676 | <xsl:value-of select="concat('public class ', $ifname, ' extends IUnknown ')" />
|
---|
| 2677 | <xsl:text>{ </xsl:text>
|
---|
| 2678 | </xsl:when>
|
---|
[53922] | 2679 | <xsl:when test="count(key('G_keyInterfacesByName', $extends)) > 0">
|
---|
[46478] | 2680 | <xsl:value-of select="concat('public class ', $ifname, ' extends ', $extends, ' ')" />
|
---|
| 2681 | <xsl:text>{ </xsl:text>
|
---|
| 2682 | </xsl:when>
|
---|
| 2683 | <xsl:otherwise>
|
---|
| 2684 | <xsl:call-template name="fatalError">
|
---|
| 2685 | <xsl:with-param name="msg" select="concat('Interface generation: interface "', $ifname, '" has invalid "extends" value ', $extends, '.')" />
|
---|
| 2686 | </xsl:call-template>
|
---|
| 2687 | </xsl:otherwise>
|
---|
| 2688 | </xsl:choose>
|
---|
| 2689 | <xsl:call-template name="genIfaceWrapper">
|
---|
| 2690 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
| 2691 | </xsl:call-template>
|
---|
| 2692 | </xsl:otherwise>
|
---|
| 2693 | </xsl:choose>
|
---|
[30987] | 2694 |
|
---|
[46478] | 2695 | <!-- end of class -->
|
---|
| 2696 | <xsl:text>} </xsl:text>
|
---|
| 2697 | </xsl:if>
|
---|
[30987] | 2698 |
|
---|
[38796] | 2699 | <xsl:call-template name="endFile">
|
---|
| 2700 | <xsl:with-param name="file" select="$filename" />
|
---|
| 2701 | </xsl:call-template>
|
---|
[30987] | 2702 |
|
---|
| 2703 | </xsl:template>
|
---|
| 2704 |
|
---|
| 2705 | <xsl:template name="genCb">
|
---|
| 2706 | <xsl:param name="ifname" />
|
---|
| 2707 | <xsl:param name="filename" />
|
---|
| 2708 | <xsl:param name="filenameimpl" />
|
---|
| 2709 |
|
---|
| 2710 | <xsl:call-template name="startFile">
|
---|
| 2711 | <xsl:with-param name="file" select="$filename" />
|
---|
| 2712 | <xsl:with-param name="package" select="$G_virtualBoxPackage" />
|
---|
| 2713 | </xsl:call-template>
|
---|
| 2714 |
|
---|
| 2715 | <xsl:text>import java.util.List; </xsl:text>
|
---|
| 2716 |
|
---|
[46478] | 2717 | <xsl:value-of select="concat('public interface ', $ifname, ' ')" />
|
---|
| 2718 | <xsl:text>{ </xsl:text>
|
---|
[30987] | 2719 |
|
---|
| 2720 | <!-- emit methods declarations-->
|
---|
| 2721 | <xsl:for-each select="method">
|
---|
| 2722 | <xsl:call-template name="genCbMethodDecl">
|
---|
| 2723 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
| 2724 | <xsl:with-param name="methodname" select="@name" />
|
---|
| 2725 | </xsl:call-template>
|
---|
| 2726 | </xsl:for-each>
|
---|
| 2727 |
|
---|
[46478] | 2728 | <xsl:text>} </xsl:text>
|
---|
[30987] | 2729 |
|
---|
| 2730 | <xsl:call-template name="endFile">
|
---|
| 2731 | <xsl:with-param name="file" select="$filename" />
|
---|
| 2732 | </xsl:call-template>
|
---|
| 2733 |
|
---|
| 2734 | <xsl:call-template name="startFile">
|
---|
| 2735 | <xsl:with-param name="file" select="$filenameimpl" />
|
---|
| 2736 | <xsl:with-param name="package" select="$G_virtualBoxPackage" />
|
---|
| 2737 | </xsl:call-template>
|
---|
| 2738 |
|
---|
| 2739 | <xsl:text>import java.util.List; </xsl:text>
|
---|
| 2740 |
|
---|
| 2741 | <xsl:variable name="backtype">
|
---|
| 2742 | <xsl:call-template name="typeIdl2Back">
|
---|
| 2743 | <xsl:with-param name="type" select="$ifname" />
|
---|
| 2744 | </xsl:call-template>
|
---|
| 2745 | </xsl:variable>
|
---|
| 2746 |
|
---|
| 2747 | <!-- emit glue methods body -->
|
---|
| 2748 | <xsl:choose>
|
---|
| 2749 | <xsl:when test="$G_vboxGlueStyle='xpcom'">
|
---|
[46478] | 2750 | <xsl:value-of select="concat('class ', $ifname, 'Impl extends nsISupportsBase implements ', $backtype, ' ')" />
|
---|
| 2751 | <xsl:text>{ </xsl:text>
|
---|
[30987] | 2752 | </xsl:when>
|
---|
| 2753 |
|
---|
| 2754 | <xsl:when test="$G_vboxGlueStyle='mscom'">
|
---|
[46478] | 2755 | <xsl:value-of select="concat('public class ', $ifname, 'Impl ')" />
|
---|
| 2756 | <xsl:text>{ </xsl:text>
|
---|
[30987] | 2757 | </xsl:when>
|
---|
| 2758 | </xsl:choose>
|
---|
| 2759 |
|
---|
| 2760 | <xsl:value-of select="concat(' ', $ifname, ' sink; ')" />
|
---|
| 2761 |
|
---|
[46478] | 2762 | <xsl:value-of select="concat(' ', $ifname, 'Impl(', $ifname, ' sink) ')" />
|
---|
| 2763 | <xsl:text> { </xsl:text>
|
---|
| 2764 | <xsl:text> this.sink = sink; </xsl:text>
|
---|
| 2765 | <xsl:text> } </xsl:text>
|
---|
[30987] | 2766 |
|
---|
| 2767 | <!-- emit methods implementations -->
|
---|
| 2768 | <xsl:for-each select="method">
|
---|
| 2769 | <xsl:call-template name="genCbMethodImpl">
|
---|
| 2770 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
| 2771 | <xsl:with-param name="methodname" select="@name" />
|
---|
| 2772 | </xsl:call-template>
|
---|
| 2773 | </xsl:for-each>
|
---|
| 2774 |
|
---|
[46478] | 2775 | <xsl:text>} </xsl:text>
|
---|
[30987] | 2776 |
|
---|
| 2777 | <xsl:call-template name="endFile">
|
---|
| 2778 | <xsl:with-param name="file" select="$filenameimpl" />
|
---|
| 2779 | </xsl:call-template>
|
---|
| 2780 | </xsl:template>
|
---|
| 2781 |
|
---|
| 2782 | <xsl:template name="emitHandwritten">
|
---|
| 2783 |
|
---|
[46478] | 2784 | <xsl:call-template name="startFile">
|
---|
[30987] | 2785 | <xsl:with-param name="file" select="'Holder.java'" />
|
---|
| 2786 | <xsl:with-param name="package" select="$G_virtualBoxPackage" />
|
---|
| 2787 | </xsl:call-template>
|
---|
| 2788 |
|
---|
[46478] | 2789 | <xsl:if test="$filelistonly=''">
|
---|
| 2790 | <xsl:text><![CDATA[
|
---|
[30987] | 2791 | public class Holder<T>
|
---|
| 2792 | {
|
---|
[46478] | 2793 | public T value;
|
---|
[30987] | 2794 |
|
---|
[46478] | 2795 | public Holder()
|
---|
| 2796 | {
|
---|
| 2797 | }
|
---|
| 2798 | public Holder(T value)
|
---|
| 2799 | {
|
---|
| 2800 | this.value = value;
|
---|
| 2801 | }
|
---|
[30987] | 2802 | }
|
---|
| 2803 | ]]></xsl:text>
|
---|
[46478] | 2804 | </xsl:if>
|
---|
[30987] | 2805 |
|
---|
[46478] | 2806 | <xsl:call-template name="endFile">
|
---|
| 2807 | <xsl:with-param name="file" select="'Holder.java'" />
|
---|
[30987] | 2808 | </xsl:call-template>
|
---|
| 2809 | </xsl:template>
|
---|
| 2810 |
|
---|
| 2811 | <xsl:template name="emitHandwrittenXpcom">
|
---|
| 2812 |
|
---|
[46478] | 2813 | <xsl:call-template name="startFile">
|
---|
[30987] | 2814 | <xsl:with-param name="file" select="'IUnknown.java'" />
|
---|
| 2815 | <xsl:with-param name="package" select="$G_virtualBoxPackageCom" />
|
---|
| 2816 | </xsl:call-template>
|
---|
| 2817 |
|
---|
[46478] | 2818 | <xsl:if test="$filelistonly=''">
|
---|
| 2819 | <xsl:text><![CDATA[
|
---|
[30987] | 2820 | public class IUnknown
|
---|
| 2821 | {
|
---|
[46478] | 2822 | private Object obj;
|
---|
| 2823 | public IUnknown(Object obj)
|
---|
| 2824 | {
|
---|
| 2825 | this.obj = obj;
|
---|
| 2826 | }
|
---|
[30987] | 2827 |
|
---|
[46478] | 2828 | public Object getWrapped()
|
---|
| 2829 | {
|
---|
| 2830 | return this.obj;
|
---|
| 2831 | }
|
---|
[30987] | 2832 |
|
---|
[46478] | 2833 | public void setWrapped(Object obj)
|
---|
| 2834 | {
|
---|
| 2835 | this.obj = obj;
|
---|
| 2836 | }
|
---|
[30987] | 2837 | }
|
---|
| 2838 | ]]></xsl:text>
|
---|
[46478] | 2839 | </xsl:if>
|
---|
[30987] | 2840 |
|
---|
[46478] | 2841 | <xsl:call-template name="endFile">
|
---|
| 2842 | <xsl:with-param name="file" select="'IUnknown.java'" />
|
---|
| 2843 | </xsl:call-template>
|
---|
[30987] | 2844 |
|
---|
[46478] | 2845 | <xsl:call-template name="startFile">
|
---|
| 2846 | <xsl:with-param name="file" select="'Helper.java'" />
|
---|
| 2847 | <xsl:with-param name="package" select="$G_virtualBoxPackageCom" />
|
---|
| 2848 | </xsl:call-template>
|
---|
[30987] | 2849 |
|
---|
[46478] | 2850 | <xsl:if test="$filelistonly=''">
|
---|
| 2851 | <xsl:text><![CDATA[
|
---|
[30987] | 2852 |
|
---|
| 2853 | import java.util.List;
|
---|
| 2854 | import java.util.ArrayList;
|
---|
| 2855 | import java.util.Collections;
|
---|
| 2856 | import java.lang.reflect.Array;
|
---|
| 2857 | import java.lang.reflect.Constructor;
|
---|
[48005] | 2858 | import java.lang.reflect.Method;
|
---|
[30987] | 2859 | import java.lang.reflect.InvocationTargetException;
|
---|
| 2860 |
|
---|
[46478] | 2861 | public class Helper
|
---|
| 2862 | {
|
---|
| 2863 | public static List<Short> wrap(byte[] values)
|
---|
| 2864 | {
|
---|
| 2865 | if (values == null)
|
---|
[31694] | 2866 | return null;
|
---|
[30987] | 2867 |
|
---|
[46478] | 2868 | List<Short> ret = new ArrayList<Short>(values.length);
|
---|
| 2869 | for (short v : values)
|
---|
| 2870 | {
|
---|
| 2871 | ret.add(v);
|
---|
[30987] | 2872 | }
|
---|
| 2873 | return ret;
|
---|
| 2874 | }
|
---|
| 2875 |
|
---|
[47850] | 2876 | public static List<Short> wrap(short[] values)
|
---|
| 2877 | {
|
---|
| 2878 | if (values == null)
|
---|
| 2879 | return null;
|
---|
| 2880 |
|
---|
| 2881 | List<Short> ret = new ArrayList<Short>(values.length);
|
---|
| 2882 | for (short v : values)
|
---|
| 2883 | {
|
---|
| 2884 | ret.add(v);
|
---|
| 2885 | }
|
---|
| 2886 | return ret;
|
---|
| 2887 | }
|
---|
| 2888 |
|
---|
[46478] | 2889 | public static List<Integer> wrap(int[] values)
|
---|
| 2890 | {
|
---|
| 2891 | if (values == null)
|
---|
| 2892 | return null;
|
---|
[30987] | 2893 |
|
---|
[46478] | 2894 | List<Integer> ret = new ArrayList<Integer>(values.length);
|
---|
| 2895 | for (int v : values)
|
---|
| 2896 | {
|
---|
| 2897 | ret.add(v);
|
---|
[30987] | 2898 | }
|
---|
| 2899 | return ret;
|
---|
| 2900 | }
|
---|
| 2901 |
|
---|
[46478] | 2902 | public static List<Long> wrap(long[] values)
|
---|
| 2903 | {
|
---|
| 2904 | if (values == null)
|
---|
| 2905 | return null;
|
---|
[30987] | 2906 |
|
---|
[46478] | 2907 | List<Long> ret = new ArrayList<Long>(values.length);
|
---|
| 2908 | for (long v : values)
|
---|
| 2909 | {
|
---|
[46123] | 2910 | ret.add(v);
|
---|
[30987] | 2911 | }
|
---|
| 2912 | return ret;
|
---|
| 2913 | }
|
---|
| 2914 |
|
---|
[46478] | 2915 | public static List<Boolean> wrap(boolean[] values)
|
---|
| 2916 | {
|
---|
| 2917 | if (values == null)
|
---|
[46123] | 2918 | return null;
|
---|
| 2919 |
|
---|
[46478] | 2920 | List<Boolean> ret = new ArrayList<Boolean>(values.length);
|
---|
| 2921 | for (boolean v: values)
|
---|
| 2922 | {
|
---|
| 2923 | ret.add(v);
|
---|
[46123] | 2924 | }
|
---|
| 2925 | return ret;
|
---|
| 2926 | }
|
---|
| 2927 |
|
---|
[46478] | 2928 | public static List<String> wrap(String[] values)
|
---|
| 2929 | {
|
---|
| 2930 | if (values == null)
|
---|
[31694] | 2931 | return null;
|
---|
[46478] | 2932 |
|
---|
| 2933 | List<String> ret = new ArrayList<String>(values.length);
|
---|
| 2934 | for (String v : values)
|
---|
| 2935 | {
|
---|
[31694] | 2936 | ret.add(v);
|
---|
[30987] | 2937 | }
|
---|
| 2938 | return ret;
|
---|
| 2939 | }
|
---|
| 2940 |
|
---|
[46478] | 2941 | public static <T> List<T> wrap(Class<T> wrapperClass, T[] values)
|
---|
| 2942 | {
|
---|
| 2943 | if (values == null)
|
---|
| 2944 | return null;
|
---|
[30987] | 2945 |
|
---|
[46478] | 2946 | List<T> ret = new ArrayList<T>(values.length);
|
---|
| 2947 | for (T v : values)
|
---|
| 2948 | {
|
---|
| 2949 | ret.add(v);
|
---|
[30987] | 2950 | }
|
---|
| 2951 | return ret;
|
---|
| 2952 | }
|
---|
| 2953 |
|
---|
[48005] | 2954 | @SuppressWarnings( "unchecked")
|
---|
[46478] | 2955 | public static <T> List<T> wrapEnum(Class<T> wrapperClass, long values[])
|
---|
| 2956 | {
|
---|
| 2957 | try
|
---|
| 2958 | {
|
---|
| 2959 | if (values == null)
|
---|
| 2960 | return null;
|
---|
[48005] | 2961 | //// This code is questionable, as it invokes a private constructor
|
---|
| 2962 | //// (all enums only have default constructors), and we don't really
|
---|
| 2963 | //// know what to pass as the name, and the ordinal may or may not
|
---|
| 2964 | //// be sensible, especially if the long was abused as a bitset.
|
---|
| 2965 | //Constructor<T> c = wrapperClass.getDeclaredConstructor(String.class, int.class, int.class);
|
---|
| 2966 | //c.setAccessible(true); // make it callable
|
---|
| 2967 | //List<T> ret = new ArrayList<T>(values.length);
|
---|
| 2968 | //for (long v : values)
|
---|
| 2969 | //{
|
---|
| 2970 | // T convEnum = c.newInstance("unknown", (int)v, (int)v);
|
---|
| 2971 | // ret.add(convEnum);
|
---|
| 2972 | //}
|
---|
| 2973 |
|
---|
| 2974 | // Alternative implementation: use the fromValue method, which is
|
---|
| 2975 | // what the code handling single enums will do. I see no reason to
|
---|
| 2976 | // use the above very ugly hack if there are better alternatives,
|
---|
| 2977 | // which as a bonus complain about unknown values. This variant is
|
---|
| 2978 | // slower, but also orders of magnitude safer.
|
---|
| 2979 | java.lang.reflect.Method fromValue = wrapperClass.getMethod("fromValue", long.class);
|
---|
[30987] | 2980 | List<T> ret = new ArrayList<T>(values.length);
|
---|
[46478] | 2981 | for (long v : values)
|
---|
| 2982 | {
|
---|
[48005] | 2983 | T convEnum = (T)fromValue.invoke(null, v);
|
---|
| 2984 | ret.add(convEnum);
|
---|
[30987] | 2985 | }
|
---|
| 2986 | return ret;
|
---|
[46478] | 2987 | }
|
---|
| 2988 | catch (NoSuchMethodException e)
|
---|
| 2989 | {
|
---|
[30987] | 2990 | throw new AssertionError(e);
|
---|
[46478] | 2991 | }
|
---|
[48005] | 2992 | //catch (InstantiationException e)
|
---|
| 2993 | //{
|
---|
| 2994 | // throw new AssertionError(e);
|
---|
| 2995 | //}
|
---|
[46478] | 2996 | catch (IllegalAccessException e)
|
---|
| 2997 | {
|
---|
[30987] | 2998 | throw new AssertionError(e);
|
---|
[46478] | 2999 | }
|
---|
| 3000 | catch (InvocationTargetException e)
|
---|
| 3001 | {
|
---|
[30987] | 3002 | throw new AssertionError(e);
|
---|
| 3003 | }
|
---|
| 3004 | }
|
---|
[46478] | 3005 | public static short[] unwrapUShort(List<Short> values)
|
---|
| 3006 | {
|
---|
| 3007 | if (values == null)
|
---|
| 3008 | return null;
|
---|
[30987] | 3009 |
|
---|
[46478] | 3010 | short[] ret = new short[values.size()];
|
---|
[30987] | 3011 | int i = 0;
|
---|
[46478] | 3012 | for (short l : values)
|
---|
| 3013 | {
|
---|
| 3014 | ret[i++] = l;
|
---|
[30987] | 3015 | }
|
---|
| 3016 | return ret;
|
---|
| 3017 | }
|
---|
| 3018 |
|
---|
[46478] | 3019 | public static int[] unwrapInteger(List<Integer> values)
|
---|
| 3020 | {
|
---|
| 3021 | if (values == null)
|
---|
| 3022 | return null;
|
---|
[30987] | 3023 |
|
---|
[46478] | 3024 | int[] ret = new int[values.size()];
|
---|
[30987] | 3025 | int i = 0;
|
---|
[46478] | 3026 | for (int l : values)
|
---|
| 3027 | {
|
---|
| 3028 | ret[i++] = l;
|
---|
[30987] | 3029 | }
|
---|
| 3030 | return ret;
|
---|
| 3031 | }
|
---|
| 3032 |
|
---|
[46478] | 3033 | public static long[] unwrapULong(List<Long> values)
|
---|
| 3034 | {
|
---|
| 3035 | if (values == null)
|
---|
| 3036 | return null;
|
---|
[30987] | 3037 |
|
---|
[46478] | 3038 | long[] ret = new long[values.size()];
|
---|
[30987] | 3039 | int i = 0;
|
---|
[46478] | 3040 | for (long l : values)
|
---|
| 3041 | {
|
---|
| 3042 | ret[i++] = l;
|
---|
[30987] | 3043 | }
|
---|
| 3044 | return ret;
|
---|
| 3045 | }
|
---|
| 3046 |
|
---|
[46478] | 3047 | public static boolean[] unwrapBoolean(List<Boolean> values)
|
---|
| 3048 | {
|
---|
| 3049 | if (values == null)
|
---|
| 3050 | return null;
|
---|
[30987] | 3051 |
|
---|
[46478] | 3052 | boolean[] ret = new boolean[values.size()];
|
---|
[30987] | 3053 | int i = 0;
|
---|
[46478] | 3054 | for (boolean l : values)
|
---|
| 3055 | {
|
---|
| 3056 | ret[i++] = l;
|
---|
[30987] | 3057 | }
|
---|
| 3058 | return ret;
|
---|
| 3059 | }
|
---|
| 3060 |
|
---|
[46478] | 3061 | public static String[] unwrapStr(List<String> values)
|
---|
| 3062 | {
|
---|
| 3063 | if (values == null)
|
---|
[31694] | 3064 | return null;
|
---|
[30987] | 3065 |
|
---|
[46478] | 3066 | String[] ret = new String[values.size()];
|
---|
[30987] | 3067 | int i = 0;
|
---|
[46478] | 3068 | for (String l : values)
|
---|
| 3069 | {
|
---|
| 3070 | ret[i++] = l;
|
---|
[30987] | 3071 | }
|
---|
| 3072 | return ret;
|
---|
| 3073 | }
|
---|
| 3074 |
|
---|
[46478] | 3075 | public static <T extends Enum <T>> long[] unwrapEnum(Class<T> enumClass, List<T> values)
|
---|
| 3076 | {
|
---|
| 3077 | if (values == null)
|
---|
| 3078 | return null;
|
---|
[30987] | 3079 |
|
---|
| 3080 | long result[] = new long[values.size()];
|
---|
[46478] | 3081 | try
|
---|
| 3082 | {
|
---|
| 3083 | java.lang.reflect.Method valueM = enumClass.getMethod("value");
|
---|
| 3084 | int i = 0;
|
---|
| 3085 | for (T v : values)
|
---|
| 3086 | {
|
---|
| 3087 | result[i++] = (Integer)valueM.invoke(v);
|
---|
| 3088 | }
|
---|
| 3089 | return result;
|
---|
[30987] | 3090 | }
|
---|
[46478] | 3091 | catch (NoSuchMethodException e)
|
---|
| 3092 | {
|
---|
| 3093 | throw new AssertionError(e);
|
---|
| 3094 | }
|
---|
| 3095 | catch(SecurityException e)
|
---|
| 3096 | {
|
---|
| 3097 | throw new AssertionError(e);
|
---|
| 3098 | }
|
---|
| 3099 | catch (IllegalAccessException e)
|
---|
| 3100 | {
|
---|
| 3101 | throw new AssertionError(e);
|
---|
| 3102 | }
|
---|
| 3103 | catch (IllegalArgumentException e)
|
---|
| 3104 | {
|
---|
| 3105 | throw new AssertionError(e);
|
---|
| 3106 | }
|
---|
| 3107 | catch (InvocationTargetException e)
|
---|
| 3108 | {
|
---|
| 3109 | throw new AssertionError(e);
|
---|
| 3110 | }
|
---|
[30987] | 3111 | }
|
---|
| 3112 |
|
---|
[46478] | 3113 | public static <T1, T2> List<T1> wrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, T2[] values)
|
---|
| 3114 | {
|
---|
| 3115 | try
|
---|
| 3116 | {
|
---|
| 3117 | if (values == null)
|
---|
[31694] | 3118 | return null;
|
---|
[30987] | 3119 |
|
---|
| 3120 | Constructor<T1> c = wrapperClass1.getConstructor(wrapperClass2);
|
---|
[46478] | 3121 | List<T1> ret = new ArrayList<T1>(values.length);
|
---|
| 3122 | for (T2 v : values)
|
---|
| 3123 | {
|
---|
| 3124 | ret.add(c.newInstance(v));
|
---|
[30987] | 3125 | }
|
---|
| 3126 | return ret;
|
---|
[46478] | 3127 | }
|
---|
| 3128 | catch (NoSuchMethodException e)
|
---|
| 3129 | {
|
---|
[30987] | 3130 | throw new AssertionError(e);
|
---|
[46478] | 3131 | }
|
---|
| 3132 | catch (InstantiationException e)
|
---|
| 3133 | {
|
---|
[30987] | 3134 | throw new AssertionError(e);
|
---|
[46478] | 3135 | }
|
---|
| 3136 | catch (IllegalAccessException e)
|
---|
| 3137 | {
|
---|
[30987] | 3138 | throw new AssertionError(e);
|
---|
[46478] | 3139 | }
|
---|
| 3140 | catch (InvocationTargetException e)
|
---|
| 3141 | {
|
---|
[30987] | 3142 | throw new AssertionError(e);
|
---|
| 3143 | }
|
---|
| 3144 | }
|
---|
| 3145 |
|
---|
[31095] | 3146 | @SuppressWarnings( "unchecked")
|
---|
[46478] | 3147 | public static <T> T[] unwrap(Class<T> wrapperClass, List<T> values)
|
---|
[46123] | 3148 | {
|
---|
[46478] | 3149 | if (values == null)
|
---|
[30987] | 3150 | return null;
|
---|
[46478] | 3151 | if (values.size() == 0)
|
---|
[30987] | 3152 | return null;
|
---|
[46478] | 3153 | return (T[])values.toArray((T[])Array.newInstance(wrapperClass, values.size()));
|
---|
[30987] | 3154 | }
|
---|
| 3155 |
|
---|
[31095] | 3156 | @SuppressWarnings( "unchecked" )
|
---|
[30987] | 3157 | public static <T> T queryInterface(Object obj, String uuid, Class<T> iface)
|
---|
| 3158 | {
|
---|
| 3159 | return (T)queryInterface(obj, uuid);
|
---|
| 3160 | }
|
---|
| 3161 |
|
---|
| 3162 | public static Object queryInterface(Object obj, String uuid)
|
---|
| 3163 | {
|
---|
[46478] | 3164 | try
|
---|
| 3165 | {
|
---|
| 3166 | /* Kind of ugly, but does the job of casting */
|
---|
| 3167 | org.mozilla.xpcom.Mozilla moz = org.mozilla.xpcom.Mozilla.getInstance();
|
---|
| 3168 | long xpobj = moz.wrapJavaObject(obj, uuid);
|
---|
| 3169 | return moz.wrapXPCOMObject(xpobj, uuid);
|
---|
| 3170 | }
|
---|
| 3171 | catch (Exception e)
|
---|
| 3172 | {
|
---|
[46123] | 3173 | return null;
|
---|
| 3174 | }
|
---|
[30987] | 3175 | }
|
---|
| 3176 |
|
---|
[31095] | 3177 | @SuppressWarnings("unchecked")
|
---|
[46478] | 3178 | public static <T1 extends IUnknown, T2> T2[] unwrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, List<T1> values)
|
---|
[46123] | 3179 | {
|
---|
[46478] | 3180 | if (values == null)
|
---|
| 3181 | return null;
|
---|
[30987] | 3182 |
|
---|
[46478] | 3183 | T2 ret[] = (T2[])Array.newInstance(wrapperClass2, values.size());
|
---|
[30987] | 3184 | int i = 0;
|
---|
[46478] | 3185 | for (T1 obj : values)
|
---|
| 3186 | {
|
---|
| 3187 | ret[i++] = (T2)obj.getWrapped();
|
---|
[30987] | 3188 | }
|
---|
| 3189 | return ret;
|
---|
| 3190 | }
|
---|
| 3191 | }
|
---|
| 3192 | ]]></xsl:text>
|
---|
[46478] | 3193 | </xsl:if>
|
---|
[30987] | 3194 |
|
---|
[46478] | 3195 | <xsl:call-template name="endFile">
|
---|
| 3196 | <xsl:with-param name="file" select="'Helper.java'" />
|
---|
| 3197 | </xsl:call-template>
|
---|
[30987] | 3198 |
|
---|
[46478] | 3199 | <xsl:call-template name="startFile">
|
---|
| 3200 | <xsl:with-param name="file" select="'VBoxException.java'" />
|
---|
| 3201 | <xsl:with-param name="package" select="$G_virtualBoxPackage" />
|
---|
| 3202 | </xsl:call-template>
|
---|
| 3203 |
|
---|
| 3204 | <xsl:if test="$filelistonly=''">
|
---|
| 3205 | <xsl:text>
|
---|
| 3206 | import org.mozilla.xpcom.*;
|
---|
| 3207 |
|
---|
| 3208 | public class VBoxException extends RuntimeException
|
---|
| 3209 | {
|
---|
| 3210 | private int resultCode;
|
---|
| 3211 | private IVirtualBoxErrorInfo errorInfo;
|
---|
| 3212 |
|
---|
| 3213 | public VBoxException(String message)
|
---|
| 3214 | {
|
---|
| 3215 | super(message);
|
---|
| 3216 | resultCode = -1;
|
---|
| 3217 | errorInfo = null;
|
---|
| 3218 | }
|
---|
| 3219 |
|
---|
| 3220 | public VBoxException(String message, Throwable cause)
|
---|
| 3221 | {
|
---|
| 3222 | super(message, cause);
|
---|
| 3223 | if (cause instanceof org.mozilla.xpcom.XPCOMException)
|
---|
| 3224 | {
|
---|
| 3225 | resultCode = (int)((org.mozilla.xpcom.XPCOMException)cause).errorcode;
|
---|
| 3226 | try
|
---|
| 3227 | {
|
---|
| 3228 | Mozilla mozilla = Mozilla.getInstance();
|
---|
| 3229 | nsIServiceManager sm = mozilla.getServiceManager();
|
---|
| 3230 | nsIExceptionService es = (nsIExceptionService)sm.getServiceByContractID("@mozilla.org/exceptionservice;1", nsIExceptionService.NS_IEXCEPTIONSERVICE_IID);
|
---|
| 3231 | nsIExceptionManager em = es.getCurrentExceptionManager();
|
---|
| 3232 | nsIException ex = em.getCurrentException();
|
---|
| 3233 | errorInfo = new IVirtualBoxErrorInfo((org.mozilla.interfaces.IVirtualBoxErrorInfo)ex.queryInterface(org.mozilla.interfaces.IVirtualBoxErrorInfo.IVIRTUALBOXERRORINFO_IID));
|
---|
| 3234 | }
|
---|
| 3235 | catch (NullPointerException e)
|
---|
| 3236 | {
|
---|
| 3237 | e.printStackTrace();
|
---|
| 3238 | // nothing we can do
|
---|
| 3239 | errorInfo = null;
|
---|
| 3240 | }
|
---|
| 3241 | }
|
---|
| 3242 | else
|
---|
| 3243 | resultCode = -1;
|
---|
| 3244 | }
|
---|
| 3245 |
|
---|
| 3246 | public int getResultCode()
|
---|
| 3247 | {
|
---|
| 3248 | return resultCode;
|
---|
| 3249 | }
|
---|
| 3250 |
|
---|
| 3251 | public IVirtualBoxErrorInfo getVirtualBoxErrorInfo()
|
---|
| 3252 | {
|
---|
| 3253 | return errorInfo;
|
---|
| 3254 | }
|
---|
| 3255 | }
|
---|
| 3256 | </xsl:text>
|
---|
| 3257 | </xsl:if>
|
---|
| 3258 |
|
---|
| 3259 | <xsl:call-template name="endFile">
|
---|
| 3260 | <xsl:with-param name="file" select="'VBoxException.java'" />
|
---|
| 3261 | </xsl:call-template>
|
---|
| 3262 |
|
---|
| 3263 | <xsl:call-template name="startFile">
|
---|
[30987] | 3264 | <xsl:with-param name="file" select="'VirtualBoxManager.java'" />
|
---|
| 3265 | <xsl:with-param name="package" select="$G_virtualBoxPackage" />
|
---|
| 3266 | </xsl:call-template>
|
---|
| 3267 |
|
---|
[46478] | 3268 | <xsl:if test="$filelistonly=''">
|
---|
| 3269 | <xsl:text><![CDATA[
|
---|
[30987] | 3270 |
|
---|
| 3271 | import java.io.File;
|
---|
| 3272 |
|
---|
| 3273 | import org.mozilla.xpcom.*;
|
---|
| 3274 | import org.mozilla.interfaces.*;
|
---|
| 3275 |
|
---|
| 3276 | public class VirtualBoxManager
|
---|
| 3277 | {
|
---|
[46478] | 3278 | private Mozilla mozilla;
|
---|
| 3279 | private IVirtualBox vbox;
|
---|
[30987] | 3280 | private nsIComponentManager componentManager;
|
---|
| 3281 |
|
---|
[36814] | 3282 | private VirtualBoxManager(Mozilla mozilla)
|
---|
[30987] | 3283 | {
|
---|
| 3284 | this.mozilla = mozilla;
|
---|
| 3285 | this.componentManager = mozilla.getComponentManager();
|
---|
| 3286 | this.vbox = new IVirtualBox((org.mozilla.interfaces.IVirtualBox) this.componentManager
|
---|
| 3287 | .createInstanceByContractID("@virtualbox.org/VirtualBox;1",
|
---|
| 3288 | null,
|
---|
[37456] | 3289 | org.mozilla.interfaces.IVirtualBox.IVIRTUALBOX_IID));
|
---|
[30987] | 3290 | }
|
---|
| 3291 |
|
---|
| 3292 | public void connect(String url, String username, String passwd)
|
---|
| 3293 | {
|
---|
[46478] | 3294 | throw new VBoxException("Connect doesn't make sense for local bindings");
|
---|
[30987] | 3295 | }
|
---|
| 3296 |
|
---|
| 3297 | public void disconnect()
|
---|
| 3298 | {
|
---|
[46478] | 3299 | throw new VBoxException("Disconnect doesn't make sense for local bindings");
|
---|
[30987] | 3300 | }
|
---|
| 3301 |
|
---|
| 3302 | public static void initPerThread()
|
---|
| 3303 | {
|
---|
| 3304 | }
|
---|
| 3305 |
|
---|
| 3306 | public static void deinitPerThread()
|
---|
| 3307 | {
|
---|
| 3308 | }
|
---|
| 3309 |
|
---|
[56306] | 3310 | public String getClientAPIVersion()
|
---|
| 3311 | {
|
---|
| 3312 | return "]]></xsl:text>
|
---|
| 3313 | <xsl:value-of select="substring($G_vboxApiSuffix, 2)" />
|
---|
| 3314 | <xsl:text><![CDATA[";
|
---|
| 3315 | }
|
---|
| 3316 |
|
---|
[30987] | 3317 | public IVirtualBox getVBox()
|
---|
| 3318 | {
|
---|
| 3319 | return this.vbox;
|
---|
| 3320 | }
|
---|
| 3321 |
|
---|
| 3322 | public ISession getSessionObject()
|
---|
| 3323 | {
|
---|
| 3324 | return new ISession((org.mozilla.interfaces.ISession) componentManager
|
---|
| 3325 | .createInstanceByContractID("@virtualbox.org/Session;1", null,
|
---|
| 3326 | org.mozilla.interfaces.ISession.ISESSION_IID));
|
---|
| 3327 | }
|
---|
| 3328 |
|
---|
[31008] | 3329 | public ISession openMachineSession(IMachine m) throws Exception
|
---|
[30987] | 3330 | {
|
---|
| 3331 | ISession s = getSessionObject();
|
---|
[31019] | 3332 | m.lockMachine(s, LockType.Shared);
|
---|
[31008] | 3333 | return s;
|
---|
[30987] | 3334 | }
|
---|
| 3335 |
|
---|
| 3336 | public void closeMachineSession(ISession s)
|
---|
| 3337 | {
|
---|
| 3338 | if (s != null)
|
---|
[31070] | 3339 | s.unlockMachine();
|
---|
[30987] | 3340 | }
|
---|
| 3341 |
|
---|
[31166] | 3342 | private static boolean hasInstance = false;
|
---|
[36814] | 3343 | private static boolean isMozillaInited = false;
|
---|
[30987] | 3344 |
|
---|
[31166] | 3345 | public static synchronized VirtualBoxManager createInstance(String home)
|
---|
[30987] | 3346 | {
|
---|
[31166] | 3347 | if (hasInstance)
|
---|
[46478] | 3348 | throw new VBoxException("only one instance of VirtualBoxManager at a time allowed");
|
---|
| 3349 | if (home == null || home.equals(""))
|
---|
[36814] | 3350 | home = System.getProperty("vbox.home");
|
---|
[30987] | 3351 |
|
---|
| 3352 | if (home == null)
|
---|
[46478] | 3353 | throw new VBoxException("vbox.home Java property must be defined to use XPCOM bridge");
|
---|
[30987] | 3354 |
|
---|
| 3355 | File grePath = new File(home);
|
---|
[36814] | 3356 |
|
---|
[30987] | 3357 | Mozilla mozilla = Mozilla.getInstance();
|
---|
[36814] | 3358 | if (!isMozillaInited)
|
---|
| 3359 | {
|
---|
[46478] | 3360 | mozilla.initialize(grePath);
|
---|
| 3361 | try
|
---|
| 3362 | {
|
---|
| 3363 | mozilla.initXPCOM(grePath, null);
|
---|
| 3364 | isMozillaInited = true;
|
---|
| 3365 | }
|
---|
| 3366 | catch (Exception e)
|
---|
| 3367 | {
|
---|
| 3368 | e.printStackTrace();
|
---|
| 3369 | return null;
|
---|
| 3370 | }
|
---|
[30987] | 3371 | }
|
---|
| 3372 |
|
---|
[31166] | 3373 | hasInstance = true;
|
---|
| 3374 |
|
---|
[36814] | 3375 | return new VirtualBoxManager(mozilla);
|
---|
[30987] | 3376 | }
|
---|
| 3377 |
|
---|
| 3378 | public IEventListener createListener(Object sink)
|
---|
| 3379 | {
|
---|
[46478] | 3380 | return new IEventListener(new EventListenerImpl(sink));
|
---|
[30987] | 3381 | }
|
---|
[46478] | 3382 |
|
---|
[30987] | 3383 | public void cleanup()
|
---|
| 3384 | {
|
---|
| 3385 | deinitPerThread();
|
---|
[36814] | 3386 | // cleanup, we don't do that, as XPCOM bridge doesn't cleanly
|
---|
| 3387 | // shuts down, so we prefer to avoid native shutdown
|
---|
| 3388 | // mozilla.shutdownXPCOM(null);
|
---|
[30987] | 3389 | mozilla = null;
|
---|
[31166] | 3390 | hasInstance = false;
|
---|
[30987] | 3391 | }
|
---|
| 3392 |
|
---|
| 3393 | public void waitForEvents(long tmo)
|
---|
| 3394 | {
|
---|
| 3395 | mozilla.waitForEvents(tmo);
|
---|
| 3396 | }
|
---|
| 3397 | }
|
---|
| 3398 | ]]></xsl:text>
|
---|
[46478] | 3399 | </xsl:if>
|
---|
[30987] | 3400 |
|
---|
[46478] | 3401 | <xsl:call-template name="endFile">
|
---|
| 3402 | <xsl:with-param name="file" select="'VirtualBoxManager.java'" />
|
---|
| 3403 | </xsl:call-template>
|
---|
[30987] | 3404 |
|
---|
[46478] | 3405 | <xsl:call-template name="startFile">
|
---|
| 3406 | <xsl:with-param name="file" select="'EventListenerImpl.java'" />
|
---|
| 3407 | <xsl:with-param name="package" select="$G_virtualBoxPackage" />
|
---|
| 3408 | </xsl:call-template>
|
---|
[30987] | 3409 |
|
---|
[46478] | 3410 | <xsl:if test="$filelistonly=''">
|
---|
| 3411 | <xsl:text><![CDATA[
|
---|
| 3412 | import org.mozilla.interfaces.*;
|
---|
[30987] | 3413 |
|
---|
[46478] | 3414 | public class EventListenerImpl extends nsISupportsBase implements org.mozilla.interfaces.IEventListener
|
---|
| 3415 | {
|
---|
[30987] | 3416 | private Object obj;
|
---|
| 3417 | private java.lang.reflect.Method handleEvent;
|
---|
| 3418 | EventListenerImpl(Object obj)
|
---|
| 3419 | {
|
---|
[46478] | 3420 | this.obj = obj;
|
---|
| 3421 | try
|
---|
| 3422 | {
|
---|
| 3423 | this.handleEvent = obj.getClass().getMethod("handleEvent", IEvent.class);
|
---|
[30987] | 3424 | }
|
---|
[46478] | 3425 | catch (Exception e)
|
---|
| 3426 | {
|
---|
| 3427 | e.printStackTrace();
|
---|
| 3428 | }
|
---|
| 3429 | }
|
---|
| 3430 | public void handleEvent(org.mozilla.interfaces.IEvent ev)
|
---|
| 3431 | {
|
---|
| 3432 | try
|
---|
| 3433 | {
|
---|
| 3434 | if (obj != null && handleEvent != null)
|
---|
| 3435 | handleEvent.invoke(obj, ev != null ? new IEvent(ev) : null);
|
---|
| 3436 | }
|
---|
| 3437 | catch (Exception e)
|
---|
| 3438 | {
|
---|
| 3439 | e.printStackTrace();
|
---|
| 3440 | }
|
---|
| 3441 | }
|
---|
| 3442 | }]]></xsl:text>
|
---|
| 3443 | </xsl:if>
|
---|
[30987] | 3444 |
|
---|
[46478] | 3445 | <xsl:call-template name="endFile">
|
---|
| 3446 | <xsl:with-param name="file" select="'EventListenerImpl.java'" />
|
---|
| 3447 | </xsl:call-template>
|
---|
[30987] | 3448 |
|
---|
[46478] | 3449 | <xsl:call-template name="startFile">
|
---|
| 3450 | <xsl:with-param name="file" select="'VBoxObjectBase.java'" />
|
---|
| 3451 | <xsl:with-param name="package" select="$G_virtualBoxPackage" />
|
---|
| 3452 | </xsl:call-template>
|
---|
[30987] | 3453 |
|
---|
[46478] | 3454 | <xsl:if test="$filelistonly=''">
|
---|
| 3455 | <xsl:text><![CDATA[
|
---|
[30987] | 3456 | abstract class nsISupportsBase implements org.mozilla.interfaces.nsISupports
|
---|
| 3457 | {
|
---|
[46478] | 3458 | public org.mozilla.interfaces.nsISupports queryInterface(String iid)
|
---|
[30987] | 3459 | {
|
---|
| 3460 | return org.mozilla.xpcom.Mozilla.queryInterface(this, iid);
|
---|
| 3461 | }
|
---|
| 3462 | }
|
---|
| 3463 |
|
---|
[46478] | 3464 | ]]></xsl:text>
|
---|
| 3465 | </xsl:if>
|
---|
[30987] | 3466 |
|
---|
[46478] | 3467 | <xsl:call-template name="endFile">
|
---|
| 3468 | <xsl:with-param name="file" select="'VBoxObjectBase.java'" />
|
---|
| 3469 | </xsl:call-template>
|
---|
[30987] | 3470 | </xsl:template>
|
---|
| 3471 |
|
---|
| 3472 |
|
---|
| 3473 | <xsl:template name="emitHandwrittenMscom">
|
---|
| 3474 |
|
---|
[46478] | 3475 | <xsl:call-template name="startFile">
|
---|
[30987] | 3476 | <xsl:with-param name="file" select="'IUnknown.java'" />
|
---|
| 3477 | <xsl:with-param name="package" select="$G_virtualBoxPackageCom" />
|
---|
| 3478 | </xsl:call-template>
|
---|
| 3479 |
|
---|
[46478] | 3480 | <xsl:if test="$filelistonly=''">
|
---|
| 3481 | <xsl:text><![CDATA[
|
---|
[30987] | 3482 | public class IUnknown
|
---|
| 3483 | {
|
---|
[46478] | 3484 | private Object obj;
|
---|
| 3485 | public IUnknown(Object obj)
|
---|
| 3486 | {
|
---|
| 3487 | this.obj = obj;
|
---|
| 3488 | }
|
---|
[30987] | 3489 |
|
---|
[46478] | 3490 | public Object getWrapped()
|
---|
| 3491 | {
|
---|
| 3492 | return this.obj;
|
---|
| 3493 | }
|
---|
[30987] | 3494 |
|
---|
[46478] | 3495 | public void setWrapped(Object obj)
|
---|
| 3496 | {
|
---|
| 3497 | this.obj = obj;
|
---|
| 3498 | }
|
---|
[30987] | 3499 | }
|
---|
| 3500 | ]]></xsl:text>
|
---|
[46478] | 3501 | </xsl:if>
|
---|
[30987] | 3502 |
|
---|
[46478] | 3503 | <xsl:call-template name="endFile">
|
---|
| 3504 | <xsl:with-param name="file" select="'IUnknown.java'" />
|
---|
| 3505 | </xsl:call-template>
|
---|
[30987] | 3506 |
|
---|
[46478] | 3507 | <xsl:call-template name="startFile">
|
---|
| 3508 | <xsl:with-param name="file" select="'Helper.java'" />
|
---|
| 3509 | <xsl:with-param name="package" select="$G_virtualBoxPackageCom" />
|
---|
| 3510 | </xsl:call-template>
|
---|
[30987] | 3511 |
|
---|
[46478] | 3512 | <xsl:if test="$filelistonly=''">
|
---|
| 3513 | <xsl:text><![CDATA[
|
---|
[30987] | 3514 |
|
---|
| 3515 | import java.util.List;
|
---|
| 3516 | import java.util.ArrayList;
|
---|
| 3517 | import java.util.Collections;
|
---|
| 3518 | import java.lang.reflect.Array;
|
---|
| 3519 | import java.lang.reflect.Constructor;
|
---|
| 3520 | import java.lang.reflect.InvocationTargetException;
|
---|
| 3521 | import com.jacob.com.*;
|
---|
| 3522 |
|
---|
[46478] | 3523 | public class Helper
|
---|
| 3524 | {
|
---|
| 3525 | public static List<Short> wrap(short[] values)
|
---|
| 3526 | {
|
---|
| 3527 | if (values == null)
|
---|
| 3528 | return null;
|
---|
[30987] | 3529 |
|
---|
[46478] | 3530 | List<Short> ret = new ArrayList<Short>(values.length);
|
---|
| 3531 | for (short v : values)
|
---|
| 3532 | {
|
---|
| 3533 | ret.add(v);
|
---|
[30987] | 3534 | }
|
---|
| 3535 | return ret;
|
---|
| 3536 | }
|
---|
| 3537 |
|
---|
[46478] | 3538 | public static List<Integer> wrap(int[] values)
|
---|
| 3539 | {
|
---|
| 3540 | if (values == null)
|
---|
| 3541 | return null;
|
---|
[30987] | 3542 |
|
---|
[46478] | 3543 | List<Integer> ret = new ArrayList<Integer>(values.length);
|
---|
| 3544 | for (int v : values)
|
---|
| 3545 | {
|
---|
| 3546 | ret.add(v);
|
---|
[30987] | 3547 | }
|
---|
| 3548 | return ret;
|
---|
| 3549 | }
|
---|
| 3550 |
|
---|
[46478] | 3551 | public static List<Long> wrap(long[] values)
|
---|
| 3552 | {
|
---|
| 3553 | if (values == null)
|
---|
| 3554 | return null;
|
---|
[30987] | 3555 |
|
---|
[46478] | 3556 | List<Long> ret = new ArrayList<Long>(values.length);
|
---|
| 3557 | for (long v : values)
|
---|
| 3558 | {
|
---|
| 3559 | ret.add(v);
|
---|
[30987] | 3560 | }
|
---|
| 3561 | return ret;
|
---|
| 3562 | }
|
---|
| 3563 |
|
---|
[46478] | 3564 | public static List<String> wrap(String[] values)
|
---|
| 3565 | {
|
---|
| 3566 | if (values == null)
|
---|
| 3567 | return null;
|
---|
[30987] | 3568 |
|
---|
[46478] | 3569 | List<String> ret = new ArrayList<String>(values.length);
|
---|
| 3570 | for (String v : values)
|
---|
| 3571 | {
|
---|
| 3572 | ret.add(v);
|
---|
[30987] | 3573 | }
|
---|
| 3574 | return ret;
|
---|
| 3575 | }
|
---|
| 3576 |
|
---|
| 3577 | public static <T> T wrapDispatch(Class<T> wrapperClass, Dispatch d)
|
---|
| 3578 | {
|
---|
[46478] | 3579 | try
|
---|
| 3580 | {
|
---|
| 3581 | if (d == null || d.m_pDispatch == 0)
|
---|
| 3582 | return null;
|
---|
| 3583 | Constructor<T> c = wrapperClass.getConstructor(Dispatch.class);
|
---|
| 3584 | return (T)c.newInstance(d);
|
---|
| 3585 | }
|
---|
| 3586 | catch (NoSuchMethodException e)
|
---|
| 3587 | {
|
---|
| 3588 | throw new AssertionError(e);
|
---|
| 3589 | }
|
---|
| 3590 | catch (InstantiationException e)
|
---|
| 3591 | {
|
---|
| 3592 | throw new AssertionError(e);
|
---|
| 3593 | }
|
---|
| 3594 | catch (IllegalAccessException e)
|
---|
| 3595 | {
|
---|
| 3596 | throw new AssertionError(e);
|
---|
| 3597 | }
|
---|
| 3598 | catch (InvocationTargetException e)
|
---|
| 3599 | {
|
---|
| 3600 | throw new AssertionError(e);
|
---|
| 3601 | }
|
---|
[30987] | 3602 | }
|
---|
| 3603 |
|
---|
[31096] | 3604 | @SuppressWarnings("unchecked")
|
---|
[30987] | 3605 | public static <T> Object wrapVariant(Class<T> wrapperClass, Variant v)
|
---|
| 3606 | {
|
---|
[46478] | 3607 | if (v == null)
|
---|
| 3608 | return null;
|
---|
[30987] | 3609 |
|
---|
[46478] | 3610 | short vt = v.getvt();
|
---|
| 3611 | switch (vt)
|
---|
| 3612 | {
|
---|
| 3613 | case Variant.VariantNull:
|
---|
| 3614 | return null;
|
---|
| 3615 | case Variant.VariantBoolean:
|
---|
| 3616 | return v.getBoolean();
|
---|
| 3617 | case Variant.VariantByte:
|
---|
| 3618 | return v.getByte();
|
---|
| 3619 | case Variant.VariantShort:
|
---|
| 3620 | return v.getShort();
|
---|
| 3621 | case Variant.VariantInt:
|
---|
| 3622 | return v.getInt();
|
---|
| 3623 | case Variant.VariantLongInt:
|
---|
| 3624 | return v.getLong();
|
---|
| 3625 | case Variant.VariantString:
|
---|
| 3626 | return v.getString();
|
---|
| 3627 | case Variant.VariantDispatch:
|
---|
| 3628 | return wrapDispatch(wrapperClass, v.getDispatch());
|
---|
| 3629 | default:
|
---|
[51416] | 3630 | throw new IllegalArgumentException("unhandled variant type " + vt);
|
---|
[46478] | 3631 | }
|
---|
[30987] | 3632 | }
|
---|
| 3633 |
|
---|
[46478] | 3634 | public static byte[] wrapBytes(SafeArray sa)
|
---|
| 3635 | {
|
---|
| 3636 | if (sa == null)
|
---|
| 3637 | return null;
|
---|
[31711] | 3638 |
|
---|
| 3639 | int saLen = sa.getUBound() - sa.getLBound() + 1;
|
---|
| 3640 |
|
---|
| 3641 | byte[] ret = new byte[saLen];
|
---|
| 3642 | int j = 0;
|
---|
| 3643 | for (int i = sa.getLBound(); i <= sa.getUBound(); i++)
|
---|
| 3644 | {
|
---|
[46478] | 3645 | Variant v = sa.getVariant(i);
|
---|
| 3646 | // come up with more effective approach!!!
|
---|
| 3647 | ret[j++] = v.getByte();
|
---|
[31711] | 3648 | }
|
---|
| 3649 | return ret;
|
---|
| 3650 | }
|
---|
| 3651 |
|
---|
[31096] | 3652 | @SuppressWarnings("unchecked")
|
---|
[46478] | 3653 | public static <T> List<T> wrap(Class<T> wrapperClass, SafeArray sa)
|
---|
| 3654 | {
|
---|
| 3655 | if (sa == null)
|
---|
| 3656 | return null;
|
---|
[30987] | 3657 |
|
---|
| 3658 | int saLen = sa.getUBound() - sa.getLBound() + 1;
|
---|
[46478] | 3659 | if (saLen == 0)
|
---|
| 3660 | return Collections.emptyList();
|
---|
[30987] | 3661 |
|
---|
| 3662 | List<T> ret = new ArrayList<T>(saLen);
|
---|
| 3663 | for (int i = sa.getLBound(); i <= sa.getUBound(); i++)
|
---|
| 3664 | {
|
---|
[46478] | 3665 | Variant v = sa.getVariant(i);
|
---|
| 3666 | ret.add((T)wrapVariant(wrapperClass, v));
|
---|
[30987] | 3667 | }
|
---|
| 3668 | return ret;
|
---|
| 3669 | }
|
---|
| 3670 |
|
---|
[46478] | 3671 | public static <T> List<T> wrapEnum(Class<T> wrapperClass, SafeArray sa)
|
---|
| 3672 | {
|
---|
| 3673 | try
|
---|
| 3674 | {
|
---|
| 3675 | if (sa == null)
|
---|
| 3676 | return null;
|
---|
[30987] | 3677 |
|
---|
[46478] | 3678 | int saLen = sa.getUBound() - sa.getLBound() + 1;
|
---|
| 3679 | if (saLen == 0)
|
---|
| 3680 | return Collections.emptyList();
|
---|
| 3681 | List<T> ret = new ArrayList<T>(saLen);
|
---|
| 3682 | Constructor<T> c = wrapperClass.getConstructor(int.class);
|
---|
| 3683 | for (int i = sa.getLBound(); i <= sa.getUBound(); i++)
|
---|
| 3684 | {
|
---|
| 3685 | Variant v = sa.getVariant(i);
|
---|
| 3686 | ret.add(c.newInstance(v.getInt()));
|
---|
| 3687 | }
|
---|
| 3688 | return ret;
|
---|
| 3689 | }
|
---|
| 3690 | catch (NoSuchMethodException e)
|
---|
| 3691 | {
|
---|
[30987] | 3692 | throw new AssertionError(e);
|
---|
[46478] | 3693 | }
|
---|
| 3694 | catch (InstantiationException e)
|
---|
| 3695 | {
|
---|
[30987] | 3696 | throw new AssertionError(e);
|
---|
[46478] | 3697 | }
|
---|
| 3698 | catch (IllegalAccessException e)
|
---|
| 3699 | {
|
---|
[30987] | 3700 | throw new AssertionError(e);
|
---|
[46478] | 3701 | }
|
---|
| 3702 | catch (InvocationTargetException e)
|
---|
| 3703 | {
|
---|
[30987] | 3704 | throw new AssertionError(e);
|
---|
| 3705 | }
|
---|
| 3706 | }
|
---|
| 3707 |
|
---|
[46478] | 3708 | public static SafeArray unwrapInt(List<Integer> values)
|
---|
| 3709 | {
|
---|
| 3710 | if (values == null)
|
---|
| 3711 | return null;
|
---|
| 3712 | SafeArray ret = new SafeArray(Variant.VariantInt, values.size());
|
---|
[30987] | 3713 | int i = 0;
|
---|
[46478] | 3714 | for (int l : values)
|
---|
| 3715 | {
|
---|
| 3716 | ret.setInt(i++, l);
|
---|
[30987] | 3717 | }
|
---|
| 3718 | return ret;
|
---|
| 3719 | }
|
---|
| 3720 |
|
---|
[46478] | 3721 | public static SafeArray unwrapLong(List<Long> values)
|
---|
| 3722 | {
|
---|
| 3723 | if (values == null)
|
---|
| 3724 | return null;
|
---|
| 3725 | SafeArray ret = new SafeArray(Variant.VariantLongInt, values.size());
|
---|
[30987] | 3726 | int i = 0;
|
---|
[46478] | 3727 | for (long l : values)
|
---|
| 3728 | {
|
---|
| 3729 | ret.setLong(i++, l);
|
---|
[30987] | 3730 | }
|
---|
| 3731 | return ret;
|
---|
| 3732 | }
|
---|
| 3733 |
|
---|
[46478] | 3734 | public static SafeArray unwrapBool(List<Boolean> values)
|
---|
| 3735 | {
|
---|
| 3736 | if (values == null)
|
---|
| 3737 | return null;
|
---|
[30987] | 3738 |
|
---|
[46478] | 3739 | SafeArray result = new SafeArray(Variant.VariantBoolean, values.size());
|
---|
[30987] | 3740 | int i = 0;
|
---|
[46478] | 3741 | for (boolean l : values)
|
---|
| 3742 | {
|
---|
| 3743 | result.setBoolean(i++, l);
|
---|
[30987] | 3744 | }
|
---|
| 3745 | return result;
|
---|
| 3746 | }
|
---|
| 3747 |
|
---|
[36270] | 3748 |
|
---|
[46478] | 3749 | public static SafeArray unwrapBytes(byte[] values)
|
---|
| 3750 | {
|
---|
| 3751 | if (values == null)
|
---|
| 3752 | return null;
|
---|
[36270] | 3753 |
|
---|
[46478] | 3754 | SafeArray result = new SafeArray(Variant.VariantByte, values.length);
|
---|
[36270] | 3755 | int i = 0;
|
---|
[46478] | 3756 | for (byte l : values)
|
---|
| 3757 | {
|
---|
| 3758 | result.setByte(i++, l);
|
---|
[36270] | 3759 | }
|
---|
| 3760 | return result;
|
---|
| 3761 | }
|
---|
| 3762 |
|
---|
| 3763 |
|
---|
[46478] | 3764 | public static <T extends Enum <T>> SafeArray unwrapEnum(Class<T> enumClass, List<T> values)
|
---|
| 3765 | {
|
---|
| 3766 | if (values == null)
|
---|
| 3767 | return null;
|
---|
[30987] | 3768 |
|
---|
| 3769 | SafeArray result = new SafeArray(Variant.VariantInt, values.size());
|
---|
[46478] | 3770 | try
|
---|
| 3771 | {
|
---|
| 3772 | java.lang.reflect.Method valueM = enumClass.getMethod("value");
|
---|
| 3773 | int i = 0;
|
---|
| 3774 | for (T v : values)
|
---|
| 3775 | {
|
---|
| 3776 | result.setInt(i++, (Integer)valueM.invoke(v));
|
---|
| 3777 | }
|
---|
| 3778 | return result;
|
---|
[30987] | 3779 | }
|
---|
[46478] | 3780 | catch (NoSuchMethodException e)
|
---|
| 3781 | {
|
---|
| 3782 | throw new AssertionError(e);
|
---|
| 3783 | }
|
---|
| 3784 | catch(SecurityException e)
|
---|
| 3785 | {
|
---|
| 3786 | throw new AssertionError(e);
|
---|
| 3787 | }
|
---|
| 3788 | catch (IllegalAccessException e)
|
---|
| 3789 | {
|
---|
| 3790 | throw new AssertionError(e);
|
---|
| 3791 | }
|
---|
| 3792 | catch (IllegalArgumentException e)
|
---|
| 3793 | {
|
---|
| 3794 | throw new AssertionError(e);
|
---|
| 3795 | }
|
---|
| 3796 | catch (InvocationTargetException e)
|
---|
| 3797 | {
|
---|
| 3798 | throw new AssertionError(e);
|
---|
| 3799 | }
|
---|
[30987] | 3800 | }
|
---|
[46478] | 3801 | public static SafeArray unwrapString(List<String> values)
|
---|
| 3802 | {
|
---|
| 3803 | if (values == null)
|
---|
| 3804 | return null;
|
---|
| 3805 | SafeArray result = new SafeArray(Variant.VariantString, values.size());
|
---|
[30987] | 3806 | int i = 0;
|
---|
[46478] | 3807 | for (String l : values)
|
---|
| 3808 | {
|
---|
| 3809 | result.setString(i++, l);
|
---|
[30987] | 3810 | }
|
---|
| 3811 | return result;
|
---|
| 3812 | }
|
---|
| 3813 |
|
---|
[46478] | 3814 | public static <T1, T2> List<T1> wrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, T2[] values)
|
---|
| 3815 | {
|
---|
| 3816 | try
|
---|
| 3817 | {
|
---|
| 3818 | if (values == null)
|
---|
| 3819 | return null;
|
---|
| 3820 | if (values.length == 0)
|
---|
| 3821 | return Collections.emptyList();
|
---|
[30987] | 3822 |
|
---|
| 3823 | Constructor<T1> c = wrapperClass1.getConstructor(wrapperClass2);
|
---|
[46478] | 3824 | List<T1> ret = new ArrayList<T1>(values.length);
|
---|
| 3825 | for (T2 v : values)
|
---|
| 3826 | {
|
---|
| 3827 | ret.add(c.newInstance(v));
|
---|
[30987] | 3828 | }
|
---|
| 3829 | return ret;
|
---|
[46478] | 3830 | }
|
---|
| 3831 | catch (NoSuchMethodException e)
|
---|
| 3832 | {
|
---|
[30987] | 3833 | throw new AssertionError(e);
|
---|
[46478] | 3834 | }
|
---|
| 3835 | catch (InstantiationException e)
|
---|
| 3836 | {
|
---|
[30987] | 3837 | throw new AssertionError(e);
|
---|
[46478] | 3838 | }
|
---|
| 3839 | catch (IllegalAccessException e)
|
---|
| 3840 | {
|
---|
[30987] | 3841 | throw new AssertionError(e);
|
---|
[46478] | 3842 | }
|
---|
| 3843 | catch (InvocationTargetException e)
|
---|
| 3844 | {
|
---|
[30987] | 3845 | throw new AssertionError(e);
|
---|
| 3846 | }
|
---|
| 3847 | }
|
---|
| 3848 |
|
---|
[31096] | 3849 | @SuppressWarnings("unchecked")
|
---|
[46478] | 3850 | public static <T> T[] unwrap(Class<T> wrapperClass, List<T> values)
|
---|
| 3851 | {
|
---|
| 3852 | if (values == null)
|
---|
| 3853 | return null;
|
---|
| 3854 | return (T[])values.toArray((T[])Array.newInstance(wrapperClass, values.size()));
|
---|
[30987] | 3855 | }
|
---|
| 3856 |
|
---|
[31096] | 3857 | @SuppressWarnings("unchecked")
|
---|
[46478] | 3858 | public static <T1 extends IUnknown, T2> T2[] unwrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, List<T1> values)
|
---|
| 3859 | {
|
---|
| 3860 | if (values == null)
|
---|
| 3861 | return null;
|
---|
[30987] | 3862 |
|
---|
[46478] | 3863 | T2 ret[] = (T2[])Array.newInstance(wrapperClass2, values.size());
|
---|
[30987] | 3864 | int i = 0;
|
---|
[46478] | 3865 | for (T1 obj : values)
|
---|
| 3866 | {
|
---|
| 3867 | ret[i++] = (T2)obj.getWrapped();
|
---|
[30987] | 3868 | }
|
---|
| 3869 | return ret;
|
---|
| 3870 | }
|
---|
[33069] | 3871 |
|
---|
[30987] | 3872 | /* We have very long invoke lists sometimes */
|
---|
| 3873 | public static Variant invoke(Dispatch d, String method, Object ... args)
|
---|
| 3874 | {
|
---|
| 3875 | return Dispatch.callN(d, method, args);
|
---|
| 3876 | }
|
---|
| 3877 | }
|
---|
| 3878 | ]]></xsl:text>
|
---|
[46478] | 3879 | </xsl:if>
|
---|
[30987] | 3880 |
|
---|
[46478] | 3881 | <xsl:call-template name="endFile">
|
---|
| 3882 | <xsl:with-param name="file" select="'Helper.java'" />
|
---|
| 3883 | </xsl:call-template>
|
---|
[30987] | 3884 |
|
---|
[46478] | 3885 | <xsl:call-template name="startFile">
|
---|
| 3886 | <xsl:with-param name="file" select="'VBoxException.java'" />
|
---|
| 3887 | <xsl:with-param name="package" select="$G_virtualBoxPackage" />
|
---|
| 3888 | </xsl:call-template>
|
---|
[30987] | 3889 |
|
---|
[46478] | 3890 | <xsl:if test="$filelistonly=''">
|
---|
| 3891 | <xsl:text>
|
---|
| 3892 |
|
---|
| 3893 | public class VBoxException extends RuntimeException
|
---|
| 3894 | {
|
---|
| 3895 | private int resultCode;
|
---|
| 3896 | private IVirtualBoxErrorInfo errorInfo;
|
---|
| 3897 |
|
---|
| 3898 | public VBoxException(String message)
|
---|
| 3899 | {
|
---|
| 3900 | super(message);
|
---|
| 3901 | resultCode = -1;
|
---|
| 3902 | errorInfo = null;
|
---|
| 3903 | }
|
---|
| 3904 |
|
---|
| 3905 | public VBoxException(String message, Throwable cause)
|
---|
| 3906 | {
|
---|
| 3907 | super(message, cause);
|
---|
| 3908 | if (cause instanceof com.jacob.com.ComException)
|
---|
| 3909 | {
|
---|
| 3910 | resultCode = ((com.jacob.com.ComException)cause).getHResult();
|
---|
| 3911 | // JACOB doesn't support calling GetErrorInfo, which
|
---|
| 3912 | // means there is no way of getting an IErrorInfo reference,
|
---|
| 3913 | // and that means no way of getting to IVirtualBoxErrorInfo.
|
---|
| 3914 | errorInfo = null;
|
---|
| 3915 | }
|
---|
| 3916 | else
|
---|
| 3917 | resultCode = -1;
|
---|
| 3918 | }
|
---|
| 3919 |
|
---|
| 3920 | public int getResultCode()
|
---|
| 3921 | {
|
---|
| 3922 | return resultCode;
|
---|
| 3923 | }
|
---|
| 3924 |
|
---|
| 3925 | public IVirtualBoxErrorInfo getVirtualBoxErrorInfo()
|
---|
| 3926 | {
|
---|
| 3927 | return errorInfo;
|
---|
| 3928 | }
|
---|
| 3929 | }
|
---|
| 3930 | </xsl:text>
|
---|
| 3931 | </xsl:if>
|
---|
| 3932 |
|
---|
| 3933 | <xsl:call-template name="endFile">
|
---|
| 3934 | <xsl:with-param name="file" select="'VBoxException.java'" />
|
---|
| 3935 | </xsl:call-template>
|
---|
| 3936 |
|
---|
| 3937 |
|
---|
| 3938 | <xsl:call-template name="startFile">
|
---|
[30987] | 3939 | <xsl:with-param name="file" select="'VirtualBoxManager.java'" />
|
---|
| 3940 | <xsl:with-param name="package" select="$G_virtualBoxPackage" />
|
---|
| 3941 | </xsl:call-template>
|
---|
| 3942 |
|
---|
[46478] | 3943 | <xsl:if test="$filelistonly=''">
|
---|
| 3944 | <xsl:text><![CDATA[
|
---|
[30987] | 3945 |
|
---|
| 3946 | import com.jacob.activeX.ActiveXComponent;
|
---|
| 3947 | import com.jacob.com.ComThread;
|
---|
| 3948 | import com.jacob.com.Dispatch;
|
---|
| 3949 | import com.jacob.com.Variant;
|
---|
| 3950 | import com.jacob.com.SafeArray;
|
---|
| 3951 | import com.jacob.com.DispatchEvents;
|
---|
| 3952 |
|
---|
| 3953 | public class VirtualBoxManager
|
---|
| 3954 | {
|
---|
[46478] | 3955 | private IVirtualBox vbox;
|
---|
[30987] | 3956 |
|
---|
| 3957 | private VirtualBoxManager()
|
---|
| 3958 | {
|
---|
| 3959 | initPerThread();
|
---|
| 3960 | vbox = new IVirtualBox(new ActiveXComponent("VirtualBox.VirtualBox"));
|
---|
| 3961 | }
|
---|
| 3962 |
|
---|
| 3963 | public static void initPerThread()
|
---|
| 3964 | {
|
---|
[46478] | 3965 | ComThread.InitMTA();
|
---|
[30987] | 3966 | }
|
---|
| 3967 |
|
---|
| 3968 | public static void deinitPerThread()
|
---|
| 3969 | {
|
---|
[46478] | 3970 | ComThread.Release();
|
---|
[30987] | 3971 | }
|
---|
| 3972 |
|
---|
| 3973 | public void connect(String url, String username, String passwd)
|
---|
| 3974 | {
|
---|
[46478] | 3975 | throw new VBoxException("Connect doesn't make sense for local bindings");
|
---|
[30987] | 3976 | }
|
---|
| 3977 |
|
---|
| 3978 | public void disconnect()
|
---|
| 3979 | {
|
---|
[46478] | 3980 | throw new VBoxException("Disconnect doesn't make sense for local bindings");
|
---|
[30987] | 3981 | }
|
---|
| 3982 |
|
---|
[56306] | 3983 | public String getClientAPIVersion()
|
---|
| 3984 | {
|
---|
| 3985 | return "]]></xsl:text>
|
---|
| 3986 | <xsl:value-of select="substring($G_vboxApiSuffix, 2)" />
|
---|
| 3987 | <xsl:text><![CDATA[";
|
---|
| 3988 | }
|
---|
| 3989 |
|
---|
[30987] | 3990 | public IVirtualBox getVBox()
|
---|
| 3991 | {
|
---|
| 3992 | return this.vbox;
|
---|
| 3993 | }
|
---|
| 3994 |
|
---|
| 3995 | public ISession getSessionObject()
|
---|
| 3996 | {
|
---|
| 3997 | return new ISession(new ActiveXComponent("VirtualBox.Session"));
|
---|
| 3998 | }
|
---|
| 3999 |
|
---|
[31096] | 4000 | public ISession openMachineSession(IMachine m)
|
---|
[30987] | 4001 | {
|
---|
| 4002 | ISession s = getSessionObject();
|
---|
[31096] | 4003 | m.lockMachine(s, LockType.Shared);
|
---|
[31166] | 4004 | return s;
|
---|
[30987] | 4005 | }
|
---|
[31166] | 4006 |
|
---|
[30987] | 4007 | public void closeMachineSession(ISession s)
|
---|
| 4008 | {
|
---|
| 4009 | if (s != null)
|
---|
[31070] | 4010 | s.unlockMachine();
|
---|
[30987] | 4011 | }
|
---|
| 4012 |
|
---|
[31166] | 4013 | private static boolean hasInstance = false;
|
---|
[30987] | 4014 |
|
---|
[31166] | 4015 | public static synchronized VirtualBoxManager createInstance(String home)
|
---|
[30987] | 4016 | {
|
---|
[31166] | 4017 | if (hasInstance)
|
---|
[46478] | 4018 | throw new VBoxException("only one instance of VirtualBoxManager at a time allowed");
|
---|
[30987] | 4019 |
|
---|
[31166] | 4020 | hasInstance = true;
|
---|
| 4021 | return new VirtualBoxManager();
|
---|
[30987] | 4022 | }
|
---|
| 4023 |
|
---|
| 4024 | public void cleanup()
|
---|
| 4025 | {
|
---|
| 4026 | deinitPerThread();
|
---|
[31166] | 4027 | hasInstance = false;
|
---|
[30987] | 4028 | }
|
---|
| 4029 |
|
---|
| 4030 | public void waitForEvents(long tmo)
|
---|
| 4031 | {
|
---|
[46478] | 4032 | try
|
---|
| 4033 | {
|
---|
[30987] | 4034 | Thread.sleep(tmo);
|
---|
| 4035 | }
|
---|
[46478] | 4036 | catch (InterruptedException ie)
|
---|
| 4037 | {
|
---|
| 4038 | }
|
---|
[30987] | 4039 | }
|
---|
| 4040 | }
|
---|
| 4041 | ]]></xsl:text>
|
---|
[46478] | 4042 | </xsl:if>
|
---|
[30987] | 4043 |
|
---|
[46478] | 4044 | <xsl:call-template name="endFile">
|
---|
| 4045 | <xsl:with-param name="file" select="'VirtualBoxManager.java'" />
|
---|
| 4046 | </xsl:call-template>
|
---|
[30987] | 4047 | </xsl:template>
|
---|
| 4048 |
|
---|
| 4049 | <xsl:template name="emitHandwrittenJaxws">
|
---|
| 4050 |
|
---|
| 4051 | <xsl:call-template name="startFile">
|
---|
| 4052 | <xsl:with-param name="file" select="'IUnknown.java'" />
|
---|
[38799] | 4053 | <xsl:with-param name="package" select="$G_virtualBoxPackage" />
|
---|
[30987] | 4054 | </xsl:call-template>
|
---|
| 4055 |
|
---|
[46478] | 4056 | <xsl:if test="$filelistonly=''">
|
---|
| 4057 | <xsl:text><![CDATA[
|
---|
[30987] | 4058 | public class IUnknown
|
---|
| 4059 | {
|
---|
[46478] | 4060 | protected String obj;
|
---|
[61203] | 4061 | protected ObjectRefManager objMgr;
|
---|
[46478] | 4062 | protected final VboxPortType port;
|
---|
[30987] | 4063 |
|
---|
[61203] | 4064 | public IUnknown(String obj, ObjectRefManager objMgr, VboxPortType port)
|
---|
[46478] | 4065 | {
|
---|
[61203] | 4066 | this.obj = obj;
|
---|
| 4067 | this.objMgr = objMgr;
|
---|
| 4068 | this.port = port;
|
---|
| 4069 | objMgr.registerObj(this);
|
---|
[46478] | 4070 | }
|
---|
[30987] | 4071 |
|
---|
[46478] | 4072 | public final String getWrapped()
|
---|
| 4073 | {
|
---|
| 4074 | return this.obj;
|
---|
| 4075 | }
|
---|
[30987] | 4076 |
|
---|
[46478] | 4077 | public final VboxPortType getRemoteWSPort()
|
---|
| 4078 | {
|
---|
| 4079 | return this.port;
|
---|
| 4080 | }
|
---|
[30987] | 4081 |
|
---|
[61203] | 4082 | public final ObjectRefManager getObjMgr()
|
---|
| 4083 | {
|
---|
| 4084 | return this.objMgr;
|
---|
| 4085 | }
|
---|
| 4086 |
|
---|
[46478] | 4087 | public synchronized void releaseRemote() throws WebServiceException
|
---|
| 4088 | {
|
---|
| 4089 | if (obj == null)
|
---|
| 4090 | return;
|
---|
| 4091 |
|
---|
| 4092 | try
|
---|
| 4093 | {
|
---|
| 4094 | this.port.iManagedObjectRefRelease(obj);
|
---|
| 4095 | this.obj = null;
|
---|
| 4096 | }
|
---|
| 4097 | catch (InvalidObjectFaultMsg e)
|
---|
| 4098 | {
|
---|
| 4099 | throw new WebServiceException(e);
|
---|
| 4100 | }
|
---|
| 4101 | catch (RuntimeFaultMsg e)
|
---|
| 4102 | {
|
---|
| 4103 | throw new WebServiceException(e);
|
---|
| 4104 | }
|
---|
| 4105 | }
|
---|
[30987] | 4106 | }
|
---|
| 4107 | ]]></xsl:text>
|
---|
[46478] | 4108 | </xsl:if>
|
---|
[30987] | 4109 |
|
---|
[46478] | 4110 | <xsl:call-template name="endFile">
|
---|
| 4111 | <xsl:with-param name="file" select="'IUnknown.java'" />
|
---|
| 4112 | </xsl:call-template>
|
---|
[30987] | 4113 |
|
---|
[46478] | 4114 | <xsl:call-template name="startFile">
|
---|
| 4115 | <xsl:with-param name="file" select="'Helper.java'" />
|
---|
| 4116 | <xsl:with-param name="package" select="$G_virtualBoxPackage" />
|
---|
| 4117 | </xsl:call-template>
|
---|
[30987] | 4118 |
|
---|
[46478] | 4119 | <xsl:if test="$filelistonly=''">
|
---|
| 4120 | <xsl:text><![CDATA[
|
---|
[30987] | 4121 |
|
---|
| 4122 | import java.util.List;
|
---|
| 4123 | import java.util.ArrayList;
|
---|
| 4124 | import java.util.Collections;
|
---|
| 4125 | import java.lang.reflect.Array;
|
---|
| 4126 | import java.lang.reflect.Constructor;
|
---|
| 4127 | import java.lang.reflect.InvocationTargetException;
|
---|
| 4128 | import java.math.BigInteger;
|
---|
| 4129 |
|
---|
[46478] | 4130 | public class Helper
|
---|
| 4131 | {
|
---|
[61203] | 4132 | public static <T> List<T> wrap(Class<T> wrapperClass, ObjectRefManager objMgr, VboxPortType pt, List<String> values)
|
---|
[46478] | 4133 | {
|
---|
| 4134 | try
|
---|
| 4135 | {
|
---|
| 4136 | if (values == null)
|
---|
| 4137 | return null;
|
---|
[30987] | 4138 |
|
---|
[61203] | 4139 | Constructor<T> c = wrapperClass.getConstructor(String.class, ObjectRefManager.class, VboxPortType.class);
|
---|
[46478] | 4140 | List<T> ret = new ArrayList<T>(values.size());
|
---|
| 4141 | for (String v : values)
|
---|
| 4142 | {
|
---|
[61203] | 4143 | ret.add(c.newInstance(v, objMgr, pt));
|
---|
[30987] | 4144 | }
|
---|
| 4145 | return ret;
|
---|
[46478] | 4146 | }
|
---|
| 4147 | catch (NoSuchMethodException e)
|
---|
| 4148 | {
|
---|
[30987] | 4149 | throw new AssertionError(e);
|
---|
[46478] | 4150 | }
|
---|
| 4151 | catch (InstantiationException e)
|
---|
| 4152 | {
|
---|
[30987] | 4153 | throw new AssertionError(e);
|
---|
[46478] | 4154 | }
|
---|
| 4155 | catch (IllegalAccessException e)
|
---|
| 4156 | {
|
---|
[30987] | 4157 | throw new AssertionError(e);
|
---|
[46478] | 4158 | }
|
---|
| 4159 | catch (InvocationTargetException e)
|
---|
| 4160 | {
|
---|
[30987] | 4161 | throw new AssertionError(e);
|
---|
| 4162 | }
|
---|
| 4163 | }
|
---|
| 4164 |
|
---|
[61203] | 4165 | public static <T1, T2> List<T1> wrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, ObjectRefManager objMgr, VboxPortType pt, List<T2> values)
|
---|
[46478] | 4166 | {
|
---|
| 4167 | try
|
---|
| 4168 | {
|
---|
| 4169 | if (values == null)
|
---|
| 4170 | return null;
|
---|
[30987] | 4171 |
|
---|
[61203] | 4172 | Constructor<T1> c = wrapperClass1.getConstructor(wrapperClass2, ObjectRefManager.class, VboxPortType.class);
|
---|
[46478] | 4173 | List<T1> ret = new ArrayList<T1>(values.size());
|
---|
| 4174 | for (T2 v : values)
|
---|
| 4175 | {
|
---|
[61203] | 4176 | ret.add(c.newInstance(v, objMgr, pt));
|
---|
[30987] | 4177 | }
|
---|
| 4178 | return ret;
|
---|
[46478] | 4179 | }
|
---|
| 4180 | catch (NoSuchMethodException e)
|
---|
| 4181 | {
|
---|
[30987] | 4182 | throw new AssertionError(e);
|
---|
[46478] | 4183 | }
|
---|
| 4184 | catch (InstantiationException e)
|
---|
| 4185 | {
|
---|
[30987] | 4186 | throw new AssertionError(e);
|
---|
[46478] | 4187 | }
|
---|
| 4188 | catch (IllegalAccessException e)
|
---|
| 4189 | {
|
---|
[30987] | 4190 | throw new AssertionError(e);
|
---|
[46478] | 4191 | }
|
---|
| 4192 | catch (InvocationTargetException e)
|
---|
| 4193 | {
|
---|
[30987] | 4194 | throw new AssertionError(e);
|
---|
| 4195 | }
|
---|
| 4196 | }
|
---|
| 4197 |
|
---|
[46478] | 4198 | public static <T extends IUnknown> List<String> unwrap(List<T> values)
|
---|
| 4199 | {
|
---|
| 4200 | if (values == null)
|
---|
| 4201 | return null;
|
---|
[30987] | 4202 |
|
---|
[46478] | 4203 | List<String> ret = new ArrayList<String>(values.size());
|
---|
| 4204 | for (T obj : values)
|
---|
| 4205 | {
|
---|
[30987] | 4206 | ret.add(obj.getWrapped());
|
---|
| 4207 | }
|
---|
| 4208 | return ret;
|
---|
| 4209 | }
|
---|
| 4210 |
|
---|
[31095] | 4211 | @SuppressWarnings("unchecked" )
|
---|
[30987] | 4212 | public static <T1 extends Enum <T1>, T2 extends Enum <T2>> List<T2> convertEnums(Class<T1> fromClass,
|
---|
| 4213 | Class<T2> toClass,
|
---|
[46478] | 4214 | List<T1> values)
|
---|
| 4215 | {
|
---|
| 4216 | try
|
---|
| 4217 | {
|
---|
| 4218 | if (values == null)
|
---|
| 4219 | return null;
|
---|
[30987] | 4220 | List<T2> ret = new ArrayList<T2>(values.size());
|
---|
[46478] | 4221 | for (T1 v : values)
|
---|
| 4222 | {
|
---|
[48005] | 4223 | // Ordinal based enum conversion, as JAX-WS "invents" its own
|
---|
| 4224 | // enum names and has string values with the expected content.
|
---|
| 4225 | int enumOrdinal = v.ordinal();
|
---|
| 4226 | T2 convEnum = toClass.getEnumConstants()[enumOrdinal];
|
---|
| 4227 | ret.add(convEnum);
|
---|
[30987] | 4228 | }
|
---|
| 4229 | return ret;
|
---|
[46478] | 4230 | }
|
---|
[48005] | 4231 | catch (ArrayIndexOutOfBoundsException e)
|
---|
[46478] | 4232 | {
|
---|
[30987] | 4233 | throw new AssertionError(e);
|
---|
[46478] | 4234 | }
|
---|
[30987] | 4235 | }
|
---|
[38912] | 4236 |
|
---|
[36883] | 4237 | /* Pretty naive Base64 encoder/decoder. */
|
---|
| 4238 | private static final char[] valToChar = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".toCharArray();
|
---|
| 4239 | private static final int[] charToVal = new int[256];
|
---|
| 4240 |
|
---|
[38912] | 4241 | /* Initialize recoding alphabet. */
|
---|
| 4242 | static
|
---|
[31708] | 4243 | {
|
---|
[36883] | 4244 | for (int i = 0; i < charToVal.length; i++)
|
---|
| 4245 | charToVal[i] = -1;
|
---|
| 4246 |
|
---|
| 4247 | for (int i = 0; i < valToChar.length; i++)
|
---|
[46478] | 4248 | charToVal[valToChar[i]] = i;
|
---|
[36883] | 4249 |
|
---|
[37456] | 4250 | charToVal['='] = 0;
|
---|
[31708] | 4251 | }
|
---|
[33069] | 4252 |
|
---|
[36883] | 4253 | public static String encodeBase64(byte[] data)
|
---|
[33069] | 4254 | {
|
---|
[36883] | 4255 | if (data == null)
|
---|
| 4256 | return null;
|
---|
| 4257 |
|
---|
| 4258 | if (data.length == 0)
|
---|
| 4259 | return "";
|
---|
| 4260 |
|
---|
| 4261 | int fullTriplets = data.length / 3;
|
---|
| 4262 | int resultLen = ((data.length - 1) / 3 + 1) * 4;
|
---|
| 4263 | char[] result = new char[resultLen];
|
---|
| 4264 | int dataIndex = 0, stringIndex = 0;
|
---|
| 4265 |
|
---|
| 4266 | for (int i = 0; i < fullTriplets; i++)
|
---|
| 4267 | {
|
---|
| 4268 | int ch1 = data[dataIndex++] & 0xff;
|
---|
| 4269 | result[stringIndex++] = valToChar[ch1 >> 2];
|
---|
| 4270 | int ch2 = data[dataIndex++] & 0xff;
|
---|
| 4271 | result[stringIndex++] = valToChar[((ch1 << 4) & 0x3f) | (ch2 >> 4)];
|
---|
| 4272 | int ch3 = data[dataIndex++] & 0xff;
|
---|
| 4273 | result[stringIndex++] = valToChar[((ch2 << 2) & 0x3f) | (ch3 >> 6)];
|
---|
| 4274 | result[stringIndex++] = valToChar[ch3 & 0x3f];
|
---|
| 4275 | }
|
---|
[38912] | 4276 |
|
---|
[36883] | 4277 | switch (data.length - dataIndex)
|
---|
| 4278 | {
|
---|
| 4279 | case 0:
|
---|
| 4280 | // do nothing
|
---|
| 4281 | break;
|
---|
| 4282 | case 1:
|
---|
| 4283 | {
|
---|
| 4284 | int ch1 = data[dataIndex++] & 0xff;
|
---|
| 4285 | result[stringIndex++] = valToChar[ch1 >> 2];
|
---|
| 4286 | result[stringIndex++] = valToChar[(ch1 << 4) & 0x3f];
|
---|
| 4287 | result[stringIndex++] = '=';
|
---|
| 4288 | result[stringIndex++] = '=';
|
---|
| 4289 | break;
|
---|
| 4290 | }
|
---|
| 4291 | case 2:
|
---|
| 4292 | {
|
---|
| 4293 | int ch1 = data[dataIndex++] & 0xff;
|
---|
| 4294 | result[stringIndex++] = valToChar[ch1 >> 2];
|
---|
| 4295 | int ch2 = data[dataIndex++] & 0xff;
|
---|
| 4296 | result[stringIndex++] = valToChar[((ch1 << 4) & 0x3f) | (ch2 >> 4)];
|
---|
| 4297 | result[stringIndex++] = valToChar[(ch2 << 2) & 0x3f];
|
---|
| 4298 | result[stringIndex++] = '=';
|
---|
| 4299 | break;
|
---|
| 4300 | }
|
---|
| 4301 | default:
|
---|
[46478] | 4302 | throw new VBoxException("bug!");
|
---|
[36883] | 4303 | }
|
---|
| 4304 |
|
---|
| 4305 | return new String(result);
|
---|
[33069] | 4306 | }
|
---|
[36883] | 4307 |
|
---|
| 4308 | private static int skipInvalid(String str, int stringIndex)
|
---|
| 4309 | {
|
---|
| 4310 | while (charToVal[str.charAt(stringIndex)] < 0)
|
---|
| 4311 | stringIndex++;
|
---|
| 4312 |
|
---|
| 4313 | return stringIndex;
|
---|
| 4314 | }
|
---|
| 4315 |
|
---|
| 4316 | public static byte[] decodeBase64(String str)
|
---|
| 4317 | {
|
---|
| 4318 | if (str == null)
|
---|
| 4319 | return null;
|
---|
[38912] | 4320 |
|
---|
[36883] | 4321 | int stringLength = str.length();
|
---|
| 4322 | if (stringLength == 0)
|
---|
| 4323 | return new byte[0];
|
---|
| 4324 |
|
---|
| 4325 | int validChars = 0, padChars = 0;
|
---|
| 4326 | for (int i = 0; i < str.length(); i++)
|
---|
| 4327 | {
|
---|
| 4328 | char ch = str.charAt(i);
|
---|
| 4329 |
|
---|
| 4330 | if (charToVal[ch] >= 0)
|
---|
| 4331 | validChars++;
|
---|
| 4332 |
|
---|
| 4333 | if (ch == '=')
|
---|
| 4334 | padChars++;
|
---|
| 4335 | }
|
---|
[38912] | 4336 |
|
---|
[36883] | 4337 | if ((validChars * 3 % 4) != 0)
|
---|
[46478] | 4338 | throw new VBoxException("invalid base64 encoded string " + str);
|
---|
[36883] | 4339 |
|
---|
| 4340 | int resultLength = validChars * 3 / 4 - padChars;
|
---|
| 4341 | byte[] result = new byte[resultLength];
|
---|
| 4342 |
|
---|
| 4343 | int dataIndex = 0, stringIndex = 0;
|
---|
| 4344 | int quadraplets = validChars / 4;
|
---|
| 4345 |
|
---|
[46478] | 4346 | for (int i = 0; i < quadraplets; i++)
|
---|
[36883] | 4347 | {
|
---|
| 4348 | stringIndex = skipInvalid(str, stringIndex);
|
---|
| 4349 | int ch1 = str.charAt(stringIndex++);
|
---|
| 4350 | stringIndex = skipInvalid(str, stringIndex);
|
---|
| 4351 | int ch2 = str.charAt(stringIndex++);
|
---|
| 4352 | stringIndex = skipInvalid(str, stringIndex);
|
---|
| 4353 | int ch3 = str.charAt(stringIndex++);
|
---|
| 4354 | stringIndex = skipInvalid(str, stringIndex);
|
---|
| 4355 | int ch4 = str.charAt(stringIndex++);
|
---|
| 4356 |
|
---|
| 4357 | result[dataIndex++] = (byte)(((charToVal[ch1] << 2) | charToVal[ch2] >> 4) & 0xff);
|
---|
[38912] | 4358 | /* we check this to ensure that we don't override data with '=' padding. */
|
---|
[36883] | 4359 | if (dataIndex < result.length)
|
---|
| 4360 | result[dataIndex++] = (byte)(((charToVal[ch2] << 4) | charToVal[ch3] >> 2) & 0xff);
|
---|
| 4361 | if (dataIndex < result.length)
|
---|
| 4362 | result[dataIndex++] = (byte)(((charToVal[ch3] << 6) | charToVal[ch4]) & 0xff);
|
---|
| 4363 | }
|
---|
[38912] | 4364 |
|
---|
[36883] | 4365 | return result;
|
---|
| 4366 | }
|
---|
[30987] | 4367 | }
|
---|
| 4368 | ]]></xsl:text>
|
---|
[46478] | 4369 | </xsl:if>
|
---|
[30987] | 4370 |
|
---|
[46478] | 4371 | <xsl:call-template name="endFile">
|
---|
| 4372 | <xsl:with-param name="file" select="'Helper.java'" />
|
---|
| 4373 | </xsl:call-template>
|
---|
[30987] | 4374 |
|
---|
[46478] | 4375 | <xsl:call-template name="startFile">
|
---|
| 4376 | <xsl:with-param name="file" select="'VBoxException.java'" />
|
---|
| 4377 | <xsl:with-param name="package" select="$G_virtualBoxPackage" />
|
---|
| 4378 | </xsl:call-template>
|
---|
| 4379 |
|
---|
| 4380 | <xsl:if test="$filelistonly=''">
|
---|
| 4381 | <xsl:text>
|
---|
| 4382 | public class VBoxException extends RuntimeException
|
---|
| 4383 | {
|
---|
| 4384 | private int resultCode;
|
---|
| 4385 | private IVirtualBoxErrorInfo errorInfo;
|
---|
| 4386 |
|
---|
| 4387 | public VBoxException(String message)
|
---|
| 4388 | {
|
---|
| 4389 | super(message);
|
---|
| 4390 | resultCode = -1;
|
---|
| 4391 | errorInfo = null;
|
---|
| 4392 | }
|
---|
| 4393 |
|
---|
| 4394 | public VBoxException(String message, Throwable cause)
|
---|
| 4395 | {
|
---|
| 4396 | super(message, cause);
|
---|
| 4397 | resultCode = -1;
|
---|
| 4398 | errorInfo = null;
|
---|
| 4399 | }
|
---|
| 4400 |
|
---|
[61203] | 4401 | public VBoxException(String message, Throwable cause, ObjectRefManager objMgr, VboxPortType port)
|
---|
[46478] | 4402 | {
|
---|
| 4403 | super(message, cause);
|
---|
| 4404 | if (cause instanceof RuntimeFaultMsg)
|
---|
| 4405 | {
|
---|
| 4406 | RuntimeFaultMsg m = (RuntimeFaultMsg)cause;
|
---|
| 4407 | RuntimeFault f = m.getFaultInfo();
|
---|
| 4408 | resultCode = f.getResultCode();
|
---|
| 4409 | String retVal = f.getReturnval();
|
---|
[61203] | 4410 | errorInfo = (retVal.length() > 0) ? new IVirtualBoxErrorInfo(retVal, objMgr, port) : null;
|
---|
[46478] | 4411 | }
|
---|
| 4412 | else
|
---|
| 4413 | resultCode = -1;
|
---|
| 4414 | }
|
---|
| 4415 |
|
---|
| 4416 | public int getResultCode()
|
---|
| 4417 | {
|
---|
| 4418 | return resultCode;
|
---|
| 4419 | }
|
---|
| 4420 |
|
---|
| 4421 | public IVirtualBoxErrorInfo getVirtualBoxErrorInfo()
|
---|
| 4422 | {
|
---|
| 4423 | return errorInfo;
|
---|
| 4424 | }
|
---|
| 4425 | }
|
---|
| 4426 | </xsl:text>
|
---|
| 4427 | </xsl:if>
|
---|
| 4428 |
|
---|
| 4429 | <xsl:call-template name="endFile">
|
---|
| 4430 | <xsl:with-param name="file" select="'VBoxException.java'" />
|
---|
| 4431 | </xsl:call-template>
|
---|
| 4432 |
|
---|
| 4433 | <xsl:call-template name="startFile">
|
---|
[30987] | 4434 | <xsl:with-param name="file" select="'VirtualBoxManager.java'" />
|
---|
| 4435 | <xsl:with-param name="package" select="$G_virtualBoxPackage" />
|
---|
[46478] | 4436 | </xsl:call-template>
|
---|
[30987] | 4437 |
|
---|
[46478] | 4438 | <xsl:if test="$filelistonly=''">
|
---|
| 4439 | <xsl:text>import java.net.URL;
|
---|
[30987] | 4440 | import java.math.BigInteger;
|
---|
[61203] | 4441 | import java.util.Iterator;
|
---|
[30987] | 4442 | import java.util.List;
|
---|
[61203] | 4443 | import java.util.LinkedList;
|
---|
[30987] | 4444 | import java.util.Map;
|
---|
| 4445 | import java.util.HashMap;
|
---|
[53219] | 4446 | import java.util.ArrayList;
|
---|
[61203] | 4447 | import java.util.concurrent.ConcurrentHashMap;
|
---|
| 4448 | import java.util.concurrent.ConcurrentLinkedQueue;
|
---|
| 4449 | import java.util.concurrent.ConcurrentMap;
|
---|
| 4450 | import java.util.concurrent.locks.ReentrantReadWriteLock;
|
---|
| 4451 | import java.lang.Integer;
|
---|
| 4452 | import java.lang.ref.WeakReference;
|
---|
| 4453 | import java.lang.ref.ReferenceQueue;
|
---|
[30987] | 4454 | import javax.xml.namespace.QName;
|
---|
| 4455 | import javax.xml.ws.BindingProvider;
|
---|
| 4456 | import javax.xml.ws.Holder;
|
---|
| 4457 | import javax.xml.ws.WebServiceException;
|
---|
[53219] | 4458 | import java.io.IOException;
|
---|
| 4459 | import java.net.UnknownHostException;
|
---|
| 4460 | import java.net.Socket;
|
---|
| 4461 | import java.net.InetAddress;
|
---|
| 4462 | import javax.net.SocketFactory;
|
---|
| 4463 | import javax.net.ssl.SSLContext;
|
---|
| 4464 | import javax.net.ssl.SSLSocketFactory;
|
---|
| 4465 | import javax.net.ssl.SSLSocket;
|
---|
[30987] | 4466 |
|
---|
| 4467 | class PortPool
|
---|
| 4468 | {
|
---|
[46478] | 4469 | private final static String wsdlFile = </xsl:text>
|
---|
| 4470 | <xsl:value-of select="$G_virtualBoxWsdl" />
|
---|
| 4471 | <xsl:text><![CDATA[;
|
---|
| 4472 | private Map<VboxPortType, Integer> known;
|
---|
[30987] | 4473 | private boolean initStarted;
|
---|
| 4474 | private VboxService svc;
|
---|
| 4475 |
|
---|
| 4476 | PortPool(boolean usePreinit)
|
---|
| 4477 | {
|
---|
| 4478 | known = new HashMap<VboxPortType, Integer>();
|
---|
| 4479 |
|
---|
| 4480 | if (usePreinit)
|
---|
| 4481 | {
|
---|
[46478] | 4482 | new Thread(new Runnable()
|
---|
| 4483 | {
|
---|
| 4484 | public void run()
|
---|
[30987] | 4485 | {
|
---|
[46478] | 4486 | // need to sync on something else but 'this'
|
---|
| 4487 | synchronized (known)
|
---|
| 4488 | {
|
---|
| 4489 | initStarted = true;
|
---|
| 4490 | known.notify();
|
---|
| 4491 | }
|
---|
| 4492 |
|
---|
| 4493 | preinit();
|
---|
[30987] | 4494 | }
|
---|
[46478] | 4495 | }).start();
|
---|
[30987] | 4496 |
|
---|
[46478] | 4497 | synchronized (known)
|
---|
| 4498 | {
|
---|
| 4499 | while (!initStarted)
|
---|
| 4500 | {
|
---|
| 4501 | try
|
---|
| 4502 | {
|
---|
| 4503 | known.wait();
|
---|
| 4504 | }
|
---|
| 4505 | catch (InterruptedException e)
|
---|
| 4506 | {
|
---|
| 4507 | break;
|
---|
| 4508 | }
|
---|
| 4509 | }
|
---|
| 4510 | }
|
---|
[30987] | 4511 | }
|
---|
| 4512 | }
|
---|
| 4513 |
|
---|
| 4514 | private synchronized void preinit()
|
---|
| 4515 | {
|
---|
| 4516 | VboxPortType port = getPort();
|
---|
| 4517 | releasePort(port);
|
---|
| 4518 | }
|
---|
| 4519 |
|
---|
| 4520 | synchronized VboxPortType getPort()
|
---|
| 4521 | {
|
---|
| 4522 | VboxPortType port = null;
|
---|
| 4523 | int ttl = 0;
|
---|
| 4524 |
|
---|
| 4525 | for (VboxPortType cur: known.keySet())
|
---|
| 4526 | {
|
---|
| 4527 | int value = known.get(cur);
|
---|
| 4528 | if ((value & 0x10000) == 0)
|
---|
| 4529 | {
|
---|
| 4530 | port = cur;
|
---|
| 4531 | ttl = value & 0xffff;
|
---|
| 4532 | break;
|
---|
| 4533 | }
|
---|
| 4534 | }
|
---|
| 4535 |
|
---|
| 4536 | if (port == null)
|
---|
| 4537 | {
|
---|
[46478] | 4538 | if (svc == null)
|
---|
| 4539 | {
|
---|
[30987] | 4540 | URL wsdl = PortPool.class.getClassLoader().getResource(wsdlFile);
|
---|
| 4541 | if (wsdl == null)
|
---|
[46478] | 4542 | throw new LinkageError(wsdlFile + " not found, but it should have been in the jar");
|
---|
[30987] | 4543 | svc = new VboxService(wsdl,
|
---|
| 4544 | new QName("http://www.virtualbox.org/Service",
|
---|
| 4545 | "vboxService"));
|
---|
| 4546 | }
|
---|
| 4547 | port = svc.getVboxServicePort();
|
---|
| 4548 | // reuse this object 0x10 times
|
---|
| 4549 | ttl = 0x10;
|
---|
| 4550 | }
|
---|
| 4551 | // mark as used
|
---|
| 4552 | known.put(port, new Integer(0x10000 | ttl));
|
---|
| 4553 | return port;
|
---|
| 4554 | }
|
---|
| 4555 |
|
---|
| 4556 | synchronized void releasePort(VboxPortType port)
|
---|
| 4557 | {
|
---|
| 4558 | Integer val = known.get(port);
|
---|
| 4559 | if (val == null || val == 0)
|
---|
| 4560 | {
|
---|
| 4561 | // know you not
|
---|
| 4562 | return;
|
---|
| 4563 | }
|
---|
| 4564 |
|
---|
| 4565 | int v = val;
|
---|
| 4566 | int ttl = v & 0xffff;
|
---|
| 4567 | // decrement TTL, and throw away port if used too much times
|
---|
| 4568 | if (--ttl <= 0)
|
---|
| 4569 | {
|
---|
| 4570 | known.remove(port);
|
---|
| 4571 | }
|
---|
| 4572 | else
|
---|
| 4573 | {
|
---|
| 4574 | v = ttl; // set new TTL and clear busy bit
|
---|
| 4575 | known.put(port, v);
|
---|
| 4576 | }
|
---|
| 4577 | }
|
---|
| 4578 | }
|
---|
| 4579 |
|
---|
| 4580 |
|
---|
[61203] | 4581 | /**
|
---|
| 4582 | * This class manages the object references between us and the webservice server.
|
---|
| 4583 | * It makes sure that the object on the server side is destroyed when all
|
---|
| 4584 | */
|
---|
| 4585 | class ObjectRefManager
|
---|
| 4586 | {
|
---|
| 4587 | private final static ReferenceQueue<IUnknown> refQ = new ReferenceQueue<IUnknown>();
|
---|
| 4588 |
|
---|
| 4589 | private final ConcurrentMap<String, ManagedObj> map = new ConcurrentHashMap<String, ManagedObj>();
|
---|
| 4590 | private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
|
---|
| 4591 | private final ObjRefMgrCleanupThread objRefMgrCleanup;
|
---|
| 4592 |
|
---|
[61365] | 4593 | public ObjectRefManager()
|
---|
[61203] | 4594 | {
|
---|
| 4595 | this.objRefMgrCleanup = new ObjRefMgrCleanupThread(this, 100);
|
---|
| 4596 | this.objRefMgrCleanup.start();
|
---|
| 4597 | }
|
---|
| 4598 |
|
---|
| 4599 | /**
|
---|
| 4600 | * Prevents the object reference manager cleanup thread from releasing any
|
---|
| 4601 | * server side objects to avoid a fundamental race in the multi threaded
|
---|
| 4602 | * java environment where it is possible that a wrapper got the object ID
|
---|
| 4603 | * from the server but couldn't create the local stub protecting the object
|
---|
| 4604 | * before the cleanup thread released it.
|
---|
| 4605 | */
|
---|
| 4606 | public void preventObjRelease()
|
---|
| 4607 | {
|
---|
| 4608 | lock.readLock().lock();
|
---|
| 4609 | }
|
---|
| 4610 |
|
---|
| 4611 | /**
|
---|
| 4612 | * Allows releasing server side objects from the cleanup thread again.
|
---|
| 4613 | */
|
---|
| 4614 | public void allowObjRelease()
|
---|
| 4615 | {
|
---|
| 4616 | lock.readLock().unlock();
|
---|
| 4617 | }
|
---|
| 4618 |
|
---|
| 4619 | /**
|
---|
| 4620 | * Marks the start of a run to release server side objects which don't hold
|
---|
| 4621 | * a reference locally anymore.
|
---|
| 4622 | */
|
---|
| 4623 | public void startObjRelease()
|
---|
| 4624 | {
|
---|
| 4625 | lock.writeLock().lock();
|
---|
| 4626 | }
|
---|
| 4627 |
|
---|
| 4628 | /**
|
---|
| 4629 | * Marks the end of a cleanup run.
|
---|
| 4630 | */
|
---|
| 4631 | public void endObjRelease()
|
---|
| 4632 | {
|
---|
| 4633 | lock.writeLock().unlock();
|
---|
| 4634 | }
|
---|
| 4635 |
|
---|
| 4636 | /**
|
---|
| 4637 | * Registers a new stub object for automatic reference managing.
|
---|
| 4638 | */
|
---|
| 4639 | public void registerObj(IUnknown obj)
|
---|
| 4640 | {
|
---|
[61365] | 4641 | assert lock.getReadLockCount() > 0;
|
---|
[61203] | 4642 | ManagedObjRef ref = new ManagedObjRef(obj);
|
---|
| 4643 |
|
---|
| 4644 | ManagedObj mgrobj = map.get(obj.getWrapped());
|
---|
| 4645 | if (mgrobj != null)
|
---|
| 4646 | {
|
---|
| 4647 | mgrobj.addObject(ref);
|
---|
| 4648 | }
|
---|
| 4649 | else
|
---|
| 4650 | {
|
---|
| 4651 | /* Create new. */
|
---|
[61365] | 4652 | mgrobj = new ManagedObj(obj.getWrapped(), obj.getRemoteWSPort());
|
---|
[61203] | 4653 | mgrobj.addObject(ref);
|
---|
| 4654 | map.put(obj.getWrapped(), mgrobj);
|
---|
| 4655 | }
|
---|
| 4656 | }
|
---|
| 4657 |
|
---|
| 4658 | /**
|
---|
| 4659 | * Removes a garbage collected object reference from our reference manager.
|
---|
| 4660 | *
|
---|
| 4661 | * Returns the server side object wrapper if there is no stub referencing it
|
---|
| 4662 | * anymore otherwise null is returned.
|
---|
| 4663 | */
|
---|
| 4664 | public ManagedObj unregisterObj(ManagedObjRef objRef)
|
---|
| 4665 | {
|
---|
| 4666 | ManagedObj obj = this.map.get(objRef.objId);
|
---|
| 4667 |
|
---|
| 4668 | assert obj != null;
|
---|
| 4669 | obj.removeObject(objRef);
|
---|
| 4670 | if (!obj.isReferenced())
|
---|
| 4671 | return obj;
|
---|
| 4672 |
|
---|
| 4673 | return null;
|
---|
| 4674 | }
|
---|
| 4675 |
|
---|
| 4676 | public void releaseRemoteObj(ManagedObj obj)
|
---|
| 4677 | {
|
---|
[61365] | 4678 | assert lock.isWriteLockedByCurrentThread();
|
---|
| 4679 |
|
---|
[61203] | 4680 | if (!obj.isReferenced())
|
---|
| 4681 | {
|
---|
| 4682 | try
|
---|
| 4683 | {
|
---|
[61365] | 4684 | obj.port.iManagedObjectRefRelease(obj.objId);
|
---|
[61203] | 4685 | }
|
---|
| 4686 | catch (InvalidObjectFaultMsg e)
|
---|
| 4687 | {
|
---|
| 4688 | throw new WebServiceException(e);
|
---|
| 4689 | }
|
---|
| 4690 | catch (RuntimeFaultMsg e)
|
---|
| 4691 | {
|
---|
| 4692 | throw new WebServiceException(e);
|
---|
| 4693 | }
|
---|
| 4694 | finally
|
---|
| 4695 | {
|
---|
| 4696 | this.map.remove(obj.objId);
|
---|
| 4697 | }
|
---|
| 4698 | }
|
---|
| 4699 | }
|
---|
| 4700 |
|
---|
| 4701 | /**
|
---|
| 4702 | * An object which is living on the server side. This can be referenced
|
---|
| 4703 | * by multiple stub objects here.
|
---|
| 4704 | */
|
---|
| 4705 | static class ManagedObj
|
---|
| 4706 | {
|
---|
| 4707 | private final String objId;
|
---|
[61365] | 4708 | private final VboxPortType port;
|
---|
[61203] | 4709 | private final ConcurrentLinkedQueue<ManagedObjRef> refQ;
|
---|
| 4710 |
|
---|
[61365] | 4711 | ManagedObj(String objId, VboxPortType port)
|
---|
[61203] | 4712 | {
|
---|
| 4713 | this.objId = objId;
|
---|
[61365] | 4714 | this.port = port;
|
---|
[61203] | 4715 | this.refQ = new ConcurrentLinkedQueue<ManagedObjRef>();
|
---|
| 4716 | }
|
---|
| 4717 |
|
---|
| 4718 | public void addObject(ManagedObjRef obj)
|
---|
| 4719 | {
|
---|
| 4720 | this.refQ.add(obj);
|
---|
| 4721 | }
|
---|
| 4722 |
|
---|
| 4723 | public void removeObject(ManagedObjRef obj)
|
---|
| 4724 | {
|
---|
| 4725 | this.refQ.remove(obj);
|
---|
| 4726 | }
|
---|
| 4727 |
|
---|
| 4728 | public boolean isReferenced()
|
---|
| 4729 | {
|
---|
| 4730 | return !this.refQ.isEmpty();
|
---|
| 4731 | }
|
---|
| 4732 | }
|
---|
| 4733 |
|
---|
| 4734 | /**
|
---|
| 4735 | * A private class extending WeakReference to get notified about garbage
|
---|
| 4736 | * collected stub objects.
|
---|
| 4737 | */
|
---|
| 4738 | static class ManagedObjRef extends WeakReference<IUnknown>
|
---|
| 4739 | {
|
---|
| 4740 | final String objId;
|
---|
| 4741 |
|
---|
| 4742 | ManagedObjRef(IUnknown obj)
|
---|
| 4743 | {
|
---|
| 4744 | super(obj, refQ);
|
---|
| 4745 | this.objId = obj.getWrapped();
|
---|
| 4746 | }
|
---|
| 4747 | }
|
---|
| 4748 |
|
---|
| 4749 | /**
|
---|
| 4750 | * A private class implementing a thread getting notified
|
---|
| 4751 | * about garbage collected objects so it can release the object on the
|
---|
| 4752 | * server side if it is not used anymore.
|
---|
| 4753 | */
|
---|
| 4754 | static class ObjRefMgrCleanupThread extends Thread
|
---|
| 4755 | {
|
---|
| 4756 | ObjectRefManager objRefMgr;
|
---|
| 4757 | int cStubsReleased;
|
---|
| 4758 | int cStubsReleaseThreshold;
|
---|
| 4759 | HashMap<String, ManagedObj> mapToRelease = new HashMap<String, ManagedObj>();
|
---|
| 4760 |
|
---|
| 4761 | ObjRefMgrCleanupThread(ObjectRefManager objRefMgr)
|
---|
| 4762 | {
|
---|
| 4763 | init(objRefMgr, 500);
|
---|
| 4764 | }
|
---|
| 4765 |
|
---|
| 4766 | ObjRefMgrCleanupThread(ObjectRefManager objRefMgr, int cStubsReleaseThreshold)
|
---|
| 4767 | {
|
---|
| 4768 | init(objRefMgr, cStubsReleaseThreshold);
|
---|
| 4769 | }
|
---|
| 4770 |
|
---|
| 4771 | private void init(ObjectRefManager objRefMgr, int cStubsReleaseThreshold)
|
---|
| 4772 | {
|
---|
| 4773 | this.objRefMgr = objRefMgr;
|
---|
| 4774 | this.cStubsReleased = 0;
|
---|
| 4775 | this.cStubsReleaseThreshold = cStubsReleaseThreshold;
|
---|
| 4776 | setName("ObjectRefManager-VBoxWSObjRefGcThrd");
|
---|
| 4777 | /*
|
---|
| 4778 | * setDaemon() makes sure the jvm exits and is not blocked
|
---|
| 4779 | * if the thread is still running so we don't have to care about
|
---|
| 4780 | * tearing it down.
|
---|
| 4781 | */
|
---|
| 4782 | setDaemon(true);
|
---|
| 4783 | }
|
---|
| 4784 |
|
---|
| 4785 | public void run()
|
---|
| 4786 | {
|
---|
| 4787 | while (true)
|
---|
| 4788 | {
|
---|
| 4789 | while (cStubsReleased < cStubsReleaseThreshold)
|
---|
| 4790 | {
|
---|
| 4791 | try
|
---|
| 4792 | {
|
---|
| 4793 | /* Accumulate a few objects before we start. */
|
---|
| 4794 | while (cStubsReleased < cStubsReleaseThreshold)
|
---|
| 4795 | {
|
---|
[61452] | 4796 | ManagedObjRef ref = (ManagedObjRef)refQ.remove();
|
---|
[61203] | 4797 | ManagedObj obj = this.objRefMgr.unregisterObj(ref);
|
---|
| 4798 | /*
|
---|
| 4799 | * If the server side object is not referenced anymore
|
---|
| 4800 | * promote to map for releasing later.
|
---|
| 4801 | */
|
---|
| 4802 | if (obj != null && !mapToRelease.containsKey(ref.objId))
|
---|
| 4803 | mapToRelease.put(ref.objId, obj);
|
---|
| 4804 |
|
---|
| 4805 | cStubsReleased++;
|
---|
| 4806 | }
|
---|
| 4807 | }
|
---|
| 4808 | catch (InterruptedException e)
|
---|
| 4809 | { /* ignore */ }
|
---|
| 4810 | catch (javax.xml.ws.WebServiceException e)
|
---|
| 4811 | { /* ignore */ }
|
---|
| 4812 | }
|
---|
| 4813 |
|
---|
| 4814 | /*
|
---|
| 4815 | * After we released enough stubs we go over all non referenced
|
---|
| 4816 | * server side objects and release them if they were not
|
---|
| 4817 | * referenced again in between.
|
---|
| 4818 | */
|
---|
| 4819 | cStubsReleased = 0;
|
---|
| 4820 | if (!mapToRelease.isEmpty())
|
---|
| 4821 | {
|
---|
| 4822 | this.objRefMgr.startObjRelease();
|
---|
| 4823 | try
|
---|
| 4824 | {
|
---|
| 4825 | Iterator<ManagedObj> it = mapToRelease.values().iterator();
|
---|
| 4826 | while (it.hasNext())
|
---|
| 4827 | {
|
---|
| 4828 | ManagedObj obj = it.next();
|
---|
| 4829 | this.objRefMgr.releaseRemoteObj(obj);
|
---|
| 4830 | }
|
---|
| 4831 |
|
---|
| 4832 | mapToRelease.clear();
|
---|
| 4833 | }
|
---|
| 4834 | catch (javax.xml.ws.WebServiceException e)
|
---|
| 4835 | { /* ignore */ }
|
---|
| 4836 | finally
|
---|
| 4837 | {
|
---|
| 4838 | this.objRefMgr.endObjRelease();
|
---|
| 4839 | }
|
---|
| 4840 | }
|
---|
| 4841 | }
|
---|
| 4842 | }
|
---|
| 4843 | }
|
---|
| 4844 | }
|
---|
| 4845 |
|
---|
[53219] | 4846 | class VBoxTLSSocketFactory extends SSLSocketFactory
|
---|
| 4847 | {
|
---|
| 4848 | private final SSLSocketFactory sf;
|
---|
| 4849 |
|
---|
| 4850 | private void setupSocket(SSLSocket s)
|
---|
| 4851 | {
|
---|
| 4852 | String[] oldproto = s.getEnabledProtocols();
|
---|
| 4853 | List<String> protolist = new ArrayList<String>();
|
---|
| 4854 | for (int i = 0; i < oldproto.length; i++)
|
---|
| 4855 | if (oldproto[i].toUpperCase().startsWith("TLS"))
|
---|
| 4856 | protolist.add(oldproto[i]);
|
---|
| 4857 | String[] newproto = protolist.toArray(new String[protolist.size()]);
|
---|
| 4858 | s.setEnabledProtocols(newproto);
|
---|
| 4859 | }
|
---|
| 4860 |
|
---|
| 4861 | public VBoxTLSSocketFactory()
|
---|
| 4862 | {
|
---|
| 4863 | SSLSocketFactory tmp = null;
|
---|
| 4864 | try
|
---|
| 4865 | {
|
---|
| 4866 | SSLContext sc = SSLContext.getInstance("TLS");
|
---|
| 4867 | sc.init(null, null, null);
|
---|
| 4868 | tmp = sc.getSocketFactory();
|
---|
| 4869 | }
|
---|
| 4870 | catch (Exception e)
|
---|
| 4871 | {
|
---|
| 4872 | e.printStackTrace();
|
---|
| 4873 | }
|
---|
| 4874 | sf = tmp;
|
---|
| 4875 | }
|
---|
| 4876 |
|
---|
| 4877 | public static SocketFactory getDefault()
|
---|
| 4878 | {
|
---|
| 4879 | return new VBoxTLSSocketFactory();
|
---|
| 4880 | }
|
---|
| 4881 |
|
---|
| 4882 | public Socket createSocket(Socket socket, String host, int port,
|
---|
| 4883 | boolean autoClose) throws IOException, UnknownHostException
|
---|
| 4884 | {
|
---|
| 4885 | SSLSocket s = (SSLSocket)sf.createSocket(socket, host, port, autoClose);
|
---|
| 4886 | setupSocket(s);
|
---|
| 4887 | return s;
|
---|
| 4888 | }
|
---|
| 4889 |
|
---|
| 4890 | public Socket createSocket() throws IOException
|
---|
| 4891 | {
|
---|
| 4892 | SSLSocket s = (SSLSocket)sf.createSocket();
|
---|
| 4893 | setupSocket(s);
|
---|
| 4894 | return s;
|
---|
| 4895 | }
|
---|
| 4896 |
|
---|
| 4897 | public Socket createSocket(InetAddress host, int port) throws IOException
|
---|
| 4898 | {
|
---|
| 4899 | SSLSocket s = (SSLSocket)sf.createSocket(host, port);
|
---|
| 4900 | setupSocket(s);
|
---|
| 4901 | return s;
|
---|
| 4902 | }
|
---|
| 4903 |
|
---|
| 4904 | public Socket createSocket(InetAddress address, int port,
|
---|
| 4905 | InetAddress localAddress, int localPort) throws IOException
|
---|
| 4906 | {
|
---|
| 4907 | SSLSocket s = (SSLSocket)sf.createSocket(address, port, localAddress, localPort);
|
---|
| 4908 | setupSocket(s);
|
---|
| 4909 | return s;
|
---|
| 4910 | }
|
---|
| 4911 |
|
---|
| 4912 | public Socket createSocket(String host, int port) throws IOException, UnknownHostException
|
---|
| 4913 | {
|
---|
| 4914 | SSLSocket s = (SSLSocket)sf.createSocket(host, port);
|
---|
| 4915 | setupSocket(s);
|
---|
| 4916 | return s;
|
---|
| 4917 | }
|
---|
| 4918 |
|
---|
| 4919 | public Socket createSocket(String host, int port,
|
---|
| 4920 | InetAddress localHost, int localPort) throws IOException, UnknownHostException
|
---|
| 4921 | {
|
---|
| 4922 | SSLSocket s = (SSLSocket)sf.createSocket(host, port, localHost, localPort);
|
---|
| 4923 | setupSocket(s);
|
---|
| 4924 | return s;
|
---|
| 4925 | }
|
---|
| 4926 |
|
---|
| 4927 | public String[] getDefaultCipherSuites()
|
---|
| 4928 | {
|
---|
[61165] | 4929 | return sf.getDefaultCipherSuites();
|
---|
[53219] | 4930 | }
|
---|
| 4931 |
|
---|
| 4932 | public String[] getSupportedCipherSuites()
|
---|
| 4933 | {
|
---|
| 4934 | return sf.getSupportedCipherSuites();
|
---|
| 4935 | }
|
---|
| 4936 | }
|
---|
| 4937 |
|
---|
[69378] | 4938 |
|
---|
[30987] | 4939 | public class VirtualBoxManager
|
---|
| 4940 | {
|
---|
| 4941 | private static PortPool pool = new PortPool(true);
|
---|
[61365] | 4942 | private static final ObjectRefManager objMgr = new ObjectRefManager();
|
---|
[30987] | 4943 | protected VboxPortType port;
|
---|
| 4944 |
|
---|
[46478] | 4945 | private IVirtualBox vbox;
|
---|
[30987] | 4946 |
|
---|
| 4947 | private VirtualBoxManager()
|
---|
| 4948 | {
|
---|
| 4949 | }
|
---|
| 4950 |
|
---|
| 4951 | public static void initPerThread()
|
---|
| 4952 | {
|
---|
| 4953 | }
|
---|
| 4954 |
|
---|
| 4955 | public static void deinitPerThread()
|
---|
| 4956 | {
|
---|
| 4957 | }
|
---|
| 4958 |
|
---|
| 4959 | public void connect(String url, String username, String passwd)
|
---|
| 4960 | {
|
---|
| 4961 | this.port = pool.getPort();
|
---|
[46478] | 4962 | try
|
---|
| 4963 | {
|
---|
[30987] | 4964 | ((BindingProvider)port).getRequestContext().
|
---|
[37457] | 4965 | put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
|
---|
[53243] | 4966 |
|
---|
| 4967 | // Unfortunately there is no official way to make JAX-WS use
|
---|
| 4968 | // TLS only, which means that a rather tedious approach is
|
---|
| 4969 | // unavoidable (implementing a TLS only SSLSocketFactory,
|
---|
| 4970 | // because the default one associated with a TLS SSLContext
|
---|
| 4971 | // happily uses SSLv2/3 handshakes, which make TLS servers
|
---|
| 4972 | // drop the connection), and additionally a not standardized,
|
---|
| 4973 | // shotgun approach is needed to make the relevant JAX-WS
|
---|
| 4974 | // implementations use this factory.
|
---|
[53219] | 4975 | VBoxTLSSocketFactory sf = new VBoxTLSSocketFactory();
|
---|
| 4976 | ((BindingProvider)port).getRequestContext().
|
---|
| 4977 | put("com.sun.xml.internal.ws.transport.https.client.SSLSocketFactory", sf);
|
---|
[53243] | 4978 | ((BindingProvider)port).getRequestContext().
|
---|
| 4979 | put("com.sun.xml.ws.transport.https.client.SSLSocketFactory", sf);
|
---|
[53219] | 4980 |
|
---|
[37457] | 4981 | String handle = port.iWebsessionManagerLogon(username, passwd);
|
---|
[61365] | 4982 | this.objMgr.preventObjRelease();
|
---|
| 4983 | try
|
---|
| 4984 | {
|
---|
| 4985 | this.vbox = new IVirtualBox(handle, this.objMgr, port);
|
---|
| 4986 | }
|
---|
| 4987 | finally
|
---|
| 4988 | {
|
---|
| 4989 | this.objMgr.allowObjRelease();
|
---|
| 4990 | }
|
---|
[46478] | 4991 | }
|
---|
| 4992 | catch (Throwable t)
|
---|
| 4993 | {
|
---|
| 4994 | if (this.port != null && pool != null)
|
---|
| 4995 | {
|
---|
[30987] | 4996 | pool.releasePort(this.port);
|
---|
[37456] | 4997 | this.port = null;
|
---|
[37457] | 4998 | }
|
---|
| 4999 | // we have to throw smth derived from RuntimeException
|
---|
[61203] | 5000 | throw new VBoxException(t.getMessage(), t, this.objMgr, this.port);
|
---|
[37457] | 5001 | }
|
---|
[30987] | 5002 | }
|
---|
| 5003 |
|
---|
| 5004 | public void connect(String url, String username, String passwd,
|
---|
| 5005 | Map<String, Object> requestContext, Map<String, Object> responseContext)
|
---|
| 5006 | {
|
---|
[37457] | 5007 | this.port = pool.getPort();
|
---|
[46478] | 5008 | try
|
---|
| 5009 | {
|
---|
[37457] | 5010 | ((BindingProvider)port).getRequestContext();
|
---|
| 5011 | if (requestContext != null)
|
---|
| 5012 | ((BindingProvider)port).getRequestContext().putAll(requestContext);
|
---|
[30987] | 5013 |
|
---|
[37457] | 5014 | if (responseContext != null)
|
---|
| 5015 | ((BindingProvider)port).getResponseContext().putAll(responseContext);
|
---|
[30987] | 5016 |
|
---|
[37457] | 5017 | ((BindingProvider)port).getRequestContext().
|
---|
[30987] | 5018 | put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
|
---|
| 5019 | String handle = port.iWebsessionManagerLogon(username, passwd);
|
---|
[61365] | 5020 | this.objMgr.preventObjRelease();
|
---|
| 5021 | try
|
---|
| 5022 | {
|
---|
| 5023 | this.vbox = new IVirtualBox(handle, this.objMgr, port);
|
---|
| 5024 | }
|
---|
| 5025 | finally
|
---|
| 5026 | {
|
---|
| 5027 | this.objMgr.allowObjRelease();
|
---|
| 5028 | }
|
---|
[46478] | 5029 | }
|
---|
| 5030 | catch (Throwable t)
|
---|
| 5031 | {
|
---|
| 5032 | if (this.port != null && pool != null)
|
---|
| 5033 | {
|
---|
[37457] | 5034 | pool.releasePort(this.port);
|
---|
| 5035 | this.port = null;
|
---|
| 5036 | }
|
---|
| 5037 | // we have to throw smth derived from RuntimeException
|
---|
[61203] | 5038 | throw new VBoxException(t.getMessage(), t, this.objMgr, this.port);
|
---|
[37457] | 5039 | }
|
---|
[30987] | 5040 | }
|
---|
| 5041 |
|
---|
| 5042 | public void disconnect()
|
---|
| 5043 | {
|
---|
[46478] | 5044 | if (this.port == null)
|
---|
| 5045 | return;
|
---|
| 5046 |
|
---|
| 5047 | try
|
---|
| 5048 | {
|
---|
| 5049 | if (this.vbox != null && port != null)
|
---|
| 5050 | port.iWebsessionManagerLogoff(this.vbox.getWrapped());
|
---|
| 5051 | }
|
---|
| 5052 | catch (InvalidObjectFaultMsg e)
|
---|
| 5053 | {
|
---|
[61203] | 5054 | throw new VBoxException(e.getMessage(), e, this.objMgr, this.port);
|
---|
[46478] | 5055 | }
|
---|
| 5056 | catch (RuntimeFaultMsg e)
|
---|
| 5057 | {
|
---|
[61203] | 5058 | throw new VBoxException(e.getMessage(), e, this.objMgr, this.port);
|
---|
[46478] | 5059 | }
|
---|
| 5060 | finally
|
---|
| 5061 | {
|
---|
| 5062 | if (this.port != null)
|
---|
| 5063 | {
|
---|
[37457] | 5064 | pool.releasePort(this.port);
|
---|
| 5065 | this.port = null;
|
---|
| 5066 | }
|
---|
[30987] | 5067 | }
|
---|
| 5068 | }
|
---|
| 5069 |
|
---|
[56306] | 5070 | public String getClientAPIVersion()
|
---|
| 5071 | {
|
---|
| 5072 | return "]]></xsl:text>
|
---|
| 5073 | <xsl:value-of select="substring($G_vboxApiSuffix, 2)" />
|
---|
| 5074 | <xsl:text><![CDATA[";
|
---|
| 5075 | }
|
---|
| 5076 |
|
---|
[30987] | 5077 | public IVirtualBox getVBox()
|
---|
| 5078 | {
|
---|
| 5079 | return this.vbox;
|
---|
| 5080 | }
|
---|
| 5081 |
|
---|
| 5082 | public ISession getSessionObject()
|
---|
| 5083 | {
|
---|
| 5084 | if (this.vbox == null)
|
---|
[46478] | 5085 | throw new VBoxException("connect first");
|
---|
| 5086 | try
|
---|
| 5087 | {
|
---|
| 5088 | String handle = port.iWebsessionManagerGetSessionObject(this.vbox.getWrapped());
|
---|
[61365] | 5089 | this.objMgr.preventObjRelease();
|
---|
| 5090 | try
|
---|
| 5091 | {
|
---|
| 5092 | return new ISession(handle, this.objMgr, port);
|
---|
| 5093 | }
|
---|
| 5094 | finally
|
---|
| 5095 | {
|
---|
| 5096 | this.objMgr.allowObjRelease();
|
---|
| 5097 | }
|
---|
[30987] | 5098 | }
|
---|
[46478] | 5099 | catch (InvalidObjectFaultMsg e)
|
---|
| 5100 | {
|
---|
[61203] | 5101 | throw new VBoxException(e.getMessage(), e, this.objMgr, this.port);
|
---|
[46478] | 5102 | }
|
---|
| 5103 | catch (RuntimeFaultMsg e)
|
---|
| 5104 | {
|
---|
[61203] | 5105 | throw new VBoxException(e.getMessage(), e, this.objMgr, this.port);
|
---|
[46478] | 5106 | }
|
---|
[30987] | 5107 | }
|
---|
| 5108 |
|
---|
[31008] | 5109 | public ISession openMachineSession(IMachine m) throws Exception
|
---|
[30987] | 5110 | {
|
---|
| 5111 | ISession s = getSessionObject();
|
---|
[31019] | 5112 | m.lockMachine(s, LockType.Shared);
|
---|
[31008] | 5113 | return s;
|
---|
[30987] | 5114 | }
|
---|
| 5115 |
|
---|
| 5116 | public void closeMachineSession(ISession s)
|
---|
| 5117 | {
|
---|
| 5118 | if (s != null)
|
---|
[31070] | 5119 | s.unlockMachine();
|
---|
[30987] | 5120 | }
|
---|
| 5121 |
|
---|
[31166] | 5122 | public static synchronized VirtualBoxManager createInstance(String home)
|
---|
[30987] | 5123 | {
|
---|
[31166] | 5124 | return new VirtualBoxManager();
|
---|
[30987] | 5125 | }
|
---|
| 5126 |
|
---|
| 5127 | public IEventListener createListener(Object sink)
|
---|
| 5128 | {
|
---|
[46478] | 5129 | throw new VBoxException("no active listeners here");
|
---|
[30987] | 5130 | }
|
---|
[46478] | 5131 |
|
---|
[30987] | 5132 | public void cleanup()
|
---|
| 5133 | {
|
---|
[40674] | 5134 | disconnect();
|
---|
[30987] | 5135 | deinitPerThread();
|
---|
| 5136 | }
|
---|
| 5137 |
|
---|
[46478] | 5138 | public void waitForEvents(long tmo)
|
---|
[30987] | 5139 | {
|
---|
[56625] | 5140 | try
|
---|
| 5141 | {
|
---|
| 5142 | Thread.sleep(tmo);
|
---|
| 5143 | }
|
---|
| 5144 | catch (InterruptedException ie)
|
---|
| 5145 | {
|
---|
| 5146 | }
|
---|
[30987] | 5147 | }
|
---|
| 5148 |
|
---|
[46478] | 5149 | protected void finalize() throws Throwable
|
---|
[30987] | 5150 | {
|
---|
[46478] | 5151 | try
|
---|
| 5152 | {
|
---|
[40674] | 5153 | cleanup();
|
---|
| 5154 | }
|
---|
[46478] | 5155 | catch(Exception e)
|
---|
| 5156 | {
|
---|
| 5157 | }
|
---|
| 5158 | finally
|
---|
| 5159 | {
|
---|
[40674] | 5160 | super.finalize();
|
---|
| 5161 | }
|
---|
| 5162 | }
|
---|
[30987] | 5163 | }
|
---|
| 5164 | ]]></xsl:text>
|
---|
[46478] | 5165 | </xsl:if>
|
---|
[30987] | 5166 |
|
---|
[46478] | 5167 | <xsl:call-template name="endFile">
|
---|
| 5168 | <xsl:with-param name="file" select="'VirtualBoxManager.java'" />
|
---|
| 5169 | </xsl:call-template>
|
---|
[30987] | 5170 | </xsl:template>
|
---|
| 5171 |
|
---|
| 5172 |
|
---|
| 5173 | <xsl:template match="/">
|
---|
| 5174 |
|
---|
| 5175 | <xsl:if test="not($G_vboxApiSuffix)">
|
---|
| 5176 | <xsl:call-template name="fatalError">
|
---|
| 5177 | <xsl:with-param name="msg" select="'G_vboxApiSuffix must be given'" />
|
---|
| 5178 | </xsl:call-template>
|
---|
| 5179 | </xsl:if>
|
---|
| 5180 |
|
---|
[46478] | 5181 | <xsl:if test="not($filelistonly='')">
|
---|
[53936] | 5182 | <xsl:value-of select="concat($filelistonly, ' :=')"/>
|
---|
[46478] | 5183 | </xsl:if>
|
---|
| 5184 |
|
---|
[30987] | 5185 | <!-- Handwritten files -->
|
---|
| 5186 | <xsl:call-template name="emitHandwritten"/>
|
---|
| 5187 |
|
---|
| 5188 | <xsl:choose>
|
---|
| 5189 | <xsl:when test="$G_vboxGlueStyle='xpcom'">
|
---|
| 5190 | <xsl:call-template name="emitHandwrittenXpcom"/>
|
---|
| 5191 | </xsl:when>
|
---|
| 5192 |
|
---|
| 5193 | <xsl:when test="$G_vboxGlueStyle='mscom'">
|
---|
| 5194 | <xsl:call-template name="emitHandwrittenMscom"/>
|
---|
| 5195 | </xsl:when>
|
---|
| 5196 |
|
---|
| 5197 | <xsl:when test="$G_vboxGlueStyle='jaxws'">
|
---|
| 5198 | <xsl:call-template name="emitHandwrittenJaxws"/>
|
---|
| 5199 | </xsl:when>
|
---|
| 5200 |
|
---|
| 5201 | <xsl:otherwise>
|
---|
| 5202 | <xsl:call-template name="fatalError">
|
---|
| 5203 | <xsl:with-param name="msg" select="'Style unknown (root)'" />
|
---|
| 5204 | </xsl:call-template>
|
---|
| 5205 | </xsl:otherwise>
|
---|
| 5206 | </xsl:choose>
|
---|
| 5207 |
|
---|
| 5208 | <!-- Enums -->
|
---|
| 5209 | <xsl:for-each select="//enum">
|
---|
| 5210 | <xsl:call-template name="genEnum">
|
---|
| 5211 | <xsl:with-param name="enumname" select="@name" />
|
---|
| 5212 | <xsl:with-param name="filename" select="concat(@name, '.java')" />
|
---|
| 5213 | </xsl:call-template>
|
---|
| 5214 | </xsl:for-each>
|
---|
| 5215 |
|
---|
| 5216 | <!-- Interfaces -->
|
---|
| 5217 | <xsl:for-each select="//interface">
|
---|
| 5218 | <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
|
---|
| 5219 | <xsl:variable name="module" select="current()/ancestor::module/@name"/>
|
---|
| 5220 |
|
---|
| 5221 | <xsl:choose>
|
---|
| 5222 | <xsl:when test="$G_vboxGlueStyle='jaxws'">
|
---|
[46478] | 5223 | <xsl:if test="not($module) and not(@wsmap='suppress')">
|
---|
[30987] | 5224 | <xsl:call-template name="genIface">
|
---|
| 5225 | <xsl:with-param name="ifname" select="@name" />
|
---|
| 5226 | <xsl:with-param name="filename" select="concat(@name, '.java')" />
|
---|
| 5227 | </xsl:call-template>
|
---|
| 5228 | </xsl:if>
|
---|
| 5229 | </xsl:when>
|
---|
| 5230 |
|
---|
[69736] | 5231 | <xsl:when test="$G_vboxGlueStyle='xpcom'">
|
---|
| 5232 | <!-- We don't need WSDL-specific nor MIDL-specific interfaces here -->
|
---|
[69738] | 5233 | <xsl:if test="not(@internal='yes') and not($self_target='wsdl') and not($module) and not($self_target='midl')">
|
---|
[69736] | 5234 | <xsl:call-template name="genIface">
|
---|
| 5235 | <xsl:with-param name="ifname" select="@name" />
|
---|
| 5236 | <xsl:with-param name="filename" select="concat(@name, '.java')" />
|
---|
| 5237 | </xsl:call-template>
|
---|
| 5238 | </xsl:if>
|
---|
[69737] | 5239 | </xsl:when>
|
---|
[69736] | 5240 |
|
---|
[30987] | 5241 | <xsl:otherwise>
|
---|
| 5242 | <!-- We don't need WSDL-specific interfaces here -->
|
---|
[51448] | 5243 | <xsl:if test="not(@internal='yes') and not($self_target='wsdl') and not($module)">
|
---|
[30987] | 5244 | <xsl:call-template name="genIface">
|
---|
| 5245 | <xsl:with-param name="ifname" select="@name" />
|
---|
| 5246 | <xsl:with-param name="filename" select="concat(@name, '.java')" />
|
---|
| 5247 | </xsl:call-template>
|
---|
| 5248 | </xsl:if>
|
---|
| 5249 | </xsl:otherwise>
|
---|
| 5250 |
|
---|
| 5251 | </xsl:choose>
|
---|
| 5252 | </xsl:for-each>
|
---|
[46478] | 5253 |
|
---|
| 5254 | <xsl:if test="not($filelistonly='')">
|
---|
[53936] | 5255 | <xsl:value-of select="concat($G_sNewLine, $G_sNewLine)"/>
|
---|
[46478] | 5256 | </xsl:if>
|
---|
| 5257 |
|
---|
[30987] | 5258 | </xsl:template>
|
---|
| 5259 | </xsl:stylesheet>
|
---|