VirtualBox

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

Last change on this file since 86506 was 82969, checked in by vboxsync, 4 years ago

Copyright year updates - manual ones.

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

© 2023 Oracle
ContactPrivacy policyTerms of Use