1 | <?xml version="1.0"?>
|
---|
2 |
|
---|
3 | <!--
|
---|
4 | websrv-cpp.xsl:
|
---|
5 | XSLT stylesheet that generates methodmaps.cpp from
|
---|
6 | VirtualBox.xidl. This generated C++ code contains
|
---|
7 | all the service implementations that one would
|
---|
8 | normally have to implement manually to create a
|
---|
9 | web service; our generated code automatically maps
|
---|
10 | all SOAP calls into COM/XPCOM method calls.
|
---|
11 | See webservice/Makefile.kmk for an overview of all the things
|
---|
12 | generated for the webservice.
|
---|
13 | -->
|
---|
14 | <!--
|
---|
15 | Copyright (C) 2007-2023 Oracle and/or its affiliates.
|
---|
16 |
|
---|
17 | This file is part of VirtualBox base platform packages, as
|
---|
18 | available from https://www.virtualbox.org.
|
---|
19 |
|
---|
20 | This program is free software; you can redistribute it and/or
|
---|
21 | modify it under the terms of the GNU General Public License
|
---|
22 | as published by the Free Software Foundation, in version 3 of the
|
---|
23 | License.
|
---|
24 |
|
---|
25 | This program is distributed in the hope that it will be useful, but
|
---|
26 | WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
27 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
28 | General Public License for more details.
|
---|
29 |
|
---|
30 | You should have received a copy of the GNU General Public License
|
---|
31 | along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
32 |
|
---|
33 | SPDX-License-Identifier: GPL-3.0-only
|
---|
34 | -->
|
---|
35 |
|
---|
36 | <xsl:stylesheet
|
---|
37 | version="1.0"
|
---|
38 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
---|
39 | xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
---|
40 | xmlns:exsl="http://exslt.org/common"
|
---|
41 | extension-element-prefixes="exsl">
|
---|
42 |
|
---|
43 | <xsl:output method="text"/>
|
---|
44 |
|
---|
45 | <xsl:strip-space elements="*"/>
|
---|
46 |
|
---|
47 | <!-- - - - - - - - - - - - - - - - - - - - - - -
|
---|
48 | global XSLT variables
|
---|
49 | - - - - - - - - - - - - - - - - - - - - - - -->
|
---|
50 |
|
---|
51 | <xsl:variable name="G_xsltFilename" select="'websrv-cpp.xsl'" />
|
---|
52 |
|
---|
53 | <xsl:include href="../idl/typemap-shared.inc.xsl" />
|
---|
54 |
|
---|
55 | <!-- collect all interfaces with "wsmap='suppress'" in a global variable for
|
---|
56 | quick lookup -->
|
---|
57 | <xsl:variable name="G_setSuppressedInterfaces"
|
---|
58 | select="//interface[@wsmap='suppress']" />
|
---|
59 |
|
---|
60 | <!-- - - - - - - - - - - - - - - - - - - - - - -
|
---|
61 | Keys for more efficiently looking up of types.
|
---|
62 | - - - - - - - - - - - - - - - - - - - - - - -->
|
---|
63 |
|
---|
64 | <xsl:key name="G_keyEnumsByName" match="//enum[@name]" use="@name"/>
|
---|
65 | <xsl:key name="G_keyInterfacesByName" match="//interface[@name]" use="@name"/>
|
---|
66 |
|
---|
67 | <!-- - - - - - - - - - - - - - - - - - - - - - -
|
---|
68 | root match
|
---|
69 | - - - - - - - - - - - - - - - - - - - - - - -->
|
---|
70 |
|
---|
71 | <xsl:template match="/idl">
|
---|
72 | <xsl:text><![CDATA[
|
---|
73 | /* DO NOT EDIT! This is a generated file.
|
---|
74 | * Generated from: src/VBox/Main/idl/VirtualBox.xidl (VirtualBox's interface definitions in XML)
|
---|
75 | * Generator: src/VBox/Main/webservice/websrv-cpp.xsl
|
---|
76 | */
|
---|
77 |
|
---|
78 | // shared webservice header
|
---|
79 | #include "vboxweb.h"
|
---|
80 |
|
---|
81 | // vbox headers
|
---|
82 | #include <VBox/com/com.h>
|
---|
83 | #include <VBox/com/array.h>
|
---|
84 | #include <VBox/com/ErrorInfo.h>
|
---|
85 | #include <VBox/com/errorprint.h>
|
---|
86 | #include <VBox/VBoxAuth.h>
|
---|
87 |
|
---|
88 | #include <iprt/assert.h>
|
---|
89 | #include <iprt/initterm.h>
|
---|
90 | #include <iprt/stream.h>
|
---|
91 | #include <iprt/string.h>
|
---|
92 |
|
---|
93 | // gSOAP headers (must come after vbox includes because it checks for conflicting defs)
|
---|
94 | #include "soapH.h"
|
---|
95 |
|
---|
96 | // standard headers
|
---|
97 | #include <map>
|
---|
98 | #include <iprt/sanitized/sstream>
|
---|
99 |
|
---|
100 | // shared strings for debug output
|
---|
101 | const char *g_pcszCallingComMethod = " calling COM method %s\n";
|
---|
102 | const char *g_pcszDoneCallingComMethod = " done calling COM method\n";
|
---|
103 | const char *g_pcszConvertComOutputBack = " convert COM output \"%s\" back to caller format\n";
|
---|
104 | const char *g_pcszDoneConvertingComOutputBack = " done converting COM output \"%s\" back to caller format\n";
|
---|
105 | const char *g_pcszEntering = "-- entering %s\n";
|
---|
106 | const char *g_pcszLeaving = "-- leaving %s, rc: %#lx (%d)\n";
|
---|
107 |
|
---|
108 | // generated string constants for all interface names
|
---|
109 | const char *g_pcszIUnknown = "IUnknown";
|
---|
110 | ]]></xsl:text>
|
---|
111 |
|
---|
112 | <xsl:for-each select="//interface">
|
---|
113 | <xsl:variable name="ifname" select="@name" />
|
---|
114 | <xsl:value-of select="concat('const char *g_pcsz', $ifname, ' = "', $ifname, '";')" />
|
---|
115 | <xsl:call-template name="emitNewline" />
|
---|
116 | </xsl:for-each>
|
---|
117 | <xsl:apply-templates />
|
---|
118 | </xsl:template>
|
---|
119 |
|
---|
120 | <!-- - - - - - - - - - - - - - - - - - - - - - -
|
---|
121 | if
|
---|
122 | - - - - - - - - - - - - - - - - - - - - - - -->
|
---|
123 |
|
---|
124 | <!--
|
---|
125 | * ignore all |if|s except those for WSDL target
|
---|
126 | -->
|
---|
127 | <xsl:template match="if">
|
---|
128 | <xsl:if test="@target='wsdl'">
|
---|
129 | <xsl:apply-templates/>
|
---|
130 | </xsl:if>
|
---|
131 | </xsl:template>
|
---|
132 |
|
---|
133 | <!-- - - - - - - - - - - - - - - - - - - - - - -
|
---|
134 | cpp
|
---|
135 | - - - - - - - - - - - - - - - - - - - - - - -->
|
---|
136 |
|
---|
137 | <xsl:template match="cpp">
|
---|
138 | <!-- ignore this -->
|
---|
139 | </xsl:template>
|
---|
140 |
|
---|
141 | <!-- - - - - - - - - - - - - - - - - - - - - - -
|
---|
142 | library
|
---|
143 | - - - - - - - - - - - - - - - - - - - - - - -->
|
---|
144 |
|
---|
145 | <xsl:template match="library">
|
---|
146 | <xsl:text>
|
---|
147 | /****************************************************************************
|
---|
148 | *
|
---|
149 | * types: enum converter helper functions
|
---|
150 | *
|
---|
151 | ****************************************************************************/
|
---|
152 | </xsl:text>
|
---|
153 | <!--
|
---|
154 | enum converter functions at top of file
|
---|
155 | -->
|
---|
156 | <xsl:for-each select="//enum">
|
---|
157 | <xsl:variable name="enumname" select="@name" />
|
---|
158 | <!-- generate enum converter for COM-to-SOAP -->
|
---|
159 | <xsl:call-template name="emitNewline" />
|
---|
160 | <xsl:value-of select="concat('vbox__', $enumname, ' ', $G_funcPrefixOutputEnumConverter, $enumname, '(', $enumname, '_T e)')" />
|
---|
161 | <xsl:call-template name="emitNewline" />
|
---|
162 | <xsl:text>{</xsl:text>
|
---|
163 | <xsl:call-template name="emitNewline" />
|
---|
164 | <xsl:value-of select="concat(' vbox__', $enumname, ' v;')" />
|
---|
165 | <xsl:call-template name="emitNewline" />
|
---|
166 | <xsl:call-template name="emitNewline" />
|
---|
167 | <xsl:text> switch(e)</xsl:text>
|
---|
168 | <xsl:call-template name="emitNewline" />
|
---|
169 | <xsl:text> {</xsl:text>
|
---|
170 | <xsl:call-template name="emitNewline" />
|
---|
171 | <xsl:for-each select="const[not(@wsmap='suppress')]">
|
---|
172 | <xsl:variable name="enumconst" select="@name" />
|
---|
173 | <xsl:value-of select="concat(' case ', $enumname, '_', $enumconst, ':')" />
|
---|
174 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
175 | <xsl:value-of select="concat(' v = vbox__', $enumname, '__')" />
|
---|
176 | <!-- escape all "_" in $enumconst -->
|
---|
177 | <xsl:call-template name="escapeUnderscores">
|
---|
178 | <xsl:with-param name="string" select="$enumconst" />
|
---|
179 | </xsl:call-template>
|
---|
180 | <xsl:value-of select="';'" />
|
---|
181 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
182 | <xsl:text>break;</xsl:text>
|
---|
183 | <xsl:call-template name="emitNewline" />
|
---|
184 | </xsl:for-each>
|
---|
185 | <!-- Add a default case so gcc gives us a rest, esp. on darwin. -->
|
---|
186 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
187 | <xsl:text>default:</xsl:text>
|
---|
188 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
189 | <xsl:text> AssertMsgFailed(("e=%d\n", (int)e));</xsl:text>
|
---|
190 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
191 | <xsl:value-of select="concat(' v = (vbox__', $enumname, ')0x7fffdead;')" />
|
---|
192 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
193 | <xsl:text>break; </xsl:text>
|
---|
194 | <xsl:call-template name="emitNewline" />
|
---|
195 | <xsl:text> }</xsl:text>
|
---|
196 | <xsl:call-template name="emitNewline" />
|
---|
197 | <xsl:call-template name="emitNewline" />
|
---|
198 | <xsl:text> return v;</xsl:text>
|
---|
199 | <xsl:call-template name="emitNewline" />
|
---|
200 | <xsl:text>}</xsl:text>
|
---|
201 | <xsl:call-template name="emitNewline" />
|
---|
202 | <!-- generate enum converter for SOAP-to-COM -->
|
---|
203 | <xsl:call-template name="emitNewline" />
|
---|
204 | <xsl:value-of select="concat($enumname, '_T ', $G_funcPrefixInputEnumConverter, $enumname, '(vbox__', $enumname, ' v)')" />
|
---|
205 | <xsl:call-template name="emitNewline" />
|
---|
206 | <xsl:text>{</xsl:text>
|
---|
207 | <xsl:call-template name="emitNewline" />
|
---|
208 | <xsl:value-of select="concat(' ', $enumname, '_T e;')" />
|
---|
209 | <xsl:call-template name="emitNewline" />
|
---|
210 | <xsl:call-template name="emitNewline" />
|
---|
211 | <xsl:text> switch(v)</xsl:text>
|
---|
212 | <xsl:call-template name="emitNewline" />
|
---|
213 | <xsl:text> {</xsl:text>
|
---|
214 | <xsl:call-template name="emitNewline" />
|
---|
215 | <xsl:for-each select="const[not(@wsmap='suppress')]">
|
---|
216 | <xsl:variable name="enumconst" select="@name" />
|
---|
217 | <xsl:value-of select="concat(' case vbox__', $enumname, '__')" />
|
---|
218 | <!-- escape all "_" in $enumconst -->
|
---|
219 | <xsl:call-template name="escapeUnderscores">
|
---|
220 | <xsl:with-param name="string" select="$enumconst" />
|
---|
221 | </xsl:call-template>
|
---|
222 | <xsl:value-of select="':'" />
|
---|
223 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
224 | <xsl:value-of select="concat(' e = ', $enumname, '_', $enumconst, ';')" />
|
---|
225 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
226 | <xsl:text>break;</xsl:text>
|
---|
227 | <xsl:call-template name="emitNewline" />
|
---|
228 | </xsl:for-each>
|
---|
229 | <!-- Insert a default case so gcc gives us a rest, esp. on darwin. -->
|
---|
230 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
231 | <xsl:text>default:</xsl:text>
|
---|
232 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
233 | <xsl:text> AssertMsgFailed(("v=%d\n", (int)v));</xsl:text>
|
---|
234 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
235 | <xsl:value-of select="concat(' e = (', $enumname, '_T)0x7fffbeef;')" />
|
---|
236 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
237 | <xsl:text>break; </xsl:text>
|
---|
238 | <xsl:call-template name="emitNewline" />
|
---|
239 | <xsl:text> }</xsl:text>
|
---|
240 | <xsl:call-template name="emitNewline" />
|
---|
241 | <xsl:call-template name="emitNewline" />
|
---|
242 | <xsl:text> return e;</xsl:text>
|
---|
243 | <xsl:call-template name="emitNewline" />
|
---|
244 | <xsl:text>}</xsl:text>
|
---|
245 | <xsl:call-template name="emitNewline" />
|
---|
246 | </xsl:for-each>
|
---|
247 |
|
---|
248 | <xsl:text>
|
---|
249 | /****************************************************************************
|
---|
250 | *
|
---|
251 | * types: struct converter helper functions
|
---|
252 | *
|
---|
253 | ****************************************************************************/
|
---|
254 | </xsl:text>
|
---|
255 |
|
---|
256 | <xsl:for-each select="//interface[@wsmap='struct']">
|
---|
257 | <xsl:variable name="structname" select="@name" />
|
---|
258 |
|
---|
259 | <xsl:call-template name="emitNewline" />
|
---|
260 | <xsl:value-of select="concat('// ', $structname, ' converter: called from method mappers to convert data from')" />
|
---|
261 | <xsl:call-template name="emitNewline" />
|
---|
262 | <xsl:value-of select="concat('// COM interface ', $structname, ', which has wsmap="struct", to SOAP structures')" />
|
---|
263 | <xsl:call-template name="emitNewline" />
|
---|
264 | <xsl:value-of select="concat('vbox__', $structname, '* ', $G_funcPrefixOutputStructConverter, $structname, '(')" />
|
---|
265 | <xsl:call-template name="emitNewline" />
|
---|
266 | <xsl:value-of select="' struct soap *soap,'" />
|
---|
267 | <xsl:call-template name="emitNewline" />
|
---|
268 | <xsl:value-of select="' const WSDLT_ID &idThis,'" />
|
---|
269 | <xsl:call-template name="emitNewline" />
|
---|
270 | <xsl:value-of select="' HRESULT &rc,'" />
|
---|
271 | <xsl:call-template name="emitNewline" />
|
---|
272 | <xsl:value-of select="concat(' ComPtr<', $structname, '> &in)')" />
|
---|
273 | <xsl:call-template name="emitNewline" />
|
---|
274 | <xsl:text>{</xsl:text>
|
---|
275 | <xsl:call-template name="emitNewline" />
|
---|
276 |
|
---|
277 | <xsl:value-of select="concat(' vbox__', $structname, ' *resp = NULL;')" />
|
---|
278 | <xsl:call-template name="emitNewline" />
|
---|
279 |
|
---|
280 | <xsl:call-template name="emitPrologue"><xsl:with-param name="fSkipHRESULT" select="'1'"/></xsl:call-template>
|
---|
281 |
|
---|
282 | <xsl:value-of select="concat(' resp = soap_new_vbox__', $structname, '(soap, -1);')" />
|
---|
283 | <xsl:call-template name="emitNewline" />
|
---|
284 | <xsl:text> if (!in) </xsl:text>
|
---|
285 | <xsl:text> { </xsl:text>
|
---|
286 | <xsl:text> // @todo ambiguous. Problem is the MOR for the object converted to struct </xsl:text>
|
---|
287 | <xsl:text> RaiseSoapInvalidObjectFault(soap, ""); </xsl:text>
|
---|
288 | <xsl:text> break; </xsl:text>
|
---|
289 | <xsl:text> } </xsl:text>
|
---|
290 | <xsl:call-template name="emitNewline" />
|
---|
291 |
|
---|
292 | <xsl:for-each select="key('G_keyInterfacesByName', $structname)/attribute">
|
---|
293 | <xsl:if test="not(@wsmap = 'suppress')">
|
---|
294 | <xsl:value-of select="concat(' // -- ', $structname, '.', @name)" />
|
---|
295 | <xsl:call-template name="emitNewline" />
|
---|
296 | <!-- recurse! -->
|
---|
297 | <xsl:call-template name="emitGetAttributeComCall">
|
---|
298 | <xsl:with-param name="ifname" select="$structname" />
|
---|
299 | <xsl:with-param name="object" select="'in'" />
|
---|
300 | <xsl:with-param name="attrname" select="@name" />
|
---|
301 | <xsl:with-param name="attrtype" select="@type" />
|
---|
302 | <xsl:with-param name="callerprefix" select="concat('out', '.')" />
|
---|
303 | </xsl:call-template>
|
---|
304 | <xsl:call-template name="emitNewline" />
|
---|
305 | </xsl:if>
|
---|
306 | </xsl:for-each>
|
---|
307 |
|
---|
308 | <xsl:call-template name="emitEpilogue"><xsl:with-param name="fSkipHRESULT" select="'1'"/></xsl:call-template>
|
---|
309 |
|
---|
310 | </xsl:for-each>
|
---|
311 |
|
---|
312 | <xsl:apply-templates />
|
---|
313 | </xsl:template>
|
---|
314 |
|
---|
315 | <!-- - - - - - - - - - - - - - - - - - - - - - -
|
---|
316 | class
|
---|
317 | - - - - - - - - - - - - - - - - - - - - - - -->
|
---|
318 |
|
---|
319 | <xsl:template match="module/class">
|
---|
320 | <!-- TODO swallow for now -->
|
---|
321 | </xsl:template>
|
---|
322 |
|
---|
323 | <!-- - - - - - - - - - - - - - - - - - - - - - -
|
---|
324 | enum
|
---|
325 | - - - - - - - - - - - - - - - - - - - - - - -->
|
---|
326 |
|
---|
327 | <xsl:template match="enum">
|
---|
328 | </xsl:template>
|
---|
329 |
|
---|
330 | <!-- - - - - - - - - - - - - - - - - - - - - - -
|
---|
331 | const
|
---|
332 | - - - - - - - - - - - - - - - - - - - - - - -->
|
---|
333 |
|
---|
334 | <!--
|
---|
335 | <xsl:template match="const">
|
---|
336 | <xsl:apply-templates />
|
---|
337 | </xsl:template>
|
---|
338 | -->
|
---|
339 |
|
---|
340 | <!-- - - - - - - - - - - - - - - - - - - - - - -
|
---|
341 | desc
|
---|
342 | - - - - - - - - - - - - - - - - - - - - - - -->
|
---|
343 |
|
---|
344 | <xsl:template match="desc">
|
---|
345 | <!-- TODO swallow for now -->
|
---|
346 | </xsl:template>
|
---|
347 |
|
---|
348 | <!-- - - - - - - - - - - - - - - - - - - - - - -
|
---|
349 | note
|
---|
350 | - - - - - - - - - - - - - - - - - - - - - - -->
|
---|
351 |
|
---|
352 | <xsl:template match="note">
|
---|
353 | <!-- TODO -->
|
---|
354 | <xsl:apply-templates />
|
---|
355 | </xsl:template>
|
---|
356 |
|
---|
357 | <!--
|
---|
358 | emitBeginOfFunctionHeader:
|
---|
359 | -->
|
---|
360 |
|
---|
361 | <xsl:template name="emitBeginOfFunctionHeader">
|
---|
362 | <xsl:param name="ifname" />
|
---|
363 | <xsl:param name="method" />
|
---|
364 |
|
---|
365 | <xsl:call-template name="emitNewline" />
|
---|
366 | <xsl:value-of select="concat('int __vbox__', $ifname, '_USCORE', $method, '(')" />
|
---|
367 | <xsl:call-template name="emitNewline" />
|
---|
368 | <xsl:text> struct soap *soap</xsl:text>
|
---|
369 | </xsl:template>
|
---|
370 |
|
---|
371 | <!--
|
---|
372 | emitCppTypeForIDLType:
|
---|
373 | emits the C++ type that corresponds to the given WSDL type in $type.
|
---|
374 | -->
|
---|
375 | <xsl:template name="emitCppTypeForIDLType">
|
---|
376 | <xsl:param name="method" />
|
---|
377 | <xsl:param name="type" />
|
---|
378 | <xsl:param name="safearray" />
|
---|
379 | <xsl:param name="varprefix" /> <!-- only with nested get-attribute calls -->
|
---|
380 | <xsl:param name="inptr" /> <!-- whether to add INPTR to BSTR (Dmitry template magic) -->
|
---|
381 |
|
---|
382 | <!-- look up C++ glue type from IDL type from table array in typemap-shared.inc.xsl -->
|
---|
383 | <xsl:variable name="gluetypefield" select="exsl:node-set($G_aSharedTypes)/type[@idlname=$type]/@gluename" />
|
---|
384 |
|
---|
385 | <xsl:choose>
|
---|
386 | <xsl:when test="$type='wstring' or $type='uuid'">
|
---|
387 | <xsl:choose>
|
---|
388 | <xsl:when test="$safearray='yes'">
|
---|
389 | <xsl:choose>
|
---|
390 | <xsl:when test="$inptr='yes'">
|
---|
391 | <xsl:value-of select="'com::SafeArray<IN_BSTR>'" /> <!-- input string arrays must use IN_BSTR (see com/array.h) -->
|
---|
392 | </xsl:when>
|
---|
393 | <xsl:otherwise>
|
---|
394 | <xsl:value-of select="'com::SafeArray<BSTR>'" /> <!-- output string arrays use raw BSTR -->
|
---|
395 | </xsl:otherwise>
|
---|
396 | </xsl:choose>
|
---|
397 | </xsl:when>
|
---|
398 | <xsl:otherwise>
|
---|
399 | <xsl:value-of select="'com::Bstr'" />
|
---|
400 | </xsl:otherwise>
|
---|
401 | </xsl:choose>
|
---|
402 | </xsl:when>
|
---|
403 | <!-- if above lookup in table succeeded, use that type -->
|
---|
404 | <xsl:when test="string-length($gluetypefield)">
|
---|
405 | <xsl:call-template name="emitTypeOrArray">
|
---|
406 | <xsl:with-param name="type" select="$gluetypefield"/>
|
---|
407 | <xsl:with-param name="safearray" select="$safearray"/>
|
---|
408 | </xsl:call-template>
|
---|
409 | </xsl:when>
|
---|
410 | <xsl:when test="count(key('G_keyEnumsByName', $type)) > 0">
|
---|
411 | <xsl:call-template name="emitTypeOrArray">
|
---|
412 | <xsl:with-param name="type" select="concat($type, '_T ')"/>
|
---|
413 | <xsl:with-param name="safearray" select="$safearray"/>
|
---|
414 | </xsl:call-template>
|
---|
415 | </xsl:when>
|
---|
416 | <xsl:when test="$type='$unknown'">
|
---|
417 | <xsl:choose>
|
---|
418 | <xsl:when test="$safearray='yes'">
|
---|
419 | <xsl:value-of select="'com::SafeIfaceArray<IUnknown>'" />
|
---|
420 | </xsl:when>
|
---|
421 | <xsl:otherwise>
|
---|
422 | <xsl:value-of select="'ComPtr<IUnknown>'" />
|
---|
423 | </xsl:otherwise>
|
---|
424 | </xsl:choose>
|
---|
425 | </xsl:when>
|
---|
426 | <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
|
---|
427 | <xsl:variable name="thatif" select="key('G_keyInterfacesByName', $type)" />
|
---|
428 | <xsl:variable name="thatifname" select="$thatif/@name" />
|
---|
429 | <xsl:choose>
|
---|
430 | <xsl:when test="$safearray='yes'">
|
---|
431 | <xsl:value-of select="concat('com::SafeIfaceArray<', $thatifname, '>')" />
|
---|
432 | </xsl:when>
|
---|
433 | <xsl:otherwise>
|
---|
434 | <xsl:value-of select="concat('ComPtr<', $thatifname, '>')" />
|
---|
435 | </xsl:otherwise>
|
---|
436 | </xsl:choose>
|
---|
437 | </xsl:when>
|
---|
438 | <xsl:otherwise>
|
---|
439 | <xsl:call-template name="fatalError">
|
---|
440 | <xsl:with-param name="msg" select="concat('emitCppTypeForIDLType: Type "', $type, '" in method "', $method, '" is not supported.')" />
|
---|
441 | </xsl:call-template>
|
---|
442 | </xsl:otherwise>
|
---|
443 | </xsl:choose>
|
---|
444 | </xsl:template>
|
---|
445 |
|
---|
446 |
|
---|
447 | <!--
|
---|
448 | emitDocumentStyleArgStructs:
|
---|
449 | with WSDL "document" style only, emits those lengthy structs for
|
---|
450 | the input and output argument in the function header.
|
---|
451 | -->
|
---|
452 | <xsl:template name="emitDocumentStyleArgStructs">
|
---|
453 | <xsl:param name="ifname" />
|
---|
454 | <xsl:param name="methodname" />
|
---|
455 | <xsl:param name="fOutputs" /> <!-- if 1, emit output struct as well -->
|
---|
456 |
|
---|
457 | <xsl:text>,</xsl:text>
|
---|
458 | <xsl:call-template name="emitNewline" />
|
---|
459 | <xsl:value-of select="concat(' _vbox__', $ifname, '_USCORE', $methodname, $G_requestMessageElementSuffix, ' *', $G_requestElementVarName)" />
|
---|
460 | <xsl:if test="$fOutputs">
|
---|
461 | <xsl:text>,</xsl:text>
|
---|
462 | <xsl:call-template name="emitNewline" />
|
---|
463 | <xsl:value-of select="concat(' _vbox__', $ifname, '_USCORE', $methodname, $G_responseMessageElementSuffix, ' *', $G_responseElementVarName)" />
|
---|
464 | <!-- <xsl:value-of select="concat(' struct ', $ifname, '__', $methodname, 'Response &', $G_result)" /> -->
|
---|
465 | </xsl:if>
|
---|
466 |
|
---|
467 | </xsl:template>
|
---|
468 |
|
---|
469 | <!--
|
---|
470 | emitPrologue:
|
---|
471 | emits the closing ")" for the parameter list and the beginning
|
---|
472 | of the function body.
|
---|
473 | -->
|
---|
474 | <xsl:template name="emitPrologue">
|
---|
475 | <xsl:text> WEBDEBUG((g_pcszEntering, __FUNCTION__));
|
---|
476 |
|
---|
477 | do {</xsl:text>
|
---|
478 | <xsl:call-template name="emitNewline" />
|
---|
479 | </xsl:template>
|
---|
480 |
|
---|
481 | <!--
|
---|
482 | emitEpilogue
|
---|
483 | -->
|
---|
484 | <xsl:template name="emitEpilogue">
|
---|
485 | <xsl:param name="fSkipHRESULT" />
|
---|
486 |
|
---|
487 | <xsl:text> } while (0);</xsl:text>
|
---|
488 | <xsl:call-template name="emitNewline" />
|
---|
489 | <xsl:call-template name="emitNewline" />
|
---|
490 | <xsl:text> WEBDEBUG((g_pcszLeaving, __FUNCTION__, rc, rc));</xsl:text>
|
---|
491 | <xsl:call-template name="emitNewline" />
|
---|
492 | <xsl:if test="not($fSkipHRESULT)">
|
---|
493 | <xsl:text>
|
---|
494 | if (FAILED(rc))
|
---|
495 | return SOAP_FAULT;
|
---|
496 | return SOAP_OK;</xsl:text>
|
---|
497 | </xsl:if>
|
---|
498 | <xsl:if test="$fSkipHRESULT">
|
---|
499 | <xsl:text> return resp;</xsl:text>
|
---|
500 | </xsl:if>
|
---|
501 | <xsl:call-template name="emitNewline" />
|
---|
502 | <xsl:text>}</xsl:text>
|
---|
503 | <xsl:call-template name="emitNewline" />
|
---|
504 | </xsl:template>
|
---|
505 |
|
---|
506 | <!--
|
---|
507 | emitObjForMethod:
|
---|
508 | after the function prologue, emit a "pObj" object that
|
---|
509 | specifies the object upon which the method should be invoked.
|
---|
510 | -->
|
---|
511 | <xsl:template name="emitObjForMethod">
|
---|
512 | <xsl:param name="ifname" />
|
---|
513 | <xsl:param name="wsmap" />
|
---|
514 | <xsl:param name="structprefix" /> <!-- with WSDL document style: req element prefix, like "vbox__IVirtualBox_USCOREcreateMachineRequestElement->" -->
|
---|
515 |
|
---|
516 | <xsl:choose>
|
---|
517 | <xsl:when test="$wsmap='global'">
|
---|
518 | <xsl:choose>
|
---|
519 | <xsl:when test="$ifname='IVirtualBox'">
|
---|
520 | <xsl:text> // invoke method on global IVirtualBox instance</xsl:text>
|
---|
521 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
522 | <xsl:text>ComPtr<IVirtualBox> pObj = G_pVirtualBox;</xsl:text>
|
---|
523 | <xsl:call-template name="emitNewline" />
|
---|
524 | </xsl:when>
|
---|
525 | <xsl:otherwise>
|
---|
526 | <xsl:call-template name="fatalError">
|
---|
527 | <xsl:with-param name="msg" select="concat('emitObjForMethod: Unknown interface "', $ifname, '" with wsmap=global in XIDL.')" />
|
---|
528 | </xsl:call-template>
|
---|
529 | </xsl:otherwise>
|
---|
530 | </xsl:choose>
|
---|
531 | </xsl:when>
|
---|
532 | <xsl:when test="($wsmap='managed')">
|
---|
533 | <xsl:text> // look up managed object reference for method call </xsl:text>
|
---|
534 | <xsl:value-of select="concat(' ComPtr<', $ifname, '> pObj; ')" />
|
---|
535 | <xsl:value-of select="concat(' if (!', $G_requestElementVarName, ') ')" />
|
---|
536 | <xsl:text> { </xsl:text>
|
---|
537 | <xsl:text> RaiseSoapInvalidObjectFault(soap, ""); </xsl:text>
|
---|
538 | <xsl:text> break; </xsl:text>
|
---|
539 | <xsl:text> } </xsl:text>
|
---|
540 | <xsl:value-of select="concat(' const WSDLT_ID &idThis = ', $structprefix, $G_nameObjectRefEncoded, '; ')" />
|
---|
541 | <xsl:value-of select="' if ((rc = findComPtrFromId(soap, idThis, pObj, false)) != S_OK) '" />
|
---|
542 | <xsl:text> break; </xsl:text>
|
---|
543 | </xsl:when>
|
---|
544 | </xsl:choose>
|
---|
545 | </xsl:template>
|
---|
546 |
|
---|
547 | <!--
|
---|
548 | emitInputArgConverter:
|
---|
549 | another type converter (from wsdl type to COM types),
|
---|
550 | that generates temporary variables on the stack with
|
---|
551 | the WSDL input parameters converted to the COM types,
|
---|
552 | so we can then pass them to the actual COM method call.
|
---|
553 | -->
|
---|
554 | <xsl:template name="emitInputArgConverter">
|
---|
555 | <xsl:param name="ifname" />
|
---|
556 | <xsl:param name="object" /> <!-- normally "pObj" -->
|
---|
557 | <xsl:param name="method" />
|
---|
558 | <xsl:param name="methodname" />
|
---|
559 | <xsl:param name="structprefix" /> <!-- with WSDL document style: req element prefix, like "vbox__IVirtualBox_USCOREcreateMachineRequestElement->" -->
|
---|
560 | <xsl:param name="name" />
|
---|
561 | <xsl:param name="type" />
|
---|
562 | <xsl:param name="safearray" />
|
---|
563 |
|
---|
564 | <xsl:value-of select="concat(' // convert input arg ', $name, '(safearray: ', $safearray, ')')" />
|
---|
565 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
566 |
|
---|
567 | <xsl:choose>
|
---|
568 | <xsl:when test="$safearray='yes' and $type='octet'">
|
---|
569 | <xsl:value-of select="concat('com::SafeArray<BYTE> comcall_',$name, ';')" />
|
---|
570 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
571 | <xsl:value-of select="concat('Base64DecodeByteArray(soap, ',$structprefix,$name,', ComSafeArrayAsOutParam(comcall_',$name, '), idThis, "', $ifname, '::', $methodname, '", ', $object, ', COM_IIDOF(', $ifname, '));')" />
|
---|
572 | </xsl:when>
|
---|
573 |
|
---|
574 | <xsl:when test="$safearray='yes'">
|
---|
575 | <xsl:value-of select="concat('size_t c', $name, ' = ', $structprefix, $name, '.size();')" />
|
---|
576 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
577 | <xsl:call-template name="emitCppTypeForIDLType">
|
---|
578 | <xsl:with-param name="method" select="$method"/>
|
---|
579 | <xsl:with-param name="type" select="$type"/>
|
---|
580 | <xsl:with-param name="safearray" select="$safearray"/>
|
---|
581 | <xsl:with-param name="inptr" select="'yes'"/>
|
---|
582 | </xsl:call-template>
|
---|
583 | <xsl:value-of select="concat(' comcall_', $name, '(c', $name, ');')" />
|
---|
584 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
585 | <xsl:value-of select="concat('for (size_t i = 0; i < c', $name, '; ++i)')" />
|
---|
586 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
587 | <xsl:value-of select="'{'" />
|
---|
588 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
589 | <xsl:choose>
|
---|
590 | <xsl:when test="$type='$unknown'">
|
---|
591 | <xsl:value-of select="' ComPtr<IUnknown> tmpObject;'" />
|
---|
592 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
593 | <xsl:value-of select="concat(' if ((rc = findComPtrFromId(soap, ', $structprefix, $name, '[i], tmpObject, true)) != S_OK)')" />
|
---|
594 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
595 | <xsl:text> break;</xsl:text>
|
---|
596 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
597 | <xsl:value-of select="concat(' IUnknown *tmpObject2(tmpObject); tmpObject2->AddRef(); comcall_', $name, '[i] = tmpObject;')" />
|
---|
598 | </xsl:when>
|
---|
599 | <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
|
---|
600 | <xsl:value-of select="concat(' ComPtr<', $type, '> tmpObject;')" />
|
---|
601 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
602 | <xsl:value-of select="concat(' if ((rc = findComPtrFromId(soap, ', $structprefix, $name, '[i], tmpObject, true)) != S_OK)')" />
|
---|
603 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
604 | <xsl:text> break;</xsl:text>
|
---|
605 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
606 | <xsl:value-of select="concat(' ', $type, ' *tmpObject2(tmpObject); tmpObject2->AddRef(); comcall_', $name, '[i] = tmpObject;')" />
|
---|
607 | </xsl:when>
|
---|
608 | <xsl:when test="$type='wstring'">
|
---|
609 | <xsl:value-of select="concat(' com::Bstr tmpObject(', $structprefix, $name, '[i].c_str());')" />
|
---|
610 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
611 | <xsl:value-of select="' BSTR tmpObjectB;'" />
|
---|
612 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
613 | <xsl:value-of select="' tmpObject.detachTo(&tmpObjectB);'" />
|
---|
614 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
615 | <xsl:value-of select="concat(' comcall_', $name, '[i] = tmpObjectB;')" />
|
---|
616 | </xsl:when>
|
---|
617 | <xsl:when test="$type='long'">
|
---|
618 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
619 | <xsl:value-of select="concat(' comcall_', $name, '[i] = ', $structprefix, $name, '[i];')" />
|
---|
620 | </xsl:when>
|
---|
621 | <xsl:when test="$type='long long'">
|
---|
622 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
623 | <xsl:value-of select="concat(' comcall_', $name, '[i] = ', $structprefix, $name, '[i];')" />
|
---|
624 | </xsl:when>
|
---|
625 | <xsl:when test="$type='boolean'">
|
---|
626 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
627 | <xsl:value-of select="concat(' comcall_', $name, '[i] = ', $structprefix, $name, '[i];')" />
|
---|
628 | </xsl:when>
|
---|
629 | <xsl:when test="count(key('G_keyEnumsByName', $type)) > 0">
|
---|
630 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
631 | <xsl:value-of select="concat(' comcall_', $name, '[i] = ', $G_funcPrefixInputEnumConverter, $type, '(', $structprefix, $name, '[i]);')" />
|
---|
632 | </xsl:when>
|
---|
633 | <xsl:otherwise>
|
---|
634 | <xsl:call-template name="fatalError">
|
---|
635 | <xsl:with-param name="msg" select="concat('emitInputArgConverter Type "', $type, '" in arg "', $name, '" of method "', $method, '" is not yet supported in safearrays.')" />
|
---|
636 | </xsl:call-template>
|
---|
637 | </xsl:otherwise>
|
---|
638 | </xsl:choose>
|
---|
639 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
640 | <xsl:value-of select="'}'" />
|
---|
641 | <xsl:call-template name="emitNewline" />
|
---|
642 | </xsl:when>
|
---|
643 | <xsl:otherwise>
|
---|
644 | <xsl:call-template name="emitCppTypeForIDLType">
|
---|
645 | <xsl:with-param name="method" select="$method"/>
|
---|
646 | <xsl:with-param name="type" select="$type"/>
|
---|
647 | <xsl:with-param name="safearray" select="$safearray"/>
|
---|
648 | <xsl:with-param name="inptr" select="'yes'"/>
|
---|
649 | </xsl:call-template>
|
---|
650 | <xsl:choose>
|
---|
651 | <xsl:when test="$type='wstring' or $type='uuid'">
|
---|
652 | <xsl:value-of select="concat(' comcall_', $name, '(', $structprefix, $name, '.c_str())')" />
|
---|
653 | </xsl:when>
|
---|
654 | <xsl:when test="count(key('G_keyEnumsByName', $type)) > 0">
|
---|
655 | <xsl:value-of select="concat(' comcall_', $name, ' = ', $G_funcPrefixInputEnumConverter, $type, '(', $structprefix, $name, ')')" />
|
---|
656 | </xsl:when>
|
---|
657 | <xsl:when test="$type='$unknown'">
|
---|
658 | <xsl:value-of select="concat(' comcall_', $name, ';')" />
|
---|
659 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
660 | <xsl:value-of select="concat('if ((rc = findComPtrFromId(soap, ', $structprefix, $name, ', comcall_', $name,', true)) != S_OK)')" />
|
---|
661 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
662 | <xsl:text> break</xsl:text>
|
---|
663 | </xsl:when>
|
---|
664 | <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
|
---|
665 | <!-- the type is one of our own interfaces: then it must have a wsmap attr -->
|
---|
666 | <xsl:variable name="thatif" select="key('G_keyInterfacesByName', $type)" />
|
---|
667 | <xsl:variable name="wsmap" select="$thatif/@wsmap" />
|
---|
668 | <xsl:variable name="thatifname" select="$thatif/@name" />
|
---|
669 | <xsl:choose>
|
---|
670 | <xsl:when test="not($wsmap)">
|
---|
671 | <xsl:call-template name="fatalError">
|
---|
672 | <xsl:with-param name="msg" select="concat('emitInputArgConverter: Type "', $type, '" in arg "', $name, '" of method "', $method, '" lacks wsmap attribute in XIDL.')" />
|
---|
673 | </xsl:call-template>
|
---|
674 | </xsl:when>
|
---|
675 | <xsl:when test="($wsmap='managed')">
|
---|
676 | <xsl:value-of select="concat(' comcall_', $name, ';')" />
|
---|
677 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
678 | <xsl:value-of select="concat('if ((rc = findComPtrFromId(soap, ', $structprefix, $name, ', comcall_', $name,', true)) != S_OK)')" />
|
---|
679 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
680 | <xsl:text> break</xsl:text>
|
---|
681 | </xsl:when>
|
---|
682 | <xsl:otherwise>
|
---|
683 | <xsl:call-template name="fatalError">
|
---|
684 | <xsl:with-param name="msg" select="concat('emitInputArgConverter: Type "', $type, '" in arg "', $name, '" of method "', $method, '" has unsupported wsmap attribute value "', $wsmap, '" in XIDL.')" />
|
---|
685 | </xsl:call-template>
|
---|
686 | </xsl:otherwise>
|
---|
687 | </xsl:choose>
|
---|
688 | </xsl:when>
|
---|
689 | <xsl:otherwise>
|
---|
690 | <xsl:value-of select="concat(' comcall_', $name, ' = ', $structprefix, $name)" />
|
---|
691 | </xsl:otherwise>
|
---|
692 | </xsl:choose>
|
---|
693 | <xsl:text>;
|
---|
694 | </xsl:text>
|
---|
695 | </xsl:otherwise>
|
---|
696 | </xsl:choose>
|
---|
697 |
|
---|
698 | </xsl:template>
|
---|
699 |
|
---|
700 | <!--
|
---|
701 | emitTypeOrArray
|
---|
702 | -->
|
---|
703 |
|
---|
704 | <xsl:template name="emitTypeOrArray">
|
---|
705 | <xsl:param name="type" />
|
---|
706 | <xsl:param name="safearray" />
|
---|
707 |
|
---|
708 | <xsl:choose>
|
---|
709 | <xsl:when test="$safearray='yes'">
|
---|
710 | <xsl:value-of select="concat('com::SafeArray<', $type, '>')" />
|
---|
711 | </xsl:when>
|
---|
712 | <xsl:otherwise>
|
---|
713 | <xsl:value-of select="$type" />
|
---|
714 | </xsl:otherwise>
|
---|
715 | </xsl:choose>
|
---|
716 | </xsl:template>
|
---|
717 |
|
---|
718 | <!--
|
---|
719 | emitOutputArgBuffer:
|
---|
720 | another type converter (from wsdl type to COM types)
|
---|
721 | that generates a buffer variable which receives the
|
---|
722 | data from 'out' and 'return' parameters of the COM method call.
|
---|
723 | -->
|
---|
724 | <xsl:template name="emitOutputArgBuffer">
|
---|
725 | <xsl:param name="method" />
|
---|
726 | <xsl:param name="name" />
|
---|
727 | <xsl:param name="type" />
|
---|
728 | <xsl:param name="safearray" />
|
---|
729 | <xsl:param name="varprefix" /> <!-- only with nested get-attribute calls -->
|
---|
730 |
|
---|
731 | <xsl:text> // com output arg for </xsl:text><xsl:value-of select="concat($name, ' (safearray: ', $safearray, ')')" /><xsl:text>
|
---|
732 | </xsl:text>
|
---|
733 | <xsl:call-template name="emitCppTypeForIDLType">
|
---|
734 | <xsl:with-param name="method" select="$method" />
|
---|
735 | <xsl:with-param name="type" select="$type" />
|
---|
736 | <xsl:with-param name="safearray" select="$safearray" />
|
---|
737 | </xsl:call-template>
|
---|
738 | <xsl:value-of select="concat(' comcall_', $varprefix, $name, ';')" />
|
---|
739 | <xsl:call-template name="emitNewline" />
|
---|
740 | </xsl:template>
|
---|
741 |
|
---|
742 | <!--
|
---|
743 | emitInParam:
|
---|
744 | -->
|
---|
745 | <xsl:template name="emitInParam">
|
---|
746 | <xsl:param name="name" />
|
---|
747 | <xsl:param name="type" />
|
---|
748 | <xsl:param name="safearray" />
|
---|
749 | <xsl:param name="varprefix" /> <!-- only with nested set-attribute calls -->
|
---|
750 |
|
---|
751 | <xsl:variable name="varname" select="concat('comcall_', $varprefix, $name)" />
|
---|
752 |
|
---|
753 | <xsl:choose>
|
---|
754 | <xsl:when test="@safearray='yes'">
|
---|
755 | <xsl:value-of select="concat('ComSafeArrayAsInParam(', $varname, ')')" />
|
---|
756 | </xsl:when>
|
---|
757 | <xsl:otherwise>
|
---|
758 | <xsl:value-of select="$varname" />
|
---|
759 | <xsl:if test="@type='wstring' or @type='uuid'">
|
---|
760 | <xsl:text>.raw()</xsl:text>
|
---|
761 | </xsl:if>
|
---|
762 | </xsl:otherwise>
|
---|
763 | </xsl:choose>
|
---|
764 | </xsl:template>
|
---|
765 |
|
---|
766 | <!--
|
---|
767 | emitOutParam:
|
---|
768 | -->
|
---|
769 | <xsl:template name="emitOutParam">
|
---|
770 | <xsl:param name="name" />
|
---|
771 | <xsl:param name="type" />
|
---|
772 | <xsl:param name="safearray" />
|
---|
773 | <xsl:param name="varprefix" /> <!-- only with nested get-attribute calls -->
|
---|
774 |
|
---|
775 | <xsl:variable name="varname" select="concat('comcall_', $varprefix, $name)" />
|
---|
776 |
|
---|
777 | <xsl:choose>
|
---|
778 | <xsl:when test="$safearray='yes'">
|
---|
779 | <xsl:value-of select="concat('ComSafeArrayAsOutParam(', $varname, ')')" />
|
---|
780 | </xsl:when>
|
---|
781 | <xsl:otherwise>
|
---|
782 | <xsl:choose>
|
---|
783 | <xsl:when test=" ($type='boolean')
|
---|
784 | or ($type='short')
|
---|
785 | or ($type='unsigned short')
|
---|
786 | or ($type='long')
|
---|
787 | or ($type='unsigned long')
|
---|
788 | or ($type='long long')
|
---|
789 | or ($type='unsigned long long')
|
---|
790 | or ($type='result')
|
---|
791 | or (count(key('G_keyEnumsByName', $type)) > 0)">
|
---|
792 | <xsl:text>&</xsl:text><xsl:value-of select="$varname" />
|
---|
793 | </xsl:when>
|
---|
794 | <xsl:otherwise>
|
---|
795 | <xsl:value-of select="$varname" /><xsl:text>.asOutParam()</xsl:text>
|
---|
796 | </xsl:otherwise>
|
---|
797 | </xsl:choose>
|
---|
798 | </xsl:otherwise>
|
---|
799 | </xsl:choose>
|
---|
800 | </xsl:template>
|
---|
801 |
|
---|
802 | <!--
|
---|
803 | emitComCall:
|
---|
804 | emits the actual method call with the arguments.
|
---|
805 | -->
|
---|
806 | <xsl:template name="emitComCall">
|
---|
807 | <xsl:param name="ifname" />
|
---|
808 | <xsl:param name="object" /> <!-- normally "pObj" -->
|
---|
809 | <xsl:param name="methodname" />
|
---|
810 | <xsl:param name="attrname" /> <!-- with attributes only -->
|
---|
811 | <xsl:param name="attrtype" /> <!-- with attributes only -->
|
---|
812 | <xsl:param name="attrsafearray" /> <!-- with attributes only -->
|
---|
813 | <xsl:param name="attrdir" /> <!-- with attributes only: "in" or "return" -->
|
---|
814 | <xsl:param name="varprefix" /> <!-- only with nested get-attribute calls -->
|
---|
815 |
|
---|
816 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
817 | <xsl:value-of select="concat('WEBDEBUG((g_pcszCallingComMethod, "', $methodname, '"));')" />
|
---|
818 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
819 | <xsl:value-of select="concat('rc = ', $object, '->', $methodname, '(')" />
|
---|
820 | <xsl:if test="$attrtype">
|
---|
821 | <xsl:choose>
|
---|
822 | <xsl:when test="$attrdir='in'">
|
---|
823 | <xsl:call-template name="emitInParam">
|
---|
824 | <xsl:with-param name="name" select="$attrname" />
|
---|
825 | <xsl:with-param name="type" select="$attrtype" />
|
---|
826 | <xsl:with-param name="safearray" select="$attrsafearray" />
|
---|
827 | <xsl:with-param name="varprefix" select="$varprefix" />
|
---|
828 | </xsl:call-template>
|
---|
829 | </xsl:when>
|
---|
830 | <xsl:when test="$attrdir='return'">
|
---|
831 | <xsl:call-template name="emitOutParam">
|
---|
832 | <xsl:with-param name="name" select="$attrname" />
|
---|
833 | <xsl:with-param name="type" select="$attrtype" />
|
---|
834 | <xsl:with-param name="safearray" select="$attrsafearray" />
|
---|
835 | <xsl:with-param name="varprefix" select="$varprefix" />
|
---|
836 | </xsl:call-template>
|
---|
837 | </xsl:when>
|
---|
838 | </xsl:choose>
|
---|
839 | </xsl:if>
|
---|
840 | <xsl:for-each select="param">
|
---|
841 | <xsl:if test="position()=1">
|
---|
842 | <xsl:call-template name="emitNewline" />
|
---|
843 | </xsl:if>
|
---|
844 | <xsl:if test="position() > 1">
|
---|
845 | <xsl:text>,</xsl:text>
|
---|
846 | <xsl:call-template name="emitNewline" />
|
---|
847 | </xsl:if>
|
---|
848 | <xsl:text> </xsl:text>
|
---|
849 | <xsl:choose>
|
---|
850 | <xsl:when test="@dir='in'">
|
---|
851 | <xsl:call-template name="emitInParam">
|
---|
852 | <xsl:with-param name="name" select="@name" />
|
---|
853 | <xsl:with-param name="type" select="@type" />
|
---|
854 | <xsl:with-param name="safearray" select="@safearray" />
|
---|
855 | <xsl:with-param name="varprefix" select="$varprefix" />
|
---|
856 | </xsl:call-template>
|
---|
857 | </xsl:when>
|
---|
858 | <xsl:when test="@dir='out'">
|
---|
859 | <xsl:call-template name="emitOutParam">
|
---|
860 | <xsl:with-param name="name" select="@name" />
|
---|
861 | <xsl:with-param name="type" select="@type" />
|
---|
862 | <xsl:with-param name="safearray" select="@safearray" />
|
---|
863 | <xsl:with-param name="varprefix" select="$varprefix" />
|
---|
864 | </xsl:call-template>
|
---|
865 | </xsl:when>
|
---|
866 | <xsl:when test="@dir='return'">
|
---|
867 | <xsl:call-template name="emitOutParam">
|
---|
868 | <xsl:with-param name="name" select="$G_result" />
|
---|
869 | <xsl:with-param name="type" select="@type" />
|
---|
870 | <xsl:with-param name="safearray" select="@safearray" />
|
---|
871 | <xsl:with-param name="varprefix" select="$varprefix" />
|
---|
872 | </xsl:call-template>
|
---|
873 | </xsl:when>
|
---|
874 | </xsl:choose>
|
---|
875 | </xsl:for-each>
|
---|
876 | <xsl:text>);</xsl:text>
|
---|
877 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
878 | <xsl:text>if (FAILED(rc))</xsl:text>
|
---|
879 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
880 | <xsl:text>{</xsl:text>
|
---|
881 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
882 | <xsl:value-of select="concat(' RaiseSoapRuntimeFault(soap, idThis, "', $ifname, '::', $methodname,'", rc, ', $object, ', COM_IIDOF(', $ifname, '));')" />
|
---|
883 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
884 | <xsl:text> break;</xsl:text>
|
---|
885 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
886 | <xsl:text>}</xsl:text>
|
---|
887 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
888 | <xsl:text>WEBDEBUG((g_pcszDoneCallingComMethod));</xsl:text>
|
---|
889 | <xsl:call-template name="emitNewline" />
|
---|
890 | </xsl:template>
|
---|
891 |
|
---|
892 | <!--
|
---|
893 | emitOutputArgBackConverter2: implementation details of emitOutputArgBackConverter.
|
---|
894 | -->
|
---|
895 |
|
---|
896 | <xsl:template name="emitOutputArgBackConverter2">
|
---|
897 | <xsl:param name="name" />
|
---|
898 | <xsl:param name="varname" />
|
---|
899 | <xsl:param name="type" />
|
---|
900 | <xsl:param name="callerprefix" />
|
---|
901 |
|
---|
902 | <xsl:choose>
|
---|
903 | <xsl:when test="$type='wstring' or $type='uuid'">
|
---|
904 | <xsl:value-of select="concat('ConvertComString(', $varname, ')')" />
|
---|
905 | </xsl:when>
|
---|
906 | <xsl:when test="$type='boolean'">
|
---|
907 | <!-- the "!!" avoids a microsoft compiler warning -->
|
---|
908 | <xsl:value-of select="concat('!!', $varname)" />
|
---|
909 | </xsl:when>
|
---|
910 | <xsl:when test=" ($type='octet')
|
---|
911 | or ($type='short')
|
---|
912 | or ($type='unsigned short')
|
---|
913 | or ($type='long')
|
---|
914 | or ($type='unsigned long')
|
---|
915 | or ($type='long long')
|
---|
916 | or ($type='unsigned long long')
|
---|
917 | or ($type='result')">
|
---|
918 | <xsl:value-of select="$varname" />
|
---|
919 | </xsl:when>
|
---|
920 | <xsl:when test="count(key('G_keyEnumsByName', $type)) > 0">
|
---|
921 | <xsl:value-of select="concat($G_funcPrefixOutputEnumConverter, $type, '(', $varname, ')')" />
|
---|
922 | </xsl:when>
|
---|
923 | <xsl:when test="$type='$unknown'">
|
---|
924 | <xsl:value-of select="concat('createOrFindRefFromComPtr(idThis, g_pcszIUnknown, ', $varname, ')')" />
|
---|
925 | </xsl:when>
|
---|
926 | <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
|
---|
927 | <!-- the type is one of our own interfaces: then it must have a wsmap attr -->
|
---|
928 | <xsl:variable name="thatif" select="key('G_keyInterfacesByName', $type)" />
|
---|
929 | <xsl:variable name="wsmap" select="$thatif/@wsmap" />
|
---|
930 | <xsl:variable name="thatifname" select="$thatif/@name" />
|
---|
931 | <xsl:choose>
|
---|
932 | <xsl:when test=" ($wsmap='managed') or ($wsmap='global')">
|
---|
933 | <xsl:value-of select="concat('createOrFindRefFromComPtr(idThis, g_pcsz', $thatifname, ', ', $varname, ')')" />
|
---|
934 | </xsl:when>
|
---|
935 | <xsl:when test="$wsmap='struct'">
|
---|
936 | <!-- prevent infinite recursion -->
|
---|
937 | <!-- <xsl:call-template name="fatalError"><xsl:with-param name="msg" select="concat('emitOutputArgBackConverter2: attempted infinite recursion for type "', $type, '" in arg "', $name, '" of method "', $ifname, '::', $method)" /></xsl:call-template> -->
|
---|
938 | <xsl:if test="not($callerprefix)">
|
---|
939 | <xsl:value-of select="concat('/* convert COM interface to struct */ ', $G_funcPrefixOutputStructConverter, $type, '(soap, idThis, rc, ', $varname, ')')" />
|
---|
940 | </xsl:if>
|
---|
941 | </xsl:when>
|
---|
942 | <xsl:otherwise>
|
---|
943 | <xsl:call-template name="fatalError">
|
---|
944 | <xsl:with-param name="msg" select="concat('emitOutputArgBackConverter2: Type "', $type, '" in arg "', $name, '" of method "', $thatifname, '::', $method, '" has invalid wsmap attribute value "', $wsmap, '" in XIDL.')" />
|
---|
945 | </xsl:call-template>
|
---|
946 | </xsl:otherwise>
|
---|
947 | </xsl:choose>
|
---|
948 | </xsl:when>
|
---|
949 | <xsl:otherwise>
|
---|
950 | <xsl:call-template name="fatalError">
|
---|
951 | <xsl:with-param name="msg" select="concat('emitOutputArgBackConverter2: Type "', $type, '" in arg "', $name, '" of method "', $method, '" is not supported.')" />
|
---|
952 | </xsl:call-template>
|
---|
953 | </xsl:otherwise>
|
---|
954 | </xsl:choose>
|
---|
955 |
|
---|
956 | </xsl:template>
|
---|
957 |
|
---|
958 | <!--
|
---|
959 | emitOutputArgBackConverter:
|
---|
960 | another type converter (from COM type back to WSDL)
|
---|
961 | which converts the output argument from the COM
|
---|
962 | method call back to the WSDL type passed in by the
|
---|
963 | caller.
|
---|
964 | -->
|
---|
965 | <xsl:template name="emitOutputArgBackConverter">
|
---|
966 | <xsl:param name="ifname" />
|
---|
967 | <xsl:param name="method" />
|
---|
968 | <xsl:param name="name" />
|
---|
969 | <xsl:param name="type" />
|
---|
970 | <xsl:param name="safearray" />
|
---|
971 | <xsl:param name="varprefix" /> <!-- only when called recursively from emitGetAttributeComCall -->
|
---|
972 | <xsl:param name="callerprefix" /> <!-- only for out params or when called recursively from emitGetAttributeComCall -->
|
---|
973 |
|
---|
974 | <xsl:variable name="topname" select="$name" />
|
---|
975 | <xsl:variable name="varname" select="concat('comcall_', $varprefix, $name)" />
|
---|
976 |
|
---|
977 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
978 | <xsl:value-of select="concat('WEBDEBUG((g_pcszConvertComOutputBack, "', $name, '"));')" />
|
---|
979 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
980 |
|
---|
981 | <xsl:variable name="receiverVariable">
|
---|
982 | <xsl:choose>
|
---|
983 | <xsl:when test="(not($varprefix))">
|
---|
984 | <xsl:choose>
|
---|
985 | <xsl:when test="$callerprefix"> <!-- callerprefix set but varprefix not: then this is an out parameter :-) -->
|
---|
986 | <xsl:value-of select="concat($G_responseElementVarName, '->', $name)" />
|
---|
987 | </xsl:when>
|
---|
988 | <xsl:otherwise>
|
---|
989 | <xsl:value-of select="concat($G_responseElementVarName, '->', $G_result)" />
|
---|
990 | </xsl:otherwise>
|
---|
991 | </xsl:choose>
|
---|
992 | </xsl:when>
|
---|
993 | <xsl:otherwise>
|
---|
994 | <xsl:value-of select="concat($callerprefix, $G_result, '->', $name)" />
|
---|
995 | </xsl:otherwise>
|
---|
996 | </xsl:choose>
|
---|
997 | </xsl:variable>
|
---|
998 |
|
---|
999 | <xsl:choose>
|
---|
1000 | <xsl:when test="$safearray='yes' and $type='octet'">
|
---|
1001 | <xsl:value-of select="concat($receiverVariable, ' = Base64EncodeByteArray(ComSafeArrayAsInParam(', $varname,'));')" />
|
---|
1002 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
1003 | </xsl:when>
|
---|
1004 |
|
---|
1005 | <xsl:when test="$safearray='yes'">
|
---|
1006 | <xsl:value-of select="concat('for (size_t i = 0; i < ', $varname, '.size(); ++i)')" />
|
---|
1007 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
1008 | <xsl:value-of select="'{'" />
|
---|
1009 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
1010 | <!-- look up C++ glue type from IDL type from table array in typemap-shared.inc.xsl -->
|
---|
1011 | <xsl:variable name="gluetypefield" select="exsl:node-set($G_aSharedTypes)/type[@idlname=$type]/@gluename" />
|
---|
1012 | <xsl:choose>
|
---|
1013 | <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
|
---|
1014 | <xsl:value-of select="concat(' ComPtr<', $type, '> tmpObject(', $varname, '[i]);')" />
|
---|
1015 | </xsl:when>
|
---|
1016 | <xsl:when test="count(key('G_keyEnumsByName', $type)) > 0">
|
---|
1017 | <xsl:value-of select="concat(' ', $type, '_T tmpObject(', $varname, '[i]);')" />
|
---|
1018 | </xsl:when>
|
---|
1019 | <xsl:when test="$type='$unknown'">
|
---|
1020 | <xsl:value-of select="concat(' ComPtr<IUnknown> tmpObject(', $varname, '[i]);')" />
|
---|
1021 | </xsl:when>
|
---|
1022 | <xsl:when test="$type='wstring' or $type='uuid'">
|
---|
1023 | <xsl:value-of select="concat(' com::Bstr tmpObject(', $varname, '[i]);')" />
|
---|
1024 | </xsl:when>
|
---|
1025 | <xsl:when test="$gluetypefield">
|
---|
1026 | <xsl:value-of select="concat(' ', $gluetypefield, ' tmpObject(', $varname, '[i]);')" />
|
---|
1027 | </xsl:when>
|
---|
1028 | <xsl:otherwise>
|
---|
1029 | <xsl:call-template name="fatalError">
|
---|
1030 | <xsl:with-param name="msg" select="concat('emitOutputArgBackConverter (1): Type "', $type, '" in arg "', $name, '" of method "', $method, '" is not yet supported in safearrays.')" />
|
---|
1031 | </xsl:call-template>
|
---|
1032 |
|
---|
1033 | </xsl:otherwise>
|
---|
1034 | </xsl:choose>
|
---|
1035 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
1036 | <xsl:value-of select="concat(' ', $receiverVariable, '.push_back(')" />
|
---|
1037 | <xsl:call-template name="emitOutputArgBackConverter2">
|
---|
1038 | <xsl:with-param name="name" select="$name"/>
|
---|
1039 | <xsl:with-param name="varname" select="'tmpObject'"/>
|
---|
1040 | <xsl:with-param name="type" select="$type"/>
|
---|
1041 | <xsl:with-param name="callerprefix" select="$callerprefix"/>
|
---|
1042 | </xsl:call-template>
|
---|
1043 | <xsl:value-of select="');'" />
|
---|
1044 | <xsl:call-template name="emitNewlineIndent8" />
|
---|
1045 | <xsl:value-of select="'}'" />
|
---|
1046 | <xsl:call-template name="emitNewline" />
|
---|
1047 | </xsl:when>
|
---|
1048 | <xsl:otherwise>
|
---|
1049 | <!-- emit variable name: "resp->retval = " -->
|
---|
1050 | <xsl:value-of select="$receiverVariable" />
|
---|
1051 |
|
---|
1052 | <xsl:value-of select="' = '" />
|
---|
1053 | <xsl:call-template name="emitOutputArgBackConverter2">
|
---|
1054 | <xsl:with-param name="name" select="$name"/>
|
---|
1055 | <xsl:with-param name="varname" select="$varname"/>
|
---|
1056 | <xsl:with-param name="type" select="$type"/>
|
---|
1057 | <xsl:with-param name="callerprefix" select="$callerprefix"/>
|
---|
1058 | </xsl:call-template>
|
---|
1059 | <xsl:value-of select="';'" />
|
---|
1060 | <xsl:call-template name="emitNewline" />
|
---|
1061 |
|
---|
1062 | </xsl:otherwise>
|
---|
1063 | </xsl:choose>
|
---|
1064 |
|
---|
1065 | <xsl:value-of select="concat(' WEBDEBUG((g_pcszDoneConvertingComOutputBack, "', $name, '"));')" />
|
---|
1066 | <xsl:call-template name="emitNewline" />
|
---|
1067 | </xsl:template>
|
---|
1068 |
|
---|
1069 | <!--
|
---|
1070 | emitGetAttributeComCall
|
---|
1071 | -->
|
---|
1072 | <xsl:template name="emitGetAttributeComCall">
|
---|
1073 | <xsl:param name="ifname" />
|
---|
1074 | <xsl:param name="object" /> <!-- normally "pObj->" -->
|
---|
1075 | <xsl:param name="attrname" />
|
---|
1076 | <xsl:param name="attrtype" />
|
---|
1077 | <xsl:param name="attrsafearray" />
|
---|
1078 | <xsl:param name="varprefix" /> <!-- only when called recursively from emitOutputArgBackConverter-->
|
---|
1079 | <xsl:param name="callerprefix" /> <!-- only when called recursively from emitOutputArgBackConverter-->
|
---|
1080 |
|
---|
1081 | <xsl:variable name="gettername"><xsl:call-template name="makeGetterName"><xsl:with-param name="attrname" select="$attrname" /></xsl:call-template></xsl:variable>
|
---|
1082 | <xsl:call-template name="emitOutputArgBuffer">
|
---|
1083 | <xsl:with-param name="ifname"><xsl:value-of select="$ifname" /></xsl:with-param>
|
---|
1084 | <xsl:with-param name="method"><xsl:value-of select="$gettername" /></xsl:with-param>
|
---|
1085 | <xsl:with-param name="name" select="$attrname" />
|
---|
1086 | <xsl:with-param name="type" select="$attrtype" />
|
---|
1087 | <xsl:with-param name="safearray" select="$attrsafearray" />
|
---|
1088 | <xsl:with-param name="varprefix" select="$varprefix" />
|
---|
1089 | </xsl:call-template>
|
---|
1090 | <xsl:variable name="upperattrname"><xsl:call-template name="capitalize"><xsl:with-param name="str" select="$attrname" /></xsl:call-template></xsl:variable>
|
---|
1091 | <!-- actual COM method call -->
|
---|
1092 | <xsl:call-template name="emitComCall">
|
---|
1093 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
1094 | <xsl:with-param name="methodname" select="concat('COMGETTER(', $upperattrname, ')')" />
|
---|
1095 | <xsl:with-param name="object" select="$object" />
|
---|
1096 | <xsl:with-param name="attrname" select="$attrname" />
|
---|
1097 | <xsl:with-param name="attrtype" select="$attrtype" />
|
---|
1098 | <xsl:with-param name="attrsafearray" select="$attrsafearray" />
|
---|
1099 | <xsl:with-param name="attrdir" select="'return'" />
|
---|
1100 | <xsl:with-param name="varprefix" select="$varprefix" />
|
---|
1101 | </xsl:call-template>
|
---|
1102 | <!-- convert back the output data -->
|
---|
1103 | <xsl:call-template name="emitOutputArgBackConverter">
|
---|
1104 | <xsl:with-param name="ifname"><xsl:value-of select="$ifname" /></xsl:with-param>
|
---|
1105 | <xsl:with-param name="method"><xsl:value-of select="$gettername" /></xsl:with-param>
|
---|
1106 | <xsl:with-param name="name" select="$attrname" />
|
---|
1107 | <xsl:with-param name="type" select="$attrtype" />
|
---|
1108 | <xsl:with-param name="safearray" select="$attrsafearray" />
|
---|
1109 | <xsl:with-param name="varprefix" select="$varprefix" />
|
---|
1110 | <xsl:with-param name="callerprefix" select="$callerprefix" />
|
---|
1111 | </xsl:call-template>
|
---|
1112 | </xsl:template>
|
---|
1113 |
|
---|
1114 | <!--
|
---|
1115 | emitSetAttributeComCall
|
---|
1116 | -->
|
---|
1117 | <xsl:template name="emitSetAttributeComCall">
|
---|
1118 | <xsl:param name="ifname" />
|
---|
1119 | <xsl:param name="object" /> <!-- normally "pObj->" -->
|
---|
1120 | <xsl:param name="attrname" />
|
---|
1121 | <xsl:param name="attrtype" />
|
---|
1122 | <xsl:param name="attrsafearray" />
|
---|
1123 | <xsl:param name="callerprefix" /> <!-- only when called recursively from emitOutputArgBackConverter-->
|
---|
1124 |
|
---|
1125 | <xsl:variable name="settername"><xsl:call-template name="makeSetterName"><xsl:with-param name="attrname" select="$attrname" /></xsl:call-template></xsl:variable>
|
---|
1126 | <xsl:variable name="upperattrname"><xsl:call-template name="capitalize"><xsl:with-param name="str" select="$attrname" /></xsl:call-template></xsl:variable>
|
---|
1127 |
|
---|
1128 | <xsl:call-template name="emitInputArgConverter">
|
---|
1129 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
1130 | <xsl:with-param name="method" select="concat($ifname, '::', $settername)" />
|
---|
1131 | <xsl:with-param name="methodname" select="concat('COMSETTER(', $upperattrname, ')')" />
|
---|
1132 | <xsl:with-param name="object" select="$object" />
|
---|
1133 | <xsl:with-param name="name" select="$attrname" />
|
---|
1134 | <xsl:with-param name="structprefix" select="concat($G_requestElementVarName, '->')" />
|
---|
1135 | <xsl:with-param name="type" select="$attrtype" />
|
---|
1136 | <xsl:with-param name="safearray" select="$attrsafearray" />
|
---|
1137 | </xsl:call-template>
|
---|
1138 | <xsl:call-template name="emitComCall">
|
---|
1139 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
1140 | <xsl:with-param name="methodname" select="concat('COMSETTER(', $upperattrname, ')')" />
|
---|
1141 | <xsl:with-param name="object" select="$object" />
|
---|
1142 | <xsl:with-param name="attrname" select="$attrname" />
|
---|
1143 | <xsl:with-param name="attrtype" select="$attrtype" />
|
---|
1144 | <xsl:with-param name="attrsafearray" select="$attrsafearray" />
|
---|
1145 | <xsl:with-param name="attrdir" select="'in'" />
|
---|
1146 | </xsl:call-template>
|
---|
1147 | </xsl:template>
|
---|
1148 |
|
---|
1149 | <!--
|
---|
1150 | emitGetAttributeMapper
|
---|
1151 | -->
|
---|
1152 | <xsl:template name="emitGetAttributeMapper">
|
---|
1153 | <xsl:param name="ifname" />
|
---|
1154 | <xsl:param name="wsmap" />
|
---|
1155 | <xsl:param name="attrname" />
|
---|
1156 | <xsl:param name="attrtype" />
|
---|
1157 | <xsl:param name="attrreadonly" />
|
---|
1158 | <xsl:param name="attrsafearray" />
|
---|
1159 |
|
---|
1160 | <xsl:variable name="gettername"><xsl:call-template name="makeGetterName"><xsl:with-param name="attrname" select="$attrname" /></xsl:call-template></xsl:variable>
|
---|
1161 |
|
---|
1162 | <xsl:call-template name="emitBeginOfFunctionHeader">
|
---|
1163 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
1164 | <xsl:with-param name="method" select="$gettername" />
|
---|
1165 | </xsl:call-template>
|
---|
1166 |
|
---|
1167 | <xsl:call-template name="emitDocumentStyleArgStructs">
|
---|
1168 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
1169 | <xsl:with-param name="methodname" select="$gettername" />
|
---|
1170 | <xsl:with-param name="fOutputs" select="$attrtype" />
|
---|
1171 | </xsl:call-template>
|
---|
1172 |
|
---|
1173 | <xsl:text>)</xsl:text>
|
---|
1174 | <xsl:call-template name="emitNewline" />
|
---|
1175 | <xsl:text>{</xsl:text>
|
---|
1176 | <xsl:call-template name="emitNewline" />
|
---|
1177 |
|
---|
1178 | <xsl:value-of select="' HRESULT rc = S_OK;'" />
|
---|
1179 | <xsl:call-template name="emitNewline" />
|
---|
1180 |
|
---|
1181 | <xsl:call-template name="emitPrologue" />
|
---|
1182 |
|
---|
1183 | <!-- actual COM method call -->
|
---|
1184 | <!-- <xsl:choose>
|
---|
1185 | array attributes/parameters are not supported yet...
|
---|
1186 | <xsl:when test="@array or @safearray='yes'">
|
---|
1187 | <xsl:call-template name="warning"><xsl:with-param name="msg" select="concat('emitComCall: SKIPPING ATTRIBUTE IMPLEMENTATION for "', $attrname, '" because it has array type. THIS SOAP METHOD WILL NOT DO ANYTHING!')" /></xsl:call-template>
|
---|
1188 | </xsl:when>
|
---|
1189 | <xsl:otherwise> -->
|
---|
1190 | <xsl:call-template name="emitObjForMethod">
|
---|
1191 | <xsl:with-param name="ifname"><xsl:value-of select="$ifname" /></xsl:with-param>
|
---|
1192 | <xsl:with-param name="wsmap"><xsl:value-of select="$wsmap" /></xsl:with-param>
|
---|
1193 | <xsl:with-param name="structprefix" select="concat($G_requestElementVarName, '->')" />
|
---|
1194 | </xsl:call-template>
|
---|
1195 |
|
---|
1196 | <xsl:call-template name="emitGetAttributeComCall">
|
---|
1197 | <xsl:with-param name="ifname"><xsl:value-of select="$ifname" /></xsl:with-param>
|
---|
1198 | <xsl:with-param name="object" select='"pObj"' />
|
---|
1199 | <xsl:with-param name="attrname"><xsl:value-of select="$attrname" /></xsl:with-param>
|
---|
1200 | <xsl:with-param name="attrtype"><xsl:value-of select="$attrtype" /></xsl:with-param>
|
---|
1201 | <xsl:with-param name="attrsafearray"><xsl:value-of select="$attrsafearray" /></xsl:with-param>
|
---|
1202 | </xsl:call-template>
|
---|
1203 | <!-- </xsl:otherwise>
|
---|
1204 | </xsl:choose> -->
|
---|
1205 |
|
---|
1206 | <xsl:call-template name="emitEpilogue" />
|
---|
1207 | </xsl:template>
|
---|
1208 |
|
---|
1209 | <!--
|
---|
1210 | emitSetAttributeMapper:
|
---|
1211 | -->
|
---|
1212 | <xsl:template name="emitSetAttributeMapper">
|
---|
1213 | <xsl:param name="ifname" select="$ifname" />
|
---|
1214 | <xsl:param name="wsmap" select="$wsmap" />
|
---|
1215 | <xsl:param name="attrname" select="$attrname" />
|
---|
1216 | <xsl:param name="attrtype" select="$attrtype" />
|
---|
1217 | <xsl:param name="attrreadonly" select="$attrreadonly" />
|
---|
1218 | <xsl:param name="attrsafearray" select="$attrsafearray" />
|
---|
1219 |
|
---|
1220 | <xsl:variable name="settername"><xsl:call-template name="makeSetterName"><xsl:with-param name="attrname" select="$attrname" /></xsl:call-template></xsl:variable>
|
---|
1221 |
|
---|
1222 | <xsl:call-template name="emitBeginOfFunctionHeader">
|
---|
1223 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
1224 | <xsl:with-param name="method" select="$settername" />
|
---|
1225 | </xsl:call-template>
|
---|
1226 |
|
---|
1227 | <xsl:call-template name="emitDocumentStyleArgStructs">
|
---|
1228 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
1229 | <xsl:with-param name="methodname" select="$settername" />
|
---|
1230 | <xsl:with-param name="fOutputs" select="1" />
|
---|
1231 | </xsl:call-template>
|
---|
1232 |
|
---|
1233 | <xsl:text>)</xsl:text>
|
---|
1234 | <xsl:call-template name="emitNewline" />
|
---|
1235 | <xsl:text>{</xsl:text>
|
---|
1236 | <xsl:call-template name="emitNewline" />
|
---|
1237 | <xsl:value-of select="' HRESULT rc = S_OK;'" />
|
---|
1238 | <xsl:value-of select="concat(concat(' NOREF(', $G_responseElementVarName),');')" />
|
---|
1239 | <xsl:call-template name="emitNewline" />
|
---|
1240 | <xsl:call-template name="emitPrologue" />
|
---|
1241 |
|
---|
1242 | <!-- actual COM method call -->
|
---|
1243 | <!-- <xsl:choose>
|
---|
1244 | array attributes/parameters are not supported yet...
|
---|
1245 | <xsl:when test="@array or @safearray='yes'">
|
---|
1246 | <xsl:call-template name="warning"><xsl:with-param name="msg" select="concat('emitComCall: SKIPPING ATTRIBUTE IMPLEMENTATION for "', $attrname, '" because it has array type. THIS SOAP METHOD WILL NOT DO ANYTHING!')" /></xsl:call-template>
|
---|
1247 | </xsl:when>
|
---|
1248 | <xsl:otherwise> -->
|
---|
1249 | <xsl:call-template name="emitObjForMethod">
|
---|
1250 | <xsl:with-param name="ifname"><xsl:value-of select="$ifname" /></xsl:with-param>
|
---|
1251 | <xsl:with-param name="wsmap"><xsl:value-of select="$wsmap" /></xsl:with-param>
|
---|
1252 | <xsl:with-param name="structprefix" select="concat($G_requestElementVarName, '->')" />
|
---|
1253 | </xsl:call-template>
|
---|
1254 | <xsl:call-template name="emitSetAttributeComCall">
|
---|
1255 | <xsl:with-param name="ifname"><xsl:value-of select="$ifname" /></xsl:with-param>
|
---|
1256 | <xsl:with-param name="object" select='"pObj"' />
|
---|
1257 | <xsl:with-param name="attrname"><xsl:value-of select="$attrname" /></xsl:with-param>
|
---|
1258 | <xsl:with-param name="attrtype"><xsl:value-of select="$attrtype" /></xsl:with-param>
|
---|
1259 | <xsl:with-param name="attrsafearray"><xsl:value-of select="$attrsafearray" /></xsl:with-param>
|
---|
1260 | </xsl:call-template>
|
---|
1261 | <!-- </xsl:otherwise>
|
---|
1262 | </xsl:choose> -->
|
---|
1263 |
|
---|
1264 | <xsl:call-template name="emitEpilogue" />
|
---|
1265 | </xsl:template>
|
---|
1266 |
|
---|
1267 | <!-- - - - - - - - - - - - - - - - - - - - - - -
|
---|
1268 | interface
|
---|
1269 | - - - - - - - - - - - - - - - - - - - - - - -->
|
---|
1270 |
|
---|
1271 | <xsl:template match="interface">
|
---|
1272 | <!-- remember the interface name in local variables -->
|
---|
1273 | <xsl:variable name="ifname"><xsl:value-of select="@name" /></xsl:variable>
|
---|
1274 | <xsl:variable name="wsmap"><xsl:value-of select="@wsmap" /></xsl:variable>
|
---|
1275 | <xsl:variable name="wscpp"><xsl:value-of select="@wscpp" /></xsl:variable>
|
---|
1276 |
|
---|
1277 | <!-- we can save ourselves verifying the interface here as it's already
|
---|
1278 | done in the WSDL converter -->
|
---|
1279 |
|
---|
1280 | <xsl:if test='not( ($wsmap="suppress") or ($wsmap="struct") or ($wscpp="hardcoded") )'>
|
---|
1281 | <xsl:text>
|
---|
1282 | /****************************************************************************
|
---|
1283 | *
|
---|
1284 | * interface </xsl:text>
|
---|
1285 | <xsl:copy-of select="$ifname" />
|
---|
1286 | <xsl:text>
|
---|
1287 | *
|
---|
1288 | ****************************************************************************/</xsl:text>
|
---|
1289 | <xsl:call-template name="xsltprocNewlineOutputHack"/>
|
---|
1290 |
|
---|
1291 | <!--
|
---|
1292 | here come the attributes
|
---|
1293 | -->
|
---|
1294 | <xsl:for-each select="attribute">
|
---|
1295 | <xsl:variable name="attrname"><xsl:value-of select="@name" /></xsl:variable>
|
---|
1296 | <xsl:variable name="attrtype"><xsl:value-of select="@type" /></xsl:variable>
|
---|
1297 | <xsl:variable name="attrreadonly"><xsl:value-of select="@readonly" /></xsl:variable>
|
---|
1298 | <xsl:variable name="attrsafearray"><xsl:value-of select="@safearray" /></xsl:variable>
|
---|
1299 | <xsl:call-template name="emitNewline" />
|
---|
1300 | <!-- skip this attribute if it has parameters of a type that has wsmap="suppress" -->
|
---|
1301 | <xsl:choose>
|
---|
1302 | <xsl:when test="( $attrtype=($G_setSuppressedInterfaces/@name) )">
|
---|
1303 | <xsl:value-of select="concat('// Skipping attribute ', $attrname, ' for it is of suppressed type ', $attrtype)" />
|
---|
1304 | </xsl:when>
|
---|
1305 | <xsl:when test="@wsmap = 'suppress'">
|
---|
1306 | <xsl:value-of select="concat('// Skipping attribute ', $attrname, ' for it is suppressed')" />
|
---|
1307 | </xsl:when>
|
---|
1308 | <xsl:otherwise>
|
---|
1309 | <xsl:choose>
|
---|
1310 | <xsl:when test="@readonly='yes'">
|
---|
1311 | <xsl:value-of select="concat('// read-only attribute ', $ifname, '::', $attrname, ' of type ', $attrtype)" />
|
---|
1312 | </xsl:when>
|
---|
1313 | <xsl:otherwise>
|
---|
1314 | <xsl:value-of select="concat('// read/write attribute ', $ifname, '::', $attrname, ' of type ', $attrtype)" />
|
---|
1315 | </xsl:otherwise>
|
---|
1316 | </xsl:choose>
|
---|
1317 | <xsl:value-of select="concat(' (safearray: ', $attrsafearray, ')')" />
|
---|
1318 | <!-- emit getter method -->
|
---|
1319 | <xsl:call-template name="emitGetAttributeMapper">
|
---|
1320 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
1321 | <xsl:with-param name="wsmap" select="$wsmap" />
|
---|
1322 | <xsl:with-param name="attrname" select="$attrname" />
|
---|
1323 | <xsl:with-param name="attrtype" select="$attrtype" />
|
---|
1324 | <xsl:with-param name="attrreadonly" select="$attrreadonly" />
|
---|
1325 | <xsl:with-param name="attrsafearray" select="$attrsafearray" />
|
---|
1326 | </xsl:call-template>
|
---|
1327 | <!-- for read-write attributes, emit setter method -->
|
---|
1328 | <xsl:if test="not(@readonly='yes')">
|
---|
1329 | <xsl:call-template name="emitSetAttributeMapper">
|
---|
1330 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
1331 | <xsl:with-param name="wsmap" select="$wsmap" />
|
---|
1332 | <xsl:with-param name="attrname" select="$attrname" />
|
---|
1333 | <xsl:with-param name="attrtype" select="$attrtype" />
|
---|
1334 | <xsl:with-param name="attrreadonly" select="$attrreadonly" />
|
---|
1335 | <xsl:with-param name="attrsafearray" select="$attrsafearray" />
|
---|
1336 | </xsl:call-template>
|
---|
1337 | </xsl:if>
|
---|
1338 | </xsl:otherwise> <!-- not wsmap=suppress -->
|
---|
1339 | </xsl:choose>
|
---|
1340 | </xsl:for-each>
|
---|
1341 |
|
---|
1342 | <!--
|
---|
1343 | here come the real methods
|
---|
1344 | -->
|
---|
1345 |
|
---|
1346 | <xsl:for-each select="method">
|
---|
1347 | <xsl:variable name="methodname"><xsl:value-of select="@name" /></xsl:variable>
|
---|
1348 | <!-- method header: return value "int", method name, soap arguments -->
|
---|
1349 | <!-- skip this method if it has parameters of a type that has wsmap="suppress" -->
|
---|
1350 | <xsl:choose>
|
---|
1351 | <xsl:when test=" (param[@type=($G_setSuppressedInterfaces/@name)])
|
---|
1352 | or (param[@mod='ptr'])" >
|
---|
1353 | <xsl:comment><xsl:value-of select="concat('Skipping method ', $methodname, ' for it has parameters with suppressed types')" /></xsl:comment>
|
---|
1354 | </xsl:when>
|
---|
1355 | <xsl:when test="@wsmap = 'suppress'">
|
---|
1356 | <xsl:comment><xsl:value-of select="concat('Skipping method ', $methodname, ' for it is suppressed')" /></xsl:comment>
|
---|
1357 | </xsl:when>
|
---|
1358 | <xsl:otherwise>
|
---|
1359 | <xsl:variable name="fHasReturnParms" select="param[@dir='return']" />
|
---|
1360 | <xsl:variable name="fHasOutParms" select="param[@dir='out']" />
|
---|
1361 |
|
---|
1362 | <xsl:call-template name="emitNewline" />
|
---|
1363 | <xsl:value-of select="concat('/* method ', $ifname, '::', $methodname, '(')" />
|
---|
1364 | <xsl:for-each select="param">
|
---|
1365 | <xsl:call-template name="emitNewline" />
|
---|
1366 | <xsl:value-of select="concat(' [', @dir, '] ', @type, ' ', @name)" />
|
---|
1367 | <xsl:if test="@safearray='yes'">
|
---|
1368 | <xsl:text>[]</xsl:text>
|
---|
1369 | </xsl:if>
|
---|
1370 | <xsl:if test="not(position()=last())">
|
---|
1371 | <xsl:text>,</xsl:text>
|
---|
1372 | </xsl:if>
|
---|
1373 | </xsl:for-each>
|
---|
1374 | <xsl:text>)</xsl:text>
|
---|
1375 | <xsl:call-template name="emitNewline" />
|
---|
1376 | <xsl:text> */</xsl:text>
|
---|
1377 |
|
---|
1378 | <xsl:call-template name="emitBeginOfFunctionHeader">
|
---|
1379 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
1380 | <xsl:with-param name="method" select="$methodname" />
|
---|
1381 | </xsl:call-template>
|
---|
1382 |
|
---|
1383 | <xsl:call-template name="emitDocumentStyleArgStructs">
|
---|
1384 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
1385 | <xsl:with-param name="methodname" select="$methodname" />
|
---|
1386 | <xsl:with-param name="fOutputs" select="1" />
|
---|
1387 | </xsl:call-template>
|
---|
1388 | <xsl:text>)</xsl:text>
|
---|
1389 | <xsl:call-template name="emitNewline" />
|
---|
1390 | <xsl:text>{</xsl:text>
|
---|
1391 | <xsl:call-template name="emitNewline" />
|
---|
1392 | <xsl:value-of select="' HRESULT rc = S_OK;'" />
|
---|
1393 | <xsl:value-of select="concat(concat(' NOREF(', $G_responseElementVarName),');')" />
|
---|
1394 | <xsl:call-template name="emitNewline" />
|
---|
1395 | <xsl:call-template name="emitPrologue" />
|
---|
1396 |
|
---|
1397 | <xsl:choose>
|
---|
1398 | <xsl:when test="param[@array]">
|
---|
1399 | <xsl:call-template name="warning"><xsl:with-param name="msg" select="concat('emitComCall: SKIPPING METHOD IMPLEMENTATION for "', $methodname, '" because it has arguments with "array" types. THIS SOAP METHOD WILL NOT DO ANYTHING!')" /></xsl:call-template>
|
---|
1400 | </xsl:when>
|
---|
1401 | <xsl:otherwise>
|
---|
1402 | <!-- emit the object upon which to invoke the method -->
|
---|
1403 | <xsl:call-template name="emitObjForMethod">
|
---|
1404 | <xsl:with-param name="ifname"><xsl:value-of select="$ifname" /></xsl:with-param>
|
---|
1405 | <xsl:with-param name="wsmap"><xsl:value-of select="$wsmap" /></xsl:with-param>
|
---|
1406 | <xsl:with-param name="structprefix" select="concat($G_requestElementVarName, '->')" />
|
---|
1407 | </xsl:call-template>
|
---|
1408 | <!-- next, emit storage variables to convert the SOAP/C++ arguments to COM types -->
|
---|
1409 | <xsl:for-each select="param">
|
---|
1410 | <xsl:variable name="dir" select="@dir" />
|
---|
1411 | <xsl:choose>
|
---|
1412 | <xsl:when test="$dir='in'">
|
---|
1413 | <xsl:call-template name="emitInputArgConverter">
|
---|
1414 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
1415 | <xsl:with-param name="method" select="concat($ifname, '::', $methodname)" />
|
---|
1416 | <xsl:with-param name="methodname">
|
---|
1417 | <xsl:call-template name="capitalize">
|
---|
1418 | <xsl:with-param name="str" select="$methodname" />
|
---|
1419 | </xsl:call-template>
|
---|
1420 | </xsl:with-param>
|
---|
1421 | <xsl:with-param name="object" select='"pObj"' />
|
---|
1422 | <xsl:with-param name="structprefix" select="concat($G_requestElementVarName, '->')" />
|
---|
1423 | <xsl:with-param name="name" select="@name" />
|
---|
1424 | <xsl:with-param name="type" select="@type" />
|
---|
1425 | <xsl:with-param name="safearray" select="@safearray" />
|
---|
1426 | </xsl:call-template>
|
---|
1427 | </xsl:when>
|
---|
1428 | <xsl:when test="$dir='out'">
|
---|
1429 | <xsl:call-template name="emitOutputArgBuffer">
|
---|
1430 | <xsl:with-param name="method" select="concat($ifname, '::', $methodname)" />
|
---|
1431 | <xsl:with-param name="name" select="@name" />
|
---|
1432 | <xsl:with-param name="type" select="@type" />
|
---|
1433 | <xsl:with-param name="safearray" select="@safearray" />
|
---|
1434 | </xsl:call-template>
|
---|
1435 | </xsl:when>
|
---|
1436 | <xsl:when test="$dir='return'">
|
---|
1437 | <xsl:call-template name="emitOutputArgBuffer">
|
---|
1438 | <xsl:with-param name="method" select="concat($ifname, '::', $methodname)" />
|
---|
1439 | <xsl:with-param name="name" select="$G_result" />
|
---|
1440 | <xsl:with-param name="type" select="@type" />
|
---|
1441 | <xsl:with-param name="safearray" select="@safearray" />
|
---|
1442 | </xsl:call-template>
|
---|
1443 | </xsl:when>
|
---|
1444 | </xsl:choose>
|
---|
1445 | </xsl:for-each>
|
---|
1446 | <!-- actual COM method call -->
|
---|
1447 | <xsl:call-template name="emitComCall">
|
---|
1448 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
1449 | <xsl:with-param name="object" select='"pObj"' />
|
---|
1450 | <xsl:with-param name="methodname">
|
---|
1451 | <xsl:call-template name="capitalize">
|
---|
1452 | <xsl:with-param name="str" select="$methodname" />
|
---|
1453 | </xsl:call-template>
|
---|
1454 | </xsl:with-param>
|
---|
1455 | </xsl:call-template>
|
---|
1456 | <!-- convert back the output data -->
|
---|
1457 | <xsl:for-each select="param">
|
---|
1458 | <xsl:variable name="dir" select="@dir" />
|
---|
1459 | <xsl:if test="$dir='out'">
|
---|
1460 | <xsl:call-template name="emitOutputArgBackConverter">
|
---|
1461 | <xsl:with-param name="ifname"><xsl:value-of select="$ifname" /></xsl:with-param>
|
---|
1462 | <xsl:with-param name="method" select="$methodname" />
|
---|
1463 | <xsl:with-param name="name"><xsl:value-of select="@name" /></xsl:with-param>
|
---|
1464 | <xsl:with-param name="type"><xsl:value-of select="@type" /></xsl:with-param>
|
---|
1465 | <xsl:with-param name="safearray"><xsl:value-of select="@safearray" /></xsl:with-param>
|
---|
1466 | <xsl:with-param name="callerprefix" select="'outparms.'"/>
|
---|
1467 | </xsl:call-template>
|
---|
1468 | </xsl:if>
|
---|
1469 | <xsl:if test="$dir='return'">
|
---|
1470 | <!-- return values _normally_ should convert to the input arg from the function prototype,
|
---|
1471 | except when there are both return and out params; in that case gsoap squeezes them all
|
---|
1472 | into the output args structure and the return thing is called "retval" -->
|
---|
1473 | <xsl:choose>
|
---|
1474 | <xsl:when test="$fHasOutParms">
|
---|
1475 | <xsl:call-template name="emitOutputArgBackConverter">
|
---|
1476 | <xsl:with-param name="ifname"><xsl:value-of select="$ifname" /></xsl:with-param>
|
---|
1477 | <xsl:with-param name="method" select="$methodname" />
|
---|
1478 | <xsl:with-param name="name"><xsl:value-of select="$G_result" /></xsl:with-param>
|
---|
1479 | <xsl:with-param name="type"><xsl:value-of select="@type" /></xsl:with-param>
|
---|
1480 | <xsl:with-param name="safearray"><xsl:value-of select="@safearray" /></xsl:with-param>
|
---|
1481 | <xsl:with-param name="callerprefix" select="'outparms.'"/>
|
---|
1482 | </xsl:call-template>
|
---|
1483 | </xsl:when>
|
---|
1484 | <xsl:otherwise>
|
---|
1485 | <xsl:call-template name="emitOutputArgBackConverter">
|
---|
1486 | <xsl:with-param name="ifname"><xsl:value-of select="$ifname" /></xsl:with-param>
|
---|
1487 | <xsl:with-param name="method" select="$methodname" />
|
---|
1488 | <xsl:with-param name="name"><xsl:value-of select="$G_result" /></xsl:with-param>
|
---|
1489 | <xsl:with-param name="type"><xsl:value-of select="@type" /></xsl:with-param>
|
---|
1490 | <xsl:with-param name="safearray"><xsl:value-of select="@safearray" /></xsl:with-param>
|
---|
1491 | </xsl:call-template>
|
---|
1492 | </xsl:otherwise>
|
---|
1493 | </xsl:choose>
|
---|
1494 | </xsl:if>
|
---|
1495 | </xsl:for-each>
|
---|
1496 | </xsl:otherwise>
|
---|
1497 | </xsl:choose>
|
---|
1498 | <xsl:call-template name="emitEpilogue" />
|
---|
1499 | </xsl:otherwise>
|
---|
1500 | </xsl:choose>
|
---|
1501 | </xsl:for-each>
|
---|
1502 | </xsl:if>
|
---|
1503 |
|
---|
1504 | </xsl:template>
|
---|
1505 |
|
---|
1506 |
|
---|
1507 | </xsl:stylesheet>
|
---|