VirtualBox

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

Last change on this file since 102673 was 101372, checked in by vboxsync, 15 months ago

Main/midl.xsl: Deal with quotes in cpp/line attributes. bugref:10384

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