VirtualBox

source: vbox/trunk/src/VBox/Main/idl/midl.xsl@ 56290

Last change on this file since 56290 was 53920, checked in by vboxsync, 10 years ago

midl.xsl,xpidl.xsl: Include typemap-shared.inc.xsl and use the utility templates there. Added a few calls to the 'xsltproc buffer flusher template'.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 28.6 KB
Line 
1<?xml version="1.0"?>
2<!-- $Id: midl.xsl 53920 2015-01-22 15:21:55Z vboxsync $ -->
3
4<!--
5 * A template to generate a MS IDL compatible interface definition file
6 * from the generic interface definition expressed in XML.
7
8 Copyright (C) 2006-2014 Oracle Corporation
9
10 This file is part of VirtualBox Open Source Edition (OSE), as
11 available from http://www.virtualbox.org. This file is free software;
12 you can redistribute it and/or modify it under the terms of the GNU
13 General Public License (GPL) as published by the Free Software
14 Foundation, in version 2 as it comes in the "COPYING" file of the
15 VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17-->
18
19<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
20<xsl:output method="text"/>
21
22<xsl:strip-space elements="*"/>
23
24<!-- Whether to generate proxy code and type library ('yes'), or just the type-library. -->
25<xsl:param name="g_fGenProxy" select="'no'"/>
26
27<xsl:include href="typemap-shared.inc.xsl"/>
28
29
30<!--
31// templates
32/////////////////////////////////////////////////////////////////////////////
33-->
34
35<!--
36 * not explicitly matched elements and attributes
37-->
38<xsl:template match="*"/>
39
40
41<!--
42 * header
43-->
44<xsl:template match="/idl">
45 <xsl:text>
46/*
47 * DO NOT EDIT! This is a generated file.
48 *
49 * MS IDL (MIDL) definition for VirtualBox Main API (COM interfaces)
50 * generated from XIDL (XML interface definition).
51 *
52 * Source : src/VBox/Main/idl/VirtualBox.xidl
53 * Generator : src/VBox/Main/idl/midl.xsl
54 */
55 </xsl:text>
56 <xsl:text>&#x0A;</xsl:text>
57 <xsl:text>import "unknwn.idl";&#x0A;&#x0A;</xsl:text>
58 <xsl:apply-templates/>
59</xsl:template>
60
61
62<!--
63 * ignore all |if|s except those for MIDL target
64-->
65<xsl:template match="if">
66 <xsl:if test="@target='midl'">
67 <xsl:apply-templates/>
68 </xsl:if>
69</xsl:template>
70<xsl:template match="if" mode="forward">
71 <xsl:if test="@target='midl'">
72 <xsl:apply-templates mode="forward"/>
73 </xsl:if>
74</xsl:template>
75<xsl:template match="if" mode="forwarder">
76 <xsl:param name="nameOnly"/>
77 <xsl:if test="@target='midl'">
78 <xsl:apply-templates mode="forwarder">
79 <xsl:with-param name="nameOnly" select="$nameOnly"/>
80 </xsl:apply-templates>
81 </xsl:if>
82</xsl:template>
83
84
85<!--
86 * cpp_quote
87-->
88<xsl:template match="cpp">
89 <xsl:text>cpp_quote("</xsl:text>
90 <xsl:value-of select="@line"/>
91 <xsl:text>")&#x0A;&#x0A;</xsl:text>
92</xsl:template>
93
94
95<!--
96 * #if statement (@if attribute)
97-->
98<xsl:template match="@if" mode="begin">
99 <xsl:text>#if </xsl:text>
100 <xsl:value-of select="."/>
101 <xsl:text>&#x0A;</xsl:text>
102</xsl:template>
103<xsl:template match="@if" mode="end">
104 <xsl:text>#endif&#x0A;</xsl:text>
105</xsl:template>
106
107
108<!--
109 * libraries
110-->
111<xsl:template match="library">
112 <xsl:if test="$g_fGenProxy = 'yes'">
113 <!-- Declare everything outside the library and then reference these
114 from inside the library statement. See:
115 http://msdn.microsoft.com/en-us/library/windows/desktop/aa366841(v=vs.85).aspx -->
116 <xsl:text>&#x0A;</xsl:text>
117 <!-- forward declarations -->
118 <xsl:apply-templates select="if | interface" mode="forward"/>
119 <xsl:text>&#x0A;</xsl:text>
120 <!-- all enums go first -->
121 <xsl:apply-templates select="enum | if/enum"/>
122 <!-- declare the interfaces -->
123 <xsl:apply-templates select="if | interface"/>
124 </xsl:if>
125
126[
127 uuid(<xsl:value-of select="@uuid"/>),
128 version(<xsl:value-of select="@version"/>),
129 helpstring("<xsl:value-of select="@desc"/>")
130]
131<xsl:text>library </xsl:text>
132 <xsl:value-of select="@name"/>
133 <xsl:text>&#x0A;{&#x0A;</xsl:text>
134 <xsl:text>&#x0A;importlib("stdole2.tlb");&#x0A;&#x0A;</xsl:text>
135 <!-- result codes -->
136 <xsl:for-each select="result">
137 <xsl:apply-templates select="."/>
138 </xsl:for-each>
139 <xsl:text>&#x0A;</xsl:text>
140 <xsl:text>&#x0A;</xsl:text>
141 <xsl:choose>
142 <xsl:when test="$g_fGenProxy = 'yes'">
143 <!-- reference enums and interfaces -->
144 <xsl:apply-templates select="if | interface" mode="forward"/>
145 <xsl:apply-templates select="enum | if/enum" mode="forward"/>
146 <!-- the modules (i.e. everything else) -->
147 <xsl:apply-templates select="module | if/module"/>
148 </xsl:when>
149 <xsl:otherwise>
150 <!-- forward declarations -->
151 <xsl:apply-templates select="if | interface" mode="forward"/>
152 <!-- all enums go first -->
153 <xsl:apply-templates select="enum | if/enum"/>
154 <!-- everything else but result codes and enums -->
155 <xsl:apply-templates select="*[not(self::result or self::enum) and
156 not(self::if[result] or self::if[enum])]"/>
157 </xsl:otherwise>
158 </xsl:choose>
159 <!-- -->
160 <xsl:text>}; /* library </xsl:text>
161 <xsl:value-of select="@name"/>
162 <xsl:text> */&#x0A;&#x0A;</xsl:text>
163</xsl:template>
164
165
166<!--
167 * result codes
168-->
169<xsl:template match="result">
170 <xsl:text>cpp_quote("</xsl:text>
171 <xsl:value-of select="concat('#define ',@name,' ',@value)"/>
172 <xsl:text>")&#x0A;</xsl:text>
173</xsl:template>
174
175
176<!--
177 * forward declarations
178-->
179<xsl:template match="interface" mode="forward">
180 <xsl:text>interface </xsl:text>
181 <xsl:value-of select="@name"/>
182 <xsl:text>;&#x0A;</xsl:text>
183</xsl:template>
184
185
186<xsl:template match="enum" mode="forward">
187 <xsl:text>enum </xsl:text>
188 <xsl:value-of select="@name"/>
189 <xsl:text>;&#x0A;&#x0A;</xsl:text>
190</xsl:template>
191
192
193<!--
194 * interfaces
195-->
196<xsl:template match="interface">[
197 uuid(<xsl:value-of select="@uuid"/>),
198 object,
199 dual,
200 oleautomation
201]
202<xsl:text>interface </xsl:text>
203 <xsl:value-of select="@name"/>
204 <xsl:text> : </xsl:text>
205 <xsl:choose>
206 <xsl:when test="@extends='$unknown'">IDispatch</xsl:when>
207 <xsl:when test="@extends='$errorinfo'">IErrorInfo</xsl:when>
208 <!-- TODO/FIXME/BUGBUG: The above $errorinfo value causes the following warning (/W4):
209warning MIDL2460 : dual interface should be derived from IDispatch : IVirtualBoxErrorInfo [ Interface 'IVirtualBoxErrorInfo' ]
210 -->
211 <xsl:otherwise><xsl:value-of select="@extends"/></xsl:otherwise>
212 </xsl:choose>
213 <xsl:call-template name="xsltprocNewlineOutputHack"/>
214 <xsl:text>{&#x0A;</xsl:text>
215 <!-- attributes (properties) -->
216 <xsl:apply-templates select="attribute"/>
217 <!-- methods -->
218 <xsl:apply-templates select="method"/>
219 <!-- 'if' enclosed elements, unsorted -->
220 <xsl:apply-templates select="if"/>
221 <!-- -->
222 <xsl:text>}; /* interface </xsl:text>
223 <xsl:value-of select="@name"/>
224 <xsl:text> */&#x0A;&#x0A;</xsl:text>
225 <!-- Interface implementation forwarder macro -->
226 <xsl:text>/* Interface implementation forwarder macro */&#x0A;</xsl:text>
227 <!-- 1) individual methods -->
228 <xsl:apply-templates select="attribute" mode="forwarder"/>
229 <xsl:apply-templates select="method" mode="forwarder"/>
230 <xsl:apply-templates select="if" mode="forwarder"/>
231 <!-- 2) COM_FORWARD_Interface_TO(smth) -->
232 <xsl:text>cpp_quote("#define COM_FORWARD_</xsl:text>
233 <xsl:value-of select="@name"/>
234 <xsl:text>_TO(smth) </xsl:text>
235 <xsl:apply-templates select="attribute" mode="forwarder">
236 <xsl:with-param name="nameOnly" select="'yes'"/>
237 </xsl:apply-templates>
238 <xsl:apply-templates select="method" mode="forwarder">
239 <xsl:with-param name="nameOnly" select="'yes'"/>
240 </xsl:apply-templates>
241 <xsl:apply-templates select="if" mode="forwarder">
242 <xsl:with-param name="nameOnly" select="'yes'"/>
243 </xsl:apply-templates>
244 <xsl:text>")&#x0A;</xsl:text>
245 <!-- 3) COM_FORWARD_Interface_TO_OBJ(obj) -->
246 <xsl:text>cpp_quote("#define COM_FORWARD_</xsl:text>
247 <xsl:value-of select="@name"/>
248 <xsl:text>_TO_OBJ(obj) COM_FORWARD_</xsl:text>
249 <xsl:value-of select="@name"/>
250 <xsl:text>_TO ((obj)->)")&#x0A;</xsl:text>
251 <!-- 4) COM_FORWARD_Interface_TO_BASE(base) -->
252 <xsl:text>cpp_quote("#define COM_FORWARD_</xsl:text>
253 <xsl:value-of select="@name"/>
254 <xsl:text>_TO_BASE(base) COM_FORWARD_</xsl:text>
255 <xsl:value-of select="@name"/>
256 <xsl:text>_TO (base::)")&#x0A;</xsl:text>
257 <!-- end -->
258 <xsl:text>&#x0A;</xsl:text>
259</xsl:template>
260
261
262<!--
263 * attributes
264-->
265<xsl:template match="interface//attribute">
266 <xsl:apply-templates select="@if" mode="begin"/>
267 <!-- getter -->
268 <xsl:text> [propget] HRESULT </xsl:text>
269 <xsl:call-template name="capitalize">
270 <xsl:with-param name="str" select="@name"/>
271 </xsl:call-template>
272 <xsl:text> ([out, retval] </xsl:text>
273 <xsl:if test="@safearray='yes'">
274 <xsl:text>SAFEARRAY(</xsl:text>
275 </xsl:if>
276 <xsl:apply-templates select="@type"/>
277 <xsl:if test="@safearray='yes'">
278 <xsl:text>)</xsl:text>
279 </xsl:if>
280 <xsl:text> * a</xsl:text>
281 <xsl:call-template name="capitalize">
282 <xsl:with-param name="str" select="@name"/>
283 </xsl:call-template>
284 <xsl:text>);&#x0A;</xsl:text>
285 <!-- setter -->
286 <xsl:if test="not(@readonly='yes')">
287 <xsl:text> [propput] HRESULT </xsl:text>
288 <xsl:call-template name="capitalize">
289 <xsl:with-param name="str" select="@name"/>
290 </xsl:call-template>
291 <xsl:text> ([in] </xsl:text>
292 <xsl:if test="@safearray='yes'">
293 <xsl:text>SAFEARRAY(</xsl:text>
294 </xsl:if>
295 <xsl:apply-templates select="@type"/>
296 <xsl:if test="@safearray='yes'">
297 <xsl:text>)</xsl:text>
298 </xsl:if>
299 <xsl:text> a</xsl:text>
300 <xsl:call-template name="capitalize">
301 <xsl:with-param name="str" select="@name"/>
302 </xsl:call-template>
303 <xsl:text>);&#x0A;</xsl:text>
304 </xsl:if>
305 <xsl:apply-templates select="@if" mode="end"/>
306 <xsl:text>&#x0A;</xsl:text>
307</xsl:template>
308
309<xsl:template match="interface//attribute" mode="forwarder">
310
311 <!-- if nameOnly='yes' then only the macro name is composed
312 followed by a space -->
313 <xsl:param name="nameOnly"/>
314
315 <xsl:variable name="parent" select="ancestor::interface"/>
316
317 <xsl:apply-templates select="@if" mode="begin"/>
318
319 <xsl:choose>
320 <xsl:when test="$nameOnly='yes'">
321 <!-- getter: COM_FORWARD_Interface_GETTER_Name_TO(smth) -->
322 <xsl:text>COM_FORWARD_</xsl:text>
323 <xsl:value-of select="$parent/@name"/>
324 <xsl:text>_GETTER_</xsl:text>
325 <xsl:call-template name="capitalize">
326 <xsl:with-param name="str" select="@name"/>
327 </xsl:call-template>
328 <xsl:text>_TO (smth) </xsl:text>
329 <!-- setter: COM_FORWARD_Interface_SETTER_Name_TO(smth) -->
330 <xsl:if test="not(@readonly='yes')">
331 <xsl:text>COM_FORWARD_</xsl:text>
332 <xsl:value-of select="$parent/@name"/>
333 <xsl:text>_SETTER_</xsl:text>
334 <xsl:call-template name="capitalize">
335 <xsl:with-param name="str" select="@name"/>
336 </xsl:call-template>
337 <xsl:text>_TO (smth) </xsl:text>
338 </xsl:if>
339 </xsl:when>
340 <xsl:otherwise>
341 <!-- getter: COM_FORWARD_Interface_GETTER_Name_TO(smth) -->
342 <xsl:text>cpp_quote("#define COM_FORWARD_</xsl:text>
343 <xsl:value-of select="$parent/@name"/>
344 <xsl:text>_GETTER_</xsl:text>
345 <xsl:call-template name="capitalize">
346 <xsl:with-param name="str" select="@name"/>
347 </xsl:call-template>
348 <xsl:text>_TO(smth) HRESULT STDMETHODCALLTYPE get_</xsl:text>
349 <xsl:call-template name="capitalize">
350 <xsl:with-param name="str" select="@name"/>
351 </xsl:call-template>
352 <xsl:text> (</xsl:text>
353 <xsl:choose>
354 <xsl:when test="@safearray='yes'">
355 <xsl:text>SAFEARRAY *</xsl:text>
356 </xsl:when>
357 <xsl:otherwise>
358 <xsl:apply-templates select="@type"/>
359 </xsl:otherwise>
360 </xsl:choose>
361 <xsl:text> * a</xsl:text>
362 <xsl:call-template name="capitalize">
363 <xsl:with-param name="str" select="@name"/>
364 </xsl:call-template>
365 <xsl:text>) { return smth get_</xsl:text>
366 <xsl:call-template name="capitalize">
367 <xsl:with-param name="str" select="@name"/>
368 </xsl:call-template>
369 <xsl:text> (a</xsl:text>
370 <xsl:call-template name="capitalize">
371 <xsl:with-param name="str" select="@name"/>
372 </xsl:call-template>
373 <xsl:text>); }")&#x0A;</xsl:text>
374 <!-- getter: COM_FORWARD_Interface_GETTER_Name_TO_OBJ(obj) -->
375 <xsl:text>cpp_quote("#define COM_FORWARD_</xsl:text>
376 <xsl:value-of select="$parent/@name"/>
377 <xsl:text>_GETTER_</xsl:text>
378 <xsl:call-template name="capitalize">
379 <xsl:with-param name="str" select="@name"/>
380 </xsl:call-template>
381 <xsl:text>_TO_OBJ(obj) COM_FORWARD_</xsl:text>
382 <xsl:value-of select="$parent/@name"/>
383 <xsl:text>_GETTER_</xsl:text>
384 <xsl:call-template name="capitalize">
385 <xsl:with-param name="str" select="@name"/>
386 </xsl:call-template>
387 <xsl:text>_TO ((obj)->)")&#x0A;</xsl:text>
388 <!-- getter: COM_FORWARD_Interface_GETTER_Name_TO_BASE(base) -->
389 <xsl:text>cpp_quote("#define COM_FORWARD_</xsl:text>
390 <xsl:value-of select="$parent/@name"/>
391 <xsl:text>_GETTER_</xsl:text>
392 <xsl:call-template name="capitalize">
393 <xsl:with-param name="str" select="@name"/>
394 </xsl:call-template>
395 <xsl:text>_TO_BASE(base) COM_FORWARD_</xsl:text>
396 <xsl:value-of select="$parent/@name"/>
397 <xsl:text>_GETTER_</xsl:text>
398 <xsl:call-template name="capitalize">
399 <xsl:with-param name="str" select="@name"/>
400 </xsl:call-template>
401 <xsl:text>_TO (base::)")&#x0A;</xsl:text>
402 <!-- -->
403 <xsl:if test="not(@readonly='yes')">
404 <!-- setter: COM_FORWARD_Interface_SETTER_Name_TO(smth) -->
405 <xsl:text>cpp_quote("#define COM_FORWARD_</xsl:text>
406 <xsl:value-of select="$parent/@name"/>
407 <xsl:text>_SETTER_</xsl:text>
408 <xsl:call-template name="capitalize">
409 <xsl:with-param name="str" select="@name"/>
410 </xsl:call-template>
411 <xsl:text>_TO(smth) HRESULT STDMETHODCALLTYPE put_</xsl:text>
412 <xsl:call-template name="capitalize">
413 <xsl:with-param name="str" select="@name"/>
414 </xsl:call-template>
415 <xsl:text> (</xsl:text>
416 <xsl:choose>
417 <xsl:when test="@safearray='yes'">
418 <xsl:text>SAFEARRAY *</xsl:text>
419 </xsl:when>
420 <xsl:otherwise>
421 <xsl:apply-templates select="@type"/>
422 </xsl:otherwise>
423 </xsl:choose>
424 <xsl:text> a</xsl:text>
425 <xsl:call-template name="capitalize">
426 <xsl:with-param name="str" select="@name"/>
427 </xsl:call-template>
428 <xsl:text>) { return smth put_</xsl:text>
429 <xsl:call-template name="capitalize">
430 <xsl:with-param name="str" select="@name"/>
431 </xsl:call-template>
432 <xsl:text> (a</xsl:text>
433 <xsl:call-template name="capitalize">
434 <xsl:with-param name="str" select="@name"/>
435 </xsl:call-template>
436 <xsl:text>); }")&#x0A;</xsl:text>
437 <!-- setter: COM_FORWARD_Interface_SETTER_Name_TO_OBJ(obj) -->
438 <xsl:text>cpp_quote("#define COM_FORWARD_</xsl:text>
439 <xsl:value-of select="$parent/@name"/>
440 <xsl:text>_SETTER_</xsl:text>
441 <xsl:call-template name="capitalize">
442 <xsl:with-param name="str" select="@name"/>
443 </xsl:call-template>
444 <xsl:text>_TO_OBJ(obj) COM_FORWARD_</xsl:text>
445 <xsl:value-of select="$parent/@name"/>
446 <xsl:text>_SETTER_</xsl:text>
447 <xsl:call-template name="capitalize">
448 <xsl:with-param name="str" select="@name"/>
449 </xsl:call-template>
450 <xsl:text>_TO ((obj)->)")&#x0A;</xsl:text>
451 <!-- setter: COM_FORWARD_Interface_SETTER_Name_TO_BASE(base) -->
452 <xsl:text>cpp_quote("#define COM_FORWARD_</xsl:text>
453 <xsl:value-of select="$parent/@name"/>
454 <xsl:text>_SETTER_</xsl:text>
455 <xsl:call-template name="capitalize">
456 <xsl:with-param name="str" select="@name"/>
457 </xsl:call-template>
458 <xsl:text>_TO_BASE(base) COM_FORWARD_</xsl:text>
459 <xsl:value-of select="$parent/@name"/>
460 <xsl:text>_SETTER_</xsl:text>
461 <xsl:call-template name="capitalize">
462 <xsl:with-param name="str" select="@name"/>
463 </xsl:call-template>
464 <xsl:text>_TO (base::)")&#x0A;</xsl:text>
465 </xsl:if>
466 </xsl:otherwise>
467 </xsl:choose>
468
469 <xsl:apply-templates select="@if" mode="end"/>
470
471</xsl:template>
472
473
474<!--
475 * methods
476-->
477<xsl:template match="interface//method">
478 <xsl:apply-templates select="@if" mode="begin"/>
479 <xsl:text> HRESULT </xsl:text>
480 <xsl:call-template name="capitalize">
481 <xsl:with-param name="str" select="@name"/>
482 </xsl:call-template>
483 <xsl:choose>
484 <xsl:when test="param">
485 <xsl:text> (&#x0A;</xsl:text>
486 <xsl:for-each select="param [position() != last()]">
487 <xsl:text> </xsl:text>
488 <xsl:apply-templates select="."/>
489 <xsl:text>,&#x0A;</xsl:text>
490 </xsl:for-each>
491 <xsl:text> </xsl:text>
492 <xsl:apply-templates select="param [last()]"/>
493 <xsl:text>&#x0A; );&#x0A;</xsl:text>
494 </xsl:when>
495 <xsl:otherwise test="not(param)">
496 <xsl:text>();&#x0A;</xsl:text>
497 </xsl:otherwise>
498 </xsl:choose>
499 <xsl:apply-templates select="@if" mode="end"/>
500 <xsl:text>&#x0A;</xsl:text>
501</xsl:template>
502
503<xsl:template match="interface//method" mode="forwarder">
504
505 <!-- if nameOnly='yes' then only the macro name is composed followed by \ -->
506 <xsl:param name="nameOnly"/>
507
508 <xsl:variable name="parent" select="ancestor::interface"/>
509
510 <xsl:apply-templates select="@if" mode="begin"/>
511
512 <xsl:choose>
513 <xsl:when test="$nameOnly='yes'">
514 <!-- COM_FORWARD_Interface_Method_TO(smth) -->
515 <xsl:text>COM_FORWARD_</xsl:text>
516 <xsl:value-of select="$parent/@name"/>
517 <xsl:text>_</xsl:text>
518 <xsl:call-template name="capitalize">
519 <xsl:with-param name="str" select="@name"/>
520 </xsl:call-template>
521 <xsl:text>_TO (smth) </xsl:text>
522 </xsl:when>
523 <xsl:otherwise>
524 <xsl:text>cpp_quote("#define COM_FORWARD_</xsl:text>
525 <xsl:value-of select="$parent/@name"/>
526 <xsl:text>_</xsl:text>
527 <xsl:call-template name="capitalize">
528 <xsl:with-param name="str" select="@name"/>
529 </xsl:call-template>
530 <xsl:text>_TO(smth) HRESULT STDMETHODCALLTYPE </xsl:text>
531 <xsl:call-template name="capitalize">
532 <xsl:with-param name="str" select="@name"/>
533 </xsl:call-template>
534 <xsl:choose>
535 <xsl:when test="param">
536 <xsl:text> (</xsl:text>
537 <xsl:for-each select="param [position() != last()]">
538 <xsl:apply-templates select="." mode="forwarder"/>
539 <xsl:text>, </xsl:text>
540 </xsl:for-each>
541 <xsl:apply-templates select="param [last()]" mode="forwarder"/>
542 <xsl:text>) { return smth </xsl:text>
543 <xsl:call-template name="capitalize">
544 <xsl:with-param name="str" select="@name"/>
545 </xsl:call-template>
546 <xsl:text> (</xsl:text>
547 <xsl:for-each select="param [position() != last()]">
548 <xsl:text>a</xsl:text>
549 <xsl:call-template name="capitalize">
550 <xsl:with-param name="str" select="@name"/>
551 </xsl:call-template>
552 <xsl:text>, </xsl:text>
553 </xsl:for-each>
554 <xsl:text>a</xsl:text>
555 <xsl:call-template name="capitalize">
556 <xsl:with-param name="str" select="param [last()]/@name"/>
557 </xsl:call-template>
558 <xsl:text>); }</xsl:text>
559 </xsl:when>
560 <xsl:otherwise test="not(param)">
561 <xsl:text>() { return smth </xsl:text>
562 <xsl:call-template name="capitalize">
563 <xsl:with-param name="str" select="@name"/>
564 </xsl:call-template>
565 <xsl:text>(); }</xsl:text>
566 </xsl:otherwise>
567 </xsl:choose>
568 <xsl:text>")&#x0A;</xsl:text>
569 <!-- COM_FORWARD_Interface_Method_TO_OBJ(obj) -->
570 <xsl:text>cpp_quote("#define COM_FORWARD_</xsl:text>
571 <xsl:value-of select="$parent/@name"/>
572 <xsl:text>_</xsl:text>
573 <xsl:call-template name="capitalize">
574 <xsl:with-param name="str" select="@name"/>
575 </xsl:call-template>
576 <xsl:text>_TO_OBJ(obj) COM_FORWARD_</xsl:text>
577 <xsl:value-of select="$parent/@name"/>
578 <xsl:text>_</xsl:text>
579 <xsl:call-template name="capitalize">
580 <xsl:with-param name="str" select="@name"/>
581 </xsl:call-template>
582 <xsl:text>_TO ((obj)->)")&#x0A;</xsl:text>
583 <!-- COM_FORWARD_Interface_Method_TO_BASE(base) -->
584 <xsl:text>cpp_quote("#define COM_FORWARD_</xsl:text>
585 <xsl:value-of select="$parent/@name"/>
586 <xsl:text>_</xsl:text>
587 <xsl:call-template name="capitalize">
588 <xsl:with-param name="str" select="@name"/>
589 </xsl:call-template>
590 <xsl:text>_TO_BASE(base) COM_FORWARD_</xsl:text>
591 <xsl:value-of select="$parent/@name"/>
592 <xsl:text>_</xsl:text>
593 <xsl:call-template name="capitalize">
594 <xsl:with-param name="str" select="@name"/>
595 </xsl:call-template>
596 <xsl:text>_TO (base::)")&#x0A;</xsl:text>
597 </xsl:otherwise>
598 </xsl:choose>
599
600 <xsl:apply-templates select="@if" mode="end"/>
601
602</xsl:template>
603
604
605<!--
606 * modules
607-->
608<xsl:template match="module">
609 <xsl:apply-templates select="class"/>
610</xsl:template>
611
612
613<!--
614 * co-classes
615-->
616<xsl:template match="module/class">[
617 uuid(<xsl:value-of select="@uuid"/>)
618]
619<xsl:text>coclass </xsl:text>
620 <xsl:value-of select="@name"/>
621 <xsl:text>&#x0A;{&#x0A;</xsl:text>
622 <xsl:for-each select="interface">
623 <xsl:text> </xsl:text>
624 <xsl:if test="@default='yes'">
625 <xsl:text>[default] </xsl:text>
626 </xsl:if>
627 <xsl:text>interface </xsl:text>
628 <xsl:value-of select="@name"/>
629 <xsl:text>;&#x0A;</xsl:text>
630 </xsl:for-each>
631 <xsl:for-each select="eventsink">
632 <xsl:text> </xsl:text>
633 <xsl:choose>
634 <xsl:when test="@default='yes'"><xsl:text>[default,source]</xsl:text></xsl:when>
635 <xsl:otherwise><xsl:text>[source]</xsl:text></xsl:otherwise>
636 </xsl:choose>
637 <xsl:text> interface </xsl:text>
638 <xsl:value-of select="@name"/>
639 <xsl:text>;&#x0A;</xsl:text>
640 </xsl:for-each>
641 <xsl:text>&#x0A;}; /* coclass </xsl:text>
642 <xsl:value-of select="@name"/>
643 <xsl:text> */&#x0A;&#x0A;</xsl:text>
644</xsl:template>
645
646
647<!--
648 * enums
649-->
650<xsl:template match="enum">[
651 uuid(<xsl:value-of select="@uuid"/>),
652 v1_enum
653]
654<xsl:text>typedef enum &#x0A;{&#x0A;</xsl:text>
655 <xsl:for-each select="const">
656 <xsl:text> </xsl:text>
657 <xsl:value-of select="concat(../@name,'_',@name)"/> = <xsl:value-of select="@value"/>
658 <xsl:choose>
659 <xsl:when test="position()!=last()"><xsl:text>,&#x0A;</xsl:text></xsl:when>
660 <xsl:otherwise><xsl:text>&#x0A;</xsl:text></xsl:otherwise>
661 </xsl:choose>
662 </xsl:for-each>
663 <xsl:text>} </xsl:text>
664 <xsl:value-of select="@name"/>
665 <xsl:text>;&#x0A;&#x0A;</xsl:text>
666 <!-- -->
667 <xsl:value-of select="concat('/* cross-platform type name for ', @name, ' */&#x0A;')"/>
668 <xsl:value-of select="concat('cpp_quote(&quot;#define ', @name, '_T', ' ',
669 @name, '&quot;)&#x0A;&#x0A;')"/>
670 <xsl:text>&#x0A;&#x0A;</xsl:text>
671</xsl:template>
672
673
674<!--
675 * method parameters
676-->
677<xsl:template match="method/param">
678 <xsl:text>[</xsl:text>
679 <xsl:choose>
680 <xsl:when test="@dir='in'">in</xsl:when>
681 <xsl:when test="@dir='out'">out</xsl:when>
682 <xsl:when test="@dir='return'">out, retval</xsl:when>
683 <xsl:otherwise>in</xsl:otherwise>
684 </xsl:choose>
685 <xsl:text>] </xsl:text>
686 <xsl:if test="@safearray='yes'">
687 <xsl:text>SAFEARRAY(</xsl:text>
688 </xsl:if>
689 <xsl:apply-templates select="@type"/>
690 <xsl:if test="@safearray='yes'">
691 <xsl:text>)</xsl:text>
692 </xsl:if>
693 <xsl:if test="@dir='out' or @dir='return'">
694 <xsl:text> *</xsl:text>
695 </xsl:if>
696 <xsl:text> a</xsl:text>
697 <xsl:call-template name="capitalize">
698 <xsl:with-param name="str" select="@name"/>
699 </xsl:call-template>
700</xsl:template>
701
702<xsl:template match="method/param" mode="forwarder">
703 <xsl:choose>
704 <xsl:when test="@safearray='yes'">
705 <xsl:text>SAFEARRAY *</xsl:text>
706 </xsl:when>
707 <xsl:otherwise>
708 <xsl:apply-templates select="@type"/>
709 </xsl:otherwise>
710 </xsl:choose>
711 <xsl:if test="@dir='out' or @dir='return' or @safearray='yes'">
712 <xsl:text> *</xsl:text>
713 </xsl:if>
714 <xsl:text> a</xsl:text>
715 <xsl:call-template name="capitalize">
716 <xsl:with-param name="str" select="@name"/>
717 </xsl:call-template>
718</xsl:template>
719
720
721<!--
722 * attribute/parameter type conversion
723-->
724<xsl:template match="attribute/@type | param/@type">
725 <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
726
727 <xsl:choose>
728 <!-- modifiers -->
729 <xsl:when test="name(current())='type' and ../@mod">
730 <xsl:choose>
731 <xsl:when test="../@mod='ptr'">
732 <xsl:choose>
733 <!-- standard types -->
734 <!--xsl:when test=".='result'">??</xsl:when-->
735 <xsl:when test=".='boolean'">BOOL *</xsl:when>
736 <xsl:when test=".='octet'">BYTE *</xsl:when>
737 <xsl:when test=".='short'">SHORT *</xsl:when>
738 <xsl:when test=".='unsigned short'">USHORT *</xsl:when>
739 <xsl:when test=".='long'">LONG *</xsl:when>
740 <xsl:when test=".='long long'">LONG64 *</xsl:when>
741 <xsl:when test=".='unsigned long'">ULONG *</xsl:when>
742 <xsl:when test=".='unsigned long long'">
743 <xsl:message terminate="yes">
744 <xsl:value-of select="'&quot;unsigned long long&quot; no longer supported'" />
745 </xsl:message>
746 </xsl:when>
747 <xsl:otherwise>
748 <xsl:message terminate="yes">
749 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
750 <xsl:text>attribute 'mod=</xsl:text>
751 <xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
752 <xsl:text>' cannot be used with type </xsl:text>
753 <xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
754 </xsl:message>
755 </xsl:otherwise>
756 </xsl:choose>
757 </xsl:when>
758 <xsl:when test="../@mod='string'">
759 <xsl:choose>
760 <!-- standard types -->
761 <!--xsl:when test=".='result'">??</xsl:when-->
762 <xsl:when test=".='uuid'">BSTR</xsl:when>
763 <xsl:otherwise>
764 <xsl:message terminate="yes">
765 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
766 <xsl:text>attribute 'mod=</xsl:text>
767 <xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
768 <xsl:text>' cannot be used with type </xsl:text>
769 <xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
770 </xsl:message>
771 </xsl:otherwise>
772 </xsl:choose>
773 </xsl:when>
774 <xsl:otherwise>
775 <xsl:message terminate="yes">
776 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
777 <xsl:value-of select="concat('value &quot;',../@mod,'&quot; ')"/>
778 <xsl:text>of attribute 'mod' is invalid!</xsl:text>
779 </xsl:message>
780 </xsl:otherwise>
781 </xsl:choose>
782 </xsl:when>
783 <!-- no modifiers -->
784 <xsl:otherwise>
785 <xsl:choose>
786 <!-- standard types -->
787 <xsl:when test=".='result'">HRESULT</xsl:when>
788 <xsl:when test=".='boolean'">BOOL</xsl:when>
789 <xsl:when test=".='octet'">BYTE</xsl:when>
790 <xsl:when test=".='short'">SHORT</xsl:when>
791 <xsl:when test=".='unsigned short'">USHORT</xsl:when>
792 <xsl:when test=".='long'">LONG</xsl:when>
793 <xsl:when test=".='long long'">LONG64</xsl:when>
794 <xsl:when test=".='unsigned long'">ULONG</xsl:when>
795 <xsl:when test=".='char'">CHAR</xsl:when>
796 <xsl:when test=".='string'">CHAR *</xsl:when>
797 <xsl:when test=".='wchar'">OLECHAR</xsl:when>
798 <xsl:when test=".='wstring'">BSTR</xsl:when>
799 <!-- UUID type -->
800 <xsl:when test=".='uuid'">GUID</xsl:when>
801 <!-- system interface types -->
802 <xsl:when test=".='$unknown'">IUnknown *</xsl:when>
803 <xsl:when test=".='unsigned long long'">
804 <xsl:message terminate="yes">
805 <xsl:value-of select="'&quot;unsigned long long&quot; no longer supported'" />
806 </xsl:message>
807 </xsl:when>
808 <xsl:otherwise>
809 <xsl:choose>
810 <!-- enum types -->
811 <xsl:when test="
812 (ancestor::library/enum[@name=current()]) or
813 (ancestor::library/if[@target=$self_target]/enum[@name=current()])
814 ">
815 <xsl:value-of select="."/>
816 </xsl:when>
817 <!-- custom interface types -->
818 <xsl:when test="
819 ((ancestor::library/interface[@name=current()]) or
820 (ancestor::library/if[@target=$self_target]/interface[@name=current()])
821 )
822 ">
823 <xsl:value-of select="."/><xsl:text> *</xsl:text>
824 </xsl:when>
825 <!-- other types -->
826 <xsl:otherwise>
827 <xsl:message terminate="yes">
828 <xsl:text>Unknown parameter type: </xsl:text>
829 <xsl:value-of select="."/>
830 </xsl:message>
831 </xsl:otherwise>
832 </xsl:choose>
833 </xsl:otherwise>
834 </xsl:choose>
835 </xsl:otherwise>
836 </xsl:choose>
837</xsl:template>
838
839</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette