VirtualBox

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

Last change on this file since 96308 was 96308, checked in by vboxsync, 3 years ago

src/VBox/Main: XML/XSL comment fixes

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

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