VirtualBox

source: vbox/trunk/src/VBox/Main/webservice/websrv-cpp.xsl@ 23724

Last change on this file since 23724 was 23223, checked in by vboxsync, 15 years ago

API: big medium handling change and lots of assorted other cleanups and fixes

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

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