VirtualBox

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

最後變更 在這個檔案從63352是 63352,由 vboxsync 提交於 9 年 前

Main: shut up two annoying and (perceived) harmless MIDL warnings, enabled every other warning. Now it only complains about IErrorInfo (standard interface?) not being related to IDispatch.

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

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