VirtualBox

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

Last change on this file since 3481 was 2988, checked in by vboxsync, 17 years ago

InnoTek -> innotek part 4: more miscellaneous files.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 53.9 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-2007 innotek GmbH
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 as published by the Free Software Foundation,
19 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
20 * distribution. VirtualBox OSE is distributed in the hope that it will
21 * be useful, but WITHOUT ANY WARRANTY of any kind.
22 *
23 * If you received this file as part of a commercial VirtualBox
24 * distribution, then only the terms of your commercial VirtualBox
25 * license agreement apply instead of the previous paragraph.
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 * This contains Qt-based wrapper classes for [XP]COM interfaces.
109 *
110 * DO NOT EDIT! This is a generated file.
111 * Generated from: src/VBox/Main/idl/VirtualBox.xidl (VirtualBox's interface definitions in XML)
112 * Generator: src/VBox/Frontends/VirtualBox/include/COMWrappers.xsl
113 *
114 * Note: this header must be included from COMDefs.h, never directly.
115 */
116</xsl:text>
117
118 <!-- all enum declarations as a single class -->
119<xsl:text>
120// all enums
121
122class CEnums
123{
124public:
125
126</xsl:text>
127 <xsl:for-each select="*/enum">
128 <xsl:text> enum </xsl:text>
129 <xsl:value-of select="@name"/>
130 <xsl:text> {&#x0A;</xsl:text>
131 <xsl:for-each select="const">
132 <xsl:text> </xsl:text>
133 <xsl:value-of select="@name"/>
134 <xsl:text> = ::</xsl:text>
135 <xsl:value-of select="parent::node()/@name"/>
136 <xsl:text>_</xsl:text>
137 <xsl:value-of select="@name"/>
138 <xsl:text>,&#x0A;</xsl:text>
139 </xsl:for-each>
140 <xsl:text> </xsl:text>
141 <xsl:value-of select="@name"/>
142 <xsl:text>_COUNT&#x0A;</xsl:text>
143 <xsl:text> };&#x0A;&#x0A;</xsl:text>
144 </xsl:for-each>
145 <xsl:text>};&#x0A;&#x0A;</xsl:text>
146
147 <xsl:apply-templates/>
148
149</xsl:template>
150
151
152<!--
153 * encloses |if| element's contents (unconditionally expanded by
154 * <apply-templates mode="define"/>) with #ifdef / #endif.
155 *
156 * @note this can produce an empty #if/#endif block if |if|'s children
157 * expand to nothing (such as |cpp|). I see no need to handle this situation
158 * specially.
159-->
160<xsl:template match="if" mode="define">
161 <xsl:if test="(@target='xpidl') or (@target='midl')">
162 <xsl:apply-templates select="." mode="begin"/>
163 <xsl:apply-templates mode="define"/>
164 <xsl:apply-templates select="." mode="end"/>
165 <xsl:text>&#x0A;</xsl:text>
166 </xsl:if>
167</xsl:template>
168
169
170<!--
171 * encloses |if| element's contents (unconditionally expanded by
172 * <apply-templates mode="declare"/>) with #ifdef / #endif.
173 *
174 * @note this can produce an empty #if/#endif block if |if|'s children
175 * expand to nothing (such as |cpp|). I see no need to handle this situation
176 * specially.
177-->
178<xsl:template match="if" mode="declare">
179 <xsl:if test="(@target='xpidl') or (@target='midl')">
180 <xsl:apply-templates select="." mode="begin"/>
181 <xsl:apply-templates mode="declare"/>
182 <xsl:apply-templates select="." mode="end"/>
183 <xsl:text>&#x0A;</xsl:text>
184 </xsl:if>
185</xsl:template>
186
187
188<!--
189 * |<if target="...">| element): begin and end.
190-->
191<xsl:template match="if" mode="begin">
192 <xsl:if test="@target='xpidl'">
193 <xsl:text>#if !defined (Q_WS_WIN32)&#x0A;</xsl:text>
194 </xsl:if>
195 <xsl:if test="@target='midl'">
196 <xsl:text>#if defined (Q_WS_WIN32)&#x0A;</xsl:text>
197 </xsl:if>
198</xsl:template>
199<xsl:template match="if" mode="end">
200 <xsl:if test="(@target='xpidl') or (@target='midl')">
201 <xsl:text>#endif&#x0A;</xsl:text>
202 </xsl:if>
203</xsl:template>
204
205
206<!--
207 * cpp_quote
208-->
209<xsl:template match="cpp"/>
210
211
212<!--
213 * #ifdef statement (@if attribute): begin and end
214-->
215<xsl:template match="@if" mode="begin">
216 <xsl:text>#if </xsl:text>
217 <xsl:value-of select="."/>
218 <xsl:text>&#x0A;</xsl:text>
219</xsl:template>
220<xsl:template match="@if" mode="end">
221 <xsl:text>#endif&#x0A;</xsl:text>
222</xsl:template>
223
224
225<!--
226 * libraries
227-->
228<xsl:template match="module">
229 <!-- forward declarations -->
230 <xsl:text>// forward declarations&#x0A;&#x0A;</xsl:text>
231 <xsl:for-each select="interface | collection | enumerator">
232 <xsl:text>class C</xsl:text>
233 <xsl:value-of select="substring(@name,2)"/>
234 <xsl:text>;&#x0A;</xsl:text>
235 </xsl:for-each>
236 <xsl:text>&#x0A;</xsl:text>
237 <!-- wrapper declarations -->
238 <xsl:text>// wrapper declarations&#x0A;&#x0A;</xsl:text>
239 <xsl:apply-templates select="
240 if |
241 interface[not(@internal='yes')] |
242 collection[not(@internal='yes')] |
243 enumerator[not(@internal='yes')]
244 "
245 mode="declare"
246 />
247 <!-- wrapper definitions -->
248 <xsl:text>// wrapper definitions&#x0A;&#x0A;</xsl:text>
249 <xsl:apply-templates select="
250 if |
251 interface[not(@internal='yes')] |
252 collection[not(@internal='yes')] |
253 enumerator[not(@internal='yes')]
254 "
255 mode="define"
256 />
257</xsl:template>
258
259
260<!--
261 * interface declarations
262-->
263<xsl:template match="interface | collection | enumerator" mode="declare">
264
265 <xsl:text>// </xsl:text>
266 <xsl:value-of select="@name"/>
267 <xsl:text> wrapper&#x0A;&#x0A;class C</xsl:text>
268 <xsl:value-of select="substring(@name,2)"/>
269 <xsl:text> : public CInterface &lt;</xsl:text>
270 <xsl:value-of select="@name"/>
271 <!-- use the correct base if supportsErrorInfo -->
272 <xsl:call-template name="tryComposeFetchErrorInfo">
273 <xsl:with-param name="mode" select="'getBaseClassName'"/>
274 </xsl:call-template>
275 <xsl:text>&gt;&#x0A;{&#x0A;public:&#x0A;&#x0A;</xsl:text>
276
277 <!-- generate the Base typedef-->
278 <xsl:text> typedef 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; Base;&#x0A;&#x0A;</xsl:text>
285
286 <xsl:if test="name()='collection'">
287 <xsl:text> // collection stuff&#x0A;&#x0A;</xsl:text>
288 <xsl:text> ULONG GetCount () const;&#x0A;</xsl:text>
289 <xsl:text> </xsl:text>
290 <xsl:apply-templates select="@type"/>
291 <xsl:text> GetItemAt (ULONG index) const;&#x0A;</xsl:text>
292 <xsl:text> </xsl:text>
293 <xsl:apply-templates select="@enumerator"/>
294 <xsl:text> Enumerate () const;&#x0A;&#x0A;</xsl:text>
295 </xsl:if>
296
297 <xsl:if test="name()='enumerator'">
298 <xsl:text> // enumerator stuff&#x0A;&#x0A;</xsl:text>
299 <xsl:text> BOOL HasMore () const;&#x0A;</xsl:text>
300 <xsl:text> </xsl:text>
301 <xsl:apply-templates select="@type"/>
302 <xsl:text> GetNext () const;&#x0A;&#x0A;</xsl:text>
303 <xsl:text> // friend wrappers&#x0A;&#x0A;</xsl:text>
304 <xsl:text> friend class CUnknown;&#x0A;</xsl:text>
305 <xsl:variable name="name" select="@name"/>
306 <xsl:variable name="parent" select=".."/>
307 <!-- for definitions inside <if> -->
308 <xsl:if test="name(..)='if'">
309 <xsl:for-each select="
310 preceding-sibling::collection | following-sibling::collection |
311 ../preceding-sibling::if[@target=$parent/@target]/collection |
312 ../following-sibling::if[@target=$parent/@target]/collection
313 ">
314 <xsl:if test="@enumerator=$name">
315 <xsl:text> friend class C</xsl:text>
316 <xsl:value-of select="substring(@name,2)"/>
317 <xsl:text>;&#x0A;</xsl:text>
318 </xsl:if>
319 </xsl:for-each>
320 </xsl:if>
321 <!-- for definitions outside <if> (i.e. inside <module>) -->
322 <xsl:if test="name(..)!='if'">
323 <xsl:for-each select="
324 preceding-sibling::collection | following-sibling::collection
325 ">
326 <xsl:if test="@enumerator=$name">
327 <xsl:text> friend class C</xsl:text>
328 <xsl:value-of select="substring(@name,2)"/>
329 <xsl:text>;&#x0A;</xsl:text>
330 </xsl:if>
331 </xsl:for-each>
332 </xsl:if>
333 </xsl:if>
334
335 <xsl:if test="name()='interface' or name()='collection'">
336 <xsl:call-template name="declareMembers"/>
337 </xsl:if>
338
339 <xsl:text>};&#x0A;&#x0A;</xsl:text>
340
341</xsl:template>
342
343<xsl:template name="declareMembers">
344
345 <xsl:text> // constructors and assignments taking CUnknown and </xsl:text>
346 <xsl:text>raw iface pointer&#x0A;&#x0A;</xsl:text>
347 <!-- default constructor -->
348 <xsl:text> C</xsl:text>
349 <xsl:value-of select="substring(@name,2)"/>
350 <xsl:text> () : Base () {}&#x0A;</xsl:text>
351 <!-- constructor taking CUnknown -->
352 <xsl:text> C</xsl:text>
353 <xsl:value-of select="substring(@name,2)"/>
354 <xsl:text> (const CUnknown &amp; that) : Base (that) {}&#x0A;</xsl:text>
355 <!-- constructor taking raw iface pointer -->
356 <xsl:text> C</xsl:text>
357 <xsl:value-of select="substring(@name,2)"/>
358 <xsl:text> (</xsl:text>
359 <xsl:value-of select="@name"/>
360 <xsl:text> *i) : Base (i) {}&#x0A;</xsl:text>
361 <!-- assignment taking CUnknown -->
362 <xsl:text> C</xsl:text>
363 <xsl:value-of select="substring(@name,2)"/>
364 <xsl:text> &amp; operator = (const CUnknown &amp; that) {&#x0A; return (C</xsl:text>
365 <xsl:value-of select="substring(@name,2)"/>
366 <xsl:text> &amp;) Base::operator = (that);&#x0A; }&#x0A;&#x0A;</xsl:text>
367
368 <xsl:text> // attributes (properties)&#x0A;&#x0A;</xsl:text>
369 <xsl:apply-templates select=".//attribute[not(@internal='yes')]" mode="declare"/>
370 <xsl:if test=".//attribute[not(@internal='yes')]">
371 <xsl:text>&#x0A;</xsl:text>
372 </xsl:if>
373
374 <xsl:text> // methods&#x0A;&#x0A;</xsl:text>
375 <xsl:apply-templates select=".//method[not(@internal='yes')]" mode="declare"/>
376 <xsl:if test=".//method[not(@internal='yes')]">
377 <xsl:text>&#x0A;</xsl:text>
378 </xsl:if>
379
380 <xsl:text> // friend wrappers&#x0A;&#x0A;</xsl:text>
381 <xsl:text> friend class CUnknown;&#x0A;</xsl:text>
382 <xsl:variable name="name" select="@name"/>
383 <xsl:variable name="parent" select=".."/>
384 <!-- for definitions inside <if> -->
385 <xsl:if test="name(..)='if'">
386 <xsl:for-each select="
387 preceding-sibling::*[self::interface or self::collection or self::enumerator] |
388 following-sibling::*[self::interface or self::collection or self::enumerator] |
389 ../preceding-sibling::*[self::interface or self::collection or self::enumerator] |
390 ../following-sibling::*[self::interface or self::collection or self::enumerator] |
391 ../preceding-sibling::if[@target=$parent/@target]/*[self::interface or self::collection or self::enumerator] |
392 ../following-sibling::if[@target=$parent/@target]/*[self::interface or self::collection or self::enumerator]
393 ">
394 <xsl:if test="
395 ((name()='interface' or name()='collection')
396 and
397 ((name(..)!='if' and (if[@target=$parent/@target]/method/param[@type=$name]
398 or
399 if[@target=$parent/@target]/attribute[@type=$name]))
400 or
401 (.//method/param[@type=$name] or attribute[@type=$name])))
402 or
403 (name(..)='if' and (name()='collection' or name()='enumerator') and @type=$name)
404 ">
405 <xsl:text> friend class C</xsl:text>
406 <xsl:value-of select="substring(@name,2)"/>
407 <xsl:text>;&#x0A;</xsl:text>
408 </xsl:if>
409 </xsl:for-each>
410 </xsl:if>
411 <!-- for definitions outside <if> (i.e. inside <module>) -->
412 <xsl:if test="name(..)!='if'">
413 <xsl:for-each select="
414 preceding-sibling::*[self::interface or self::collection or self::enumerator] |
415 following-sibling::*[self::interface or self::collection or self::enumerator] |
416 preceding-sibling::if/*[self::interface or self::collection or self::enumerator] |
417 following-sibling::if/*[self::interface or self::collection or self::enumerator]
418 ">
419 <xsl:if test="
420 ((name()='interface' or name()='collection')
421 and
422 (.//method/param[@type=$name] or attribute[@type=$name]))
423 or
424 ((name()='collection' or name()='enumerator') and @type=$name)
425 ">
426 <xsl:text> friend class C</xsl:text>
427 <xsl:value-of select="substring(@name,2)"/>
428 <xsl:text>;&#x0A;</xsl:text>
429 </xsl:if>
430 </xsl:for-each>
431 </xsl:if>
432
433</xsl:template>
434
435<xsl:template match="interface//attribute | collection//attribute" mode="declare">
436 <xsl:apply-templates select="parent::node()" mode="begin"/>
437 <xsl:apply-templates select="@if" mode="begin"/>
438 <xsl:call-template name="composeMethod">
439 <xsl:with-param name="return" select="."/>
440 </xsl:call-template>
441 <xsl:if test="not(@readonly='yes')">
442 <xsl:call-template name="composeMethod">
443 <xsl:with-param name="return" select="''"/>
444 </xsl:call-template>
445 </xsl:if>
446 <xsl:apply-templates select="@if" mode="end"/>
447 <xsl:apply-templates select="parent::node()" mode="end"/>
448</xsl:template>
449
450<xsl:template match="interface//method | collection//method" mode="declare">
451 <xsl:apply-templates select="parent::node()" mode="begin"/>
452 <xsl:apply-templates select="@if" mode="begin"/>
453 <xsl:call-template name="composeMethod"/>
454 <xsl:apply-templates select="@if" mode="end"/>
455 <xsl:apply-templates select="parent::node()" mode="end"/>
456</xsl:template>
457
458
459<!--
460 * interface definitions
461-->
462<xsl:template match="interface | collection | enumerator" mode="define">
463
464 <xsl:text>// </xsl:text>
465 <xsl:value-of select="@name"/>
466 <xsl:text> wrapper&#x0A;&#x0A;</xsl:text>
467
468 <xsl:if test="name()='collection'">
469 <!-- GetCount -->
470 <xsl:text>inline ULONG C</xsl:text>
471 <xsl:value-of select="substring(@name,2)"/>
472 <xsl:text>::GetCount () const {&#x0A;</xsl:text>
473 <xsl:text> ULONG count = 0;&#x0A;</xsl:text>
474 <xsl:text> Assert (mIface);&#x0A;</xsl:text>
475 <xsl:text> if (!mIface)&#x0A; return count;&#x0A;</xsl:text>
476 <xsl:text> mRC = mIface->COMGETTER(Count) (&amp;count);&#x0A;</xsl:text>
477 <xsl:call-template name="tryComposeFetchErrorInfo"/>
478 <xsl:text> return count;&#x0A;</xsl:text>
479 <xsl:text>}&#x0A;&#x0A;</xsl:text>
480 <!-- GetItemAt -->
481 <xsl:text>inline </xsl:text>
482 <xsl:apply-templates select="@type"/>
483 <xsl:text> C</xsl:text>
484 <xsl:value-of select="substring(@name,2)"/>
485 <xsl:text>::GetItemAt (ULONG index) const {&#x0A;</xsl:text>
486 <xsl:text> </xsl:text><xsl:apply-templates select="@type"/>
487 <xsl:text> item;&#x0A;</xsl:text>
488 <xsl:text> Assert (mIface);&#x0A;</xsl:text>
489 <xsl:text> if (!mIface)&#x0A; return item;&#x0A;</xsl:text>
490 <xsl:text> mRC = mIface->GetItemAt (index, &amp;item.mIface);&#x0A;</xsl:text>
491 <xsl:call-template name="tryComposeFetchErrorInfo"/>
492 <xsl:text> return item;&#x0A;</xsl:text>
493 <xsl:text>}&#x0A;&#x0A;</xsl:text>
494 <!-- Enumerate -->
495 <xsl:text>inline </xsl:text>
496 <xsl:apply-templates select="@enumerator"/>
497 <xsl:text> C</xsl:text>
498 <xsl:value-of select="substring(@name,2)"/>
499 <xsl:text>::Enumerate () const {&#x0A;</xsl:text>
500 <xsl:text> </xsl:text><xsl:apply-templates select="@enumerator"/>
501 <xsl:text> enumerator;&#x0A;</xsl:text>
502 <xsl:text> Assert (mIface);&#x0A;</xsl:text>
503 <xsl:text> if (!mIface)&#x0A; return enumerator;&#x0A;</xsl:text>
504 <xsl:text> mRC = mIface->Enumerate (&amp;enumerator.mIface);&#x0A;</xsl:text>
505 <xsl:call-template name="tryComposeFetchErrorInfo"/>
506 <xsl:text> return enumerator;&#x0A;</xsl:text>
507 <xsl:text>}&#x0A;&#x0A;</xsl:text>
508 </xsl:if>
509
510 <xsl:if test="name()='enumerator'">
511 <!-- HasMore -->
512 <xsl:text>inline BOOL C</xsl:text>
513 <xsl:value-of select="substring(@name,2)"/>
514 <xsl:text>::HasMore () const {&#x0A;</xsl:text>
515 <xsl:text> BOOL more = FALSE;&#x0A;</xsl:text>
516 <xsl:text> Assert (mIface);&#x0A;</xsl:text>
517 <xsl:text> if (!mIface)&#x0A; return more;&#x0A;</xsl:text>
518 <xsl:text> mRC = mIface->HasMore (&amp;more);&#x0A;</xsl:text>
519 <xsl:call-template name="tryComposeFetchErrorInfo"/>
520 <xsl:text> return more;&#x0A;</xsl:text>
521 <xsl:text>}&#x0A;&#x0A;</xsl:text>
522 <!-- GetNext -->
523 <xsl:text>inline </xsl:text>
524 <xsl:apply-templates select="@type"/>
525 <xsl:text> C</xsl:text>
526 <xsl:value-of select="substring(@name,2)"/>
527 <xsl:text>::GetNext () const {&#x0A;</xsl:text>
528 <xsl:text> </xsl:text><xsl:apply-templates select="@type"/>
529 <xsl:text> next;&#x0A;</xsl:text>
530 <xsl:text> Assert (mIface);&#x0A;</xsl:text>
531 <xsl:text> if (!mIface)&#x0A; return next;&#x0A;</xsl:text>
532 <xsl:text> mRC = mIface->GetNext (&amp;next.mIface);&#x0A;</xsl:text>
533 <xsl:call-template name="tryComposeFetchErrorInfo"/>
534 <xsl:text> return next;&#x0A;</xsl:text>
535 <xsl:text>}&#x0A;&#x0A;</xsl:text>
536 </xsl:if>
537
538 <xsl:if test="name()='interface' or name()='collection'">
539 <xsl:call-template name="defineMembers"/>
540 </xsl:if>
541
542</xsl:template>
543
544<xsl:template name="defineMembers">
545 <xsl:apply-templates select=".//attribute[not(@internal='yes')]" mode="define"/>
546 <xsl:apply-templates select=".//method[not(@internal='yes')]" mode="define"/>
547</xsl:template>
548
549<xsl:template match="interface//attribute | collection//attribute" mode="define">
550 <xsl:apply-templates select="parent::node()" mode="begin"/>
551 <xsl:apply-templates select="@if" mode="begin"/>
552 <xsl:call-template name="composeMethod">
553 <xsl:with-param name="return" select="."/>
554 <xsl:with-param name="define" select="'yes'"/>
555 </xsl:call-template>
556 <xsl:if test="not(@readonly='yes')">
557 <xsl:call-template name="composeMethod">
558 <xsl:with-param name="return" select="''"/>
559 <xsl:with-param name="define" select="'yes'"/>
560 </xsl:call-template>
561 </xsl:if>
562 <xsl:apply-templates select="@if" mode="end"/>
563 <xsl:apply-templates select="parent::node()" mode="end"/>
564 <xsl:text>&#x0A;</xsl:text>
565</xsl:template>
566
567<xsl:template match="interface//method | collection//method" mode="define">
568 <xsl:apply-templates select="parent::node()" mode="begin"/>
569 <xsl:apply-templates select="@if" mode="begin"/>
570 <xsl:call-template name="composeMethod">
571 <xsl:with-param name="define" select="'yes'"/>
572 </xsl:call-template>
573 <xsl:apply-templates select="@if" mode="end"/>
574 <xsl:apply-templates select="parent::node()" mode="end"/>
575 <xsl:text>&#x0A;</xsl:text>
576</xsl:template>
577
578
579<!--
580 * co-classes
581-->
582<xsl:template match="class"/>
583
584
585<!--
586 * enums
587-->
588<xsl:template match="enum"/>
589
590
591<!--
592 * base template to produce interface methods
593 *
594 * @param return
595 * - in <attribute> context, must be '.' for getters and
596 * '' for setters
597 * - in <method> context, must not be specified (the default value
598 * will apply)
599 * @param define
600 * 'yes' to procuce inlined definition outside the class
601 * declaration, or
602 * empty string to produce method declaration only (w/o body)
603-->
604<xsl:template name="composeMethod">
605 <xsl:param name="return" select="param[@dir='return']"/>
606 <xsl:param name="define" select="''"/>
607 <xsl:variable name="namespace" select="(ancestor::interface | ancestor::collection)[1]"/>
608 <xsl:choose>
609 <!-- no return value -->
610 <xsl:when test="not($return)">
611 <xsl:choose>
612 <xsl:when test="$define">
613 <xsl:text>inline </xsl:text>
614 </xsl:when>
615 <xsl:otherwise>
616 <xsl:text> </xsl:text>
617 </xsl:otherwise>
618 </xsl:choose>
619 <xsl:text>void </xsl:text>
620 <xsl:if test="$define">
621 <xsl:text>C</xsl:text>
622 <xsl:value-of select="substring($namespace/@name,2)"/>
623 <xsl:text>::</xsl:text>
624 </xsl:if>
625 <xsl:call-template name="composeMethodDecl">
626 <xsl:with-param name="isSetter" select="'yes'"/>
627 </xsl:call-template>
628 <xsl:if test="$define">
629 <xsl:text> {&#x0A;</xsl:text>
630 <!-- iface assertion -->
631 <xsl:text> Assert (mIface);&#x0A;</xsl:text>
632 <xsl:text> if (!mIface)&#x0A; return;&#x0A;</xsl:text>
633 <!-- method call -->
634 <xsl:call-template name="composeMethodCall">
635 <xsl:with-param name="isSetter" select="'yes'"/>
636 </xsl:call-template>
637 <xsl:text>}&#x0A;</xsl:text>
638 </xsl:if>
639 <xsl:if test="not($define)">
640 <xsl:text>;&#x0A;</xsl:text>
641 </xsl:if>
642 </xsl:when>
643 <!-- has a return value -->
644 <xsl:when test="count($return) = 1">
645 <xsl:choose>
646 <xsl:when test="$define">
647 <xsl:text>inline </xsl:text>
648 </xsl:when>
649 <xsl:otherwise>
650 <xsl:text> </xsl:text>
651 </xsl:otherwise>
652 </xsl:choose>
653 <xsl:apply-templates select="$return/@type"/>
654 <xsl:text> </xsl:text>
655 <xsl:if test="$define">
656 <xsl:text>C</xsl:text>
657 <xsl:value-of select="substring($namespace/@name,2)"/>
658 <xsl:text>::</xsl:text>
659 </xsl:if>
660 <xsl:call-template name="composeMethodDecl"/>
661 <xsl:if test="$define">
662 <xsl:text> {&#x0A; </xsl:text>
663 <xsl:apply-templates select="$return/@type"/>
664 <xsl:text> a_</xsl:text>
665 <!-- ### xsl:call-template name="capitalize">
666 <xsl:with-param name="str" select="$return/@name"/>
667 </xsl:call-template-->
668 <!--
669 using one of the blocks marked with ### causes sabcmd on RedHat
670 to stupidly fail, so we use <value-of> instead.
671 -->
672 <xsl:value-of select="$return/@name"/>
673 <xsl:apply-templates select="$return/@type" mode="initializer"/>
674 <xsl:text>;&#x0A;</xsl:text>
675 <!-- iface assertion -->
676 <xsl:text> Assert (mIface);&#x0A;</xsl:text>
677 <xsl:text> if (!mIface)&#x0A; return a_</xsl:text>
678 <!-- ### xsl:call-template name="capitalize">
679 <xsl:with-param name="str" select="$return/@name"/>
680 </xsl:call-template-->
681 <xsl:value-of select="$return/@name"/>
682 <xsl:text>;&#x0A;</xsl:text>
683 <!-- method call -->
684 <xsl:call-template name="composeMethodCall"/>
685 <!-- return statement -->
686 <xsl:text> return a_</xsl:text>
687 <!-- ### xsl:call-template name="capitalize">
688 <xsl:with-param name="str" select="$return/@name"/>
689 </xsl:call-template -->
690 <xsl:value-of select="$return/@name"/>
691 <xsl:text>;&#x0A;}&#x0A;</xsl:text>
692 </xsl:if>
693 <xsl:if test="not($define)">
694 <xsl:text>;&#x0A;</xsl:text>
695 </xsl:if>
696 </xsl:when>
697 <!-- otherwise error -->
698 <xsl:otherwise>
699 <xsl:message terminate="yes">
700 <xsl:text>More than one return value in method: </xsl:text>
701 <xsl:value-of select="$namespace/@name"/>
702 <xsl:text>::</xsl:text>
703 <xsl:value-of select="@name"/>
704 </xsl:message>
705 </xsl:otherwise>
706 </xsl:choose>
707</xsl:template>
708
709<xsl:template name="composeMethodDecl">
710 <xsl:param name="isSetter" select="''"/>
711 <xsl:choose>
712 <!-- attribute method call -->
713 <xsl:when test="name()='attribute'">
714 <xsl:choose>
715 <xsl:when test="$isSetter">
716 <!-- name -->
717 <xsl:text>Set</xsl:text>
718 <xsl:call-template name="capitalize">
719 <xsl:with-param name="str" select="@name"/>
720 </xsl:call-template>
721 <xsl:text> (</xsl:text>
722 <!-- parameter -->
723 <xsl:apply-templates select="@type" mode="param"/>
724 <xsl:text> a_</xsl:text>
725 <!-- ### xsl:call-template name="capitalize">
726 <xsl:with-param name="str" select="@name"/>
727 </xsl:call-template -->
728 <xsl:value-of select="@name"/>
729 <xsl:text>)</xsl:text>
730 </xsl:when>
731 <xsl:otherwise>
732 <!-- name -->
733 <xsl:text>Get</xsl:text>
734 <xsl:call-template name="capitalize">
735 <xsl:with-param name="str" select="@name"/>
736 </xsl:call-template>
737 <xsl:text> (</xsl:text>
738 <!-- const method -->
739 <xsl:text>) const</xsl:text>
740 </xsl:otherwise>
741 </xsl:choose>
742 </xsl:when>
743 <!-- regular method call -->
744 <xsl:when test="name()='method'">
745 <!-- name -->
746 <xsl:call-template name="capitalize">
747 <xsl:with-param name="str" select="@name"/>
748 </xsl:call-template>
749 <xsl:text> (</xsl:text>
750 <!-- parameters -->
751 <xsl:for-each select="param[@dir!='return']">
752 <xsl:apply-templates select="@type" mode="param"/>
753 <xsl:text> a_</xsl:text>
754 <!-- ### xsl:call-template name="capitalize">
755 <xsl:with-param name="str" select="@name"/>
756 </xsl:call-template -->
757 <xsl:value-of select="@name"/>
758 <xsl:if test="position() != last()">
759 <xsl:text>, </xsl:text>
760 </xsl:if>
761 </xsl:for-each>
762 <xsl:text>)</xsl:text>
763 <!-- const method -->
764 <xsl:if test="@const='yes'"> const</xsl:if>
765 </xsl:when>
766 </xsl:choose>
767</xsl:template>
768
769<xsl:template name="composeMethodCall">
770 <xsl:param name="isSetter" select="''"/>
771 <xsl:text> mRC = mIface-></xsl:text>
772 <xsl:choose>
773 <!-- attribute method call -->
774 <xsl:when test="name()='attribute'">
775 <!-- method name -->
776 <xsl:choose>
777 <xsl:when test="$isSetter">
778 <xsl:text>COMSETTER(</xsl:text>
779 </xsl:when>
780 <xsl:otherwise>
781 <xsl:text>COMGETTER(</xsl:text>
782 </xsl:otherwise>
783 </xsl:choose>
784 <xsl:call-template name="capitalize">
785 <xsl:with-param name="str" select="@name"/>
786 </xsl:call-template>
787 <xsl:text>) (</xsl:text>
788 <!-- parameter -->
789 <xsl:call-template name="composeMethodCallParam">
790 <xsl:with-param name="isIn" select="$isSetter"/>
791 <xsl:with-param name="isOut" select="not($isSetter)"/>
792 </xsl:call-template>
793 </xsl:when>
794 <!-- regular method call -->
795 <xsl:when test="name()='method'">
796 <!-- method name -->
797 <xsl:call-template name="capitalize">
798 <xsl:with-param name="str" select="@name"/>
799 </xsl:call-template>
800 <xsl:text> (</xsl:text>
801 <!-- parameters -->
802 <xsl:for-each select="param">
803 <xsl:call-template name="composeMethodCallParam"/>
804 <xsl:if test="position() != last()">
805 <xsl:text>, </xsl:text>
806 </xsl:if>
807 </xsl:for-each>
808 </xsl:when>
809 </xsl:choose>
810 <xsl:text>);&#x0A;</xsl:text>
811 <xsl:call-template name="tryComposeFetchErrorInfo"/>
812</xsl:template>
813
814<!--
815 * Composes a 'fetch error info' call or returns the name of the
816 * appropriate base class name that provides error info functionality
817 * (depending on the mode parameter). Does nothing if the current
818 * entity (interface, collection or enumerator) does not support error info.
819 *
820 * @param mode
821 * - 'getBaseClassName': expands to the base class name
822 * - any other value: composes a 'fetch error info' method call
823-->
824<xsl:template name="tryComposeFetchErrorInfo">
825 <xsl:param name="mode" select="''"/>
826 <xsl:variable name="ifaceSupportsErrorInfo" select="
827 (ancestor-or-self::interface |
828 ancestor-or-self::collection |
829 ancestor-or-self::enumerator)[1]/@supportsErrorInfo
830 "/>
831 <xsl:variable name="moduleSupportsErrorInfo" select="ancestor::module/@supportsErrorInfo"/>
832 <xsl:choose>
833 <xsl:when test="$ifaceSupportsErrorInfo">
834 <xsl:call-template name="composeFetchErrorInfo">
835 <xsl:with-param name="supports" select="string($ifaceSupportsErrorInfo)"/>
836 <xsl:with-param name="mode" select="$mode"/>
837 </xsl:call-template>
838 </xsl:when>
839 <xsl:when test="$moduleSupportsErrorInfo">
840 <xsl:call-template name="composeFetchErrorInfo">
841 <xsl:with-param name="supports" select="string($moduleSupportsErrorInfo)"/>
842 <xsl:with-param name="mode" select="$mode"/>
843 </xsl:call-template>
844 </xsl:when>
845 </xsl:choose>
846</xsl:template>
847
848<xsl:template name="composeFetchErrorInfo">
849 <xsl:param name="supports" select="''"/>
850 <xsl:param name="mode" select="''"/>
851 <xsl:choose>
852 <xsl:when test="$mode='getBaseClassName'">
853 <xsl:if test="$supports='strict' or $supports='yes'">
854 <xsl:text>, COMBaseWithEI</xsl:text>
855 </xsl:if>
856 </xsl:when>
857 <xsl:otherwise>
858 <xsl:if test="$supports='strict' or $supports='yes'">
859 <xsl:text> if (FAILED (mRC)) {&#x0A;</xsl:text>
860 <xsl:text> fetchErrorInfo (mIface, &amp;COM_IIDOF (Base::Iface));&#x0A;</xsl:text>
861 <xsl:if test="$supports='strict'">
862 <xsl:text> AssertMsg (errInfo.isFullAvailable(), </xsl:text>
863 <xsl:text>("for RC=0x%08X\n", mRC));&#x0A;</xsl:text>
864 </xsl:if>
865 <xsl:text> }&#x0A;</xsl:text>
866 </xsl:if>
867 </xsl:otherwise>
868 </xsl:choose>
869</xsl:template>
870
871<xsl:template name="composeMethodCallParam">
872 <xsl:param name="isIn" select="@dir='in'"/>
873 <xsl:param name="isOut" select="@dir='out' or @dir='return'"/>
874
875 <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
876
877 <xsl:choose>
878 <!-- string types -->
879 <xsl:when test="@type = 'wstring'">
880 <xsl:choose>
881 <xsl:when test="$isIn">
882 <xsl:text>BSTRIn (a_</xsl:text>
883 <!-- ### xsl:call-template name="capitalize">
884 <xsl:with-param name="str" select="@name"/>
885 </xsl:call-template -->
886 <xsl:value-of select="@name"/>
887 <xsl:text>)</xsl:text>
888 </xsl:when>
889 <xsl:when test="$isOut">
890 <xsl:text>BSTROut (a_</xsl:text>
891 <!-- ### xsl:call-template name="capitalize">
892 <xsl:with-param name="str" select="@name"/>
893 </xsl:call-template -->
894 <xsl:value-of select="@name"/>
895 <xsl:text>)</xsl:text>
896 </xsl:when>
897 </xsl:choose>
898 </xsl:when>
899 <!-- uuid type -->
900 <xsl:when test="@type = 'uuid'">
901 <xsl:choose>
902 <xsl:when test="$isIn">
903 <xsl:text>GUIDIn (a_</xsl:text>
904 <!-- ### xsl:call-template name="capitalize">
905 <xsl:with-param name="str" select="@name"/>
906 </xsl:call-template -->
907 <xsl:value-of select="@name"/>
908 <xsl:text>)</xsl:text>
909 </xsl:when>
910 <xsl:when test="$isOut">
911 <xsl:text>GUIDOut (a_</xsl:text>
912 <!-- ### xsl:call-template name="capitalize">
913 <xsl:with-param name="str" select="@name"/>
914 </xsl:call-template -->
915 <xsl:value-of select="@name"/>
916 <xsl:text>)</xsl:text>
917 </xsl:when>
918 </xsl:choose>
919 </xsl:when>
920 <!-- enum types -->
921 <xsl:when test="
922 (ancestor::module/enum[@name=current()/@type]) or
923 (ancestor::module/if[@target=$self_target]/enum[@name=current()/@type])
924 ">
925 <xsl:choose>
926 <xsl:when test="$isIn">
927 <xsl:text>(</xsl:text>
928 <xsl:value-of select="@type"/>
929 <xsl:text>_T) a_</xsl:text>
930 <!-- ### xsl:call-template name="capitalize">
931 <xsl:with-param name="str" select="@name"/>
932 </xsl:call-template -->
933 <xsl:value-of select="@name"/>
934 </xsl:when>
935 <xsl:when test="$isOut">
936 <xsl:text>ENUMOut &lt;CEnums::</xsl:text>
937 <xsl:value-of select="@type"/>
938 <xsl:text>, </xsl:text>
939 <xsl:value-of select="@type"/>
940 <xsl:text>_T&gt; (a_</xsl:text>
941 <!-- ### xsl:call-template name="capitalize">
942 <xsl:with-param name="str" select="@name"/>
943 </xsl:call-template -->
944 <xsl:value-of select="@name"/>
945 <xsl:text>)</xsl:text>
946 </xsl:when>
947 </xsl:choose>
948 </xsl:when>
949 <!-- interface types -->
950 <xsl:when test="
951 @type='$unknown' or
952 ((ancestor::module/enumerator[@name=current()/@type]) or
953 (ancestor::module/if[@target=$self_target]/enumerator[@name=current()/@type])
954 ) or
955 ((ancestor::module/interface[@name=current()/@type]) or
956 (ancestor::module/if[@target=$self_target]/interface[@name=current()/@type])
957 ) or
958 ((ancestor::module/collection[@name=current()/@type]) or
959 (ancestor::module/if[@target=$self_target]/collection[@name=current()/@type])
960 )
961 ">
962 <xsl:choose>
963 <xsl:when test="$isIn">
964 <xsl:text>a_</xsl:text>
965 <!-- ### xsl:call-template name="capitalize">
966 <xsl:with-param name="str" select="@name"/>
967 </xsl:call-template -->
968 <xsl:value-of select="@name"/>
969 <xsl:choose>
970 <xsl:when test="@type='$unknown'">
971 <xsl:text>.iface()</xsl:text>
972 </xsl:when>
973 <xsl:otherwise>
974 <xsl:text>.mIface</xsl:text>
975 </xsl:otherwise>
976 </xsl:choose>
977 </xsl:when>
978 <xsl:when test="$isOut">
979 <xsl:text>&amp;a_</xsl:text>
980 <!-- ### xsl:call-template name="capitalize">
981 <xsl:with-param name="str" select="@name"/>
982 </xsl:call-template -->
983 <xsl:value-of select="@name"/>
984 <xsl:choose>
985 <xsl:when test="@type='$unknown'">
986 <xsl:text>.ifaceRef()</xsl:text>
987 </xsl:when>
988 <xsl:otherwise>
989 <xsl:text>.mIface</xsl:text>
990 </xsl:otherwise>
991 </xsl:choose>
992 </xsl:when>
993 </xsl:choose>
994 </xsl:when>
995 <!-- currently unsupported types -->
996 <xsl:when test="@type = 'string'">
997 <xsl:message terminate="yes">
998 <xsl:text>Parameter type </xsl:text>
999 <xsl:value-of select="@type"/>
1000 <xsl:text>is not currently supported</xsl:text>
1001 </xsl:message>
1002 </xsl:when>
1003 <!-- assuming scalar types -->
1004 <xsl:otherwise>
1005 <xsl:choose>
1006 <xsl:when test="$isIn">
1007 <xsl:text>a_</xsl:text>
1008 <!-- ### xsl:call-template name="capitalize">
1009 <xsl:with-param name="str" select="@name"/>
1010 </xsl:call-template -->
1011 <xsl:value-of select="@name"/>
1012 </xsl:when>
1013 <xsl:when test="$isOut">
1014 <xsl:text>&amp;a_</xsl:text>
1015 <!-- ### xsl:call-template name="capitalize">
1016 <xsl:with-param name="str" select="@name"/>
1017 </xsl:call-template -->
1018 <xsl:value-of select="@name"/>
1019 </xsl:when>
1020 </xsl:choose>
1021 </xsl:otherwise>
1022 </xsl:choose>
1023</xsl:template>
1024
1025
1026<!--
1027 * attribute/parameter type conversion (plain type name)
1028-->
1029<xsl:template match="
1030 attribute/@type | param/@type |
1031 enumerator/@type | collection/@type | collection/@enumerator
1032">
1033 <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
1034
1035 <xsl:if test="name(..)='param' and ../@array and ../@dir='return'">
1036 <xsl:message terminate="yes">
1037 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
1038 <xsl:text>return array parameters are not currently supported</xsl:text>
1039 </xsl:message>
1040 </xsl:if>
1041
1042 <xsl:choose>
1043 <!-- modifiers (ignored for 'enumeration' attributes)-->
1044 <xsl:when test="name(current())='type' and ../@mod">
1045 <xsl:if test="../@array">
1046 <xsl:message terminate="yes">
1047 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
1048 <xsl:text>either 'array' or 'mod' attribute is allowed, but not both!</xsl:text>
1049 </xsl:message>
1050 </xsl:if>
1051 <xsl:choose>
1052 <xsl:when test="../@mod='ptr'">
1053 <xsl:choose>
1054 <!-- standard types -->
1055 <!--xsl:when test=".='result'">??</xsl:when-->
1056 <xsl:when test=".='boolean'">BOOL *</xsl:when>
1057 <xsl:when test=".='octet'">BYTE *</xsl:when>
1058 <xsl:when test=".='short'">SHORT *</xsl:when>
1059 <xsl:when test=".='unsigned short'">USHORT *</xsl:when>
1060 <xsl:when test=".='long'">LONG *</xsl:when>
1061 <xsl:when test=".='long long'">LONG64 *</xsl:when>
1062 <xsl:when test=".='unsigned long'">ULONG *</xsl:when>
1063 <xsl:when test=".='unsigned long long'">ULONG64 *</xsl:when>
1064 <xsl:when test=".='char'">CHAR *</xsl:when>
1065 <!--<xsl:when test=".='string'">??</xsl:when-->
1066 <xsl:when test=".='wchar'">OLECHAR *</xsl:when>
1067 <!--<xsl:when test=".='wstring'">??</xsl:when-->
1068 <xsl:otherwise>
1069 <xsl:message terminate="yes">
1070 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
1071 <xsl:text>attribute 'mod=</xsl:text>
1072 <xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
1073 <xsl:text>' cannot be used with type </xsl:text>
1074 <xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
1075 </xsl:message>
1076 </xsl:otherwise>
1077 </xsl:choose>
1078 </xsl:when>
1079 <xsl:otherwise>
1080 <xsl:message terminate="yes">
1081 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
1082 <xsl:value-of select="concat('value &quot;',../@mod,'&quot; ')"/>
1083 <xsl:text>of attibute 'mod' is invalid!</xsl:text>
1084 </xsl:message>
1085 </xsl:otherwise>
1086 </xsl:choose>
1087 </xsl:when>
1088 <!-- no modifiers -->
1089 <xsl:otherwise>
1090 <xsl:choose>
1091 <!-- standard types -->
1092 <xsl:when test=".='result'">HRESULT</xsl:when>
1093 <xsl:when test=".='boolean'">BOOL</xsl:when>
1094 <xsl:when test=".='octet'">BYTE</xsl:when>
1095 <xsl:when test=".='short'">SHORT</xsl:when>
1096 <xsl:when test=".='unsigned short'">USHORT</xsl:when>
1097 <xsl:when test=".='long'">LONG</xsl:when>
1098 <xsl:when test=".='long long'">LONG64</xsl:when>
1099 <xsl:when test=".='unsigned long'">ULONG</xsl:when>
1100 <xsl:when test=".='unsigned long long'">ULONG64</xsl:when>
1101 <xsl:when test=".='char'">CHAR</xsl:when>
1102 <xsl:when test=".='string'">CHAR *</xsl:when>
1103 <xsl:when test=".='wchar'">OLECHAR</xsl:when>
1104 <xsl:when test=".='wstring'">QString</xsl:when>
1105 <!-- UUID type -->
1106 <xsl:when test=".='uuid'">QUuid</xsl:when>
1107 <!-- system interface types -->
1108 <xsl:when test=".='$unknown'">CUnknown</xsl:when>
1109 <xsl:otherwise>
1110 <xsl:choose>
1111 <!-- enum types -->
1112 <xsl:when test="
1113 (ancestor::module/enum[@name=current()]) or
1114 (ancestor::module/if[@target=$self_target]/enum[@name=current()])
1115 ">
1116 <xsl:value-of select="concat('CEnums::',string(.))"/>
1117 </xsl:when>
1118 <!-- custom interface types -->
1119 <xsl:when test="
1120 (name(current())='enumerator' and
1121 ((ancestor::module/enumerator[@name=current()]) or
1122 (ancestor::module/if[@target=$self_target]/enumerator[@name=current()]))
1123 ) or
1124 ((ancestor::module/interface[@name=current()]) or
1125 (ancestor::module/if[@target=$self_target]/interface[@name=current()])
1126 ) or
1127 ((ancestor::module/collection[@name=current()]) or
1128 (ancestor::module/if[@target=$self_target]/collection[@name=current()])
1129 )
1130 ">
1131 <xsl:value-of select="concat('C',substring(.,2))"/>
1132 </xsl:when>
1133 <!-- other types -->
1134 <xsl:otherwise>
1135 <xsl:message terminate="yes">
1136 <xsl:text>Unknown parameter type: </xsl:text>
1137 <xsl:value-of select="."/>
1138 </xsl:message>
1139 </xsl:otherwise>
1140 </xsl:choose>
1141 </xsl:otherwise>
1142 </xsl:choose>
1143 </xsl:otherwise>
1144 </xsl:choose>
1145</xsl:template>
1146
1147
1148<!--
1149 * generates a null initializer for all scalar types (such as bool or long)
1150 * and enum types in the form of ' = <null_initializer>', or nothing for other
1151 * types.
1152-->
1153<xsl:template match="
1154 attribute/@type | param/@type |
1155 enumerator/@type | collection/@type | collection/@enumerator
1156" mode="initializer">
1157
1158 <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
1159
1160 <xsl:choose>
1161 <!-- modifiers (ignored for 'enumeration' attributes)-->
1162 <xsl:when test="name(current())='type' and ../@mod">
1163 <xsl:if test="../@array">
1164 <xsl:message terminate="yes">
1165 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
1166 <xsl:text>either 'array' or 'mod' attribute is allowed, but not both!</xsl:text>
1167 </xsl:message>
1168 </xsl:if>
1169 <xsl:choose>
1170 <xsl:when test="../@mod='ptr'">
1171 <xsl:choose>
1172 <!-- standard types -->
1173 <!--xsl:when test=".='result'">??</xsl:when-->
1174 <xsl:when test=".='boolean'"> = NULL</xsl:when>
1175 <xsl:when test=".='octet'"> = NULL</xsl:when>
1176 <xsl:when test=".='short'"> = NULL</xsl:when>
1177 <xsl:when test=".='unsigned short'"> = NULL</xsl:when>
1178 <xsl:when test=".='long'"> = NULL</xsl:when>
1179 <xsl:when test=".='long long'"> = NULL</xsl:when>
1180 <xsl:when test=".='unsigned long'"> = NULL</xsl:when>
1181 <xsl:when test=".='unsigned long long'"> = NULL</xsl:when>
1182 <xsl:when test=".='char'"> = NULL</xsl:when>
1183 <!--<xsl:when test=".='string'">??</xsl:when-->
1184 <xsl:when test=".='wchar'"> = NULL</xsl:when>
1185 <!--<xsl:when test=".='wstring'">??</xsl:when-->
1186 <xsl:otherwise>
1187 <xsl:message terminate="yes">
1188 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
1189 <xsl:text>attribute 'mod=</xsl:text>
1190 <xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
1191 <xsl:text>' cannot be used with type </xsl:text>
1192 <xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
1193 </xsl:message>
1194 </xsl:otherwise>
1195 </xsl:choose>
1196 </xsl:when>
1197 <xsl:otherwise>
1198 <xsl:message terminate="yes">
1199 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
1200 <xsl:value-of select="concat('value &quot;',../@mod,'&quot; ')"/>
1201 <xsl:text>of attibute 'mod' is invalid!</xsl:text>
1202 </xsl:message>
1203 </xsl:otherwise>
1204 </xsl:choose>
1205 </xsl:when>
1206 <!-- no modifiers -->
1207 <xsl:otherwise>
1208 <xsl:choose>
1209 <!-- standard types that need a zero initializer -->
1210 <xsl:when test=".='result'"> = S_OK</xsl:when>
1211 <xsl:when test=".='boolean'"> = FALSE</xsl:when>
1212 <xsl:when test=".='octet'"> = 0</xsl:when>
1213 <xsl:when test=".='short'"> = 0</xsl:when>
1214 <xsl:when test=".='unsigned short'"> = 0</xsl:when>
1215 <xsl:when test=".='long'"> = 0</xsl:when>
1216 <xsl:when test=".='long long'"> = 0</xsl:when>
1217 <xsl:when test=".='unsigned long'"> = 0</xsl:when>
1218 <xsl:when test=".='unsigned long long'"> = 0</xsl:when>
1219 <xsl:when test=".='char'"> = 0</xsl:when>
1220 <xsl:when test=".='string'"> = NULL</xsl:when>
1221 <xsl:when test=".='wchar'"> = 0</xsl:when>
1222 <xsl:otherwise>
1223 <xsl:choose>
1224 <!-- enum types initialized with 0 -->
1225 <xsl:when test="
1226 (ancestor::module/enum[@name=current()]) or
1227 (ancestor::module/if[@target=$self_target]/enum[@name=current()])
1228 ">
1229 <xsl:value-of select="concat(' = (CEnums::',string(.),') 0')"/>
1230 </xsl:when>
1231 </xsl:choose>
1232 </xsl:otherwise>
1233 </xsl:choose>
1234 </xsl:otherwise>
1235 </xsl:choose>
1236</xsl:template>
1237
1238
1239<!--
1240 * attribute/parameter type conversion (for method declaration)
1241-->
1242<xsl:template match="attribute/@type | param/@type" mode="param">
1243
1244 <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
1245
1246 <xsl:choose>
1247 <!-- class types -->
1248 <xsl:when test="
1249 .='string' or
1250 .='wstring' or
1251 ((ancestor::module/enum[@name=current()]) or
1252 (ancestor::module/if[@target=$self_target]/enum[@name=current()])
1253 ) or
1254 .='$unknown' or
1255 ((ancestor::module/enumerator[@name=current()]) or
1256 (ancestor::module/if[@target=$self_target]/enumerator[@name=current()])
1257 ) or
1258 ((ancestor::module/interface[@name=current()]) or
1259 (ancestor::module/if[@target=$self_target]/interface[@name=current()])
1260 ) or
1261 ((ancestor::module/collection[@name=current()]) or
1262 (ancestor::module/if[@target=$self_target]/collection[@name=current()])
1263 )
1264 ">
1265 <xsl:choose>
1266 <!-- <attribute> context -->
1267 <xsl:when test="name(..)='attribute'">
1268 <xsl:text>const </xsl:text>
1269 <xsl:apply-templates select="."/>
1270 <xsl:text> &amp;</xsl:text>
1271 </xsl:when>
1272 <!-- <param> context -->
1273 <xsl:when test="name(..)='param'">
1274 <xsl:if test="../@array">
1275 <xsl:message terminate="yes">
1276 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
1277 <xsl:text>arrays of non-scalar types are not currently supported</xsl:text>
1278 </xsl:message>
1279 </xsl:if>
1280 <xsl:choose>
1281 <xsl:when test="../@dir='in'">
1282 <xsl:text>const </xsl:text>
1283 <xsl:apply-templates select="."/>
1284 <xsl:text> &amp;</xsl:text>
1285 </xsl:when>
1286 <xsl:when test="../@dir='out'">
1287 <xsl:apply-templates select="."/>
1288 <xsl:text> &amp;</xsl:text>
1289 </xsl:when>
1290 <xsl:when test="../@dir='return'">
1291 <xsl:apply-templates select="."/>
1292 </xsl:when>
1293 </xsl:choose>
1294 </xsl:when>
1295 </xsl:choose>
1296 </xsl:when>
1297 <!-- assume scalar types -->
1298 <xsl:otherwise>
1299 <xsl:choose>
1300 <!-- <attribute> context -->
1301 <xsl:when test="name(..)='attribute'">
1302 <xsl:apply-templates select="."/>
1303 </xsl:when>
1304 <!-- <param> context -->
1305 <xsl:when test="name(..)='param'">
1306 <xsl:choose>
1307 <xsl:when test="../@array">
1308 <xsl:apply-templates select="."/>
1309 <xsl:text> *</xsl:text>
1310 <xsl:if test="../@dir='out'">
1311 <xsl:text> &amp;</xsl:text>
1312 </xsl:if>
1313 </xsl:when>
1314 <xsl:otherwise>
1315 <xsl:apply-templates select="."/>
1316 <xsl:if test="../@dir='out'">
1317 <xsl:text> &amp;</xsl:text>
1318 </xsl:if>
1319 </xsl:otherwise>
1320 </xsl:choose>
1321 </xsl:when>
1322 </xsl:choose>
1323 </xsl:otherwise>
1324 </xsl:choose>
1325</xsl:template>
1326
1327
1328</xsl:stylesheet>
1329
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