VirtualBox

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

Last change on this file since 100772 was 98103, checked in by vboxsync, 23 months ago

Copyright year updates by scm.

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