VirtualBox

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

Last change on this file since 98103 was 98103, checked in by vboxsync, 17 months ago

Copyright year updates by scm.

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

© 2023 Oracle
ContactPrivacy policyTerms of Use