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