diff options
Diffstat (limited to 'src/VBox/Main/glue/glue-java.xsl')
-rw-r--r-- | src/VBox/Main/glue/glue-java.xsl | 3113 |
1 files changed, 1794 insertions, 1319 deletions
diff --git a/src/VBox/Main/glue/glue-java.xsl b/src/VBox/Main/glue/glue-java.xsl index 0bcc4398..a1f47fc8 100644 --- a/src/VBox/Main/glue/glue-java.xsl +++ b/src/VBox/Main/glue/glue-java.xsl @@ -1,8 +1,8 @@ <xsl:stylesheet version = '1.0' - xmlns:xsl='http://www.w3.org/1999/XSL/Transform' - xmlns:vbox="http://www.virtualbox.org/" - xmlns:exsl="http://exslt.org/common" - extension-element-prefixes="exsl"> + xmlns:xsl='http://www.w3.org/1999/XSL/Transform' + xmlns:vbox="http://www.virtualbox.org/" + xmlns:exsl="http://exslt.org/common" + extension-element-prefixes="exsl"> <!-- @@ -10,7 +10,7 @@ XSLT stylesheet that generates Java glue code for XPCOM, MSCOM and JAX-WS from VirtualBox.xidl. - Copyright (C) 2010-2011 Oracle Corporation + Copyright (C) 2010-2014 Oracle Corporation This file is part of VirtualBox Open Source Edition (OSE), as available from http://www.virtualbox.org. This file is free software; @@ -32,35 +32,34 @@ - - - - - - - - - - - - - - - - - - - - - - --> <xsl:variable name="G_xsltFilename" select="'glue-java.xsl'" /> -<xsl:variable name="G_virtualBoxPackage" select="concat('org.virtualbox',$G_vboxApiSuffix)" /> -<xsl:variable name="G_virtualBoxPackageCom" select="concat('org.virtualbox',$G_vboxApiSuffix,'.',$G_vboxGlueStyle)" /> -<xsl:variable name="G_virtualBoxWsdl" select="concat(concat('"vboxwebService',$G_vboxApiSuffix), '.wsdl"')" /> -<!-- collect all interfaces with "wsmap='suppress'" in a global variable for - quick lookup --> +<xsl:variable name="G_virtualBoxPackage" select="concat('org.virtualbox', $G_vboxApiSuffix)" /> +<xsl:variable name="G_virtualBoxPackageCom" select="concat('org.virtualbox', $G_vboxApiSuffix, '.', $G_vboxGlueStyle)" /> +<xsl:variable name="G_virtualBoxWsdl" select="concat('"vboxwebService', $G_vboxApiSuffix, '.wsdl"')" /> +<!-- collect all interfaces with "wsmap='suppress'" in a global variable for quick lookup --> <xsl:variable name="G_setSuppressedInterfaces" select="//interface[@wsmap='suppress']" /> -<xsl:include href="../webservice/websrv-shared.inc.xsl" /> +<xsl:include href="../idl/typemap-shared.inc.xsl" /> <xsl:strip-space elements="*"/> <xsl:template name="fileheader"> <xsl:param name="name" /> <xsl:text>/* - * Copyright (C) 2010-2011 Oracle Corporation + * Copyright (C) 2010-2014 Oracle Corporation * - * This file is part of the VirtualBox SDK, as available from - * http://www.virtualbox.org. This library is free software; you can - * 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. + * This file is part of the VirtualBox SDK, as available from + * http://www.virtualbox.org. This library is free software; you can + * 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:text> - <xsl:value-of select="concat(' * ',$name)"/> + <xsl:value-of select="concat(' * ', $name)"/> <xsl:text> * * DO NOT EDIT! This is a generated file. @@ -75,39 +74,48 @@ <xsl:param name="file" /> <xsl:param name="package" /> - <xsl:value-of select="concat(' // ##### BEGINFILE "', $G_vboxDirPrefix, $file, '" ')" /> - <xsl:call-template name="fileheader"> - <xsl:with-param name="name" select="$file" /> - </xsl:call-template> + <xsl:choose> + <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:call-template> - <xsl:value-of select="concat('package ',$package,'; ')" /> - <xsl:value-of select="concat('import ',$G_virtualBoxPackageCom,'.*; ')" /> + <xsl:value-of select="concat('package ', $package, '; ')" /> + <xsl:value-of select="concat('import ', $G_virtualBoxPackageCom, '.*; ')" /> - <xsl:choose> - <xsl:when test="$G_vboxGlueStyle='xpcom'"> - <xsl:value-of select="'import org.mozilla.interfaces.*; '" /> - </xsl:when> + <xsl:choose> + <xsl:when test="$G_vboxGlueStyle='xpcom'"> + <xsl:text>import org.mozilla.interfaces.*; </xsl:text> + </xsl:when> - <xsl:when test="$G_vboxGlueStyle='mscom'"> - <xsl:value-of select="'import com.jacob.com.*; '" /> - <xsl:value-of select="'import com.jacob.activeX.ActiveXComponent; '" /> - </xsl:when> + <xsl:when test="$G_vboxGlueStyle='mscom'"> + <xsl:text>import com.jacob.com.*; </xsl:text> + <xsl:text>import com.jacob.activeX.ActiveXComponent; </xsl:text> + </xsl:when> - <xsl:when test="$G_vboxGlueStyle='jaxws'"> - <xsl:value-of select="'import javax.xml.ws.*; '" /> - </xsl:when> + <xsl:when test="$G_vboxGlueStyle='jaxws'"> + <xsl:text>import javax.xml.ws.*; </xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="fatalError"> + <xsl:with-param name="msg" select="'no header rule (startFile)'" /> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> + </xsl:when> <xsl:otherwise> - <xsl:call-template name="fatalError"> - <xsl:with-param name="msg" select="'no header rule (startFile)'" /> - </xsl:call-template> + <xsl:value-of select="concat('	', $G_vboxDirPrefix, $file, ' \ ')"/> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="endFile"> - <xsl:param name="file" /> - <xsl:value-of select="concat(' // ##### ENDFILE "', $file, '" ')" /> + <xsl:param name="file" /> + <xsl:if test="$filelistonly=''"> + <xsl:value-of select="concat(' // ##### ENDFILE "', $file, '" ')" /> + </xsl:if> </xsl:template> @@ -115,15 +123,23 @@ <xsl:param name="haystack"/> <xsl:param name="needle"/> <xsl:param name="replacement"/> + <xsl:param name="onlyfirst" select="false"/> <xsl:choose> - <xsl:when test="contains($haystack,$needle)"> - <xsl:value-of select="substring-before($haystack,$needle)"/> + <xsl:when test="contains($haystack, $needle)"> + <xsl:value-of select="substring-before($haystack, $needle)"/> <xsl:value-of select="$replacement"/> - <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:call-template> + <xsl:choose> + <xsl:when test="$onlyfirst = 'true'"> + <xsl:value-of select="substring-after($haystack, $needle)"/> + </xsl:when> + <xsl:otherwise> + <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:call-template> + </xsl:otherwise> + </xsl:choose> </xsl:when> <xsl:otherwise> <xsl:value-of select="$haystack"/> @@ -131,6 +147,48 @@ </xsl:choose> </xsl:template> +<xsl:template name="string-trim"> + <xsl:param name="text"/> + + <xsl:variable name="begin" select="substring($text, 1, 1)"/> + <xsl:choose> + <xsl:when test="$begin = ' ' or $begin = ' ' or $begin = ' '"> + <xsl:call-template name="string-trim"> + <xsl:with-param name="text" select="substring($text, 2)"/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:variable name="end" select="substring($text, string-length($text) - 1, 1)"/> + <xsl:choose> + <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:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:choose> + <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> + </xsl:variable> + <xsl:call-template name="string-trim"> + <xsl:with-param name="text" select="$tmptext"/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$text"/> + </xsl:otherwise> + </xsl:choose> + </xsl:otherwise> + </xsl:choose> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + <!-- descriptions --> <xsl:template match="*/text()"> @@ -160,18 +218,24 @@ </xsl:call-template> </xsl:variable> - <xsl:value-of select="$rep3"/> + <xsl:variable name="rep4"> + <xsl:call-template name="string-trim"> + <xsl:with-param name="text" select="$rep3"/> + </xsl:call-template> + </xsl:variable> + + <xsl:value-of select="$rep4"/> </xsl:template> <!-- - * all sub-elements that are not explicitly matched are considered to be - * html tags and copied w/o modifications + * 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:value-of select="concat('<', $tagname, '>')"/> <xsl:apply-templates/> - <xsl:value-of select="concat('</',$tagname,'>')"/> + <xsl:value-of select="concat('</', $tagname, '>')"/> </xsl:template> <xsl:template name="emit_refsig"> @@ -214,14 +278,14 @@ </xsl:when> <xsl:otherwise> <xsl:call-template name="fatalError"> - <xsl:with-param name="msg" select="concat('unknown reference destination in @see/@link: context=',$context,' identifier=',$identifier)" /> + <xsl:with-param name="msg" select="concat('unknown reference destination in @see/@link: context=', $context, ' identifier=', $identifier)" /> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:template> <!-- - * link + * link --> <xsl:template match="desc//link"> <xsl:text>{@link </xsl:text> @@ -231,10 +295,15 @@ <xsl:template match="link" mode="middle"> <xsl:variable name="linktext"> - <xsl:value-of select="translate(@to,'_','#')"/> + <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:call-template> </xsl:variable> <xsl:choose> - <xsl:when test="substring($linktext,1,1)='#'"> + <xsl:when test="substring($linktext, 1, 1)='#'"> <xsl:variable name="context"> <xsl:choose> <xsl:when test="local-name(../..)='interface' or local-name(../..)='enum'"> @@ -254,13 +323,13 @@ </xsl:when> <xsl:otherwise> <xsl:call-template name="fatalError"> - <xsl:with-param name="msg" select="concat('cannot determine context for identifier ',$linktext)" /> + <xsl:with-param name="msg" select="concat('cannot determine context for identifier ', $linktext)" /> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="linkname"> - <xsl:value-of select="substring($linktext,2)"/> + <xsl:value-of select="substring($linktext, 2)"/> </xsl:variable> <xsl:text>#</xsl:text> <xsl:call-template name="emit_refsig"> @@ -268,26 +337,26 @@ <xsl:with-param name="identifier" select="$linkname"/> </xsl:call-template> </xsl:when> - <xsl:when test="contains($linktext,'::')"> + <xsl:when test="contains($linktext, '::')"> <xsl:variable name="context"> - <xsl:value-of select="substring-before($linktext,'::')"/> + <xsl:value-of select="substring-before($linktext, '::')"/> </xsl:variable> <xsl:variable name="linkname"> - <xsl:value-of select="substring-after($linktext,'::')"/> + <xsl:value-of select="substring-after($linktext, '::')"/> </xsl:variable> - <xsl:value-of select="concat($G_virtualBoxPackage,'.',$context,'#')"/> + <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:call-template> </xsl:when> <xsl:otherwise> - <xsl:value-of select="concat($G_virtualBoxPackage,'.',$linktext)"/> + <xsl:value-of select="concat($G_virtualBoxPackage, '.', $linktext)"/> </xsl:otherwise> </xsl:choose> </xsl:template> <!-- - * note + * note --> <xsl:template match="desc/note"> <xsl:if test="not(@internal='yes')"> @@ -298,12 +367,12 @@ </xsl:template> <!-- - * see + * see --> <xsl:template match="desc/see"> <!-- 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 --> + Should be replaced in the xidl by multiple <see> without nested tag --> <xsl:text> </xsl:text> <xsl:apply-templates match="link"/> </xsl:template> @@ -317,18 +386,18 @@ </xsl:template> <!-- - * common comment prologue (handles group IDs) + * 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:text> /** </xsl:text> <xsl:if test="$id"> - <xsl:value-of select="concat(' @ingroup ',$id,' ')"/> + <xsl:value-of select="concat(' @ingroup ', $id, ' ')"/> </xsl:if> </xsl:template> <!-- - * common middle part of the comment block + * common middle part of the comment block --> <xsl:template match="desc" mode="middle"> <xsl:apply-templates select="text() | *[not(self::note or self::see)]"/> @@ -337,7 +406,7 @@ </xsl:template> <!-- - * result part of the comment block + * result part of the comment block --> <xsl:template match="desc" mode="results"> <xsl:if test="result"> @@ -347,10 +416,10 @@ <xsl:text><tr></xsl:text> <xsl:choose> <xsl:when test="ancestor::library/result[@name=current()/@name]"> - <xsl:value-of select="concat('<td>@link ::',@name,' ',@name,'</td>')"/> + <xsl:value-of select="concat('<td>@link ::', @name, ' ', @name, '</td>')"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="concat('<td>',@name,'</td>')"/> + <xsl:value-of select="concat('<td>', @name, '</td>')"/> </xsl:otherwise> </xsl:choose> <xsl:text><td></xsl:text> @@ -363,17 +432,15 @@ </xsl:template> <!-- - * translates the string to uppercase + * translates the string to uppercase --> <xsl:template name="uppercase"> <xsl:param name="str" select="."/> - <xsl:value-of select=" - translate($str,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ') - "/> + <xsl:value-of select="translate($str, $G_lowerCase, $G_upperCase)"/> </xsl:template> <!-- - * comment for interfaces + * comment for interfaces --> <xsl:template match="desc" mode="interface"> <xsl:apply-templates select="." mode="begin"/> @@ -386,7 +453,7 @@ </xsl:template> <!-- - * comment for attribute getters + * comment for attribute getters --> <xsl:template match="desc" mode="attribute_get"> <xsl:apply-templates select="." mode="begin"/> @@ -400,11 +467,11 @@ </xsl:call-template> <xsl:text> </xsl:text> <xsl:apply-templates select="see"/> - <xsl:text> */ </xsl:text> + <xsl:text>*/ </xsl:text> </xsl:template> <!-- - * comment for attribute setters + * comment for attribute setters --> <xsl:template match="desc" mode="attribute_set"> <xsl:apply-templates select="." mode="begin"/> @@ -422,7 +489,7 @@ </xsl:template> <!-- - * comment for methods + * comment for methods --> <xsl:template match="desc" mode="method"> <xsl:apply-templates select="." mode="begin"/> @@ -438,7 +505,7 @@ </xsl:template> <!-- - * comment for method parameters + * comment for method parameters --> <xsl:template match="method/param/desc"> <xsl:if test="text() | *[not(self::note or self::see)]"> @@ -458,7 +525,7 @@ </xsl:template> <!-- - * comment for enums + * comment for enums --> <xsl:template match="desc" mode="enum"> <xsl:apply-templates select="." mode="begin"/> @@ -471,7 +538,7 @@ </xsl:template> <!-- - * comment for enum values + * comment for enum values --> <xsl:template match="desc" mode="enum_const"> <xsl:apply-templates select="." mode="begin"/> @@ -480,7 +547,7 @@ </xsl:template> <!-- - * ignore descGroups by default (processed in /idl) + * ignore descGroups by default (processed in /idl) --> <xsl:template match="descGroup"/> @@ -497,47 +564,55 @@ <xsl:with-param name="package" select="$G_virtualBoxPackage" /> </xsl:call-template> - <xsl:apply-templates select="desc" mode="enum"/> - <xsl:value-of select="concat('public enum ', $enumname, ' { ')" /> - <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:choose> - <xsl:when test="not(position()=last())"> - <xsl:text>, </xsl:text> - </xsl:when> - <xsl:otherwise> - <xsl:text>; </xsl:text> - </xsl:otherwise> - </xsl:choose> - </xsl:for-each> - - <xsl:text> </xsl:text> - <xsl:text> private final int value; </xsl:text> - - <xsl:value-of select="concat(' ', $enumname, '(int v) { ')" /> - <xsl:text> value = v; </xsl:text> - <xsl:text> } </xsl:text> - - <xsl:text> public int value() { </xsl:text> - <xsl:text> return value; </xsl:text> - <xsl:text> } </xsl:text> - - <xsl:value-of select="concat(' public static ', $enumname, ' fromValue(long v) { ')" /> - <xsl:value-of select="concat(' for (', $enumname, ' c: ', $enumname, '.values()) { ')" /> - <xsl:text> if (c.value == (int)v) { </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:value-of select="concat(' return valueOf(',$enumname, '.class, v); ')" /> - <xsl:value-of select=" ' } '" /> + <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:choose> + <xsl:when test="not(position()=last())"> + <xsl:text>, </xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:text>; </xsl:text> + </xsl:otherwise> + </xsl:choose> + </xsl:for-each> - <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:if> <xsl:call-template name="endFile"> <xsl:with-param name="file" select="$filename" /> @@ -546,32 +621,39 @@ </xsl:template> <xsl:template name="startExcWrapper"> - - <xsl:value-of select="' try { '" /> - + <xsl:text> try </xsl:text> + <xsl:text> { </xsl:text> </xsl:template> <xsl:template name="endExcWrapper"> <xsl:choose> <xsl:when test="$G_vboxGlueStyle='xpcom'"> - <xsl:value-of select="' } catch (org.mozilla.xpcom.XPCOMException e) { '" /> - <xsl:value-of select="' throw new VBoxException(e, e.getMessage()); '" /> - <xsl:value-of select="' } '" /> + <xsl:text> } </xsl:text> + <xsl:text> catch (org.mozilla.xpcom.XPCOMException e) </xsl:text> + <xsl:text> { </xsl:text> + <xsl:text> throw new VBoxException(e.getMessage(), e); </xsl:text> + <xsl:text> } </xsl:text> </xsl:when> <xsl:when test="$G_vboxGlueStyle='mscom'"> - <xsl:value-of select="' } catch (com.jacob.com.ComException e) { '" /> - <xsl:value-of select="' throw new VBoxException(e, e.getMessage()); '" /> - <xsl:value-of select="' } '" /> + <xsl:text> } </xsl:text> + <xsl:text> catch (com.jacob.com.ComException e) </xsl:text> + <xsl:text> { </xsl:text> + <xsl:text> throw new VBoxException(e.getMessage(), e); </xsl:text> + <xsl:text> } </xsl:text> </xsl:when> <xsl:when test="$G_vboxGlueStyle='jaxws'"> - <xsl:value-of select="' } catch (InvalidObjectFaultMsg e) { '" /> - <xsl:value-of select="' throw new VBoxException(e, e.getMessage()); '" /> - <xsl:value-of select="' } catch (RuntimeFaultMsg e) { '" /> - <xsl:value-of select="' throw new VBoxException(e, e.getMessage()); '" /> - <xsl:value-of select="' } '" /> + <xsl:text> } </xsl:text> + <xsl:text> catch (InvalidObjectFaultMsg e) </xsl:text> + <xsl:text> { </xsl:text> + <xsl:text> throw new VBoxException(e.getMessage(), e, this.port); </xsl:text> + <xsl:text> } </xsl:text> + <xsl:text> catch (RuntimeFaultMsg e) </xsl:text> + <xsl:text> { </xsl:text> + <xsl:text> throw new VBoxException(e.getMessage(), e, this.port); </xsl:text> + <xsl:text> } </xsl:text> </xsl:when> <xsl:otherwise> @@ -587,15 +669,15 @@ <xsl:choose> <xsl:when test="$G_vboxGlueStyle='xpcom'"> - <xsl:value-of select="concat('org.mozilla.interfaces.',$ifname)" /> + <xsl:value-of select="concat('org.mozilla.interfaces.', $ifname)" /> </xsl:when> <xsl:when test="$G_vboxGlueStyle='mscom'"> - <xsl:value-of select="'com.jacob.com.Dispatch'" /> + <xsl:text>com.jacob.com.Dispatch</xsl:text> </xsl:when> <xsl:when test="$G_vboxGlueStyle='jaxws'"> - <xsl:value-of select="'String'" /> + <xsl:text>String</xsl:text> </xsl:when> <xsl:otherwise> @@ -611,19 +693,20 @@ <xsl:param name="name" /> <xsl:param name="origname" /> <xsl:param name="collPrefix" /> - <xsl:choose> - <xsl:when test="//enum[@name=$name] or //enum[@name=$origname]"> - <xsl:value-of select="concat($G_virtualBoxPackage, concat('.', $name))" /> - </xsl:when> - <xsl:when test="//interface[@name=$name]"> - <xsl:value-of select="concat($G_virtualBoxPackage, concat('.', $name))" /> - </xsl:when> - <xsl:otherwise> + + <xsl:choose> + <xsl:when test="//enum[@name=$name] or //enum[@name=$origname]"> + <xsl:value-of select="concat($G_virtualBoxPackage, concat('.', $name))" /> + </xsl:when> + <xsl:when test="//interface[@name=$name]"> + <xsl:value-of select="concat($G_virtualBoxPackage, concat('.', $name))" /> + </xsl:when> + <xsl:otherwise> <xsl:call-template name="fatalError"> <xsl:with-param name="msg" select="concat('fullClassName: Type "', $name, '" is not supported.')" /> </xsl:call-template> - </xsl:otherwise> - </xsl:choose> + </xsl:otherwise> + </xsl:choose> </xsl:template> <xsl:template name="typeIdl2Glue"> @@ -636,14 +719,14 @@ <xsl:variable name="needlist" select="($needarray) and not($type='octet')" /> <xsl:if test="($needlist)"> - <xsl:value-of select="'List'" /> + <xsl:text>List</xsl:text> <xsl:if test="not($skiplisttype='yes')"> - <xsl:value-of select="'<'" /> + <xsl:text><</xsl:text> </xsl:if> </xsl:if> <xsl:if test="not($needlist) or not($skiplisttype='yes')"> - <!-- look up Java type from IDL type from table array in websrv-shared.inc.xsl --> + <!-- look up Java type from IDL type from table array in typemap-shared.inc.xsl --> <xsl:variable name="javatypefield" select="exsl:node-set($G_aSharedTypes)/type[@idlname=$type]/@javaname" /> <xsl:choose> @@ -664,11 +747,11 @@ <xsl:choose> <xsl:when test="($needlist)"> <xsl:if test="not($skiplisttype='yes')"> - <xsl:value-of select="'>'" /> + <xsl:text>></xsl:text> </xsl:if> </xsl:when> <xsl:when test="($needarray)"> - <xsl:value-of select="'[]'" /> + <xsl:text>[]</xsl:text> </xsl:when> </xsl:choose> </xsl:template> @@ -687,43 +770,43 @@ <xsl:choose> <xsl:when test="$type='long long'"> - <xsl:value-of select="'long'" /> + <xsl:text>long</xsl:text> </xsl:when> <xsl:when test="$type='unsigned long'"> - <xsl:value-of select="'long'" /> + <xsl:text>long</xsl:text> </xsl:when> <xsl:when test="$type='long'"> - <xsl:value-of select="'int'" /> + <xsl:text>int</xsl:text> </xsl:when> <xsl:when test="$type='unsigned short'"> - <xsl:value-of select="'int'" /> + <xsl:text>int</xsl:text> </xsl:when> <xsl:when test="$type='short'"> - <xsl:value-of select="'short'" /> + <xsl:text>short</xsl:text> </xsl:when> <xsl:when test="$type='octet'"> - <xsl:value-of select="'byte'" /> + <xsl:text>byte</xsl:text> </xsl:when> <xsl:when test="$type='boolean'"> - <xsl:value-of select="'boolean'" /> + <xsl:text>boolean</xsl:text> </xsl:when> <xsl:when test="$type='$unknown'"> - <xsl:value-of select="'nsISupports'"/> + <xsl:text>nsISupports</xsl:text> </xsl:when> <xsl:when test="$type='wstring'"> - <xsl:value-of select="'String'" /> + <xsl:text>String</xsl:text> </xsl:when> <xsl:when test="$type='uuid'"> - <xsl:value-of select="'String'" /> + <xsl:text>String</xsl:text> </xsl:when> <xsl:when test="//interface[@name=$type]/@wsmap='struct'"> @@ -739,7 +822,7 @@ </xsl:when> <xsl:when test="//enum[@name=$type]"> - <xsl:value-of select="'long'" /> + <xsl:text>long</xsl:text> </xsl:when> <xsl:otherwise> @@ -750,27 +833,27 @@ </xsl:choose> <xsl:if test="$needarray"> - <xsl:value-of select="'[]'" /> + <xsl:text>[]</xsl:text> </xsl:if> </xsl:when> <xsl:when test="($G_vboxGlueStyle='mscom')"> - <xsl:value-of select="'Variant'"/> + <xsl:text>Variant</xsl:text> </xsl:when> <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:value-of select="'List<'" /> + <xsl:text>List<</xsl:text> </xsl:if> <xsl:choose> <xsl:when test="$type='$unknown'"> - <xsl:value-of select="'String'" /> + <xsl:text>String</xsl:text> </xsl:when> <xsl:when test="//interface[@name=$type]/@wsmap='managed'"> - <xsl:value-of select="'String'" /> + <xsl:text>String</xsl:text> </xsl:when> <xsl:when test="//interface[@name=$type]/@wsmap='struct'"> @@ -783,51 +866,51 @@ <!-- we encode byte arrays as Base64 strings. --> <xsl:when test="$type='octet'"> - <xsl:value-of select="'/*base64*/String'" /> + <xsl:text>/*base64*/String</xsl:text> </xsl:when> <xsl:when test="$type='long long'"> - <xsl:value-of select="'Long'" /> + <xsl:text>Long</xsl:text> </xsl:when> <xsl:when test="$type='unsigned long'"> - <xsl:value-of select="'Long'" /> + <xsl:text>Long</xsl:text> </xsl:when> <xsl:when test="$type='long'"> - <xsl:value-of select="'Integer'" /> + <xsl:text>Integer</xsl:text> </xsl:when> <xsl:when test="$type='unsigned short'"> - <xsl:value-of select="'Integer'" /> + <xsl:text>Integer</xsl:text> </xsl:when> <xsl:when test="$type='short'"> - <xsl:value-of select="'Short'" /> + <xsl:text>Short</xsl:text> </xsl:when> <xsl:when test="$type='boolean'"> - <xsl:value-of select="'Boolean'" /> + <xsl:text>Boolean</xsl:text> </xsl:when> <xsl:when test="$type='wstring'"> - <xsl:value-of select="'String'" /> + <xsl:text>String</xsl:text> </xsl:when> <xsl:when test="$type='uuid'"> - <xsl:value-of select="'String'" /> + <xsl:text>String</xsl:text> </xsl:when> <xsl:otherwise> <xsl:call-template name="fatalError"> - <xsl:with-param name="msg" select="concat('Unhandled type ', $type,' (typeIdl2Back)')" /> + <xsl:with-param name="msg" select="concat('Unhandled type ', $type, ' (typeIdl2Back)')" /> </xsl:call-template> </xsl:otherwise> </xsl:choose> <xsl:if test="$needarray"> - <xsl:value-of select="'>'" /> + <xsl:text>></xsl:text> </xsl:if> </xsl:when> @@ -875,16 +958,16 @@ <xsl:with-param name="forceelem" select="'yes'" /> </xsl:call-template> </xsl:variable> - <xsl:value-of select="concat('Helper.wrap2(',$elemgluetype, '.class, ', $elembacktype, '.class, ', $value,')')"/> + <xsl:value-of select="concat('Helper.wrap2(', $elemgluetype, '.class, ', $elembacktype, '.class, ', $value, ')')"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="concat('(', $value, ' != null) ? new ', $gluetype, '(', $value,') : null')" /> + <xsl:value-of select="concat('(', $value, ' != null) ? new ', $gluetype, '(', $value, ') : null')" /> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:when test="//enum[@name=$idltype]"> - <xsl:choose> + <xsl:choose> <xsl:when test="$safearray='yes'"> <xsl:variable name="elembacktype"> <xsl:call-template name="typeIdl2Back"> @@ -893,12 +976,12 @@ <xsl:with-param name="forceelem" select="'yes'" /> </xsl:call-template> </xsl:variable> - <xsl:value-of select="concat('Helper.wrapEnum(',$elemgluetype, '.class, ', $value,')')"/> + <xsl:value-of select="concat('Helper.wrapEnum(', $elemgluetype, '.class, ', $value, ')')"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="concat($gluetype,'.fromValue(', $value,')')"/> + <xsl:value-of select="concat($gluetype, '.fromValue(', $value, ')')"/> </xsl:otherwise> - </xsl:choose> + </xsl:choose> </xsl:when> <xsl:otherwise> @@ -907,7 +990,7 @@ <xsl:value-of select="$value"/> </xsl:when> <xsl:when test="$safearray='yes'"> - <xsl:value-of select="concat('Helper.wrap(', $value,')')"/> + <xsl:value-of select="concat('Helper.wrap(', $value, ')')"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$value"/> @@ -943,54 +1026,54 @@ <xsl:value-of select="concat('Helper.wrapBytes(', $value, '.toSafeArray())')"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="concat('Helper.wrap(', $elemgluetype, '.class, ', $value,'.toSafeArray())')"/> + <xsl:value-of select="concat('Helper.wrap(', $elemgluetype, '.class, ', $value, '.toSafeArray())')"/> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:when test="//interface[@name=$idltype] or $idltype='$unknown'"> - <xsl:value-of select="concat('Helper.wrapDispatch(',$gluetype, '.class, ', $value,'.getDispatch())')"/> + <xsl:value-of select="concat('Helper.wrapDispatch(', $gluetype, '.class, ', $value, '.getDispatch())')"/> </xsl:when> <xsl:when test="//enum[@name=$idltype]"> - <xsl:value-of select="concat($gluetype,'.fromValue(', $value,'.getInt())')"/> + <xsl:value-of select="concat($gluetype, '.fromValue(', $value, '.getInt())')"/> </xsl:when> <xsl:when test="$idltype='wstring'"> - <xsl:value-of select="concat($value,'.getString()')"/> + <xsl:value-of select="concat($value, '.getString()')"/> </xsl:when> <xsl:when test="$idltype='uuid'"> - <xsl:value-of select="concat($value,'.getString()')"/> + <xsl:value-of select="concat($value, '.getString()')"/> </xsl:when> - <xsl:when test="$idltype='boolean'"> - <xsl:value-of select="concat($value,'.toBoolean()')"/> + <xsl:when test="$idltype='boolean'"> + <xsl:value-of select="concat($value, '.toBoolean()')"/> </xsl:when> <xsl:when test="$idltype='unsigned short'"> - <xsl:value-of select="concat('(int)', $value,'.getShort()')"/> + <xsl:value-of select="concat('(int)', $value, '.getShort()')"/> </xsl:when> - <xsl:when test="$idltype='short'"> - <xsl:value-of select="concat($value,'.getShort()')"/> + <xsl:when test="$idltype='short'"> + <xsl:value-of select="concat($value, '.getShort()')"/> </xsl:when> <xsl:when test="$idltype='long'"> - <xsl:value-of select="concat($value,'.getInt()')"/> + <xsl:value-of select="concat($value, '.getInt()')"/> </xsl:when> <xsl:when test="$idltype='unsigned long'"> - <xsl:value-of select="concat('(long)', $value,'.getInt()')"/> + <xsl:value-of select="concat('(long)', $value, '.getInt()')"/> </xsl:when> <xsl:when test="$idltype='long'"> - <xsl:value-of select="concat($value,'.getInt()')"/> + <xsl:value-of select="concat($value, '.getInt()')"/> </xsl:when> <xsl:when test="$idltype='long long'"> - <xsl:value-of select="concat($value,'.getLong()')"/> + <xsl:value-of select="concat($value, '.getLong()')"/> </xsl:when> <xsl:otherwise> @@ -1035,19 +1118,19 @@ </xsl:variable> <xsl:choose> <xsl:when test="$isstruct"> - <xsl:value-of select="concat('Helper.wrap2(',$elemgluetype, '.class, ', $elembacktype, '.class, port, ', $value,')')"/> + <xsl:value-of select="concat('Helper.wrap2(', $elemgluetype, '.class, ', $elembacktype, '.class, port, ', $value, ')')"/> </xsl:when> <xsl:when test="//enum[@name=$idltype]"> - <xsl:value-of select="concat('Helper.convertEnums(',$elembacktype, '.class, ', $elemgluetype, '.class, ', $value,')')"/> + <xsl:value-of select="concat('Helper.convertEnums(', $elembacktype, '.class, ', $elemgluetype, '.class, ', $value, ')')"/> </xsl:when> <xsl:when test="//interface[@name=$idltype] or $idltype='$unknown'"> - <xsl:value-of select="concat('Helper.wrap(',$elemgluetype,'.class, port, ', $value,')')"/> + <xsl:value-of select="concat('Helper.wrap(', $elemgluetype, '.class, port, ', $value, ')')"/> </xsl:when> <xsl:when test="$idltype='octet'"> - <xsl:value-of select="concat('Helper.decodeBase64(',$value,')')"/> + <xsl:value-of select="concat('Helper.decodeBase64(', $value, ')')"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="$value" /> + <xsl:value-of select="$value" /> </xsl:otherwise> </xsl:choose> </xsl:when> @@ -1055,7 +1138,7 @@ <xsl:otherwise> <xsl:choose> <xsl:when test="//enum[@name=$idltype]"> - <xsl:value-of select="concat($gluetype,'.fromValue(', $value,'.value())')"/> + <xsl:value-of select="concat($gluetype, '.fromValue(', $value, '.value())')"/> </xsl:when> <xsl:when test="$idltype='boolean'"> <xsl:value-of select="$value"/> @@ -1085,15 +1168,15 @@ <xsl:value-of select="$value"/> </xsl:when> <xsl:when test="$isstruct"> - <xsl:value-of select="concat('(', $value, ' != null) ? new ', $gluetype, '(', $value,', port) : null')" /> + <xsl:value-of select="concat('(', $value, ' != null) ? new ', $gluetype, '(', $value, ', port) : null')" /> </xsl:when> <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:value-of select="concat('(', $value, '.length() > 0) ? new ', $gluetype, '(', $value, ', port) : null')" /> </xsl:when> <xsl:otherwise> <xsl:call-template name="fatalError"> - <xsl:with-param name="msg" select="concat('Unhandled type ', $idltype, ' (cookOutParamJaxws)')" /> + <xsl:with-param name="msg" select="concat('Unhandled type ', $idltype, ' (cookOutParamJaxws)')" /> </xsl:call-template> </xsl:otherwise> </xsl:choose> @@ -1177,21 +1260,21 @@ <xsl:with-param name="forceelem" select="'yes'" /> </xsl:call-template> </xsl:variable> - <xsl:value-of select="concat('Helper.unwrap2(',$elemgluetype, '.class, ', $elembacktype, '.class, ', $value,')')"/> + <xsl:value-of select="concat('Helper.unwrap2(', $elemgluetype, '.class, ', $elembacktype, '.class, ', $value, ')')"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="concat('(', $value, ' != null) ? ', $value, '.getTypedWrapped() : null')" /> + <xsl:value-of select="concat('(', $value, ' != null) ? ', $value, '.getTypedWrapped() : null')" /> </xsl:otherwise> </xsl:choose> </xsl:when> - <xsl:when test="$idltype='$unknown'"> - <xsl:choose> + <xsl:when test="$idltype='$unknown'"> + <xsl:choose> <xsl:when test="$safearray='yes'"> - <xsl:value-of select="concat('Helper.unwrap2(',$elemgluetype, '.class, nsISupports.class, ', $value,')')"/> + <xsl:value-of select="concat('Helper.unwrap2(', $elemgluetype, '.class, nsISupports.class, ', $value, ')')"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="concat('(', $value, ' != null) ? (nsISupports)', $value, '.getWrapped() : null')" /> + <xsl:value-of select="concat('(', $value, ' != null) ? (nsISupports)', $value, '.getWrapped() : null')" /> </xsl:otherwise> </xsl:choose> </xsl:when> @@ -1199,10 +1282,10 @@ <xsl:when test="//enum[@name=$idltype]"> <xsl:choose> <xsl:when test="$safearray='yes'"> - <xsl:value-of select="concat('Helper.unwrapEnum(', $elemgluetype, '.class,', $value,')')"/> + <xsl:value-of select="concat('Helper.unwrapEnum(', $elemgluetype, '.class, ', $value, ')')"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="concat($value,'.value()')"/> + <xsl:value-of select="concat($value, '.value()')"/> </xsl:otherwise> </xsl:choose> </xsl:when> @@ -1216,19 +1299,19 @@ <xsl:when test="$safearray='yes'"> <xsl:choose> <xsl:when test="$idltype='boolean'"> - <xsl:value-of select="concat('Helper.unwrapBoolean(',$value,')')"/> + <xsl:value-of select="concat('Helper.unwrapBoolean(', $value, ')')"/> </xsl:when> <xsl:when test="($idltype='long') or ($idltype='unsigned long') or ($idltype='integer')"> - <xsl:value-of select="concat('Helper.unwrapInteger(',$value,')')"/> + <xsl:value-of select="concat('Helper.unwrapInteger(', $value, ')')"/> </xsl:when> <xsl:when test="($idltype='short') or ($idltype='unsigned short')"> - <xsl:value-of select="concat('Helper.unwrapUShort(',$value,')')"/> + <xsl:value-of select="concat('Helper.unwrapUShort(', $value, ')')"/> </xsl:when> <xsl:when test="($idltype='unsigned long long') or ($idltype='long long')"> - <xsl:value-of select="concat('Helper.unwrapULong(',$value,')')"/> + <xsl:value-of select="concat('Helper.unwrapULong(', $value, ')')"/> </xsl:when> <xsl:when test="($idltype='wstring') or ($idltype='uuid')"> - <xsl:value-of select="concat('Helper.unwrapStr(',$value,')')"/> + <xsl:value-of select="concat('Helper.unwrapStr(', $value, ')')"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$value"/> @@ -1283,21 +1366,21 @@ <xsl:with-param name="forceelem" select="'yes'" /> </xsl:call-template> </xsl:variable> - <xsl:value-of select="concat('Helper.unwrap2(',$elemgluetype, '.class, ', $elembacktype, '.class, ', $value,')')"/> + <xsl:value-of select="concat('Helper.unwrap2(', $elemgluetype, '.class, ', $elembacktype, '.class, ', $value, ')')"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="concat('(', $value, ' != null) ? ', $value, '.getTypedWrapped() : null')" /> + <xsl:value-of select="concat('(', $value, ' != null) ? ', $value, '.getTypedWrapped() : null')" /> </xsl:otherwise> </xsl:choose> </xsl:when> - <xsl:when test="$idltype='$unknown'"> - <xsl:choose> + <xsl:when test="$idltype='$unknown'"> + <xsl:choose> <xsl:when test="$safearray='yes'"> - <xsl:value-of select="concat('Helper.unwrap2(',$elemgluetype, '.class, Dispatch.class, ', $value,')')"/> + <xsl:value-of select="concat('Helper.unwrap2(', $elemgluetype, '.class, Dispatch.class, ', $value, ')')"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="concat('(', $value, ' != null) ? (Dispatch)', $value, '.getWrapped() : null')" /> + <xsl:value-of select="concat('(', $value, ' != null) ? (Dispatch)', $value, '.getWrapped() : null')" /> </xsl:otherwise> </xsl:choose> </xsl:when> @@ -1305,10 +1388,10 @@ <xsl:when test="//enum[@name=$idltype]"> <xsl:choose> <xsl:when test="$safearray='yes'"> - <xsl:value-of select="concat('Helper.unwrapEnum(', $elemgluetype, '.class,',$value,')')"/> + <xsl:value-of select="concat('Helper.unwrapEnum(', $elemgluetype, '.class, ', $value, ')')"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="concat($value,'.value()')"/> + <xsl:value-of select="concat($value, '.value()')"/> </xsl:otherwise> </xsl:choose> </xsl:when> @@ -1316,10 +1399,10 @@ <xsl:when test="$idltype='boolean'"> <xsl:choose> <xsl:when test="$safearray='yes'"> - <xsl:value-of select="concat('Helper.unwrapBool(', $value,')')"/> + <xsl:value-of select="concat('Helper.unwrapBool(', $value, ')')"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="concat('new Variant(',$value,')')"/> + <xsl:value-of select="concat('new Variant(', $value, ')')"/> </xsl:otherwise> </xsl:choose> </xsl:when> @@ -1327,10 +1410,10 @@ <xsl:when test="($idltype='short') or ($idltype='unsigned short')"> <xsl:choose> <xsl:when test="$safearray='yes'"> - <xsl:value-of select="concat('Helper.unwrapShort(', $value,')')"/> + <xsl:value-of select="concat('Helper.unwrapShort(', $value, ')')"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="concat('new Variant(',$value,')')"/> + <xsl:value-of select="concat('new Variant(', $value, ')')"/> </xsl:otherwise> </xsl:choose> </xsl:when> @@ -1339,10 +1422,10 @@ <xsl:when test="($idltype='long') or ($idltype='unsigned long')"> <xsl:choose> <xsl:when test="$safearray='yes'"> - <xsl:value-of select="concat('Helper.unwrapInt(', $value,')')"/> + <xsl:value-of select="concat('Helper.unwrapInt(', $value, ')')"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="concat('new Variant(',$value,')')"/> + <xsl:value-of select="concat('new Variant(', $value, ')')"/> </xsl:otherwise> </xsl:choose> </xsl:when> @@ -1350,10 +1433,10 @@ <xsl:when test="($idltype='wstring') or ($idltype='uuid')"> <xsl:choose> <xsl:when test="$safearray='yes'"> - <xsl:value-of select="concat('Helper.unwrapString(', $value,')')"/> + <xsl:value-of select="concat('Helper.unwrapString(', $value, ')')"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="concat('new Variant(',$value,')')"/> + <xsl:value-of select="concat('new Variant(', $value, ')')"/> </xsl:otherwise> </xsl:choose> </xsl:when> @@ -1361,16 +1444,16 @@ <xsl:when test="($idltype='unsigned long long') or ($idltype='long long')"> <xsl:choose> <xsl:when test="$safearray='yes'"> - <xsl:value-of select="concat('Helper.unwrapLong(', $value,')')"/> + <xsl:value-of select="concat('Helper.unwrapLong(', $value, ')')"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="concat('new Variant(',$value,'.longValue())')"/> + <xsl:value-of select="concat('new Variant(', $value, '.longValue())')"/> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:when test="($idltype='octet') and ($safearray='yes')"> - <xsl:value-of select="concat('Helper.encodeBase64(', $value,')')"/> + <xsl:value-of select="concat('Helper.encodeBase64(', $value, ')')"/> </xsl:when> <xsl:otherwise> @@ -1407,49 +1490,49 @@ </xsl:variable> <xsl:choose> - <xsl:when test="//interface[@name=$idltype] or $idltype='$unknown'"> + <xsl:when test="//interface[@name=$idltype] or $idltype='$unknown'"> <xsl:choose> <xsl:when test="@safearray='yes'"> - <xsl:value-of select="concat('Helper.unwrap(',$value,')')"/> + <xsl:value-of select="concat('Helper.unwrap(', $value, ')')"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="concat('((', $value, ' == null) ? null :', $value, '.getWrapped())')" /> </xsl:otherwise> </xsl:choose> - </xsl:when> - - <xsl:when test="//enum[@name=$idltype]"> - <xsl:choose> - <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:call-template> - </xsl:variable> - <xsl:value-of select="concat('Helper.convertEnums(', $elemgluetype, '.class,', $elembacktype, '.class,', $value,')')"/> - </xsl:when> - <xsl:otherwise> - <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:call-template> - </xsl:variable> - <xsl:value-of select="concat($backtype, '.fromValue(', $value, '.name())')"/> - </xsl:otherwise> - </xsl:choose> - </xsl:when> - - <xsl:when test="($idltype='octet') and ($safearray='yes')"> - <xsl:value-of select="concat('Helper.encodeBase64(',$value,')')"/> - </xsl:when> - - <xsl:otherwise> - <xsl:value-of select="$value"/> - </xsl:otherwise> + </xsl:when> + + <xsl:when test="//enum[@name=$idltype]"> + <xsl:choose> + <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:call-template> + </xsl:variable> + <xsl:value-of select="concat('Helper.convertEnums(', $elemgluetype, '.class, ', $elembacktype, '.class, ', $value, ')')"/> + </xsl:when> + <xsl:otherwise> + <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:call-template> + </xsl:variable> + <xsl:value-of select="concat($backtype, '.fromValue(', $value, '.name())')"/> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + + <xsl:when test="($idltype='octet') and ($safearray='yes')"> + <xsl:value-of select="concat('Helper.encodeBase64(', $value, ')')"/> + </xsl:when> + + <xsl:otherwise> + <xsl:value-of select="$value"/> + </xsl:otherwise> </xsl:choose> </xsl:template> @@ -1496,150 +1579,150 @@ <xsl:choose> <xsl:when test="($G_vboxGlueStyle='xpcom')"> - <xsl:value-of select="' '" /> + <xsl:text> </xsl:text> <xsl:if test="param[@dir='return']"> <xsl:value-of select="concat($retval, ' = ')" /> </xsl:if> - <xsl:value-of select="concat('getTypedWrapped().', $methodname,'(')"/> + <xsl:value-of select="concat('getTypedWrapped().', $methodname, '(')"/> <xsl:for-each select="param"> - <xsl:choose> - <xsl:when test="@dir='return'"> - <xsl:if test="@safearray='yes'"> - <xsl:value-of select="'null'" /> - </xsl:if> - </xsl:when> - <xsl:when test="@dir='out'"> - <xsl:if test="@safearray='yes'"> - <xsl:value-of select="'null, '" /> - </xsl:if> - <xsl:value-of select="concat('tmp_', @name)" /> - </xsl:when> - <xsl:when test="@dir='in'"> - <xsl:if test="(@safearray='yes') and not(@type = 'octet')"> - <xsl:value-of select="concat(@name,'.size(), ')" /> - </xsl:if> - <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:call-template> - </xsl:variable> - <xsl:value-of select="$unwrapped"/> - </xsl:when> - <xsl:otherwise> - <xsl:call-template name="fatalError"> - <xsl:with-param name="msg" select="concat('Unsupported param dir: ', @dir, '".')" /> + <xsl:choose> + <xsl:when test="@dir='return'"> + <xsl:if test="@safearray='yes'"> + <xsl:text>null</xsl:text> + </xsl:if> + </xsl:when> + <xsl:when test="@dir='out'"> + <xsl:if test="@safearray='yes'"> + <xsl:text>null, </xsl:text> + </xsl:if> + <xsl:value-of select="concat('tmp_', @name)" /> + </xsl:when> + <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:if> + <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:call-template> - </xsl:otherwise> - </xsl:choose> - <xsl:if test="not(position()=last()) and not(following-sibling::param[1]/@dir='return' and not(following-sibling::param[1]/@safearray='yes'))"> - <xsl:value-of select="', '"/> - </xsl:if> + </xsl:variable> + <xsl:value-of select="$unwrapped"/> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="fatalError"> + <xsl:with-param name="msg" select="concat('Unsupported param dir: ', @dir, '".')" /> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> + <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:if> </xsl:for-each> - <xsl:value-of select="'); '"/> + <xsl:text>); </xsl:text> </xsl:when> <xsl:when test="($G_vboxGlueStyle='mscom')"> - <xsl:value-of select="' '" /> + <xsl:text> </xsl:text> <xsl:if test="param[@dir='return']"> <xsl:value-of select="concat($retval, ' = ')" /> </xsl:if> - <xsl:value-of select="concat('Helper.invoke(getTypedWrapped(), "', $methodname, '" ')"/> + <xsl:value-of select="concat('Helper.invoke(getTypedWrapped(), "', $methodname, '" ')"/> <xsl:for-each select="param[not(@dir='return')]"> - <xsl:value-of select="', '"/> + <xsl:text>, </xsl:text> <xsl:choose> - <xsl:when test="@dir='out'"> - <xsl:value-of select="concat('tmp_', @name)" /> - </xsl:when> - <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:call-template> - </xsl:variable> - <xsl:value-of select="$unwrapped"/> - </xsl:when> + <xsl:when test="@dir='out'"> + <xsl:value-of select="concat('tmp_', @name)" /> + </xsl:when> + <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:call-template> + </xsl:variable> + <xsl:value-of select="$unwrapped"/> + </xsl:when> </xsl:choose> </xsl:for-each> - <xsl:value-of select="'); '"/> + <xsl:text>); </xsl:text> </xsl:when> - <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:call-template> - </xsl:variable> - <xsl:variable name="portArg"> - <xsl:if test="not(//interface[@name=$ifname]/@wsmap='global')"> - <xsl:value-of select="'obj'"/> - </xsl:if> - </xsl:variable> - <xsl:variable name="paramsinout" select="param[@dir='in' or @dir='out']" /> - - <xsl:value-of select="' '" /> - <xsl:if test="param[@dir='return'] and not(param[@dir='out'])"> - <xsl:value-of select="concat($retval, ' = ')" /> - </xsl:if> - <xsl:value-of select="concat('port.', $jaxwsmethod, '(', $portArg)" /> - <xsl:if test="$paramsinout and not($portArg='')"> - <xsl:value-of select="', '"/> - </xsl:if> - - <!-- 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:choose> - <xsl:when test="param[@dir='out'] and param[@dir='return']"> - <xsl:for-each select="param"> - <xsl:choose> - <xsl:when test="@dir='return'"> - <xsl:value-of select="$retval"/> - </xsl:when> - <xsl:when test="@dir='out'"> - <xsl:value-of select="concat('tmp_', @name)" /> - </xsl:when> - <xsl:otherwise> - <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:call-template> - </xsl:otherwise> - </xsl:choose> - <xsl:if test="not(position()=last())"> - <xsl:value-of select="', '"/> - </xsl:if> - </xsl:for-each> - </xsl:when> - <xsl:otherwise> - <xsl:for-each select="$paramsinout"> - <xsl:choose> - <xsl:when test="@dir='return'"> - <xsl:value-of select="$retval"/> - </xsl:when> - <xsl:when test="@dir='out'"> - <xsl:value-of select="concat('tmp_', @name)" /> - </xsl:when> - <xsl:otherwise> - <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:call-template> - </xsl:otherwise> - </xsl:choose> - <xsl:if test="not(position()=last())"> - <xsl:value-of select="', '"/> - </xsl:if> - </xsl:for-each> - </xsl:otherwise> - </xsl:choose> - <xsl:value-of select="'); '"/> - </xsl:when> + <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:call-template> + </xsl:variable> + <xsl:variable name="portArg"> + <xsl:if test="not(//interface[@name=$ifname]/@wsmap='global')"> + <xsl:text>obj</xsl:text> + </xsl:if> + </xsl:variable> + <xsl:variable name="paramsinout" select="param[@dir='in' or @dir='out']" /> + + <xsl:text> </xsl:text> + <xsl:if test="param[@dir='return'] and not(param[@dir='out'])"> + <xsl:value-of select="concat($retval, ' = ')" /> + </xsl:if> + <xsl:value-of select="concat('port.', $jaxwsmethod, '(', $portArg)" /> + <xsl:if test="$paramsinout and not($portArg='')"> + <xsl:text>, </xsl:text> + </xsl:if> + + <!-- 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:choose> + <xsl:when test="param[@dir='out'] and param[@dir='return']"> + <xsl:for-each select="param"> + <xsl:choose> + <xsl:when test="@dir='return'"> + <xsl:value-of select="$retval"/> + </xsl:when> + <xsl:when test="@dir='out'"> + <xsl:value-of select="concat('tmp_', @name)" /> + </xsl:when> + <xsl:otherwise> + <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:call-template> + </xsl:otherwise> + </xsl:choose> + <xsl:if test="not(position()=last())"> + <xsl:text>, </xsl:text> + </xsl:if> + </xsl:for-each> + </xsl:when> + <xsl:otherwise> + <xsl:for-each select="$paramsinout"> + <xsl:choose> + <xsl:when test="@dir='return'"> + <xsl:value-of select="$retval"/> + </xsl:when> + <xsl:when test="@dir='out'"> + <xsl:value-of select="concat('tmp_', @name)" /> + </xsl:when> + <xsl:otherwise> + <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:call-template> + </xsl:otherwise> + </xsl:choose> + <xsl:if test="not(position()=last())"> + <xsl:text>, </xsl:text> + </xsl:if> + </xsl:for-each> + </xsl:otherwise> + </xsl:choose> + <xsl:text>); </xsl:text> + </xsl:when> <xsl:otherwise> <xsl:call-template name="fatalError"> @@ -1657,35 +1740,33 @@ <xsl:param name="retval"/> <xsl:choose> + <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:if> + <xsl:text>); </xsl:text> + </xsl:when> - <xsl:when test="$G_vboxGlueStyle='xpcom'"> - <xsl:value-of select="concat(' ', $backtype, ' ', $retval,' = getTypedWrapped().', $gettername,'(')" /> - <xsl:if test="@safearray"> - <xsl:value-of select="'null'" /> - </xsl:if> - <xsl:value-of select="'); '" /> - </xsl:when> - - <xsl:when test="$G_vboxGlueStyle='mscom'"> - <xsl:value-of select="concat(' ', $backtype, ' ', $retval,' = Dispatch.get(getTypedWrapped(), "', @name,'"); ')" /> - </xsl:when> - - <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:call-template> - </xsl:variable> - <xsl:value-of select="concat(' ', $backtype, ' ', $retval,' = port.', $jaxwsGetter, '(obj); ')" /> - </xsl:when> - - <xsl:otherwise> - <xsl:call-template name="fatalError"> - <xsl:with-param name="msg" select="'Style unknown (genGetterCall)'" /> - </xsl:call-template> - </xsl:otherwise> + <xsl:when test="$G_vboxGlueStyle='mscom'"> + <xsl:value-of select="concat(' ', $backtype, ' ', $retval, ' = Dispatch.get(getTypedWrapped(), "', @name, '"); ')" /> + </xsl:when> + + <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:call-template> + </xsl:variable> + <xsl:value-of select="concat(' ', $backtype, ' ', $retval, ' = port.', $jaxwsGetter, '(obj); ')" /> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="fatalError"> + <xsl:with-param name="msg" select="'Style unknown (genGetterCall)'" /> + </xsl:call-template> + </xsl:otherwise> </xsl:choose> </xsl:template> @@ -1695,104 +1776,111 @@ <xsl:param name="value"/> <xsl:choose> - <xsl:when test="$G_vboxGlueStyle='xpcom'"> - <xsl:value-of select="concat(' getTypedWrapped().', $settername, '(', $value,'); ')" /> - </xsl:when> + <xsl:when test="$G_vboxGlueStyle='xpcom'"> + <xsl:value-of select="concat(' getTypedWrapped().', $settername, '(', $value, '); ')" /> + </xsl:when> - <xsl:when test="$G_vboxGlueStyle='mscom'"> - <xsl:value-of select="concat(' Dispatch.put(getTypedWrapped(), "', @name,'", ',$value, '); ')" /> - </xsl:when> + <xsl:when test="$G_vboxGlueStyle='mscom'"> + <xsl:value-of select="concat(' Dispatch.put(getTypedWrapped(), "', @name, '", ', $value, '); ')" /> + </xsl:when> - <xsl:when test="$G_vboxGlueStyle='jaxws'"> + <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:call-template> </xsl:variable> - <xsl:value-of select="concat(' port.', $jaxwsSetter, '(obj, ', $value,'); ')" /> - </xsl:when> - - <xsl:otherwise> - <xsl:call-template name="fatalError"> - <xsl:with-param name="msg" select="'Style unknown (genSetterCall)'" /> - </xsl:call-template> - </xsl:otherwise> + <xsl:value-of select="concat(' port.', $jaxwsSetter, '(obj, ', $value, '); ')" /> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="fatalError"> + <xsl:with-param name="msg" select="'Style unknown (genSetterCall)'" /> + </xsl:call-template> + </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="genStructWrapperJaxws"> <xsl:param name="ifname"/> - <xsl:value-of select="concat(' private ', $G_virtualBoxPackageCom,'.',$ifname, ' real; ')"/> - <xsl:value-of select="' private VboxPortType port; '"/> + <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) { this.real = real; this.port = port; } ')"/> + <xsl:value-of select="concat(' public ', $ifname, '(', $G_virtualBoxPackageCom, '.', $ifname, ' real, VboxPortType port) ')" /> + <xsl:text> { </xsl:text> + <xsl:text> this.real = real; </xsl:text> + <xsl:text> this.port = port; </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="attrreadonly"><xsl:value-of select="@readonly" /></xsl:variable> <xsl:variable name="attrsafearray"><xsl:value-of select="@safearray" /></xsl:variable> - <xsl:if test="not($attrreadonly)"> - <xsl:call-template name="fatalError"> - <xsl:with-param name="msg" select="'Non read-only struct (genStructWrapperJaxws)'" /> - </xsl:call-template> - </xsl:if> + <xsl:if test="not(@wsmap = 'suppress')"> - <!-- Emit getter --> - <xsl:variable name="backgettername"> - <xsl:choose> - <!-- 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: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:call-template> + </xsl:if> + + <!-- Emit getter --> + <xsl:variable name="backgettername"> + <xsl:choose> + <!-- 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:call-template> + </xsl:variable> + <xsl:value-of select="concat('is', $capsname)" /> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="makeGetterName"> + <xsl:with-param name="attrname" select="$attrname" /> </xsl:call-template> - </xsl:variable> - <xsl:value-of select="concat('is', $capsname)" /> - </xsl:when> - <xsl:otherwise> - <xsl:call-template name="makeGetterName"> - <xsl:with-param name="attrname" select="$attrname" /> - </xsl:call-template> - </xsl:otherwise> - </xsl:choose> - </xsl:variable> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> - <xsl:variable name="gluegettername"> - <xsl:call-template name="makeGetterName"> - <xsl:with-param name="attrname" select="$attrname" /> - </xsl:call-template> - </xsl:variable> + <xsl:variable name="gluegettername"> + <xsl:call-template name="makeGetterName"> + <xsl:with-param name="attrname" select="$attrname" /> + </xsl:call-template> + </xsl:variable> - <xsl:variable name="gluegettertype"> - <xsl:call-template name="typeIdl2Glue"> - <xsl:with-param name="type" select="$attrtype" /> - <xsl:with-param name="safearray" select="@safearray" /> - </xsl:call-template> - </xsl:variable> + <xsl:variable name="gluegettertype"> + <xsl:call-template name="typeIdl2Glue"> + <xsl:with-param name="type" select="$attrtype" /> + <xsl:with-param name="safearray" select="@safearray" /> + </xsl:call-template> + </xsl:variable> - <xsl:variable name="backgettertype"> - <xsl:call-template name="typeIdl2Back"> - <xsl:with-param name="type" select="$attrtype" /> - <xsl:with-param name="safearray" select="@safearray" /> - </xsl:call-template> - </xsl:variable> - - <xsl:value-of select="concat(' public ', $gluegettertype, ' ', $gluegettername, '() { ')" /> - <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:call-template> - </xsl:variable> - <xsl:value-of select="concat(' return ', $wrapped, '; ')" /> - <xsl:value-of select=" ' } '" /> + <xsl:variable name="backgettertype"> + <xsl:call-template name="typeIdl2Back"> + <xsl:with-param name="type" select="$attrtype" /> + <xsl:with-param name="safearray" select="@safearray" /> + </xsl:call-template> + </xsl:variable> + + <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:call-template> + </xsl:variable> + <xsl:value-of select="concat(' return ', $wrapped, '; ')" /> + <xsl:text> } </xsl:text> + </xsl:if> </xsl:for-each> @@ -1805,9 +1893,10 @@ <xsl:choose> <xsl:when test="(param[@mod='ptr']) or (($G_vboxGlueStyle='jaxws') and (param[@type=($G_setSuppressedInterfaces/@name)]))" > - <xsl:comment> - <xsl:value-of select="concat('Skipping method ', $methodname, ' for it has parameters with suppressed types')" /> - </xsl:comment> + <xsl:value-of select="concat(' // Skipping method ', $methodname, ' for it has parameters with suppressed types ')" /> + </xsl:when> + <xsl:when test="($G_vboxGlueStyle='jaxws') and (@wsmap = 'suppress')" > + <xsl:value-of select="concat(' // Skipping method ', $methodname, ' for it is suppressed ')" /> </xsl:when> <xsl:otherwise> <xsl:variable name="hasReturnParms" select="param[@dir='return']" /> @@ -1830,10 +1919,10 @@ <xsl:variable name="retValValue"> <xsl:choose> <xsl:when test="(param[@dir='out']) and ($G_vboxGlueStyle='jaxws')"> - <xsl:value-of select="'retVal.value'"/> + <xsl:text>retVal.value</xsl:text> </xsl:when> <xsl:otherwise> - <xsl:value-of select="'retVal'"/> + <xsl:text>retVal</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:variable> @@ -1856,10 +1945,11 @@ </xsl:otherwise> </xsl:choose> <xsl:if test="not(position()=last())"> - <xsl:value-of select="', '" /> + <xsl:text>, </xsl:text> </xsl:if> </xsl:for-each> - <xsl:value-of select="') { '"/> + <xsl:text>) </xsl:text> + <xsl:text> { </xsl:text> <xsl:call-template name="startExcWrapper"/> @@ -1873,13 +1963,13 @@ </xsl:variable> <xsl:choose> <xsl:when test="$G_vboxGlueStyle='xpcom'"> - <xsl:value-of select="concat(' ', $backouttype, '[] tmp_', @name, ' = (', $backouttype, '[])java.lang.reflect.Array.newInstance(',$backouttype,'.class, 1); ')"/> + <xsl:value-of select="concat(' ', $backouttype, '[] tmp_', @name, ' = (', $backouttype, '[])java.lang.reflect.Array.newInstance(', $backouttype, '.class, 1); ')"/> </xsl:when> <xsl:when test="$G_vboxGlueStyle='mscom'"> - <xsl:value-of select="concat(' Variant tmp_', @name, ' = new Variant(); ')"/> + <xsl:value-of select="concat(' Variant tmp_', @name, ' = new Variant(); ')"/> </xsl:when> <xsl:when test="$G_vboxGlueStyle='jaxws'"> - <xsl:value-of select="concat(' javax.xml.ws.Holder<', $backouttype,'> tmp_', @name, ' = new javax.xml.ws.Holder<', $backouttype,'>(); ')"/> + <xsl:value-of select="concat(' javax.xml.ws.Holder<', $backouttype, '> tmp_', @name, ' = new javax.xml.ws.Holder<', $backouttype, '>(); ')"/> </xsl:when> <xsl:otherwise> <xsl:call-template name="fatalError"> @@ -1904,7 +1994,7 @@ '>(); ')"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="concat(' ', $backrettype, ' retVal; ')"/> + <xsl:value-of select="concat(' ', $backrettype, ' retVal; ')"/> </xsl:otherwise> </xsl:choose> </xsl:if> @@ -1916,18 +2006,18 @@ <xsl:with-param name="retval" select="'retVal'" /> </xsl:call-template> - <!-- return out params --> + <!-- return out params --> <xsl:for-each select="param[@dir='out']"> <xsl:variable name="varval"> <xsl:choose> <xsl:when test="$G_vboxGlueStyle='xpcom'"> - <xsl:value-of select="concat('tmp_',@name,'[0]')" /> + <xsl:value-of select="concat('tmp_', @name, '[0]')" /> </xsl:when> <xsl:when test="$G_vboxGlueStyle='mscom'"> - <xsl:value-of select="concat('tmp_',@name)" /> + <xsl:value-of select="concat('tmp_', @name)" /> </xsl:when> <xsl:when test="$G_vboxGlueStyle='jaxws'"> - <xsl:value-of select="concat('tmp_',@name,'.value')" /> + <xsl:value-of select="concat('tmp_', @name, '.value')" /> </xsl:when> <xsl:otherwise> <xsl:call-template name="fatalError"> @@ -1943,7 +2033,7 @@ <xsl:with-param name="safearray" select="@safearray" /> </xsl:call-template> </xsl:variable> - <xsl:value-of select="concat(' ', @name, '.value = ',$wrapped,'; ')"/> + <xsl:value-of select="concat(' ', @name, '.value = ', $wrapped, '; ')"/> </xsl:for-each> <xsl:if test="$hasReturnParms"> @@ -1959,7 +2049,7 @@ </xsl:if> <xsl:call-template name="endExcWrapper"/> - <xsl:value-of select="' } '"/> + <xsl:text> } </xsl:text> </xsl:otherwise> </xsl:choose> @@ -1972,9 +2062,7 @@ <xsl:choose> <xsl:when test="(param[@mod='ptr'])" > - <xsl:comment> - <xsl:value-of select="concat('Skipping method ', $methodname, ' for it has parameters with suppressed types')" /> - </xsl:comment> + <xsl:value-of select="concat(' // Skipping method ', $methodname, ' for it has parameters with suppressed types ')" /> </xsl:when> <xsl:otherwise> <xsl:variable name="returnidltype" select="param[@dir='return']/@type" /> @@ -2013,7 +2101,7 @@ <xsl:text>, </xsl:text> </xsl:if> </xsl:for-each> - <xsl:value-of select="'); '"/> + <xsl:text>); </xsl:text> </xsl:otherwise> </xsl:choose> </xsl:template> @@ -2023,7 +2111,8 @@ <xsl:param name="ifname"/> <xsl:param name="uuid" /> - <xsl:value-of select="concat(' public static ', $ifname, ' queryInterface(IUnknown obj) { ')" /> + <xsl:value-of select="concat(' public static ', $ifname, ' queryInterface(IUnknown obj) ')" /> + <xsl:text> { </xsl:text> <xsl:choose> <xsl:when test="$G_vboxGlueStyle='xpcom'"> <xsl:variable name="backtype"> @@ -2031,9 +2120,9 @@ <xsl:with-param name="type" select="$ifname" /> </xsl:call-template> </xsl:variable> - <xsl:value-of select=" ' nsISupports nsobj = obj != null ? (nsISupports)obj.getWrapped() : null; '"/> - <xsl:value-of select=" ' if (nsobj == null) return null; '"/> - <xsl:value-of select="concat(' ',$backtype, ' qiobj = Helper.queryInterface(nsobj, "{',$uuid,'}", ',$backtype,'.class); ')" /> + <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> @@ -2053,7 +2142,7 @@ </xsl:otherwise> </xsl:choose> - <xsl:value-of select=" ' } '" /> + <xsl:text> } </xsl:text> </xsl:template> @@ -2063,9 +2152,7 @@ <xsl:choose> <xsl:when test="(param[@mod='ptr'])" > - <xsl:comment> - <xsl:value-of select="concat('Skipping method ', $methodname, ' for it has parameters with suppressed types')" /> - </xsl:comment> + <xsl:value-of select="concat(' // Skipping method ', $methodname, ' for it has parameters with suppressed types ')" /> </xsl:when> <xsl:otherwise> <xsl:variable name="hasReturnParms" select="param[@dir='return']" /> @@ -2102,7 +2189,7 @@ </xsl:when> <xsl:otherwise> <xsl:if test="@safearray"> - <xsl:value-of select="concat('long len_',@name,', ')" /> + <xsl:value-of select="concat('long len_', @name, ', ')" /> </xsl:if> <xsl:value-of select="concat($parambacktype, ' ', @name)" /> </xsl:otherwise> @@ -2111,7 +2198,8 @@ <xsl:text>, </xsl:text> </xsl:if> </xsl:for-each> - <xsl:value-of select="') { '"/> + <xsl:text>) </xsl:text> + <xsl:text> { </xsl:text> </xsl:when> <xsl:when test="$G_vboxGlueStyle='mscom'"> @@ -2121,8 +2209,8 @@ </xsl:call-template> </xsl:variable> <xsl:value-of select="concat(' public ', $returnbacktype, ' ', $capsname, '(')" /> - <xsl:value-of select="'Variant _args[]'"/> - <xsl:value-of select="') { '"/> + <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"> @@ -2130,16 +2218,15 @@ <xsl:with-param name="safearray" select="@safearray" /> </xsl:call-template> </xsl:variable> - <xsl:value-of select="concat(' ', $parambacktype, ' ', @name, '=_args[', count(preceding-sibling::param),']; ')" /> + <xsl:value-of select="concat(' ', $parambacktype, ' ', @name, '=_args[', count(preceding-sibling::param), ']; ')" /> </xsl:for-each> </xsl:when> - <xsl:otherwise> - <xsl:call-template name="fatalError"> - <xsl:with-param name="msg" select="'Style unknown (genSetterCall)'" /> - </xsl:call-template> - </xsl:otherwise> - + <xsl:otherwise> + <xsl:call-template name="fatalError"> + <xsl:with-param name="msg" select="'Style unknown (genSetterCall)'" /> + </xsl:call-template> + </xsl:otherwise> </xsl:choose> <!-- declare temp out params --> @@ -2165,50 +2252,50 @@ </xsl:if> <!-- Method call --> - <xsl:value-of select="concat(' sink.', $methodname,'(')"/> + <xsl:value-of select="concat(' sink.', $methodname, '(')"/> <xsl:for-each select="param[not(@dir='return')]"> - <xsl:choose> - <xsl:when test="@dir='out'"> - <xsl:value-of select="concat('tmp_', @name)" /> - </xsl:when> - <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:call-template> - </xsl:variable> - <xsl:value-of select="$wrapped"/> - </xsl:when> - <xsl:otherwise> - <xsl:call-template name="fatalError"> - <xsl:with-param name="msg" select="concat('Unsupported param dir: ', @dir, '".')" /> + <xsl:choose> + <xsl:when test="@dir='out'"> + <xsl:value-of select="concat('tmp_', @name)" /> + </xsl:when> + <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:call-template> - </xsl:otherwise> - </xsl:choose> - <xsl:if test="not(position()=last())"> - <xsl:value-of select="', '"/> - </xsl:if> + </xsl:variable> + <xsl:value-of select="$wrapped"/> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="fatalError"> + <xsl:with-param name="msg" select="concat('Unsupported param dir: ', @dir, '".')" /> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> + <xsl:if test="not(position()=last())"> + <xsl:text>, </xsl:text> + </xsl:if> </xsl:for-each> - <xsl:value-of select="'); '"/> + <xsl:text>); </xsl:text> - <!-- return out params --> + <!-- 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="value" select="concat('tmp_', @name, '.value')" /> <xsl:with-param name="idltype" select="@type" /> <xsl:with-param name="safearray" select="@safearray" /> </xsl:call-template> </xsl:variable> <xsl:choose> <xsl:when test="$G_vboxGlueStyle='xpcom'"> - <xsl:value-of select="concat(' ', @name, '[0] = ',$unwrapped,'; ')"/> + <xsl:value-of select="concat(' ', @name, '[0] = ', $unwrapped, '; ')"/> </xsl:when> <xsl:when test="$G_vboxGlueStyle='mscom'"> - <xsl:value-of select="concat(' _args[',count(preceding-sibling::param),'] = ',$unwrapped,'; ')"/> + <xsl:value-of select="concat(' _args[', count(preceding-sibling::param), '] = ', $unwrapped, '; ')"/> </xsl:when> </xsl:choose> </xsl:for-each> @@ -2224,7 +2311,7 @@ </xsl:variable> <xsl:value-of select="concat(' return ', $unwrapped, '; ')" /> </xsl:if> - <xsl:value-of select="' } '"/> + <xsl:text> } </xsl:text> </xsl:otherwise> </xsl:choose> </xsl:template> @@ -2242,20 +2329,23 @@ <!-- Constructor --> <xsl:choose> <xsl:when test="($G_vboxGlueStyle='jaxws')"> - <xsl:value-of select="concat(' public ', $ifname, '(String wrapped, VboxPortType port) { ')" /> - <xsl:value-of select=" ' super(wrapped, port); '"/> - <xsl:value-of select=" ' } '"/> + <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> <xsl:when test="($G_vboxGlueStyle='xpcom') or ($G_vboxGlueStyle='mscom')"> - <xsl:value-of select="concat(' public ', $ifname, '(', $wrappedType,' wrapped) { ')" /> - <xsl:value-of select=" ' super(wrapped); '"/> - <xsl:value-of select=" ' } '"/> + <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:value-of select="concat(' return (', $wrappedType, ') getWrapped(); ')" /> - <xsl:value-of select=" ' } '" /> + <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:when> <xsl:otherwise> @@ -2268,12 +2358,14 @@ <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="attrreadonly"><xsl:value-of select="@readonly" /></xsl:variable> <xsl:variable name="attrsafearray"><xsl:value-of select="@safearray" /></xsl:variable> <xsl:choose> <xsl:when test="($G_vboxGlueStyle='jaxws') and ($attrtype=($G_setSuppressedInterfaces/@name))"> - <xsl:value-of select="concat(' // skip attribute ',$attrname, ' of suppressed type ', $attrtype, ' ')" /> + <xsl:value-of select="concat(' // Skipping attribute ', $attrname, ' of suppressed type ', $attrtype, ' ')" /> + </xsl:when> + <xsl:when test="($G_vboxGlueStyle='jaxws') and (@wsmap = 'suppress')" > + <xsl:value-of select="concat(' // Skipping attribute ', $attrname, ' for it is suppressed ')" /> </xsl:when> <xsl:otherwise> @@ -2303,7 +2395,8 @@ <xsl:with-param name="safearray" select="@safearray" /> </xsl:call-template> </xsl:variable> - <xsl:value-of select="concat(' public ', $gluetype, ' ', $gettername, '() { ')" /> + <xsl:value-of select="concat(' public ', $gluetype, ' ', $gettername, '() ')" /> + <xsl:text> { </xsl:text> <xsl:call-template name="startExcWrapper"/> @@ -2315,11 +2408,11 @@ <xsl:with-param name="retval" select="'retVal'" /> </xsl:call-template> - <xsl:value-of select="concat(' return ', $wrapped, '; ')" /> + <xsl:value-of select="concat(' return ', $wrapped, '; ')" /> <xsl:call-template name="endExcWrapper"/> - <xsl:value-of select= "' } '" /> - <xsl:if test="not(@readonly='yes')"> + <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> @@ -2331,7 +2424,8 @@ <xsl:with-param name="safearray" select="@safearray" /> </xsl:call-template> </xsl:variable> - <xsl:value-of select="concat(' public void ', $settername, '(', $gluetype, ' value) { ')" /> + <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"> @@ -2340,7 +2434,7 @@ <xsl:with-param name="value" select="$unwrapped" /> </xsl:call-template> <xsl:call-template name="endExcWrapper"/> - <xsl:value-of select= "' } '" /> + <xsl:text> } </xsl:text> </xsl:if> </xsl:otherwise> @@ -2375,41 +2469,46 @@ <xsl:with-param name="package" select="$G_virtualBoxPackage" /> </xsl:call-template> - <xsl:text>import java.util.List; </xsl:text> + <xsl:if test="$filelistonly=''"> + <xsl:text>import java.util.List; </xsl:text> - <xsl:apply-templates select="desc" mode="interface"/> + <xsl:apply-templates select="desc" mode="interface"/> - <xsl:choose> - <xsl:when test="($wsmap='struct') and ($G_vboxGlueStyle='jaxws')"> - <xsl:value-of select="concat('public class ', $ifname, ' { ')" /> - <xsl:call-template name="genStructWrapperJaxws"> - <xsl:with-param name="ifname" select="$ifname" /> - </xsl:call-template> - </xsl:when> + <xsl:choose> + <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:call-template> + </xsl:when> - <xsl:otherwise> - <xsl:variable name="extends" select="//interface[@name=$ifname]/@extends" /> - <xsl:choose> - <xsl:when test="($extends = '$unknown') or ($extends = '$dispatched') or ($extends = '$errorinfo')"> - <xsl:value-of select="concat('public class ', $ifname, ' extends IUnknown { ')" /> - </xsl:when> - <xsl:when test="//interface[@name=$extends]"> - <xsl:value-of select="concat('public class ', $ifname, ' extends ', $extends, ' { ')" /> - </xsl:when> - <xsl:otherwise> - <xsl:call-template name="fatalError"> - <xsl:with-param name="msg" select="concat('Interface generation: interface "', $ifname, '" has invalid "extends" value ', $extends, '.')" /> - </xsl:call-template> - </xsl:otherwise> - </xsl:choose> - <xsl:call-template name="genIfaceWrapper"> - <xsl:with-param name="ifname" select="$ifname" /> - </xsl:call-template> - </xsl:otherwise> - </xsl:choose> + <xsl:otherwise> + <xsl:variable name="extends" select="//interface[@name=$ifname]/@extends" /> + <xsl:choose> + <xsl:when test="($extends = '$unknown') or ($extends = '$errorinfo')"> + <xsl:value-of select="concat('public class ', $ifname, ' extends IUnknown ')" /> + <xsl:text>{ </xsl:text> + </xsl:when> + <xsl:when test="//interface[@name=$extends]"> + <xsl:value-of select="concat('public class ', $ifname, ' extends ', $extends, ' ')" /> + <xsl:text>{ </xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="fatalError"> + <xsl:with-param name="msg" select="concat('Interface generation: interface "', $ifname, '" has invalid "extends" value ', $extends, '.')" /> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> + <xsl:call-template name="genIfaceWrapper"> + <xsl:with-param name="ifname" select="$ifname" /> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> - <!-- end of class --> - <xsl:value-of select="'} '" /> + <!-- end of class --> + <xsl:text>} </xsl:text> + </xsl:if> <xsl:call-template name="endFile"> <xsl:with-param name="file" select="$filename" /> @@ -2429,7 +2528,8 @@ <xsl:text>import java.util.List; </xsl:text> - <xsl:value-of select="concat('public interface ', $ifname, ' { ')" /> + <xsl:value-of select="concat('public interface ', $ifname, ' ')" /> + <xsl:text>{ </xsl:text> <!-- emit methods declarations--> <xsl:for-each select="method"> @@ -2439,7 +2539,7 @@ </xsl:call-template> </xsl:for-each> - <xsl:value-of select="'} '" /> + <xsl:text>} </xsl:text> <xsl:call-template name="endFile"> <xsl:with-param name="file" select="$filename" /> @@ -2461,19 +2561,22 @@ <!-- emit glue methods body --> <xsl:choose> <xsl:when test="$G_vboxGlueStyle='xpcom'"> - <xsl:value-of select="concat('class ', $ifname, 'Impl extends nsISupportsBase implements ', $backtype, ' { ')" /> + <xsl:value-of select="concat('class ', $ifname, 'Impl extends nsISupportsBase implements ', $backtype, ' ')" /> + <xsl:text>{ </xsl:text> </xsl:when> <xsl:when test="$G_vboxGlueStyle='mscom'"> - <xsl:value-of select="concat('public class ', $ifname, 'Impl { ')" /> + <xsl:value-of select="concat('public class ', $ifname, 'Impl ')" /> + <xsl:text>{ </xsl:text> </xsl:when> </xsl:choose> <xsl:value-of select="concat(' ', $ifname, ' sink; ')" /> - <xsl:value-of select="concat(' ', $ifname, 'Impl(', $ifname,' sink) { ')" /> - <xsl:value-of select="' this.sink = sink; '" /> - <xsl:value-of select="' } '" /> + <xsl:value-of select="concat(' ', $ifname, 'Impl(', $ifname, ' sink) ')" /> + <xsl:text> { </xsl:text> + <xsl:text> this.sink = sink; </xsl:text> + <xsl:text> } </xsl:text> <!-- emit methods implementations --> <xsl:for-each select="method"> @@ -2483,7 +2586,7 @@ </xsl:call-template> </xsl:for-each> - <xsl:value-of select="'} '" /> + <xsl:text>} </xsl:text> <xsl:call-template name="endFile"> <xsl:with-param name="file" select="$filenameimpl" /> @@ -2492,298 +2595,376 @@ <xsl:template name="emitHandwritten"> -<xsl:call-template name="startFile"> + <xsl:call-template name="startFile"> <xsl:with-param name="file" select="'Holder.java'" /> <xsl:with-param name="package" select="$G_virtualBoxPackage" /> </xsl:call-template> - <xsl:text><![CDATA[ + <xsl:if test="$filelistonly=''"> + <xsl:text><![CDATA[ public class Holder<T> { - public T value; - - public Holder() - { - } - public Holder(T value) - { - this.value = value; - } -} -]]></xsl:text> - - <xsl:call-template name="endFile"> - <xsl:with-param name="file" select="'Holder.java'" /> - </xsl:call-template> + public T value; -<xsl:call-template name="startFile"> - <xsl:with-param name="file" select="'VBoxException.java'" /> - <xsl:with-param name="package" select="$G_virtualBoxPackage" /> - </xsl:call-template> - - <xsl:text><![CDATA[ -public class VBoxException extends RuntimeException -{ - private Throwable wrapped; - private String msg; - - public VBoxException(Throwable wrapped, String msg) - { - this.wrapped = wrapped; - this.msg = msg; - } - public Throwable getWrapped() - { - return wrapped; - } - public String getMessage() - { - return msg; - } + public Holder() + { + } + public Holder(T value) + { + this.value = value; + } } ]]></xsl:text> + </xsl:if> - <xsl:call-template name="endFile"> - <xsl:with-param name="file" select="'VBoxException.java'" /> - </xsl:call-template> - - + <xsl:call-template name="endFile"> + <xsl:with-param name="file" select="'Holder.java'" /> + </xsl:call-template> </xsl:template> <xsl:template name="emitHandwrittenXpcom"> -<xsl:call-template name="startFile"> + <xsl:call-template name="startFile"> <xsl:with-param name="file" select="'IUnknown.java'" /> <xsl:with-param name="package" select="$G_virtualBoxPackageCom" /> </xsl:call-template> - <xsl:text><![CDATA[ + <xsl:if test="$filelistonly=''"> + <xsl:text><![CDATA[ public class IUnknown { - private Object obj; - public IUnknown(Object obj) - { - this.obj = obj; - } - - public Object getWrapped() - { - return this.obj; - } - - public void setWrapped(Object obj) - { - this.obj = obj; - } + private Object obj; + public IUnknown(Object obj) + { + this.obj = obj; + } + + public Object getWrapped() + { + return this.obj; + } + + public void setWrapped(Object obj) + { + this.obj = obj; + } } ]]></xsl:text> + </xsl:if> - <xsl:call-template name="endFile"> - <xsl:with-param name="file" select="'IUnknown.java'" /> - </xsl:call-template> + <xsl:call-template name="endFile"> + <xsl:with-param name="file" select="'IUnknown.java'" /> + </xsl:call-template> - <xsl:call-template name="startFile"> - <xsl:with-param name="file" select="'Helper.java'" /> - <xsl:with-param name="package" select="$G_virtualBoxPackageCom" /> - </xsl:call-template> + <xsl:call-template name="startFile"> + <xsl:with-param name="file" select="'Helper.java'" /> + <xsl:with-param name="package" select="$G_virtualBoxPackageCom" /> + </xsl:call-template> -<xsl:text><![CDATA[ + <xsl:if test="$filelistonly=''"> + <xsl:text><![CDATA[ import java.util.List; import java.util.ArrayList; import java.util.Collections; import java.lang.reflect.Array; import java.lang.reflect.Constructor; +import java.lang.reflect.Method; import java.lang.reflect.InvocationTargetException; -public class Helper { - public static List<Short> wrap(byte[] vals) { - if (vals==null) +public class Helper +{ + public static List<Short> wrap(byte[] values) + { + if (values == null) + return null; + + List<Short> ret = new ArrayList<Short>(values.length); + for (short v : values) + { + ret.add(v); + } + return ret; + } + + public static List<Short> wrap(short[] values) + { + if (values == null) return null; - List<Short> ret = new ArrayList<Short>(vals.length); - for (short v : vals) { - ret.add(v); + List<Short> ret = new ArrayList<Short>(values.length); + for (short v : values) + { + ret.add(v); } return ret; } - public static List<Integer> wrap(int[] vals) { - if (vals==null) - return null; + public static List<Integer> wrap(int[] values) + { + if (values == null) + return null; - List<Integer> ret = new ArrayList<Integer>(vals.length); - for (int v : vals) { - ret.add(v); + List<Integer> ret = new ArrayList<Integer>(values.length); + for (int v : values) + { + ret.add(v); } return ret; } - public static List<Long> wrap(long[] vals) { - if (vals==null) - return null; + public static List<Long> wrap(long[] values) + { + if (values == null) + return null; - List<Long> ret = new ArrayList<Long>(vals.length); - for (long v : vals) { - ret.add(v); + List<Long> ret = new ArrayList<Long>(values.length); + for (long v : values) + { + ret.add(v); } return ret; } - public static List<String> wrap(String[] vals) { - if (vals==null) + public static List<Boolean> wrap(boolean[] values) + { + if (values == null) return null; - List<String> ret = new ArrayList<String>(vals.length); - for (String v : vals) { + + List<Boolean> ret = new ArrayList<Boolean>(values.length); + for (boolean v: values) + { ret.add(v); } return ret; } - public static <T> List<T> wrap(Class<T> wrapperClass, T[] thisPtrs) { - if (thisPtrs==null) - return null; + public static List<String> wrap(String[] values) + { + if (values == null) + return null; - List<T> ret = new ArrayList<T>(thisPtrs.length); - for (T thisPtr : thisPtrs) { - ret.add(thisPtr); + List<String> ret = new ArrayList<String>(values.length); + for (String v : values) + { + ret.add(v); } return ret; } - public static <T> List<T> wrapEnum(Class<T> wrapperClass, long values[]) { - try { - if (values==null) - return null; - Constructor<T> c = wrapperClass.getConstructor(int.class); + public static <T> List<T> wrap(Class<T> wrapperClass, T[] values) + { + if (values == null) + return null; + + List<T> ret = new ArrayList<T>(values.length); + for (T v : values) + { + ret.add(v); + } + return ret; + } + + @SuppressWarnings( "unchecked") + public static <T> List<T> wrapEnum(Class<T> wrapperClass, long values[]) + { + try + { + if (values == null) + return null; + //// 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. + //Constructor<T> c = wrapperClass.getDeclaredConstructor(String.class, int.class, int.class); + //c.setAccessible(true); // make it callable + //List<T> ret = new ArrayList<T>(values.length); + //for (long v : values) + //{ + // T convEnum = c.newInstance("unknown", (int)v, (int)v); + // ret.add(convEnum); + //} + + // 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. + java.lang.reflect.Method fromValue = wrapperClass.getMethod("fromValue", long.class); List<T> ret = new ArrayList<T>(values.length); - for (long v : values) { - ret.add(c.newInstance(v)); + for (long v : values) + { + T convEnum = (T)fromValue.invoke(null, v); + ret.add(convEnum); } return ret; - } catch (NoSuchMethodException e) { - throw new AssertionError(e); - } catch (InstantiationException e) { + } + catch (NoSuchMethodException e) + { throw new AssertionError(e); - } catch (IllegalAccessException e) { + } + //catch (InstantiationException e) + //{ + // throw new AssertionError(e); + //} + catch (IllegalAccessException e) + { throw new AssertionError(e); - } catch (InvocationTargetException e) { + } + catch (InvocationTargetException e) + { throw new AssertionError(e); } } - public static short[] unwrapUShort(List<Short> vals) { - if (vals==null) - return null; + public static short[] unwrapUShort(List<Short> values) + { + if (values == null) + return null; - short[] ret = new short[vals.size()]; + short[] ret = new short[values.size()]; int i = 0; - for (short l : vals) { - ret[i++] = l; + for (short l : values) + { + ret[i++] = l; } return ret; } - public static int[] unwrapInteger(List<Integer> vals) { - if (vals == null) - return null; + public static int[] unwrapInteger(List<Integer> values) + { + if (values == null) + return null; - int[] ret = new int[vals.size()]; + int[] ret = new int[values.size()]; int i = 0; - for (int l : vals) { - ret[i++] = l; + for (int l : values) + { + ret[i++] = l; } return ret; } - public static long[] unwrapULong(List<Long> vals) { - if (vals == null) - return null; + public static long[] unwrapULong(List<Long> values) + { + if (values == null) + return null; - long[] ret = new long[vals.size()]; + long[] ret = new long[values.size()]; int i = 0; - for (long l : vals) { - ret[i++] = l; + for (long l : values) + { + ret[i++] = l; } return ret; } - public static boolean[] unwrapBoolean(List<Boolean> vals) { - if (vals==null) - return null; + public static boolean[] unwrapBoolean(List<Boolean> values) + { + if (values == null) + return null; - boolean[] ret = new boolean[vals.size()]; + boolean[] ret = new boolean[values.size()]; int i = 0; - for (boolean l : vals) { - ret[i++] = l; + for (boolean l : values) + { + ret[i++] = l; } return ret; } - public static String[] unwrapStr(List<String> vals) { - if (vals==null) + public static String[] unwrapStr(List<String> values) + { + if (values == null) return null; - String[] ret = new String[vals.size()]; + String[] ret = new String[values.size()]; int i = 0; - for (String l : vals) { - ret[i++] = l; + for (String l : values) + { + ret[i++] = l; } return ret; } - public static <T extends Enum <T>> long[] unwrapEnum(Class<T> enumClass, List<T> values) { - if (values == null) return null; + public static <T extends Enum <T>> long[] unwrapEnum(Class<T> enumClass, List<T> values) + { + if (values == null) + return null; long result[] = new long[values.size()]; - try { - java.lang.reflect.Method valueM = enumClass.getMethod("value"); - int i = 0; - for (T v : values) { - result[i++] = (Integer)valueM.invoke(v); - } - return result; - } 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); + try + { + java.lang.reflect.Method valueM = enumClass.getMethod("value"); + int i = 0; + for (T v : values) + { + result[i++] = (Integer)valueM.invoke(v); + } + return result; + } + 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[] thisPtrs) { - try { - if (thisPtrs==null) + public static <T1, T2> List<T1> wrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, T2[] values) + { + try + { + if (values == null) return null; Constructor<T1> c = wrapperClass1.getConstructor(wrapperClass2); - List<T1> ret = new ArrayList<T1>(thisPtrs.length); - for (T2 thisPtr : thisPtrs) { - ret.add(c.newInstance(thisPtr)); + List<T1> ret = new ArrayList<T1>(values.length); + for (T2 v : values) + { + ret.add(c.newInstance(v)); } return ret; - } catch (NoSuchMethodException e) { + } + catch (NoSuchMethodException e) + { throw new AssertionError(e); - } catch (InstantiationException e) { + } + catch (InstantiationException e) + { throw new AssertionError(e); - } catch (IllegalAccessException e) { + } + catch (IllegalAccessException e) + { throw new AssertionError(e); - } catch (InvocationTargetException e) { + } + catch (InvocationTargetException e) + { throw new AssertionError(e); } } @SuppressWarnings( "unchecked") - public static <T> T[] unwrap(Class<T> wrapperClass, List<T> thisPtrs) { - if (thisPtrs==null) + public static <T> T[] unwrap(Class<T> wrapperClass, List<T> values) + { + if (values == null) return null; - if (thisPtrs.size() == 0) + if (values.size() == 0) return null; - return (T[])thisPtrs.toArray((T[])Array.newInstance(wrapperClass, thisPtrs.size())); + return (T[])values.toArray((T[])Array.newInstance(wrapperClass, values.size())); } @SuppressWarnings( "unchecked" ) @@ -2794,40 +2975,112 @@ public class Helper { public static Object queryInterface(Object obj, String uuid) { - try { + try + { /* Kind of ugly, but does the job of casting */ org.mozilla.xpcom.Mozilla moz = org.mozilla.xpcom.Mozilla.getInstance(); long xpobj = moz.wrapJavaObject(obj, uuid); return moz.wrapXPCOMObject(xpobj, uuid); - } catch (Exception e) { - return null; - } + } + catch (Exception e) + { + return null; + } } @SuppressWarnings("unchecked") - public static <T1 extends IUnknown,T2> T2[] unwrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, List<T1> thisPtrs) { - if (thisPtrs==null) return null; + public static <T1 extends IUnknown, T2> T2[] unwrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, List<T1> values) + { + if (values == null) + return null; - T2 ret[] = (T2[])Array.newInstance(wrapperClass2, thisPtrs.size()); + T2 ret[] = (T2[])Array.newInstance(wrapperClass2, values.size()); int i = 0; - for (T1 obj : thisPtrs) { - ret[i++] = (T2)obj.getWrapped(); + for (T1 obj : values) + { + ret[i++] = (T2)obj.getWrapped(); } return ret; } } ]]></xsl:text> + </xsl:if> + + <xsl:call-template name="endFile"> + <xsl:with-param name="file" select="'Helper.java'" /> + </xsl:call-template> + + <xsl:call-template name="startFile"> + <xsl:with-param name="file" select="'VBoxException.java'" /> + <xsl:with-param name="package" select="$G_virtualBoxPackage" /> + </xsl:call-template> + + <xsl:if test="$filelistonly=''"> + <xsl:text> +import org.mozilla.xpcom.*; + +public class VBoxException extends RuntimeException +{ + private int resultCode; + private IVirtualBoxErrorInfo errorInfo; + + public VBoxException(String message) + { + super(message); + resultCode = -1; + errorInfo = null; + } + + public VBoxException(String message, Throwable cause) + { + super(message, cause); + if (cause instanceof org.mozilla.xpcom.XPCOMException) + { + resultCode = (int)((org.mozilla.xpcom.XPCOMException)cause).errorcode; + try + { + Mozilla mozilla = Mozilla.getInstance(); + nsIServiceManager sm = mozilla.getServiceManager(); + nsIExceptionService es = (nsIExceptionService)sm.getServiceByContractID("@mozilla.org/exceptionservice;1", nsIExceptionService.NS_IEXCEPTIONSERVICE_IID); + nsIExceptionManager em = es.getCurrentExceptionManager(); + nsIException ex = em.getCurrentException(); + errorInfo = new IVirtualBoxErrorInfo((org.mozilla.interfaces.IVirtualBoxErrorInfo)ex.queryInterface(org.mozilla.interfaces.IVirtualBoxErrorInfo.IVIRTUALBOXERRORINFO_IID)); + } + catch (NullPointerException e) + { + e.printStackTrace(); + // nothing we can do + errorInfo = null; + } + } + else + resultCode = -1; + } + + public int getResultCode() + { + return resultCode; + } - <xsl:call-template name="endFile"> - <xsl:with-param name="file" select="'Helper.java'" /> - </xsl:call-template> + public IVirtualBoxErrorInfo getVirtualBoxErrorInfo() + { + return errorInfo; + } +} +</xsl:text> + </xsl:if> - <xsl:call-template name="startFile"> + <xsl:call-template name="endFile"> + <xsl:with-param name="file" select="'VBoxException.java'" /> + </xsl:call-template> + + <xsl:call-template name="startFile"> <xsl:with-param name="file" select="'VirtualBoxManager.java'" /> <xsl:with-param name="package" select="$G_virtualBoxPackage" /> </xsl:call-template> - <xsl:text><![CDATA[ + <xsl:if test="$filelistonly=''"> + <xsl:text><![CDATA[ import java.io.File; @@ -2836,8 +3089,8 @@ import org.mozilla.interfaces.*; public class VirtualBoxManager { - private Mozilla mozilla; - private IVirtualBox vbox; + private Mozilla mozilla; + private IVirtualBox vbox; private nsIComponentManager componentManager; private VirtualBoxManager(Mozilla mozilla) @@ -2852,12 +3105,12 @@ public class VirtualBoxManager public void connect(String url, String username, String passwd) { - throw new RuntimeException("Connect doesn't make sense for local bindings"); + throw new VBoxException("Connect doesn't make sense for local bindings"); } public void disconnect() { - throw new RuntimeException("Disconnect doesn't make sense for local bindings"); + throw new VBoxException("Disconnect doesn't make sense for local bindings"); } public static void initPerThread() @@ -2899,26 +3152,29 @@ public class VirtualBoxManager public static synchronized VirtualBoxManager createInstance(String home) { if (hasInstance) - throw new VBoxException(null, "only one instance at the time allowed"); - if (home == null || "".equals(home)) + throw new VBoxException("only one instance of VirtualBoxManager at a time allowed"); + if (home == null || home.equals("")) home = System.getProperty("vbox.home"); if (home == null) - throw new RuntimeException("vbox.home Java property must be defined to use XPCOM bridge"); + throw new VBoxException("vbox.home Java property must be defined to use XPCOM bridge"); File grePath = new File(home); Mozilla mozilla = Mozilla.getInstance(); if (!isMozillaInited) { - mozilla.initialize(grePath); - try { - mozilla.initXPCOM(grePath, null); - isMozillaInited = true; - } catch (Exception e) { - e.printStackTrace(); - return null; - } + mozilla.initialize(grePath); + try + { + mozilla.initXPCOM(grePath, null); + isMozillaInited = true; + } + catch (Exception e) + { + e.printStackTrace(); + return null; + } } hasInstance = true; @@ -2928,8 +3184,9 @@ public class VirtualBoxManager public IEventListener createListener(Object sink) { - return new IEventListener(new EventListenerImpl(sink)); + return new IEventListener(new EventListenerImpl(sink)); } + public void cleanup() { deinitPerThread(); @@ -2940,141 +3197,127 @@ public class VirtualBoxManager hasInstance = false; } - public boolean progressBar(IProgress p, int wait) - { - long end = System.currentTimeMillis() + wait; - while (!p.getCompleted()) - { - mozilla.waitForEvents(0); - p.waitForCompletion(wait); - if (System.currentTimeMillis() >= end) - return false; - } - - return true; - } - - public boolean startVm(String name, String type, int timeout) - { - IMachine m = vbox.findMachine(name); - if (m == null) - return false; - ISession session = getSessionObject(); - - if (type == null) - type = "gui"; - IProgress p = m.launchVMProcess(session, type, ""); - progressBar(p, timeout); - session.unlockMachine(); - return true; - } - public void waitForEvents(long tmo) { mozilla.waitForEvents(tmo); } } ]]></xsl:text> + </xsl:if> - <xsl:call-template name="endFile"> - <xsl:with-param name="file" select="'VirtualBoxManager.java'" /> - </xsl:call-template> + <xsl:call-template name="endFile"> + <xsl:with-param name="file" select="'VirtualBoxManager.java'" /> + </xsl:call-template> - <xsl:call-template name="startFile"> - <xsl:with-param name="file" select="'EventListenerImpl.java'" /> - <xsl:with-param name="package" select="$G_virtualBoxPackage" /> - </xsl:call-template> + <xsl:call-template name="startFile"> + <xsl:with-param name="file" select="'EventListenerImpl.java'" /> + <xsl:with-param name="package" select="$G_virtualBoxPackage" /> + </xsl:call-template> - <xsl:text><![CDATA[ - import org.mozilla.interfaces.*; + <xsl:if test="$filelistonly=''"> + <xsl:text><![CDATA[ +import org.mozilla.interfaces.*; - public class EventListenerImpl extends nsISupportsBase implements org.mozilla.interfaces.IEventListener - { +public class EventListenerImpl extends nsISupportsBase implements org.mozilla.interfaces.IEventListener +{ private Object obj; private java.lang.reflect.Method handleEvent; EventListenerImpl(Object obj) { - this.obj = obj; - try { - this.handleEvent = obj.getClass().getMethod("handleEvent", IEvent.class); - } catch (Exception e) { - e.printStackTrace(); + this.obj = obj; + try + { + this.handleEvent = obj.getClass().getMethod("handleEvent", IEvent.class); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + public void handleEvent(org.mozilla.interfaces.IEvent ev) + { + try + { + if (obj != null && handleEvent != null) + handleEvent.invoke(obj, ev != null ? new IEvent(ev) : null); + } + catch (Exception e) + { + e.printStackTrace(); } - } - public void handleEvent(org.mozilla.interfaces.IEvent ev) - { - try { - if (obj != null && handleEvent != null) - handleEvent.invoke(obj, ev != null ? new IEvent(ev) : null); - } catch (Exception e) { - e.printStackTrace(); - } - } - }]]></xsl:text> - - <xsl:call-template name="endFile"> - <xsl:with-param name="file" select="'EventListenerImpl.java'" /> - </xsl:call-template> - - <xsl:call-template name="startFile"> - <xsl:with-param name="file" select="'VBoxObjectBase.java'" /> - <xsl:with-param name="package" select="$G_virtualBoxPackage" /> - </xsl:call-template> - -<xsl:text><![CDATA[ + } +}]]></xsl:text> + </xsl:if> + + <xsl:call-template name="endFile"> + <xsl:with-param name="file" select="'EventListenerImpl.java'" /> + </xsl:call-template> + + <xsl:call-template name="startFile"> + <xsl:with-param name="file" select="'VBoxObjectBase.java'" /> + <xsl:with-param name="package" select="$G_virtualBoxPackage" /> + </xsl:call-template> + + <xsl:if test="$filelistonly=''"> + <xsl:text><![CDATA[ abstract class nsISupportsBase implements org.mozilla.interfaces.nsISupports { - public org.mozilla.interfaces.nsISupports queryInterface(String iid) + public org.mozilla.interfaces.nsISupports queryInterface(String iid) { return org.mozilla.xpcom.Mozilla.queryInterface(this, iid); } } -]]></xsl:text><xsl:call-template name="endFile"> - <xsl:with-param name="file" select="'VBoxObjectBase.java'" /> - </xsl:call-template> +]]></xsl:text> + </xsl:if> + <xsl:call-template name="endFile"> + <xsl:with-param name="file" select="'VBoxObjectBase.java'" /> + </xsl:call-template> </xsl:template> <xsl:template name="emitHandwrittenMscom"> -<xsl:call-template name="startFile"> + <xsl:call-template name="startFile"> <xsl:with-param name="file" select="'IUnknown.java'" /> <xsl:with-param name="package" select="$G_virtualBoxPackageCom" /> </xsl:call-template> - <xsl:text><![CDATA[ + <xsl:if test="$filelistonly=''"> + <xsl:text><![CDATA[ public class IUnknown { - private Object obj; - public IUnknown(Object obj) - { - this.obj = obj; - } - - public Object getWrapped() - { - return this.obj; - } - - public void setWrapped(Object obj) - { - this.obj = obj; - } + private Object obj; + public IUnknown(Object obj) + { + this.obj = obj; + } + + public Object getWrapped() + { + return this.obj; + } + + public void setWrapped(Object obj) + { + this.obj = obj; + } } ]]></xsl:text> + </xsl:if> - <xsl:call-template name="endFile"> - <xsl:with-param name="file" select="'IUnknown.java'" /> - </xsl:call-template> + <xsl:call-template name="endFile"> + <xsl:with-param name="file" select="'IUnknown.java'" /> + </xsl:call-template> -<xsl:call-template name="startFile"> - <xsl:with-param name="file" select="'Helper.java'" /> - <xsl:with-param name="package" select="$G_virtualBoxPackageCom" /> - </xsl:call-template> + <xsl:call-template name="startFile"> + <xsl:with-param name="file" select="'Helper.java'" /> + <xsl:with-param name="package" select="$G_virtualBoxPackageCom" /> + </xsl:call-template> -<xsl:text><![CDATA[ + <xsl:if test="$filelistonly=''"> + <xsl:text><![CDATA[ import java.util.List; import java.util.ArrayList; @@ -3084,101 +3327,129 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import com.jacob.com.*; -public class Helper { - public static List<Short> wrap(short[] vals) { - if (vals==null) return null; - if (vals.length == 0) return Collections.emptyList(); +public class Helper +{ + public static List<Short> wrap(short[] values) + { + if (values == null) + return null; + if (values.length == 0) + return Collections.emptyList(); - List<Short> ret = new ArrayList<Short>(vals.length); - for (short v : vals) { - ret.add(v); + List<Short> ret = new ArrayList<Short>(values.length); + for (short v : values) + { + ret.add(v); } return ret; } - public static List<Integer> wrap(int[] vals) { - if (vals == null) return null; - if (vals.length == 0) return Collections.emptyList(); + public static List<Integer> wrap(int[] values) + { + if (values == null) + return null; + if (values.length == 0) + return Collections.emptyList(); - List<Integer> ret = new ArrayList<Integer>(vals.length); - for (int v : vals) { - ret.add(v); + List<Integer> ret = new ArrayList<Integer>(values.length); + for (int v : values) + { + ret.add(v); } return ret; } - public static List<Long> wrap(long[] vals) { - if (vals==null) return null; - if (vals.length == 0) return Collections.emptyList(); + public static List<Long> wrap(long[] values) + { + if (values == null) + return null; + if (values.length == 0) + return Collections.emptyList(); - List<Long> ret = new ArrayList<Long>(vals.length); - for (long v : vals) { - ret.add(v); + List<Long> ret = new ArrayList<Long>(values.length); + for (long v : values) + { + ret.add(v); } return ret; } - public static List<String> wrap(String[] vals) { - if (vals==null) return null; - if (vals.length == 0) return Collections.emptyList(); + public static List<String> wrap(String[] values) + { + if (values == null) + return null; + if (values.length == 0) + return Collections.emptyList(); - List<String> ret = new ArrayList<String>(vals.length); - for (String v : vals) { - ret.add(v); + List<String> ret = new ArrayList<String>(values.length); + for (String v : values) + { + ret.add(v); } return ret; } public static <T> T wrapDispatch(Class<T> wrapperClass, Dispatch d) { - try { - if (d == null || d.m_pDispatch == 0) - return null; - Constructor<T> c = wrapperClass.getConstructor(Dispatch.class); - return (T)c.newInstance(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); - } + try + { + if (d == null || d.m_pDispatch == 0) + return null; + Constructor<T> c = wrapperClass.getConstructor(Dispatch.class); + return (T)c.newInstance(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) { - if (v == null) - return null; - - short vt = v.getvt(); - switch (vt) - { - case Variant.VariantNull: - return null; - case Variant.VariantBoolean: - return v.getBoolean(); - case Variant.VariantByte: - return v.getByte(); - case Variant.VariantShort: - return v.getShort(); - case Variant.VariantInt: - return v.getInt(); - case Variant.VariantLongInt: - return v.getLong(); - case Variant.VariantString: - return v.getString(); - case Variant.VariantDispatch: - return wrapDispatch(wrapperClass, v.getDispatch()); - default: - throw new RuntimeException("unhandled variant type "+vt); - } + if (v == null) + return null; + + short vt = v.getvt(); + switch (vt) + { + case Variant.VariantNull: + return null; + case Variant.VariantBoolean: + return v.getBoolean(); + case Variant.VariantByte: + return v.getByte(); + case Variant.VariantShort: + return v.getShort(); + case Variant.VariantInt: + return v.getInt(); + case Variant.VariantLongInt: + return v.getLong(); + case Variant.VariantString: + return v.getString(); + case Variant.VariantDispatch: + return wrapDispatch(wrapperClass, v.getDispatch()); + default: + throw new VBoxException("unhandled variant type " + vt); + } } - public static byte[] wrapBytes(SafeArray sa) { - if (sa==null) return null; + public static byte[] wrapBytes(SafeArray sa) + { + if (sa == null) + return null; int saLen = sa.getUBound() - sa.getLBound() + 1; @@ -3186,168 +3457,229 @@ public class Helper { int j = 0; for (int i = sa.getLBound(); i <= sa.getUBound(); i++) { - Variant v = sa.getVariant(i); - // come upo with more effective approach!!! - ret[j++] = v.getByte(); + Variant v = sa.getVariant(i); + // come up with more effective approach!!! + ret[j++] = v.getByte(); } return ret; } @SuppressWarnings("unchecked") - public static <T> List<T> wrap(Class<T> wrapperClass, SafeArray sa) { - if (sa==null) return null; + public static <T> List<T> wrap(Class<T> wrapperClass, SafeArray sa) + { + if (sa == null) + return null; int saLen = sa.getUBound() - sa.getLBound() + 1; - if (saLen == 0) return Collections.emptyList(); + if (saLen == 0) + return Collections.emptyList(); List<T> ret = new ArrayList<T>(saLen); for (int i = sa.getLBound(); i <= sa.getUBound(); i++) { - Variant v = sa.getVariant(i); - ret.add((T)wrapVariant(wrapperClass, v)); + Variant v = sa.getVariant(i); + ret.add((T)wrapVariant(wrapperClass, v)); } return ret; } - public static <T> List<T> wrapEnum(Class<T> wrapperClass, SafeArray sa) { - try { - if (sa==null) return null; - - int saLen = sa.getUBound() - sa.getLBound() + 1; - if (saLen == 0) return Collections.emptyList(); - List<T> ret = new ArrayList<T>(saLen); - Constructor<T> c = wrapperClass.getConstructor(int.class); - for (int i = sa.getLBound(); i <= sa.getUBound(); i++) - { - Variant v = sa.getVariant(i); - ret.add(c.newInstance(v.getInt())); - } - return ret; - } catch (NoSuchMethodException e) { + public static <T> List<T> wrapEnum(Class<T> wrapperClass, SafeArray sa) + { + try + { + if (sa == null) + return null; + + int saLen = sa.getUBound() - sa.getLBound() + 1; + if (saLen == 0) + return Collections.emptyList(); + List<T> ret = new ArrayList<T>(saLen); + Constructor<T> c = wrapperClass.getConstructor(int.class); + for (int i = sa.getLBound(); i <= sa.getUBound(); i++) + { + Variant v = sa.getVariant(i); + ret.add(c.newInstance(v.getInt())); + } + return ret; + } + catch (NoSuchMethodException e) + { throw new AssertionError(e); - } catch (InstantiationException e) { + } + catch (InstantiationException e) + { throw new AssertionError(e); - } catch (IllegalAccessException e) { + } + catch (IllegalAccessException e) + { throw new AssertionError(e); - } catch (InvocationTargetException e) { + } + catch (InvocationTargetException e) + { throw new AssertionError(e); } } - public static SafeArray unwrapInt(List<Integer> vals) { - if (vals==null) return null; - SafeArray ret = new SafeArray(Variant.VariantInt, vals.size()); + public static SafeArray unwrapInt(List<Integer> values) + { + if (values == null) + return null; + SafeArray ret = new SafeArray(Variant.VariantInt, values.size()); int i = 0; - for (int l : vals) { - ret.setInt(i++, l); + for (int l : values) + { + ret.setInt(i++, l); } return ret; } - public static SafeArray unwrapLong(List<Long> vals) { - if (vals==null) return null; - SafeArray ret = new SafeArray(Variant.VariantLongInt, vals.size()); + public static SafeArray unwrapLong(List<Long> values) + { + if (values == null) + return null; + SafeArray ret = new SafeArray(Variant.VariantLongInt, values.size()); int i = 0; - for (long l : vals) { - ret.setLong(i++, l); + for (long l : values) + { + ret.setLong(i++, l); } return ret; } - public static SafeArray unwrapBool(List<Boolean> vals) { - if (vals==null) return null; + public static SafeArray unwrapBool(List<Boolean> values) + { + if (values == null) + return null; - SafeArray result = new SafeArray(Variant.VariantBoolean, vals.size()); + SafeArray result = new SafeArray(Variant.VariantBoolean, values.size()); int i = 0; - for (boolean l : vals) { - result.setBoolean(i++, l); + for (boolean l : values) + { + result.setBoolean(i++, l); } return result; } - public static SafeArray unwrapBytes(byte[] vals) { - if (vals==null) return null; + public static SafeArray unwrapBytes(byte[] values) + { + if (values == null) + return null; - SafeArray result = new SafeArray(Variant.VariantByte, vals.length); + SafeArray result = new SafeArray(Variant.VariantByte, values.length); int i = 0; - for (byte l : vals) { - result.setByte(i++, l); + for (byte l : values) + { + result.setByte(i++, l); } return result; } - public static <T extends Enum <T>> SafeArray unwrapEnum(Class<T> enumClass, List<T> values) { - if (values == null) return null; + public static <T extends Enum <T>> SafeArray unwrapEnum(Class<T> enumClass, List<T> values) + { + if (values == null) + return null; SafeArray result = new SafeArray(Variant.VariantInt, values.size()); - try { - java.lang.reflect.Method valueM = enumClass.getMethod("value"); - int i = 0; - for (T v : values) { - result.setInt(i++, (Integer)valueM.invoke(v)); - } - return result; - } 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); + try + { + java.lang.reflect.Method valueM = enumClass.getMethod("value"); + int i = 0; + for (T v : values) + { + result.setInt(i++, (Integer)valueM.invoke(v)); + } + return result; + } + 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> vals) { - if (vals==null) - return null; - SafeArray result = new SafeArray(Variant.VariantString, vals.size()); + public static SafeArray unwrapString(List<String> values) + { + if (values == null) + return null; + SafeArray result = new SafeArray(Variant.VariantString, values.size()); int i = 0; - for (String l : vals) { - result.setString(i++, l); + for (String l : values) + { + result.setString(i++, l); } return result; } - public static <T1, T2> List<T1> wrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, T2[] thisPtrs) { - try { - if (thisPtrs==null) return null; - if (thisPtrs.length == 0) return Collections.emptyList(); + public static <T1, T2> List<T1> wrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, T2[] values) + { + try + { + if (values == null) + return null; + if (values.length == 0) + return Collections.emptyList(); Constructor<T1> c = wrapperClass1.getConstructor(wrapperClass2); - List<T1> ret = new ArrayList<T1>(thisPtrs.length); - for (T2 thisPtr : thisPtrs) { - ret.add(c.newInstance(thisPtr)); + List<T1> ret = new ArrayList<T1>(values.length); + for (T2 v : values) + { + ret.add(c.newInstance(v)); } return ret; - } catch (NoSuchMethodException e) { + } + catch (NoSuchMethodException e) + { throw new AssertionError(e); - } catch (InstantiationException e) { + } + catch (InstantiationException e) + { throw new AssertionError(e); - } catch (IllegalAccessException e) { + } + catch (IllegalAccessException e) + { throw new AssertionError(e); - } catch (InvocationTargetException e) { + } + catch (InvocationTargetException e) + { throw new AssertionError(e); } } @SuppressWarnings("unchecked") - public static <T> T[] unwrap(Class<T> wrapperClass, List<T> thisPtrs) { - if (thisPtrs==null) return null; - return (T[])thisPtrs.toArray((T[])Array.newInstance(wrapperClass, thisPtrs.size())); + public static <T> T[] unwrap(Class<T> wrapperClass, List<T> values) + { + if (values == null) + return null; + return (T[])values.toArray((T[])Array.newInstance(wrapperClass, values.size())); } @SuppressWarnings("unchecked") - public static <T1 extends IUnknown,T2> T2[] unwrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, List<T1> thisPtrs) { - if (thisPtrs==null) return null; + public static <T1 extends IUnknown, T2> T2[] unwrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, List<T1> values) + { + if (values == null) + return null; - T2 ret[] = (T2[])Array.newInstance(wrapperClass2, thisPtrs.size()); + T2 ret[] = (T2[])Array.newInstance(wrapperClass2, values.size()); int i = 0; - for (T1 obj : thisPtrs) { - ret[i++] = (T2)obj.getWrapped(); + for (T1 obj : values) + { + ret[i++] = (T2)obj.getWrapped(); } return ret; } @@ -3359,18 +3691,72 @@ public class Helper { } } ]]></xsl:text> + </xsl:if> + + <xsl:call-template name="endFile"> + <xsl:with-param name="file" select="'Helper.java'" /> + </xsl:call-template> + + <xsl:call-template name="startFile"> + <xsl:with-param name="file" select="'VBoxException.java'" /> + <xsl:with-param name="package" select="$G_virtualBoxPackage" /> + </xsl:call-template> + + <xsl:if test="$filelistonly=''"> + <xsl:text> + +public class VBoxException extends RuntimeException +{ + private int resultCode; + private IVirtualBoxErrorInfo errorInfo; + + public VBoxException(String message) + { + super(message); + resultCode = -1; + errorInfo = null; + } + + public VBoxException(String message, Throwable cause) + { + super(message, cause); + if (cause instanceof com.jacob.com.ComException) + { + resultCode = ((com.jacob.com.ComException)cause).getHResult(); + // 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. + errorInfo = null; + } + else + resultCode = -1; + } + + public int getResultCode() + { + return resultCode; + } + + public IVirtualBoxErrorInfo getVirtualBoxErrorInfo() + { + return errorInfo; + } +} +</xsl:text> + </xsl:if> - <xsl:call-template name="endFile"> - <xsl:with-param name="file" select="'Helper.java'" /> - </xsl:call-template> + <xsl:call-template name="endFile"> + <xsl:with-param name="file" select="'VBoxException.java'" /> + </xsl:call-template> - <xsl:call-template name="startFile"> + <xsl:call-template name="startFile"> <xsl:with-param name="file" select="'VirtualBoxManager.java'" /> <xsl:with-param name="package" select="$G_virtualBoxPackage" /> </xsl:call-template> - <xsl:text><![CDATA[ + <xsl:if test="$filelistonly=''"> + <xsl:text><![CDATA[ import com.jacob.activeX.ActiveXComponent; import com.jacob.com.ComThread; @@ -3381,7 +3767,7 @@ import com.jacob.com.DispatchEvents; public class VirtualBoxManager { - private IVirtualBox vbox; + private IVirtualBox vbox; private VirtualBoxManager() { @@ -3391,22 +3777,22 @@ public class VirtualBoxManager public static void initPerThread() { - ComThread.InitMTA(); + ComThread.InitMTA(); } public static void deinitPerThread() { - ComThread.Release(); + ComThread.Release(); } public void connect(String url, String username, String passwd) { - throw new RuntimeException("Connect doesn't make sense for local bindings"); + throw new VBoxException("Connect doesn't make sense for local bindings"); } public void disconnect() { - throw new RuntimeException("Disconnect doesn't make sense for local bindings"); + throw new VBoxException("Disconnect doesn't make sense for local bindings"); } public IVirtualBox getVBox() @@ -3437,7 +3823,7 @@ public class VirtualBoxManager public static synchronized VirtualBoxManager createInstance(String home) { if (hasInstance) - throw new VBoxException(null, "only one instance at the time allowed"); + throw new VBoxException("only one instance of VirtualBoxManager at a time allowed"); hasInstance = true; return new VirtualBoxManager(); @@ -3449,48 +3835,24 @@ public class VirtualBoxManager hasInstance = false; } - public boolean progressBar(IProgress p, int wait) - { - long end = System.currentTimeMillis() + wait; - while (!p.getCompleted()) - { - p.waitForCompletion(wait); - if (System.currentTimeMillis() >= end) - return false; - } - - return true; - } - - public boolean startVm(String name, String type, int timeout) - { - IMachine m = vbox.findMachine(name); - if (m == null) - return false; - ISession session = getSessionObject(); - if (type == null) - type = "gui"; - IProgress p = m.launchVMProcess(session, type, ""); - progressBar(p, timeout); - session.unlockMachine(); - return true; - } - public void waitForEvents(long tmo) { // what to do here? - try { + try + { Thread.sleep(tmo); - } catch (InterruptedException ie) { + } + catch (InterruptedException ie) + { } } } ]]></xsl:text> + </xsl:if> - <xsl:call-template name="endFile"> - <xsl:with-param name="file" select="'VirtualBoxManager.java'" /> - </xsl:call-template> - + <xsl:call-template name="endFile"> + <xsl:with-param name="file" select="'VirtualBoxManager.java'" /> + </xsl:call-template> </xsl:template> <xsl:template name="emitHandwrittenJaxws"> @@ -3500,55 +3862,63 @@ public class VirtualBoxManager <xsl:with-param name="package" select="$G_virtualBoxPackage" /> </xsl:call-template> - <xsl:text><![CDATA[ + <xsl:if test="$filelistonly=''"> + <xsl:text><![CDATA[ public class IUnknown { - protected String obj; - protected final VboxPortType port; - - public IUnknown(String obj, VboxPortType port) - { - this.obj = obj; - this.port = port; - } - - public final String getWrapped() - { - return this.obj; - } - - public final VboxPortType getRemoteWSPort() - { - return this.port; - } - - public synchronized void releaseRemote() throws WebServiceException - { - if (obj == null) { - return; - } - try { - this.port.iManagedObjectRefRelease(obj); - this.obj = null; - } catch (InvalidObjectFaultMsg e) { - throw new WebServiceException(e); - } catch (RuntimeFaultMsg e) { - throw new WebServiceException(e); - } - } + protected String obj; + protected final VboxPortType port; + + public IUnknown(String obj, VboxPortType port) + { + this.obj = obj; + this.port = port; + } + + public final String getWrapped() + { + return this.obj; + } + + public final VboxPortType getRemoteWSPort() + { + return this.port; + } + + public synchronized void releaseRemote() throws WebServiceException + { + if (obj == null) + return; + + try + { + this.port.iManagedObjectRefRelease(obj); + this.obj = null; + } + catch (InvalidObjectFaultMsg e) + { + throw new WebServiceException(e); + } + catch (RuntimeFaultMsg e) + { + throw new WebServiceException(e); + } + } } ]]></xsl:text> + </xsl:if> - <xsl:call-template name="endFile"> - <xsl:with-param name="file" select="'IUnknown.java'" /> - </xsl:call-template> + <xsl:call-template name="endFile"> + <xsl:with-param name="file" select="'IUnknown.java'" /> + </xsl:call-template> - <xsl:call-template name="startFile"> - <xsl:with-param name="file" select="'Helper.java'" /> - <xsl:with-param name="package" select="$G_virtualBoxPackage" /> - </xsl:call-template> + <xsl:call-template name="startFile"> + <xsl:with-param name="file" select="'Helper.java'" /> + <xsl:with-param name="package" select="$G_virtualBoxPackage" /> + </xsl:call-template> -<xsl:text><![CDATA[ + <xsl:if test="$filelistonly=''"> + <xsl:text><![CDATA[ import java.util.List; import java.util.ArrayList; @@ -3558,54 +3928,82 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.math.BigInteger; -public class Helper { - public static <T> List<T> wrap(Class<T> wrapperClass, VboxPortType pt, List<String> thisPtrs) { - try { - if(thisPtrs==null) return null; +public class Helper +{ + public static <T> List<T> wrap(Class<T> wrapperClass, VboxPortType pt, List<String> values) + { + try + { + if (values == null) + return null; Constructor<T> c = wrapperClass.getConstructor(String.class, VboxPortType.class); - List<T> ret = new ArrayList<T>(thisPtrs.size()); - for (String thisPtr : thisPtrs) { - ret.add(c.newInstance(thisPtr,pt)); + List<T> ret = new ArrayList<T>(values.size()); + for (String v : values) + { + ret.add(c.newInstance(v, pt)); } return ret; - } catch (NoSuchMethodException e) { + } + catch (NoSuchMethodException e) + { throw new AssertionError(e); - } catch (InstantiationException e) { + } + catch (InstantiationException e) + { throw new AssertionError(e); - } catch (IllegalAccessException e) { + } + catch (IllegalAccessException e) + { throw new AssertionError(e); - } catch (InvocationTargetException 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> thisPtrs) { - try { - if(thisPtrs==null) return null; + public static <T1, T2> List<T1> wrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, VboxPortType pt, List<T2> values) + { + try + { + if (values == null) + return null; Constructor<T1> c = wrapperClass1.getConstructor(wrapperClass2, VboxPortType.class); - List<T1> ret = new ArrayList<T1>(thisPtrs.size()); - for (T2 thisPtr : thisPtrs) { - ret.add(c.newInstance(thisPtr,pt)); + List<T1> ret = new ArrayList<T1>(values.size()); + for (T2 v : values) + { + ret.add(c.newInstance(v, pt)); } return ret; - } catch (NoSuchMethodException e) { + } + catch (NoSuchMethodException e) + { throw new AssertionError(e); - } catch (InstantiationException e) { + } + catch (InstantiationException e) + { throw new AssertionError(e); - } catch (IllegalAccessException e) { + } + catch (IllegalAccessException e) + { throw new AssertionError(e); - } catch (InvocationTargetException e) { + } + catch (InvocationTargetException e) + { throw new AssertionError(e); } } - public static <T extends IUnknown> List<String> unwrap(List<T> thisPtrs) { - if (thisPtrs==null) return null; + public static <T extends IUnknown> List<String> unwrap(List<T> values) + { + if (values == null) + return null; - List<String> ret = new ArrayList<String>(thisPtrs.size()); - for (T obj : thisPtrs) { + List<String> ret = new ArrayList<String>(values.size()); + for (T obj : values) + { ret.add(obj.getWrapped()); } return ret; @@ -3614,22 +4012,25 @@ public class Helper { @SuppressWarnings("unchecked" ) public static <T1 extends Enum <T1>, T2 extends Enum <T2>> List<T2> convertEnums(Class<T1> fromClass, Class<T2> toClass, - List<T1> values) { - try { - if (values==null) - return null; - java.lang.reflect.Method fromValue = toClass.getMethod("fromValue", String.class); + List<T1> values) + { + try + { + if (values == null) + return null; List<T2> ret = new ArrayList<T2>(values.size()); - for (T1 v : values) { - // static method is called with null this - ret.add((T2)fromValue.invoke(null, v.name())); + for (T1 v : values) + { + // Ordinal based enum conversion, as JAX-WS "invents" its own + // enum names and has string values with the expected content. + int enumOrdinal = v.ordinal(); + T2 convEnum = toClass.getEnumConstants()[enumOrdinal]; + ret.add(convEnum); } return ret; - } catch (NoSuchMethodException e) { - throw new AssertionError(e); - } catch (IllegalAccessException e) { - throw new AssertionError(e); - } catch (InvocationTargetException e) { + } + catch (ArrayIndexOutOfBoundsException e) + { throw new AssertionError(e); } } @@ -3645,7 +4046,7 @@ public class Helper { charToVal[i] = -1; for (int i = 0; i < valToChar.length; i++) - charToVal[valToChar[i]] = i; + charToVal[valToChar[i]] = i; charToVal['='] = 0; } @@ -3699,7 +4100,7 @@ public class Helper { break; } default: - throw new RuntimeException("bug!"); + throw new VBoxException("bug!"); } return new String(result); @@ -3735,7 +4136,7 @@ public class Helper { } if ((validChars * 3 % 4) != 0) - throw new RuntimeException("invalid encoded string "+str); + throw new VBoxException("invalid base64 encoded string " + str); int resultLength = validChars * 3 / 4 - padChars; byte[] result = new byte[resultLength]; @@ -3743,7 +4144,7 @@ public class Helper { int dataIndex = 0, stringIndex = 0; int quadraplets = validChars / 4; - for (int i=0; i<quadraplets; i++) + for (int i = 0; i < quadraplets; i++) { stringIndex = skipInvalid(str, stringIndex); int ch1 = str.charAt(stringIndex++); @@ -3766,17 +4167,77 @@ public class Helper { } } ]]></xsl:text> + </xsl:if> + + <xsl:call-template name="endFile"> + <xsl:with-param name="file" select="'Helper.java'" /> + </xsl:call-template> + + <xsl:call-template name="startFile"> + <xsl:with-param name="file" select="'VBoxException.java'" /> + <xsl:with-param name="package" select="$G_virtualBoxPackage" /> + </xsl:call-template> + + <xsl:if test="$filelistonly=''"> + <xsl:text> +public class VBoxException extends RuntimeException +{ + private int resultCode; + private IVirtualBoxErrorInfo errorInfo; + + public VBoxException(String message) + { + super(message); + resultCode = -1; + errorInfo = null; + } + + public VBoxException(String message, Throwable cause) + { + super(message, cause); + resultCode = -1; + errorInfo = null; + } + + public VBoxException(String message, Throwable cause, VboxPortType port) + { + super(message, cause); + if (cause instanceof RuntimeFaultMsg) + { + RuntimeFaultMsg m = (RuntimeFaultMsg)cause; + RuntimeFault f = m.getFaultInfo(); + resultCode = f.getResultCode(); + String retVal = f.getReturnval(); + errorInfo = (retVal.length() > 0) ? new IVirtualBoxErrorInfo(retVal, port) : null; + } + else + resultCode = -1; + } + + public int getResultCode() + { + return resultCode; + } + + public IVirtualBoxErrorInfo getVirtualBoxErrorInfo() + { + return errorInfo; + } +} +</xsl:text> + </xsl:if> - <xsl:call-template name="endFile"> - <xsl:with-param name="file" select="'Helper.java'" /> - </xsl:call-template> + <xsl:call-template name="endFile"> + <xsl:with-param name="file" select="'VBoxException.java'" /> + </xsl:call-template> - <xsl:call-template name="startFile"> + <xsl:call-template name="startFile"> <xsl:with-param name="file" select="'VirtualBoxManager.java'" /> <xsl:with-param name="package" select="$G_virtualBoxPackage" /> - </xsl:call-template> + </xsl:call-template> -import java.net.URL; + <xsl:if test="$filelistonly=''"> + <xsl:text>import java.net.URL; import java.math.BigInteger; import java.util.List; import java.util.Map; @@ -3788,10 +4249,10 @@ import javax.xml.ws.WebServiceException; class PortPool { - private final static String wsdlFile = <xsl:value-of select="$G_virtualBoxWsdl" />; - - <xsl:text><![CDATA[ -private Map<VboxPortType, Integer> known; + private final static String wsdlFile = </xsl:text> + <xsl:value-of select="$G_virtualBoxWsdl" /> + <xsl:text><![CDATA[; + private Map<VboxPortType, Integer> known; private boolean initStarted; private VboxService svc; @@ -3801,32 +4262,35 @@ private Map<VboxPortType, Integer> known; if (usePreinit) { - new Thread(new Runnable() - { - public void run() - { - // need to sync on something else but 'this' - synchronized (known) + new Thread(new Runnable() + { + public void run() { - initStarted = true; - known.notify(); + // need to sync on something else but 'this' + synchronized (known) + { + initStarted = true; + known.notify(); + } + + preinit(); } + }).start(); - preinit(); - } - }).start(); - - synchronized (known) - { - while (!initStarted) - { - try { - known.wait(); - } catch (InterruptedException e) { - break; - } - } - } + synchronized (known) + { + while (!initStarted) + { + try + { + known.wait(); + } + catch (InterruptedException e) + { + break; + } + } + } } } @@ -3854,10 +4318,11 @@ private Map<VboxPortType, Integer> known; if (port == null) { - if (svc == null) { + if (svc == null) + { URL wsdl = PortPool.class.getClassLoader().getResource(wsdlFile); if (wsdl == null) - throw new LinkageError(wsdlFile+" not found, but it should have been in the jar"); + throw new LinkageError(wsdlFile + " not found, but it should have been in the jar"); svc = new VboxService(wsdl, new QName("http://www.virtualbox.org/Service", "vboxService")); @@ -3901,7 +4366,7 @@ public class VirtualBoxManager private static PortPool pool = new PortPool(true); protected VboxPortType port; - private IVirtualBox vbox; + private IVirtualBox vbox; private VirtualBoxManager() { @@ -3918,18 +4383,22 @@ public class VirtualBoxManager public void connect(String url, String username, String passwd) { this.port = pool.getPort(); - try { + try + { ((BindingProvider)port).getRequestContext(). put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url); String handle = port.iWebsessionManagerLogon(username, passwd); this.vbox = new IVirtualBox(handle, port); - } catch (Throwable t) { - if (this.port != null && pool != null) { + } + catch (Throwable t) + { + if (this.port != null && pool != null) + { pool.releasePort(this.port); this.port = null; } // we have to throw smth derived from RuntimeException - throw new VBoxException(t, t.getMessage()); + throw new VBoxException(t.getMessage(), t, this.port); } } @@ -3938,7 +4407,8 @@ public class VirtualBoxManager { this.port = pool.getPort(); - try { + try + { ((BindingProvider)port).getRequestContext(); if (requestContext != null) ((BindingProvider)port).getRequestContext().putAll(requestContext); @@ -3950,27 +4420,41 @@ public class VirtualBoxManager put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url); String handle = port.iWebsessionManagerLogon(username, passwd); this.vbox = new IVirtualBox(handle, port); - } catch (Throwable t) { - if (this.port != null && pool != null) { + } + catch (Throwable t) + { + if (this.port != null && pool != null) + { pool.releasePort(this.port); this.port = null; } // we have to throw smth derived from RuntimeException - throw new VBoxException(t, t.getMessage()); + throw new VBoxException(t.getMessage(), t, this.port); } } public void disconnect() { - try { - if (this.vbox != null) - port.iWebsessionManagerLogoff(this.vbox.getWrapped()); - } catch (InvalidObjectFaultMsg e) { - throw new VBoxException(e, e.getMessage()); - } catch (RuntimeFaultMsg e) { - throw new VBoxException(e, e.getMessage()); - } finally { - if (this.port != null) { + if (this.port == null) + return; + + try + { + if (this.vbox != null && port != null) + port.iWebsessionManagerLogoff(this.vbox.getWrapped()); + } + catch (InvalidObjectFaultMsg e) + { + throw new VBoxException(e.getMessage(), e, this.port); + } + catch (RuntimeFaultMsg e) + { + throw new VBoxException(e.getMessage(), e, this.port); + } + finally + { + if (this.port != null) + { pool.releasePort(this.port); this.port = null; } @@ -3985,14 +4469,19 @@ public class VirtualBoxManager public ISession getSessionObject() { if (this.vbox == null) - throw new RuntimeException("connect first"); - try { - String handle = port.iWebsessionManagerGetSessionObject(this.vbox.getWrapped()); - return new ISession(handle, port); - } catch (InvalidObjectFaultMsg e) { - throw new VBoxException(e, e.getMessage()); - } catch (RuntimeFaultMsg e) { - throw new VBoxException(e, e.getMessage()); + throw new VBoxException("connect first"); + try + { + String handle = port.iWebsessionManagerGetSessionObject(this.vbox.getWrapped()); + return new ISession(handle, port); + } + catch (InvalidObjectFaultMsg e) + { + throw new VBoxException(e.getMessage(), e, this.port); + } + catch (RuntimeFaultMsg e) + { + throw new VBoxException(e.getMessage(), e, this.port); } } @@ -4016,63 +4505,40 @@ public class VirtualBoxManager public IEventListener createListener(Object sink) { - throw new RuntimeException("no active listeners here"); + throw new VBoxException("no active listeners here"); } + public void cleanup() { disconnect(); deinitPerThread(); } - public boolean progressBar(IProgress p, int wait) - { - long end = System.currentTimeMillis() + wait; - while (!p.getCompleted()) - { - p.waitForCompletion(wait); - if (System.currentTimeMillis() >= end) - return false; - } - - return true; - } - - public boolean startVm(String name, String type, int timeout) - { - IMachine m = vbox.findMachine(name); - if (m == null) - return false; - ISession session = getSessionObject(); - - if (type == null) - type = "gui"; - IProgress p = m.launchVMProcess(session, type, ""); - progressBar(p, timeout); - session.unlockMachine(); - return true; - } - public void waitForEvents(long tmo) { } - - protected void finalize() throws Throwable + + protected void finalize() throws Throwable { - try { + try + { cleanup(); - } catch(Exception e) { } - finally { + catch(Exception e) + { + } + finally + { super.finalize(); } } } ]]></xsl:text> + </xsl:if> - <xsl:call-template name="endFile"> - <xsl:with-param name="file" select="'VirtualBoxManager.java'" /> - </xsl:call-template> - + <xsl:call-template name="endFile"> + <xsl:with-param name="file" select="'VirtualBoxManager.java'" /> + </xsl:call-template> </xsl:template> @@ -4084,6 +4550,10 @@ public class VirtualBoxManager </xsl:call-template> </xsl:if> + <xsl:if test="not($filelistonly='')"> + <xsl:value-of select="concat($filelistonly, ' := \ ')"/> + </xsl:if> + <!-- Handwritten files --> <xsl:call-template name="emitHandwritten"/> @@ -4122,7 +4592,7 @@ public class VirtualBoxManager <xsl:choose> <xsl:when test="$G_vboxGlueStyle='jaxws'"> - <xsl:if test="not($module) and not(@wsmap='suppress') and not(@wsmap='global')"> + <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')" /> @@ -4142,5 +4612,10 @@ public class VirtualBoxManager </xsl:choose> </xsl:for-each> + + <xsl:if test="not($filelistonly='')"> + <xsl:value-of select="' '"/> + </xsl:if> + </xsl:template> </xsl:stylesheet> |