VirtualBox

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

Last change on this file since 43394 was 43103, checked in by vboxsync, 12 years ago

whitespace/comment touchup

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