VirtualBox

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

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

VirtualBox/Makefile.kmk: Bad $(RM) -f !!

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

© 2023 Oracle
ContactPrivacy policyTerms of Use