VirtualBox

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

Last change on this file was 103803, checked in by vboxsync, 2 months ago

FE/Qt. bugref:10618. Splitting COMEnums.h file into individual enum header files.

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

© 2023 Oracle
ContactPrivacy policyTerms of Use