VirtualBox

source: vbox/trunk/src/VBox/Main/glue/glue-java.xsl@ 68155

Last change on this file since 68155 was 61452, checked in by vboxsync, 9 years ago

Main/glue/glue-java.xsl: release all unused managed object references, previously the last was forgotten. Contributed by Maxime Dor. Thanks!

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

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