VirtualBox

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

Last change on this file since 47167 was 46478, checked in by vboxsync, 12 years ago

libs/xpcom: touch up Java XPCOM wrapper generation, new common exception handlin
g model
Main/glue: Java glue code with better exception handling, indentation/coding style fixes both in the XSLT and the generated code, touched up Java sample code showing exception handling and getting all error information, Python indentation/whitespace cleanup
Main/idl: make more interfaces available over the webservice, some minor docs changes, whitespace cleanup
Main/webservice: redo error reporting through exceptions, no longer loses error
information, allow more fine-grained suppression of methods/attributed, touched up C++ webservice sample code to support showing the full error information, build system changes to prepare for incremental Java compilation, indentation fixesFrontends/VBoxShell: minor cleanups, coding style fixes, indentation fixes, elim
inate warnings

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 147.6 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-2013 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-2013 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 <xsl:value-of select="concat('Helper.unwrap2(', $elemgluetype, '.class, ', $elembacktype, '.class, ', $value, ')')"/>
1370 </xsl:when>
1371 <xsl:otherwise>
1372 <xsl:value-of select="concat('(', $value, ' != null) ? ', $value, '.getTypedWrapped() : null')" />
1373 </xsl:otherwise>
1374 </xsl:choose>
1375 </xsl:when>
1376
1377 <xsl:when test="$idltype='$unknown'">
1378 <xsl:choose>
1379 <xsl:when test="$safearray='yes'">
1380 <xsl:value-of select="concat('Helper.unwrap2(', $elemgluetype, '.class, Dispatch.class, ', $value, ')')"/>
1381 </xsl:when>
1382 <xsl:otherwise>
1383 <xsl:value-of select="concat('(', $value, ' != null) ? (Dispatch)', $value, '.getWrapped() : null')" />
1384 </xsl:otherwise>
1385 </xsl:choose>
1386 </xsl:when>
1387
1388 <xsl:when test="//enum[@name=$idltype]">
1389 <xsl:choose>
1390 <xsl:when test="$safearray='yes'">
1391 <xsl:value-of select="concat('Helper.unwrapEnum(', $elemgluetype, '.class, ', $value, ')')"/>
1392 </xsl:when>
1393 <xsl:otherwise>
1394 <xsl:value-of select="concat($value, '.value()')"/>
1395 </xsl:otherwise>
1396 </xsl:choose>
1397 </xsl:when>
1398
1399 <xsl:when test="$idltype='boolean'">
1400 <xsl:choose>
1401 <xsl:when test="$safearray='yes'">
1402 <xsl:value-of select="concat('Helper.unwrapBool(', $value, ')')"/>
1403 </xsl:when>
1404 <xsl:otherwise>
1405 <xsl:value-of select="concat('new Variant(', $value, ')')"/>
1406 </xsl:otherwise>
1407 </xsl:choose>
1408 </xsl:when>
1409
1410 <xsl:when test="($idltype='short') or ($idltype='unsigned short')">
1411 <xsl:choose>
1412 <xsl:when test="$safearray='yes'">
1413 <xsl:value-of select="concat('Helper.unwrapShort(', $value, ')')"/>
1414 </xsl:when>
1415 <xsl:otherwise>
1416 <xsl:value-of select="concat('new Variant(', $value, ')')"/>
1417 </xsl:otherwise>
1418 </xsl:choose>
1419 </xsl:when>
1420
1421
1422 <xsl:when test="($idltype='long') or ($idltype='unsigned long')">
1423 <xsl:choose>
1424 <xsl:when test="$safearray='yes'">
1425 <xsl:value-of select="concat('Helper.unwrapInt(', $value, ')')"/>
1426 </xsl:when>
1427 <xsl:otherwise>
1428 <xsl:value-of select="concat('new Variant(', $value, ')')"/>
1429 </xsl:otherwise>
1430 </xsl:choose>
1431 </xsl:when>
1432
1433 <xsl:when test="($idltype='wstring') or ($idltype='uuid')">
1434 <xsl:choose>
1435 <xsl:when test="$safearray='yes'">
1436 <xsl:value-of select="concat('Helper.unwrapString(', $value, ')')"/>
1437 </xsl:when>
1438 <xsl:otherwise>
1439 <xsl:value-of select="concat('new Variant(', $value, ')')"/>
1440 </xsl:otherwise>
1441 </xsl:choose>
1442 </xsl:when>
1443
1444 <xsl:when test="($idltype='unsigned long long') or ($idltype='long long')">
1445 <xsl:choose>
1446 <xsl:when test="$safearray='yes'">
1447 <xsl:value-of select="concat('Helper.unwrapLong(', $value, ')')"/>
1448 </xsl:when>
1449 <xsl:otherwise>
1450 <xsl:value-of select="concat('new Variant(', $value, '.longValue())')"/>
1451 </xsl:otherwise>
1452 </xsl:choose>
1453 </xsl:when>
1454
1455 <xsl:when test="($idltype='octet') and ($safearray='yes')">
1456 <xsl:value-of select="concat('Helper.encodeBase64(', $value, ')')"/>
1457 </xsl:when>
1458
1459 <xsl:otherwise>
1460 <xsl:call-template name="fatalError">
1461 <xsl:with-param name="msg" select="concat('Unhandled type: ', $idltype)" />
1462 </xsl:call-template>
1463 </xsl:otherwise>
1464 </xsl:choose>
1465
1466</xsl:template>
1467
1468<xsl:template name="cookInParamJaxws">
1469 <xsl:param name="value"/>
1470 <xsl:param name="idltype"/>
1471 <xsl:param name="safearray"/>
1472 <xsl:variable name="isstruct"
1473 select="//interface[@name=$idltype]/@wsmap='struct'" />
1474
1475 <xsl:variable name="gluetype">
1476 <xsl:call-template name="typeIdl2Glue">
1477 <xsl:with-param name="type" select="$idltype" />
1478 <xsl:with-param name="safearray" select="$safearray" />
1479 </xsl:call-template>
1480 </xsl:variable>
1481
1482 <xsl:variable name="elemgluetype">
1483 <xsl:if test="$safearray='yes'">
1484 <xsl:call-template name="typeIdl2Glue">
1485 <xsl:with-param name="type" select="$idltype" />
1486 <xsl:with-param name="safearray" select="'no'" />
1487 <xsl:with-param name="forceelem" select="'yes'" />
1488 </xsl:call-template>
1489 </xsl:if>
1490 </xsl:variable>
1491
1492 <xsl:choose>
1493 <xsl:when test="//interface[@name=$idltype] or $idltype='$unknown'">
1494 <xsl:choose>
1495 <xsl:when test="@safearray='yes'">
1496 <xsl:value-of select="concat('Helper.unwrap(', $value, ')')"/>
1497 </xsl:when>
1498 <xsl:otherwise>
1499 <xsl:value-of select="concat('((', $value, ' == null) ? null :', $value, '.getWrapped())')" />
1500 </xsl:otherwise>
1501 </xsl:choose>
1502 </xsl:when>
1503
1504 <xsl:when test="//enum[@name=$idltype]">
1505 <xsl:choose>
1506 <xsl:when test="$safearray='yes'">
1507 <xsl:variable name="elembacktype">
1508 <xsl:call-template name="typeIdl2Back">
1509 <xsl:with-param name="type" select="$idltype" />
1510 <xsl:with-param name="safearray" select="'no'" />
1511 <xsl:with-param name="forceelem" select="'yes'" />
1512 </xsl:call-template>
1513 </xsl:variable>
1514 <xsl:value-of select="concat('Helper.convertEnums(', $elemgluetype, '.class, ', $elembacktype, '.class, ', $value, ')')"/>
1515 </xsl:when>
1516 <xsl:otherwise>
1517 <xsl:variable name="backtype">
1518 <xsl:call-template name="typeIdl2Back">
1519 <xsl:with-param name="type" select="$idltype" />
1520 <xsl:with-param name="safearray" select="'no'" />
1521 <xsl:with-param name="forceelem" select="'yes'" />
1522 </xsl:call-template>
1523 </xsl:variable>
1524 <xsl:value-of select="concat($backtype, '.fromValue(', $value, '.name())')"/>
1525 </xsl:otherwise>
1526 </xsl:choose>
1527 </xsl:when>
1528
1529 <xsl:when test="($idltype='octet') and ($safearray='yes')">
1530 <xsl:value-of select="concat('Helper.encodeBase64(', $value, ')')"/>
1531 </xsl:when>
1532
1533 <xsl:otherwise>
1534 <xsl:value-of select="$value"/>
1535 </xsl:otherwise>
1536 </xsl:choose>
1537
1538</xsl:template>
1539
1540<xsl:template name="cookInParam">
1541 <xsl:param name="value"/>
1542 <xsl:param name="idltype"/>
1543 <xsl:param name="safearray"/>
1544 <xsl:choose>
1545 <xsl:when test="($G_vboxGlueStyle='xpcom')">
1546 <xsl:call-template name="cookInParamXpcom">
1547 <xsl:with-param name="value" select="$value" />
1548 <xsl:with-param name="idltype" select="$idltype" />
1549 <xsl:with-param name="safearray" select="$safearray" />
1550 </xsl:call-template>
1551 </xsl:when>
1552 <xsl:when test="($G_vboxGlueStyle='mscom')">
1553 <xsl:call-template name="cookInParamMscom">
1554 <xsl:with-param name="value" select="$value" />
1555 <xsl:with-param name="idltype" select="$idltype" />
1556 <xsl:with-param name="safearray" select="$safearray" />
1557 </xsl:call-template>
1558 </xsl:when>
1559 <xsl:when test="($G_vboxGlueStyle='jaxws')">
1560 <xsl:call-template name="cookInParamJaxws">
1561 <xsl:with-param name="value" select="$value" />
1562 <xsl:with-param name="idltype" select="$idltype" />
1563 <xsl:with-param name="safearray" select="$safearray" />
1564 </xsl:call-template>
1565 </xsl:when>
1566 <xsl:otherwise>
1567 <xsl:call-template name="fatalError">
1568 <xsl:with-param name="msg" select="'Unhandled style (cookInParam)'" />
1569 </xsl:call-template>
1570 </xsl:otherwise>
1571 </xsl:choose>
1572</xsl:template>
1573
1574<!-- Invoke backend method, including parameter conversion -->
1575<xsl:template name="genBackMethodCall">
1576 <xsl:param name="ifname"/>
1577 <xsl:param name="methodname"/>
1578 <xsl:param name="retval"/>
1579
1580 <xsl:choose>
1581 <xsl:when test="($G_vboxGlueStyle='xpcom')">
1582 <xsl:text> </xsl:text>
1583 <xsl:if test="param[@dir='return']">
1584 <xsl:value-of select="concat($retval, ' = ')" />
1585 </xsl:if>
1586 <xsl:value-of select="concat('getTypedWrapped().', $methodname, '(')"/>
1587 <xsl:for-each select="param">
1588 <xsl:choose>
1589 <xsl:when test="@dir='return'">
1590 <xsl:if test="@safearray='yes'">
1591 <xsl:text>null</xsl:text>
1592 </xsl:if>
1593 </xsl:when>
1594 <xsl:when test="@dir='out'">
1595 <xsl:if test="@safearray='yes'">
1596 <xsl:text>null, </xsl:text>
1597 </xsl:if>
1598 <xsl:value-of select="concat('tmp_', @name)" />
1599 </xsl:when>
1600 <xsl:when test="@dir='in'">
1601 <xsl:if test="(@safearray='yes') and not(@type = 'octet')">
1602 <xsl:value-of select="concat(@name, '.size(), ')" />
1603 </xsl:if>
1604 <xsl:variable name="unwrapped">
1605 <xsl:call-template name="cookInParam">
1606 <xsl:with-param name="value" select="@name" />
1607 <xsl:with-param name="idltype" select="@type" />
1608 <xsl:with-param name="safearray" select="@safearray" />
1609 </xsl:call-template>
1610 </xsl:variable>
1611 <xsl:value-of select="$unwrapped"/>
1612 </xsl:when>
1613 <xsl:otherwise>
1614 <xsl:call-template name="fatalError">
1615 <xsl:with-param name="msg" select="concat('Unsupported param dir: ', @dir, '&quot;.')" />
1616 </xsl:call-template>
1617 </xsl:otherwise>
1618 </xsl:choose>
1619 <xsl:if test="not(position()=last()) and not(following-sibling::param[1]/@dir='return' and not(following-sibling::param[1]/@safearray='yes'))">
1620 <xsl:text>, </xsl:text>
1621 </xsl:if>
1622 </xsl:for-each>
1623 <xsl:text>);&#10;</xsl:text>
1624 </xsl:when>
1625
1626 <xsl:when test="($G_vboxGlueStyle='mscom')">
1627 <xsl:text> </xsl:text>
1628 <xsl:if test="param[@dir='return']">
1629 <xsl:value-of select="concat($retval, ' = ')" />
1630 </xsl:if>
1631 <xsl:value-of select="concat('Helper.invoke(getTypedWrapped(), &quot;', $methodname, '&quot; ')"/>
1632 <xsl:for-each select="param[not(@dir='return')]">
1633 <xsl:text>, </xsl:text>
1634 <xsl:choose>
1635 <xsl:when test="@dir='out'">
1636 <xsl:value-of select="concat('tmp_', @name)" />
1637 </xsl:when>
1638 <xsl:when test="@dir='in'">
1639 <xsl:variable name="unwrapped">
1640 <xsl:call-template name="cookInParam">
1641 <xsl:with-param name="value" select="@name" />
1642 <xsl:with-param name="idltype" select="@type" />
1643 <xsl:with-param name="safearray" select="@safearray" />
1644 </xsl:call-template>
1645 </xsl:variable>
1646 <xsl:value-of select="$unwrapped"/>
1647 </xsl:when>
1648 </xsl:choose>
1649 </xsl:for-each>
1650 <xsl:text>);&#10;</xsl:text>
1651 </xsl:when>
1652
1653 <xsl:when test="($G_vboxGlueStyle='jaxws')">
1654 <xsl:variable name="jaxwsmethod">
1655 <xsl:call-template name="makeJaxwsMethod">
1656 <xsl:with-param name="ifname" select="$ifname" />
1657 <xsl:with-param name="methodname" select="$methodname" />
1658 </xsl:call-template>
1659 </xsl:variable>
1660 <xsl:variable name="portArg">
1661 <xsl:if test="not(//interface[@name=$ifname]/@wsmap='global')">
1662 <xsl:text>obj</xsl:text>
1663 </xsl:if>
1664 </xsl:variable>
1665 <xsl:variable name="paramsinout" select="param[@dir='in' or @dir='out']" />
1666
1667 <xsl:text> </xsl:text>
1668 <xsl:if test="param[@dir='return'] and not(param[@dir='out'])">
1669 <xsl:value-of select="concat($retval, ' = ')" />
1670 </xsl:if>
1671 <xsl:value-of select="concat('port.', $jaxwsmethod, '(', $portArg)" />
1672 <xsl:if test="$paramsinout and not($portArg='')">
1673 <xsl:text>, </xsl:text>
1674 </xsl:if>
1675
1676 <!-- jax-ws has an oddity: if both out params and a return value exist,
1677 then the return value is moved to the function's argument list... -->
1678 <xsl:choose>
1679 <xsl:when test="param[@dir='out'] and param[@dir='return']">
1680 <xsl:for-each select="param">
1681 <xsl:choose>
1682 <xsl:when test="@dir='return'">
1683 <xsl:value-of select="$retval"/>
1684 </xsl:when>
1685 <xsl:when test="@dir='out'">
1686 <xsl:value-of select="concat('tmp_', @name)" />
1687 </xsl:when>
1688 <xsl:otherwise>
1689 <xsl:call-template name="cookInParam">
1690 <xsl:with-param name="value" select="@name" />
1691 <xsl:with-param name="idltype" select="@type" />
1692 <xsl:with-param name="safearray" select="@safearray" />
1693 </xsl:call-template>
1694 </xsl:otherwise>
1695 </xsl:choose>
1696 <xsl:if test="not(position()=last())">
1697 <xsl:text>, </xsl:text>
1698 </xsl:if>
1699 </xsl:for-each>
1700 </xsl:when>
1701 <xsl:otherwise>
1702 <xsl:for-each select="$paramsinout">
1703 <xsl:choose>
1704 <xsl:when test="@dir='return'">
1705 <xsl:value-of select="$retval"/>
1706 </xsl:when>
1707 <xsl:when test="@dir='out'">
1708 <xsl:value-of select="concat('tmp_', @name)" />
1709 </xsl:when>
1710 <xsl:otherwise>
1711 <xsl:call-template name="cookInParam">
1712 <xsl:with-param name="value" select="@name" />
1713 <xsl:with-param name="idltype" select="@type" />
1714 <xsl:with-param name="safearray" select="@safearray" />
1715 </xsl:call-template>
1716 </xsl:otherwise>
1717 </xsl:choose>
1718 <xsl:if test="not(position()=last())">
1719 <xsl:text>, </xsl:text>
1720 </xsl:if>
1721 </xsl:for-each>
1722 </xsl:otherwise>
1723 </xsl:choose>
1724 <xsl:text>);&#10;</xsl:text>
1725 </xsl:when>
1726
1727 <xsl:otherwise>
1728 <xsl:call-template name="fatalError">
1729 <xsl:with-param name="msg" select="'Style unknown (genBackMethodCall)'" />
1730 </xsl:call-template>
1731 </xsl:otherwise>
1732
1733 </xsl:choose>
1734</xsl:template>
1735
1736<xsl:template name="genGetterCall">
1737 <xsl:param name="ifname"/>
1738 <xsl:param name="gettername"/>
1739 <xsl:param name="backtype"/>
1740 <xsl:param name="retval"/>
1741
1742 <xsl:choose>
1743 <xsl:when test="$G_vboxGlueStyle='xpcom'">
1744 <xsl:value-of select="concat(' ', $backtype, ' ', $retval, ' = getTypedWrapped().', $gettername, '(')" />
1745 <xsl:if test="@safearray">
1746 <xsl:text>null</xsl:text>
1747 </xsl:if>
1748 <xsl:text>);&#10;</xsl:text>
1749 </xsl:when>
1750
1751 <xsl:when test="$G_vboxGlueStyle='mscom'">
1752 <xsl:value-of select="concat(' ', $backtype, ' ', $retval, ' = Dispatch.get(getTypedWrapped(), &quot;', @name, '&quot;);&#10;')" />
1753 </xsl:when>
1754
1755 <xsl:when test="$G_vboxGlueStyle='jaxws'">
1756 <xsl:variable name="jaxwsGetter">
1757 <xsl:call-template name="makeJaxwsMethod">
1758 <xsl:with-param name="ifname" select="$ifname" />
1759 <xsl:with-param name="methodname" select="$gettername" />
1760 </xsl:call-template>
1761 </xsl:variable>
1762 <xsl:value-of select="concat(' ', $backtype, ' ', $retval, ' = port.', $jaxwsGetter, '(obj);&#10;')" />
1763 </xsl:when>
1764
1765 <xsl:otherwise>
1766 <xsl:call-template name="fatalError">
1767 <xsl:with-param name="msg" select="'Style unknown (genGetterCall)'" />
1768 </xsl:call-template>
1769 </xsl:otherwise>
1770 </xsl:choose>
1771</xsl:template>
1772
1773<xsl:template name="genSetterCall">
1774 <xsl:param name="ifname"/>
1775 <xsl:param name="settername"/>
1776 <xsl:param name="value"/>
1777
1778 <xsl:choose>
1779 <xsl:when test="$G_vboxGlueStyle='xpcom'">
1780 <xsl:value-of select="concat(' getTypedWrapped().', $settername, '(', $value, ');&#10;')" />
1781 </xsl:when>
1782
1783 <xsl:when test="$G_vboxGlueStyle='mscom'">
1784 <xsl:value-of select="concat(' Dispatch.put(getTypedWrapped(), &quot;', @name, '&quot;, ', $value, ');&#10;')" />
1785 </xsl:when>
1786
1787 <xsl:when test="$G_vboxGlueStyle='jaxws'">
1788 <xsl:variable name="jaxwsSetter">
1789 <xsl:call-template name="makeJaxwsMethod">
1790 <xsl:with-param name="ifname" select="$ifname" />
1791 <xsl:with-param name="methodname" select="$settername" />
1792 </xsl:call-template>
1793 </xsl:variable>
1794 <xsl:value-of select="concat(' port.', $jaxwsSetter, '(obj, ', $value, ');&#10;')" />
1795 </xsl:when>
1796
1797 <xsl:otherwise>
1798 <xsl:call-template name="fatalError">
1799 <xsl:with-param name="msg" select="'Style unknown (genSetterCall)'" />
1800 </xsl:call-template>
1801 </xsl:otherwise>
1802 </xsl:choose>
1803</xsl:template>
1804
1805<xsl:template name="genStructWrapperJaxws">
1806 <xsl:param name="ifname"/>
1807
1808 <xsl:value-of select="concat(' private ', $G_virtualBoxPackageCom, '.', $ifname, ' real;&#10;')"/>
1809 <xsl:text> private VboxPortType port;&#10;&#10;</xsl:text>
1810
1811 <xsl:value-of select="concat(' public ', $ifname, '(', $G_virtualBoxPackageCom, '.', $ifname, ' real, VboxPortType port)&#10;')" />
1812 <xsl:text> {&#10;</xsl:text>
1813 <xsl:text> this.real = real;&#10;</xsl:text>
1814 <xsl:text> this.port = port;&#10;</xsl:text>
1815 <xsl:text> }&#10;&#10;</xsl:text>
1816
1817 <xsl:for-each select="attribute">
1818 <xsl:variable name="attrname"><xsl:value-of select="@name" /></xsl:variable>
1819 <xsl:variable name="attrtype"><xsl:value-of select="@type" /></xsl:variable>
1820 <xsl:variable name="attrsafearray"><xsl:value-of select="@safearray" /></xsl:variable>
1821
1822 <xsl:if test="not(@wsmap = 'suppress')">
1823
1824 <xsl:if test="not(@readonly = 'yes')">
1825 <xsl:call-template name="fatalError">
1826 <xsl:with-param name="msg" select="concat('Non read-only struct (genStructWrapperJaxws) in interface ', $ifname, ', attribute ', $attrname)" />
1827 </xsl:call-template>
1828 </xsl:if>
1829
1830 <!-- Emit getter -->
1831 <xsl:variable name="backgettername">
1832 <xsl:choose>
1833 <!-- Stupid, but backend boolean getters called isFoo(), not getFoo() -->
1834 <xsl:when test="$attrtype = 'boolean'">
1835 <xsl:variable name="capsname">
1836 <xsl:call-template name="capitalize">
1837 <xsl:with-param name="str" select="$attrname" />
1838 </xsl:call-template>
1839 </xsl:variable>
1840 <xsl:value-of select="concat('is', $capsname)" />
1841 </xsl:when>
1842 <xsl:otherwise>
1843 <xsl:call-template name="makeGetterName">
1844 <xsl:with-param name="attrname" select="$attrname" />
1845 </xsl:call-template>
1846 </xsl:otherwise>
1847 </xsl:choose>
1848 </xsl:variable>
1849
1850 <xsl:variable name="gluegettername">
1851 <xsl:call-template name="makeGetterName">
1852 <xsl:with-param name="attrname" select="$attrname" />
1853 </xsl:call-template>
1854 </xsl:variable>
1855
1856 <xsl:variable name="gluegettertype">
1857 <xsl:call-template name="typeIdl2Glue">
1858 <xsl:with-param name="type" select="$attrtype" />
1859 <xsl:with-param name="safearray" select="@safearray" />
1860 </xsl:call-template>
1861 </xsl:variable>
1862
1863 <xsl:variable name="backgettertype">
1864 <xsl:call-template name="typeIdl2Back">
1865 <xsl:with-param name="type" select="$attrtype" />
1866 <xsl:with-param name="safearray" select="@safearray" />
1867 </xsl:call-template>
1868 </xsl:variable>
1869
1870 <xsl:apply-templates select="desc" mode="attribute_get"/>
1871 <xsl:value-of select="concat(' public ', $gluegettertype, ' ', $gluegettername, '()&#10;')" />
1872 <xsl:text> {&#10;</xsl:text>
1873 <xsl:value-of select="concat(' ', $backgettertype, ' retVal = real.', $backgettername, '();&#10;')" />
1874 <xsl:variable name="wrapped">
1875 <xsl:call-template name="cookOutParam">
1876 <xsl:with-param name="value" select="'retVal'" />
1877 <xsl:with-param name="idltype" select="$attrtype" />
1878 <xsl:with-param name="safearray" select="@safearray" />
1879 </xsl:call-template>
1880 </xsl:variable>
1881 <xsl:value-of select="concat(' return ', $wrapped, ';&#10;')" />
1882 <xsl:text> }&#10;</xsl:text>
1883 </xsl:if>
1884
1885 </xsl:for-each>
1886
1887</xsl:template>
1888
1889<!-- Interface method wrapper -->
1890<xsl:template name="genMethod">
1891 <xsl:param name="ifname"/>
1892 <xsl:param name="methodname"/>
1893
1894 <xsl:choose>
1895 <xsl:when test="(param[@mod='ptr']) or (($G_vboxGlueStyle='jaxws') and (param[@type=($G_setSuppressedInterfaces/@name)]))" >
1896 <xsl:value-of select="concat(' // Skipping method ', $methodname, ' for it has parameters with suppressed types&#10;')" />
1897 </xsl:when>
1898 <xsl:when test="($G_vboxGlueStyle='jaxws') and (@wsmap = 'suppress')" >
1899 <xsl:value-of select="concat(' // Skipping method ', $methodname, ' for it is suppressed&#10;')" />
1900 </xsl:when>
1901 <xsl:otherwise>
1902 <xsl:variable name="hasReturnParms" select="param[@dir='return']" />
1903 <xsl:variable name="hasOutParms" select="param[@dir='out']" />
1904 <xsl:variable name="returnidltype" select="param[@dir='return']/@type" />
1905 <xsl:variable name="returnidlsafearray" select="param[@dir='return']/@safearray" />
1906 <xsl:variable name="returngluetype">
1907 <xsl:choose>
1908 <xsl:when test="$returnidltype">
1909 <xsl:call-template name="typeIdl2Glue">
1910 <xsl:with-param name="type" select="$returnidltype" />
1911 <xsl:with-param name="safearray" select="$returnidlsafearray" />
1912 </xsl:call-template>
1913 </xsl:when>
1914 <xsl:otherwise>
1915 <xsl:text>void</xsl:text>
1916 </xsl:otherwise>
1917 </xsl:choose>
1918 </xsl:variable>
1919 <xsl:variable name="retValValue">
1920 <xsl:choose>
1921 <xsl:when test="(param[@dir='out']) and ($G_vboxGlueStyle='jaxws')">
1922 <xsl:text>retVal.value</xsl:text>
1923 </xsl:when>
1924 <xsl:otherwise>
1925 <xsl:text>retVal</xsl:text>
1926 </xsl:otherwise>
1927 </xsl:choose>
1928 </xsl:variable>
1929 <xsl:apply-templates select="desc" mode="method"/>
1930 <xsl:value-of select="concat(' public ', $returngluetype, ' ', $methodname, '(')" />
1931 <xsl:variable name="paramsinout" select="param[@dir='in' or @dir='out']" />
1932 <xsl:for-each select="exsl:node-set($paramsinout)">
1933 <xsl:variable name="paramgluetype">
1934 <xsl:call-template name="typeIdl2Glue">
1935 <xsl:with-param name="type" select="@type" />
1936 <xsl:with-param name="safearray" select="@safearray" />
1937 </xsl:call-template>
1938 </xsl:variable>
1939 <xsl:choose>
1940 <xsl:when test="@dir='out'">
1941 <xsl:value-of select="concat('Holder&lt;', $paramgluetype, '&gt; ', @name)" />
1942 </xsl:when>
1943 <xsl:otherwise>
1944 <xsl:value-of select="concat($paramgluetype, ' ', @name)" />
1945 </xsl:otherwise>
1946 </xsl:choose>
1947 <xsl:if test="not(position()=last())">
1948 <xsl:text>, </xsl:text>
1949 </xsl:if>
1950 </xsl:for-each>
1951 <xsl:text>)&#10;</xsl:text>
1952 <xsl:text> {&#10;</xsl:text>
1953
1954 <xsl:call-template name="startExcWrapper"/>
1955
1956 <!-- declare temp out params -->
1957 <xsl:for-each select="param[@dir='out']">
1958 <xsl:variable name="backouttype">
1959 <xsl:call-template name="typeIdl2Back">
1960 <xsl:with-param name="type" select="@type" />
1961 <xsl:with-param name="safearray" select="@safearray" />
1962 </xsl:call-template>
1963 </xsl:variable>
1964 <xsl:choose>
1965 <xsl:when test="$G_vboxGlueStyle='xpcom'">
1966 <xsl:value-of select="concat(' ', $backouttype, '[] tmp_', @name, ' = (', $backouttype, '[])java.lang.reflect.Array.newInstance(', $backouttype, '.class, 1);&#10;')"/>
1967 </xsl:when>
1968 <xsl:when test="$G_vboxGlueStyle='mscom'">
1969 <xsl:value-of select="concat(' Variant tmp_', @name, ' = new Variant();&#10;')"/>
1970 </xsl:when>
1971 <xsl:when test="$G_vboxGlueStyle='jaxws'">
1972 <xsl:value-of select="concat(' javax.xml.ws.Holder&lt;', $backouttype, '&gt; tmp_', @name, ' = new javax.xml.ws.Holder&lt;', $backouttype, '&gt;();&#10;')"/>
1973 </xsl:when>
1974 <xsl:otherwise>
1975 <xsl:call-template name="fatalError">
1976 <xsl:with-param name="msg" select="'Handle out param (genMethod)'" />
1977 </xsl:call-template>
1978 </xsl:otherwise>
1979 </xsl:choose>
1980 </xsl:for-each>
1981
1982 <!-- declare return param, if any -->
1983 <xsl:if test="$hasReturnParms">
1984 <xsl:variable name="backrettype">
1985 <xsl:call-template name="typeIdl2Back">
1986 <xsl:with-param name="type" select="$returnidltype" />
1987 <xsl:with-param name="safearray" select="$returnidlsafearray" />
1988 </xsl:call-template>
1989 </xsl:variable>
1990 <xsl:choose>
1991 <xsl:when test="(param[@dir='out']) and ($G_vboxGlueStyle='jaxws')">
1992 <xsl:value-of select="concat(' javax.xml.ws.Holder&lt;', $backrettype, '&gt;',
1993 ' retVal = new javax.xml.ws.Holder&lt;', $backrettype,
1994 '&gt;();&#10;')"/>
1995 </xsl:when>
1996 <xsl:otherwise>
1997 <xsl:value-of select="concat(' ', $backrettype, ' retVal;&#10;')"/>
1998 </xsl:otherwise>
1999 </xsl:choose>
2000 </xsl:if>
2001
2002 <!-- Method call -->
2003 <xsl:call-template name="genBackMethodCall">
2004 <xsl:with-param name="ifname" select="$ifname" />
2005 <xsl:with-param name="methodname" select="$methodname" />
2006 <xsl:with-param name="retval" select="'retVal'" />
2007 </xsl:call-template>
2008
2009 <!-- return out params -->
2010 <xsl:for-each select="param[@dir='out']">
2011 <xsl:variable name="varval">
2012 <xsl:choose>
2013 <xsl:when test="$G_vboxGlueStyle='xpcom'">
2014 <xsl:value-of select="concat('tmp_', @name, '[0]')" />
2015 </xsl:when>
2016 <xsl:when test="$G_vboxGlueStyle='mscom'">
2017 <xsl:value-of select="concat('tmp_', @name)" />
2018 </xsl:when>
2019 <xsl:when test="$G_vboxGlueStyle='jaxws'">
2020 <xsl:value-of select="concat('tmp_', @name, '.value')" />
2021 </xsl:when>
2022 <xsl:otherwise>
2023 <xsl:call-template name="fatalError">
2024 <xsl:with-param name="msg" select="'Style unknown (genMethod, outparam)'" />
2025 </xsl:call-template>
2026 </xsl:otherwise>
2027 </xsl:choose>
2028 </xsl:variable>
2029 <xsl:variable name="wrapped">
2030 <xsl:call-template name="cookOutParam">
2031 <xsl:with-param name="value" select="$varval" />
2032 <xsl:with-param name="idltype" select="@type" />
2033 <xsl:with-param name="safearray" select="@safearray" />
2034 </xsl:call-template>
2035 </xsl:variable>
2036 <xsl:value-of select="concat(' ', @name, '.value = ', $wrapped, ';&#10;')"/>
2037 </xsl:for-each>
2038
2039 <xsl:if test="$hasReturnParms">
2040 <!-- actual 'return' statement -->
2041 <xsl:variable name="wrapped">
2042 <xsl:call-template name="cookOutParam">
2043 <xsl:with-param name="value" select="$retValValue" />
2044 <xsl:with-param name="idltype" select="$returnidltype" />
2045 <xsl:with-param name="safearray" select="$returnidlsafearray" />
2046 </xsl:call-template>
2047 </xsl:variable>
2048 <xsl:value-of select="concat(' return ', $wrapped, ';&#10;')" />
2049 </xsl:if>
2050 <xsl:call-template name="endExcWrapper"/>
2051
2052 <xsl:text> }&#10;</xsl:text>
2053 </xsl:otherwise>
2054 </xsl:choose>
2055
2056</xsl:template>
2057
2058<!-- Callback interface method -->
2059<xsl:template name="genCbMethodDecl">
2060 <xsl:param name="ifname"/>
2061 <xsl:param name="methodname"/>
2062
2063 <xsl:choose>
2064 <xsl:when test="(param[@mod='ptr'])" >
2065 <xsl:value-of select="concat(' // Skipping method ', $methodname, ' for it has parameters with suppressed types&#10;')" />
2066 </xsl:when>
2067 <xsl:otherwise>
2068 <xsl:variable name="returnidltype" select="param[@dir='return']/@type" />
2069 <xsl:variable name="returnidlsafearray" select="param[@dir='return']/@safearray" />
2070 <xsl:variable name="returngluetype">
2071 <xsl:choose>
2072 <xsl:when test="$returnidltype">
2073 <xsl:call-template name="typeIdl2Glue">
2074 <xsl:with-param name="type" select="$returnidltype" />
2075 <xsl:with-param name="safearray" select="$returnidlsafearray" />
2076 </xsl:call-template>
2077 </xsl:when>
2078 <xsl:otherwise>
2079 <xsl:text>void</xsl:text>
2080 </xsl:otherwise>
2081 </xsl:choose>
2082 </xsl:variable>
2083 <xsl:value-of select="concat(' public ', $returngluetype, ' ', $methodname, '(')" />
2084 <xsl:variable name="paramsinout" select="param[@dir='in' or @dir='out']" />
2085 <xsl:for-each select="exsl:node-set($paramsinout)">
2086 <xsl:variable name="paramgluetype">
2087 <xsl:call-template name="typeIdl2Glue">
2088 <xsl:with-param name="type" select="@type" />
2089 <xsl:with-param name="safearray" select="@safearray" />
2090 </xsl:call-template>
2091 </xsl:variable>
2092 <xsl:choose>
2093 <xsl:when test="@dir='out'">
2094 <xsl:value-of select="concat('Holder&lt;', $paramgluetype, '&gt; ', @name)" />
2095 </xsl:when>
2096 <xsl:otherwise>
2097 <xsl:value-of select="concat($paramgluetype, ' ', @name)" />
2098 </xsl:otherwise>
2099 </xsl:choose>
2100 <xsl:if test="not(position()=last())">
2101 <xsl:text>, </xsl:text>
2102 </xsl:if>
2103 </xsl:for-each>
2104 <xsl:text>);&#10;</xsl:text>
2105 </xsl:otherwise>
2106 </xsl:choose>
2107</xsl:template>
2108
2109<!-- queryInterface wrapper -->
2110<xsl:template name="genQI">
2111 <xsl:param name="ifname"/>
2112 <xsl:param name="uuid" />
2113
2114 <xsl:value-of select="concat(' public static ', $ifname, ' queryInterface(IUnknown obj)&#10;')" />
2115 <xsl:text> {&#10;</xsl:text>
2116 <xsl:choose>
2117 <xsl:when test="$G_vboxGlueStyle='xpcom'">
2118 <xsl:variable name="backtype">
2119 <xsl:call-template name="typeIdl2Back">
2120 <xsl:with-param name="type" select="$ifname" />
2121 </xsl:call-template>
2122 </xsl:variable>
2123 <xsl:text> nsISupports nsobj = obj != null ? (nsISupports)obj.getWrapped() : null;&#10;</xsl:text>
2124 <xsl:text> if (nsobj == null) return null;&#10;</xsl:text>
2125 <xsl:value-of select="concat(' ', $backtype, ' qiobj = Helper.queryInterface(nsobj, &quot;{', $uuid, '}&quot;, ', $backtype, '.class);&#10;')" />
2126 <xsl:value-of select="concat(' return qiobj == null ? null : new ', $ifname, '(qiobj);&#10;')" />
2127 </xsl:when>
2128
2129 <xsl:when test="$G_vboxGlueStyle='mscom'">
2130 <xsl:value-of select="concat(' return', ' obj == null ? null : new ', $ifname, '((com.jacob.com.Dispatch)obj.getWrapped());&#10;')" />
2131 </xsl:when>
2132
2133 <xsl:when test="$G_vboxGlueStyle='jaxws'">
2134 <!-- bad, need to check that we really can be casted to this type -->
2135 <xsl:value-of select="concat(' return obj == null ? null : new ', $ifname, '(obj.getWrapped(), obj.getRemoteWSPort());&#10;')" />
2136 </xsl:when>
2137
2138 <xsl:otherwise>
2139 <xsl:call-template name="fatalError">
2140 <xsl:with-param name="msg" select="'Style unknown (genQI)'" />
2141 </xsl:call-template>
2142 </xsl:otherwise>
2143
2144 </xsl:choose>
2145 <xsl:text> }&#10;</xsl:text>
2146</xsl:template>
2147
2148
2149<xsl:template name="genCbMethodImpl">
2150 <xsl:param name="ifname"/>
2151 <xsl:param name="methodname"/>
2152
2153 <xsl:choose>
2154 <xsl:when test="(param[@mod='ptr'])" >
2155 <xsl:value-of select="concat(' // Skipping method ', $methodname, ' for it has parameters with suppressed types&#10;')" />
2156 </xsl:when>
2157 <xsl:otherwise>
2158 <xsl:variable name="hasReturnParms" select="param[@dir='return']" />
2159 <xsl:variable name="hasOutParms" select="param[@dir='out']" />
2160 <xsl:variable name="returnidltype" select="param[@dir='return']/@type" />
2161 <xsl:variable name="returnidlsafearray" select="param[@dir='return']/@safearray" />
2162 <xsl:variable name="returnbacktype">
2163 <xsl:choose>
2164 <xsl:when test="$returnidltype">
2165 <xsl:call-template name="typeIdl2Back">
2166 <xsl:with-param name="type" select="$returnidltype" />
2167 <xsl:with-param name="safearray" select="$returnidlsafearray" />
2168 </xsl:call-template>
2169 </xsl:when>
2170 <xsl:otherwise>
2171 <xsl:text>void</xsl:text>
2172 </xsl:otherwise>
2173 </xsl:choose>
2174 </xsl:variable>
2175 <xsl:variable name="paramsinout" select="param[@dir='in' or @dir='out']" />
2176 <xsl:choose>
2177 <xsl:when test="$G_vboxGlueStyle='xpcom'">
2178 <xsl:value-of select="concat(' public ', $returnbacktype, ' ', $methodname, '(')" />
2179 <xsl:for-each select="exsl:node-set($paramsinout)">
2180 <xsl:variable name="parambacktype">
2181 <xsl:call-template name="typeIdl2Back">
2182 <xsl:with-param name="type" select="@type" />
2183 <xsl:with-param name="safearray" select="@safearray" />
2184 </xsl:call-template>
2185 </xsl:variable>
2186 <xsl:choose>
2187 <xsl:when test="@dir='out'">
2188 <xsl:value-of select="concat($parambacktype, '[] ', @name)" />
2189 </xsl:when>
2190 <xsl:otherwise>
2191 <xsl:if test="@safearray">
2192 <xsl:value-of select="concat('long len_', @name, ', ')" />
2193 </xsl:if>
2194 <xsl:value-of select="concat($parambacktype, ' ', @name)" />
2195 </xsl:otherwise>
2196 </xsl:choose>
2197 <xsl:if test="not(position()=last())">
2198 <xsl:text>, </xsl:text>
2199 </xsl:if>
2200 </xsl:for-each>
2201 <xsl:text>)&#10;</xsl:text>
2202 <xsl:text> {&#10;</xsl:text>
2203 </xsl:when>
2204
2205 <xsl:when test="$G_vboxGlueStyle='mscom'">
2206 <xsl:variable name="capsname">
2207 <xsl:call-template name="capitalize">
2208 <xsl:with-param name="str" select="$methodname" />
2209 </xsl:call-template>
2210 </xsl:variable>
2211 <xsl:value-of select="concat(' public ', $returnbacktype, ' ', $capsname, '(')" />
2212 <xsl:text>Variant _args[])&#10;</xsl:text>
2213 <xsl:text> {&#10;</xsl:text>
2214 <xsl:for-each select="exsl:node-set($paramsinout)">
2215 <xsl:variable name="parambacktype">
2216 <xsl:call-template name="typeIdl2Back">
2217 <xsl:with-param name="type" select="@type" />
2218 <xsl:with-param name="safearray" select="@safearray" />
2219 </xsl:call-template>
2220 </xsl:variable>
2221 <xsl:value-of select="concat(' ', $parambacktype, ' ', @name, '=_args[', count(preceding-sibling::param), '];&#10;')" />
2222 </xsl:for-each>
2223 </xsl:when>
2224
2225 <xsl:otherwise>
2226 <xsl:call-template name="fatalError">
2227 <xsl:with-param name="msg" select="'Style unknown (genSetterCall)'" />
2228 </xsl:call-template>
2229 </xsl:otherwise>
2230 </xsl:choose>
2231
2232 <!-- declare temp out params -->
2233 <xsl:for-each select="param[@dir='out']">
2234 <xsl:variable name="glueouttype">
2235 <xsl:call-template name="typeIdl2Glue">
2236 <xsl:with-param name="type" select="@type" />
2237 <xsl:with-param name="safearray" select="@safearray" />
2238 </xsl:call-template>
2239 </xsl:variable>
2240 <xsl:value-of select="concat(' Holder&lt;', $glueouttype, '&gt; tmp_', @name, ' = new Holder&lt;', $glueouttype, '&gt;();&#10;')"/>
2241 </xsl:for-each>
2242
2243 <!-- declare return param, if any -->
2244 <xsl:if test="$hasReturnParms">
2245 <xsl:variable name="gluerettype">
2246 <xsl:call-template name="typeIdl2Glue">
2247 <xsl:with-param name="type" select="$returnidltype" />
2248 <xsl:with-param name="safearray" select="$returnidlsafearray" />
2249 </xsl:call-template>
2250 </xsl:variable>
2251 <xsl:value-of select="concat(' ', $gluerettype, ' retVal = &#10;')"/>
2252 </xsl:if>
2253
2254 <!-- Method call -->
2255 <xsl:value-of select="concat(' sink.', $methodname, '(')"/>
2256 <xsl:for-each select="param[not(@dir='return')]">
2257 <xsl:choose>
2258 <xsl:when test="@dir='out'">
2259 <xsl:value-of select="concat('tmp_', @name)" />
2260 </xsl:when>
2261 <xsl:when test="@dir='in'">
2262 <xsl:variable name="wrapped">
2263 <xsl:call-template name="cookOutParam">
2264 <xsl:with-param name="value" select="@name" />
2265 <xsl:with-param name="idltype" select="@type" />
2266 <xsl:with-param name="safearray" select="@safearray" />
2267 </xsl:call-template>
2268 </xsl:variable>
2269 <xsl:value-of select="$wrapped"/>
2270 </xsl:when>
2271 <xsl:otherwise>
2272 <xsl:call-template name="fatalError">
2273 <xsl:with-param name="msg" select="concat('Unsupported param dir: ', @dir, '&quot;.')" />
2274 </xsl:call-template>
2275 </xsl:otherwise>
2276 </xsl:choose>
2277 <xsl:if test="not(position()=last())">
2278 <xsl:text>, </xsl:text>
2279 </xsl:if>
2280 </xsl:for-each>
2281 <xsl:text>);&#10;</xsl:text>
2282
2283 <!-- return out params -->
2284 <xsl:for-each select="param[@dir='out']">
2285
2286 <xsl:variable name="unwrapped">
2287 <xsl:call-template name="cookInParam">
2288 <xsl:with-param name="value" select="concat('tmp_', @name, '.value')" />
2289 <xsl:with-param name="idltype" select="@type" />
2290 <xsl:with-param name="safearray" select="@safearray" />
2291 </xsl:call-template>
2292 </xsl:variable>
2293 <xsl:choose>
2294 <xsl:when test="$G_vboxGlueStyle='xpcom'">
2295 <xsl:value-of select="concat(' ', @name, '[0] = ', $unwrapped, ';&#10;')"/>
2296 </xsl:when>
2297 <xsl:when test="$G_vboxGlueStyle='mscom'">
2298 <xsl:value-of select="concat(' _args[', count(preceding-sibling::param), '] = ', $unwrapped, ';&#10;')"/>
2299 </xsl:when>
2300 </xsl:choose>
2301 </xsl:for-each>
2302
2303 <xsl:if test="$hasReturnParms">
2304 <!-- actual 'return' statement -->
2305 <xsl:variable name="unwrapped">
2306 <xsl:call-template name="cookInParam">
2307 <xsl:with-param name="value" select="'retVal'" />
2308 <xsl:with-param name="idltype" select="$returnidltype" />
2309 <xsl:with-param name="safearray" select="$returnidlsafearray" />
2310 </xsl:call-template>
2311 </xsl:variable>
2312 <xsl:value-of select="concat(' return ', $unwrapped, ';&#10;')" />
2313 </xsl:if>
2314 <xsl:text> }&#10;</xsl:text>
2315 </xsl:otherwise>
2316 </xsl:choose>
2317</xsl:template>
2318
2319<!-- Interface method -->
2320<xsl:template name="genIfaceWrapper">
2321 <xsl:param name="ifname"/>
2322
2323 <xsl:variable name="wrappedType">
2324 <xsl:call-template name="wrappedName">
2325 <xsl:with-param name="ifname" select="$ifname" />
2326 </xsl:call-template>
2327 </xsl:variable>
2328
2329 <!-- Constructor -->
2330 <xsl:choose>
2331 <xsl:when test="($G_vboxGlueStyle='jaxws')">
2332 <xsl:value-of select="concat(' public ', $ifname, '(String wrapped, VboxPortType port)&#10;')" />
2333 <xsl:text> {&#10;</xsl:text>
2334 <xsl:text> super(wrapped, port);&#10;</xsl:text>
2335 <xsl:text> }&#10;</xsl:text>
2336 </xsl:when>
2337
2338 <xsl:when test="($G_vboxGlueStyle='xpcom') or ($G_vboxGlueStyle='mscom')">
2339 <xsl:value-of select="concat(' public ', $ifname, '(', $wrappedType, ' wrapped)&#10;')" />
2340 <xsl:text> {&#10;</xsl:text>
2341 <xsl:text> super(wrapped);&#10;</xsl:text>
2342 <xsl:text> }&#10;</xsl:text>
2343
2344 <!-- Typed wrapped object accessor -->
2345 <xsl:value-of select="concat(' public ', $wrappedType, ' getTypedWrapped()&#10;')" />
2346 <xsl:text> {&#10;</xsl:text>
2347 <xsl:value-of select="concat(' return (', $wrappedType, ') getWrapped();&#10;')" />
2348 <xsl:text> }&#10;</xsl:text>
2349 </xsl:when>
2350
2351 <xsl:otherwise>
2352 <xsl:call-template name="fatalError">
2353 <xsl:with-param name="msg" select="'Style unknown (root, ctr)'" />
2354 </xsl:call-template>
2355 </xsl:otherwise>
2356 </xsl:choose>
2357 <!-- Attributes -->
2358 <xsl:for-each select="attribute[not(@mod='ptr')]">
2359 <xsl:variable name="attrname"><xsl:value-of select="@name" /></xsl:variable>
2360 <xsl:variable name="attrtype"><xsl:value-of select="@type" /></xsl:variable>
2361 <xsl:variable name="attrsafearray"><xsl:value-of select="@safearray" /></xsl:variable>
2362
2363 <xsl:choose>
2364 <xsl:when test="($G_vboxGlueStyle='jaxws') and ($attrtype=($G_setSuppressedInterfaces/@name))">
2365 <xsl:value-of select="concat(' // Skipping attribute ', $attrname, ' of suppressed type ', $attrtype, '&#10;&#10;')" />
2366 </xsl:when>
2367 <xsl:when test="($G_vboxGlueStyle='jaxws') and (@wsmap = 'suppress')" >
2368 <xsl:value-of select="concat(' // Skipping attribute ', $attrname, ' for it is suppressed&#10;')" />
2369 </xsl:when>
2370
2371 <xsl:otherwise>
2372 <!-- emit getter method -->
2373 <xsl:apply-templates select="desc" mode="attribute_get"/>
2374 <xsl:variable name="gettername">
2375 <xsl:call-template name="makeGetterName">
2376 <xsl:with-param name="attrname" select="$attrname" />
2377 </xsl:call-template>
2378 </xsl:variable>
2379 <xsl:variable name="gluetype">
2380 <xsl:call-template name="typeIdl2Glue">
2381 <xsl:with-param name="type" select="$attrtype" />
2382 <xsl:with-param name="safearray" select="@safearray" />
2383 </xsl:call-template>
2384 </xsl:variable>
2385 <xsl:variable name="backtype">
2386 <xsl:call-template name="typeIdl2Back">
2387 <xsl:with-param name="type" select="$attrtype" />
2388 <xsl:with-param name="safearray" select="@safearray" />
2389 </xsl:call-template>
2390 </xsl:variable>
2391 <xsl:variable name="wrapped">
2392 <xsl:call-template name="cookOutParam">
2393 <xsl:with-param name="value" select="'retVal'" />
2394 <xsl:with-param name="idltype" select="$attrtype" />
2395 <xsl:with-param name="safearray" select="@safearray" />
2396 </xsl:call-template>
2397 </xsl:variable>
2398 <xsl:value-of select="concat(' public ', $gluetype, ' ', $gettername, '()&#10;')" />
2399 <xsl:text> {&#10;</xsl:text>
2400
2401 <xsl:call-template name="startExcWrapper"/>
2402
2403 <!-- Actual getter implementation -->
2404 <xsl:call-template name="genGetterCall">
2405 <xsl:with-param name="ifname" select="$ifname" />
2406 <xsl:with-param name="gettername" select="$gettername" />
2407 <xsl:with-param name="backtype" select="$backtype" />
2408 <xsl:with-param name="retval" select="'retVal'" />
2409 </xsl:call-template>
2410
2411 <xsl:value-of select="concat(' return ', $wrapped, ';&#10;')" />
2412 <xsl:call-template name="endExcWrapper"/>
2413
2414 <xsl:text> }&#10;</xsl:text>
2415 <xsl:if test="not(@readonly = 'yes')">
2416 <!-- emit setter method -->
2417 <xsl:apply-templates select="desc" mode="attribute_set"/>
2418 <xsl:variable name="settername"><xsl:call-template name="makeSetterName"><xsl:with-param name="attrname" select="$attrname" /></xsl:call-template></xsl:variable>
2419 <xsl:variable name="unwrapped">
2420 <xsl:call-template name="cookInParam">
2421 <xsl:with-param name="ifname" select="$ifname" />
2422 <xsl:with-param name="value" select="'value'" />
2423 <xsl:with-param name="idltype" select="$attrtype" />
2424 <xsl:with-param name="safearray" select="@safearray" />
2425 </xsl:call-template>
2426 </xsl:variable>
2427 <xsl:value-of select="concat(' public void ', $settername, '(', $gluetype, ' value)&#10;')" />
2428 <xsl:text> {&#10;</xsl:text>
2429 <xsl:call-template name="startExcWrapper"/>
2430 <!-- Actual setter implementation -->
2431 <xsl:call-template name="genSetterCall">
2432 <xsl:with-param name="ifname" select="$ifname" />
2433 <xsl:with-param name="settername" select="$settername" />
2434 <xsl:with-param name="value" select="$unwrapped" />
2435 </xsl:call-template>
2436 <xsl:call-template name="endExcWrapper"/>
2437 <xsl:text> }&#10;</xsl:text>
2438 </xsl:if>
2439
2440 </xsl:otherwise>
2441 </xsl:choose>
2442
2443 </xsl:for-each>
2444
2445 <!-- emit queryInterface() *to* this class -->
2446 <xsl:call-template name="genQI">
2447 <xsl:with-param name="ifname" select="$ifname" />
2448 <xsl:with-param name="uuid" select="@uuid" />
2449 </xsl:call-template>
2450
2451 <!-- emit methods -->
2452 <xsl:for-each select="method">
2453 <xsl:call-template name="genMethod">
2454 <xsl:with-param name="ifname" select="$ifname" />
2455 <xsl:with-param name="methodname" select="@name" />
2456 </xsl:call-template>
2457 </xsl:for-each>
2458
2459</xsl:template>
2460
2461<xsl:template name="genIface">
2462 <xsl:param name="ifname" />
2463 <xsl:param name="filename" />
2464
2465 <xsl:variable name="wsmap" select="@wsmap" />
2466
2467 <xsl:call-template name="startFile">
2468 <xsl:with-param name="file" select="$filename" />
2469 <xsl:with-param name="package" select="$G_virtualBoxPackage" />
2470 </xsl:call-template>
2471
2472 <xsl:if test="$filelistonly=''">
2473 <xsl:text>import java.util.List;&#10;&#10;</xsl:text>
2474
2475 <xsl:apply-templates select="desc" mode="interface"/>
2476
2477 <xsl:choose>
2478 <xsl:when test="($wsmap='struct') and ($G_vboxGlueStyle='jaxws')">
2479 <xsl:value-of select="concat('public class ', $ifname, '&#10;')" />
2480 <xsl:text>{&#10;&#10;</xsl:text>
2481 <xsl:call-template name="genStructWrapperJaxws">
2482 <xsl:with-param name="ifname" select="$ifname" />
2483 </xsl:call-template>
2484 </xsl:when>
2485
2486 <xsl:otherwise>
2487 <xsl:variable name="extends" select="//interface[@name=$ifname]/@extends" />
2488 <xsl:choose>
2489 <xsl:when test="($extends = '$unknown') or ($extends = '$dispatched') or ($extends = '$errorinfo')">
2490 <xsl:value-of select="concat('public class ', $ifname, ' extends IUnknown&#10;')" />
2491 <xsl:text>{&#10;&#10;</xsl:text>
2492 </xsl:when>
2493 <xsl:when test="//interface[@name=$extends]">
2494 <xsl:value-of select="concat('public class ', $ifname, ' extends ', $extends, '&#10;')" />
2495 <xsl:text>{&#10;&#10;</xsl:text>
2496 </xsl:when>
2497 <xsl:otherwise>
2498 <xsl:call-template name="fatalError">
2499 <xsl:with-param name="msg" select="concat('Interface generation: interface &quot;', $ifname, '&quot; has invalid &quot;extends&quot; value ', $extends, '.')" />
2500 </xsl:call-template>
2501 </xsl:otherwise>
2502 </xsl:choose>
2503 <xsl:call-template name="genIfaceWrapper">
2504 <xsl:with-param name="ifname" select="$ifname" />
2505 </xsl:call-template>
2506 </xsl:otherwise>
2507 </xsl:choose>
2508
2509 <!-- end of class -->
2510 <xsl:text>}&#10;</xsl:text>
2511 </xsl:if>
2512
2513 <xsl:call-template name="endFile">
2514 <xsl:with-param name="file" select="$filename" />
2515 </xsl:call-template>
2516
2517</xsl:template>
2518
2519<xsl:template name="genCb">
2520 <xsl:param name="ifname" />
2521 <xsl:param name="filename" />
2522 <xsl:param name="filenameimpl" />
2523
2524 <xsl:call-template name="startFile">
2525 <xsl:with-param name="file" select="$filename" />
2526 <xsl:with-param name="package" select="$G_virtualBoxPackage" />
2527 </xsl:call-template>
2528
2529 <xsl:text>import java.util.List;&#10;</xsl:text>
2530
2531 <xsl:value-of select="concat('public interface ', $ifname, '&#10;')" />
2532 <xsl:text>{&#10;</xsl:text>
2533
2534 <!-- emit methods declarations-->
2535 <xsl:for-each select="method">
2536 <xsl:call-template name="genCbMethodDecl">
2537 <xsl:with-param name="ifname" select="$ifname" />
2538 <xsl:with-param name="methodname" select="@name" />
2539 </xsl:call-template>
2540 </xsl:for-each>
2541
2542 <xsl:text>}&#10;&#10;</xsl:text>
2543
2544 <xsl:call-template name="endFile">
2545 <xsl:with-param name="file" select="$filename" />
2546 </xsl:call-template>
2547
2548 <xsl:call-template name="startFile">
2549 <xsl:with-param name="file" select="$filenameimpl" />
2550 <xsl:with-param name="package" select="$G_virtualBoxPackage" />
2551 </xsl:call-template>
2552
2553 <xsl:text>import java.util.List;&#10;</xsl:text>
2554
2555 <xsl:variable name="backtype">
2556 <xsl:call-template name="typeIdl2Back">
2557 <xsl:with-param name="type" select="$ifname" />
2558 </xsl:call-template>
2559 </xsl:variable>
2560
2561 <!-- emit glue methods body -->
2562 <xsl:choose>
2563 <xsl:when test="$G_vboxGlueStyle='xpcom'">
2564 <xsl:value-of select="concat('class ', $ifname, 'Impl extends nsISupportsBase implements ', $backtype, '&#10;')" />
2565 <xsl:text>{&#10;</xsl:text>
2566 </xsl:when>
2567
2568 <xsl:when test="$G_vboxGlueStyle='mscom'">
2569 <xsl:value-of select="concat('public class ', $ifname, 'Impl&#10;')" />
2570 <xsl:text>{&#10;</xsl:text>
2571 </xsl:when>
2572 </xsl:choose>
2573
2574 <xsl:value-of select="concat(' ', $ifname, ' sink;&#10;')" />
2575
2576 <xsl:value-of select="concat(' ', $ifname, 'Impl(', $ifname, ' sink)&#10;')" />
2577 <xsl:text> {&#10;</xsl:text>
2578 <xsl:text> this.sink = sink;&#10;</xsl:text>
2579 <xsl:text> }&#10;</xsl:text>
2580
2581 <!-- emit methods implementations -->
2582 <xsl:for-each select="method">
2583 <xsl:call-template name="genCbMethodImpl">
2584 <xsl:with-param name="ifname" select="$ifname" />
2585 <xsl:with-param name="methodname" select="@name" />
2586 </xsl:call-template>
2587 </xsl:for-each>
2588
2589 <xsl:text>}&#10;&#10;</xsl:text>
2590
2591 <xsl:call-template name="endFile">
2592 <xsl:with-param name="file" select="$filenameimpl" />
2593 </xsl:call-template>
2594</xsl:template>
2595
2596<xsl:template name="emitHandwritten">
2597
2598 <xsl:call-template name="startFile">
2599 <xsl:with-param name="file" select="'Holder.java'" />
2600 <xsl:with-param name="package" select="$G_virtualBoxPackage" />
2601 </xsl:call-template>
2602
2603 <xsl:if test="$filelistonly=''">
2604 <xsl:text><![CDATA[
2605public class Holder<T>
2606{
2607 public T value;
2608
2609 public Holder()
2610 {
2611 }
2612 public Holder(T value)
2613 {
2614 this.value = value;
2615 }
2616}
2617]]></xsl:text>
2618 </xsl:if>
2619
2620 <xsl:call-template name="endFile">
2621 <xsl:with-param name="file" select="'Holder.java'" />
2622 </xsl:call-template>
2623</xsl:template>
2624
2625<xsl:template name="emitHandwrittenXpcom">
2626
2627 <xsl:call-template name="startFile">
2628 <xsl:with-param name="file" select="'IUnknown.java'" />
2629 <xsl:with-param name="package" select="$G_virtualBoxPackageCom" />
2630 </xsl:call-template>
2631
2632 <xsl:if test="$filelistonly=''">
2633 <xsl:text><![CDATA[
2634public class IUnknown
2635{
2636 private Object obj;
2637 public IUnknown(Object obj)
2638 {
2639 this.obj = obj;
2640 }
2641
2642 public Object getWrapped()
2643 {
2644 return this.obj;
2645 }
2646
2647 public void setWrapped(Object obj)
2648 {
2649 this.obj = obj;
2650 }
2651}
2652]]></xsl:text>
2653 </xsl:if>
2654
2655 <xsl:call-template name="endFile">
2656 <xsl:with-param name="file" select="'IUnknown.java'" />
2657 </xsl:call-template>
2658
2659 <xsl:call-template name="startFile">
2660 <xsl:with-param name="file" select="'Helper.java'" />
2661 <xsl:with-param name="package" select="$G_virtualBoxPackageCom" />
2662 </xsl:call-template>
2663
2664 <xsl:if test="$filelistonly=''">
2665 <xsl:text><![CDATA[
2666
2667import java.util.List;
2668import java.util.ArrayList;
2669import java.util.Collections;
2670import java.lang.reflect.Array;
2671import java.lang.reflect.Constructor;
2672import java.lang.reflect.InvocationTargetException;
2673
2674public class Helper
2675{
2676 public static List<Short> wrap(byte[] values)
2677 {
2678 if (values == null)
2679 return null;
2680
2681 List<Short> ret = new ArrayList<Short>(values.length);
2682 for (short v : values)
2683 {
2684 ret.add(v);
2685 }
2686 return ret;
2687 }
2688
2689 public static List<Integer> wrap(int[] values)
2690 {
2691 if (values == null)
2692 return null;
2693
2694 List<Integer> ret = new ArrayList<Integer>(values.length);
2695 for (int v : values)
2696 {
2697 ret.add(v);
2698 }
2699 return ret;
2700 }
2701
2702 public static List<Long> wrap(long[] values)
2703 {
2704 if (values == null)
2705 return null;
2706
2707 List<Long> ret = new ArrayList<Long>(values.length);
2708 for (long v : values)
2709 {
2710 ret.add(v);
2711 }
2712 return ret;
2713 }
2714
2715 public static List<Boolean> wrap(boolean[] values)
2716 {
2717 if (values == null)
2718 return null;
2719
2720 List<Boolean> ret = new ArrayList<Boolean>(values.length);
2721 for (boolean v: values)
2722 {
2723 ret.add(v);
2724 }
2725 return ret;
2726 }
2727
2728 public static List<String> wrap(String[] values)
2729 {
2730 if (values == null)
2731 return null;
2732
2733 List<String> ret = new ArrayList<String>(values.length);
2734 for (String v : values)
2735 {
2736 ret.add(v);
2737 }
2738 return ret;
2739 }
2740
2741 public static <T> List<T> wrap(Class<T> wrapperClass, T[] values)
2742 {
2743 if (values == null)
2744 return null;
2745
2746 List<T> ret = new ArrayList<T>(values.length);
2747 for (T v : values)
2748 {
2749 ret.add(v);
2750 }
2751 return ret;
2752 }
2753
2754 public static <T> List<T> wrapEnum(Class<T> wrapperClass, long values[])
2755 {
2756 try
2757 {
2758 if (values == null)
2759 return null;
2760 Constructor<T> c = wrapperClass.getConstructor(int.class);
2761 List<T> ret = new ArrayList<T>(values.length);
2762 for (long v : values)
2763 {
2764 ret.add(c.newInstance(v));
2765 }
2766 return ret;
2767 }
2768 catch (NoSuchMethodException e)
2769 {
2770 throw new AssertionError(e);
2771 }
2772 catch (InstantiationException e)
2773 {
2774 throw new AssertionError(e);
2775 }
2776 catch (IllegalAccessException e)
2777 {
2778 throw new AssertionError(e);
2779 }
2780 catch (InvocationTargetException e)
2781 {
2782 throw new AssertionError(e);
2783 }
2784 }
2785 public static short[] unwrapUShort(List<Short> values)
2786 {
2787 if (values == null)
2788 return null;
2789
2790 short[] ret = new short[values.size()];
2791 int i = 0;
2792 for (short l : values)
2793 {
2794 ret[i++] = l;
2795 }
2796 return ret;
2797 }
2798
2799 public static int[] unwrapInteger(List<Integer> values)
2800 {
2801 if (values == null)
2802 return null;
2803
2804 int[] ret = new int[values.size()];
2805 int i = 0;
2806 for (int l : values)
2807 {
2808 ret[i++] = l;
2809 }
2810 return ret;
2811 }
2812
2813 public static long[] unwrapULong(List<Long> values)
2814 {
2815 if (values == null)
2816 return null;
2817
2818 long[] ret = new long[values.size()];
2819 int i = 0;
2820 for (long l : values)
2821 {
2822 ret[i++] = l;
2823 }
2824 return ret;
2825 }
2826
2827 public static boolean[] unwrapBoolean(List<Boolean> values)
2828 {
2829 if (values == null)
2830 return null;
2831
2832 boolean[] ret = new boolean[values.size()];
2833 int i = 0;
2834 for (boolean l : values)
2835 {
2836 ret[i++] = l;
2837 }
2838 return ret;
2839 }
2840
2841 public static String[] unwrapStr(List<String> values)
2842 {
2843 if (values == null)
2844 return null;
2845
2846 String[] ret = new String[values.size()];
2847 int i = 0;
2848 for (String l : values)
2849 {
2850 ret[i++] = l;
2851 }
2852 return ret;
2853 }
2854
2855 public static <T extends Enum <T>> long[] unwrapEnum(Class<T> enumClass, List<T> values)
2856 {
2857 if (values == null)
2858 return null;
2859
2860 long result[] = new long[values.size()];
2861 try
2862 {
2863 java.lang.reflect.Method valueM = enumClass.getMethod("value");
2864 int i = 0;
2865 for (T v : values)
2866 {
2867 result[i++] = (Integer)valueM.invoke(v);
2868 }
2869 return result;
2870 }
2871 catch (NoSuchMethodException e)
2872 {
2873 throw new AssertionError(e);
2874 }
2875 catch(SecurityException e)
2876 {
2877 throw new AssertionError(e);
2878 }
2879 catch (IllegalAccessException e)
2880 {
2881 throw new AssertionError(e);
2882 }
2883 catch (IllegalArgumentException e)
2884 {
2885 throw new AssertionError(e);
2886 }
2887 catch (InvocationTargetException e)
2888 {
2889 throw new AssertionError(e);
2890 }
2891 }
2892
2893 public static <T1, T2> List<T1> wrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, T2[] values)
2894 {
2895 try
2896 {
2897 if (values == null)
2898 return null;
2899
2900 Constructor<T1> c = wrapperClass1.getConstructor(wrapperClass2);
2901 List<T1> ret = new ArrayList<T1>(values.length);
2902 for (T2 v : values)
2903 {
2904 ret.add(c.newInstance(v));
2905 }
2906 return ret;
2907 }
2908 catch (NoSuchMethodException e)
2909 {
2910 throw new AssertionError(e);
2911 }
2912 catch (InstantiationException e)
2913 {
2914 throw new AssertionError(e);
2915 }
2916 catch (IllegalAccessException e)
2917 {
2918 throw new AssertionError(e);
2919 }
2920 catch (InvocationTargetException e)
2921 {
2922 throw new AssertionError(e);
2923 }
2924 }
2925
2926 @SuppressWarnings( "unchecked")
2927 public static <T> T[] unwrap(Class<T> wrapperClass, List<T> values)
2928 {
2929 if (values == null)
2930 return null;
2931 if (values.size() == 0)
2932 return null;
2933 return (T[])values.toArray((T[])Array.newInstance(wrapperClass, values.size()));
2934 }
2935
2936 @SuppressWarnings( "unchecked" )
2937 public static <T> T queryInterface(Object obj, String uuid, Class<T> iface)
2938 {
2939 return (T)queryInterface(obj, uuid);
2940 }
2941
2942 public static Object queryInterface(Object obj, String uuid)
2943 {
2944 try
2945 {
2946 /* Kind of ugly, but does the job of casting */
2947 org.mozilla.xpcom.Mozilla moz = org.mozilla.xpcom.Mozilla.getInstance();
2948 long xpobj = moz.wrapJavaObject(obj, uuid);
2949 return moz.wrapXPCOMObject(xpobj, uuid);
2950 }
2951 catch (Exception e)
2952 {
2953 return null;
2954 }
2955 }
2956
2957 @SuppressWarnings("unchecked")
2958 public static <T1 extends IUnknown, T2> T2[] unwrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, List<T1> values)
2959 {
2960 if (values == null)
2961 return null;
2962
2963 T2 ret[] = (T2[])Array.newInstance(wrapperClass2, values.size());
2964 int i = 0;
2965 for (T1 obj : values)
2966 {
2967 ret[i++] = (T2)obj.getWrapped();
2968 }
2969 return ret;
2970 }
2971}
2972]]></xsl:text>
2973 </xsl:if>
2974
2975 <xsl:call-template name="endFile">
2976 <xsl:with-param name="file" select="'Helper.java'" />
2977 </xsl:call-template>
2978
2979 <xsl:call-template name="startFile">
2980 <xsl:with-param name="file" select="'VBoxException.java'" />
2981 <xsl:with-param name="package" select="$G_virtualBoxPackage" />
2982 </xsl:call-template>
2983
2984 <xsl:if test="$filelistonly=''">
2985 <xsl:text>
2986import org.mozilla.xpcom.*;
2987
2988public class VBoxException extends RuntimeException
2989{
2990 private int resultCode;
2991 private IVirtualBoxErrorInfo errorInfo;
2992
2993 public VBoxException(String message)
2994 {
2995 super(message);
2996 resultCode = -1;
2997 errorInfo = null;
2998 }
2999
3000 public VBoxException(String message, Throwable cause)
3001 {
3002 super(message, cause);
3003 if (cause instanceof org.mozilla.xpcom.XPCOMException)
3004 {
3005 resultCode = (int)((org.mozilla.xpcom.XPCOMException)cause).errorcode;
3006 try
3007 {
3008 Mozilla mozilla = Mozilla.getInstance();
3009 nsIServiceManager sm = mozilla.getServiceManager();
3010 nsIExceptionService es = (nsIExceptionService)sm.getServiceByContractID("@mozilla.org/exceptionservice;1", nsIExceptionService.NS_IEXCEPTIONSERVICE_IID);
3011 nsIExceptionManager em = es.getCurrentExceptionManager();
3012 nsIException ex = em.getCurrentException();
3013 errorInfo = new IVirtualBoxErrorInfo((org.mozilla.interfaces.IVirtualBoxErrorInfo)ex.queryInterface(org.mozilla.interfaces.IVirtualBoxErrorInfo.IVIRTUALBOXERRORINFO_IID));
3014 }
3015 catch (NullPointerException e)
3016 {
3017 e.printStackTrace();
3018 // nothing we can do
3019 errorInfo = null;
3020 }
3021 }
3022 else
3023 resultCode = -1;
3024 }
3025
3026 public int getResultCode()
3027 {
3028 return resultCode;
3029 }
3030
3031 public IVirtualBoxErrorInfo getVirtualBoxErrorInfo()
3032 {
3033 return errorInfo;
3034 }
3035}
3036</xsl:text>
3037 </xsl:if>
3038
3039 <xsl:call-template name="endFile">
3040 <xsl:with-param name="file" select="'VBoxException.java'" />
3041 </xsl:call-template>
3042
3043 <xsl:call-template name="startFile">
3044 <xsl:with-param name="file" select="'VirtualBoxManager.java'" />
3045 <xsl:with-param name="package" select="$G_virtualBoxPackage" />
3046 </xsl:call-template>
3047
3048 <xsl:if test="$filelistonly=''">
3049 <xsl:text><![CDATA[
3050
3051import java.io.File;
3052
3053import org.mozilla.xpcom.*;
3054import org.mozilla.interfaces.*;
3055
3056public class VirtualBoxManager
3057{
3058 private Mozilla mozilla;
3059 private IVirtualBox vbox;
3060 private nsIComponentManager componentManager;
3061
3062 private VirtualBoxManager(Mozilla mozilla)
3063 {
3064 this.mozilla = mozilla;
3065 this.componentManager = mozilla.getComponentManager();
3066 this.vbox = new IVirtualBox((org.mozilla.interfaces.IVirtualBox) this.componentManager
3067 .createInstanceByContractID("@virtualbox.org/VirtualBox;1",
3068 null,
3069 org.mozilla.interfaces.IVirtualBox.IVIRTUALBOX_IID));
3070 }
3071
3072 public void connect(String url, String username, String passwd)
3073 {
3074 throw new VBoxException("Connect doesn't make sense for local bindings");
3075 }
3076
3077 public void disconnect()
3078 {
3079 throw new VBoxException("Disconnect doesn't make sense for local bindings");
3080 }
3081
3082 public static void initPerThread()
3083 {
3084 }
3085
3086 public static void deinitPerThread()
3087 {
3088 }
3089
3090 public IVirtualBox getVBox()
3091 {
3092 return this.vbox;
3093 }
3094
3095 public ISession getSessionObject()
3096 {
3097 return new ISession((org.mozilla.interfaces.ISession) componentManager
3098 .createInstanceByContractID("@virtualbox.org/Session;1", null,
3099 org.mozilla.interfaces.ISession.ISESSION_IID));
3100 }
3101
3102 public ISession openMachineSession(IMachine m) throws Exception
3103 {
3104 ISession s = getSessionObject();
3105 m.lockMachine(s, LockType.Shared);
3106 return s;
3107 }
3108
3109 public void closeMachineSession(ISession s)
3110 {
3111 if (s != null)
3112 s.unlockMachine();
3113 }
3114
3115 private static boolean hasInstance = false;
3116 private static boolean isMozillaInited = false;
3117
3118 public static synchronized VirtualBoxManager createInstance(String home)
3119 {
3120 if (hasInstance)
3121 throw new VBoxException("only one instance of VirtualBoxManager at a time allowed");
3122 if (home == null || home.equals(""))
3123 home = System.getProperty("vbox.home");
3124
3125 if (home == null)
3126 throw new VBoxException("vbox.home Java property must be defined to use XPCOM bridge");
3127
3128 File grePath = new File(home);
3129
3130 Mozilla mozilla = Mozilla.getInstance();
3131 if (!isMozillaInited)
3132 {
3133 mozilla.initialize(grePath);
3134 try
3135 {
3136 mozilla.initXPCOM(grePath, null);
3137 isMozillaInited = true;
3138 }
3139 catch (Exception e)
3140 {
3141 e.printStackTrace();
3142 return null;
3143 }
3144 }
3145
3146 hasInstance = true;
3147
3148 return new VirtualBoxManager(mozilla);
3149 }
3150
3151 public IEventListener createListener(Object sink)
3152 {
3153 return new IEventListener(new EventListenerImpl(sink));
3154 }
3155
3156 public void cleanup()
3157 {
3158 deinitPerThread();
3159 // cleanup, we don't do that, as XPCOM bridge doesn't cleanly
3160 // shuts down, so we prefer to avoid native shutdown
3161 // mozilla.shutdownXPCOM(null);
3162 mozilla = null;
3163 hasInstance = false;
3164 }
3165
3166 public void waitForEvents(long tmo)
3167 {
3168 mozilla.waitForEvents(tmo);
3169 }
3170}
3171]]></xsl:text>
3172 </xsl:if>
3173
3174 <xsl:call-template name="endFile">
3175 <xsl:with-param name="file" select="'VirtualBoxManager.java'" />
3176 </xsl:call-template>
3177
3178 <xsl:call-template name="startFile">
3179 <xsl:with-param name="file" select="'EventListenerImpl.java'" />
3180 <xsl:with-param name="package" select="$G_virtualBoxPackage" />
3181 </xsl:call-template>
3182
3183 <xsl:if test="$filelistonly=''">
3184 <xsl:text><![CDATA[
3185import org.mozilla.interfaces.*;
3186
3187public class EventListenerImpl extends nsISupportsBase implements org.mozilla.interfaces.IEventListener
3188{
3189 private Object obj;
3190 private java.lang.reflect.Method handleEvent;
3191 EventListenerImpl(Object obj)
3192 {
3193 this.obj = obj;
3194 try
3195 {
3196 this.handleEvent = obj.getClass().getMethod("handleEvent", IEvent.class);
3197 }
3198 catch (Exception e)
3199 {
3200 e.printStackTrace();
3201 }
3202 }
3203 public void handleEvent(org.mozilla.interfaces.IEvent ev)
3204 {
3205 try
3206 {
3207 if (obj != null && handleEvent != null)
3208 handleEvent.invoke(obj, ev != null ? new IEvent(ev) : null);
3209 }
3210 catch (Exception e)
3211 {
3212 e.printStackTrace();
3213 }
3214 }
3215}]]></xsl:text>
3216 </xsl:if>
3217
3218 <xsl:call-template name="endFile">
3219 <xsl:with-param name="file" select="'EventListenerImpl.java'" />
3220 </xsl:call-template>
3221
3222 <xsl:call-template name="startFile">
3223 <xsl:with-param name="file" select="'VBoxObjectBase.java'" />
3224 <xsl:with-param name="package" select="$G_virtualBoxPackage" />
3225 </xsl:call-template>
3226
3227 <xsl:if test="$filelistonly=''">
3228 <xsl:text><![CDATA[
3229abstract class nsISupportsBase implements org.mozilla.interfaces.nsISupports
3230{
3231 public org.mozilla.interfaces.nsISupports queryInterface(String iid)
3232 {
3233 return org.mozilla.xpcom.Mozilla.queryInterface(this, iid);
3234 }
3235}
3236
3237]]></xsl:text>
3238 </xsl:if>
3239
3240 <xsl:call-template name="endFile">
3241 <xsl:with-param name="file" select="'VBoxObjectBase.java'" />
3242 </xsl:call-template>
3243</xsl:template>
3244
3245
3246<xsl:template name="emitHandwrittenMscom">
3247
3248 <xsl:call-template name="startFile">
3249 <xsl:with-param name="file" select="'IUnknown.java'" />
3250 <xsl:with-param name="package" select="$G_virtualBoxPackageCom" />
3251 </xsl:call-template>
3252
3253 <xsl:if test="$filelistonly=''">
3254 <xsl:text><![CDATA[
3255public class IUnknown
3256{
3257 private Object obj;
3258 public IUnknown(Object obj)
3259 {
3260 this.obj = obj;
3261 }
3262
3263 public Object getWrapped()
3264 {
3265 return this.obj;
3266 }
3267
3268 public void setWrapped(Object obj)
3269 {
3270 this.obj = obj;
3271 }
3272}
3273]]></xsl:text>
3274 </xsl:if>
3275
3276 <xsl:call-template name="endFile">
3277 <xsl:with-param name="file" select="'IUnknown.java'" />
3278 </xsl:call-template>
3279
3280 <xsl:call-template name="startFile">
3281 <xsl:with-param name="file" select="'Helper.java'" />
3282 <xsl:with-param name="package" select="$G_virtualBoxPackageCom" />
3283 </xsl:call-template>
3284
3285 <xsl:if test="$filelistonly=''">
3286 <xsl:text><![CDATA[
3287
3288import java.util.List;
3289import java.util.ArrayList;
3290import java.util.Collections;
3291import java.lang.reflect.Array;
3292import java.lang.reflect.Constructor;
3293import java.lang.reflect.InvocationTargetException;
3294import com.jacob.com.*;
3295
3296public class Helper
3297{
3298 public static List<Short> wrap(short[] values)
3299 {
3300 if (values == null)
3301 return null;
3302 if (values.length == 0)
3303 return Collections.emptyList();
3304
3305 List<Short> ret = new ArrayList<Short>(values.length);
3306 for (short v : values)
3307 {
3308 ret.add(v);
3309 }
3310 return ret;
3311 }
3312
3313 public static List<Integer> wrap(int[] values)
3314 {
3315 if (values == null)
3316 return null;
3317 if (values.length == 0)
3318 return Collections.emptyList();
3319
3320 List<Integer> ret = new ArrayList<Integer>(values.length);
3321 for (int v : values)
3322 {
3323 ret.add(v);
3324 }
3325 return ret;
3326 }
3327
3328 public static List<Long> wrap(long[] values)
3329 {
3330 if (values == null)
3331 return null;
3332 if (values.length == 0)
3333 return Collections.emptyList();
3334
3335 List<Long> ret = new ArrayList<Long>(values.length);
3336 for (long v : values)
3337 {
3338 ret.add(v);
3339 }
3340 return ret;
3341 }
3342
3343 public static List<String> wrap(String[] values)
3344 {
3345 if (values == null)
3346 return null;
3347 if (values.length == 0)
3348 return Collections.emptyList();
3349
3350 List<String> ret = new ArrayList<String>(values.length);
3351 for (String v : values)
3352 {
3353 ret.add(v);
3354 }
3355 return ret;
3356 }
3357
3358 public static <T> T wrapDispatch(Class<T> wrapperClass, Dispatch d)
3359 {
3360 try
3361 {
3362 if (d == null || d.m_pDispatch == 0)
3363 return null;
3364 Constructor<T> c = wrapperClass.getConstructor(Dispatch.class);
3365 return (T)c.newInstance(d);
3366 }
3367 catch (NoSuchMethodException e)
3368 {
3369 throw new AssertionError(e);
3370 }
3371 catch (InstantiationException e)
3372 {
3373 throw new AssertionError(e);
3374 }
3375 catch (IllegalAccessException e)
3376 {
3377 throw new AssertionError(e);
3378 }
3379 catch (InvocationTargetException e)
3380 {
3381 throw new AssertionError(e);
3382 }
3383 }
3384
3385 @SuppressWarnings("unchecked")
3386 public static <T> Object wrapVariant(Class<T> wrapperClass, Variant v)
3387 {
3388 if (v == null)
3389 return null;
3390
3391 short vt = v.getvt();
3392 switch (vt)
3393 {
3394 case Variant.VariantNull:
3395 return null;
3396 case Variant.VariantBoolean:
3397 return v.getBoolean();
3398 case Variant.VariantByte:
3399 return v.getByte();
3400 case Variant.VariantShort:
3401 return v.getShort();
3402 case Variant.VariantInt:
3403 return v.getInt();
3404 case Variant.VariantLongInt:
3405 return v.getLong();
3406 case Variant.VariantString:
3407 return v.getString();
3408 case Variant.VariantDispatch:
3409 return wrapDispatch(wrapperClass, v.getDispatch());
3410 default:
3411 throw new VBoxException("unhandled variant type " + vt);
3412 }
3413 }
3414
3415 public static byte[] wrapBytes(SafeArray sa)
3416 {
3417 if (sa == null)
3418 return null;
3419
3420 int saLen = sa.getUBound() - sa.getLBound() + 1;
3421
3422 byte[] ret = new byte[saLen];
3423 int j = 0;
3424 for (int i = sa.getLBound(); i <= sa.getUBound(); i++)
3425 {
3426 Variant v = sa.getVariant(i);
3427 // come up with more effective approach!!!
3428 ret[j++] = v.getByte();
3429 }
3430 return ret;
3431 }
3432
3433 @SuppressWarnings("unchecked")
3434 public static <T> List<T> wrap(Class<T> wrapperClass, SafeArray sa)
3435 {
3436 if (sa == null)
3437 return null;
3438
3439 int saLen = sa.getUBound() - sa.getLBound() + 1;
3440 if (saLen == 0)
3441 return Collections.emptyList();
3442
3443 List<T> ret = new ArrayList<T>(saLen);
3444 for (int i = sa.getLBound(); i <= sa.getUBound(); i++)
3445 {
3446 Variant v = sa.getVariant(i);
3447 ret.add((T)wrapVariant(wrapperClass, v));
3448 }
3449 return ret;
3450 }
3451
3452 public static <T> List<T> wrapEnum(Class<T> wrapperClass, SafeArray sa)
3453 {
3454 try
3455 {
3456 if (sa == null)
3457 return null;
3458
3459 int saLen = sa.getUBound() - sa.getLBound() + 1;
3460 if (saLen == 0)
3461 return Collections.emptyList();
3462 List<T> ret = new ArrayList<T>(saLen);
3463 Constructor<T> c = wrapperClass.getConstructor(int.class);
3464 for (int i = sa.getLBound(); i <= sa.getUBound(); i++)
3465 {
3466 Variant v = sa.getVariant(i);
3467 ret.add(c.newInstance(v.getInt()));
3468 }
3469 return ret;
3470 }
3471 catch (NoSuchMethodException e)
3472 {
3473 throw new AssertionError(e);
3474 }
3475 catch (InstantiationException e)
3476 {
3477 throw new AssertionError(e);
3478 }
3479 catch (IllegalAccessException e)
3480 {
3481 throw new AssertionError(e);
3482 }
3483 catch (InvocationTargetException e)
3484 {
3485 throw new AssertionError(e);
3486 }
3487 }
3488
3489 public static SafeArray unwrapInt(List<Integer> values)
3490 {
3491 if (values == null)
3492 return null;
3493 SafeArray ret = new SafeArray(Variant.VariantInt, values.size());
3494 int i = 0;
3495 for (int l : values)
3496 {
3497 ret.setInt(i++, l);
3498 }
3499 return ret;
3500 }
3501
3502 public static SafeArray unwrapLong(List<Long> values)
3503 {
3504 if (values == null)
3505 return null;
3506 SafeArray ret = new SafeArray(Variant.VariantLongInt, values.size());
3507 int i = 0;
3508 for (long l : values)
3509 {
3510 ret.setLong(i++, l);
3511 }
3512 return ret;
3513 }
3514
3515 public static SafeArray unwrapBool(List<Boolean> values)
3516 {
3517 if (values == null)
3518 return null;
3519
3520 SafeArray result = new SafeArray(Variant.VariantBoolean, values.size());
3521 int i = 0;
3522 for (boolean l : values)
3523 {
3524 result.setBoolean(i++, l);
3525 }
3526 return result;
3527 }
3528
3529
3530 public static SafeArray unwrapBytes(byte[] values)
3531 {
3532 if (values == null)
3533 return null;
3534
3535 SafeArray result = new SafeArray(Variant.VariantByte, values.length);
3536 int i = 0;
3537 for (byte l : values)
3538 {
3539 result.setByte(i++, l);
3540 }
3541 return result;
3542 }
3543
3544
3545 public static <T extends Enum <T>> SafeArray unwrapEnum(Class<T> enumClass, List<T> values)
3546 {
3547 if (values == null)
3548 return null;
3549
3550 SafeArray result = new SafeArray(Variant.VariantInt, values.size());
3551 try
3552 {
3553 java.lang.reflect.Method valueM = enumClass.getMethod("value");
3554 int i = 0;
3555 for (T v : values)
3556 {
3557 result.setInt(i++, (Integer)valueM.invoke(v));
3558 }
3559 return result;
3560 }
3561 catch (NoSuchMethodException e)
3562 {
3563 throw new AssertionError(e);
3564 }
3565 catch(SecurityException e)
3566 {
3567 throw new AssertionError(e);
3568 }
3569 catch (IllegalAccessException e)
3570 {
3571 throw new AssertionError(e);
3572 }
3573 catch (IllegalArgumentException e)
3574 {
3575 throw new AssertionError(e);
3576 }
3577 catch (InvocationTargetException e)
3578 {
3579 throw new AssertionError(e);
3580 }
3581 }
3582 public static SafeArray unwrapString(List<String> values)
3583 {
3584 if (values == null)
3585 return null;
3586 SafeArray result = new SafeArray(Variant.VariantString, values.size());
3587 int i = 0;
3588 for (String l : values)
3589 {
3590 result.setString(i++, l);
3591 }
3592 return result;
3593 }
3594
3595 public static <T1, T2> List<T1> wrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, T2[] values)
3596 {
3597 try
3598 {
3599 if (values == null)
3600 return null;
3601 if (values.length == 0)
3602 return Collections.emptyList();
3603
3604 Constructor<T1> c = wrapperClass1.getConstructor(wrapperClass2);
3605 List<T1> ret = new ArrayList<T1>(values.length);
3606 for (T2 v : values)
3607 {
3608 ret.add(c.newInstance(v));
3609 }
3610 return ret;
3611 }
3612 catch (NoSuchMethodException e)
3613 {
3614 throw new AssertionError(e);
3615 }
3616 catch (InstantiationException e)
3617 {
3618 throw new AssertionError(e);
3619 }
3620 catch (IllegalAccessException e)
3621 {
3622 throw new AssertionError(e);
3623 }
3624 catch (InvocationTargetException e)
3625 {
3626 throw new AssertionError(e);
3627 }
3628 }
3629
3630 @SuppressWarnings("unchecked")
3631 public static <T> T[] unwrap(Class<T> wrapperClass, List<T> values)
3632 {
3633 if (values == null)
3634 return null;
3635 return (T[])values.toArray((T[])Array.newInstance(wrapperClass, values.size()));
3636 }
3637
3638 @SuppressWarnings("unchecked")
3639 public static <T1 extends IUnknown, T2> T2[] unwrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, List<T1> values)
3640 {
3641 if (values == null)
3642 return null;
3643
3644 T2 ret[] = (T2[])Array.newInstance(wrapperClass2, values.size());
3645 int i = 0;
3646 for (T1 obj : values)
3647 {
3648 ret[i++] = (T2)obj.getWrapped();
3649 }
3650 return ret;
3651 }
3652
3653 /* We have very long invoke lists sometimes */
3654 public static Variant invoke(Dispatch d, String method, Object ... args)
3655 {
3656 return Dispatch.callN(d, method, args);
3657 }
3658}
3659]]></xsl:text>
3660 </xsl:if>
3661
3662 <xsl:call-template name="endFile">
3663 <xsl:with-param name="file" select="'Helper.java'" />
3664 </xsl:call-template>
3665
3666 <xsl:call-template name="startFile">
3667 <xsl:with-param name="file" select="'VBoxException.java'" />
3668 <xsl:with-param name="package" select="$G_virtualBoxPackage" />
3669 </xsl:call-template>
3670
3671 <xsl:if test="$filelistonly=''">
3672 <xsl:text>
3673
3674public class VBoxException extends RuntimeException
3675{
3676 private int resultCode;
3677 private IVirtualBoxErrorInfo errorInfo;
3678
3679 public VBoxException(String message)
3680 {
3681 super(message);
3682 resultCode = -1;
3683 errorInfo = null;
3684 }
3685
3686 public VBoxException(String message, Throwable cause)
3687 {
3688 super(message, cause);
3689 if (cause instanceof com.jacob.com.ComException)
3690 {
3691 resultCode = ((com.jacob.com.ComException)cause).getHResult();
3692 // JACOB doesn't support calling GetErrorInfo, which
3693 // means there is no way of getting an IErrorInfo reference,
3694 // and that means no way of getting to IVirtualBoxErrorInfo.
3695 errorInfo = null;
3696 }
3697 else
3698 resultCode = -1;
3699 }
3700
3701 public int getResultCode()
3702 {
3703 return resultCode;
3704 }
3705
3706 public IVirtualBoxErrorInfo getVirtualBoxErrorInfo()
3707 {
3708 return errorInfo;
3709 }
3710}
3711</xsl:text>
3712 </xsl:if>
3713
3714 <xsl:call-template name="endFile">
3715 <xsl:with-param name="file" select="'VBoxException.java'" />
3716 </xsl:call-template>
3717
3718
3719 <xsl:call-template name="startFile">
3720 <xsl:with-param name="file" select="'VirtualBoxManager.java'" />
3721 <xsl:with-param name="package" select="$G_virtualBoxPackage" />
3722 </xsl:call-template>
3723
3724 <xsl:if test="$filelistonly=''">
3725 <xsl:text><![CDATA[
3726
3727import com.jacob.activeX.ActiveXComponent;
3728import com.jacob.com.ComThread;
3729import com.jacob.com.Dispatch;
3730import com.jacob.com.Variant;
3731import com.jacob.com.SafeArray;
3732import com.jacob.com.DispatchEvents;
3733
3734public class VirtualBoxManager
3735{
3736 private IVirtualBox vbox;
3737
3738 private VirtualBoxManager()
3739 {
3740 initPerThread();
3741 vbox = new IVirtualBox(new ActiveXComponent("VirtualBox.VirtualBox"));
3742 }
3743
3744 public static void initPerThread()
3745 {
3746 ComThread.InitMTA();
3747 }
3748
3749 public static void deinitPerThread()
3750 {
3751 ComThread.Release();
3752 }
3753
3754 public void connect(String url, String username, String passwd)
3755 {
3756 throw new VBoxException("Connect doesn't make sense for local bindings");
3757 }
3758
3759 public void disconnect()
3760 {
3761 throw new VBoxException("Disconnect doesn't make sense for local bindings");
3762 }
3763
3764 public IVirtualBox getVBox()
3765 {
3766 return this.vbox;
3767 }
3768
3769 public ISession getSessionObject()
3770 {
3771 return new ISession(new ActiveXComponent("VirtualBox.Session"));
3772 }
3773
3774 public ISession openMachineSession(IMachine m)
3775 {
3776 ISession s = getSessionObject();
3777 m.lockMachine(s, LockType.Shared);
3778 return s;
3779 }
3780
3781 public void closeMachineSession(ISession s)
3782 {
3783 if (s != null)
3784 s.unlockMachine();
3785 }
3786
3787 private static boolean hasInstance = false;
3788
3789 public static synchronized VirtualBoxManager createInstance(String home)
3790 {
3791 if (hasInstance)
3792 throw new VBoxException("only one instance of VirtualBoxManager at a time allowed");
3793
3794 hasInstance = true;
3795 return new VirtualBoxManager();
3796 }
3797
3798 public void cleanup()
3799 {
3800 deinitPerThread();
3801 hasInstance = false;
3802 }
3803
3804 public void waitForEvents(long tmo)
3805 {
3806 // what to do here?
3807 try
3808 {
3809 Thread.sleep(tmo);
3810 }
3811 catch (InterruptedException ie)
3812 {
3813 }
3814 }
3815}
3816]]></xsl:text>
3817 </xsl:if>
3818
3819 <xsl:call-template name="endFile">
3820 <xsl:with-param name="file" select="'VirtualBoxManager.java'" />
3821 </xsl:call-template>
3822</xsl:template>
3823
3824<xsl:template name="emitHandwrittenJaxws">
3825
3826 <xsl:call-template name="startFile">
3827 <xsl:with-param name="file" select="'IUnknown.java'" />
3828 <xsl:with-param name="package" select="$G_virtualBoxPackage" />
3829 </xsl:call-template>
3830
3831 <xsl:if test="$filelistonly=''">
3832 <xsl:text><![CDATA[
3833public class IUnknown
3834{
3835 protected String obj;
3836 protected final VboxPortType port;
3837
3838 public IUnknown(String obj, VboxPortType port)
3839 {
3840 this.obj = obj;
3841 this.port = port;
3842 }
3843
3844 public final String getWrapped()
3845 {
3846 return this.obj;
3847 }
3848
3849 public final VboxPortType getRemoteWSPort()
3850 {
3851 return this.port;
3852 }
3853
3854 public synchronized void releaseRemote() throws WebServiceException
3855 {
3856 if (obj == null)
3857 return;
3858
3859 try
3860 {
3861 this.port.iManagedObjectRefRelease(obj);
3862 this.obj = null;
3863 }
3864 catch (InvalidObjectFaultMsg e)
3865 {
3866 throw new WebServiceException(e);
3867 }
3868 catch (RuntimeFaultMsg e)
3869 {
3870 throw new WebServiceException(e);
3871 }
3872 }
3873}
3874]]></xsl:text>
3875 </xsl:if>
3876
3877 <xsl:call-template name="endFile">
3878 <xsl:with-param name="file" select="'IUnknown.java'" />
3879 </xsl:call-template>
3880
3881 <xsl:call-template name="startFile">
3882 <xsl:with-param name="file" select="'Helper.java'" />
3883 <xsl:with-param name="package" select="$G_virtualBoxPackage" />
3884 </xsl:call-template>
3885
3886 <xsl:if test="$filelistonly=''">
3887 <xsl:text><![CDATA[
3888
3889import java.util.List;
3890import java.util.ArrayList;
3891import java.util.Collections;
3892import java.lang.reflect.Array;
3893import java.lang.reflect.Constructor;
3894import java.lang.reflect.InvocationTargetException;
3895import java.math.BigInteger;
3896
3897public class Helper
3898{
3899 public static <T> List<T> wrap(Class<T> wrapperClass, VboxPortType pt, List<String> values)
3900 {
3901 try
3902 {
3903 if (values == null)
3904 return null;
3905
3906 Constructor<T> c = wrapperClass.getConstructor(String.class, VboxPortType.class);
3907 List<T> ret = new ArrayList<T>(values.size());
3908 for (String v : values)
3909 {
3910 ret.add(c.newInstance(v, pt));
3911 }
3912 return ret;
3913 }
3914 catch (NoSuchMethodException e)
3915 {
3916 throw new AssertionError(e);
3917 }
3918 catch (InstantiationException e)
3919 {
3920 throw new AssertionError(e);
3921 }
3922 catch (IllegalAccessException e)
3923 {
3924 throw new AssertionError(e);
3925 }
3926 catch (InvocationTargetException e)
3927 {
3928 throw new AssertionError(e);
3929 }
3930 }
3931
3932 public static <T1, T2> List<T1> wrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, VboxPortType pt, List<T2> values)
3933 {
3934 try
3935 {
3936 if (values == null)
3937 return null;
3938
3939 Constructor<T1> c = wrapperClass1.getConstructor(wrapperClass2, VboxPortType.class);
3940 List<T1> ret = new ArrayList<T1>(values.size());
3941 for (T2 v : values)
3942 {
3943 ret.add(c.newInstance(v, pt));
3944 }
3945 return ret;
3946 }
3947 catch (NoSuchMethodException e)
3948 {
3949 throw new AssertionError(e);
3950 }
3951 catch (InstantiationException e)
3952 {
3953 throw new AssertionError(e);
3954 }
3955 catch (IllegalAccessException e)
3956 {
3957 throw new AssertionError(e);
3958 }
3959 catch (InvocationTargetException e)
3960 {
3961 throw new AssertionError(e);
3962 }
3963 }
3964
3965 public static <T extends IUnknown> List<String> unwrap(List<T> values)
3966 {
3967 if (values == null)
3968 return null;
3969
3970 List<String> ret = new ArrayList<String>(values.size());
3971 for (T obj : values)
3972 {
3973 ret.add(obj.getWrapped());
3974 }
3975 return ret;
3976 }
3977
3978 @SuppressWarnings("unchecked" )
3979 public static <T1 extends Enum <T1>, T2 extends Enum <T2>> List<T2> convertEnums(Class<T1> fromClass,
3980 Class<T2> toClass,
3981 List<T1> values)
3982 {
3983 try
3984 {
3985 if (values == null)
3986 return null;
3987 java.lang.reflect.Method fromValue = toClass.getMethod("fromValue", String.class);
3988 List<T2> ret = new ArrayList<T2>(values.size());
3989 for (T1 v : values)
3990 {
3991 // static method is called with null this
3992 ret.add((T2)fromValue.invoke(null, v.name()));
3993 }
3994 return ret;
3995 }
3996 catch (NoSuchMethodException e)
3997 {
3998 throw new AssertionError(e);
3999 }
4000 catch (IllegalAccessException e)
4001 {
4002 throw new AssertionError(e);
4003 }
4004 catch (InvocationTargetException e)
4005 {
4006 throw new AssertionError(e);
4007 }
4008 }
4009
4010 /* Pretty naive Base64 encoder/decoder. */
4011 private static final char[] valToChar = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".toCharArray();
4012 private static final int[] charToVal = new int[256];
4013
4014 /* Initialize recoding alphabet. */
4015 static
4016 {
4017 for (int i = 0; i < charToVal.length; i++)
4018 charToVal[i] = -1;
4019
4020 for (int i = 0; i < valToChar.length; i++)
4021 charToVal[valToChar[i]] = i;
4022
4023 charToVal['='] = 0;
4024 }
4025
4026 public static String encodeBase64(byte[] data)
4027 {
4028 if (data == null)
4029 return null;
4030
4031 if (data.length == 0)
4032 return "";
4033
4034 int fullTriplets = data.length / 3;
4035 int resultLen = ((data.length - 1) / 3 + 1) * 4;
4036 char[] result = new char[resultLen];
4037 int dataIndex = 0, stringIndex = 0;
4038
4039 for (int i = 0; i < fullTriplets; i++)
4040 {
4041 int ch1 = data[dataIndex++] & 0xff;
4042 result[stringIndex++] = valToChar[ch1 >> 2];
4043 int ch2 = data[dataIndex++] & 0xff;
4044 result[stringIndex++] = valToChar[((ch1 << 4) & 0x3f) | (ch2 >> 4)];
4045 int ch3 = data[dataIndex++] & 0xff;
4046 result[stringIndex++] = valToChar[((ch2 << 2) & 0x3f) | (ch3 >> 6)];
4047 result[stringIndex++] = valToChar[ch3 & 0x3f];
4048 }
4049
4050 switch (data.length - dataIndex)
4051 {
4052 case 0:
4053 // do nothing
4054 break;
4055 case 1:
4056 {
4057 int ch1 = data[dataIndex++] & 0xff;
4058 result[stringIndex++] = valToChar[ch1 >> 2];
4059 result[stringIndex++] = valToChar[(ch1 << 4) & 0x3f];
4060 result[stringIndex++] = '=';
4061 result[stringIndex++] = '=';
4062 break;
4063 }
4064 case 2:
4065 {
4066 int ch1 = data[dataIndex++] & 0xff;
4067 result[stringIndex++] = valToChar[ch1 >> 2];
4068 int ch2 = data[dataIndex++] & 0xff;
4069 result[stringIndex++] = valToChar[((ch1 << 4) & 0x3f) | (ch2 >> 4)];
4070 result[stringIndex++] = valToChar[(ch2 << 2) & 0x3f];
4071 result[stringIndex++] = '=';
4072 break;
4073 }
4074 default:
4075 throw new VBoxException("bug!");
4076 }
4077
4078 return new String(result);
4079 }
4080
4081 private static int skipInvalid(String str, int stringIndex)
4082 {
4083 while (charToVal[str.charAt(stringIndex)] < 0)
4084 stringIndex++;
4085
4086 return stringIndex;
4087 }
4088
4089 public static byte[] decodeBase64(String str)
4090 {
4091 if (str == null)
4092 return null;
4093
4094 int stringLength = str.length();
4095 if (stringLength == 0)
4096 return new byte[0];
4097
4098 int validChars = 0, padChars = 0;
4099 for (int i = 0; i < str.length(); i++)
4100 {
4101 char ch = str.charAt(i);
4102
4103 if (charToVal[ch] >= 0)
4104 validChars++;
4105
4106 if (ch == '=')
4107 padChars++;
4108 }
4109
4110 if ((validChars * 3 % 4) != 0)
4111 throw new VBoxException("invalid base64 encoded string " + str);
4112
4113 int resultLength = validChars * 3 / 4 - padChars;
4114 byte[] result = new byte[resultLength];
4115
4116 int dataIndex = 0, stringIndex = 0;
4117 int quadraplets = validChars / 4;
4118
4119 for (int i = 0; i < quadraplets; i++)
4120 {
4121 stringIndex = skipInvalid(str, stringIndex);
4122 int ch1 = str.charAt(stringIndex++);
4123 stringIndex = skipInvalid(str, stringIndex);
4124 int ch2 = str.charAt(stringIndex++);
4125 stringIndex = skipInvalid(str, stringIndex);
4126 int ch3 = str.charAt(stringIndex++);
4127 stringIndex = skipInvalid(str, stringIndex);
4128 int ch4 = str.charAt(stringIndex++);
4129
4130 result[dataIndex++] = (byte)(((charToVal[ch1] << 2) | charToVal[ch2] >> 4) & 0xff);
4131 /* we check this to ensure that we don't override data with '=' padding. */
4132 if (dataIndex < result.length)
4133 result[dataIndex++] = (byte)(((charToVal[ch2] << 4) | charToVal[ch3] >> 2) & 0xff);
4134 if (dataIndex < result.length)
4135 result[dataIndex++] = (byte)(((charToVal[ch3] << 6) | charToVal[ch4]) & 0xff);
4136 }
4137
4138 return result;
4139 }
4140}
4141]]></xsl:text>
4142 </xsl:if>
4143
4144 <xsl:call-template name="endFile">
4145 <xsl:with-param name="file" select="'Helper.java'" />
4146 </xsl:call-template>
4147
4148 <xsl:call-template name="startFile">
4149 <xsl:with-param name="file" select="'VBoxException.java'" />
4150 <xsl:with-param name="package" select="$G_virtualBoxPackage" />
4151 </xsl:call-template>
4152
4153 <xsl:if test="$filelistonly=''">
4154 <xsl:text>
4155public class VBoxException extends RuntimeException
4156{
4157 private int resultCode;
4158 private IVirtualBoxErrorInfo errorInfo;
4159
4160 public VBoxException(String message)
4161 {
4162 super(message);
4163 resultCode = -1;
4164 errorInfo = null;
4165 }
4166
4167 public VBoxException(String message, Throwable cause)
4168 {
4169 super(message, cause);
4170 resultCode = -1;
4171 errorInfo = null;
4172 }
4173
4174 public VBoxException(String message, Throwable cause, VboxPortType port)
4175 {
4176 super(message, cause);
4177 if (cause instanceof RuntimeFaultMsg)
4178 {
4179 RuntimeFaultMsg m = (RuntimeFaultMsg)cause;
4180 RuntimeFault f = m.getFaultInfo();
4181 resultCode = f.getResultCode();
4182 String retVal = f.getReturnval();
4183 errorInfo = (retVal.length() > 0) ? new IVirtualBoxErrorInfo(retVal, port) : null;
4184 }
4185 else
4186 resultCode = -1;
4187 }
4188
4189 public int getResultCode()
4190 {
4191 return resultCode;
4192 }
4193
4194 public IVirtualBoxErrorInfo getVirtualBoxErrorInfo()
4195 {
4196 return errorInfo;
4197 }
4198}
4199</xsl:text>
4200 </xsl:if>
4201
4202 <xsl:call-template name="endFile">
4203 <xsl:with-param name="file" select="'VBoxException.java'" />
4204 </xsl:call-template>
4205
4206 <xsl:call-template name="startFile">
4207 <xsl:with-param name="file" select="'VirtualBoxManager.java'" />
4208 <xsl:with-param name="package" select="$G_virtualBoxPackage" />
4209 </xsl:call-template>
4210
4211 <xsl:if test="$filelistonly=''">
4212 <xsl:text>import java.net.URL;
4213import java.math.BigInteger;
4214import java.util.List;
4215import java.util.Map;
4216import java.util.HashMap;
4217import javax.xml.namespace.QName;
4218import javax.xml.ws.BindingProvider;
4219import javax.xml.ws.Holder;
4220import javax.xml.ws.WebServiceException;
4221
4222class PortPool
4223{
4224 private final static String wsdlFile = </xsl:text>
4225 <xsl:value-of select="$G_virtualBoxWsdl" />
4226 <xsl:text><![CDATA[;
4227 private Map<VboxPortType, Integer> known;
4228 private boolean initStarted;
4229 private VboxService svc;
4230
4231 PortPool(boolean usePreinit)
4232 {
4233 known = new HashMap<VboxPortType, Integer>();
4234
4235 if (usePreinit)
4236 {
4237 new Thread(new Runnable()
4238 {
4239 public void run()
4240 {
4241 // need to sync on something else but 'this'
4242 synchronized (known)
4243 {
4244 initStarted = true;
4245 known.notify();
4246 }
4247
4248 preinit();
4249 }
4250 }).start();
4251
4252 synchronized (known)
4253 {
4254 while (!initStarted)
4255 {
4256 try
4257 {
4258 known.wait();
4259 }
4260 catch (InterruptedException e)
4261 {
4262 break;
4263 }
4264 }
4265 }
4266 }
4267 }
4268
4269 private synchronized void preinit()
4270 {
4271 VboxPortType port = getPort();
4272 releasePort(port);
4273 }
4274
4275 synchronized VboxPortType getPort()
4276 {
4277 VboxPortType port = null;
4278 int ttl = 0;
4279
4280 for (VboxPortType cur: known.keySet())
4281 {
4282 int value = known.get(cur);
4283 if ((value & 0x10000) == 0)
4284 {
4285 port = cur;
4286 ttl = value & 0xffff;
4287 break;
4288 }
4289 }
4290
4291 if (port == null)
4292 {
4293 if (svc == null)
4294 {
4295 URL wsdl = PortPool.class.getClassLoader().getResource(wsdlFile);
4296 if (wsdl == null)
4297 throw new LinkageError(wsdlFile + " not found, but it should have been in the jar");
4298 svc = new VboxService(wsdl,
4299 new QName("http://www.virtualbox.org/Service",
4300 "vboxService"));
4301 }
4302 port = svc.getVboxServicePort();
4303 // reuse this object 0x10 times
4304 ttl = 0x10;
4305 }
4306 // mark as used
4307 known.put(port, new Integer(0x10000 | ttl));
4308 return port;
4309 }
4310
4311 synchronized void releasePort(VboxPortType port)
4312 {
4313 Integer val = known.get(port);
4314 if (val == null || val == 0)
4315 {
4316 // know you not
4317 return;
4318 }
4319
4320 int v = val;
4321 int ttl = v & 0xffff;
4322 // decrement TTL, and throw away port if used too much times
4323 if (--ttl <= 0)
4324 {
4325 known.remove(port);
4326 }
4327 else
4328 {
4329 v = ttl; // set new TTL and clear busy bit
4330 known.put(port, v);
4331 }
4332 }
4333}
4334
4335
4336public class VirtualBoxManager
4337{
4338 private static PortPool pool = new PortPool(true);
4339 protected VboxPortType port;
4340
4341 private IVirtualBox vbox;
4342
4343 private VirtualBoxManager()
4344 {
4345 }
4346
4347 public static void initPerThread()
4348 {
4349 }
4350
4351 public static void deinitPerThread()
4352 {
4353 }
4354
4355 public void connect(String url, String username, String passwd)
4356 {
4357 this.port = pool.getPort();
4358 try
4359 {
4360 ((BindingProvider)port).getRequestContext().
4361 put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
4362 String handle = port.iWebsessionManagerLogon(username, passwd);
4363 this.vbox = new IVirtualBox(handle, port);
4364 }
4365 catch (Throwable t)
4366 {
4367 if (this.port != null && pool != null)
4368 {
4369 pool.releasePort(this.port);
4370 this.port = null;
4371 }
4372 // we have to throw smth derived from RuntimeException
4373 throw new VBoxException(t.getMessage(), t, this.port);
4374 }
4375 }
4376
4377 public void connect(String url, String username, String passwd,
4378 Map<String, Object> requestContext, Map<String, Object> responseContext)
4379 {
4380 this.port = pool.getPort();
4381
4382 try
4383 {
4384 ((BindingProvider)port).getRequestContext();
4385 if (requestContext != null)
4386 ((BindingProvider)port).getRequestContext().putAll(requestContext);
4387
4388 if (responseContext != null)
4389 ((BindingProvider)port).getResponseContext().putAll(responseContext);
4390
4391 ((BindingProvider)port).getRequestContext().
4392 put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
4393 String handle = port.iWebsessionManagerLogon(username, passwd);
4394 this.vbox = new IVirtualBox(handle, port);
4395 }
4396 catch (Throwable t)
4397 {
4398 if (this.port != null && pool != null)
4399 {
4400 pool.releasePort(this.port);
4401 this.port = null;
4402 }
4403 // we have to throw smth derived from RuntimeException
4404 throw new VBoxException(t.getMessage(), t, this.port);
4405 }
4406 }
4407
4408 public void disconnect()
4409 {
4410 if (this.port == null)
4411 return;
4412
4413 try
4414 {
4415 if (this.vbox != null && port != null)
4416 port.iWebsessionManagerLogoff(this.vbox.getWrapped());
4417 }
4418 catch (InvalidObjectFaultMsg e)
4419 {
4420 throw new VBoxException(e.getMessage(), e, this.port);
4421 }
4422 catch (RuntimeFaultMsg e)
4423 {
4424 throw new VBoxException(e.getMessage(), e, this.port);
4425 }
4426 finally
4427 {
4428 if (this.port != null)
4429 {
4430 pool.releasePort(this.port);
4431 this.port = null;
4432 }
4433 }
4434 }
4435
4436 public IVirtualBox getVBox()
4437 {
4438 return this.vbox;
4439 }
4440
4441 public ISession getSessionObject()
4442 {
4443 if (this.vbox == null)
4444 throw new VBoxException("connect first");
4445 try
4446 {
4447 String handle = port.iWebsessionManagerGetSessionObject(this.vbox.getWrapped());
4448 return new ISession(handle, port);
4449 }
4450 catch (InvalidObjectFaultMsg e)
4451 {
4452 throw new VBoxException(e.getMessage(), e, this.port);
4453 }
4454 catch (RuntimeFaultMsg e)
4455 {
4456 throw new VBoxException(e.getMessage(), e, this.port);
4457 }
4458 }
4459
4460 public ISession openMachineSession(IMachine m) throws Exception
4461 {
4462 ISession s = getSessionObject();
4463 m.lockMachine(s, LockType.Shared);
4464 return s;
4465 }
4466
4467 public void closeMachineSession(ISession s)
4468 {
4469 if (s != null)
4470 s.unlockMachine();
4471 }
4472
4473 public static synchronized VirtualBoxManager createInstance(String home)
4474 {
4475 return new VirtualBoxManager();
4476 }
4477
4478 public IEventListener createListener(Object sink)
4479 {
4480 throw new VBoxException("no active listeners here");
4481 }
4482
4483 public void cleanup()
4484 {
4485 disconnect();
4486 deinitPerThread();
4487 }
4488
4489 public void waitForEvents(long tmo)
4490 {
4491 }
4492
4493 protected void finalize() throws Throwable
4494 {
4495 try
4496 {
4497 cleanup();
4498 }
4499 catch(Exception e)
4500 {
4501 }
4502 finally
4503 {
4504 super.finalize();
4505 }
4506 }
4507}
4508]]></xsl:text>
4509 </xsl:if>
4510
4511 <xsl:call-template name="endFile">
4512 <xsl:with-param name="file" select="'VirtualBoxManager.java'" />
4513 </xsl:call-template>
4514</xsl:template>
4515
4516
4517<xsl:template match="/">
4518
4519 <xsl:if test="not($G_vboxApiSuffix)">
4520 <xsl:call-template name="fatalError">
4521 <xsl:with-param name="msg" select="'G_vboxApiSuffix must be given'" />
4522 </xsl:call-template>
4523 </xsl:if>
4524
4525 <xsl:if test="not($filelistonly='')">
4526 <xsl:value-of select="concat($filelistonly, ' := \&#10;')"/>
4527 </xsl:if>
4528
4529 <!-- Handwritten files -->
4530 <xsl:call-template name="emitHandwritten"/>
4531
4532 <xsl:choose>
4533 <xsl:when test="$G_vboxGlueStyle='xpcom'">
4534 <xsl:call-template name="emitHandwrittenXpcom"/>
4535 </xsl:when>
4536
4537 <xsl:when test="$G_vboxGlueStyle='mscom'">
4538 <xsl:call-template name="emitHandwrittenMscom"/>
4539 </xsl:when>
4540
4541 <xsl:when test="$G_vboxGlueStyle='jaxws'">
4542 <xsl:call-template name="emitHandwrittenJaxws"/>
4543 </xsl:when>
4544
4545 <xsl:otherwise>
4546 <xsl:call-template name="fatalError">
4547 <xsl:with-param name="msg" select="'Style unknown (root)'" />
4548 </xsl:call-template>
4549 </xsl:otherwise>
4550 </xsl:choose>
4551
4552 <!-- Enums -->
4553 <xsl:for-each select="//enum">
4554 <xsl:call-template name="genEnum">
4555 <xsl:with-param name="enumname" select="@name" />
4556 <xsl:with-param name="filename" select="concat(@name, '.java')" />
4557 </xsl:call-template>
4558 </xsl:for-each>
4559
4560 <!-- Interfaces -->
4561 <xsl:for-each select="//interface">
4562 <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
4563 <xsl:variable name="module" select="current()/ancestor::module/@name"/>
4564
4565 <xsl:choose>
4566 <xsl:when test="$G_vboxGlueStyle='jaxws'">
4567 <xsl:if test="not($module) and not(@wsmap='suppress')">
4568 <xsl:call-template name="genIface">
4569 <xsl:with-param name="ifname" select="@name" />
4570 <xsl:with-param name="filename" select="concat(@name, '.java')" />
4571 </xsl:call-template>
4572 </xsl:if>
4573 </xsl:when>
4574
4575 <xsl:otherwise>
4576 <!-- We don't need WSDL-specific interfaces here -->
4577 <xsl:if test="not($self_target='wsdl') and not($module)">
4578 <xsl:call-template name="genIface">
4579 <xsl:with-param name="ifname" select="@name" />
4580 <xsl:with-param name="filename" select="concat(@name, '.java')" />
4581 </xsl:call-template>
4582 </xsl:if>
4583 </xsl:otherwise>
4584
4585 </xsl:choose>
4586 </xsl:for-each>
4587
4588 <xsl:if test="not($filelistonly='')">
4589 <xsl:value-of select="'&#10;'"/>
4590 </xsl:if>
4591
4592</xsl:template>
4593</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.

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