1 | <?xml version="1.0"?>
|
---|
2 |
|
---|
3 | <!--
|
---|
4 | /*
|
---|
5 | * A template to generate wrapper classes for [XP]COM interfaces (defined
|
---|
6 | * in XIDL) to use them in the main Qt-based GUI in platform-independent
|
---|
7 | * script-like manner.
|
---|
8 | *
|
---|
9 | * The generated header requires COMDefs.h and must be included from there.
|
---|
10 | */
|
---|
11 |
|
---|
12 | /*
|
---|
13 | Copyright (C) 2006-2008 Sun Microsystems, Inc.
|
---|
14 |
|
---|
15 | This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
16 | available from http://www.virtualbox.org. This file is free software;
|
---|
17 | you can redistribute it and/or modify it under the terms of the GNU
|
---|
18 | General Public License (GPL) as published by the Free Software
|
---|
19 | Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
20 | VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
21 | hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
22 |
|
---|
23 | Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
24 | Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
25 | additional information or have any questions.
|
---|
26 | */
|
---|
27 | -->
|
---|
28 |
|
---|
29 | <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
---|
30 | <xsl:output method="text"/>
|
---|
31 |
|
---|
32 | <xsl:strip-space elements="*"/>
|
---|
33 |
|
---|
34 |
|
---|
35 | <!--
|
---|
36 | // helper definitions
|
---|
37 | /////////////////////////////////////////////////////////////////////////////
|
---|
38 | -->
|
---|
39 |
|
---|
40 | <!--
|
---|
41 | * capitalizes the first letter
|
---|
42 | -->
|
---|
43 | <xsl:template name="capitalize">
|
---|
44 | <xsl:param name="str" select="."/>
|
---|
45 | <xsl:value-of select="
|
---|
46 | concat(
|
---|
47 | translate(substring($str,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ'),
|
---|
48 | substring($str,2)
|
---|
49 | )
|
---|
50 | "/>
|
---|
51 | </xsl:template>
|
---|
52 |
|
---|
53 | <!--
|
---|
54 | * uncapitalizes the first letter only if the second one is not capital
|
---|
55 | * otherwise leaves the string unchanged
|
---|
56 | -->
|
---|
57 | <xsl:template name="uncapitalize">
|
---|
58 | <xsl:param name="str" select="."/>
|
---|
59 | <xsl:choose>
|
---|
60 | <xsl:when test="not(contains('ABCDEFGHIJKLMNOPQRSTUVWXYZ', substring($str,2,1)))">
|
---|
61 | <xsl:value-of select="
|
---|
62 | concat(
|
---|
63 | translate(substring($str,1,1),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),
|
---|
64 | substring($str,2)
|
---|
65 | )
|
---|
66 | "/>
|
---|
67 | </xsl:when>
|
---|
68 | <xsl:otherwise>
|
---|
69 | <xsl:value-of select="string($str)"/>
|
---|
70 | </xsl:otherwise>
|
---|
71 | </xsl:choose>
|
---|
72 | </xsl:template>
|
---|
73 |
|
---|
74 | <!--
|
---|
75 | * translates the string to uppercase
|
---|
76 | -->
|
---|
77 | <xsl:template name="uppercase">
|
---|
78 | <xsl:param name="str" select="."/>
|
---|
79 | <xsl:value-of select="
|
---|
80 | translate($str,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')
|
---|
81 | "/>
|
---|
82 | </xsl:template>
|
---|
83 |
|
---|
84 |
|
---|
85 | <!--
|
---|
86 | // templates
|
---|
87 | /////////////////////////////////////////////////////////////////////////////
|
---|
88 | -->
|
---|
89 |
|
---|
90 |
|
---|
91 | <!--
|
---|
92 | * shut down all implicit templates
|
---|
93 | -->
|
---|
94 | <xsl:template match="*"/>
|
---|
95 | <xsl:template match="*|/" mode="declare"/>
|
---|
96 | <xsl:template match="*|/" mode="define"/>
|
---|
97 | <xsl:template match="*|/" mode="end"/>
|
---|
98 | <xsl:template match="*|/" mode="begin"/>
|
---|
99 |
|
---|
100 |
|
---|
101 | <!--
|
---|
102 | * header
|
---|
103 | -->
|
---|
104 | <xsl:template match="/idl">
|
---|
105 |
|
---|
106 | <xsl:text>
|
---|
107 | /*
|
---|
108 | * DO NOT EDIT! This is a generated file.
|
---|
109 | *
|
---|
110 | * Qt-based wrapper classes for VirtualBox Main API (COM interfaces)
|
---|
111 | * generated from XIDL (XML interface definition).
|
---|
112 | *
|
---|
113 | * Source : src/VBox/Main/idl/VirtualBox.xidl
|
---|
114 | * Generator : src/VBox/Frontends/VirtualBox/include/COMWrappers.xsl
|
---|
115 | *
|
---|
116 | * Note: this header must be included from COMDefs.h, never directly.
|
---|
117 | */
|
---|
118 | </xsl:text>
|
---|
119 |
|
---|
120 | <!-- all enum declarations -->
|
---|
121 | <xsl:text>
|
---|
122 | // all enums
|
---|
123 |
|
---|
124 | </xsl:text>
|
---|
125 | <xsl:for-each select="*/enum">
|
---|
126 | <xsl:text>enum </xsl:text>
|
---|
127 | <xsl:value-of select="concat('K',@name)"/>
|
---|
128 | <xsl:text>
{
</xsl:text>
|
---|
129 | <xsl:for-each select="const">
|
---|
130 | <xsl:text> </xsl:text>
|
---|
131 | <xsl:value-of select="concat('K',../@name,'_',@name)"/>
|
---|
132 | <xsl:text> = ::</xsl:text>
|
---|
133 | <xsl:value-of select="concat(../@name,'_',@name)"/>
|
---|
134 | <xsl:text>,
</xsl:text>
|
---|
135 | </xsl:for-each>
|
---|
136 | <xsl:text>};

Q_DECLARE_METATYPE(</xsl:text>
|
---|
137 | <xsl:value-of select="concat('K',@name)"/>
|
---|
138 | <xsl:text>)

</xsl:text>
|
---|
139 | </xsl:for-each>
|
---|
140 | <xsl:text>

</xsl:text>
|
---|
141 |
|
---|
142 | <xsl:apply-templates/>
|
---|
143 |
|
---|
144 | </xsl:template>
|
---|
145 |
|
---|
146 |
|
---|
147 | <!--
|
---|
148 | * encloses |if| element's contents (unconditionally expanded by
|
---|
149 | * <apply-templates mode="define"/>) with #ifdef / #endif.
|
---|
150 | *
|
---|
151 | * @note this can produce an empty #if/#endif block if |if|'s children
|
---|
152 | * expand to nothing (such as |cpp|). I see no need to handle this situation
|
---|
153 | * specially.
|
---|
154 | -->
|
---|
155 | <xsl:template match="if" mode="define">
|
---|
156 | <xsl:if test="(@target='xpidl') or (@target='midl')">
|
---|
157 | <xsl:apply-templates select="." mode="begin"/>
|
---|
158 | <xsl:apply-templates mode="define"/>
|
---|
159 | <xsl:apply-templates select="." mode="end"/>
|
---|
160 | <xsl:text>
</xsl:text>
|
---|
161 | </xsl:if>
|
---|
162 | </xsl:template>
|
---|
163 |
|
---|
164 |
|
---|
165 | <!--
|
---|
166 | * encloses |if| element's contents (unconditionally expanded by
|
---|
167 | * <apply-templates mode="declare"/>) with #ifdef / #endif.
|
---|
168 | *
|
---|
169 | * @note this can produce an empty #if/#endif block if |if|'s children
|
---|
170 | * expand to nothing (such as |cpp|). I see no need to handle this situation
|
---|
171 | * specially.
|
---|
172 | -->
|
---|
173 | <xsl:template match="if" mode="declare">
|
---|
174 | <xsl:if test="(@target='xpidl') or (@target='midl')">
|
---|
175 | <xsl:apply-templates select="." mode="begin"/>
|
---|
176 | <xsl:apply-templates mode="declare"/>
|
---|
177 | <xsl:apply-templates select="." mode="end"/>
|
---|
178 | <xsl:text>
</xsl:text>
|
---|
179 | </xsl:if>
|
---|
180 | </xsl:template>
|
---|
181 |
|
---|
182 |
|
---|
183 | <!--
|
---|
184 | * |<if target="...">| element): begin and end.
|
---|
185 | -->
|
---|
186 | <xsl:template match="if" mode="begin">
|
---|
187 | <xsl:if test="@target='xpidl'">
|
---|
188 | <xsl:text>#if !defined (Q_WS_WIN32)
</xsl:text>
|
---|
189 | </xsl:if>
|
---|
190 | <xsl:if test="@target='midl'">
|
---|
191 | <xsl:text>#if defined (Q_WS_WIN32)
</xsl:text>
|
---|
192 | </xsl:if>
|
---|
193 | </xsl:template>
|
---|
194 | <xsl:template match="if" mode="end">
|
---|
195 | <xsl:if test="(@target='xpidl') or (@target='midl')">
|
---|
196 | <xsl:text>#endif
</xsl:text>
|
---|
197 | </xsl:if>
|
---|
198 | </xsl:template>
|
---|
199 |
|
---|
200 |
|
---|
201 | <!--
|
---|
202 | * cpp_quote
|
---|
203 | -->
|
---|
204 | <xsl:template match="cpp"/>
|
---|
205 |
|
---|
206 |
|
---|
207 | <!--
|
---|
208 | * #ifdef statement (@if attribute): begin and end
|
---|
209 | -->
|
---|
210 | <xsl:template match="@if" mode="begin">
|
---|
211 | <xsl:text>#if </xsl:text>
|
---|
212 | <xsl:value-of select="."/>
|
---|
213 | <xsl:text>
</xsl:text>
|
---|
214 | </xsl:template>
|
---|
215 | <xsl:template match="@if" mode="end">
|
---|
216 | <xsl:text>#endif
</xsl:text>
|
---|
217 | </xsl:template>
|
---|
218 |
|
---|
219 |
|
---|
220 | <!--
|
---|
221 | * libraries
|
---|
222 | -->
|
---|
223 | <xsl:template match="library">
|
---|
224 | <!-- forward declarations -->
|
---|
225 | <xsl:text>// forward declarations

</xsl:text>
|
---|
226 | <xsl:for-each select="interface">
|
---|
227 | <xsl:text>class C</xsl:text>
|
---|
228 | <xsl:value-of select="substring(@name,2)"/>
|
---|
229 | <xsl:text>;
</xsl:text>
|
---|
230 | </xsl:for-each>
|
---|
231 | <xsl:text>
</xsl:text>
|
---|
232 | <!-- array typedefs -->
|
---|
233 | <xsl:text>// array typedefs

</xsl:text>
|
---|
234 | <xsl:for-each select="interface[not(@internal='yes')]">
|
---|
235 | <xsl:if test="
|
---|
236 | (//attribute[@safearray='yes' and not(@internal='yes') and @type=current()/@name])
|
---|
237 | or
|
---|
238 | (//param[@safearray='yes' and not(../@internal='yes') and @type=current()/@name])
|
---|
239 | ">
|
---|
240 | <xsl:text>typedef QVector <C</xsl:text>
|
---|
241 | <xsl:value-of select="substring(@name,2)"/>
|
---|
242 | <xsl:text>> C</xsl:text>
|
---|
243 | <xsl:value-of select="substring(@name,2)"/>
|
---|
244 | <xsl:text>Vector;
</xsl:text>
|
---|
245 | </xsl:if>
|
---|
246 | </xsl:for-each>
|
---|
247 | <xsl:text>
</xsl:text>
|
---|
248 | <!-- wrapper declarations -->
|
---|
249 | <xsl:text>// wrapper declarations

</xsl:text>
|
---|
250 | <xsl:apply-templates select="
|
---|
251 | if |
|
---|
252 | interface[not(@internal='yes')]
|
---|
253 | "
|
---|
254 | mode="declare"
|
---|
255 | />
|
---|
256 | <!-- wrapper definitions -->
|
---|
257 | <xsl:text>// wrapper definitions

</xsl:text>
|
---|
258 | <xsl:apply-templates select="
|
---|
259 | if |
|
---|
260 | interface[not(@internal='yes')]
|
---|
261 | "
|
---|
262 | mode="define"
|
---|
263 | />
|
---|
264 | </xsl:template>
|
---|
265 |
|
---|
266 |
|
---|
267 | <!--
|
---|
268 | * interface declarations
|
---|
269 | -->
|
---|
270 | <xsl:template match="interface" mode="declare">
|
---|
271 |
|
---|
272 | <xsl:text>// </xsl:text>
|
---|
273 | <xsl:value-of select="@name"/>
|
---|
274 | <xsl:text> wrapper

class C</xsl:text>
|
---|
275 | <xsl:value-of select="substring(@name,2)"/>
|
---|
276 | <xsl:text> : public CInterface <</xsl:text>
|
---|
277 | <xsl:value-of select="@name"/>
|
---|
278 | <!-- use the correct base if supportsErrorInfo -->
|
---|
279 | <xsl:call-template name="tryComposeFetchErrorInfo">
|
---|
280 | <xsl:with-param name="mode" select="'getBaseClassName'"/>
|
---|
281 | </xsl:call-template>
|
---|
282 | <xsl:text>>
{
public:

</xsl:text>
|
---|
283 |
|
---|
284 | <!-- generate the Base typedef-->
|
---|
285 | <xsl:text> typedef CInterface <</xsl:text>
|
---|
286 | <xsl:value-of select="@name"/>
|
---|
287 | <!-- Use the correct base if supportsErrorInfo -->
|
---|
288 | <xsl:call-template name="tryComposeFetchErrorInfo">
|
---|
289 | <xsl:with-param name="mode" select="'getBaseClassName'"/>
|
---|
290 | </xsl:call-template>
|
---|
291 | <xsl:text>> Base;

</xsl:text>
|
---|
292 |
|
---|
293 | <xsl:if test="name()='interface'">
|
---|
294 | <xsl:call-template name="declareMembers"/>
|
---|
295 | </xsl:if>
|
---|
296 |
|
---|
297 | <xsl:text>};

</xsl:text>
|
---|
298 |
|
---|
299 | </xsl:template>
|
---|
300 |
|
---|
301 | <xsl:template name="declareAttributes">
|
---|
302 |
|
---|
303 | <xsl:param name="iface"/>
|
---|
304 |
|
---|
305 | <xsl:apply-templates select="$iface//attribute[not(@internal='yes')]" mode="declare"/>
|
---|
306 | <xsl:if test="$iface//attribute[not(@internal='yes')]">
|
---|
307 | <xsl:text>
</xsl:text>
|
---|
308 | </xsl:if>
|
---|
309 | <!-- go to the base interface -->
|
---|
310 | <xsl:if test="$iface/@extends and $iface/@extends!='$unknown'">
|
---|
311 | <xsl:choose>
|
---|
312 | <!-- interfaces within library/if -->
|
---|
313 | <xsl:when test="name(..)='if'">
|
---|
314 | <xsl:call-template name="declareAttributes">
|
---|
315 | <xsl:with-param name="iface" select="
|
---|
316 | preceding-sibling::
|
---|
317 | *[self::interface and @name=$iface/@extends] |
|
---|
318 | following-sibling::
|
---|
319 | *[self::interface and @name=$iface/@extends] |
|
---|
320 | ../preceding-sibling::if[@target=../@target]/
|
---|
321 | *[self::interface and @name=$iface/@extends] |
|
---|
322 | ../following-sibling::if[@target=../@target]/
|
---|
323 | *[self::interface and @name=$iface/@extends]
|
---|
324 | "/>
|
---|
325 | </xsl:call-template>
|
---|
326 | </xsl:when>
|
---|
327 | <!-- interfaces within library -->
|
---|
328 | <xsl:otherwise>
|
---|
329 | <xsl:call-template name="declareAttributes">
|
---|
330 | <xsl:with-param name="iface" select="
|
---|
331 | preceding-sibling::
|
---|
332 | *[self::interface and @name=$iface/@extends] |
|
---|
333 | following-sibling::
|
---|
334 | *[self::interface and @name=$iface/@extends]
|
---|
335 | "/>
|
---|
336 | </xsl:call-template>
|
---|
337 | </xsl:otherwise>
|
---|
338 | </xsl:choose>
|
---|
339 | </xsl:if>
|
---|
340 |
|
---|
341 | </xsl:template>
|
---|
342 |
|
---|
343 | <xsl:template name="declareMethods">
|
---|
344 |
|
---|
345 | <xsl:param name="iface"/>
|
---|
346 |
|
---|
347 | <xsl:apply-templates select="$iface//method[not(@internal='yes')]" mode="declare"/>
|
---|
348 | <xsl:if test="$iface//method[not(@internal='yes')]">
|
---|
349 | <xsl:text>
</xsl:text>
|
---|
350 | </xsl:if>
|
---|
351 | <!-- go to the base interface -->
|
---|
352 | <xsl:if test="$iface/@extends and $iface/@extends!='$unknown'">
|
---|
353 | <xsl:choose>
|
---|
354 | <!-- interfaces within library/if -->
|
---|
355 | <xsl:when test="name(..)='if'">
|
---|
356 | <xsl:call-template name="declareMethods">
|
---|
357 | <xsl:with-param name="iface" select="
|
---|
358 | preceding-sibling::
|
---|
359 | *[self::interface and @name=$iface/@extends] |
|
---|
360 | following-sibling::
|
---|
361 | *[self::interface and @name=$iface/@extends] |
|
---|
362 | ../preceding-sibling::if[@target=../@target]/
|
---|
363 | *[self::interface and @name=$iface/@extends] |
|
---|
364 | ../following-sibling::if[@target=../@target]/
|
---|
365 | *[self::interface and @name=$iface/@extends]
|
---|
366 | "/>
|
---|
367 | </xsl:call-template>
|
---|
368 | </xsl:when>
|
---|
369 | <!-- interfaces within library -->
|
---|
370 | <xsl:otherwise>
|
---|
371 | <xsl:call-template name="declareMethods">
|
---|
372 | <xsl:with-param name="iface" select="
|
---|
373 | preceding-sibling::
|
---|
374 | *[self::interface and @name=$iface/@extends] |
|
---|
375 | following-sibling::
|
---|
376 | *[self::interface and @name=$iface/@extends]
|
---|
377 | "/>
|
---|
378 | </xsl:call-template>
|
---|
379 | </xsl:otherwise>
|
---|
380 | </xsl:choose>
|
---|
381 | </xsl:if>
|
---|
382 |
|
---|
383 | </xsl:template>
|
---|
384 |
|
---|
385 | <xsl:template name="declareMembers">
|
---|
386 |
|
---|
387 | <xsl:text> // constructors and assignments taking CUnknown and </xsl:text>
|
---|
388 | <xsl:text>raw iface pointer

</xsl:text>
|
---|
389 | <!-- default constructor -->
|
---|
390 | <xsl:text> C</xsl:text>
|
---|
391 | <xsl:value-of select="substring(@name,2)"/>
|
---|
392 | <xsl:text> () {}

</xsl:text>
|
---|
393 | <!-- constructor taking CWhatever -->
|
---|
394 | <xsl:text> template <class OI, class OB> explicit C</xsl:text>
|
---|
395 | <xsl:value-of select="substring(@name,2)"/>
|
---|
396 | <xsl:text> (const CInterface <OI, OB> & that)
|
---|
397 | {
|
---|
398 | attach (that.raw());
|
---|
399 | if (SUCCEEDED (mRC))
|
---|
400 | {
|
---|
401 | mRC = that.lastRC();
|
---|
402 | setErrorInfo (that.errorInfo());
|
---|
403 | }
|
---|
404 | }
|
---|
405 | </xsl:text>
|
---|
406 | <xsl:text>
</xsl:text>
|
---|
407 | <!-- specialization for ourselves (copy constructor) -->
|
---|
408 | <xsl:text> C</xsl:text>
|
---|
409 | <xsl:value-of select="substring(@name,2)"/>
|
---|
410 | <xsl:text> (const C</xsl:text>
|
---|
411 | <xsl:value-of select="substring(@name,2)"/>
|
---|
412 | <xsl:text> & that) : Base (that) {}

</xsl:text>
|
---|
413 | <!-- constructor taking a raw iface pointer -->
|
---|
414 | <xsl:text> template <class OI> explicit C</xsl:text>
|
---|
415 | <xsl:value-of select="substring(@name,2)"/>
|
---|
416 | <xsl:text> (OI * aIface) { attach (aIface); }

</xsl:text>
|
---|
417 | <!-- specialization for ourselves -->
|
---|
418 | <xsl:text> explicit C</xsl:text>
|
---|
419 | <xsl:value-of select="substring(@name,2)"/>
|
---|
420 | <xsl:text> (</xsl:text>
|
---|
421 | <xsl:value-of select="@name"/>
|
---|
422 | <xsl:text> * aIface) : Base (aIface) {}

</xsl:text>
|
---|
423 | <!-- assignment taking CWhatever -->
|
---|
424 | <xsl:text> template <class OI, class OB> C</xsl:text>
|
---|
425 | <xsl:value-of select="substring(@name,2)"/>
|
---|
426 | <xsl:text> & operator = (const CInterface <OI, OB> & that)
|
---|
427 | {
|
---|
428 | attach (that.raw());
|
---|
429 | if (SUCCEEDED (mRC))
|
---|
430 | {
|
---|
431 | mRC = that.lastRC();
|
---|
432 | setErrorInfo (that.errorInfo());
|
---|
433 | }
|
---|
434 | return *this;
|
---|
435 | }
|
---|
436 | </xsl:text>
|
---|
437 | <xsl:text>
</xsl:text>
|
---|
438 | <!-- specialization for ourselves -->
|
---|
439 | <xsl:text> C</xsl:text>
|
---|
440 | <xsl:value-of select="substring(@name,2)"/>
|
---|
441 | <xsl:text> & operator = (const C</xsl:text>
|
---|
442 | <xsl:value-of select="substring(@name,2)"/>
|
---|
443 | <xsl:text> & that)
|
---|
444 | {
|
---|
445 | Base::operator= (that);
|
---|
446 | return *this;
|
---|
447 | }
|
---|
448 | </xsl:text>
|
---|
449 | <xsl:text>
</xsl:text>
|
---|
450 | <!-- assignment taking a raw iface pointer -->
|
---|
451 | <xsl:text> template <class OI> C</xsl:text>
|
---|
452 | <xsl:value-of select="substring(@name,2)"/>
|
---|
453 | <xsl:text> & operator = (OI * aIface)
|
---|
454 | {
|
---|
455 | attach (aIface);
|
---|
456 | return *this;
|
---|
457 | }
|
---|
458 | </xsl:text>
|
---|
459 | <xsl:text>
</xsl:text>
|
---|
460 | <!-- specialization for ourselves -->
|
---|
461 | <xsl:text> C</xsl:text>
|
---|
462 | <xsl:value-of select="substring(@name,2)"/>
|
---|
463 | <xsl:text> & operator = (</xsl:text>
|
---|
464 | <xsl:value-of select="@name"/>
|
---|
465 | <xsl:text> * aIface)
|
---|
466 | {
|
---|
467 | Base::operator= (aIface);
|
---|
468 | return *this;
|
---|
469 | }
|
---|
470 | </xsl:text>
|
---|
471 | <xsl:text>
</xsl:text>
|
---|
472 |
|
---|
473 | <xsl:text> // attributes (properties)

</xsl:text>
|
---|
474 | <xsl:call-template name="declareAttributes">
|
---|
475 | <xsl:with-param name="iface" select="."/>
|
---|
476 | </xsl:call-template>
|
---|
477 |
|
---|
478 | <xsl:text> // methods

</xsl:text>
|
---|
479 | <xsl:call-template name="declareMethods">
|
---|
480 | <xsl:with-param name="iface" select="."/>
|
---|
481 | </xsl:call-template>
|
---|
482 |
|
---|
483 | <xsl:text> // friend wrappers

</xsl:text>
|
---|
484 | <xsl:text> friend class CUnknown;
</xsl:text>
|
---|
485 | <xsl:variable name="name" select="@name"/>
|
---|
486 | <xsl:variable name="parent" select=".."/>
|
---|
487 | <!-- for definitions inside <if> -->
|
---|
488 | <xsl:if test="name(..)='if'">
|
---|
489 | <xsl:for-each select="
|
---|
490 | preceding-sibling::*[self::interface] |
|
---|
491 | following-sibling::*[self::interface] |
|
---|
492 | ../preceding-sibling::*[self::interface] |
|
---|
493 | ../following-sibling::*[self::interface] |
|
---|
494 | ../preceding-sibling::if[@target=$parent/@target]/*[self::interface] |
|
---|
495 | ../following-sibling::if[@target=$parent/@target]/*[self::interface]
|
---|
496 | ">
|
---|
497 | <xsl:if test="
|
---|
498 | ((name()='interface')
|
---|
499 | and
|
---|
500 | ((name(..)!='if' and (if[@target=$parent/@target]/method/param[@type=$name]
|
---|
501 | or
|
---|
502 | if[@target=$parent/@target]/attribute[@type=$name]))
|
---|
503 | or
|
---|
504 | (.//method/param[@type=$name] or attribute[@type=$name])))
|
---|
505 | ">
|
---|
506 | <xsl:text> friend class C</xsl:text>
|
---|
507 | <xsl:value-of select="substring(@name,2)"/>
|
---|
508 | <xsl:text>;
</xsl:text>
|
---|
509 | </xsl:if>
|
---|
510 | </xsl:for-each>
|
---|
511 | </xsl:if>
|
---|
512 | <!-- for definitions outside <if> (i.e. inside <library>) -->
|
---|
513 | <xsl:if test="name(..)!='if'">
|
---|
514 | <xsl:for-each select="
|
---|
515 | preceding-sibling::*[self::interface] |
|
---|
516 | following-sibling::*[self::interface] |
|
---|
517 | preceding-sibling::if/*[self::interface] |
|
---|
518 | following-sibling::if/*[self::interface]
|
---|
519 | ">
|
---|
520 | <xsl:if test="
|
---|
521 | name()='interface' and (.//method/param[@type=$name] or attribute[@type=$name])
|
---|
522 | ">
|
---|
523 | <xsl:text> friend class C</xsl:text>
|
---|
524 | <xsl:value-of select="substring(@name,2)"/>
|
---|
525 | <xsl:text>;
</xsl:text>
|
---|
526 | </xsl:if>
|
---|
527 | </xsl:for-each>
|
---|
528 | </xsl:if>
|
---|
529 |
|
---|
530 | </xsl:template>
|
---|
531 |
|
---|
532 | <!-- attribute declarations -->
|
---|
533 | <xsl:template match="interface//attribute" mode="declare">
|
---|
534 | <xsl:apply-templates select="parent::node()" mode="begin"/>
|
---|
535 | <xsl:apply-templates select="@if" mode="begin"/>
|
---|
536 | <xsl:call-template name="composeMethod">
|
---|
537 | <xsl:with-param name="return" select="."/>
|
---|
538 | </xsl:call-template>
|
---|
539 | <xsl:if test="not(@readonly='yes')">
|
---|
540 | <xsl:call-template name="composeMethod">
|
---|
541 | <xsl:with-param name="return" select="''"/>
|
---|
542 | </xsl:call-template>
|
---|
543 | </xsl:if>
|
---|
544 | <xsl:apply-templates select="@if" mode="end"/>
|
---|
545 | <xsl:apply-templates select="parent::node()" mode="end"/>
|
---|
546 | </xsl:template>
|
---|
547 |
|
---|
548 | <!-- method declarations -->
|
---|
549 | <xsl:template match="interface//method" mode="declare">
|
---|
550 | <xsl:apply-templates select="parent::node()" mode="begin"/>
|
---|
551 | <xsl:apply-templates select="@if" mode="begin"/>
|
---|
552 | <xsl:call-template name="composeMethod"/>
|
---|
553 | <xsl:apply-templates select="@if" mode="end"/>
|
---|
554 | <xsl:apply-templates select="parent::node()" mode="end"/>
|
---|
555 | </xsl:template>
|
---|
556 |
|
---|
557 |
|
---|
558 | <!--
|
---|
559 | * interface definitions
|
---|
560 | -->
|
---|
561 | <xsl:template match="interface" mode="define">
|
---|
562 |
|
---|
563 | <xsl:text>// </xsl:text>
|
---|
564 | <xsl:value-of select="@name"/>
|
---|
565 | <xsl:text> wrapper

</xsl:text>
|
---|
566 |
|
---|
567 | <xsl:if test="name()='interface'">
|
---|
568 | <xsl:call-template name="defineMembers"/>
|
---|
569 | </xsl:if>
|
---|
570 |
|
---|
571 | </xsl:template>
|
---|
572 |
|
---|
573 | <xsl:template name="defineAttributes">
|
---|
574 |
|
---|
575 | <xsl:param name="iface"/>
|
---|
576 |
|
---|
577 | <xsl:apply-templates select="$iface//attribute[not(@internal='yes')]" mode="define">
|
---|
578 | <xsl:with-param name="namespace" select="."/>
|
---|
579 | </xsl:apply-templates>
|
---|
580 |
|
---|
581 | <!-- go to the base interface -->
|
---|
582 | <xsl:if test="$iface/@extends and $iface/@extends!='$unknown'">
|
---|
583 | <xsl:choose>
|
---|
584 | <!-- interfaces within library/if -->
|
---|
585 | <xsl:when test="name(..)='if'">
|
---|
586 | <xsl:call-template name="defineAttributes">
|
---|
587 | <xsl:with-param name="iface" select="
|
---|
588 | preceding-sibling::
|
---|
589 | *[self::interface and @name=$iface/@extends] |
|
---|
590 | following-sibling::
|
---|
591 | *[self::interface and @name=$iface/@extends] |
|
---|
592 | ../preceding-sibling::if[@target=../@target]/
|
---|
593 | *[self::interface and @name=$iface/@extends] |
|
---|
594 | ../following-sibling::if[@target=../@target]/
|
---|
595 | *[self::interface and @name=$iface/@extends]
|
---|
596 | "/>
|
---|
597 | </xsl:call-template>
|
---|
598 | </xsl:when>
|
---|
599 | <!-- interfaces within library -->
|
---|
600 | <xsl:otherwise>
|
---|
601 | <xsl:call-template name="defineAttributes">
|
---|
602 | <xsl:with-param name="iface" select="
|
---|
603 | preceding-sibling::
|
---|
604 | *[self::interface and @name=$iface/@extends] |
|
---|
605 | following-sibling::
|
---|
606 | *[self::interface and @name=$iface/@extends]
|
---|
607 | "/>
|
---|
608 | </xsl:call-template>
|
---|
609 | </xsl:otherwise>
|
---|
610 | </xsl:choose>
|
---|
611 | </xsl:if>
|
---|
612 |
|
---|
613 | </xsl:template>
|
---|
614 |
|
---|
615 | <xsl:template name="defineMethods">
|
---|
616 |
|
---|
617 | <xsl:param name="iface"/>
|
---|
618 |
|
---|
619 | <xsl:apply-templates select="$iface//method[not(@internal='yes')]" mode="define">
|
---|
620 | <xsl:with-param name="namespace" select="."/>
|
---|
621 | </xsl:apply-templates>
|
---|
622 |
|
---|
623 | <!-- go to the base interface -->
|
---|
624 | <xsl:if test="$iface/@extends and $iface/@extends!='$unknown'">
|
---|
625 | <xsl:choose>
|
---|
626 | <!-- interfaces within library/if -->
|
---|
627 | <xsl:when test="name(..)='if'">
|
---|
628 | <xsl:call-template name="defineMethods">
|
---|
629 | <xsl:with-param name="iface" select="
|
---|
630 | preceding-sibling::
|
---|
631 | *[self::interface and @name=$iface/@extends] |
|
---|
632 | following-sibling::
|
---|
633 | *[self::interface and @name=$iface/@extends] |
|
---|
634 | ../preceding-sibling::if[@target=../@target]/
|
---|
635 | *[self::interface and @name=$iface/@extends] |
|
---|
636 | ../following-sibling::if[@target=../@target]/
|
---|
637 | *[self::interface and @name=$iface/@extends]
|
---|
638 | "/>
|
---|
639 | </xsl:call-template>
|
---|
640 | </xsl:when>
|
---|
641 | <!-- interfaces within library -->
|
---|
642 | <xsl:otherwise>
|
---|
643 | <xsl:call-template name="defineMethods">
|
---|
644 | <xsl:with-param name="iface" select="
|
---|
645 | preceding-sibling::
|
---|
646 | *[self::interface and @name=$iface/@extends] |
|
---|
647 | following-sibling::
|
---|
648 | *[self::interface and @name=$iface/@extends]
|
---|
649 | "/>
|
---|
650 | </xsl:call-template>
|
---|
651 | </xsl:otherwise>
|
---|
652 | </xsl:choose>
|
---|
653 | </xsl:if>
|
---|
654 |
|
---|
655 | </xsl:template>
|
---|
656 |
|
---|
657 | <xsl:template name="defineMembers">
|
---|
658 | <xsl:call-template name="defineAttributes">
|
---|
659 | <xsl:with-param name="iface" select="."/>
|
---|
660 | </xsl:call-template>
|
---|
661 | <xsl:call-template name="defineMethods">
|
---|
662 | <xsl:with-param name="iface" select="."/>
|
---|
663 | </xsl:call-template>
|
---|
664 | </xsl:template>
|
---|
665 |
|
---|
666 | <!-- attribute definitions -->
|
---|
667 | <xsl:template match="interface//attribute" mode="define">
|
---|
668 |
|
---|
669 | <xsl:param name="namespace" select="ancestor::interface[1]"/>
|
---|
670 |
|
---|
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:with-param name="return" select="."/>
|
---|
675 | <xsl:with-param name="define" select="'yes'"/>
|
---|
676 | <xsl:with-param name="namespace" select="$namespace"/>
|
---|
677 | </xsl:call-template>
|
---|
678 | <xsl:if test="not(@readonly='yes')">
|
---|
679 | <xsl:call-template name="composeMethod">
|
---|
680 | <xsl:with-param name="return" select="''"/>
|
---|
681 | <xsl:with-param name="define" select="'yes'"/>
|
---|
682 | <xsl:with-param name="namespace" select="$namespace"/>
|
---|
683 | </xsl:call-template>
|
---|
684 | </xsl:if>
|
---|
685 | <xsl:apply-templates select="@if" mode="end"/>
|
---|
686 | <xsl:apply-templates select="parent::node()" mode="end"/>
|
---|
687 | <xsl:text>
</xsl:text>
|
---|
688 |
|
---|
689 | </xsl:template>
|
---|
690 |
|
---|
691 | <!-- method definitions -->
|
---|
692 | <xsl:template match="interface//method" mode="define">
|
---|
693 |
|
---|
694 | <xsl:param name="namespace" select="ancestor::interface[1]"/>
|
---|
695 |
|
---|
696 | <xsl:apply-templates select="parent::node()" mode="begin"/>
|
---|
697 | <xsl:apply-templates select="@if" mode="begin"/>
|
---|
698 | <xsl:call-template name="composeMethod">
|
---|
699 | <xsl:with-param name="define" select="'yes'"/>
|
---|
700 | <xsl:with-param name="namespace" select="$namespace"/>
|
---|
701 | </xsl:call-template>
|
---|
702 | <xsl:apply-templates select="@if" mode="end"/>
|
---|
703 | <xsl:apply-templates select="parent::node()" mode="end"/>
|
---|
704 | <xsl:text>
</xsl:text>
|
---|
705 |
|
---|
706 | </xsl:template>
|
---|
707 |
|
---|
708 |
|
---|
709 | <!--
|
---|
710 | * co-classes
|
---|
711 | -->
|
---|
712 | <xsl:template match="module/class"/>
|
---|
713 |
|
---|
714 |
|
---|
715 | <!--
|
---|
716 | * enums
|
---|
717 | -->
|
---|
718 | <xsl:template match="enum"/>
|
---|
719 |
|
---|
720 |
|
---|
721 | <!--
|
---|
722 | * base template to produce interface methods
|
---|
723 | *
|
---|
724 | * @param return
|
---|
725 | * - in <attribute> context, must be '.' for getters and
|
---|
726 | * '' for setters
|
---|
727 | * - in <method> context, must not be specified (the default value
|
---|
728 | * will apply)
|
---|
729 | * @param define
|
---|
730 | * 'yes' to procuce inlined definition outside the class
|
---|
731 | * declaration, or
|
---|
732 | * empty string to produce method declaration only (w/o body)
|
---|
733 | * @param namespace
|
---|
734 | * actual interface node for which this method is being defined
|
---|
735 | * (necessary to properly set a class name for inherited methods).
|
---|
736 | * If not specified, will default to the parent interface
|
---|
737 | * node of the method being defined.
|
---|
738 | -->
|
---|
739 | <xsl:template name="composeMethod">
|
---|
740 | <xsl:param name="return" select="param[@dir='return']"/>
|
---|
741 | <xsl:param name="define" select="''"/>
|
---|
742 | <xsl:param name="namespace" select="ancestor::interface[1]"/>
|
---|
743 | <xsl:choose>
|
---|
744 | <!-- no return value -->
|
---|
745 | <xsl:when test="not($return)">
|
---|
746 | <xsl:choose>
|
---|
747 | <xsl:when test="$define">
|
---|
748 | <xsl:text>inline </xsl:text>
|
---|
749 | </xsl:when>
|
---|
750 | <xsl:otherwise>
|
---|
751 | <xsl:text> </xsl:text>
|
---|
752 | </xsl:otherwise>
|
---|
753 | </xsl:choose>
|
---|
754 | <xsl:text>void </xsl:text>
|
---|
755 | <xsl:if test="$define">
|
---|
756 | <xsl:text>C</xsl:text>
|
---|
757 | <xsl:value-of select="substring($namespace/@name,2)"/>
|
---|
758 | <xsl:text>::</xsl:text>
|
---|
759 | </xsl:if>
|
---|
760 | <xsl:call-template name="composeMethodDecl">
|
---|
761 | <xsl:with-param name="isSetter" select="'yes'"/>
|
---|
762 | </xsl:call-template>
|
---|
763 | <xsl:if test="$define">
|
---|
764 | <xsl:text>
{
</xsl:text>
|
---|
765 | <!-- iface assertion -->
|
---|
766 | <xsl:text> Assert (mIface);
</xsl:text>
|
---|
767 | <xsl:text> if (!mIface)
 return;
</xsl:text>
|
---|
768 | <!-- method call -->
|
---|
769 | <xsl:call-template name="composeMethodCall">
|
---|
770 | <xsl:with-param name="isSetter" select="'yes'"/>
|
---|
771 | </xsl:call-template>
|
---|
772 | <xsl:text>}
</xsl:text>
|
---|
773 | </xsl:if>
|
---|
774 | <xsl:if test="not($define)">
|
---|
775 | <xsl:text>;
</xsl:text>
|
---|
776 | </xsl:if>
|
---|
777 | </xsl:when>
|
---|
778 | <!-- has a return value -->
|
---|
779 | <xsl:when test="count($return) = 1">
|
---|
780 | <xsl:choose>
|
---|
781 | <xsl:when test="$define">
|
---|
782 | <xsl:text>inline </xsl:text>
|
---|
783 | </xsl:when>
|
---|
784 | <xsl:otherwise>
|
---|
785 | <xsl:text> </xsl:text>
|
---|
786 | </xsl:otherwise>
|
---|
787 | </xsl:choose>
|
---|
788 | <xsl:apply-templates select="$return/@type"/>
|
---|
789 | <xsl:text> </xsl:text>
|
---|
790 | <xsl:if test="$define">
|
---|
791 | <xsl:text>C</xsl:text>
|
---|
792 | <xsl:value-of select="substring($namespace/@name,2)"/>
|
---|
793 | <xsl:text>::</xsl:text>
|
---|
794 | </xsl:if>
|
---|
795 | <xsl:call-template name="composeMethodDecl"/>
|
---|
796 | <xsl:if test="$define">
|
---|
797 | <xsl:text>
{
 </xsl:text>
|
---|
798 | <xsl:apply-templates select="$return/@type"/>
|
---|
799 | <xsl:text> a</xsl:text>
|
---|
800 | <xsl:call-template name="capitalize">
|
---|
801 | <xsl:with-param name="str" select="$return/@name"/>
|
---|
802 | </xsl:call-template>
|
---|
803 | <xsl:apply-templates select="$return/@type" mode="initializer"/>
|
---|
804 | <xsl:text>;
</xsl:text>
|
---|
805 | <!-- iface assertion -->
|
---|
806 | <xsl:text> Assert (mIface);
</xsl:text>
|
---|
807 | <xsl:text> if (!mIface)
 return a</xsl:text>
|
---|
808 | <xsl:call-template name="capitalize">
|
---|
809 | <xsl:with-param name="str" select="$return/@name"/>
|
---|
810 | </xsl:call-template>
|
---|
811 | <xsl:text>;
</xsl:text>
|
---|
812 | <!-- method call -->
|
---|
813 | <xsl:call-template name="composeMethodCall"/>
|
---|
814 | <!-- return statement -->
|
---|
815 | <xsl:text> return a</xsl:text>
|
---|
816 | <xsl:call-template name="capitalize">
|
---|
817 | <xsl:with-param name="str" select="$return/@name"/>
|
---|
818 | </xsl:call-template>
|
---|
819 | <xsl:text>;
}
</xsl:text>
|
---|
820 | </xsl:if>
|
---|
821 | <xsl:if test="not($define)">
|
---|
822 | <xsl:text>;
</xsl:text>
|
---|
823 | </xsl:if>
|
---|
824 | </xsl:when>
|
---|
825 | <!-- otherwise error -->
|
---|
826 | <xsl:otherwise>
|
---|
827 | <xsl:message terminate="yes">
|
---|
828 | <xsl:text>More than one return value in method: </xsl:text>
|
---|
829 | <xsl:value-of select="$namespace/@name"/>
|
---|
830 | <xsl:text>::</xsl:text>
|
---|
831 | <xsl:value-of select="@name"/>
|
---|
832 | </xsl:message>
|
---|
833 | </xsl:otherwise>
|
---|
834 | </xsl:choose>
|
---|
835 | </xsl:template>
|
---|
836 |
|
---|
837 | <xsl:template name="composeMethodDecl">
|
---|
838 | <xsl:param name="isSetter" select="''"/>
|
---|
839 | <xsl:choose>
|
---|
840 | <!-- attribute method call -->
|
---|
841 | <xsl:when test="name()='attribute'">
|
---|
842 | <xsl:choose>
|
---|
843 | <xsl:when test="$isSetter">
|
---|
844 | <!-- name -->
|
---|
845 | <xsl:text>Set</xsl:text>
|
---|
846 | <xsl:call-template name="capitalize">
|
---|
847 | <xsl:with-param name="str" select="@name"/>
|
---|
848 | </xsl:call-template>
|
---|
849 | <xsl:text> (</xsl:text>
|
---|
850 | <!-- parameter -->
|
---|
851 | <xsl:apply-templates select="@type" mode="param"/>
|
---|
852 | <xsl:text> a</xsl:text>
|
---|
853 | <xsl:call-template name="capitalize">
|
---|
854 | <xsl:with-param name="str" select="@name"/>
|
---|
855 | </xsl:call-template>
|
---|
856 | <xsl:text>)</xsl:text>
|
---|
857 | </xsl:when>
|
---|
858 | <xsl:otherwise>
|
---|
859 | <!-- name -->
|
---|
860 | <xsl:text>Get</xsl:text>
|
---|
861 | <xsl:call-template name="capitalize">
|
---|
862 | <xsl:with-param name="str" select="@name"/>
|
---|
863 | </xsl:call-template>
|
---|
864 | <xsl:text> (</xsl:text>
|
---|
865 | <!-- const method -->
|
---|
866 | <xsl:text>) const</xsl:text>
|
---|
867 | </xsl:otherwise>
|
---|
868 | </xsl:choose>
|
---|
869 | </xsl:when>
|
---|
870 | <!-- regular method call -->
|
---|
871 | <xsl:when test="name()='method'">
|
---|
872 | <!-- name -->
|
---|
873 | <xsl:call-template name="capitalize">
|
---|
874 | <xsl:with-param name="str" select="@name"/>
|
---|
875 | </xsl:call-template>
|
---|
876 | <xsl:text> (</xsl:text>
|
---|
877 | <!-- parameters -->
|
---|
878 | <xsl:for-each select="param[@dir!='return']">
|
---|
879 | <xsl:apply-templates select="@type" mode="param"/>
|
---|
880 | <xsl:text> a</xsl:text>
|
---|
881 | <xsl:call-template name="capitalize">
|
---|
882 | <xsl:with-param name="str" select="@name"/>
|
---|
883 | </xsl:call-template>
|
---|
884 | <xsl:if test="position() != last()">
|
---|
885 | <xsl:text>, </xsl:text>
|
---|
886 | </xsl:if>
|
---|
887 | </xsl:for-each>
|
---|
888 | <xsl:text>)</xsl:text>
|
---|
889 | <!-- const method -->
|
---|
890 | <xsl:if test="@const='yes'"> const</xsl:if>
|
---|
891 | </xsl:when>
|
---|
892 | </xsl:choose>
|
---|
893 | </xsl:template>
|
---|
894 |
|
---|
895 | <xsl:template name="composeMethodCall">
|
---|
896 | <xsl:param name="isSetter" select="''"/>
|
---|
897 | <!-- apply 'pre-call' hooks -->
|
---|
898 | <xsl:choose>
|
---|
899 | <xsl:when test="name()='attribute'">
|
---|
900 | <xsl:call-template name="hooks">
|
---|
901 | <xsl:with-param name="when" select="'pre-call'"/>
|
---|
902 | <xsl:with-param name="isSetter" select="$isSetter"/>
|
---|
903 | </xsl:call-template>
|
---|
904 | </xsl:when>
|
---|
905 | <xsl:when test="name()='method'">
|
---|
906 | <xsl:for-each select="param">
|
---|
907 | <xsl:call-template name="hooks">
|
---|
908 | <xsl:with-param name="when" select="'pre-call'"/>
|
---|
909 | </xsl:call-template>
|
---|
910 | </xsl:for-each>
|
---|
911 | </xsl:when>
|
---|
912 | </xsl:choose>
|
---|
913 | <!-- start the call -->
|
---|
914 | <xsl:text> mRC = mIface-></xsl:text>
|
---|
915 | <xsl:choose>
|
---|
916 | <!-- attribute method call -->
|
---|
917 | <xsl:when test="name()='attribute'">
|
---|
918 | <!-- method name -->
|
---|
919 | <xsl:choose>
|
---|
920 | <xsl:when test="$isSetter">
|
---|
921 | <xsl:text>COMSETTER(</xsl:text>
|
---|
922 | </xsl:when>
|
---|
923 | <xsl:otherwise>
|
---|
924 | <xsl:text>COMGETTER(</xsl:text>
|
---|
925 | </xsl:otherwise>
|
---|
926 | </xsl:choose>
|
---|
927 | <xsl:call-template name="capitalize">
|
---|
928 | <xsl:with-param name="str" select="@name"/>
|
---|
929 | </xsl:call-template>
|
---|
930 | <xsl:text>) (</xsl:text>
|
---|
931 | <!-- parameter -->
|
---|
932 | <xsl:call-template name="composeMethodCallParam">
|
---|
933 | <xsl:with-param name="isIn" select="$isSetter"/>
|
---|
934 | <xsl:with-param name="isOut" select="not($isSetter)"/>
|
---|
935 | </xsl:call-template>
|
---|
936 | </xsl:when>
|
---|
937 | <!-- regular method call -->
|
---|
938 | <xsl:when test="name()='method'">
|
---|
939 | <!-- method name -->
|
---|
940 | <xsl:call-template name="capitalize">
|
---|
941 | <xsl:with-param name="str" select="@name"/>
|
---|
942 | </xsl:call-template>
|
---|
943 | <xsl:text> (</xsl:text>
|
---|
944 | <!-- parameters -->
|
---|
945 | <xsl:for-each select="param">
|
---|
946 | <xsl:call-template name="composeMethodCallParam"/>
|
---|
947 | <xsl:if test="position() != last()">
|
---|
948 | <xsl:text>, </xsl:text>
|
---|
949 | </xsl:if>
|
---|
950 | </xsl:for-each>
|
---|
951 | </xsl:when>
|
---|
952 | </xsl:choose>
|
---|
953 | <xsl:text>);
</xsl:text>
|
---|
954 | <!-- apply 'post-call' hooks -->
|
---|
955 | <xsl:choose>
|
---|
956 | <xsl:when test="name()='attribute'">
|
---|
957 | <xsl:call-template name="hooks">
|
---|
958 | <xsl:with-param name="when" select="'post-call'"/>
|
---|
959 | <xsl:with-param name="isSetter" select="$isSetter"/>
|
---|
960 | </xsl:call-template>
|
---|
961 | </xsl:when>
|
---|
962 | <xsl:when test="name()='method'">
|
---|
963 | <xsl:for-each select="param">
|
---|
964 | <xsl:call-template name="hooks">
|
---|
965 | <xsl:with-param name="when" select="'post-call'"/>
|
---|
966 | </xsl:call-template>
|
---|
967 | </xsl:for-each>
|
---|
968 | </xsl:when>
|
---|
969 | </xsl:choose>
|
---|
970 | <!-- -->
|
---|
971 | <xsl:call-template name="tryComposeFetchErrorInfo"/>
|
---|
972 | </xsl:template>
|
---|
973 |
|
---|
974 | <!--
|
---|
975 | * Composes a 'fetch error info' call or returns the name of the
|
---|
976 | * appropriate base class name that provides error info functionality
|
---|
977 | * (depending on the mode parameter). Does nothing if the current
|
---|
978 | * interface does not support error info.
|
---|
979 | *
|
---|
980 | * @param mode
|
---|
981 | * - 'getBaseClassName': expands to the base class name
|
---|
982 | * - any other value: composes a 'fetch error info' method call
|
---|
983 | -->
|
---|
984 | <xsl:template name="tryComposeFetchErrorInfo">
|
---|
985 | <xsl:param name="mode" select="''"/>
|
---|
986 | <xsl:variable name="ifaceSupportsErrorInfo" select="
|
---|
987 | ancestor-or-self::interface[1]/@supportsErrorInfo
|
---|
988 | "/>
|
---|
989 | <xsl:variable name="librarySupportsErrorInfo" select="ancestor::library/@supportsErrorInfo"/>
|
---|
990 | <xsl:choose>
|
---|
991 | <xsl:when test="$ifaceSupportsErrorInfo">
|
---|
992 | <xsl:call-template name="composeFetchErrorInfo">
|
---|
993 | <xsl:with-param name="supports" select="string($ifaceSupportsErrorInfo)"/>
|
---|
994 | <xsl:with-param name="mode" select="$mode"/>
|
---|
995 | </xsl:call-template>
|
---|
996 | </xsl:when>
|
---|
997 | <xsl:when test="$librarySupportsErrorInfo">
|
---|
998 | <xsl:call-template name="composeFetchErrorInfo">
|
---|
999 | <xsl:with-param name="supports" select="string($librarySupportsErrorInfo)"/>
|
---|
1000 | <xsl:with-param name="mode" select="$mode"/>
|
---|
1001 | </xsl:call-template>
|
---|
1002 | </xsl:when>
|
---|
1003 | </xsl:choose>
|
---|
1004 | </xsl:template>
|
---|
1005 |
|
---|
1006 | <xsl:template name="composeFetchErrorInfo">
|
---|
1007 | <xsl:param name="supports" select="''"/>
|
---|
1008 | <xsl:param name="mode" select="''"/>
|
---|
1009 | <xsl:choose>
|
---|
1010 | <xsl:when test="$mode='getBaseClassName'">
|
---|
1011 | <xsl:if test="$supports='strict' or $supports='yes'">
|
---|
1012 | <xsl:text>, COMBaseWithEI</xsl:text>
|
---|
1013 | </xsl:if>
|
---|
1014 | </xsl:when>
|
---|
1015 | <xsl:otherwise>
|
---|
1016 | <xsl:if test="$supports='strict' or $supports='yes'">
|
---|
1017 | <xsl:text> if (mRC != S_OK)
 {
</xsl:text>
|
---|
1018 | <xsl:text> fetchErrorInfo (mIface, &COM_IIDOF (Base::Iface));
</xsl:text>
|
---|
1019 | <xsl:if test="$supports='strict'">
|
---|
1020 | <xsl:text> AssertMsg (errInfo.isFullAvailable(), </xsl:text>
|
---|
1021 | <xsl:text>("for RC=0x%08X\n", mRC));
</xsl:text>
|
---|
1022 | </xsl:if>
|
---|
1023 | <xsl:text> }
</xsl:text>
|
---|
1024 | </xsl:if>
|
---|
1025 | </xsl:otherwise>
|
---|
1026 | </xsl:choose>
|
---|
1027 | </xsl:template>
|
---|
1028 |
|
---|
1029 | <xsl:template name="composeMethodCallParam">
|
---|
1030 |
|
---|
1031 | <xsl:param name="isIn" select="@dir='in'"/>
|
---|
1032 | <xsl:param name="isOut" select="@dir='out' or @dir='return'"/>
|
---|
1033 |
|
---|
1034 | <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
|
---|
1035 |
|
---|
1036 | <xsl:choose>
|
---|
1037 | <!-- safearrays -->
|
---|
1038 | <xsl:when test="@safearray='yes'">
|
---|
1039 | <xsl:choose>
|
---|
1040 | <xsl:when test="$isIn">
|
---|
1041 | <xsl:text>ComSafeArrayAsInParam (</xsl:text>
|
---|
1042 | <xsl:value-of select="@name"/>
|
---|
1043 | <xsl:text>)</xsl:text>
|
---|
1044 | </xsl:when>
|
---|
1045 | <xsl:when test="$isOut">
|
---|
1046 | <xsl:text>ComSafeArrayAsOutParam (</xsl:text>
|
---|
1047 | <xsl:value-of select="@name"/>
|
---|
1048 | <xsl:text>)</xsl:text>
|
---|
1049 | </xsl:when>
|
---|
1050 | </xsl:choose>
|
---|
1051 | </xsl:when>
|
---|
1052 | <!-- string types -->
|
---|
1053 | <xsl:when test="@type = 'wstring' or @type = 'uuid'">
|
---|
1054 | <xsl:choose>
|
---|
1055 | <xsl:when test="$isIn">
|
---|
1056 | <xsl:text>BSTRIn (a</xsl:text>
|
---|
1057 | <xsl:call-template name="capitalize">
|
---|
1058 | <xsl:with-param name="str" select="@name"/>
|
---|
1059 | </xsl:call-template>
|
---|
1060 | <xsl:text>)</xsl:text>
|
---|
1061 | </xsl:when>
|
---|
1062 | <xsl:when test="$isOut">
|
---|
1063 | <xsl:text>BSTROut (a</xsl:text>
|
---|
1064 | <xsl:call-template name="capitalize">
|
---|
1065 | <xsl:with-param name="str" select="@name"/>
|
---|
1066 | </xsl:call-template>
|
---|
1067 | <xsl:text>)</xsl:text>
|
---|
1068 | </xsl:when>
|
---|
1069 | </xsl:choose>
|
---|
1070 | </xsl:when>
|
---|
1071 | <!-- enum types -->
|
---|
1072 | <xsl:when test="
|
---|
1073 | (ancestor::library/enum[@name=current()/@type]) or
|
---|
1074 | (ancestor::library/if[@target=$self_target]/enum[@name=current()/@type])
|
---|
1075 | ">
|
---|
1076 | <xsl:choose>
|
---|
1077 | <xsl:when test="$isIn">
|
---|
1078 | <xsl:text>(</xsl:text>
|
---|
1079 | <xsl:value-of select="@type"/>
|
---|
1080 | <xsl:text>_T) a</xsl:text>
|
---|
1081 | <xsl:call-template name="capitalize">
|
---|
1082 | <xsl:with-param name="str" select="@name"/>
|
---|
1083 | </xsl:call-template>
|
---|
1084 | </xsl:when>
|
---|
1085 | <xsl:when test="$isOut">
|
---|
1086 | <xsl:text>ENUMOut <K</xsl:text>
|
---|
1087 | <xsl:value-of select="@type"/>
|
---|
1088 | <xsl:text>, </xsl:text>
|
---|
1089 | <xsl:value-of select="@type"/>
|
---|
1090 | <xsl:text>_T> (a</xsl:text>
|
---|
1091 | <xsl:call-template name="capitalize">
|
---|
1092 | <xsl:with-param name="str" select="@name"/>
|
---|
1093 | </xsl:call-template>
|
---|
1094 | <xsl:text>)</xsl:text>
|
---|
1095 | </xsl:when>
|
---|
1096 | </xsl:choose>
|
---|
1097 | </xsl:when>
|
---|
1098 | <!-- interface types -->
|
---|
1099 | <xsl:when test="
|
---|
1100 | @type='$unknown' or
|
---|
1101 | ((ancestor::library/interface[@name=current()/@type]) or
|
---|
1102 | (ancestor::library/if[@target=$self_target]/interface[@name=current()/@type])
|
---|
1103 | )
|
---|
1104 | ">
|
---|
1105 | <xsl:choose>
|
---|
1106 | <xsl:when test="$isIn">
|
---|
1107 | <xsl:text>a</xsl:text>
|
---|
1108 | <xsl:call-template name="capitalize">
|
---|
1109 | <xsl:with-param name="str" select="@name"/>
|
---|
1110 | </xsl:call-template>
|
---|
1111 | <xsl:choose>
|
---|
1112 | <xsl:when test="@type='$unknown'">
|
---|
1113 | <xsl:text>.raw()</xsl:text>
|
---|
1114 | </xsl:when>
|
---|
1115 | <xsl:otherwise>
|
---|
1116 | <xsl:text>.mIface</xsl:text>
|
---|
1117 | </xsl:otherwise>
|
---|
1118 | </xsl:choose>
|
---|
1119 | </xsl:when>
|
---|
1120 | <xsl:when test="$isOut">
|
---|
1121 | <xsl:text>&a</xsl:text>
|
---|
1122 | <xsl:call-template name="capitalize">
|
---|
1123 | <xsl:with-param name="str" select="@name"/>
|
---|
1124 | </xsl:call-template>
|
---|
1125 | <xsl:choose>
|
---|
1126 | <xsl:when test="@type='$unknown'">
|
---|
1127 | <xsl:text>.rawRef()</xsl:text>
|
---|
1128 | </xsl:when>
|
---|
1129 | <xsl:otherwise>
|
---|
1130 | <xsl:text>.mIface</xsl:text>
|
---|
1131 | </xsl:otherwise>
|
---|
1132 | </xsl:choose>
|
---|
1133 | </xsl:when>
|
---|
1134 | </xsl:choose>
|
---|
1135 | </xsl:when>
|
---|
1136 | <!-- currently unsupported types -->
|
---|
1137 | <xsl:when test="@type = 'string'">
|
---|
1138 | <xsl:message terminate="yes">
|
---|
1139 | <xsl:text>Parameter type </xsl:text>
|
---|
1140 | <xsl:value-of select="@type"/>
|
---|
1141 | <xsl:text>is not currently supported</xsl:text>
|
---|
1142 | </xsl:message>
|
---|
1143 | </xsl:when>
|
---|
1144 | <!-- assuming scalar types -->
|
---|
1145 | <xsl:otherwise>
|
---|
1146 | <xsl:choose>
|
---|
1147 | <xsl:when test="$isIn">
|
---|
1148 | <xsl:text>a</xsl:text>
|
---|
1149 | <xsl:call-template name="capitalize">
|
---|
1150 | <xsl:with-param name="str" select="@name"/>
|
---|
1151 | </xsl:call-template>
|
---|
1152 | </xsl:when>
|
---|
1153 | <xsl:when test="$isOut">
|
---|
1154 | <xsl:text>&a</xsl:text>
|
---|
1155 | <xsl:call-template name="capitalize">
|
---|
1156 | <xsl:with-param name="str" select="@name"/>
|
---|
1157 | </xsl:call-template>
|
---|
1158 | </xsl:when>
|
---|
1159 | </xsl:choose>
|
---|
1160 | </xsl:otherwise>
|
---|
1161 | </xsl:choose>
|
---|
1162 | </xsl:template>
|
---|
1163 |
|
---|
1164 |
|
---|
1165 | <!--
|
---|
1166 | * attribute/parameter type conversion (returns plain Qt type name)
|
---|
1167 | -->
|
---|
1168 | <xsl:template match="attribute/@type | param/@type">
|
---|
1169 | <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
|
---|
1170 |
|
---|
1171 | <xsl:choose>
|
---|
1172 | <!-- modifiers -->
|
---|
1173 | <xsl:when test="name(current())='type' and ../@mod">
|
---|
1174 | <xsl:if test="../@safearray and ../@mod='ptr'">
|
---|
1175 | <xsl:message terminate="yes">
|
---|
1176 | <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
|
---|
1177 | <xsl:text>either 'safearray' or 'mod' attribute is allowed, but not both!</xsl:text>
|
---|
1178 | </xsl:message>
|
---|
1179 | </xsl:if>
|
---|
1180 | <xsl:choose>
|
---|
1181 | <xsl:when test="../@mod='ptr'">
|
---|
1182 | <xsl:choose>
|
---|
1183 | <!-- standard types -->
|
---|
1184 | <!--xsl:when test=".='result'">??</xsl:when-->
|
---|
1185 | <xsl:when test=".='boolean'">BOOL *</xsl:when>
|
---|
1186 | <xsl:when test=".='octet'">BYTE *</xsl:when>
|
---|
1187 | <xsl:when test=".='short'">SHORT *</xsl:when>
|
---|
1188 | <xsl:when test=".='unsigned short'">USHORT *</xsl:when>
|
---|
1189 | <xsl:when test=".='long'">LONG *</xsl:when>
|
---|
1190 | <xsl:when test=".='long long'">LONG64 *</xsl:when>
|
---|
1191 | <xsl:when test=".='unsigned long'">ULONG *</xsl:when>
|
---|
1192 | <xsl:when test=".='unsigned long long'">ULONG64 *</xsl:when>
|
---|
1193 | <xsl:otherwise>
|
---|
1194 | <xsl:message terminate="yes">
|
---|
1195 | <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
|
---|
1196 | <xsl:text>attribute 'mod=</xsl:text>
|
---|
1197 | <xsl:value-of select="concat('"',../@mod,'"')"/>
|
---|
1198 | <xsl:text>' cannot be used with type </xsl:text>
|
---|
1199 | <xsl:value-of select="concat('"',current(),'"!')"/>
|
---|
1200 | </xsl:message>
|
---|
1201 | </xsl:otherwise>
|
---|
1202 | </xsl:choose>
|
---|
1203 | </xsl:when>
|
---|
1204 | <xsl:when test="../@mod='string'">
|
---|
1205 | <xsl:if test="../@safearray">
|
---|
1206 | <xsl:text>QVector <</xsl:text>
|
---|
1207 | </xsl:if>
|
---|
1208 | <xsl:choose>
|
---|
1209 | <!-- standard types -->
|
---|
1210 | <!--xsl:when test=".='result'">??</xsl:when-->
|
---|
1211 | <xsl:when test=".='uuid'">QString</xsl:when>
|
---|
1212 | <xsl:otherwise>
|
---|
1213 | <xsl:message terminate="yes">
|
---|
1214 | <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
|
---|
1215 | <xsl:text>attribute 'mod=</xsl:text>
|
---|
1216 | <xsl:value-of select="concat('"',../@mod,'"')"/>
|
---|
1217 | <xsl:text>' cannot be used with type </xsl:text>
|
---|
1218 | <xsl:value-of select="concat('"',current(),'"!')"/>
|
---|
1219 | </xsl:message>
|
---|
1220 | </xsl:otherwise>
|
---|
1221 | </xsl:choose>
|
---|
1222 | <xsl:if test="../@safearray">
|
---|
1223 | <xsl:text>></xsl:text>
|
---|
1224 | </xsl:if>
|
---|
1225 | </xsl:when>
|
---|
1226 | <xsl:otherwise>
|
---|
1227 | <xsl:message terminate="yes">
|
---|
1228 | <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
|
---|
1229 | <xsl:value-of select="concat('value "',../@mod,'" ')"/>
|
---|
1230 | <xsl:text>of attribute 'mod' is invalid!</xsl:text>
|
---|
1231 | </xsl:message>
|
---|
1232 | </xsl:otherwise>
|
---|
1233 | </xsl:choose>
|
---|
1234 | </xsl:when>
|
---|
1235 | <!-- no modifiers -->
|
---|
1236 | <xsl:otherwise>
|
---|
1237 | <xsl:if test="../@safearray">
|
---|
1238 | <xsl:text>QVector <</xsl:text>
|
---|
1239 | </xsl:if>
|
---|
1240 | <xsl:choose>
|
---|
1241 | <!-- standard types -->
|
---|
1242 | <xsl:when test=".='result'">HRESULT</xsl:when>
|
---|
1243 | <xsl:when test=".='boolean'">BOOL</xsl:when>
|
---|
1244 | <xsl:when test=".='octet'">BYTE</xsl:when>
|
---|
1245 | <xsl:when test=".='short'">SHORT</xsl:when>
|
---|
1246 | <xsl:when test=".='unsigned short'">USHORT</xsl:when>
|
---|
1247 | <xsl:when test=".='long'">LONG</xsl:when>
|
---|
1248 | <xsl:when test=".='long long'">LONG64</xsl:when>
|
---|
1249 | <xsl:when test=".='unsigned long'">ULONG</xsl:when>
|
---|
1250 | <xsl:when test=".='unsigned long long'">ULONG64</xsl:when>
|
---|
1251 | <xsl:when test=".='char'">CHAR</xsl:when>
|
---|
1252 | <xsl:when test=".='string'">CHAR *</xsl:when>
|
---|
1253 | <xsl:when test=".='wchar'">OLECHAR</xsl:when>
|
---|
1254 | <xsl:when test=".='wstring'">QString</xsl:when>
|
---|
1255 | <!-- UUID type -->
|
---|
1256 | <xsl:when test=".='uuid'">QUuid</xsl:when>
|
---|
1257 | <!-- system interface types -->
|
---|
1258 | <xsl:when test=".='$unknown'">CUnknown</xsl:when>
|
---|
1259 | <xsl:otherwise>
|
---|
1260 | <xsl:choose>
|
---|
1261 | <!-- enum types -->
|
---|
1262 | <xsl:when test="
|
---|
1263 | (ancestor::library/enum[@name=current()]) or
|
---|
1264 | (ancestor::library/if[@target=$self_target]/enum[@name=current()])
|
---|
1265 | ">
|
---|
1266 | <xsl:value-of select="concat('K',string(.))"/>
|
---|
1267 | </xsl:when>
|
---|
1268 | <!-- custom interface types -->
|
---|
1269 | <xsl:when test="
|
---|
1270 | ((ancestor::library/interface[@name=current()]) or
|
---|
1271 | (ancestor::library/if[@target=$self_target]/interface[@name=current()])
|
---|
1272 | )
|
---|
1273 | ">
|
---|
1274 | <xsl:value-of select="concat('C',substring(.,2))"/>
|
---|
1275 | </xsl:when>
|
---|
1276 | <!-- other types -->
|
---|
1277 | <xsl:otherwise>
|
---|
1278 | <xsl:message terminate="yes">
|
---|
1279 | <xsl:text>Unknown parameter type: </xsl:text>
|
---|
1280 | <xsl:value-of select="."/>
|
---|
1281 | </xsl:message>
|
---|
1282 | </xsl:otherwise>
|
---|
1283 | </xsl:choose>
|
---|
1284 | </xsl:otherwise>
|
---|
1285 | </xsl:choose>
|
---|
1286 | <xsl:if test="../@safearray">
|
---|
1287 | <xsl:text>></xsl:text>
|
---|
1288 | </xsl:if>
|
---|
1289 | </xsl:otherwise>
|
---|
1290 | </xsl:choose>
|
---|
1291 | </xsl:template>
|
---|
1292 |
|
---|
1293 |
|
---|
1294 | <!--
|
---|
1295 | * generates a null initializer for all scalar types (such as bool or long)
|
---|
1296 | * and enum types in the form of ' = <null_initializer>', or nothing for other
|
---|
1297 | * types.
|
---|
1298 | -->
|
---|
1299 | <xsl:template match="attribute/@type | param/@type" mode="initializer">
|
---|
1300 |
|
---|
1301 | <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
|
---|
1302 |
|
---|
1303 | <xsl:choose>
|
---|
1304 | <!-- safearrays don't need initializers -->
|
---|
1305 | <xsl:when test="../@safearray">
|
---|
1306 | </xsl:when>
|
---|
1307 | <!-- modifiers -->
|
---|
1308 | <xsl:when test="name(current())='type' and ../@mod">
|
---|
1309 | <xsl:choose>
|
---|
1310 | <xsl:when test="../@mod='ptr'">
|
---|
1311 | <xsl:choose>
|
---|
1312 | <!-- standard types -->
|
---|
1313 | <!--xsl:when test=".='result'">??</xsl:when-->
|
---|
1314 | <xsl:when test=".='boolean'"> = NULL</xsl:when>
|
---|
1315 | <xsl:when test=".='octet'"> = NULL</xsl:when>
|
---|
1316 | <xsl:when test=".='short'"> = NULL</xsl:when>
|
---|
1317 | <xsl:when test=".='unsigned short'"> = NULL</xsl:when>
|
---|
1318 | <xsl:when test=".='long'"> = NULL</xsl:when>
|
---|
1319 | <xsl:when test=".='long long'"> = NULL</xsl:when>
|
---|
1320 | <xsl:when test=".='unsigned long'"> = NULL</xsl:when>
|
---|
1321 | <xsl:when test=".='unsigned long long'"> = NULL</xsl:when>
|
---|
1322 | <xsl:otherwise>
|
---|
1323 | <xsl:message terminate="yes">
|
---|
1324 | <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
|
---|
1325 | <xsl:text>attribute 'mod=</xsl:text>
|
---|
1326 | <xsl:value-of select="concat('"',../@mod,'"')"/>
|
---|
1327 | <xsl:text>' cannot be used with type </xsl:text>
|
---|
1328 | <xsl:value-of select="concat('"',current(),'"!')"/>
|
---|
1329 | </xsl:message>
|
---|
1330 | </xsl:otherwise>
|
---|
1331 | </xsl:choose>
|
---|
1332 | </xsl:when>
|
---|
1333 | <xsl:when test="../@mod='string'">
|
---|
1334 | <xsl:choose>
|
---|
1335 | <!-- standard types -->
|
---|
1336 | <!--xsl:when test=".='result'">??</xsl:when-->
|
---|
1337 | <xsl:when test=".='uuid'"></xsl:when>
|
---|
1338 | <xsl:otherwise>
|
---|
1339 | <xsl:message terminate="yes">
|
---|
1340 | <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
|
---|
1341 | <xsl:text>attribute 'mod=</xsl:text>
|
---|
1342 | <xsl:value-of select="concat('"',../@mod,'"')"/>
|
---|
1343 | <xsl:text>' cannot be used with type </xsl:text>
|
---|
1344 | <xsl:value-of select="concat('"',current(),'"!')"/>
|
---|
1345 | </xsl:message>
|
---|
1346 | </xsl:otherwise>
|
---|
1347 | </xsl:choose>
|
---|
1348 | </xsl:when>
|
---|
1349 | <xsl:otherwise>
|
---|
1350 | <xsl:message terminate="yes">
|
---|
1351 | <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
|
---|
1352 | <xsl:value-of select="concat('value "',../@mod,'" ')"/>
|
---|
1353 | <xsl:text>of attribute 'mod' is invalid!</xsl:text>
|
---|
1354 | </xsl:message>
|
---|
1355 | </xsl:otherwise>
|
---|
1356 | </xsl:choose>
|
---|
1357 | </xsl:when>
|
---|
1358 | <!-- no modifiers -->
|
---|
1359 | <xsl:otherwise>
|
---|
1360 | <xsl:choose>
|
---|
1361 | <!-- standard types that need a zero initializer -->
|
---|
1362 | <xsl:when test=".='result'"> = S_OK</xsl:when>
|
---|
1363 | <xsl:when test=".='boolean'"> = FALSE</xsl:when>
|
---|
1364 | <xsl:when test=".='octet'"> = 0</xsl:when>
|
---|
1365 | <xsl:when test=".='short'"> = 0</xsl:when>
|
---|
1366 | <xsl:when test=".='unsigned short'"> = 0</xsl:when>
|
---|
1367 | <xsl:when test=".='long'"> = 0</xsl:when>
|
---|
1368 | <xsl:when test=".='long long'"> = 0</xsl:when>
|
---|
1369 | <xsl:when test=".='unsigned long'"> = 0</xsl:when>
|
---|
1370 | <xsl:when test=".='unsigned long long'"> = 0</xsl:when>
|
---|
1371 | <xsl:when test=".='char'"> = 0</xsl:when>
|
---|
1372 | <xsl:when test=".='string'"> = NULL</xsl:when>
|
---|
1373 | <xsl:when test=".='wchar'"> = 0</xsl:when>
|
---|
1374 | <xsl:otherwise>
|
---|
1375 | <xsl:choose>
|
---|
1376 | <!-- enum types initialized with 0 -->
|
---|
1377 | <xsl:when test="
|
---|
1378 | (ancestor::library/enum[@name=current()]) or
|
---|
1379 | (ancestor::library/if[@target=$self_target]/enum[@name=current()])
|
---|
1380 | ">
|
---|
1381 | <xsl:value-of select="concat(' = (K',string(.),') 0')"/>
|
---|
1382 | </xsl:when>
|
---|
1383 | </xsl:choose>
|
---|
1384 | </xsl:otherwise>
|
---|
1385 | </xsl:choose>
|
---|
1386 | </xsl:otherwise>
|
---|
1387 | </xsl:choose>
|
---|
1388 | </xsl:template>
|
---|
1389 |
|
---|
1390 |
|
---|
1391 | <!--
|
---|
1392 | * attribute/parameter type conversion (for method declaration)
|
---|
1393 | -->
|
---|
1394 | <xsl:template match="attribute/@type | param/@type" mode="param">
|
---|
1395 |
|
---|
1396 | <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
|
---|
1397 |
|
---|
1398 | <xsl:choose>
|
---|
1399 | <!-- class types -->
|
---|
1400 | <xsl:when test="
|
---|
1401 | .='string' or
|
---|
1402 | .='wstring' or
|
---|
1403 | ../@safearray='yes' or
|
---|
1404 | ((ancestor::library/enum[@name=current()]) or
|
---|
1405 | (ancestor::library/if[@target=$self_target]/enum[@name=current()])
|
---|
1406 | ) or
|
---|
1407 | .='$unknown' or
|
---|
1408 | ((ancestor::library/interface[@name=current()]) or
|
---|
1409 | (ancestor::library/if[@target=$self_target]/interface[@name=current()])
|
---|
1410 | )
|
---|
1411 | ">
|
---|
1412 | <xsl:choose>
|
---|
1413 | <!-- <attribute> context -->
|
---|
1414 | <xsl:when test="name(..)='attribute'">
|
---|
1415 | <xsl:text>const </xsl:text>
|
---|
1416 | <xsl:apply-templates select="."/>
|
---|
1417 | <xsl:text> &</xsl:text>
|
---|
1418 | </xsl:when>
|
---|
1419 | <!-- <param> context -->
|
---|
1420 | <xsl:when test="name(..)='param'">
|
---|
1421 | <xsl:choose>
|
---|
1422 | <xsl:when test="../@dir='in'">
|
---|
1423 | <xsl:text>const </xsl:text>
|
---|
1424 | <xsl:apply-templates select="."/>
|
---|
1425 | <xsl:text> &</xsl:text>
|
---|
1426 | </xsl:when>
|
---|
1427 | <xsl:when test="../@dir='out'">
|
---|
1428 | <xsl:apply-templates select="."/>
|
---|
1429 | <xsl:text> &</xsl:text>
|
---|
1430 | </xsl:when>
|
---|
1431 | <xsl:when test="../@dir='return'">
|
---|
1432 | <xsl:apply-templates select="."/>
|
---|
1433 | </xsl:when>
|
---|
1434 | </xsl:choose>
|
---|
1435 | </xsl:when>
|
---|
1436 | </xsl:choose>
|
---|
1437 | </xsl:when>
|
---|
1438 | <!-- assume scalar types -->
|
---|
1439 | <xsl:otherwise>
|
---|
1440 | <xsl:choose>
|
---|
1441 | <!-- <attribute> context -->
|
---|
1442 | <xsl:when test="name(..)='attribute'">
|
---|
1443 | <xsl:apply-templates select="."/>
|
---|
1444 | </xsl:when>
|
---|
1445 | <!-- <param> context -->
|
---|
1446 | <xsl:when test="name(..)='param'">
|
---|
1447 | <xsl:apply-templates select="."/>
|
---|
1448 | <xsl:if test="../@dir='out'">
|
---|
1449 | <xsl:text> &</xsl:text>
|
---|
1450 | </xsl:if>
|
---|
1451 | </xsl:when>
|
---|
1452 | </xsl:choose>
|
---|
1453 | </xsl:otherwise>
|
---|
1454 | </xsl:choose>
|
---|
1455 | </xsl:template>
|
---|
1456 |
|
---|
1457 |
|
---|
1458 | <!--
|
---|
1459 | * attribute/parameter type conversion (returns plain COM type name)
|
---|
1460 | * (basically, copied from midl.xsl)
|
---|
1461 | -->
|
---|
1462 | <xsl:template match="attribute/@type | param/@type" mode="com">
|
---|
1463 |
|
---|
1464 | <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
|
---|
1465 |
|
---|
1466 | <xsl:choose>
|
---|
1467 | <!-- modifiers -->
|
---|
1468 | <xsl:when test="name(current())='type' and ../@mod">
|
---|
1469 | <xsl:choose>
|
---|
1470 | <xsl:when test="../@mod='ptr'">
|
---|
1471 | <xsl:choose>
|
---|
1472 | <!-- standard types -->
|
---|
1473 | <!--xsl:when test=".='result'">??</xsl:when-->
|
---|
1474 | <xsl:when test=".='boolean'">BOOL *</xsl:when>
|
---|
1475 | <xsl:when test=".='octet'">BYTE *</xsl:when>
|
---|
1476 | <xsl:when test=".='short'">SHORT *</xsl:when>
|
---|
1477 | <xsl:when test=".='unsigned short'">USHORT *</xsl:when>
|
---|
1478 | <xsl:when test=".='long'">LONG *</xsl:when>
|
---|
1479 | <xsl:when test=".='long long'">LONG64 *</xsl:when>
|
---|
1480 | <xsl:when test=".='unsigned long'">ULONG *</xsl:when>
|
---|
1481 | <xsl:when test=".='unsigned long long'">ULONG64 *</xsl:when>
|
---|
1482 | <xsl:otherwise>
|
---|
1483 | <xsl:message terminate="yes">
|
---|
1484 | <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
|
---|
1485 | <xsl:text>attribute 'mod=</xsl:text>
|
---|
1486 | <xsl:value-of select="concat('"',../@mod,'"')"/>
|
---|
1487 | <xsl:text>' cannot be used with type </xsl:text>
|
---|
1488 | <xsl:value-of select="concat('"',current(),'"!')"/>
|
---|
1489 | </xsl:message>
|
---|
1490 | </xsl:otherwise>
|
---|
1491 | </xsl:choose>
|
---|
1492 | </xsl:when>
|
---|
1493 | <xsl:when test="../@mod='string'">
|
---|
1494 | <xsl:choose>
|
---|
1495 | <!-- standard types -->
|
---|
1496 | <!--xsl:when test=".='result'">??</xsl:when-->
|
---|
1497 | <xsl:when test=".='uuid'">BSTR</xsl:when>
|
---|
1498 | <xsl:otherwise>
|
---|
1499 | <xsl:message terminate="yes">
|
---|
1500 | <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
|
---|
1501 | <xsl:text>attribute 'mod=</xsl:text>
|
---|
1502 | <xsl:value-of select="concat('"',../@mod,'"')"/>
|
---|
1503 | <xsl:text>' cannot be used with type </xsl:text>
|
---|
1504 | <xsl:value-of select="concat('"',current(),'"!')"/>
|
---|
1505 | </xsl:message>
|
---|
1506 | </xsl:otherwise>
|
---|
1507 | </xsl:choose>
|
---|
1508 | </xsl:when>
|
---|
1509 | <xsl:otherwise>
|
---|
1510 | <xsl:message terminate="yes">
|
---|
1511 | <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
|
---|
1512 | <xsl:value-of select="concat('value "',../@mod,'" ')"/>
|
---|
1513 | <xsl:text>of attribute 'mod' is invalid!</xsl:text>
|
---|
1514 | </xsl:message>
|
---|
1515 | </xsl:otherwise>
|
---|
1516 | </xsl:choose>
|
---|
1517 | </xsl:when>
|
---|
1518 | <!-- no modifiers -->
|
---|
1519 | <xsl:otherwise>
|
---|
1520 | <xsl:choose>
|
---|
1521 | <!-- standard types -->
|
---|
1522 | <xsl:when test=".='result'">HRESULT</xsl:when>
|
---|
1523 | <xsl:when test=".='boolean'">BOOL</xsl:when>
|
---|
1524 | <xsl:when test=".='octet'">BYTE</xsl:when>
|
---|
1525 | <xsl:when test=".='short'">SHORT</xsl:when>
|
---|
1526 | <xsl:when test=".='unsigned short'">USHORT</xsl:when>
|
---|
1527 | <xsl:when test=".='long'">LONG</xsl:when>
|
---|
1528 | <xsl:when test=".='long long'">LONG64</xsl:when>
|
---|
1529 | <xsl:when test=".='unsigned long'">ULONG</xsl:when>
|
---|
1530 | <xsl:when test=".='unsigned long long'">ULONG64</xsl:when>
|
---|
1531 | <xsl:when test=".='char'">CHAR</xsl:when>
|
---|
1532 | <xsl:when test=".='string'">CHAR *</xsl:when>
|
---|
1533 | <xsl:when test=".='wchar'">OLECHAR</xsl:when>
|
---|
1534 | <xsl:when test=".='wstring'">BSTR</xsl:when>
|
---|
1535 | <!-- UUID type -->
|
---|
1536 | <xsl:when test=".='uuid'">GUID</xsl:when>
|
---|
1537 | <!-- system interface types -->
|
---|
1538 | <xsl:when test=".='$unknown'">IUnknown *</xsl:when>
|
---|
1539 | <xsl:otherwise>
|
---|
1540 | <xsl:choose>
|
---|
1541 | <!-- enum types -->
|
---|
1542 | <xsl:when test="
|
---|
1543 | (ancestor::library/enum[@name=current()]) or
|
---|
1544 | (ancestor::library/if[@target=$self_target]/enum[@name=current()])
|
---|
1545 | ">
|
---|
1546 | <xsl:value-of select="."/>
|
---|
1547 | </xsl:when>
|
---|
1548 | <!-- custom interface types -->
|
---|
1549 | <xsl:when test="
|
---|
1550 | ((ancestor::library/interface[@name=current()]) or
|
---|
1551 | (ancestor::library/if[@target=$self_target]/interface[@name=current()])
|
---|
1552 | )
|
---|
1553 | ">
|
---|
1554 | <xsl:value-of select="."/><xsl:text> *</xsl:text>
|
---|
1555 | </xsl:when>
|
---|
1556 | <!-- other types -->
|
---|
1557 | <xsl:otherwise>
|
---|
1558 | <xsl:message terminate="yes">
|
---|
1559 | <xsl:text>Unknown parameter type: </xsl:text>
|
---|
1560 | <xsl:value-of select="."/>
|
---|
1561 | </xsl:message>
|
---|
1562 | </xsl:otherwise>
|
---|
1563 | </xsl:choose>
|
---|
1564 | </xsl:otherwise>
|
---|
1565 | </xsl:choose>
|
---|
1566 | </xsl:otherwise>
|
---|
1567 | </xsl:choose>
|
---|
1568 | </xsl:template>
|
---|
1569 |
|
---|
1570 |
|
---|
1571 | <!--
|
---|
1572 | * attribute/parameter type additional hooks.
|
---|
1573 | *
|
---|
1574 | * Called in the context of <attribute> or <param> elements.
|
---|
1575 | *
|
---|
1576 | * @param when When the hook is being called:
|
---|
1577 | * 'pre-call' - right before the method call
|
---|
1578 | * 'post-call' - right after the method call
|
---|
1579 | * @param isSetter Non-empty if called in the cotext of the attribute setter
|
---|
1580 | * call.
|
---|
1581 | -->
|
---|
1582 | <xsl:template name="hooks">
|
---|
1583 |
|
---|
1584 | <xsl:param name="when" select="''"/>
|
---|
1585 | <xsl:param name="isSetter" select="''"/>
|
---|
1586 |
|
---|
1587 | <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
|
---|
1588 |
|
---|
1589 | <xsl:variable name="is_iface" select="(
|
---|
1590 | ((ancestor::library/interface[@name=current()/@type]) or
|
---|
1591 | (ancestor::library/if[@target=$self_target]/interface[@name=current()/@type])
|
---|
1592 | )
|
---|
1593 | )"/>
|
---|
1594 |
|
---|
1595 | <xsl:variable name="is_enum" select="(
|
---|
1596 | (ancestor::library/enum[@name=current()/@type]) or
|
---|
1597 | (ancestor::library/if[@target=$self_target]/enum[@name=current()/@type])
|
---|
1598 | )"/>
|
---|
1599 |
|
---|
1600 | <xsl:choose>
|
---|
1601 | <xsl:when test="$when='pre-call'">
|
---|
1602 | <xsl:choose>
|
---|
1603 | <xsl:when test="@safearray='yes'">
|
---|
1604 | <!-- declare a SafeArray variable -->
|
---|
1605 | <xsl:choose>
|
---|
1606 | <!-- interface types need special treatment here -->
|
---|
1607 | <xsl:when test="@type='$unknown'">
|
---|
1608 | <xsl:text> com::SafeIfaceArray <IUnknown> </xsl:text>
|
---|
1609 | </xsl:when>
|
---|
1610 | <xsl:when test="$is_iface">
|
---|
1611 | <xsl:text> com::SafeIfaceArray <</xsl:text>
|
---|
1612 | <xsl:value-of select="@type"/>
|
---|
1613 | <xsl:text>> </xsl:text>
|
---|
1614 | </xsl:when>
|
---|
1615 | <!-- enums need the _T prefix -->
|
---|
1616 | <xsl:when test="$is_enum">
|
---|
1617 | <xsl:text> com::SafeArray <</xsl:text>
|
---|
1618 | <xsl:value-of select="@type"/>
|
---|
1619 | <xsl:text>_T> </xsl:text>
|
---|
1620 | </xsl:when>
|
---|
1621 | <!-- GUID is special too -->
|
---|
1622 | <xsl:when test="@type='uuid' and @mod!='string'">
|
---|
1623 | <xsl:text> com::SafeGUIDArray </xsl:text>
|
---|
1624 | </xsl:when>
|
---|
1625 | <!-- everything else is not -->
|
---|
1626 | <xsl:otherwise>
|
---|
1627 | <xsl:text> com::SafeArray <</xsl:text>
|
---|
1628 | <xsl:apply-templates select="@type" mode="com"/>
|
---|
1629 | <xsl:text>> </xsl:text>
|
---|
1630 | </xsl:otherwise>
|
---|
1631 | </xsl:choose>
|
---|
1632 | <xsl:value-of select="@name"/>
|
---|
1633 | <xsl:text>;
</xsl:text>
|
---|
1634 | <xsl:if test="(name()='attribute' and $isSetter) or
|
---|
1635 | (name()='param' and @dir='in')">
|
---|
1636 | <!-- convert QVector to SafeArray -->
|
---|
1637 | <xsl:choose>
|
---|
1638 | <!-- interface types need special treatment here -->
|
---|
1639 | <xsl:when test="@type='$unknown' or $is_iface">
|
---|
1640 | <xsl:text> ToSafeIfaceArray (</xsl:text>
|
---|
1641 | </xsl:when>
|
---|
1642 | <xsl:otherwise>
|
---|
1643 | <xsl:text> ToSafeArray (</xsl:text>
|
---|
1644 | </xsl:otherwise>
|
---|
1645 | </xsl:choose>
|
---|
1646 | <xsl:text>a</xsl:text>
|
---|
1647 | <xsl:call-template name="capitalize">
|
---|
1648 | <xsl:with-param name="str" select="@name"/>
|
---|
1649 | </xsl:call-template>
|
---|
1650 | <xsl:text>, </xsl:text>
|
---|
1651 | <xsl:value-of select="@name"/>
|
---|
1652 | <xsl:text>);
</xsl:text>
|
---|
1653 | </xsl:if>
|
---|
1654 | </xsl:when>
|
---|
1655 | </xsl:choose>
|
---|
1656 | </xsl:when>
|
---|
1657 | <xsl:when test="$when='post-call'">
|
---|
1658 | <xsl:choose>
|
---|
1659 | <xsl:when test="@safearray='yes'">
|
---|
1660 | <xsl:if test="(name()='attribute' and not($isSetter)) or
|
---|
1661 | (name()='param' and (@dir='out' or @dir='return'))">
|
---|
1662 | <!-- convert SafeArray to QVector -->
|
---|
1663 | <xsl:choose>
|
---|
1664 | <!-- interface types need special treatment here -->
|
---|
1665 | <xsl:when test="@type='$unknown' or $is_iface">
|
---|
1666 | <xsl:text> FromSafeIfaceArray (</xsl:text>
|
---|
1667 | </xsl:when>
|
---|
1668 | <xsl:otherwise>
|
---|
1669 | <xsl:text> FromSafeArray (</xsl:text>
|
---|
1670 | </xsl:otherwise>
|
---|
1671 | </xsl:choose>
|
---|
1672 | <xsl:value-of select="@name"/>
|
---|
1673 | <xsl:text>, </xsl:text>
|
---|
1674 | <xsl:text>a</xsl:text>
|
---|
1675 | <xsl:call-template name="capitalize">
|
---|
1676 | <xsl:with-param name="str" select="@name"/>
|
---|
1677 | </xsl:call-template>
|
---|
1678 | <xsl:text>);
</xsl:text>
|
---|
1679 | </xsl:if>
|
---|
1680 | </xsl:when>
|
---|
1681 | </xsl:choose>
|
---|
1682 | </xsl:when>
|
---|
1683 | <xsl:otherwise>
|
---|
1684 | <xsl:message terminate="yes">
|
---|
1685 | <xsl:text>Invalid when value: </xsl:text>
|
---|
1686 | <xsl:value-of select="$when"/>
|
---|
1687 | </xsl:message>
|
---|
1688 | </xsl:otherwise>
|
---|
1689 | </xsl:choose>
|
---|
1690 |
|
---|
1691 | </xsl:template>
|
---|
1692 |
|
---|
1693 |
|
---|
1694 | </xsl:stylesheet>
|
---|
1695 |
|
---|