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