VirtualBox

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

Last change on this file since 69740 was 69740, checked in by vboxsync, 7 years ago

Hack midl.xsl extends $unknown translation for notdual to fix SDK build.

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