<xsl:strip-space elements="*"/>
<xsl:template name="fileheader">
<xsl:param name="name" />
* Copyright (C) 2010-2014 Oracle Corporation
* This file is part of the VirtualBox SDK, as available from
* redistribute it
and/or modify it under the terms of the GNU Lesser General
* Public License as published by the Free Software Foundation, in version 2.1
* as it comes in the "
COPYING.LIB" file of the VirtualBox SDK distribution.
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
<xsl:value-of select="concat(' * ', $name)"/>
* DO NOT EDIT! This is a generated file.
<xsl:template name="startFile">
<xsl:param name="file" />
<xsl:param name="package" />
<xsl:when test="$filelistonly=''">
<xsl:value-of select="concat(' // ##### BEGINFILE "', $G_vboxDirPrefix, $file, '" ')" />
<xsl:call-template name="fileheader">
<xsl:with-param name="name" select="$file" />
<xsl:value-of select="concat('package ', $package, '; ')" />
<xsl:value-of select="concat('import ', $G_virtualBoxPackageCom, '.*; ')" />
<xsl:when test="$G_vboxGlueStyle='xpcom'">
<xsl:when test="$G_vboxGlueStyle='mscom'">
<xsl:when test="$G_vboxGlueStyle='jaxws'">
<xsl:call-template name="fatalError">
<xsl:with-param name="msg" select="'no header rule (startFile)'" />
<xsl:value-of select="concat('	', $G_vboxDirPrefix, $file, ' \ ')"/>
<xsl:template name="endFile">
<xsl:param name="file" />
<xsl:if test="$filelistonly=''">
<xsl:value-of select="concat(' // ##### ENDFILE "', $file, '" ')" />
<xsl:template name="string-replace">
<xsl:param name="haystack"/>
<xsl:param name="needle"/>
<xsl:param name="replacement"/>
<xsl:param name="onlyfirst" select="false"/>
<xsl:when test="contains($haystack, $needle)">
<xsl:value-of select="substring-before($haystack, $needle)"/>
<xsl:value-of select="$replacement"/>
<xsl:when test="$onlyfirst = 'true'">
<xsl:value-of select="substring-after($haystack, $needle)"/>
<xsl:call-template name="string-replace">
<xsl:with-param name="haystack" select="substring-after($haystack, $needle)"/>
<xsl:with-param name="needle" select="$needle"/>
<xsl:with-param name="replacement" select="$replacement"/>
<xsl:value-of select="$haystack"/>
<xsl:template name="string-trim">
<xsl:variable name="begin" select="substring($text, 1, 1)"/>
<xsl:when test="$begin = ' ' or $begin = ' ' or $begin = ' '">
<xsl:call-template name="string-trim">
<xsl:with-param name="text" select="substring($text, 2)"/>
<xsl:variable name="end" select="substring($text, string-length($text), 1)"/>
<xsl:when test="$end = ' ' or $end = ' ' or $end = ' '">
<xsl:call-template name="string-trim">
<xsl:with-param name="text" select="substring($text, 1, string-length($text) - 1)"/>
<xsl:when test="contains($text, ' ')">
<xsl:variable name="tmptext">
<xsl:call-template name="string-replace">
<xsl:with-param name="haystack" select="$text"/>
<xsl:with-param name="needle" select="' '"/>
<xsl:with-param name="replacement" select="' '"/>
<xsl:call-template name="string-trim">
<xsl:with-param name="text" select="$tmptext"/>
<xsl:value-of select="$text"/>
<xsl:template match="*/text()">
<!-- TODO: strip out @c/@a for now. long term solution is changing that to a
tag in the xidl file, and translate it when generating doxygen etc. -->
<xsl:variable name="rep1">
<xsl:call-template name="string-replace">
<xsl:with-param name="haystack" select="."/>
<xsl:with-param name="needle" select="'@c'"/>
<xsl:with-param name="replacement" select="''"/>
<xsl:variable name="rep2">
<xsl:call-template name="string-replace">
<xsl:with-param name="haystack" select="$rep1"/>
<xsl:with-param name="needle" select="'@a'"/>
<xsl:with-param name="replacement" select="''"/>
<xsl:variable name="rep3">
<xsl:call-template name="string-replace">
<xsl:with-param name="haystack" select="$rep2"/>
<xsl:with-param name="needle" select="'@todo'"/>
<xsl:with-param name="replacement" select="'TODO'"/>
<!-- &, < and > must remain as they are or javadoc 8 throws a fit. -->
<xsl:variable name="rep4">
<xsl:call-template name="string-replace">
<xsl:with-param name="haystack" select="$rep3"/>
<xsl:with-param name="needle" select="'&'"/>
<xsl:with-param name="replacement" select="'&amp;'"/>
<xsl:variable name="rep5">
<xsl:call-template name="string-replace">
<xsl:with-param name="haystack" select="$rep4"/>
<xsl:with-param name="needle" select="'<'"/>
<xsl:with-param name="replacement" select="'&lt;'"/>
<xsl:variable name="rep6">
<xsl:call-template name="string-replace">
<xsl:with-param name="haystack" select="$rep5"/>
<xsl:with-param name="needle" select="'>'"/>
<xsl:with-param name="replacement" select="'&gt;'"/>
<xsl:variable name="rep7">
<xsl:call-template name="string-trim">
<xsl:with-param name="text" select="$rep6"/>
<xsl:value-of select="$rep7"/>
* all sub-elements that are not explicitly matched are considered to be
* html tags and copied w/o modifications
<xsl:template match="desc//*">
<xsl:variable name="tagname" select="local-name()"/>
<xsl:value-of select="concat('<', $tagname)"/>
<xsl:if test="$tagname = 'table'"> <!-- javadoc 8 fudge -->
<xsl:text> summary=""</xsl:text>
<xsl:text>></xsl:text>
<xsl:value-of select="concat('</', $tagname, '>')"/>
<xsl:template name="emit_refsig">
<xsl:param name="context"/>
<xsl:param name="identifier"/>
<xsl:when test="//enum[@name=$context]/const[@name=$identifier]">
<xsl:value-of select="$identifier"/>
<xsl:when test="//interface[@name=$context]/method[@name=$identifier]">
<xsl:value-of select="$identifier"/>
<xsl:for-each select="//interface[@name=$context]/method[@name=$identifier]/param">
<xsl:if test="@dir!='return'">
<xsl:if test="position() > 1">
<xsl:when test="@dir='out'">
<xsl:text>Holder</xsl:text>
<xsl:call-template name="typeIdl2Glue">
<xsl:with-param name="type" select="@type"/>
<xsl:with-param name="safearray" select="@safearray"/>
<xsl:with-param name="skiplisttype" select="'yes'"/>
<xsl:when test="//interface[@name=$context]/attribute[@name=$identifier]">
<xsl:call-template name="makeGetterName">
<xsl:with-param name="attrname" select="$identifier" />
<xsl:call-template name="fatalError">
<xsl:with-param name="msg" select="concat('unknown reference destination in @see/@link: context=', $context, ' identifier=', $identifier)" />
<xsl:template match="desc//link">
<xsl:text>{@link </xsl:text>
<xsl:apply-templates select="." mode="middle"/>
<xsl:template match="link" mode="middle">
<xsl:variable name="linktext">
<xsl:call-template name="string-replace">
<xsl:with-param name="haystack" select="@to"/>
<xsl:with-param name="needle" select="'_'"/>
<xsl:with-param name="replacement" select="'#'"/>
<xsl:with-param name="onlyfirst" select="'true'"/>
<xsl:when test="substring($linktext, 1, 1)='#'">
<xsl:variable name="context">
<xsl:when test="local-name(../..)='interface' or local-name(../..)='enum'">
<xsl:value-of select="../../@name"/>
<xsl:when test="local-name(../../..)='interface' or local-name(../../..)='enum'">
<xsl:value-of select="../../../@name"/>
<xsl:when test="local-name(../../../..)='interface' or local-name(../../../..)='enum'">
<xsl:value-of select="../../../../@name"/>
<xsl:when test="local-name(../../../../..)='interface' or local-name(../../../../..)='enum'">
<xsl:value-of select="../../../../../@name"/>
<xsl:when test="local-name(../../../../../..)='interface' or local-name(../../../../../..)='enum'">
<xsl:value-of select="../../../../../../@name"/>
<xsl:call-template name="fatalError">
<xsl:with-param name="msg" select="concat('cannot determine context for identifier ', $linktext)" />
<xsl:variable name="linkname">
<xsl:value-of select="substring($linktext, 2)"/>
<xsl:call-template name="emit_refsig">
<xsl:with-param name="context" select="$context"/>
<xsl:with-param name="identifier" select="$linkname"/>
<xsl:when test="contains($linktext, '::')">
<xsl:variable name="context">
<xsl:value-of select="substring-before($linktext, '::')"/>
<xsl:variable name="linkname">
<xsl:value-of select="substring-after($linktext, '::')"/>
<xsl:value-of select="concat($G_virtualBoxPackage, '.', $context, '#')"/>
<xsl:call-template name="emit_refsig">
<xsl:with-param name="context" select="$context"/>
<xsl:with-param name="identifier" select="$linkname"/>
<xsl:value-of select="concat($G_virtualBoxPackage, '.', $linktext)"/>
<xsl:if test="not(@internal='yes')">
<xsl:text> NOTE: </xsl:text>
<xsl:text> </xsl:text>
<!-- TODO: quirk in our xidl file: only one <see> tag with <link> nested
into it, translate this to multiple @see lines and strip the rest.
Should be replaced in the xidl by multiple <see> without nested tag -->
<xsl:text> </xsl:text>
<xsl:apply-templates match="link"/>
<xsl:text>@see </xsl:text>
<xsl:apply-templates select="." mode="middle"/>
<xsl:text> </xsl:text>
* common comment prologue (handles group IDs)
<xsl:template match="desc" mode="begin">
<xsl:param name="id" select="@group | preceding::descGroup[1]/@id"/>
<xsl:text> /** </xsl:text>
<xsl:value-of select="concat(' @ingroup ', $id, ' ')"/>
* common middle part of the comment block
<xsl:template match="desc" mode="middle">
<xsl:apply-templates select="text() | *[not(self::note or self::see)]"/>
<xsl:apply-templates select="note"/>
<xsl:apply-templates select="see"/>
* result part of the comment block
<xsl:template match="desc" mode="results">
<xsl:text> Expected result codes: </xsl:text>
<xsl:text><table summary=""> </xsl:text>
<xsl:for-each select="result">
<xsl:text><tr></xsl:text>
<xsl:value-of select="concat('<td>@link ::', @name, ' ', @name, '</td>')"/>
<xsl:value-of select="concat('<td>', @name, '</td>')"/>
<xsl:text><td></xsl:text>
<xsl:apply-templates select="text() | *[not(self::note or self::see or
<xsl:text></td></tr> </xsl:text>
<xsl:text></table> </xsl:text>
* translates the string to uppercase
<xsl:template name="uppercase">
<xsl:param name="str" select="."/>
<xsl:value-of select="translate($str, $G_lowerCase, $G_upperCase)"/>
<xsl:template match="desc" mode="interface">
<xsl:apply-templates select="." mode="begin"/>
<xsl:apply-templates select="." mode="middle"/>
<xsl:text> Interface ID: <tt>{</xsl:text>
<xsl:call-template name="uppercase">
<xsl:with-param name="str" select="../@uuid"/>
<xsl:text>}</tt> */ </xsl:text>
* comment for attribute getters
<xsl:template match="desc" mode="attribute_get">
<xsl:apply-templates select="." mode="begin"/>
<xsl:apply-templates select="text() | *[not(self::note or self::see or self::result)]"/>
<xsl:apply-templates select="." mode="results"/>
<xsl:apply-templates select="note"/>
<xsl:text> @return </xsl:text>
<xsl:call-template name="typeIdl2Glue">
<xsl:with-param name="type" select="../@type"/>
<xsl:with-param name="safearray" select="../@safearray"/>
<xsl:with-param name="doubleescape">yes</xsl:with-param>
<xsl:text> </xsl:text>
<xsl:apply-templates select="see"/>
<xsl:text>*/ </xsl:text>
* comment for attribute setters
<xsl:template match="desc" mode="attribute_set">
<xsl:apply-templates select="." mode="begin"/>
<xsl:apply-templates select="text() | *[not(self::note or self::see or self::result)]"/>
<xsl:apply-templates select="." mode="results"/>
<xsl:apply-templates select="note"/>
<xsl:text> @param value </xsl:text>
<xsl:call-template name="typeIdl2Glue">
<xsl:with-param name="type" select="../@type"/>
<xsl:with-param name="safearray" select="../@safearray"/>
<xsl:with-param name="doubleescape">yes</xsl:with-param>
<xsl:text> </xsl:text>
<xsl:apply-templates select="see"/>
<xsl:text> */ </xsl:text>
<xsl:template match="desc" mode="method">
<xsl:apply-templates select="." mode="begin"/>
<xsl:apply-templates select="text() | *[not(self::note or self::see or self::result)]"/>
<xsl:for-each select="../param">
<xsl:apply-templates select="desc"/>
<xsl:apply-templates select="." mode="results"/>
<xsl:apply-templates select="note"/>
<xsl:apply-templates select="see"/>
<xsl:text> */ </xsl:text>
* comment for method parameters
<xsl:if test="text() | *[not(self::note or self::see)]">
<xsl:when test="../@dir='return'">
<xsl:text> @return </xsl:text>
<xsl:text> @param </xsl:text>
<xsl:value-of select="../@name"/>
<xsl:apply-templates select="text() | *[not(self::note or self::see)]"/>
<xsl:text> </xsl:text>
<xsl:template match="desc" mode="enum">
<xsl:apply-templates select="." mode="begin"/>
<xsl:apply-templates select="." mode="middle"/>
<xsl:text> Interface ID: <tt>{</xsl:text>
<xsl:call-template name="uppercase">
<xsl:with-param name="str" select="../@uuid"/>
<xsl:text>}</tt> */ </xsl:text>
* comment for enum values
<xsl:template match="desc" mode="enum_const">
<xsl:apply-templates select="." mode="begin"/>
<xsl:apply-templates select="." mode="middle"/>
<xsl:text> */ </xsl:text>
* ignore descGroups by default (processed in /idl)
<xsl:template match="descGroup"/>
<!-- actual code generation -->
<xsl:template name="genEnum">
<xsl:param name="enumname" />
<xsl:param name="filename" />
<xsl:call-template name="startFile">
<xsl:with-param name="file" select="$filename" />
<xsl:with-param name="package" select="$G_virtualBoxPackage" />
<xsl:if test="$filelistonly=''">
<xsl:apply-templates select="desc" mode="enum"/>
<xsl:value-of select="concat('public enum ', $enumname, ' ')" />
<xsl:text>{ </xsl:text>
<xsl:for-each select="const">
<xsl:apply-templates select="desc" mode="enum_const"/>
<xsl:variable name="enumconst" select="@name" />
<xsl:value-of select="concat(' ', $enumconst, '(', @value, ')')" />
<xsl:when test="not(position()=last())">
<xsl:text>, </xsl:text>
<xsl:text>; </xsl:text>
<xsl:text> </xsl:text>
<xsl:text> private final int value; </xsl:text>
<xsl:value-of select="concat(' ', $enumname, '(int v) ')" />
<xsl:text> { </xsl:text>
<xsl:text> value = v; </xsl:text>
<xsl:text> } </xsl:text>
<xsl:text> public int value() </xsl:text>
<xsl:text> { </xsl:text>
<xsl:text> return value; </xsl:text>
<xsl:text> } </xsl:text>
<xsl:value-of select="concat(' public static ', $enumname, ' fromValue(long v) ')" />
<xsl:text> { </xsl:text>
<xsl:value-of select="concat(' for (', $enumname, ' c: ', $enumname, '.values()) ')" />
<xsl:text> { </xsl:text>
<xsl:text> if (
c.value == (int)v) </xsl:text>
<xsl:text> { </xsl:text>
<xsl:text> return c; </xsl:text>
<xsl:text> } </xsl:text>
<xsl:text> } </xsl:text>
<xsl:text> throw new IllegalArgumentException(
Long.toString(v)); </xsl:text>
<xsl:text> } </xsl:text>
<xsl:value-of select="concat(' public static ', $enumname, ' fromValue(String v) ')" />
<xsl:text> { </xsl:text>
<xsl:value-of select="concat(' return valueOf(', $enumname, '.class, v); ')" />
<xsl:text> } </xsl:text>
<xsl:text>} </xsl:text>
<xsl:call-template name="endFile">
<xsl:with-param name="file" select="$filename" />
<xsl:template name="startExcWrapper">
<xsl:text> try </xsl:text>
<xsl:text> { </xsl:text>
<xsl:template name="endExcWrapper">
<xsl:when test="$G_vboxGlueStyle='xpcom'">
<xsl:text> } </xsl:text>
<xsl:text> { </xsl:text>
<xsl:text> throw new VBoxException(
e.getMessage(), e); </xsl:text>
<xsl:text> } </xsl:text>
<xsl:when test="$G_vboxGlueStyle='mscom'">
<xsl:text> } </xsl:text>
<xsl:text> { </xsl:text>
<xsl:text> throw new VBoxException(
e.getMessage(), e); </xsl:text>
<xsl:text> } </xsl:text>
<xsl:when test="$G_vboxGlueStyle='jaxws'">
<xsl:text> } </xsl:text>
<xsl:text> catch (InvalidObjectFaultMsg e) </xsl:text>
<xsl:text> { </xsl:text>
<xsl:text> } </xsl:text>
<xsl:text> catch (RuntimeFaultMsg e) </xsl:text>
<xsl:text> { </xsl:text>
<xsl:text> } </xsl:text>
<xsl:call-template name="fatalError">
<xsl:with-param name="msg" select="'no header rule (startFile)'" />
<xsl:template name="wrappedName">
<xsl:param name="ifname" />
<xsl:when test="$G_vboxGlueStyle='xpcom'">
<xsl:when test="$G_vboxGlueStyle='mscom'">
<xsl:when test="$G_vboxGlueStyle='jaxws'">
<xsl:text>String</xsl:text>
<xsl:call-template name="fatalError">
<xsl:with-param name="msg" select="'no wrapper naming rule defined (wrappedName)'" />
<xsl:template name="fullClassName">
<xsl:param name="name" />
<xsl:param name="origname" />
<xsl:param name="collPrefix" />
<xsl:when test="//enum[@name=$name] or //enum[@name=$origname]">
<xsl:value-of select="concat($G_virtualBoxPackage, concat('.', $name))" />
<xsl:when test="//interface[@name=$name]">
<xsl:value-of select="concat($G_virtualBoxPackage, concat('.', $name))" />
<xsl:call-template name="fatalError">
<xsl:with-param name="msg" select="concat('fullClassName: Type "', $name, '" is not supported.')" />
<xsl:template name="typeIdl2Glue">
<xsl:param name="type" />
<xsl:param name="safearray" />
<xsl:param name="forceelem" />
<xsl:param name="skiplisttype" />
<xsl:param name="doubleescape" />
<xsl:variable name="needarray" select="($safearray='yes') and not($forceelem='yes')" />
<xsl:variable name="needlist" select="($needarray) and not($type='octet')" />
<xsl:if test="($needlist)">
<xsl:text>List</xsl:text>
<xsl:if test="not($skiplisttype='yes')">
<xsl:when test="$doubleescape='yes'">
<xsl:text>&lt;</xsl:text>
<xsl:text><</xsl:text>
<xsl:if test="not($needlist) or not($skiplisttype='yes')">
<xsl:variable name="javatypefield" select="exsl:node-set($G_aSharedTypes)/type[@idlname=$type]/@javaname" />
<xsl:when test="string-length($javatypefield)">
<xsl:value-of select="$javatypefield" />
<!-- not a standard type: then it better be one of the types defined in the XIDL -->
<xsl:when test="$type='$unknown'">IUnknown</xsl:when>
<xsl:call-template name="fullClassName">
<xsl:with-param name="name" select="$type" />
<xsl:with-param name="collPrefix" select="''"/>
<xsl:when test="($needlist)">
<xsl:if test="not($skiplisttype='yes')">
<xsl:when test="$doubleescape='yes'">
<xsl:text>&gt;</xsl:text>
<xsl:text>></xsl:text>
<xsl:when test="($needarray)">
typeIdl2Back: converts $type into a type as used by the backend.
<xsl:template name="typeIdl2Back">
<xsl:param name="type" />
<xsl:param name="safearray" />
<xsl:param name="forceelem" />
<xsl:when test="($G_vboxGlueStyle='xpcom')">
<xsl:variable name="needarray" select="($safearray='yes') and not($forceelem='yes')" />
<xsl:when test="$type='long long'">
<xsl:text>long</xsl:text>
<xsl:when test="$type='unsigned long'">
<xsl:text>long</xsl:text>
<xsl:when test="$type='long'">
<xsl:when test="$type='unsigned short'">
<xsl:when test="$type='short'">
<xsl:text>short</xsl:text>
<xsl:when test="$type='octet'">
<xsl:text>byte</xsl:text>
<xsl:when test="$type='boolean'">
<xsl:text>boolean</xsl:text>
<xsl:when test="$type='$unknown'">
<xsl:text>nsISupports</xsl:text>
<xsl:when test="$type='wstring'">
<xsl:text>String</xsl:text>
<xsl:when test="$type='uuid'">
<xsl:text>String</xsl:text>
<xsl:when test="//interface[@name=$type]/@wsmap='struct'">
<xsl:call-template name="wrappedName">
<xsl:with-param name="ifname" select="$type" />
<xsl:when test="//interface[@name=$type]">
<xsl:call-template name="wrappedName">
<xsl:with-param name="ifname" select="$type" />
<xsl:when test="//enum[@name=$type]">
<xsl:text>long</xsl:text>
<xsl:call-template name="fullClassName">
<xsl:with-param name="name" select="$type" />
<xsl:if test="$needarray">
<xsl:when test="($G_vboxGlueStyle='mscom')">
<xsl:text>Variant</xsl:text>
<xsl:when test="($G_vboxGlueStyle='jaxws')">
<xsl:variable name="needarray" select="($safearray='yes' and not($type='octet')) and not($forceelem='yes')" />
<xsl:if test="$needarray">
<xsl:text>List<</xsl:text>
<xsl:when test="$type='$unknown'">
<xsl:text>String</xsl:text>
<xsl:when test="//interface[@name=$type]/@wsmap='managed'">
<xsl:text>String</xsl:text>
<xsl:when test="//interface[@name=$type]/@wsmap='struct'">
<xsl:value-of select="concat($G_virtualBoxPackageCom, '.', $type)" />
<xsl:when test="//enum[@name=$type]">
<xsl:value-of select="concat($G_virtualBoxPackageCom, '.', $type)" />
<!-- we encode byte arrays as Base64 strings. -->
<xsl:when test="$type='octet'">
<xsl:text>/*base64*/String</xsl:text>
<xsl:when test="$type='long long'">
<xsl:text>Long</xsl:text>
<xsl:when test="$type='unsigned long'">
<xsl:text>Long</xsl:text>
<xsl:when test="$type='long'">
<xsl:text>Integer</xsl:text>
<xsl:when test="$type='unsigned short'">
<xsl:text>Integer</xsl:text>
<xsl:when test="$type='short'">
<xsl:text>Short</xsl:text>
<xsl:when test="$type='boolean'">
<xsl:text>Boolean</xsl:text>
<xsl:when test="$type='wstring'">
<xsl:text>String</xsl:text>
<xsl:when test="$type='uuid'">
<xsl:text>String</xsl:text>
<xsl:call-template name="fatalError">
<xsl:with-param name="msg" select="concat('Unhandled type ', $type, ' (typeIdl2Back)')" />
<xsl:if test="$needarray">
<xsl:text>></xsl:text>
<xsl:call-template name="fatalError">
<xsl:with-param name="msg" select="'Write typeIdl2Back for this style (typeIdl2Back)'" />
<xsl:template name="cookOutParamXpcom">
<xsl:param name="value"/>
<xsl:param name="idltype"/>
<xsl:param name="safearray"/>
<xsl:variable name="isstruct"
select="//interface[@name=$idltype]/@wsmap='struct'" />
<xsl:variable name="gluetype">
<xsl:call-template name="typeIdl2Glue">
<xsl:with-param name="type" select="$idltype" />
<xsl:with-param name="safearray" select="$safearray" />
<xsl:variable name="elemgluetype">
<xsl:if test="$safearray='yes'">
<xsl:call-template name="typeIdl2Glue">
<xsl:with-param name="type" select="$idltype" />
<xsl:with-param name="safearray" select="'no'" />
<xsl:with-param name="forceelem" select="'yes'" />
<xsl:when test="//interface[@name=$idltype] or $idltype='$unknown'">
<xsl:when test="$safearray='yes'">
<xsl:variable name="elembacktype">
<xsl:call-template name="typeIdl2Back">
<xsl:with-param name="type" select="$idltype" />
<xsl:with-param name="safearray" select="$safearray" />
<xsl:with-param name="forceelem" select="'yes'" />
<xsl:value-of select="concat('
Helper.wrap2(', $elemgluetype, '.class, ', $elembacktype, '.class, ', $value, ')')"/>
<xsl:value-of select="concat('(', $value, ' != null) ? new ', $gluetype, '(', $value, ') : null')" />
<xsl:when test="//enum[@name=$idltype]">
<xsl:when test="$safearray='yes'">
<xsl:variable name="elembacktype">
<xsl:call-template name="typeIdl2Back">
<xsl:with-param name="type" select="$idltype" />
<xsl:with-param name="safearray" select="$safearray" />
<xsl:with-param name="forceelem" select="'yes'" />
<xsl:value-of select="concat('
Helper.wrapEnum(', $elemgluetype, '.class, ', $value, ')')"/>
<xsl:value-of select="concat($gluetype, '.fromValue(', $value, ')')"/>
<xsl:when test="($safearray='yes') and ($idltype='octet')">
<xsl:value-of select="$value"/>
<xsl:when test="$safearray='yes'">
<xsl:value-of select="concat('
Helper.wrap(', $value, ')')"/>
<xsl:value-of select="$value"/>
<xsl:template name="cookOutParamMscom">
<xsl:param name="value"/>
<xsl:param name="idltype"/>
<xsl:param name="safearray"/>
<xsl:variable name="gluetype">
<xsl:call-template name="typeIdl2Glue">
<xsl:with-param name="type" select="$idltype" />
<xsl:with-param name="safearray" select="$safearray" />
<xsl:when test="$safearray='yes'">
<xsl:variable name="elemgluetype">
<xsl:call-template name="typeIdl2Glue">
<xsl:with-param name="type" select="$idltype" />
<xsl:with-param name="safearray" select="'no'" />
<xsl:with-param name="forceelem" select="'yes'" />
<xsl:when test="($idltype='octet')">
<xsl:value-of select="concat('
Helper.wrap(', $elemgluetype, '.class, ', $value, '.toSafeArray())')"/>
<xsl:when test="//interface[@name=$idltype] or $idltype='$unknown'">
<xsl:value-of select="concat('
Helper.wrapDispatch(', $gluetype, '.class, ', $value, '.getDispatch())')"/>
<xsl:when test="//enum[@name=$idltype]">
<xsl:value-of select="concat($gluetype, '.fromValue(', $value, '.getInt())')"/>
<xsl:when test="$idltype='wstring'">
<xsl:value-of select="concat($value, '.getString()')"/>
<xsl:when test="$idltype='uuid'">
<xsl:value-of select="concat($value, '.getString()')"/>
<xsl:when test="$idltype='boolean'">
<xsl:value-of select="concat($value, '.toBoolean()')"/>
<xsl:when test="$idltype='unsigned short'">
<xsl:value-of select="concat('(int)', $value, '.getShort()')"/>
<xsl:when test="$idltype='short'">
<xsl:value-of select="concat($value, '.getShort()')"/>
<xsl:when test="$idltype='long'">
<xsl:value-of select="concat($value, '.getInt()')"/>
<xsl:when test="$idltype='unsigned long'">
<xsl:value-of select="concat('(long)', $value, '.getInt()')"/>
<xsl:when test="$idltype='long'">
<xsl:value-of select="concat($value, '.getInt()')"/>
<xsl:when test="$idltype='long long'">
<xsl:value-of select="concat($value, '.getLong()')"/>
<xsl:call-template name="fatalError">
<xsl:with-param name="msg" select="concat('Unhandled type' , $idltype, ' (cookOutParamMscom)')" />
<xsl:template name="cookOutParamJaxws">
<xsl:param name="value"/>
<xsl:param name="idltype"/>
<xsl:param name="safearray"/>
<xsl:variable name="isstruct"
select="//interface[@name=$idltype]/@wsmap='struct'" />
<xsl:variable name="gluetype">
<xsl:call-template name="typeIdl2Glue">
<xsl:with-param name="type" select="$idltype" />
<xsl:with-param name="safearray" select="$safearray" />
<xsl:when test="$safearray='yes'">
<xsl:variable name="elemgluetype">
<xsl:call-template name="typeIdl2Glue">
<xsl:with-param name="type" select="$idltype" />
<xsl:with-param name="safearray" select="''" />
<xsl:with-param name="forceelem" select="'yes'" />
<xsl:variable name="elembacktype">
<xsl:call-template name="typeIdl2Back">
<xsl:with-param name="type" select="$idltype" />
<xsl:with-param name="safearray" select="''" />
<xsl:with-param name="forceelem" select="'yes'" />
<xsl:when test="$isstruct">
<xsl:value-of select="concat('
Helper.wrap2(', $elemgluetype, '.class, ', $elembacktype, '.class, port, ', $value, ')')"/>
<xsl:when test="//enum[@name=$idltype]">
<xsl:value-of select="concat('
Helper.convertEnums(', $elembacktype, '.class, ', $elemgluetype, '.class, ', $value, ')')"/>
<xsl:when test="//interface[@name=$idltype] or $idltype='$unknown'">
<xsl:value-of select="concat('
Helper.wrap(', $elemgluetype, '.class, port, ', $value, ')')"/>
<xsl:when test="$idltype='octet'">
<xsl:value-of select="$value" />
<xsl:when test="//enum[@name=$idltype]">
<xsl:value-of select="concat($gluetype, '.fromValue(', $value, '.value())')"/>
<xsl:when test="$idltype='boolean'">
<xsl:value-of select="$value"/>
<xsl:when test="$idltype='long long'">
<xsl:value-of select="$value"/>
<xsl:when test="$idltype='unsigned long long'">
<xsl:value-of select="$value"/>
<xsl:when test="$idltype='long'">
<xsl:value-of select="$value"/>
<xsl:when test="$idltype='unsigned long'">
<xsl:value-of select="$value"/>
<xsl:when test="$idltype='short'">
<xsl:value-of select="$value"/>
<xsl:when test="$idltype='unsigned short'">
<xsl:value-of select="$value"/>
<xsl:when test="$idltype='wstring'">
<xsl:value-of select="$value"/>
<xsl:when test="$idltype='uuid'">
<xsl:value-of select="$value"/>
<xsl:when test="$isstruct">
<xsl:value-of select="concat('(', $value, ' != null) ? new ', $gluetype, '(', $value, ', port) : null')" />
<xsl:when test="//interface[@name=$idltype] or $idltype='$unknown'">
<!-- if the MOR string is empty, that means NULL, so return NULL instead of an object then -->
<xsl:value-of select="concat('(', $value, '.length() > 0) ? new ', $gluetype, '(', $value, ', port) : null')" />
<xsl:call-template name="fatalError">
<xsl:with-param name="msg" select="concat('Unhandled type ', $idltype, ' (cookOutParamJaxws)')" />
<xsl:template name="cookOutParam">
<xsl:param name="value"/>
<xsl:param name="idltype"/>
<xsl:param name="safearray"/>
<xsl:when test="($G_vboxGlueStyle='xpcom')">
<xsl:call-template name="cookOutParamXpcom">
<xsl:with-param name="value" select="$value" />
<xsl:with-param name="idltype" select="$idltype" />
<xsl:with-param name="safearray" select="$safearray" />
<xsl:when test="($G_vboxGlueStyle='mscom')">
<xsl:call-template name="cookOutParamMscom">
<xsl:with-param name="value" select="$value" />
<xsl:with-param name="idltype" select="$idltype" />
<xsl:with-param name="safearray" select="$safearray" />
<xsl:when test="($G_vboxGlueStyle='jaxws')">
<xsl:call-template name="cookOutParamJaxws">
<xsl:with-param name="value" select="$value" />
<xsl:with-param name="idltype" select="$idltype" />
<xsl:with-param name="safearray" select="$safearray" />
<xsl:call-template name="fatalError">
<xsl:with-param name="msg" select="'Unhandled style(cookOutParam)'" />
<xsl:template name="cookInParamXpcom">
<xsl:param name="value"/>
<xsl:param name="idltype"/>
<xsl:param name="safearray"/>
<xsl:variable name="isstruct"
select="//interface[@name=$idltype]/@wsmap='struct'" />
<xsl:variable name="gluetype">
<xsl:call-template name="typeIdl2Glue">
<xsl:with-param name="type" select="$idltype" />
<xsl:with-param name="safearray" select="$safearray" />
<xsl:variable name="backtype">
<xsl:call-template name="typeIdl2Back">
<xsl:with-param name="type" select="$idltype" />
<xsl:with-param name="safearray" select="$safearray" />
<xsl:variable name="elemgluetype">
<xsl:if test="$safearray='yes'">
<xsl:call-template name="typeIdl2Glue">
<xsl:with-param name="type" select="$idltype" />
<xsl:with-param name="safearray" select="'no'" />
<xsl:with-param name="forceelem" select="'yes'" />
<xsl:when test="//interface[@name=$idltype]">
<xsl:when test="$safearray='yes'">
<xsl:variable name="elembacktype">
<xsl:call-template name="typeIdl2Back">
<xsl:with-param name="type" select="$idltype" />
<xsl:with-param name="safearray" select="$safearray" />
<xsl:with-param name="forceelem" select="'yes'" />
<xsl:value-of select="concat('
Helper.unwrap2(', $elemgluetype, '.class, ', $elembacktype, '.class, ', $value, ')')"/>
<xsl:value-of select="concat('(', $value, ' != null) ? ', $value, '.getTypedWrapped() : null')" />
<xsl:when test="$idltype='$unknown'">
<xsl:when test="$safearray='yes'">
<xsl:value-of select="concat('(', $value, ' != null) ? (nsISupports)', $value, '.getWrapped() : null')" />
<xsl:when test="//enum[@name=$idltype]">
<xsl:when test="$safearray='yes'">
<xsl:value-of select="concat('
Helper.unwrapEnum(', $elemgluetype, '.class, ', $value, ')')"/>
<xsl:value-of select="concat($value, '.value()')"/>
<xsl:when test="($idltype='octet') and ($safearray='yes')">
<xsl:value-of select="$value"/>
<xsl:when test="$safearray='yes'">
<xsl:when test="$idltype='boolean'">
<xsl:when test="($idltype='long') or ($idltype='unsigned long') or ($idltype='integer')">
<xsl:when test="($idltype='short') or ($idltype='unsigned short')">
<xsl:when test="($idltype='unsigned long long') or ($idltype='long long')">
<xsl:when test="($idltype='wstring') or ($idltype='uuid')">
<xsl:value-of select="$value"/>
<xsl:value-of select="$value"/>
<xsl:template name="cookInParamMscom">
<xsl:param name="value"/>
<xsl:param name="idltype"/>
<xsl:param name="safearray"/>
<xsl:variable name="gluetype">
<xsl:call-template name="typeIdl2Glue">
<xsl:with-param name="type" select="$idltype" />
<xsl:with-param name="safearray" select="$safearray" />
<xsl:variable name="backtype">
<xsl:call-template name="typeIdl2Back">
<xsl:with-param name="type" select="$idltype" />
<xsl:with-param name="safearray" select="$safearray" />
<xsl:variable name="elemgluetype">
<xsl:if test="$safearray='yes'">
<xsl:call-template name="typeIdl2Glue">
<xsl:with-param name="type" select="$idltype" />
<xsl:with-param name="safearray" select="'no'" />
<xsl:with-param name="forceelem" select="'yes'" />
<xsl:when test="//interface[@name=$idltype]">
<xsl:when test="$safearray='yes'">
<xsl:variable name="elembacktype">
<xsl:call-template name="typeIdl2Back">
<xsl:with-param name="type" select="$idltype" />
<xsl:with-param name="safearray" select="$safearray" />
<xsl:with-param name="forceelem" select="'yes'" />
<!-- Sometimes javac needs a boost of self-confidence regarding
varargs calls, and this (Object) cast makes sure that it calls
the varargs method - as if there is any other. -->
<xsl:value-of select="concat('(Object)
Helper.unwrap2(', $elemgluetype, '.class, ', $elembacktype, '.class, ', $value, ')')"/>
<xsl:value-of select="concat('(', $value, ' != null) ? ', $value, '.getTypedWrapped() : null')" />
<xsl:when test="$idltype='$unknown'">
<xsl:when test="$safearray='yes'">
<xsl:value-of select="concat('(', $value, ' != null) ? (Dispatch)', $value, '.getWrapped() : null')" />
<xsl:when test="//enum[@name=$idltype]">
<xsl:when test="$safearray='yes'">
<xsl:value-of select="concat('
Helper.unwrapEnum(', $elemgluetype, '.class, ', $value, ')')"/>
<xsl:value-of select="concat($value, '.value()')"/>
<xsl:when test="$idltype='boolean'">
<xsl:when test="$safearray='yes'">
<xsl:value-of select="concat('new Variant(', $value, ')')"/>
<xsl:when test="($idltype='short') or ($idltype='unsigned short')">
<xsl:when test="$safearray='yes'">
<xsl:value-of select="concat('new Variant(', $value, ')')"/>
<xsl:when test="($idltype='long') or ($idltype='unsigned long')">
<xsl:when test="$safearray='yes'">
<xsl:value-of select="concat('new Variant(', $value, ')')"/>
<xsl:when test="($idltype='wstring') or ($idltype='uuid')">
<xsl:when test="$safearray='yes'">
<xsl:value-of select="concat('new Variant(', $value, ')')"/>
<xsl:when test="($idltype='unsigned long long') or ($idltype='long long')">
<xsl:when test="$safearray='yes'">
<xsl:value-of select="concat('new Variant(', $value, '.longValue())')"/>
<xsl:when test="($idltype='octet') and ($safearray='yes')">
<xsl:value-of select="$value"/>
<xsl:call-template name="fatalError">
<xsl:with-param name="msg" select="concat('Unhandled type: ', $idltype)" />
<xsl:template name="cookInParamJaxws">
<xsl:param name="value"/>
<xsl:param name="idltype"/>
<xsl:param name="safearray"/>
<xsl:variable name="isstruct"
select="//interface[@name=$idltype]/@wsmap='struct'" />
<xsl:variable name="gluetype">
<xsl:call-template name="typeIdl2Glue">
<xsl:with-param name="type" select="$idltype" />
<xsl:with-param name="safearray" select="$safearray" />
<xsl:variable name="elemgluetype">
<xsl:if test="$safearray='yes'">
<xsl:call-template name="typeIdl2Glue">
<xsl:with-param name="type" select="$idltype" />
<xsl:with-param name="safearray" select="'no'" />
<xsl:with-param name="forceelem" select="'yes'" />
<xsl:when test="//interface[@name=$idltype] or $idltype='$unknown'">
<xsl:when test="@safearray='yes'">
<xsl:value-of select="concat('((', $value, ' == null) ? null :', $value, '.getWrapped())')" />
<xsl:when test="//enum[@name=$idltype]">
<xsl:when test="$safearray='yes'">
<xsl:variable name="elembacktype">
<xsl:call-template name="typeIdl2Back">
<xsl:with-param name="type" select="$idltype" />
<xsl:with-param name="safearray" select="'no'" />
<xsl:with-param name="forceelem" select="'yes'" />
<xsl:value-of select="concat('
Helper.convertEnums(', $elemgluetype, '.class, ', $elembacktype, '.class, ', $value, ')')"/>
<xsl:variable name="backtype">
<xsl:call-template name="typeIdl2Back">
<xsl:with-param name="type" select="$idltype" />
<xsl:with-param name="safearray" select="'no'" />
<xsl:with-param name="forceelem" select="'yes'" />
<xsl:value-of select="concat($backtype, '.fromValue(', $value, '.name())')"/>
<xsl:when test="($idltype='octet') and ($safearray='yes')">
<xsl:value-of select="$value"/>
<xsl:template name="cookInParam">
<xsl:param name="value"/>
<xsl:param name="idltype"/>
<xsl:param name="safearray"/>
<xsl:when test="($G_vboxGlueStyle='xpcom')">
<xsl:call-template name="cookInParamXpcom">
<xsl:with-param name="value" select="$value" />
<xsl:with-param name="idltype" select="$idltype" />
<xsl:with-param name="safearray" select="$safearray" />
<xsl:when test="($G_vboxGlueStyle='mscom')">
<xsl:call-template name="cookInParamMscom">
<xsl:with-param name="value" select="$value" />
<xsl:with-param name="idltype" select="$idltype" />
<xsl:with-param name="safearray" select="$safearray" />
<xsl:when test="($G_vboxGlueStyle='jaxws')">
<xsl:call-template name="cookInParamJaxws">
<xsl:with-param name="value" select="$value" />
<xsl:with-param name="idltype" select="$idltype" />
<xsl:with-param name="safearray" select="$safearray" />
<xsl:call-template name="fatalError">
<xsl:with-param name="msg" select="'Unhandled style (cookInParam)'" />
<!-- Invoke backend method, including parameter conversion -->
<xsl:template name="genBackMethodCall">
<xsl:param name="ifname"/>
<xsl:param name="methodname"/>
<xsl:param name="retval"/>
<xsl:when test="($G_vboxGlueStyle='xpcom')">
<xsl:if test="param[@dir='return']">
<xsl:value-of select="concat($retval, ' = ')" />
<xsl:value-of select="concat('getTypedWrapped().', $methodname, '(')"/>
<xsl:for-each select="param">
<xsl:when test="@dir='return'">
<xsl:if test="@safearray='yes'">
<xsl:text>null</xsl:text>
<xsl:when test="@dir='out'">
<xsl:if test="@safearray='yes'">
<xsl:text>null, </xsl:text>
<xsl:value-of select="concat('tmp_', @name)" />
<xsl:when test="@dir='in'">
<xsl:if test="(@safearray='yes') and not(@type = 'octet')">
<xsl:value-of select="concat(@name, ' != null ? ', @name, '.size() : 0, ')" />
<xsl:variable name="unwrapped">
<xsl:call-template name="cookInParam">
<xsl:with-param name="value" select="@name" />
<xsl:with-param name="idltype" select="@type" />
<xsl:with-param name="safearray" select="@safearray" />
<xsl:value-of select="$unwrapped"/>
<xsl:call-template name="fatalError">
<xsl:with-param name="msg" select="concat('Unsupported param dir: ', @dir, '".')" />
<xsl:if test="not(position()=last()) and not(following-sibling::param[1]/@dir='return' and not(following-sibling::param[1]/@safearray='yes'))">
<xsl:text>); </xsl:text>
<xsl:when test="($G_vboxGlueStyle='mscom')">
<xsl:if test="param[@dir='return']">
<xsl:value-of select="concat($retval, ' = ')" />
<xsl:value-of select="concat('
Helper.invoke(getTypedWrapped(), "', $methodname, '" ')"/>
<xsl:for-each select="param[not(@dir='return')]">
<xsl:when test="@dir='out'">
<xsl:value-of select="concat('tmp_', @name)" />
<xsl:when test="@dir='in'">
<xsl:variable name="unwrapped">
<xsl:call-template name="cookInParam">
<xsl:with-param name="value" select="@name" />
<xsl:with-param name="idltype" select="@type" />
<xsl:with-param name="safearray" select="@safearray" />
<xsl:value-of select="$unwrapped"/>
<xsl:text>); </xsl:text>
<xsl:when test="($G_vboxGlueStyle='jaxws')">
<xsl:variable name="jaxwsmethod">
<xsl:call-template name="makeJaxwsMethod">
<xsl:with-param name="ifname" select="$ifname" />
<xsl:with-param name="methodname" select="$methodname" />
<xsl:variable name="portArg">
<xsl:if test="not(//interface[@name=$ifname]/@wsmap='global')">
<xsl:variable name="paramsinout" select="param[@dir='in' or @dir='out']" />
<xsl:if test="param[@dir='return'] and not(param[@dir='out'])">
<xsl:value-of select="concat($retval, ' = ')" />
<xsl:value-of select="concat('port.', $jaxwsmethod, '(', $portArg)" />
<xsl:if test="$paramsinout and not($portArg='')">
<!-- jax-ws has an oddity: if both out params and a return value exist,
then the return value is moved to the function's argument list... -->
<xsl:when test="param[@dir='out'] and param[@dir='return']">
<xsl:for-each select="param">
<xsl:when test="@dir='return'">
<xsl:value-of select="$retval"/>
<xsl:when test="@dir='out'">
<xsl:value-of select="concat('tmp_', @name)" />
<xsl:call-template name="cookInParam">
<xsl:with-param name="value" select="@name" />
<xsl:with-param name="idltype" select="@type" />
<xsl:with-param name="safearray" select="@safearray" />
<xsl:if test="not(position()=last())">
<xsl:for-each select="$paramsinout">
<xsl:when test="@dir='return'">
<xsl:value-of select="$retval"/>
<xsl:when test="@dir='out'">
<xsl:value-of select="concat('tmp_', @name)" />
<xsl:call-template name="cookInParam">
<xsl:with-param name="value" select="@name" />
<xsl:with-param name="idltype" select="@type" />
<xsl:with-param name="safearray" select="@safearray" />
<xsl:if test="not(position()=last())">
<xsl:text>); </xsl:text>
<xsl:call-template name="fatalError">
<xsl:with-param name="msg" select="'Style unknown (genBackMethodCall)'" />
<xsl:template name="genGetterCall">
<xsl:param name="ifname"/>
<xsl:param name="gettername"/>
<xsl:param name="backtype"/>
<xsl:param name="retval"/>
<xsl:when test="$G_vboxGlueStyle='xpcom'">
<xsl:value-of select="concat(' ', $backtype, ' ', $retval, ' = getTypedWrapped().', $gettername, '(')" />
<xsl:if test="@safearray">
<xsl:text>null</xsl:text>
<xsl:text>); </xsl:text>
<xsl:when test="$G_vboxGlueStyle='mscom'">
<xsl:value-of select="concat(' ', $backtype, ' ', $retval, ' =
Dispatch.get(getTypedWrapped(), "', @name, '"); ')" />
<xsl:when test="$G_vboxGlueStyle='jaxws'">
<xsl:variable name="jaxwsGetter">
<xsl:call-template name="makeJaxwsMethod">
<xsl:with-param name="ifname" select="$ifname" />
<xsl:with-param name="methodname" select="$gettername" />
<xsl:value-of select="concat(' ', $backtype, ' ', $retval, ' = port.', $jaxwsGetter, '(obj); ')" />
<xsl:call-template name="fatalError">
<xsl:with-param name="msg" select="'Style unknown (genGetterCall)'" />
<xsl:template name="genSetterCall">
<xsl:param name="ifname"/>
<xsl:param name="settername"/>
<xsl:param name="value"/>
<xsl:when test="$G_vboxGlueStyle='xpcom'">
<xsl:value-of select="concat(' getTypedWrapped().', $settername, '(', $value, '); ')" />
<xsl:when test="$G_vboxGlueStyle='mscom'">
<xsl:value-of select="concat('
Dispatch.put(getTypedWrapped(), "', @name, '", ', $value, '); ')" />
<xsl:when test="$G_vboxGlueStyle='jaxws'">
<xsl:variable name="jaxwsSetter">
<xsl:call-template name="makeJaxwsMethod">
<xsl:with-param name="ifname" select="$ifname" />
<xsl:with-param name="methodname" select="$settername" />
<xsl:value-of select="concat(' port.', $jaxwsSetter, '(obj, ', $value, '); ')" />
<xsl:call-template name="fatalError">
<xsl:with-param name="msg" select="'Style unknown (genSetterCall)'" />
<xsl:template name="genStructWrapperJaxws">
<xsl:param name="ifname"/>
<xsl:value-of select="concat(' private ', $G_virtualBoxPackageCom, '.', $ifname, ' real; ')"/>
<xsl:text> private VboxPortType port; </xsl:text>
<xsl:value-of select="concat(' public ', $ifname, '(', $G_virtualBoxPackageCom, '.', $ifname, ' real, VboxPortType port) ')" />
<xsl:text> { </xsl:text>
<xsl:text> } </xsl:text>
<xsl:for-each select="attribute">
<xsl:variable name="attrname"><xsl:value-of select="@name" /></xsl:variable>
<xsl:variable name="attrtype"><xsl:value-of select="@type" /></xsl:variable>
<xsl:variable name="attrsafearray"><xsl:value-of select="@safearray" /></xsl:variable>
<xsl:if test="not(@wsmap = 'suppress')">
<xsl:if test="not(@readonly = 'yes')">
<xsl:call-template name="fatalError">
<xsl:with-param name="msg" select="concat('Non read-only struct (genStructWrapperJaxws) in interface ', $ifname, ', attribute ', $attrname)" />
<xsl:variable name="backgettername">
<!-- Stupid, but backend boolean getters called isFoo(), not getFoo() -->
<xsl:when test="$attrtype = 'boolean'">
<xsl:variable name="capsname">
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="$attrname" />
<xsl:value-of select="concat('is', $capsname)" />
<xsl:call-template name="makeGetterName">
<xsl:with-param name="attrname" select="$attrname" />
<xsl:variable name="gluegettername">
<xsl:call-template name="makeGetterName">
<xsl:with-param name="attrname" select="$attrname" />
<xsl:variable name="gluegettertype">
<xsl:call-template name="typeIdl2Glue">
<xsl:with-param name="type" select="$attrtype" />
<xsl:with-param name="safearray" select="@safearray" />
<xsl:variable name="backgettertype">
<xsl:call-template name="typeIdl2Back">
<xsl:with-param name="type" select="$attrtype" />
<xsl:with-param name="safearray" select="@safearray" />
<xsl:apply-templates select="desc" mode="attribute_get"/>
<xsl:value-of select="concat(' public ', $gluegettertype, ' ', $gluegettername, '() ')" />
<xsl:text> { </xsl:text>
<xsl:value-of select="concat(' ', $backgettertype, ' retVal = real.', $backgettername, '(); ')" />
<xsl:variable name="wrapped">
<xsl:call-template name="cookOutParam">
<xsl:with-param name="value" select="'retVal'" />
<xsl:with-param name="idltype" select="$attrtype" />
<xsl:with-param name="safearray" select="@safearray" />
<xsl:value-of select="concat(' return ', $wrapped, '; ')" />
<xsl:text> } </xsl:text>
<!-- Interface method wrapper -->
<xsl:template name="genMethod">
<xsl:param name="ifname"/>
<xsl:param name="methodname"/>
<xsl:when test="(param[@mod='ptr']) or (($G_vboxGlueStyle='jaxws') and (param[@type=($G_setSuppressedInterfaces/@name)]))" >
<xsl:value-of select="concat(' // Skipping method ', $methodname, ' for it has parameters with suppressed types ')" />
<xsl:when test="($G_vboxGlueStyle='jaxws') and (@wsmap = 'suppress')" >
<xsl:value-of select="concat(' // Skipping method ', $methodname, ' for it is suppressed ')" />
<xsl:variable name="hasReturnParms" select="param[@dir='return']" />
<xsl:variable name="hasOutParms" select="count(param[@dir='out']) > 0" />
<xsl:variable name="returnidltype" select="param[@dir='return']/@type" />
<xsl:variable name="returnidlsafearray" select="param[@dir='return']/@safearray" />
<xsl:if test="$hasOutParms and not($hasReturnParms) and (string-length(@wsmap) = 0) and (count(param[@dir='out']) = 1)">
<xsl:call-template name="fatalError">
<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')" />
<xsl:variable name="returngluetype">
<xsl:when test="$returnidltype">
<xsl:call-template name="typeIdl2Glue">
<xsl:with-param name="type" select="$returnidltype" />
<xsl:with-param name="safearray" select="$returnidlsafearray" />
<xsl:text>void</xsl:text>
<xsl:variable name="retValValue">
<xsl:when test="(param[@dir='out']) and ($G_vboxGlueStyle='jaxws')">
<xsl:text>retVal</xsl:text>
<xsl:apply-templates select="desc" mode="method"/>
<xsl:value-of select="concat(' public ', $returngluetype, ' ', $methodname, '(')" />
<xsl:variable name="paramsinout" select="param[@dir='in' or @dir='out']" />
<xsl:for-each select="exsl:node-set($paramsinout)">
<xsl:variable name="paramgluetype">
<xsl:call-template name="typeIdl2Glue">
<xsl:with-param name="type" select="@type" />
<xsl:with-param name="safearray" select="@safearray" />
<xsl:when test="@dir='out'">
<xsl:value-of select="concat('Holder<', $paramgluetype, '> ', @name)" />
<xsl:value-of select="concat($paramgluetype, ' ', @name)" />
<xsl:if test="not(position()=last())">
<xsl:text>) </xsl:text>
<xsl:text> { </xsl:text>
<xsl:call-template name="startExcWrapper"/>
<!-- declare temp out params -->
<xsl:for-each select="param[@dir='out']">
<xsl:variable name="backouttype">
<xsl:call-template name="typeIdl2Back">
<xsl:with-param name="type" select="@type" />
<xsl:with-param name="safearray" select="@safearray" />
<xsl:when test="$G_vboxGlueStyle='xpcom'">
<xsl:when test="$G_vboxGlueStyle='mscom'">
<xsl:value-of select="concat(' Variant tmp_', @name, ' = new Variant(); ')"/>
<xsl:when test="$G_vboxGlueStyle='jaxws'">
<xsl:call-template name="fatalError">
<xsl:with-param name="msg" select="'Handle out param (genMethod)'" />
<!-- declare return param, if any -->
<xsl:if test="$hasReturnParms">
<xsl:variable name="backrettype">
<xsl:call-template name="typeIdl2Back">
<xsl:with-param name="type" select="$returnidltype" />
<xsl:with-param name="safearray" select="$returnidlsafearray" />
<xsl:when test="(param[@dir='out']) and ($G_vboxGlueStyle='jaxws')">
<xsl:value-of select="concat(' ', $backrettype, ' retVal; ')"/>
<xsl:call-template name="genBackMethodCall">
<xsl:with-param name="ifname" select="$ifname" />
<xsl:with-param name="methodname" select="$methodname" />
<xsl:with-param name="retval" select="'retVal'" />
<!-- return out params -->
<xsl:for-each select="param[@dir='out']">
<xsl:variable name="varval">
<xsl:when test="$G_vboxGlueStyle='xpcom'">
<xsl:value-of select="concat('tmp_', @name, '[0]')" />
<xsl:when test="$G_vboxGlueStyle='mscom'">
<xsl:value-of select="concat('tmp_', @name)" />
<xsl:when test="$G_vboxGlueStyle='jaxws'">
<xsl:value-of select="concat('tmp_', @name, '.value')" />
<xsl:call-template name="fatalError">
<xsl:with-param name="msg" select="'Style unknown (genMethod, outparam)'" />
<xsl:variable name="wrapped">
<xsl:call-template name="cookOutParam">
<xsl:with-param name="value" select="$varval" />
<xsl:with-param name="idltype" select="@type" />
<xsl:with-param name="safearray" select="@safearray" />
<xsl:value-of select="concat(' ', @name, '.value = ', $wrapped, '; ')"/>
<xsl:if test="$hasReturnParms">
<!-- actual 'return' statement -->
<xsl:variable name="wrapped">
<xsl:call-template name="cookOutParam">
<xsl:with-param name="value" select="$retValValue" />
<xsl:with-param name="idltype" select="$returnidltype" />
<xsl:with-param name="safearray" select="$returnidlsafearray" />
<xsl:value-of select="concat(' return ', $wrapped, '; ')" />
<xsl:call-template name="endExcWrapper"/>
<xsl:text> } </xsl:text>
<!-- Callback interface method -->
<xsl:template name="genCbMethodDecl">
<xsl:param name="ifname"/>
<xsl:param name="methodname"/>
<xsl:when test="(param[@mod='ptr'])" >
<xsl:value-of select="concat(' // Skipping method ', $methodname, ' for it has parameters with suppressed types ')" />
<xsl:variable name="returnidltype" select="param[@dir='return']/@type" />
<xsl:variable name="returnidlsafearray" select="param[@dir='return']/@safearray" />
<xsl:variable name="returngluetype">
<xsl:when test="$returnidltype">
<xsl:call-template name="typeIdl2Glue">
<xsl:with-param name="type" select="$returnidltype" />
<xsl:with-param name="safearray" select="$returnidlsafearray" />
<xsl:text>void</xsl:text>
<xsl:value-of select="concat(' public ', $returngluetype, ' ', $methodname, '(')" />
<xsl:variable name="paramsinout" select="param[@dir='in' or @dir='out']" />
<xsl:for-each select="exsl:node-set($paramsinout)">
<xsl:variable name="paramgluetype">
<xsl:call-template name="typeIdl2Glue">
<xsl:with-param name="type" select="@type" />
<xsl:with-param name="safearray" select="@safearray" />
<xsl:when test="@dir='out'">
<xsl:value-of select="concat('Holder<', $paramgluetype, '> ', @name)" />
<xsl:value-of select="concat($paramgluetype, ' ', @name)" />
<xsl:if test="not(position()=last())">
<xsl:text>); </xsl:text>
<!-- queryInterface wrapper -->
<xsl:template name="genQI">
<xsl:param name="ifname"/>
<xsl:param name="uuid" />
<xsl:value-of select="concat(' public static ', $ifname, ' queryInterface(IUnknown obj) ')" />
<xsl:text> { </xsl:text>
<xsl:when test="$G_vboxGlueStyle='xpcom'">
<xsl:variable name="backtype">
<xsl:call-template name="typeIdl2Back">
<xsl:with-param name="type" select="$ifname" />
<xsl:text> nsISupports nsobj = obj != null ? (nsISupports)
obj.getWrapped() : null; </xsl:text>
<xsl:text> if (nsobj == null) return null; </xsl:text>
<xsl:value-of select="concat(' ', $backtype, ' qiobj =
Helper.queryInterface(nsobj, "{', $uuid, '}", ', $backtype, '.class); ')" />
<xsl:value-of select="concat(' return qiobj == null ? null : new ', $ifname, '(qiobj); ')" />
<xsl:when test="$G_vboxGlueStyle='mscom'">
<xsl:when test="$G_vboxGlueStyle='jaxws'">
<!-- bad, need to check that we really can be casted to this type -->
<xsl:call-template name="fatalError">
<xsl:with-param name="msg" select="'Style unknown (genQI)'" />
<xsl:text> } </xsl:text>
<xsl:template name="genCbMethodImpl">
<xsl:param name="ifname"/>
<xsl:param name="methodname"/>
<xsl:when test="(param[@mod='ptr'])" >
<xsl:value-of select="concat(' // Skipping method ', $methodname, ' for it has parameters with suppressed types ')" />
<xsl:variable name="hasReturnParms" select="param[@dir='return']" />
<xsl:variable name="returnidltype" select="param[@dir='return']/@type" />
<xsl:variable name="returnidlsafearray" select="param[@dir='return']/@safearray" />
<xsl:variable name="returnbacktype">
<xsl:when test="$returnidltype">
<xsl:call-template name="typeIdl2Back">
<xsl:with-param name="type" select="$returnidltype" />
<xsl:with-param name="safearray" select="$returnidlsafearray" />
<xsl:text>void</xsl:text>
<xsl:variable name="paramsinout" select="param[@dir='in' or @dir='out']" />
<xsl:when test="$G_vboxGlueStyle='xpcom'">
<xsl:value-of select="concat(' public ', $returnbacktype, ' ', $methodname, '(')" />
<xsl:for-each select="exsl:node-set($paramsinout)">
<xsl:variable name="parambacktype">
<xsl:call-template name="typeIdl2Back">
<xsl:with-param name="type" select="@type" />
<xsl:with-param name="safearray" select="@safearray" />
<xsl:when test="@dir='out'">
<xsl:value-of select="concat($parambacktype, '[] ', @name)" />
<xsl:if test="@safearray">
<xsl:value-of select="concat('long len_', @name, ', ')" />
<xsl:value-of select="concat($parambacktype, ' ', @name)" />
<xsl:if test="not(position()=last())">
<xsl:text>) </xsl:text>
<xsl:text> { </xsl:text>
<xsl:when test="$G_vboxGlueStyle='mscom'">
<xsl:variable name="capsname">
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="$methodname" />
<xsl:value-of select="concat(' public ', $returnbacktype, ' ', $capsname, '(')" />
<xsl:text>Variant _args[]) </xsl:text>
<xsl:text> { </xsl:text>
<xsl:for-each select="exsl:node-set($paramsinout)">
<xsl:variable name="parambacktype">
<xsl:call-template name="typeIdl2Back">
<xsl:with-param name="type" select="@type" />
<xsl:with-param name="safearray" select="@safearray" />
<xsl:value-of select="concat(' ', $parambacktype, ' ', @name, '=_args[', count(preceding-sibling::param), ']; ')" />
<xsl:call-template name="fatalError">
<xsl:with-param name="msg" select="'Style unknown (genSetterCall)'" />
<!-- declare temp out params -->
<xsl:for-each select="param[@dir='out']">
<xsl:variable name="glueouttype">
<xsl:call-template name="typeIdl2Glue">
<xsl:with-param name="type" select="@type" />
<xsl:with-param name="safearray" select="@safearray" />
<xsl:value-of select="concat(' Holder<', $glueouttype, '> tmp_', @name, ' = new Holder<', $glueouttype, '>(); ')"/>
<!-- declare return param, if any -->
<xsl:if test="$hasReturnParms">
<xsl:variable name="gluerettype">
<xsl:call-template name="typeIdl2Glue">
<xsl:with-param name="type" select="$returnidltype" />
<xsl:with-param name="safearray" select="$returnidlsafearray" />
<xsl:value-of select="concat(' ', $gluerettype, ' retVal = ')"/>
<xsl:value-of select="concat(' sink.', $methodname, '(')"/>
<xsl:for-each select="param[not(@dir='return')]">
<xsl:when test="@dir='out'">
<xsl:value-of select="concat('tmp_', @name)" />
<xsl:when test="@dir='in'">
<xsl:variable name="wrapped">
<xsl:call-template name="cookOutParam">
<xsl:with-param name="value" select="@name" />
<xsl:with-param name="idltype" select="@type" />
<xsl:with-param name="safearray" select="@safearray" />
<xsl:value-of select="$wrapped"/>
<xsl:call-template name="fatalError">
<xsl:with-param name="msg" select="concat('Unsupported param dir: ', @dir, '".')" />
<xsl:if test="not(position()=last())">
<xsl:text>); </xsl:text>
<!-- return out params -->
<xsl:for-each select="param[@dir='out']">
<xsl:variable name="unwrapped">
<xsl:call-template name="cookInParam">
<xsl:with-param name="value" select="concat('tmp_', @name, '.value')" />
<xsl:with-param name="idltype" select="@type" />
<xsl:with-param name="safearray" select="@safearray" />
<xsl:when test="$G_vboxGlueStyle='xpcom'">
<xsl:value-of select="concat(' ', @name, '[0] = ', $unwrapped, '; ')"/>
<xsl:when test="$G_vboxGlueStyle='mscom'">
<xsl:value-of select="concat(' _args[', count(preceding-sibling::param), '] = ', $unwrapped, '; ')"/>
<xsl:if test="$hasReturnParms">
<!-- actual 'return' statement -->
<xsl:variable name="unwrapped">
<xsl:call-template name="cookInParam">
<xsl:with-param name="value" select="'retVal'" />
<xsl:with-param name="idltype" select="$returnidltype" />
<xsl:with-param name="safearray" select="$returnidlsafearray" />
<xsl:value-of select="concat(' return ', $unwrapped, '; ')" />
<xsl:text> } </xsl:text>
<!-- Interface method -->
<xsl:template name="genIfaceWrapper">
<xsl:param name="ifname"/>
<xsl:variable name="wrappedType">
<xsl:call-template name="wrappedName">
<xsl:with-param name="ifname" select="$ifname" />
<xsl:when test="($G_vboxGlueStyle='jaxws')">
<xsl:value-of select="concat(' public ', $ifname, '(String wrapped, VboxPortType port) ')" />
<xsl:text> { </xsl:text>
<xsl:text> super(wrapped, port); </xsl:text>
<xsl:text> } </xsl:text>
<xsl:when test="($G_vboxGlueStyle='xpcom') or ($G_vboxGlueStyle='mscom')">
<xsl:value-of select="concat(' public ', $ifname, '(', $wrappedType, ' wrapped) ')" />
<xsl:text> { </xsl:text>
<xsl:text> super(wrapped); </xsl:text>
<xsl:text> } </xsl:text>
<!-- Typed wrapped object accessor -->
<xsl:value-of select="concat(' public ', $wrappedType, ' getTypedWrapped() ')" />
<xsl:text> { </xsl:text>
<xsl:value-of select="concat(' return (', $wrappedType, ') getWrapped(); ')" />
<xsl:text> } </xsl:text>
<xsl:call-template name="fatalError">
<xsl:with-param name="msg" select="'Style unknown (root, ctr)'" />
<xsl:for-each select="attribute[not(@mod='ptr')]">
<xsl:variable name="attrname"><xsl:value-of select="@name" /></xsl:variable>
<xsl:variable name="attrtype"><xsl:value-of select="@type" /></xsl:variable>
<xsl:variable name="attrsafearray"><xsl:value-of select="@safearray" /></xsl:variable>
<xsl:when test="($G_vboxGlueStyle='jaxws') and ($attrtype=($G_setSuppressedInterfaces/@name))">
<xsl:value-of select="concat(' // Skipping attribute ', $attrname, ' of suppressed type ', $attrtype, ' ')" />
<xsl:when test="($G_vboxGlueStyle='jaxws') and (@wsmap = 'suppress')" >
<xsl:value-of select="concat(' // Skipping attribute ', $attrname, ' for it is suppressed ')" />
<!-- emit getter method -->
<xsl:apply-templates select="desc" mode="attribute_get"/>
<xsl:variable name="gettername">
<xsl:call-template name="makeGetterName">
<xsl:with-param name="attrname" select="$attrname" />
<xsl:variable name="gluetype">
<xsl:call-template name="typeIdl2Glue">
<xsl:with-param name="type" select="$attrtype" />
<xsl:with-param name="safearray" select="@safearray" />
<xsl:variable name="backtype">
<xsl:call-template name="typeIdl2Back">
<xsl:with-param name="type" select="$attrtype" />
<xsl:with-param name="safearray" select="@safearray" />
<xsl:variable name="wrapped">
<xsl:call-template name="cookOutParam">
<xsl:with-param name="value" select="'retVal'" />
<xsl:with-param name="idltype" select="$attrtype" />
<xsl:with-param name="safearray" select="@safearray" />
<xsl:value-of select="concat(' public ', $gluetype, ' ', $gettername, '() ')" />
<xsl:text> { </xsl:text>
<xsl:call-template name="startExcWrapper"/>
<!-- Actual getter implementation -->
<xsl:call-template name="genGetterCall">
<xsl:with-param name="ifname" select="$ifname" />
<xsl:with-param name="gettername" select="$gettername" />
<xsl:with-param name="backtype" select="$backtype" />
<xsl:with-param name="retval" select="'retVal'" />
<xsl:value-of select="concat(' return ', $wrapped, '; ')" />
<xsl:call-template name="endExcWrapper"/>
<xsl:text> } </xsl:text>
<xsl:if test="not(@readonly = 'yes')">
<!-- emit setter method -->
<xsl:apply-templates select="desc" mode="attribute_set"/>
<xsl:variable name="settername"><xsl:call-template name="makeSetterName"><xsl:with-param name="attrname" select="$attrname" /></xsl:call-template></xsl:variable>
<xsl:variable name="unwrapped">
<xsl:call-template name="cookInParam">
<xsl:with-param name="ifname" select="$ifname" />
<xsl:with-param name="value" select="'value'" />
<xsl:with-param name="idltype" select="$attrtype" />
<xsl:with-param name="safearray" select="@safearray" />
<xsl:value-of select="concat(' public void ', $settername, '(', $gluetype, ' value) ')" />
<xsl:text> { </xsl:text>
<xsl:call-template name="startExcWrapper"/>
<!-- Actual setter implementation -->
<xsl:call-template name="genSetterCall">
<xsl:with-param name="ifname" select="$ifname" />
<xsl:with-param name="settername" select="$settername" />
<xsl:with-param name="value" select="$unwrapped" />
<xsl:call-template name="endExcWrapper"/>
<xsl:text> } </xsl:text>
<!-- emit queryInterface() *to* this class -->
<xsl:call-template name="genQI">
<xsl:with-param name="ifname" select="$ifname" />
<xsl:with-param name="uuid" select="@uuid" />
<xsl:for-each select="method">
<xsl:call-template name="genMethod">
<xsl:with-param name="ifname" select="$ifname" />
<xsl:with-param name="methodname" select="@name" />
<xsl:template name="genIface">
<xsl:param name="ifname" />
<xsl:param name="filename" />
<xsl:variable name="wsmap" select="@wsmap" />
<xsl:call-template name="startFile">
<xsl:with-param name="file" select="$filename" />
<xsl:with-param name="package" select="$G_virtualBoxPackage" />
<xsl:if test="$filelistonly=''">
<xsl:apply-templates select="desc" mode="interface"/>
<xsl:when test="($wsmap='struct') and ($G_vboxGlueStyle='jaxws')">
<xsl:value-of select="concat('public class ', $ifname, ' ')" />
<xsl:text>{ </xsl:text>
<xsl:call-template name="genStructWrapperJaxws">
<xsl:with-param name="ifname" select="$ifname" />
<xsl:variable name="extends" select="//interface[@name=$ifname]/@extends" />
<xsl:when test="($extends = '$unknown') or ($extends = '$errorinfo')">
<xsl:value-of select="concat('public class ', $ifname, ' extends IUnknown ')" />
<xsl:text>{ </xsl:text>
<xsl:when test="//interface[@name=$extends]">
<xsl:value-of select="concat('public class ', $ifname, ' extends ', $extends, ' ')" />
<xsl:text>{ </xsl:text>
<xsl:call-template name="fatalError">
<xsl:with-param name="msg" select="concat('Interface generation: interface "', $ifname, '" has invalid "extends" value ', $extends, '.')" />
<xsl:call-template name="genIfaceWrapper">
<xsl:with-param name="ifname" select="$ifname" />
<xsl:text>} </xsl:text>
<xsl:call-template name="endFile">
<xsl:with-param name="file" select="$filename" />
<xsl:template name="genCb">
<xsl:param name="ifname" />
<xsl:param name="filename" />
<xsl:param name="filenameimpl" />
<xsl:call-template name="startFile">
<xsl:with-param name="file" select="$filename" />
<xsl:with-param name="package" select="$G_virtualBoxPackage" />
<xsl:value-of select="concat('public interface ', $ifname, ' ')" />
<xsl:text>{ </xsl:text>
<!-- emit methods declarations-->
<xsl:for-each select="method">
<xsl:call-template name="genCbMethodDecl">
<xsl:with-param name="ifname" select="$ifname" />
<xsl:with-param name="methodname" select="@name" />
<xsl:text>} </xsl:text>
<xsl:call-template name="endFile">
<xsl:with-param name="file" select="$filename" />
<xsl:call-template name="startFile">
<xsl:with-param name="file" select="$filenameimpl" />
<xsl:with-param name="package" select="$G_virtualBoxPackage" />
<xsl:variable name="backtype">
<xsl:call-template name="typeIdl2Back">
<xsl:with-param name="type" select="$ifname" />
<!-- emit glue methods body -->
<xsl:when test="$G_vboxGlueStyle='xpcom'">
<xsl:value-of select="concat('class ', $ifname, 'Impl extends nsISupportsBase implements ', $backtype, ' ')" />
<xsl:text>{ </xsl:text>
<xsl:when test="$G_vboxGlueStyle='mscom'">
<xsl:value-of select="concat('public class ', $ifname, 'Impl ')" />
<xsl:text>{ </xsl:text>
<xsl:value-of select="concat(' ', $ifname, ' sink; ')" />
<xsl:value-of select="concat(' ', $ifname, 'Impl(', $ifname, ' sink) ')" />
<xsl:text> { </xsl:text>
<xsl:text> } </xsl:text>
<!-- emit methods implementations -->
<xsl:for-each select="method">
<xsl:call-template name="genCbMethodImpl">
<xsl:with-param name="ifname" select="$ifname" />
<xsl:with-param name="methodname" select="@name" />
<xsl:text>} </xsl:text>
<xsl:call-template name="endFile">
<xsl:with-param name="file" select="$filenameimpl" />
<xsl:template name="emitHandwritten">
<xsl:call-template name="startFile">
<xsl:with-param name="package" select="$G_virtualBoxPackage" />
<xsl:if test="$filelistonly=''">
<xsl:call-template name="endFile">
<xsl:template name="emitHandwrittenXpcom">
<xsl:call-template name="startFile">
<xsl:with-param name="package" select="$G_virtualBoxPackageCom" />
<xsl:if test="$filelistonly=''">
public IUnknown(Object obj)
public Object getWrapped()
public void setWrapped(Object obj)
<xsl:call-template name="endFile">
<xsl:call-template name="startFile">
<xsl:with-param name="package" select="$G_virtualBoxPackageCom" />
<xsl:if test="$filelistonly=''">
public static List<Short> wrap(byte[] values)
public static List<Short> wrap(short[] values)
public static List<Integer> wrap(int[] values)
public static List<Long> wrap(long[] values)
public static List<Boolean> wrap(boolean[] values)
public static List<String> wrap(String[] values)
public static <T> List<T> wrap(Class<T> wrapperClass, T[] values)
@SuppressWarnings( "unchecked")
public static <T> List<T> wrapEnum(Class<T> wrapperClass, long values[])
//// This code is questionable, as it invokes a private constructor
//// (all enums only have default constructors), and we don't really
//// know what to pass as the name, and the ordinal may or may not
//// be sensible, especially if the long was abused as a bitset.
// Alternative implementation: use the fromValue method, which is
// what the code handling single enums will do. I see no reason to
// use the above very ugly hack if there are better alternatives,
// which as a bonus complain about unknown values. This variant is
// slower, but also orders of magnitude safer.
catch (NoSuchMethodException e)
throw new AssertionError(e);
//catch (InstantiationException e)
// throw new AssertionError(e);
catch (IllegalAccessException e)
throw new AssertionError(e);
catch (InvocationTargetException e)
throw new AssertionError(e);
public static short[] unwrapUShort(List<Short> values)
public static int[] unwrapInteger(List<Integer> values)
public static long[] unwrapULong(List<Long> values)
public static boolean[] unwrapBoolean(List<Boolean> values)
public static String[] unwrapStr(List<String> values)
public static <T extends Enum <T>> long[] unwrapEnum(Class<T> enumClass, List<T> values)
catch (NoSuchMethodException e)
throw new AssertionError(e);
catch(SecurityException e)
throw new AssertionError(e);
catch (IllegalAccessException e)
throw new AssertionError(e);
catch (IllegalArgumentException e)
throw new AssertionError(e);
catch (InvocationTargetException e)
throw new AssertionError(e);
public static <T1, T2> List<T1> wrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, T2[] values)
catch (NoSuchMethodException e)
throw new AssertionError(e);
catch (InstantiationException e)
throw new AssertionError(e);
catch (IllegalAccessException e)
throw new AssertionError(e);
catch (InvocationTargetException e)
throw new AssertionError(e);
@SuppressWarnings( "unchecked")
public static <T> T[] unwrap(Class<T> wrapperClass, List<T> values)
@SuppressWarnings( "unchecked" )
public static <T> T queryInterface(Object obj, String uuid, Class<T> iface)
return (T)queryInterface(obj, uuid);
public static Object queryInterface(Object obj, String uuid)
/* Kind of ugly, but does the job of casting */
@SuppressWarnings("unchecked")
public static <T1 extends IUnknown, T2> T2[] unwrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, List<T1> values)
<xsl:call-template name="endFile">
<xsl:call-template name="startFile">
<xsl:with-param name="package" select="$G_virtualBoxPackage" />
<xsl:if test="$filelistonly=''">
public class VBoxException extends RuntimeException
private IVirtualBoxErrorInfo errorInfo;
public VBoxException(String message)
public VBoxException(String message, Throwable cause)
catch (NullPointerException e)
public int getResultCode()
public IVirtualBoxErrorInfo getVirtualBoxErrorInfo()
<xsl:call-template name="endFile">
<xsl:call-template name="startFile">
<xsl:with-param name="package" select="$G_virtualBoxPackage" />
<xsl:if test="$filelistonly=''">
public class VirtualBoxManager
private IVirtualBox vbox;
private nsIComponentManager componentManager;
private VirtualBoxManager(Mozilla mozilla)
public void connect(String url, String username, String passwd)
throw new VBoxException("Connect doesn't make sense for local bindings");
throw new VBoxException("Disconnect doesn't make sense for local bindings");
public static void initPerThread()
public static void deinitPerThread()
public IVirtualBox getVBox()
public ISession getSessionObject()
public ISession openMachineSession(IMachine m) throws Exception
ISession s = getSessionObject();
public void closeMachineSession(ISession s)
private static boolean hasInstance = false;
private static boolean isMozillaInited = false;
public static synchronized VirtualBoxManager createInstance(String home)
throw new VBoxException("only one instance of VirtualBoxManager at a time allowed");
throw new VBoxException("
vbox.home Java property must be defined to use XPCOM bridge");
File grePath = new File(home);
return new VirtualBoxManager(mozilla);
public IEventListener createListener(Object sink)
return new IEventListener(new EventListenerImpl(sink));
// cleanup, we don't do that, as XPCOM bridge doesn't cleanly
// shuts down, so we prefer to avoid native shutdown
public void waitForEvents(long tmo)
<xsl:call-template name="endFile">
<xsl:call-template name="startFile">
<xsl:with-param name="package" select="$G_virtualBoxPackage" />
<xsl:if test="$filelistonly=''">
EventListenerImpl(Object obj)
if (obj != null && handleEvent != null)
<xsl:call-template name="endFile">
<xsl:call-template name="startFile">
<xsl:with-param name="package" select="$G_virtualBoxPackage" />
<xsl:if test="$filelistonly=''">
<xsl:call-template name="endFile">
<xsl:template name="emitHandwrittenMscom">
<xsl:call-template name="startFile">
<xsl:with-param name="package" select="$G_virtualBoxPackageCom" />
<xsl:if test="$filelistonly=''">
public IUnknown(Object obj)
public Object getWrapped()
public void setWrapped(Object obj)
<xsl:call-template name="endFile">
<xsl:call-template name="startFile">
<xsl:with-param name="package" select="$G_virtualBoxPackageCom" />
<xsl:if test="$filelistonly=''">
public static List<Short> wrap(short[] values)
public static List<Integer> wrap(int[] values)
public static List<Long> wrap(long[] values)
public static List<String> wrap(String[] values)
public static <T> T wrapDispatch(Class<T> wrapperClass, Dispatch d)
catch (NoSuchMethodException e)
throw new AssertionError(e);
catch (InstantiationException e)
throw new AssertionError(e);
catch (IllegalAccessException e)
throw new AssertionError(e);
catch (InvocationTargetException e)
throw new AssertionError(e);
@SuppressWarnings("unchecked")
public static <T> Object wrapVariant(Class<T> wrapperClass, Variant v)
throw new IllegalArgumentException("unhandled variant type " + vt);
public static byte[] wrapBytes(SafeArray sa)
byte[] ret = new byte[saLen];
// come up with more effective approach!!!
@SuppressWarnings("unchecked")
public static <T> List<T> wrap(Class<T> wrapperClass, SafeArray sa)
List<T> ret = new ArrayList<T>(saLen);
ret.add((T)wrapVariant(wrapperClass, v));
public static <T> List<T> wrapEnum(Class<T> wrapperClass, SafeArray sa)
List<T> ret = new ArrayList<T>(saLen);
catch (NoSuchMethodException e)
throw new AssertionError(e);
catch (InstantiationException e)
throw new AssertionError(e);
catch (IllegalAccessException e)
throw new AssertionError(e);
catch (InvocationTargetException e)
throw new AssertionError(e);
public static SafeArray unwrapInt(List<Integer> values)
public static SafeArray unwrapLong(List<Long> values)
public static SafeArray unwrapBool(List<Boolean> values)
public static SafeArray unwrapBytes(byte[] values)
public static <T extends Enum <T>> SafeArray unwrapEnum(Class<T> enumClass, List<T> values)
catch (NoSuchMethodException e)
throw new AssertionError(e);
catch(SecurityException e)
throw new AssertionError(e);
catch (IllegalAccessException e)
throw new AssertionError(e);
catch (IllegalArgumentException e)
throw new AssertionError(e);
catch (InvocationTargetException e)
throw new AssertionError(e);
public static SafeArray unwrapString(List<String> values)
public static <T1, T2> List<T1> wrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, T2[] values)
catch (NoSuchMethodException e)
throw new AssertionError(e);
catch (InstantiationException e)
throw new AssertionError(e);
catch (IllegalAccessException e)
throw new AssertionError(e);
catch (InvocationTargetException e)
throw new AssertionError(e);
@SuppressWarnings("unchecked")
public static <T> T[] unwrap(Class<T> wrapperClass, List<T> values)
@SuppressWarnings("unchecked")
public static <T1 extends IUnknown, T2> T2[] unwrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, List<T1> values)
/* We have very long invoke lists sometimes */
public static Variant invoke(Dispatch d, String method, Object ... args)
<xsl:call-template name="endFile">
<xsl:call-template name="startFile">
<xsl:with-param name="package" select="$G_virtualBoxPackage" />
<xsl:if test="$filelistonly=''">
public class VBoxException extends RuntimeException
private IVirtualBoxErrorInfo errorInfo;
public VBoxException(String message)
public VBoxException(String message, Throwable cause)
// JACOB doesn't support calling GetErrorInfo, which
// means there is no way of getting an IErrorInfo reference,
// and that means no way of getting to IVirtualBoxErrorInfo.
public int getResultCode()
public IVirtualBoxErrorInfo getVirtualBoxErrorInfo()
<xsl:call-template name="endFile">
<xsl:call-template name="startFile">
<xsl:with-param name="package" select="$G_virtualBoxPackage" />
<xsl:if test="$filelistonly=''">
public class VirtualBoxManager
private IVirtualBox vbox;
private VirtualBoxManager()
public static void initPerThread()
public static void deinitPerThread()
public void connect(String url, String username, String passwd)
throw new VBoxException("Connect doesn't make sense for local bindings");
throw new VBoxException("Disconnect doesn't make sense for local bindings");
public IVirtualBox getVBox()
public ISession getSessionObject()
public ISession openMachineSession(IMachine m)
ISession s = getSessionObject();
public void closeMachineSession(ISession s)
private static boolean hasInstance = false;
public static synchronized VirtualBoxManager createInstance(String home)
throw new VBoxException("only one instance of VirtualBoxManager at a time allowed");
return new VirtualBoxManager();
public void waitForEvents(long tmo)
catch (InterruptedException ie)
<xsl:call-template name="endFile">
<xsl:template name="emitHandwrittenJaxws">
<xsl:call-template name="startFile">
<xsl:with-param name="package" select="$G_virtualBoxPackage" />
<xsl:if test="$filelistonly=''">
protected final VboxPortType port;
public IUnknown(String obj, VboxPortType port)
public final String getWrapped()
public final VboxPortType getRemoteWSPort()
public synchronized void releaseRemote() throws WebServiceException
catch (InvalidObjectFaultMsg e)
throw new WebServiceException(e);
catch (RuntimeFaultMsg e)
throw new WebServiceException(e);
<xsl:call-template name="endFile">
<xsl:call-template name="startFile">
<xsl:with-param name="package" select="$G_virtualBoxPackage" />
<xsl:if test="$filelistonly=''">
public static <T> List<T> wrap(Class<T> wrapperClass, VboxPortType pt, List<String> values)
catch (NoSuchMethodException e)
throw new AssertionError(e);
catch (InstantiationException e)
throw new AssertionError(e);
catch (IllegalAccessException e)
throw new AssertionError(e);
catch (InvocationTargetException e)
throw new AssertionError(e);
public static <T1, T2> List<T1> wrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, VboxPortType pt, List<T2> values)
catch (NoSuchMethodException e)
throw new AssertionError(e);
catch (InstantiationException e)
throw new AssertionError(e);
catch (IllegalAccessException e)
throw new AssertionError(e);
catch (InvocationTargetException e)
throw new AssertionError(e);
public static <T extends IUnknown> List<String> unwrap(List<T> values)
List<String> ret = new ArrayList<String>(
values.size());
@SuppressWarnings("unchecked" )
public static <T1 extends Enum <T1>, T2 extends Enum <T2>> List<T2> convertEnums(Class<T1> fromClass,
// Ordinal based enum conversion, as JAX-WS "invents" its own
// enum names and has string values with the expected content.
catch (ArrayIndexOutOfBoundsException e)
throw new AssertionError(e);
private static final char[] valToChar = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".toCharArray();
private static final int[] charToVal = new int[256];
/* Initialize recoding alphabet. */
charToVal[valToChar[i]] = i;
public static String encodeBase64(byte[] data)
char[] result = new char[resultLen];
int dataIndex = 0, stringIndex = 0;
for (int i = 0; i < fullTriplets; i++)
int ch1 = data[dataIndex++] & 0xff;
result[stringIndex++] = valToChar[ch1 >> 2];
int ch2 = data[dataIndex++] & 0xff;
result[stringIndex++] = valToChar[((ch1 << 4) & 0x3f) | (ch2 >> 4)];
int ch3 = data[dataIndex++] & 0xff;
result[stringIndex++] = valToChar[((ch2 << 2) & 0x3f) | (ch3 >> 6)];
result[stringIndex++] = valToChar[ch3 & 0x3f];
int ch1 = data[dataIndex++] & 0xff;
result[stringIndex++] = valToChar[ch1 >> 2];
result[stringIndex++] = valToChar[(ch1 << 4) & 0x3f];
result[stringIndex++] = '=';
result[stringIndex++] = '=';
int ch1 = data[dataIndex++] & 0xff;
result[stringIndex++] = valToChar[ch1 >> 2];
int ch2 = data[dataIndex++] & 0xff;
result[stringIndex++] = valToChar[((ch1 << 4) & 0x3f) | (ch2 >> 4)];
result[stringIndex++] = valToChar[(ch2 << 2) & 0x3f];
result[stringIndex++] = '=';
throw new VBoxException("bug!");
return new String(result);
private static int skipInvalid(String str, int stringIndex)
public static byte[] decodeBase64(String str)
int validChars = 0, padChars = 0;
if ((validChars * 3 % 4) != 0)
throw new VBoxException("invalid base64 encoded string " + str);
int resultLength = validChars * 3 / 4 - padChars;
byte[] result = new byte[resultLength];
int dataIndex = 0, stringIndex = 0;
int quadraplets = validChars / 4;
for (int i = 0; i < quadraplets; i++)
stringIndex = skipInvalid(str, stringIndex);
stringIndex = skipInvalid(str, stringIndex);
stringIndex = skipInvalid(str, stringIndex);
stringIndex = skipInvalid(str, stringIndex);
result[dataIndex++] = (byte)(((charToVal[ch1] << 2) | charToVal[ch2] >> 4) & 0xff);
/* we check this to ensure that we don't override data with '=' padding. */
result[dataIndex++] = (byte)(((charToVal[ch2] << 4) | charToVal[ch3] >> 2) & 0xff);
result[dataIndex++] = (byte)(((charToVal[ch3] << 6) | charToVal[ch4]) & 0xff);
<xsl:call-template name="endFile">
<xsl:call-template name="startFile">
<xsl:with-param name="package" select="$G_virtualBoxPackage" />
<xsl:if test="$filelistonly=''">
public class VBoxException extends RuntimeException
private IVirtualBoxErrorInfo errorInfo;
public VBoxException(String message)
public VBoxException(String message, Throwable cause)
public VBoxException(String message, Throwable cause, VboxPortType port)
if (cause instanceof RuntimeFaultMsg)
RuntimeFaultMsg m = (RuntimeFaultMsg)cause;
errorInfo = (
retVal.length() > 0) ? new IVirtualBoxErrorInfo(retVal, port) : null;
public int getResultCode()
public IVirtualBoxErrorInfo getVirtualBoxErrorInfo()
<xsl:call-template name="endFile">
<xsl:call-template name="startFile">
<xsl:with-param name="package" select="$G_virtualBoxPackage" />
<xsl:if test="$filelistonly=''">
private final static String wsdlFile = </xsl:text>
<xsl:value-of select="$G_virtualBoxWsdl" />
private Map<VboxPortType, Integer> known;
private boolean initStarted;
PortPool(boolean usePreinit)
known = new HashMap<VboxPortType, Integer>();
new Thread(new Runnable()
// need to sync on something else but 'this'
catch (InterruptedException e)
private synchronized void preinit()
VboxPortType port = getPort();
synchronized VboxPortType getPort()
VboxPortType port = null;
if ((value & 0x10000) == 0)
throw new LinkageError(wsdlFile + " not found, but it should have been in the jar");
svc = new VboxService(wsdl,
// reuse this object 0x10 times
synchronized void releasePort(VboxPortType port)
if (val == null || val == 0)
// decrement TTL, and throw away port if used too much times
v = ttl; // set new TTL and clear busy bit
class VBoxTLSSocketFactory extends SSLSocketFactory
private final SSLSocketFactory sf;
private void setupSocket(SSLSocket s)
List<String> protolist = new ArrayList<String>();
if (oldproto[i].toUpperCase().startsWith("TLS"))
public VBoxTLSSocketFactory()
SSLSocketFactory tmp = null;
public static SocketFactory getDefault()
return new VBoxTLSSocketFactory();
public Socket createSocket(Socket socket, String host, int port,
boolean autoClose) throws IOException, UnknownHostException
public Socket createSocket() throws IOException
public Socket createSocket(InetAddress host, int port) throws IOException
public Socket createSocket(InetAddress address, int port,
InetAddress localAddress, int localPort) throws IOException
SSLSocket s = (SSLSocket)
sf.createSocket(address, port, localAddress, localPort);
public Socket createSocket(String host, int port) throws IOException, UnknownHostException
public Socket createSocket(String host, int port,
InetAddress localHost, int localPort) throws IOException, UnknownHostException
SSLSocket s = (SSLSocket)
sf.createSocket(host, port, localHost, localPort);
public String[] getDefaultCipherSuites()
public String[] getSupportedCipherSuites()
public class VirtualBoxManager
private static PortPool pool = new PortPool(true);
protected VboxPortType port;
private IVirtualBox vbox;
private VirtualBoxManager()
public static void initPerThread()
public static void deinitPerThread()
public void connect(String url, String username, String passwd)
((BindingProvider)port).getRequestContext().
// Unfortunately there is no official way to make JAX-WS use
// TLS only, which means that a rather tedious approach is
// unavoidable (implementing a TLS only SSLSocketFactory,
// because the default one associated with a TLS SSLContext
// happily uses SSLv2/3 handshakes, which make TLS servers
// drop the connection), and additionally a not standardized,
// shotgun approach is needed to make the relevant JAX-WS
// implementations use this factory.
VBoxTLSSocketFactory sf = new VBoxTLSSocketFactory();
((BindingProvider)port).getRequestContext().
((BindingProvider)port).getRequestContext().
// we have to throw smth derived from RuntimeException
public void connect(String url, String username, String passwd,
Map<String, Object> requestContext, Map<String, Object> responseContext)
((BindingProvider)port).getRequestContext();
if (requestContext != null)
((BindingProvider)port).getRequestContext().putAll(requestContext);
if (responseContext != null)
((BindingProvider)port).getResponseContext().putAll(responseContext);
((BindingProvider)port).getRequestContext().
// we have to throw smth derived from RuntimeException
catch (InvalidObjectFaultMsg e)
catch (RuntimeFaultMsg e)
public IVirtualBox getVBox()
public ISession getSessionObject()
throw new VBoxException("connect first");
return new ISession(handle, port);
catch (InvalidObjectFaultMsg e)
catch (RuntimeFaultMsg e)
public ISession openMachineSession(IMachine m) throws Exception
ISession s = getSessionObject();
public void closeMachineSession(ISession s)
public static synchronized VirtualBoxManager createInstance(String home)
return new VirtualBoxManager();
public IEventListener createListener(Object sink)
throw new VBoxException("no active listeners here");
public void waitForEvents(long tmo)
protected void finalize() throws Throwable
<xsl:call-template name="endFile">
<xsl:if test="not($G_vboxApiSuffix)">
<xsl:call-template name="fatalError">
<xsl:with-param name="msg" select="'G_vboxApiSuffix must be given'" />
<xsl:if test="not($filelistonly='')">
<xsl:value-of select="concat($filelistonly, ' := \ ')"/>
<!-- Handwritten files -->
<xsl:call-template name="emitHandwritten"/>
<xsl:when test="$G_vboxGlueStyle='xpcom'">
<xsl:call-template name="emitHandwrittenXpcom"/>
<xsl:when test="$G_vboxGlueStyle='mscom'">
<xsl:call-template name="emitHandwrittenMscom"/>
<xsl:when test="$G_vboxGlueStyle='jaxws'">
<xsl:call-template name="emitHandwrittenJaxws"/>
<xsl:call-template name="fatalError">
<xsl:with-param name="msg" select="'Style unknown (root)'" />
<xsl:for-each select="//enum">
<xsl:call-template name="genEnum">
<xsl:with-param name="enumname" select="@name" />
<xsl:with-param name="filename" select="concat(@name, '.java')" />
<xsl:for-each select="//interface">
<xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
<xsl:variable name="module" select="current()/ancestor::module/@name"/>
<xsl:when test="$G_vboxGlueStyle='jaxws'">
<xsl:if test="not($module) and not(@wsmap='suppress')">
<xsl:call-template name="genIface">
<xsl:with-param name="ifname" select="@name" />
<xsl:with-param name="filename" select="concat(@name, '.java')" />
<!-- We don't need WSDL-specific interfaces here -->
<xsl:if test="not(@internal='yes') and not($self_target='wsdl') and not($module)">
<xsl:call-template name="genIface">
<xsl:with-param name="ifname" select="@name" />
<xsl:with-param name="filename" select="concat(@name, '.java')" />
<xsl:if test="not($filelistonly='')">
<xsl:value-of select="' '"/>