VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/include/COMWrappers.xsl@ 16694

Last change on this file since 16694 was 15304, checked in by vboxsync, 16 years ago

FE/Qt: Don't generate KEnum_COUNT values for COM enums as they might easy get wrong values (next integer after the last enum member which is not necessarily the largest) and screw the GUI.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 67.3 KB
Line 
1<?xml version="1.0"?>
2
3<!--
4/*
5 * A template to generate wrapper classes for [XP]COM interfaces (defined
6 * in XIDL) to use them in the main Qt-based GUI in platform-independent
7 * script-like manner.
8 *
9 * The generated header requires COMDefs.h and must be included from there.
10 */
11
12/*
13 Copyright (C) 2006-2008 Sun Microsystems, Inc.
14
15 This file is part of VirtualBox Open Source Edition (OSE), as
16 available from http://www.virtualbox.org. This file is free software;
17 you can redistribute it and/or modify it under the terms of the GNU
18 General Public License (GPL) as published by the Free Software
19 Foundation, in version 2 as it comes in the "COPYING" file of the
20 VirtualBox OSE distribution. VirtualBox OSE is distributed in the
21 hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
22
23 Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
24 Clara, CA 95054 USA or visit http://www.sun.com if you need
25 additional information or have any questions.
26 */
27-->
28
29<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
30<xsl:output method="text"/>
31
32<xsl:strip-space elements="*"/>
33
34
35<!--
36// helper definitions
37/////////////////////////////////////////////////////////////////////////////
38-->
39
40<!--
41 * capitalizes the first letter
42-->
43<xsl:template name="capitalize">
44 <xsl:param name="str" select="."/>
45 <xsl:value-of select="
46 concat(
47 translate(substring($str,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ'),
48 substring($str,2)
49 )
50 "/>
51</xsl:template>
52
53<!--
54 * uncapitalizes the first letter only if the second one is not capital
55 * otherwise leaves the string unchanged
56-->
57<xsl:template name="uncapitalize">
58 <xsl:param name="str" select="."/>
59 <xsl:choose>
60 <xsl:when test="not(contains('ABCDEFGHIJKLMNOPQRSTUVWXYZ', substring($str,2,1)))">
61 <xsl:value-of select="
62 concat(
63 translate(substring($str,1,1),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),
64 substring($str,2)
65 )
66 "/>
67 </xsl:when>
68 <xsl:otherwise>
69 <xsl:value-of select="string($str)"/>
70 </xsl:otherwise>
71 </xsl:choose>
72</xsl:template>
73
74<!--
75 * translates the string to uppercase
76-->
77<xsl:template name="uppercase">
78 <xsl:param name="str" select="."/>
79 <xsl:value-of select="
80 translate($str,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')
81 "/>
82</xsl:template>
83
84
85<!--
86// templates
87/////////////////////////////////////////////////////////////////////////////
88-->
89
90
91<!--
92 * shut down all implicit templates
93-->
94<xsl:template match="*"/>
95<xsl:template match="*|/" mode="declare"/>
96<xsl:template match="*|/" mode="define"/>
97<xsl:template match="*|/" mode="end"/>
98<xsl:template match="*|/" mode="begin"/>
99
100
101<!--
102 * header
103-->
104<xsl:template match="/idl">
105
106<xsl:text>
107/*
108 * DO NOT EDIT! This is a generated file.
109 *
110 * Qt-based wrapper classes for VirtualBox Main API (COM interfaces)
111 * generated from XIDL (XML interface definition).
112 *
113 * Source : src/VBox/Main/idl/VirtualBox.xidl
114 * Generator : src/VBox/Frontends/VirtualBox/include/COMWrappers.xsl
115 *
116 * Note: this header must be included from COMDefs.h, never directly.
117 */
118</xsl:text>
119
120<!-- all enum declarations -->
121<xsl:text>
122// all enums
123
124</xsl:text>
125 <xsl:for-each select="*/enum">
126 <xsl:text>enum </xsl:text>
127 <xsl:value-of select="concat('K',@name)"/>
128 <xsl:text>&#x0A;{&#x0A;</xsl:text>
129 <xsl:for-each select="const">
130 <xsl:text> </xsl:text>
131 <xsl:value-of select="concat('K',../@name,'_',@name)"/>
132 <xsl:text> = ::</xsl:text>
133 <xsl:value-of select="concat(../@name,'_',@name)"/>
134 <xsl:text>,&#x0A;</xsl:text>
135 </xsl:for-each>
136 <xsl:text>&#x0A;};&#x0A;&#x0A;</xsl:text>
137 </xsl:for-each>
138 <xsl:text>&#x0A;&#x0A;</xsl:text>
139
140 <xsl:apply-templates/>
141
142</xsl:template>
143
144
145<!--
146 * encloses |if| element's contents (unconditionally expanded by
147 * <apply-templates mode="define"/>) with #ifdef / #endif.
148 *
149 * @note this can produce an empty #if/#endif block if |if|'s children
150 * expand to nothing (such as |cpp|). I see no need to handle this situation
151 * specially.
152-->
153<xsl:template match="if" mode="define">
154 <xsl:if test="(@target='xpidl') or (@target='midl')">
155 <xsl:apply-templates select="." mode="begin"/>
156 <xsl:apply-templates mode="define"/>
157 <xsl:apply-templates select="." mode="end"/>
158 <xsl:text>&#x0A;</xsl:text>
159 </xsl:if>
160</xsl:template>
161
162
163<!--
164 * encloses |if| element's contents (unconditionally expanded by
165 * <apply-templates mode="declare"/>) with #ifdef / #endif.
166 *
167 * @note this can produce an empty #if/#endif block if |if|'s children
168 * expand to nothing (such as |cpp|). I see no need to handle this situation
169 * specially.
170-->
171<xsl:template match="if" mode="declare">
172 <xsl:if test="(@target='xpidl') or (@target='midl')">
173 <xsl:apply-templates select="." mode="begin"/>
174 <xsl:apply-templates mode="declare"/>
175 <xsl:apply-templates select="." mode="end"/>
176 <xsl:text>&#x0A;</xsl:text>
177 </xsl:if>
178</xsl:template>
179
180
181<!--
182 * |<if target="...">| element): begin and end.
183-->
184<xsl:template match="if" mode="begin">
185 <xsl:if test="@target='xpidl'">
186 <xsl:text>#if !defined (Q_WS_WIN32)&#x0A;</xsl:text>
187 </xsl:if>
188 <xsl:if test="@target='midl'">
189 <xsl:text>#if defined (Q_WS_WIN32)&#x0A;</xsl:text>
190 </xsl:if>
191</xsl:template>
192<xsl:template match="if" mode="end">
193 <xsl:if test="(@target='xpidl') or (@target='midl')">
194 <xsl:text>#endif&#x0A;</xsl:text>
195 </xsl:if>
196</xsl:template>
197
198
199<!--
200 * cpp_quote
201-->
202<xsl:template match="cpp"/>
203
204
205<!--
206 * #ifdef statement (@if attribute): begin and end
207-->
208<xsl:template match="@if" mode="begin">
209 <xsl:text>#if </xsl:text>
210 <xsl:value-of select="."/>
211 <xsl:text>&#x0A;</xsl:text>
212</xsl:template>
213<xsl:template match="@if" mode="end">
214 <xsl:text>#endif&#x0A;</xsl:text>
215</xsl:template>
216
217
218<!--
219 * libraries
220-->
221<xsl:template match="library">
222 <!-- forward declarations -->
223 <xsl:text>// forward declarations&#x0A;&#x0A;</xsl:text>
224 <xsl:for-each select="interface | collection | enumerator">
225 <xsl:text>class C</xsl:text>
226 <xsl:value-of select="substring(@name,2)"/>
227 <xsl:text>;&#x0A;</xsl:text>
228 </xsl:for-each>
229 <xsl:text>&#x0A;</xsl:text>
230 <!-- array typedefs -->
231 <xsl:text>// array typedefs&#x0A;&#x0A;</xsl:text>
232 <xsl:for-each select="interface[not(@internal='yes')]">
233 <xsl:if test="
234 (//attribute[@safearray='yes' and not(@internal='yes') and @type=current()/@name])
235 or
236 (//param[@safearray='yes' and not(../@internal='yes') and @type=current()/@name])
237 ">
238 <xsl:text>typedef QVector &lt;C</xsl:text>
239 <xsl:value-of select="substring(@name,2)"/>
240 <xsl:text>&gt; C</xsl:text>
241 <xsl:value-of select="substring(@name,2)"/>
242 <xsl:text>Vector;&#x0A;</xsl:text>
243 </xsl:if>
244 </xsl:for-each>
245 <xsl:text>&#x0A;</xsl:text>
246 <!-- wrapper declarations -->
247 <xsl:text>// wrapper declarations&#x0A;&#x0A;</xsl:text>
248 <xsl:apply-templates select="
249 if |
250 interface[not(@internal='yes')] |
251 collection[not(@internal='yes')] |
252 enumerator[not(@internal='yes')]
253 "
254 mode="declare"
255 />
256 <!-- wrapper definitions -->
257 <xsl:text>// wrapper definitions&#x0A;&#x0A;</xsl:text>
258 <xsl:apply-templates select="
259 if |
260 interface[not(@internal='yes')] |
261 collection[not(@internal='yes')] |
262 enumerator[not(@internal='yes')]
263 "
264 mode="define"
265 />
266</xsl:template>
267
268
269<!--
270 * interface declarations
271-->
272<xsl:template match="interface | collection | enumerator" mode="declare">
273
274 <xsl:text>// </xsl:text>
275 <xsl:value-of select="@name"/>
276 <xsl:text> wrapper&#x0A;&#x0A;class C</xsl:text>
277 <xsl:value-of select="substring(@name,2)"/>
278 <xsl:text> : public CInterface &lt;</xsl:text>
279 <xsl:value-of select="@name"/>
280 <!-- use the correct base if supportsErrorInfo -->
281 <xsl:call-template name="tryComposeFetchErrorInfo">
282 <xsl:with-param name="mode" select="'getBaseClassName'"/>
283 </xsl:call-template>
284 <xsl:text>&gt;&#x0A;{&#x0A;public:&#x0A;&#x0A;</xsl:text>
285
286 <!-- generate the Base typedef-->
287 <xsl:text> typedef CInterface &lt;</xsl:text>
288 <xsl:value-of select="@name"/>
289 <!-- Use the correct base if supportsErrorInfo -->
290 <xsl:call-template name="tryComposeFetchErrorInfo">
291 <xsl:with-param name="mode" select="'getBaseClassName'"/>
292 </xsl:call-template>
293 <xsl:text>&gt; Base;&#x0A;&#x0A;</xsl:text>
294
295 <xsl:if test="name()='collection'">
296 <xsl:text> // collection stuff&#x0A;&#x0A;</xsl:text>
297 <xsl:text> ULONG GetCount () const;&#x0A;</xsl:text>
298 <xsl:text> </xsl:text>
299 <xsl:apply-templates select="@type"/>
300 <xsl:text> GetItemAt (ULONG index) const;&#x0A;</xsl:text>
301 <xsl:text> </xsl:text>
302 <xsl:apply-templates select="@enumerator"/>
303 <xsl:text> Enumerate () const;&#x0A;&#x0A;</xsl:text>
304 </xsl:if>
305
306 <xsl:if test="name()='enumerator'">
307 <xsl:text> // enumerator stuff&#x0A;&#x0A;</xsl:text>
308 <xsl:text> BOOL HasMore () const;&#x0A;</xsl:text>
309 <xsl:text> </xsl:text>
310 <xsl:apply-templates select="@type"/>
311 <xsl:text> GetNext () const;&#x0A;&#x0A;</xsl:text>
312 <xsl:text> // friend wrappers&#x0A;&#x0A;</xsl:text>
313 <xsl:text> friend class CUnknown;&#x0A;</xsl:text>
314 <xsl:variable name="name" select="@name"/>
315 <xsl:variable name="parent" select=".."/>
316 <!-- for definitions inside <if> -->
317 <xsl:if test="name(..)='if'">
318 <xsl:for-each select="
319 preceding-sibling::collection | following-sibling::collection |
320 ../preceding-sibling::if[@target=$parent/@target]/collection |
321 ../following-sibling::if[@target=$parent/@target]/collection
322 ">
323 <xsl:if test="@enumerator=$name">
324 <xsl:text> friend class C</xsl:text>
325 <xsl:value-of select="substring(@name,2)"/>
326 <xsl:text>;&#x0A;</xsl:text>
327 </xsl:if>
328 </xsl:for-each>
329 </xsl:if>
330 <!-- for definitions outside <if> (i.e. inside <library>) -->
331 <xsl:if test="name(..)!='if'">
332 <xsl:for-each select="
333 preceding-sibling::collection | following-sibling::collection
334 ">
335 <xsl:if test="@enumerator=$name">
336 <xsl:text> friend class C</xsl:text>
337 <xsl:value-of select="substring(@name,2)"/>
338 <xsl:text>;&#x0A;</xsl:text>
339 </xsl:if>
340 </xsl:for-each>
341 </xsl:if>
342 </xsl:if>
343
344 <xsl:if test="name()='interface' or name()='collection'">
345 <xsl:call-template name="declareMembers"/>
346 </xsl:if>
347
348 <xsl:text>};&#x0A;&#x0A;</xsl:text>
349
350</xsl:template>
351
352<xsl:template name="declareAttributes">
353
354 <xsl:param name="iface"/>
355
356 <xsl:apply-templates select="$iface//attribute[not(@internal='yes')]" mode="declare"/>
357 <xsl:if test="$iface//attribute[not(@internal='yes')]">
358 <xsl:text>&#x0A;</xsl:text>
359 </xsl:if>
360 <!-- go to the base interface -->
361 <xsl:if test="$iface/@extends and $iface/@extends!='$unknown'">
362 <xsl:choose>
363 <!-- interfaces within library/if -->
364 <xsl:when test="name(..)='if'">
365 <xsl:call-template name="declareAttributes">
366 <xsl:with-param name="iface" select="
367 preceding-sibling::
368 *[(self::interface or self::collection) and @name=$iface/@extends] |
369 following-sibling::
370 *[(self::interface or self::collection) and @name=$iface/@extends] |
371 ../preceding-sibling::if[@target=../@target]/
372 *[(self::interface or self::collection) and @name=$iface/@extends] |
373 ../following-sibling::if[@target=../@target]/
374 *[(self::interface or self::collection) and @name=$iface/@extends]
375 "/>
376 </xsl:call-template>
377 </xsl:when>
378 <!-- interfaces within library -->
379 <xsl:otherwise>
380 <xsl:call-template name="declareAttributes">
381 <xsl:with-param name="iface" select="
382 preceding-sibling::
383 *[(self::interface or self::collection) and @name=$iface/@extends] |
384 following-sibling::
385 *[(self::interface or self::collection) and @name=$iface/@extends]
386 "/>
387 </xsl:call-template>
388 </xsl:otherwise>
389 </xsl:choose>
390 </xsl:if>
391
392</xsl:template>
393
394<xsl:template name="declareMethods">
395
396 <xsl:param name="iface"/>
397
398 <xsl:apply-templates select="$iface//method[not(@internal='yes')]" mode="declare"/>
399 <xsl:if test="$iface//method[not(@internal='yes')]">
400 <xsl:text>&#x0A;</xsl:text>
401 </xsl:if>
402 <!-- go to the base interface -->
403 <xsl:if test="$iface/@extends and $iface/@extends!='$unknown'">
404 <xsl:choose>
405 <!-- interfaces within library/if -->
406 <xsl:when test="name(..)='if'">
407 <xsl:call-template name="declareMethods">
408 <xsl:with-param name="iface" select="
409 preceding-sibling::
410 *[(self::interface or self::collection) and @name=$iface/@extends] |
411 following-sibling::
412 *[(self::interface or self::collection) and @name=$iface/@extends] |
413 ../preceding-sibling::if[@target=../@target]/
414 *[(self::interface or self::collection) and @name=$iface/@extends] |
415 ../following-sibling::if[@target=../@target]/
416 *[(self::interface or self::collection) and @name=$iface/@extends]
417 "/>
418 </xsl:call-template>
419 </xsl:when>
420 <!-- interfaces within library -->
421 <xsl:otherwise>
422 <xsl:call-template name="declareMethods">
423 <xsl:with-param name="iface" select="
424 preceding-sibling::
425 *[(self::interface or self::collection) and @name=$iface/@extends] |
426 following-sibling::
427 *[(self::interface or self::collection) and @name=$iface/@extends]
428 "/>
429 </xsl:call-template>
430 </xsl:otherwise>
431 </xsl:choose>
432 </xsl:if>
433
434</xsl:template>
435
436<xsl:template name="declareMembers">
437
438 <xsl:text> // constructors and assignments taking CUnknown and </xsl:text>
439 <xsl:text>raw iface pointer&#x0A;&#x0A;</xsl:text>
440 <!-- default constructor -->
441 <xsl:text> C</xsl:text>
442 <xsl:value-of select="substring(@name,2)"/>
443 <xsl:text> () {}&#x0A;&#x0A;</xsl:text>
444 <!-- constructor taking CWhatever -->
445 <xsl:text> template &lt;class OI, class OB&gt; explicit C</xsl:text>
446 <xsl:value-of select="substring(@name,2)"/>
447<xsl:text> (const CInterface &lt;OI, OB&gt; &amp; that)
448 {
449 attach (that.raw());
450 if (SUCCEEDED (mRC))
451 {
452 mRC = that.lastRC();
453 setErrorInfo (that.errorInfo());
454 }
455 }
456</xsl:text>
457 <xsl:text>&#x0A;</xsl:text>
458 <!-- specialization for ourselves (copy constructor) -->
459 <xsl:text> C</xsl:text>
460 <xsl:value-of select="substring(@name,2)"/>
461 <xsl:text> (const C</xsl:text>
462 <xsl:value-of select="substring(@name,2)"/>
463 <xsl:text> &amp; that) : Base (that) {}&#x0A;&#x0A;</xsl:text>
464 <!-- constructor taking a raw iface pointer -->
465 <xsl:text> template &lt;class OI&gt; explicit C</xsl:text>
466 <xsl:value-of select="substring(@name,2)"/>
467 <xsl:text> (OI * aIface) { attach (aIface); }&#x0A;&#x0A;</xsl:text>
468 <!-- specialization for ourselves -->
469 <xsl:text> explicit C</xsl:text>
470 <xsl:value-of select="substring(@name,2)"/>
471 <xsl:text> (</xsl:text>
472 <xsl:value-of select="@name"/>
473 <xsl:text> * aIface) : Base (aIface) {}&#x0A;&#x0A;</xsl:text>
474 <!-- assignment taking CWhatever -->
475 <xsl:text> template &lt;class OI, class OB&gt; C</xsl:text>
476 <xsl:value-of select="substring(@name,2)"/>
477<xsl:text> &amp; operator = (const CInterface &lt;OI, OB&gt; &amp; that)
478 {
479 attach (that.raw());
480 if (SUCCEEDED (mRC))
481 {
482 mRC = that.lastRC();
483 setErrorInfo (that.errorInfo());
484 }
485 return *this;
486 }
487</xsl:text>
488 <xsl:text>&#x0A;</xsl:text>
489 <!-- specialization for ourselves -->
490 <xsl:text> C</xsl:text>
491 <xsl:value-of select="substring(@name,2)"/>
492 <xsl:text> &amp; operator = (const C</xsl:text>
493 <xsl:value-of select="substring(@name,2)"/>
494<xsl:text> &amp; that)
495 {
496 Base::operator= (that);
497 return *this;
498 }
499</xsl:text>
500 <xsl:text>&#x0A;</xsl:text>
501 <!-- assignment taking a raw iface pointer -->
502 <xsl:text> template &lt;class OI&gt; C</xsl:text>
503 <xsl:value-of select="substring(@name,2)"/>
504<xsl:text> &amp; operator = (OI * aIface)
505 {
506 attach (aIface);
507 return *this;
508 }
509</xsl:text>
510 <xsl:text>&#x0A;</xsl:text>
511 <!-- specialization for ourselves -->
512 <xsl:text> C</xsl:text>
513 <xsl:value-of select="substring(@name,2)"/>
514 <xsl:text> &amp; operator = (</xsl:text>
515 <xsl:value-of select="@name"/>
516<xsl:text> * aIface)
517 {
518 Base::operator= (aIface);
519 return *this;
520 }
521</xsl:text>
522 <xsl:text>&#x0A;</xsl:text>
523
524 <xsl:text> // attributes (properties)&#x0A;&#x0A;</xsl:text>
525 <xsl:call-template name="declareAttributes">
526 <xsl:with-param name="iface" select="."/>
527 </xsl:call-template>
528
529 <xsl:text> // methods&#x0A;&#x0A;</xsl:text>
530 <xsl:call-template name="declareMethods">
531 <xsl:with-param name="iface" select="."/>
532 </xsl:call-template>
533
534 <xsl:text> // friend wrappers&#x0A;&#x0A;</xsl:text>
535 <xsl:text> friend class CUnknown;&#x0A;</xsl:text>
536 <xsl:variable name="name" select="@name"/>
537 <xsl:variable name="parent" select=".."/>
538 <!-- for definitions inside <if> -->
539 <xsl:if test="name(..)='if'">
540 <xsl:for-each select="
541 preceding-sibling::*[self::interface or self::collection or self::enumerator] |
542 following-sibling::*[self::interface or self::collection or self::enumerator] |
543 ../preceding-sibling::*[self::interface or self::collection or self::enumerator] |
544 ../following-sibling::*[self::interface or self::collection or self::enumerator] |
545 ../preceding-sibling::if[@target=$parent/@target]/*[self::interface or self::collection or self::enumerator] |
546 ../following-sibling::if[@target=$parent/@target]/*[self::interface or self::collection or self::enumerator]
547 ">
548 <xsl:if test="
549 ((name()='interface' or name()='collection')
550 and
551 ((name(..)!='if' and (if[@target=$parent/@target]/method/param[@type=$name]
552 or
553 if[@target=$parent/@target]/attribute[@type=$name]))
554 or
555 (.//method/param[@type=$name] or attribute[@type=$name])))
556 or
557 (name(..)='if' and (name()='collection' or name()='enumerator') and @type=$name)
558 ">
559 <xsl:text> friend class C</xsl:text>
560 <xsl:value-of select="substring(@name,2)"/>
561 <xsl:text>;&#x0A;</xsl:text>
562 </xsl:if>
563 </xsl:for-each>
564 </xsl:if>
565 <!-- for definitions outside <if> (i.e. inside <library>) -->
566 <xsl:if test="name(..)!='if'">
567 <xsl:for-each select="
568 preceding-sibling::*[self::interface or self::collection or self::enumerator] |
569 following-sibling::*[self::interface or self::collection or self::enumerator] |
570 preceding-sibling::if/*[self::interface or self::collection or self::enumerator] |
571 following-sibling::if/*[self::interface or self::collection or self::enumerator]
572 ">
573 <xsl:if test="
574 ((name()='interface' or name()='collection')
575 and
576 (.//method/param[@type=$name] or attribute[@type=$name]))
577 or
578 ((name()='collection' or name()='enumerator') and @type=$name)
579 ">
580 <xsl:text> friend class C</xsl:text>
581 <xsl:value-of select="substring(@name,2)"/>
582 <xsl:text>;&#x0A;</xsl:text>
583 </xsl:if>
584 </xsl:for-each>
585 </xsl:if>
586
587</xsl:template>
588
589<!-- attribute declarations -->
590<xsl:template match="interface//attribute | collection//attribute" mode="declare">
591 <xsl:if test="@array">
592 <xsl:message terminate="yes">
593 <xsl:value-of select="concat(../../@name,'::',../@name,'::',@name,': ')"/>
594 <xsl:text>'array' attributes are not supported, use 'safearray="yes"' instead.</xsl:text>
595 </xsl:message>
596 </xsl:if>
597 <xsl:apply-templates select="parent::node()" mode="begin"/>
598 <xsl:apply-templates select="@if" mode="begin"/>
599 <xsl:call-template name="composeMethod">
600 <xsl:with-param name="return" select="."/>
601 </xsl:call-template>
602 <xsl:if test="not(@readonly='yes')">
603 <xsl:call-template name="composeMethod">
604 <xsl:with-param name="return" select="''"/>
605 </xsl:call-template>
606 </xsl:if>
607 <xsl:apply-templates select="@if" mode="end"/>
608 <xsl:apply-templates select="parent::node()" mode="end"/>
609</xsl:template>
610
611<!-- method declarations -->
612<xsl:template match="interface//method | collection//method" mode="declare">
613 <xsl:apply-templates select="parent::node()" mode="begin"/>
614 <xsl:apply-templates select="@if" mode="begin"/>
615 <xsl:call-template name="composeMethod"/>
616 <xsl:apply-templates select="@if" mode="end"/>
617 <xsl:apply-templates select="parent::node()" mode="end"/>
618</xsl:template>
619
620
621<!--
622 * interface definitions
623-->
624<xsl:template match="interface | collection | enumerator" mode="define">
625
626 <xsl:text>// </xsl:text>
627 <xsl:value-of select="@name"/>
628 <xsl:text> wrapper&#x0A;&#x0A;</xsl:text>
629
630 <xsl:if test="name()='collection'">
631 <!-- GetCount -->
632 <xsl:text>inline ULONG C</xsl:text>
633 <xsl:value-of select="substring(@name,2)"/>
634 <xsl:text>::GetCount () const&#x0A;{&#x0A;</xsl:text>
635 <xsl:text> ULONG count = 0;&#x0A;</xsl:text>
636 <xsl:text> Assert (mIface);&#x0A;</xsl:text>
637 <xsl:text> if (!mIface)&#x0A; return count;&#x0A;</xsl:text>
638 <xsl:text> mRC = mIface->COMGETTER(Count) (&amp;count);&#x0A;</xsl:text>
639 <xsl:call-template name="tryComposeFetchErrorInfo"/>
640 <xsl:text> return count;&#x0A;</xsl:text>
641 <xsl:text>}&#x0A;&#x0A;</xsl:text>
642 <!-- GetItemAt -->
643 <xsl:text>inline </xsl:text>
644 <xsl:apply-templates select="@type"/>
645 <xsl:text> C</xsl:text>
646 <xsl:value-of select="substring(@name,2)"/>
647 <xsl:text>::GetItemAt (ULONG index) const&#x0A;{&#x0A;</xsl:text>
648 <xsl:text> </xsl:text><xsl:apply-templates select="@type"/>
649 <xsl:text> item;&#x0A;</xsl:text>
650 <xsl:text> Assert (mIface);&#x0A;</xsl:text>
651 <xsl:text> if (!mIface)&#x0A; return item;&#x0A;</xsl:text>
652 <xsl:text> mRC = mIface->GetItemAt (index, &amp;item.mIface);&#x0A;</xsl:text>
653 <xsl:call-template name="tryComposeFetchErrorInfo"/>
654 <xsl:text> return item;&#x0A;</xsl:text>
655 <xsl:text>}&#x0A;&#x0A;</xsl:text>
656 <!-- Enumerate -->
657 <xsl:text>inline </xsl:text>
658 <xsl:apply-templates select="@enumerator"/>
659 <xsl:text> C</xsl:text>
660 <xsl:value-of select="substring(@name,2)"/>
661 <xsl:text>::Enumerate () const&#x0A;{&#x0A;</xsl:text>
662 <xsl:text> </xsl:text><xsl:apply-templates select="@enumerator"/>
663 <xsl:text> enumerator;&#x0A;</xsl:text>
664 <xsl:text> Assert (mIface);&#x0A;</xsl:text>
665 <xsl:text> if (!mIface)&#x0A; return enumerator;&#x0A;</xsl:text>
666 <xsl:text> mRC = mIface->Enumerate (&amp;enumerator.mIface);&#x0A;</xsl:text>
667 <xsl:call-template name="tryComposeFetchErrorInfo"/>
668 <xsl:text> return enumerator;&#x0A;</xsl:text>
669 <xsl:text>}&#x0A;&#x0A;</xsl:text>
670 </xsl:if>
671
672 <xsl:if test="name()='enumerator'">
673 <!-- HasMore -->
674 <xsl:text>inline BOOL C</xsl:text>
675 <xsl:value-of select="substring(@name,2)"/>
676 <xsl:text>::HasMore () const&#x0A;{&#x0A;</xsl:text>
677 <xsl:text> BOOL more = FALSE;&#x0A;</xsl:text>
678 <xsl:text> Assert (mIface);&#x0A;</xsl:text>
679 <xsl:text> if (!mIface)&#x0A; return more;&#x0A;</xsl:text>
680 <xsl:text> mRC = mIface->HasMore (&amp;more);&#x0A;</xsl:text>
681 <xsl:call-template name="tryComposeFetchErrorInfo"/>
682 <xsl:text> return more;&#x0A;</xsl:text>
683 <xsl:text>}&#x0A;&#x0A;</xsl:text>
684 <!-- GetNext -->
685 <xsl:text>inline </xsl:text>
686 <xsl:apply-templates select="@type"/>
687 <xsl:text> C</xsl:text>
688 <xsl:value-of select="substring(@name,2)"/>
689 <xsl:text>::GetNext () const&#x0A;{&#x0A;</xsl:text>
690 <xsl:text> </xsl:text><xsl:apply-templates select="@type"/>
691 <xsl:text> next;&#x0A;</xsl:text>
692 <xsl:text> Assert (mIface);&#x0A;</xsl:text>
693 <xsl:text> if (!mIface)&#x0A; return next;&#x0A;</xsl:text>
694 <xsl:text> mRC = mIface->GetNext (&amp;next.mIface);&#x0A;</xsl:text>
695 <xsl:call-template name="tryComposeFetchErrorInfo"/>
696 <xsl:text> return next;&#x0A;</xsl:text>
697 <xsl:text>}&#x0A;&#x0A;</xsl:text>
698 </xsl:if>
699
700 <xsl:if test="name()='interface' or name()='collection'">
701 <xsl:call-template name="defineMembers"/>
702 </xsl:if>
703
704</xsl:template>
705
706<xsl:template name="defineAttributes">
707
708 <xsl:param name="iface"/>
709
710 <xsl:apply-templates select="$iface//attribute[not(@internal='yes')]" mode="define">
711 <xsl:with-param name="namespace" select="."/>
712 </xsl:apply-templates>
713
714 <!-- go to the base interface -->
715 <xsl:if test="$iface/@extends and $iface/@extends!='$unknown'">
716 <xsl:choose>
717 <!-- interfaces within library/if -->
718 <xsl:when test="name(..)='if'">
719 <xsl:call-template name="defineAttributes">
720 <xsl:with-param name="iface" select="
721 preceding-sibling::
722 *[(self::interface or self::collection) and @name=$iface/@extends] |
723 following-sibling::
724 *[(self::interface or self::collection) and @name=$iface/@extends] |
725 ../preceding-sibling::if[@target=../@target]/
726 *[(self::interface or self::collection) and @name=$iface/@extends] |
727 ../following-sibling::if[@target=../@target]/
728 *[(self::interface or self::collection) and @name=$iface/@extends]
729 "/>
730 </xsl:call-template>
731 </xsl:when>
732 <!-- interfaces within library -->
733 <xsl:otherwise>
734 <xsl:call-template name="defineAttributes">
735 <xsl:with-param name="iface" select="
736 preceding-sibling::
737 *[(self::interface or self::collection) and @name=$iface/@extends] |
738 following-sibling::
739 *[(self::interface or self::collection) and @name=$iface/@extends]
740 "/>
741 </xsl:call-template>
742 </xsl:otherwise>
743 </xsl:choose>
744 </xsl:if>
745
746</xsl:template>
747
748<xsl:template name="defineMethods">
749
750 <xsl:param name="iface"/>
751
752 <xsl:apply-templates select="$iface//method[not(@internal='yes')]" mode="define">
753 <xsl:with-param name="namespace" select="."/>
754 </xsl:apply-templates>
755
756 <!-- go to the base interface -->
757 <xsl:if test="$iface/@extends and $iface/@extends!='$unknown'">
758 <xsl:choose>
759 <!-- interfaces within library/if -->
760 <xsl:when test="name(..)='if'">
761 <xsl:call-template name="defineMethods">
762 <xsl:with-param name="iface" select="
763 preceding-sibling::
764 *[(self::interface or self::collection) and @name=$iface/@extends] |
765 following-sibling::
766 *[(self::interface or self::collection) and @name=$iface/@extends] |
767 ../preceding-sibling::if[@target=../@target]/
768 *[(self::interface or self::collection) and @name=$iface/@extends] |
769 ../following-sibling::if[@target=../@target]/
770 *[(self::interface or self::collection) and @name=$iface/@extends]
771 "/>
772 </xsl:call-template>
773 </xsl:when>
774 <!-- interfaces within library -->
775 <xsl:otherwise>
776 <xsl:call-template name="defineMethods">
777 <xsl:with-param name="iface" select="
778 preceding-sibling::
779 *[(self::interface or self::collection) and @name=$iface/@extends] |
780 following-sibling::
781 *[(self::interface or self::collection) and @name=$iface/@extends]
782 "/>
783 </xsl:call-template>
784 </xsl:otherwise>
785 </xsl:choose>
786 </xsl:if>
787
788</xsl:template>
789
790<xsl:template name="defineMembers">
791 <xsl:call-template name="defineAttributes">
792 <xsl:with-param name="iface" select="."/>
793 </xsl:call-template>
794 <xsl:call-template name="defineMethods">
795 <xsl:with-param name="iface" select="."/>
796 </xsl:call-template>
797</xsl:template>
798
799<!-- attribute definitions -->
800<xsl:template match="interface//attribute | collection//attribute" mode="define">
801
802 <xsl:param name="namespace" select="(ancestor::interface | ancestor::collection)[1]"/>
803
804 <xsl:apply-templates select="parent::node()" mode="begin"/>
805 <xsl:apply-templates select="@if" mode="begin"/>
806 <xsl:call-template name="composeMethod">
807 <xsl:with-param name="return" select="."/>
808 <xsl:with-param name="define" select="'yes'"/>
809 <xsl:with-param name="namespace" select="$namespace"/>
810 </xsl:call-template>
811 <xsl:if test="not(@readonly='yes')">
812 <xsl:call-template name="composeMethod">
813 <xsl:with-param name="return" select="''"/>
814 <xsl:with-param name="define" select="'yes'"/>
815 <xsl:with-param name="namespace" select="$namespace"/>
816 </xsl:call-template>
817 </xsl:if>
818 <xsl:apply-templates select="@if" mode="end"/>
819 <xsl:apply-templates select="parent::node()" mode="end"/>
820 <xsl:text>&#x0A;</xsl:text>
821
822</xsl:template>
823
824<!-- method definitions -->
825<xsl:template match="interface//method | collection//method" mode="define">
826
827 <xsl:param name="namespace" select="(ancestor::interface | ancestor::collection)[1]"/>
828
829 <xsl:apply-templates select="parent::node()" mode="begin"/>
830 <xsl:apply-templates select="@if" mode="begin"/>
831 <xsl:call-template name="composeMethod">
832 <xsl:with-param name="define" select="'yes'"/>
833 <xsl:with-param name="namespace" select="$namespace"/>
834 </xsl:call-template>
835 <xsl:apply-templates select="@if" mode="end"/>
836 <xsl:apply-templates select="parent::node()" mode="end"/>
837 <xsl:text>&#x0A;</xsl:text>
838
839</xsl:template>
840
841
842<!--
843 * co-classes
844-->
845<xsl:template match="module/class"/>
846
847
848<!--
849 * enums
850-->
851<xsl:template match="enum"/>
852
853
854<!--
855 * base template to produce interface methods
856 *
857 * @param return
858 * - in <attribute> context, must be '.' for getters and
859 * '' for setters
860 * - in <method> context, must not be specified (the default value
861 * will apply)
862 * @param define
863 * 'yes' to procuce inlined definition outside the class
864 * declaration, or
865 * empty string to produce method declaration only (w/o body)
866 * @param namespace
867 * actual interface node for which this method is being defined
868 * (necessary to properly set a class name for inherited methods).
869 * If not specified, will default to the parent interface/collection
870 * node of the method being defined.
871-->
872<xsl:template name="composeMethod">
873 <xsl:param name="return" select="param[@dir='return']"/>
874 <xsl:param name="define" select="''"/>
875 <xsl:param name="namespace" select="(ancestor::interface | ancestor::collection)[1]"/>
876 <xsl:choose>
877 <!-- no return value -->
878 <xsl:when test="not($return)">
879 <xsl:choose>
880 <xsl:when test="$define">
881 <xsl:text>inline </xsl:text>
882 </xsl:when>
883 <xsl:otherwise>
884 <xsl:text> </xsl:text>
885 </xsl:otherwise>
886 </xsl:choose>
887 <xsl:text>void </xsl:text>
888 <xsl:if test="$define">
889 <xsl:text>C</xsl:text>
890 <xsl:value-of select="substring($namespace/@name,2)"/>
891 <xsl:text>::</xsl:text>
892 </xsl:if>
893 <xsl:call-template name="composeMethodDecl">
894 <xsl:with-param name="isSetter" select="'yes'"/>
895 </xsl:call-template>
896 <xsl:if test="$define">
897 <xsl:text>&#x0A;{&#x0A;</xsl:text>
898 <!-- iface assertion -->
899 <xsl:text> Assert (mIface);&#x0A;</xsl:text>
900 <xsl:text> if (!mIface)&#x0A; return;&#x0A;</xsl:text>
901 <!-- method call -->
902 <xsl:call-template name="composeMethodCall">
903 <xsl:with-param name="isSetter" select="'yes'"/>
904 </xsl:call-template>
905 <xsl:text>}&#x0A;</xsl:text>
906 </xsl:if>
907 <xsl:if test="not($define)">
908 <xsl:text>;&#x0A;</xsl:text>
909 </xsl:if>
910 </xsl:when>
911 <!-- has a return value -->
912 <xsl:when test="count($return) = 1">
913 <xsl:choose>
914 <xsl:when test="$define">
915 <xsl:text>inline </xsl:text>
916 </xsl:when>
917 <xsl:otherwise>
918 <xsl:text> </xsl:text>
919 </xsl:otherwise>
920 </xsl:choose>
921 <xsl:apply-templates select="$return/@type"/>
922 <xsl:text> </xsl:text>
923 <xsl:if test="$define">
924 <xsl:text>C</xsl:text>
925 <xsl:value-of select="substring($namespace/@name,2)"/>
926 <xsl:text>::</xsl:text>
927 </xsl:if>
928 <xsl:call-template name="composeMethodDecl"/>
929 <xsl:if test="$define">
930 <xsl:text>&#x0A;{&#x0A; </xsl:text>
931 <xsl:apply-templates select="$return/@type"/>
932 <xsl:text> a</xsl:text>
933 <xsl:call-template name="capitalize">
934 <xsl:with-param name="str" select="$return/@name"/>
935 </xsl:call-template>
936 <xsl:apply-templates select="$return/@type" mode="initializer"/>
937 <xsl:text>;&#x0A;</xsl:text>
938 <!-- iface assertion -->
939 <xsl:text> Assert (mIface);&#x0A;</xsl:text>
940 <xsl:text> if (!mIface)&#x0A; return a</xsl:text>
941 <xsl:call-template name="capitalize">
942 <xsl:with-param name="str" select="$return/@name"/>
943 </xsl:call-template>
944 <xsl:text>;&#x0A;</xsl:text>
945 <!-- method call -->
946 <xsl:call-template name="composeMethodCall"/>
947 <!-- return statement -->
948 <xsl:text> return a</xsl:text>
949 <xsl:call-template name="capitalize">
950 <xsl:with-param name="str" select="$return/@name"/>
951 </xsl:call-template>
952 <xsl:text>;&#x0A;}&#x0A;</xsl:text>
953 </xsl:if>
954 <xsl:if test="not($define)">
955 <xsl:text>;&#x0A;</xsl:text>
956 </xsl:if>
957 </xsl:when>
958 <!-- otherwise error -->
959 <xsl:otherwise>
960 <xsl:message terminate="yes">
961 <xsl:text>More than one return value in method: </xsl:text>
962 <xsl:value-of select="$namespace/@name"/>
963 <xsl:text>::</xsl:text>
964 <xsl:value-of select="@name"/>
965 </xsl:message>
966 </xsl:otherwise>
967 </xsl:choose>
968</xsl:template>
969
970<xsl:template name="composeMethodDecl">
971 <xsl:param name="isSetter" select="''"/>
972 <xsl:choose>
973 <!-- attribute method call -->
974 <xsl:when test="name()='attribute'">
975 <xsl:choose>
976 <xsl:when test="$isSetter">
977 <!-- name -->
978 <xsl:text>Set</xsl:text>
979 <xsl:call-template name="capitalize">
980 <xsl:with-param name="str" select="@name"/>
981 </xsl:call-template>
982 <xsl:text> (</xsl:text>
983 <!-- parameter -->
984 <xsl:apply-templates select="@type" mode="param"/>
985 <xsl:text> a</xsl:text>
986 <xsl:call-template name="capitalize">
987 <xsl:with-param name="str" select="@name"/>
988 </xsl:call-template>
989 <xsl:text>)</xsl:text>
990 </xsl:when>
991 <xsl:otherwise>
992 <!-- name -->
993 <xsl:text>Get</xsl:text>
994 <xsl:call-template name="capitalize">
995 <xsl:with-param name="str" select="@name"/>
996 </xsl:call-template>
997 <xsl:text> (</xsl:text>
998 <!-- const method -->
999 <xsl:text>) const</xsl:text>
1000 </xsl:otherwise>
1001 </xsl:choose>
1002 </xsl:when>
1003 <!-- regular method call -->
1004 <xsl:when test="name()='method'">
1005 <!-- name -->
1006 <xsl:call-template name="capitalize">
1007 <xsl:with-param name="str" select="@name"/>
1008 </xsl:call-template>
1009 <xsl:text> (</xsl:text>
1010 <!-- parameters -->
1011 <xsl:for-each select="param[@dir!='return']">
1012 <xsl:apply-templates select="@type" mode="param"/>
1013 <xsl:text> a</xsl:text>
1014 <xsl:call-template name="capitalize">
1015 <xsl:with-param name="str" select="@name"/>
1016 </xsl:call-template>
1017 <xsl:if test="position() != last()">
1018 <xsl:text>, </xsl:text>
1019 </xsl:if>
1020 </xsl:for-each>
1021 <xsl:text>)</xsl:text>
1022 <!-- const method -->
1023 <xsl:if test="@const='yes'"> const</xsl:if>
1024 </xsl:when>
1025 </xsl:choose>
1026</xsl:template>
1027
1028<xsl:template name="composeMethodCall">
1029 <xsl:param name="isSetter" select="''"/>
1030 <!-- apply 'pre-call' hooks -->
1031 <xsl:choose>
1032 <xsl:when test="name()='attribute'">
1033 <xsl:call-template name="hooks">
1034 <xsl:with-param name="when" select="'pre-call'"/>
1035 <xsl:with-param name="isSetter" select="$isSetter"/>
1036 </xsl:call-template>
1037 </xsl:when>
1038 <xsl:when test="name()='method'">
1039 <xsl:for-each select="param">
1040 <xsl:call-template name="hooks">
1041 <xsl:with-param name="when" select="'pre-call'"/>
1042 </xsl:call-template>
1043 </xsl:for-each>
1044 </xsl:when>
1045 </xsl:choose>
1046 <!-- start the call -->
1047 <xsl:text> mRC = mIface-></xsl:text>
1048 <xsl:choose>
1049 <!-- attribute method call -->
1050 <xsl:when test="name()='attribute'">
1051 <!-- method name -->
1052 <xsl:choose>
1053 <xsl:when test="$isSetter">
1054 <xsl:text>COMSETTER(</xsl:text>
1055 </xsl:when>
1056 <xsl:otherwise>
1057 <xsl:text>COMGETTER(</xsl:text>
1058 </xsl:otherwise>
1059 </xsl:choose>
1060 <xsl:call-template name="capitalize">
1061 <xsl:with-param name="str" select="@name"/>
1062 </xsl:call-template>
1063 <xsl:text>) (</xsl:text>
1064 <!-- parameter -->
1065 <xsl:call-template name="composeMethodCallParam">
1066 <xsl:with-param name="isIn" select="$isSetter"/>
1067 <xsl:with-param name="isOut" select="not($isSetter)"/>
1068 </xsl:call-template>
1069 </xsl:when>
1070 <!-- regular method call -->
1071 <xsl:when test="name()='method'">
1072 <!-- method name -->
1073 <xsl:call-template name="capitalize">
1074 <xsl:with-param name="str" select="@name"/>
1075 </xsl:call-template>
1076 <xsl:text> (</xsl:text>
1077 <!-- parameters -->
1078 <xsl:for-each select="param">
1079 <xsl:call-template name="composeMethodCallParam"/>
1080 <xsl:if test="position() != last()">
1081 <xsl:text>, </xsl:text>
1082 </xsl:if>
1083 </xsl:for-each>
1084 </xsl:when>
1085 </xsl:choose>
1086 <xsl:text>);&#x0A;</xsl:text>
1087 <!-- apply 'post-call' hooks -->
1088 <xsl:choose>
1089 <xsl:when test="name()='attribute'">
1090 <xsl:call-template name="hooks">
1091 <xsl:with-param name="when" select="'post-call'"/>
1092 <xsl:with-param name="isSetter" select="$isSetter"/>
1093 </xsl:call-template>
1094 </xsl:when>
1095 <xsl:when test="name()='method'">
1096 <xsl:for-each select="param">
1097 <xsl:call-template name="hooks">
1098 <xsl:with-param name="when" select="'post-call'"/>
1099 </xsl:call-template>
1100 </xsl:for-each>
1101 </xsl:when>
1102 </xsl:choose>
1103 <!-- -->
1104 <xsl:call-template name="tryComposeFetchErrorInfo"/>
1105</xsl:template>
1106
1107<!--
1108 * Composes a 'fetch error info' call or returns the name of the
1109 * appropriate base class name that provides error info functionality
1110 * (depending on the mode parameter). Does nothing if the current
1111 * entity (interface, collection or enumerator) does not support error info.
1112 *
1113 * @param mode
1114 * - 'getBaseClassName': expands to the base class name
1115 * - any other value: composes a 'fetch error info' method call
1116-->
1117<xsl:template name="tryComposeFetchErrorInfo">
1118 <xsl:param name="mode" select="''"/>
1119 <xsl:variable name="ifaceSupportsErrorInfo" select="
1120 (ancestor-or-self::interface |
1121 ancestor-or-self::collection |
1122 ancestor-or-self::enumerator)[1]/@supportsErrorInfo
1123 "/>
1124 <xsl:variable name="librarySupportsErrorInfo" select="ancestor::library/@supportsErrorInfo"/>
1125 <xsl:choose>
1126 <xsl:when test="$ifaceSupportsErrorInfo">
1127 <xsl:call-template name="composeFetchErrorInfo">
1128 <xsl:with-param name="supports" select="string($ifaceSupportsErrorInfo)"/>
1129 <xsl:with-param name="mode" select="$mode"/>
1130 </xsl:call-template>
1131 </xsl:when>
1132 <xsl:when test="$librarySupportsErrorInfo">
1133 <xsl:call-template name="composeFetchErrorInfo">
1134 <xsl:with-param name="supports" select="string($librarySupportsErrorInfo)"/>
1135 <xsl:with-param name="mode" select="$mode"/>
1136 </xsl:call-template>
1137 </xsl:when>
1138 </xsl:choose>
1139</xsl:template>
1140
1141<xsl:template name="composeFetchErrorInfo">
1142 <xsl:param name="supports" select="''"/>
1143 <xsl:param name="mode" select="''"/>
1144 <xsl:choose>
1145 <xsl:when test="$mode='getBaseClassName'">
1146 <xsl:if test="$supports='strict' or $supports='yes'">
1147 <xsl:text>, COMBaseWithEI</xsl:text>
1148 </xsl:if>
1149 </xsl:when>
1150 <xsl:otherwise>
1151 <xsl:if test="$supports='strict' or $supports='yes'">
1152 <xsl:text> if (mRC != S_OK)&#x0A; {&#x0A;</xsl:text>
1153 <xsl:text> fetchErrorInfo (mIface, &amp;COM_IIDOF (Base::Iface));&#x0A;</xsl:text>
1154 <xsl:if test="$supports='strict'">
1155 <xsl:text> AssertMsg (errInfo.isFullAvailable(), </xsl:text>
1156 <xsl:text>("for RC=0x%08X\n", mRC));&#x0A;</xsl:text>
1157 </xsl:if>
1158 <xsl:text> }&#x0A;</xsl:text>
1159 </xsl:if>
1160 </xsl:otherwise>
1161 </xsl:choose>
1162</xsl:template>
1163
1164<xsl:template name="composeMethodCallParam">
1165
1166 <xsl:param name="isIn" select="@dir='in'"/>
1167 <xsl:param name="isOut" select="@dir='out' or @dir='return'"/>
1168
1169 <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
1170
1171 <xsl:choose>
1172 <!-- safearrays -->
1173 <xsl:when test="@safearray='yes'">
1174 <xsl:choose>
1175 <xsl:when test="$isIn">
1176 <xsl:text>ComSafeArrayAsInParam (</xsl:text>
1177 <xsl:value-of select="@name"/>
1178 <xsl:text>)</xsl:text>
1179 </xsl:when>
1180 <xsl:when test="$isOut">
1181 <xsl:text>ComSafeArrayAsOutParam (</xsl:text>
1182 <xsl:value-of select="@name"/>
1183 <xsl:text>)</xsl:text>
1184 </xsl:when>
1185 </xsl:choose>
1186 </xsl:when>
1187 <!-- string types -->
1188 <xsl:when test="@type = 'wstring'">
1189 <xsl:choose>
1190 <xsl:when test="$isIn">
1191 <xsl:text>BSTRIn (a</xsl:text>
1192 <xsl:call-template name="capitalize">
1193 <xsl:with-param name="str" select="@name"/>
1194 </xsl:call-template>
1195 <xsl:text>)</xsl:text>
1196 </xsl:when>
1197 <xsl:when test="$isOut">
1198 <xsl:text>BSTROut (a</xsl:text>
1199 <xsl:call-template name="capitalize">
1200 <xsl:with-param name="str" select="@name"/>
1201 </xsl:call-template>
1202 <xsl:text>)</xsl:text>
1203 </xsl:when>
1204 </xsl:choose>
1205 </xsl:when>
1206 <!-- uuid type -->
1207 <xsl:when test="@type = 'uuid'">
1208 <xsl:choose>
1209 <xsl:when test="$isIn">
1210 <xsl:text>GUIDIn (a</xsl:text>
1211 <xsl:call-template name="capitalize">
1212 <xsl:with-param name="str" select="@name"/>
1213 </xsl:call-template>
1214 <xsl:text>)</xsl:text>
1215 </xsl:when>
1216 <xsl:when test="$isOut">
1217 <xsl:text>GUIDOut (a</xsl:text>
1218 <xsl:call-template name="capitalize">
1219 <xsl:with-param name="str" select="@name"/>
1220 </xsl:call-template>
1221 <xsl:text>)</xsl:text>
1222 </xsl:when>
1223 </xsl:choose>
1224 </xsl:when>
1225 <!-- enum types -->
1226 <xsl:when test="
1227 (ancestor::library/enum[@name=current()/@type]) or
1228 (ancestor::library/if[@target=$self_target]/enum[@name=current()/@type])
1229 ">
1230 <xsl:choose>
1231 <xsl:when test="$isIn">
1232 <xsl:text>(</xsl:text>
1233 <xsl:value-of select="@type"/>
1234 <xsl:text>_T) a</xsl:text>
1235 <xsl:call-template name="capitalize">
1236 <xsl:with-param name="str" select="@name"/>
1237 </xsl:call-template>
1238 </xsl:when>
1239 <xsl:when test="$isOut">
1240 <xsl:text>ENUMOut &lt;K</xsl:text>
1241 <xsl:value-of select="@type"/>
1242 <xsl:text>, </xsl:text>
1243 <xsl:value-of select="@type"/>
1244 <xsl:text>_T&gt; (a</xsl:text>
1245 <xsl:call-template name="capitalize">
1246 <xsl:with-param name="str" select="@name"/>
1247 </xsl:call-template>
1248 <xsl:text>)</xsl:text>
1249 </xsl:when>
1250 </xsl:choose>
1251 </xsl:when>
1252 <!-- interface types -->
1253 <xsl:when test="
1254 @type='$unknown' or
1255 ((ancestor::library/enumerator[@name=current()/@type]) or
1256 (ancestor::library/if[@target=$self_target]/enumerator[@name=current()/@type])
1257 ) or
1258 ((ancestor::library/interface[@name=current()/@type]) or
1259 (ancestor::library/if[@target=$self_target]/interface[@name=current()/@type])
1260 ) or
1261 ((ancestor::library/collection[@name=current()/@type]) or
1262 (ancestor::library/if[@target=$self_target]/collection[@name=current()/@type])
1263 )
1264 ">
1265 <xsl:choose>
1266 <xsl:when test="$isIn">
1267 <xsl:text>a</xsl:text>
1268 <xsl:call-template name="capitalize">
1269 <xsl:with-param name="str" select="@name"/>
1270 </xsl:call-template>
1271 <xsl:choose>
1272 <xsl:when test="@type='$unknown'">
1273 <xsl:text>.raw()</xsl:text>
1274 </xsl:when>
1275 <xsl:otherwise>
1276 <xsl:text>.mIface</xsl:text>
1277 </xsl:otherwise>
1278 </xsl:choose>
1279 </xsl:when>
1280 <xsl:when test="$isOut">
1281 <xsl:text>&amp;a</xsl:text>
1282 <xsl:call-template name="capitalize">
1283 <xsl:with-param name="str" select="@name"/>
1284 </xsl:call-template>
1285 <xsl:choose>
1286 <xsl:when test="@type='$unknown'">
1287 <xsl:text>.rawRef()</xsl:text>
1288 </xsl:when>
1289 <xsl:otherwise>
1290 <xsl:text>.mIface</xsl:text>
1291 </xsl:otherwise>
1292 </xsl:choose>
1293 </xsl:when>
1294 </xsl:choose>
1295 </xsl:when>
1296 <!-- currently unsupported types -->
1297 <xsl:when test="@type = 'string'">
1298 <xsl:message terminate="yes">
1299 <xsl:text>Parameter type </xsl:text>
1300 <xsl:value-of select="@type"/>
1301 <xsl:text>is not currently supported</xsl:text>
1302 </xsl:message>
1303 </xsl:when>
1304 <!-- assuming scalar types -->
1305 <xsl:otherwise>
1306 <xsl:choose>
1307 <xsl:when test="$isIn">
1308 <xsl:text>a</xsl:text>
1309 <xsl:call-template name="capitalize">
1310 <xsl:with-param name="str" select="@name"/>
1311 </xsl:call-template>
1312 </xsl:when>
1313 <xsl:when test="$isOut">
1314 <xsl:text>&amp;a</xsl:text>
1315 <xsl:call-template name="capitalize">
1316 <xsl:with-param name="str" select="@name"/>
1317 </xsl:call-template>
1318 </xsl:when>
1319 </xsl:choose>
1320 </xsl:otherwise>
1321 </xsl:choose>
1322</xsl:template>
1323
1324
1325<!--
1326 * attribute/parameter type conversion (returns plain Qt type name)
1327-->
1328<xsl:template match="
1329 attribute/@type | param/@type |
1330 enumerator/@type | collection/@type | collection/@enumerator
1331">
1332 <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
1333
1334 <xsl:if test="../@array and ../@safearray='yes'">
1335 <xsl:message terminate="yes">
1336 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
1337 <xsl:text>either 'array' or 'safearray="yes"' attribute is allowed, but not both!</xsl:text>
1338 </xsl:message>
1339 </xsl:if>
1340
1341 <xsl:if test="../@array and ((name(..)='param' and ../@dir='return') or (name(..)='attribute'))">
1342 <xsl:message terminate="yes">
1343 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
1344 <xsl:text>return 'array' parameters and 'array' attributes are not supported, use 'safearray="yes"' instead.</xsl:text>
1345 </xsl:message>
1346 </xsl:if>
1347
1348 <xsl:choose>
1349 <!-- modifiers (ignored for 'enumeration' attributes)-->
1350 <xsl:when test="name(current())='type' and ../@mod">
1351 <xsl:if test="../@safearray">
1352 <xsl:message terminate="yes">
1353 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
1354 <xsl:text>either 'safearray' or 'mod' attribute is allowed, but not both!</xsl:text>
1355 </xsl:message>
1356 </xsl:if>
1357 <xsl:if test="../@array">
1358 <xsl:message terminate="yes">
1359 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
1360 <xsl:text>either 'array' or 'mod' attribute is allowed, but not both!</xsl:text>
1361 </xsl:message>
1362 </xsl:if>
1363 <xsl:choose>
1364 <xsl:when test="../@mod='ptr'">
1365 <xsl:choose>
1366 <!-- standard types -->
1367 <!--xsl:when test=".='result'">??</xsl:when-->
1368 <xsl:when test=".='boolean'">BOOL *</xsl:when>
1369 <xsl:when test=".='octet'">BYTE *</xsl:when>
1370 <xsl:when test=".='short'">SHORT *</xsl:when>
1371 <xsl:when test=".='unsigned short'">USHORT *</xsl:when>
1372 <xsl:when test=".='long'">LONG *</xsl:when>
1373 <xsl:when test=".='long long'">LONG64 *</xsl:when>
1374 <xsl:when test=".='unsigned long'">ULONG *</xsl:when>
1375 <xsl:when test=".='unsigned long long'">ULONG64 *</xsl:when>
1376 <xsl:when test=".='char'">CHAR *</xsl:when>
1377 <!--<xsl:when test=".='string'">??</xsl:when-->
1378 <xsl:when test=".='wchar'">OLECHAR *</xsl:when>
1379 <!--<xsl:when test=".='wstring'">??</xsl:when-->
1380 <xsl:otherwise>
1381 <xsl:message terminate="yes">
1382 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
1383 <xsl:text>attribute 'mod=</xsl:text>
1384 <xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
1385 <xsl:text>' cannot be used with type </xsl:text>
1386 <xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
1387 </xsl:message>
1388 </xsl:otherwise>
1389 </xsl:choose>
1390 </xsl:when>
1391 <xsl:otherwise>
1392 <xsl:message terminate="yes">
1393 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
1394 <xsl:value-of select="concat('value &quot;',../@mod,'&quot; ')"/>
1395 <xsl:text>of attribute 'mod' is invalid!</xsl:text>
1396 </xsl:message>
1397 </xsl:otherwise>
1398 </xsl:choose>
1399 </xsl:when>
1400 <!-- no modifiers -->
1401 <xsl:otherwise>
1402 <xsl:if test="../@safearray">
1403 <xsl:text>QVector &lt;</xsl:text>
1404 </xsl:if>
1405 <xsl:choose>
1406 <!-- standard types -->
1407 <xsl:when test=".='result'">HRESULT</xsl:when>
1408 <xsl:when test=".='boolean'">BOOL</xsl:when>
1409 <xsl:when test=".='octet'">BYTE</xsl:when>
1410 <xsl:when test=".='short'">SHORT</xsl:when>
1411 <xsl:when test=".='unsigned short'">USHORT</xsl:when>
1412 <xsl:when test=".='long'">LONG</xsl:when>
1413 <xsl:when test=".='long long'">LONG64</xsl:when>
1414 <xsl:when test=".='unsigned long'">ULONG</xsl:when>
1415 <xsl:when test=".='unsigned long long'">ULONG64</xsl:when>
1416 <xsl:when test=".='char'">CHAR</xsl:when>
1417 <xsl:when test=".='string'">CHAR *</xsl:when>
1418 <xsl:when test=".='wchar'">OLECHAR</xsl:when>
1419 <xsl:when test=".='wstring'">QString</xsl:when>
1420 <!-- UUID type -->
1421 <xsl:when test=".='uuid'">QUuid</xsl:when>
1422 <!-- system interface types -->
1423 <xsl:when test=".='$unknown'">CUnknown</xsl:when>
1424 <xsl:otherwise>
1425 <xsl:choose>
1426 <!-- enum types -->
1427 <xsl:when test="
1428 (ancestor::library/enum[@name=current()]) or
1429 (ancestor::library/if[@target=$self_target]/enum[@name=current()])
1430 ">
1431 <xsl:value-of select="concat('K',string(.))"/>
1432 </xsl:when>
1433 <!-- custom interface types -->
1434 <xsl:when test="
1435 (name(current())='enumerator' and
1436 ((ancestor::library/enumerator[@name=current()]) or
1437 (ancestor::library/if[@target=$self_target]/enumerator[@name=current()]))
1438 ) or
1439 ((ancestor::library/interface[@name=current()]) or
1440 (ancestor::library/if[@target=$self_target]/interface[@name=current()])
1441 ) or
1442 ((ancestor::library/collection[@name=current()]) or
1443 (ancestor::library/if[@target=$self_target]/collection[@name=current()])
1444 )
1445 ">
1446 <xsl:value-of select="concat('C',substring(.,2))"/>
1447 </xsl:when>
1448 <!-- other types -->
1449 <xsl:otherwise>
1450 <xsl:message terminate="yes">
1451 <xsl:text>Unknown parameter type: </xsl:text>
1452 <xsl:value-of select="."/>
1453 </xsl:message>
1454 </xsl:otherwise>
1455 </xsl:choose>
1456 </xsl:otherwise>
1457 </xsl:choose>
1458 <xsl:if test="../@safearray">
1459 <xsl:text>&gt;</xsl:text>
1460 </xsl:if>
1461 </xsl:otherwise>
1462 </xsl:choose>
1463</xsl:template>
1464
1465
1466<!--
1467 * generates a null initializer for all scalar types (such as bool or long)
1468 * and enum types in the form of ' = <null_initializer>', or nothing for other
1469 * types.
1470-->
1471<xsl:template match="
1472 attribute/@type | param/@type |
1473 enumerator/@type | collection/@type | collection/@enumerator
1474" mode="initializer">
1475
1476 <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
1477
1478 <xsl:choose>
1479 <!-- safearrays don't need initializers -->
1480 <xsl:when test="../@safearray">
1481 </xsl:when>
1482 <!-- modifiers (ignored for 'enumeration' attributes)-->
1483 <xsl:when test="name(current())='type' and ../@mod">
1484 <xsl:choose>
1485 <xsl:when test="../@mod='ptr'">
1486 <xsl:choose>
1487 <!-- standard types -->
1488 <!--xsl:when test=".='result'">??</xsl:when-->
1489 <xsl:when test=".='boolean'"> = NULL</xsl:when>
1490 <xsl:when test=".='octet'"> = NULL</xsl:when>
1491 <xsl:when test=".='short'"> = NULL</xsl:when>
1492 <xsl:when test=".='unsigned short'"> = NULL</xsl:when>
1493 <xsl:when test=".='long'"> = NULL</xsl:when>
1494 <xsl:when test=".='long long'"> = NULL</xsl:when>
1495 <xsl:when test=".='unsigned long'"> = NULL</xsl:when>
1496 <xsl:when test=".='unsigned long long'"> = NULL</xsl:when>
1497 <xsl:when test=".='char'"> = NULL</xsl:when>
1498 <!--<xsl:when test=".='string'">??</xsl:when-->
1499 <xsl:when test=".='wchar'"> = NULL</xsl:when>
1500 <!--<xsl:when test=".='wstring'">??</xsl:when-->
1501 <xsl:otherwise>
1502 <xsl:message terminate="yes">
1503 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
1504 <xsl:text>attribute 'mod=</xsl:text>
1505 <xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
1506 <xsl:text>' cannot be used with type </xsl:text>
1507 <xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
1508 </xsl:message>
1509 </xsl:otherwise>
1510 </xsl:choose>
1511 </xsl:when>
1512 <xsl:otherwise>
1513 <xsl:message terminate="yes">
1514 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
1515 <xsl:value-of select="concat('value &quot;',../@mod,'&quot; ')"/>
1516 <xsl:text>of attribute 'mod' is invalid!</xsl:text>
1517 </xsl:message>
1518 </xsl:otherwise>
1519 </xsl:choose>
1520 </xsl:when>
1521 <!-- no modifiers -->
1522 <xsl:otherwise>
1523 <xsl:choose>
1524 <!-- standard types that need a zero initializer -->
1525 <xsl:when test=".='result'"> = S_OK</xsl:when>
1526 <xsl:when test=".='boolean'"> = FALSE</xsl:when>
1527 <xsl:when test=".='octet'"> = 0</xsl:when>
1528 <xsl:when test=".='short'"> = 0</xsl:when>
1529 <xsl:when test=".='unsigned short'"> = 0</xsl:when>
1530 <xsl:when test=".='long'"> = 0</xsl:when>
1531 <xsl:when test=".='long long'"> = 0</xsl:when>
1532 <xsl:when test=".='unsigned long'"> = 0</xsl:when>
1533 <xsl:when test=".='unsigned long long'"> = 0</xsl:when>
1534 <xsl:when test=".='char'"> = 0</xsl:when>
1535 <xsl:when test=".='string'"> = NULL</xsl:when>
1536 <xsl:when test=".='wchar'"> = 0</xsl:when>
1537 <xsl:otherwise>
1538 <xsl:choose>
1539 <!-- enum types initialized with 0 -->
1540 <xsl:when test="
1541 (ancestor::library/enum[@name=current()]) or
1542 (ancestor::library/if[@target=$self_target]/enum[@name=current()])
1543 ">
1544 <xsl:value-of select="concat(' = (K',string(.),') 0')"/>
1545 </xsl:when>
1546 </xsl:choose>
1547 </xsl:otherwise>
1548 </xsl:choose>
1549 </xsl:otherwise>
1550 </xsl:choose>
1551</xsl:template>
1552
1553
1554<!--
1555 * attribute/parameter type conversion (for method declaration)
1556-->
1557<xsl:template match="attribute/@type | param/@type" mode="param">
1558
1559 <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
1560
1561 <xsl:choose>
1562 <!-- class types -->
1563 <xsl:when test="
1564 .='string' or
1565 .='wstring' or
1566 ../@safearray='yes' or
1567 ((ancestor::library/enum[@name=current()]) or
1568 (ancestor::library/if[@target=$self_target]/enum[@name=current()])
1569 ) or
1570 .='$unknown' or
1571 ((ancestor::library/enumerator[@name=current()]) or
1572 (ancestor::library/if[@target=$self_target]/enumerator[@name=current()])
1573 ) or
1574 ((ancestor::library/interface[@name=current()]) or
1575 (ancestor::library/if[@target=$self_target]/interface[@name=current()])
1576 ) or
1577 ((ancestor::library/collection[@name=current()]) or
1578 (ancestor::library/if[@target=$self_target]/collection[@name=current()])
1579 )
1580 ">
1581 <xsl:choose>
1582 <!-- <attribute> context -->
1583 <xsl:when test="name(..)='attribute'">
1584 <xsl:text>const </xsl:text>
1585 <xsl:apply-templates select="."/>
1586 <xsl:text> &amp;</xsl:text>
1587 </xsl:when>
1588 <!-- <param> context -->
1589 <xsl:when test="name(..)='param'">
1590 <xsl:choose>
1591 <xsl:when test="../@dir='in'">
1592 <xsl:text>const </xsl:text>
1593 <xsl:apply-templates select="."/>
1594 <xsl:text> &amp;</xsl:text>
1595 </xsl:when>
1596 <xsl:when test="../@dir='out'">
1597 <xsl:apply-templates select="."/>
1598 <xsl:text> &amp;</xsl:text>
1599 </xsl:when>
1600 <xsl:when test="../@dir='return'">
1601 <xsl:apply-templates select="."/>
1602 </xsl:when>
1603 </xsl:choose>
1604 </xsl:when>
1605 </xsl:choose>
1606 </xsl:when>
1607 <!-- assume scalar types -->
1608 <xsl:otherwise>
1609 <xsl:choose>
1610 <!-- <attribute> context -->
1611 <xsl:when test="name(..)='attribute'">
1612 <xsl:apply-templates select="."/>
1613 </xsl:when>
1614 <!-- <param> context -->
1615 <xsl:when test="name(..)='param'">
1616 <xsl:choose>
1617 <xsl:when test="../@array">
1618 <xsl:apply-templates select="."/>
1619 <xsl:text> *</xsl:text>
1620 <xsl:if test="../@dir='out'">
1621 <xsl:text> &amp;</xsl:text>
1622 </xsl:if>
1623 </xsl:when>
1624 <xsl:otherwise>
1625 <xsl:apply-templates select="."/>
1626 <xsl:if test="../@dir='out'">
1627 <xsl:text> &amp;</xsl:text>
1628 </xsl:if>
1629 </xsl:otherwise>
1630 </xsl:choose>
1631 </xsl:when>
1632 </xsl:choose>
1633 </xsl:otherwise>
1634 </xsl:choose>
1635</xsl:template>
1636
1637
1638<!--
1639 * attribute/parameter type conversion (returns plain COM type name)
1640 * (basically, copied from midl.xsl)
1641-->
1642<xsl:template match="
1643 attribute/@type | param/@type |
1644 enumerator/@type | collection/@type | collection/@enumerator
1645" mode="com">
1646
1647 <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
1648
1649 <xsl:choose>
1650 <!-- modifiers (ignored for 'enumeration' attributes)-->
1651 <xsl:when test="name(current())='type' and ../@mod">
1652 <xsl:choose>
1653 <xsl:when test="../@mod='ptr'">
1654 <xsl:choose>
1655 <!-- standard types -->
1656 <!--xsl:when test=".='result'">??</xsl:when-->
1657 <xsl:when test=".='boolean'">BOOL *</xsl:when>
1658 <xsl:when test=".='octet'">BYTE *</xsl:when>
1659 <xsl:when test=".='short'">SHORT *</xsl:when>
1660 <xsl:when test=".='unsigned short'">USHORT *</xsl:when>
1661 <xsl:when test=".='long'">LONG *</xsl:when>
1662 <xsl:when test=".='long long'">LONG64 *</xsl:when>
1663 <xsl:when test=".='unsigned long'">ULONG *</xsl:when>
1664 <xsl:when test=".='unsigned long long'">ULONG64 *</xsl:when>
1665 <xsl:when test=".='char'">CHAR *</xsl:when>
1666 <!--xsl:when test=".='string'">??</xsl:when-->
1667 <xsl:when test=".='wchar'">OLECHAR *</xsl:when>
1668 <!--xsl:when test=".='wstring'">??</xsl:when-->
1669 <xsl:otherwise>
1670 <xsl:message terminate="yes">
1671 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
1672 <xsl:text>attribute 'mod=</xsl:text>
1673 <xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
1674 <xsl:text>' cannot be used with type </xsl:text>
1675 <xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
1676 </xsl:message>
1677 </xsl:otherwise>
1678 </xsl:choose>
1679 </xsl:when>
1680 <xsl:otherwise>
1681 <xsl:message terminate="yes">
1682 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
1683 <xsl:value-of select="concat('value &quot;',../@mod,'&quot; ')"/>
1684 <xsl:text>of attribute 'mod' is invalid!</xsl:text>
1685 </xsl:message>
1686 </xsl:otherwise>
1687 </xsl:choose>
1688 </xsl:when>
1689 <!-- no modifiers -->
1690 <xsl:otherwise>
1691 <xsl:choose>
1692 <!-- standard types -->
1693 <xsl:when test=".='result'">HRESULT</xsl:when>
1694 <xsl:when test=".='boolean'">BOOL</xsl:when>
1695 <xsl:when test=".='octet'">BYTE</xsl:when>
1696 <xsl:when test=".='short'">SHORT</xsl:when>
1697 <xsl:when test=".='unsigned short'">USHORT</xsl:when>
1698 <xsl:when test=".='long'">LONG</xsl:when>
1699 <xsl:when test=".='long long'">LONG64</xsl:when>
1700 <xsl:when test=".='unsigned long'">ULONG</xsl:when>
1701 <xsl:when test=".='unsigned long long'">ULONG64</xsl:when>
1702 <xsl:when test=".='char'">CHAR</xsl:when>
1703 <xsl:when test=".='string'">CHAR *</xsl:when>
1704 <xsl:when test=".='wchar'">OLECHAR</xsl:when>
1705 <xsl:when test=".='wstring'">BSTR</xsl:when>
1706 <!-- UUID type -->
1707 <xsl:when test=".='uuid'">GUID</xsl:when>
1708 <!-- system interface types -->
1709 <xsl:when test=".='$unknown'">IUnknown *</xsl:when>
1710 <xsl:otherwise>
1711 <xsl:choose>
1712 <!-- enum types -->
1713 <xsl:when test="
1714 (ancestor::library/enum[@name=current()]) or
1715 (ancestor::library/if[@target=$self_target]/enum[@name=current()])
1716 ">
1717 <xsl:value-of select="."/>
1718 </xsl:when>
1719 <!-- custom interface types -->
1720 <xsl:when test="
1721 (name(current())='enumerator' and
1722 ((ancestor::library/enumerator[@name=current()]) or
1723 (ancestor::library/if[@target=$self_target]/enumerator[@name=current()]))
1724 ) or
1725 ((ancestor::library/interface[@name=current()]) or
1726 (ancestor::library/if[@target=$self_target]/interface[@name=current()])
1727 ) or
1728 ((ancestor::library/collection[@name=current()]) or
1729 (ancestor::library/if[@target=$self_target]/collection[@name=current()])
1730 )
1731 ">
1732 <xsl:value-of select="."/><xsl:text> *</xsl:text>
1733 </xsl:when>
1734 <!-- other types -->
1735 <xsl:otherwise>
1736 <xsl:message terminate="yes">
1737 <xsl:text>Unknown parameter type: </xsl:text>
1738 <xsl:value-of select="."/>
1739 </xsl:message>
1740 </xsl:otherwise>
1741 </xsl:choose>
1742 </xsl:otherwise>
1743 </xsl:choose>
1744 </xsl:otherwise>
1745 </xsl:choose>
1746</xsl:template>
1747
1748
1749<!--
1750 * attribute/parameter type additional hooks.
1751 *
1752 * Called in the context of <attribute> or <param> elements.
1753 *
1754 * @param when When the hook is being called:
1755 * 'pre-call' - right before the method call
1756 * 'post-call' - right after the method call
1757 * @param isSetter Non-empty if called in the cotext of the attribute setter
1758 * call.
1759-->
1760<xsl:template name="hooks">
1761
1762 <xsl:param name="when" select="''"/>
1763 <xsl:param name="isSetter" select="''"/>
1764
1765 <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
1766
1767 <xsl:variable name="is_iface" select="(
1768 ((ancestor::library/enumerator[@name=current()/@type]) or
1769 (ancestor::library/if[@target=$self_target]/enumerator[@name=current()/@type])
1770 ) or
1771 ((ancestor::library/interface[@name=current()/@type]) or
1772 (ancestor::library/if[@target=$self_target]/interface[@name=current()/@type])
1773 ) or
1774 ((ancestor::library/collection[@name=current()/@type]) or
1775 (ancestor::library/if[@target=$self_target]/collection[@name=current()/@type])
1776 )
1777 )"/>
1778
1779 <xsl:variable name="is_enum" select="(
1780 (ancestor::library/enum[@name=current()/@type]) or
1781 (ancestor::library/if[@target=$self_target]/enum[@name=current()/@type])
1782 )"/>
1783
1784 <xsl:choose>
1785 <xsl:when test="$when='pre-call'">
1786 <xsl:choose>
1787 <xsl:when test="@safearray='yes'">
1788 <!-- declare a SafeArray variable -->
1789 <xsl:choose>
1790 <!-- interface types need special treatment here -->
1791 <xsl:when test="@type='$unknown'">
1792 <xsl:text> com::SafeIfaceArray &lt;IUnknown&gt; </xsl:text>
1793 </xsl:when>
1794 <xsl:when test="$is_iface">
1795 <xsl:text> com::SafeIfaceArray &lt;</xsl:text>
1796 <xsl:value-of select="@type"/>
1797 <xsl:text>&gt; </xsl:text>
1798 </xsl:when>
1799 <!-- enums need the _T prefix -->
1800 <xsl:when test="$is_enum">
1801 <xsl:text> com::SafeArray &lt;</xsl:text>
1802 <xsl:value-of select="@type"/>
1803 <xsl:text>_T&gt; </xsl:text>
1804 </xsl:when>
1805 <!-- GUID is special too -->
1806 <xsl:when test="@type='uuid'">
1807 <xsl:text> com::SafeGUIDArray </xsl:text>
1808 </xsl:when>
1809 <!-- everything else is not -->
1810 <xsl:otherwise>
1811 <xsl:text> com::SafeArray &lt;</xsl:text>
1812 <xsl:apply-templates select="@type" mode="com"/>
1813 <xsl:text>&gt; </xsl:text>
1814 </xsl:otherwise>
1815 </xsl:choose>
1816 <xsl:value-of select="@name"/>
1817 <xsl:text>;&#x0A;</xsl:text>
1818 <xsl:if test="(name()='attribute' and $isSetter) or
1819 (name()='param' and @dir='in')">
1820 <!-- convert QVector to SafeArray -->
1821 <xsl:choose>
1822 <!-- interface types need special treatment here -->
1823 <xsl:when test="@type='$unknown' or $is_iface">
1824 <xsl:text> ToSafeIfaceArray (</xsl:text>
1825 </xsl:when>
1826 <xsl:otherwise>
1827 <xsl:text> ToSafeArray (</xsl:text>
1828 </xsl:otherwise>
1829 </xsl:choose>
1830 <xsl:text>a</xsl:text>
1831 <xsl:call-template name="capitalize">
1832 <xsl:with-param name="str" select="@name"/>
1833 </xsl:call-template>
1834 <xsl:text>, </xsl:text>
1835 <xsl:value-of select="@name"/>
1836 <xsl:text>);&#x0A;</xsl:text>
1837 </xsl:if>
1838 </xsl:when>
1839 </xsl:choose>
1840 </xsl:when>
1841 <xsl:when test="$when='post-call'">
1842 <xsl:choose>
1843 <xsl:when test="@safearray='yes'">
1844 <xsl:if test="(name()='attribute' and not($isSetter)) or
1845 (name()='param' and (@dir='out' or @dir='return'))">
1846 <!-- convert SafeArray to QVector -->
1847 <xsl:choose>
1848 <!-- interface types need special treatment here -->
1849 <xsl:when test="@type='$unknown' or $is_iface">
1850 <xsl:text> FromSafeIfaceArray (</xsl:text>
1851 </xsl:when>
1852 <xsl:otherwise>
1853 <xsl:text> FromSafeArray (</xsl:text>
1854 </xsl:otherwise>
1855 </xsl:choose>
1856 <xsl:value-of select="@name"/>
1857 <xsl:text>, </xsl:text>
1858 <xsl:text>a</xsl:text>
1859 <xsl:call-template name="capitalize">
1860 <xsl:with-param name="str" select="@name"/>
1861 </xsl:call-template>
1862 <xsl:text>);&#x0A;</xsl:text>
1863 </xsl:if>
1864 </xsl:when>
1865 </xsl:choose>
1866 </xsl:when>
1867 <xsl:otherwise>
1868 <xsl:message terminate="yes">
1869 <xsl:text>Invalid when value: </xsl:text>
1870 <xsl:value-of select="$when"/>
1871 </xsl:message>
1872 </xsl:otherwise>
1873 </xsl:choose>
1874
1875</xsl:template>
1876
1877
1878</xsl:stylesheet>
1879
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