VirtualBox

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

Last change on this file since 51425 was 51416, checked in by vboxsync, 11 years ago

Java COM bindings: fix much bit rot, accidental breakage of the code due to a change meant for WSDL, use an exception class which is available, remove optimization not done in the other API variants, eliminate java warning and fix Makefile

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

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