VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/globals/COMWrappers.xsl@ 43138

Last change on this file since 43138 was 43103, checked in by vboxsync, 12 years ago

whitespace/comment touchup

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

© 2023 Oracle
ContactPrivacy policyTerms of Use