VirtualBox

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

Last change on this file since 28851 was 28800, checked in by vboxsync, 14 years ago

Automated rebranding to Oracle copyright/license strings via filemuncher

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 27.7 KB
Line 
1<?xml version="1.0"?>
2<!-- $Id: midl.xsl 28800 2010-04-27 08:22:32Z 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-2009 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 <!-- VB supports only [in, out], [out] and [out, retval] arrays -->
293 <xsl:text>, out</xsl:text>
294 </xsl:if>
295 <xsl:text>] </xsl:text>
296 <xsl:if test="@safearray='yes'">
297 <xsl:text>SAFEARRAY(</xsl:text>
298 </xsl:if>
299 <xsl:apply-templates select="@type"/>
300 <xsl:if test="@safearray='yes'">
301 <xsl:text>) *</xsl:text>
302 </xsl:if>
303 <xsl:text> a</xsl:text>
304 <xsl:call-template name="capitalize">
305 <xsl:with-param name="str" select="@name"/>
306 </xsl:call-template>
307 <xsl:text>);&#x0A;</xsl:text>
308 </xsl:if>
309 <xsl:apply-templates select="@if" mode="end"/>
310 <xsl:text>&#x0A;</xsl:text>
311</xsl:template>
312
313<xsl:template match="interface//attribute" mode="forwarder">
314
315 <!-- if nameOnly='yes' then only the macro name is composed
316 followed by a space -->
317 <xsl:param name="nameOnly"/>
318
319 <xsl:variable name="parent" select="ancestor::interface"/>
320
321 <xsl:apply-templates select="@if" mode="begin"/>
322
323 <xsl:choose>
324 <xsl:when test="$nameOnly='yes'">
325 <!-- getter: COM_FORWARD_Interface_GETTER_Name_TO(smth) -->
326 <xsl:text>COM_FORWARD_</xsl:text>
327 <xsl:value-of select="$parent/@name"/>
328 <xsl:text>_GETTER_</xsl:text>
329 <xsl:call-template name="capitalize">
330 <xsl:with-param name="str" select="@name"/>
331 </xsl:call-template>
332 <xsl:text>_TO (smth) </xsl:text>
333 <!-- setter: COM_FORWARD_Interface_SETTER_Name_TO(smth) -->
334 <xsl:if test="not(@readonly='yes')">
335 <xsl:text>COM_FORWARD_</xsl:text>
336 <xsl:value-of select="$parent/@name"/>
337 <xsl:text>_SETTER_</xsl:text>
338 <xsl:call-template name="capitalize">
339 <xsl:with-param name="str" select="@name"/>
340 </xsl:call-template>
341 <xsl:text>_TO (smth) </xsl:text>
342 </xsl:if>
343 </xsl:when>
344 <xsl:otherwise>
345 <!-- getter: COM_FORWARD_Interface_GETTER_Name_TO(smth) -->
346 <xsl:text>cpp_quote("#define COM_FORWARD_</xsl:text>
347 <xsl:value-of select="$parent/@name"/>
348 <xsl:text>_GETTER_</xsl:text>
349 <xsl:call-template name="capitalize">
350 <xsl:with-param name="str" select="@name"/>
351 </xsl:call-template>
352 <xsl:text>_TO(smth) HRESULT STDMETHODCALLTYPE get_</xsl:text>
353 <xsl:call-template name="capitalize">
354 <xsl:with-param name="str" select="@name"/>
355 </xsl:call-template>
356 <xsl:text> (</xsl:text>
357 <xsl:choose>
358 <xsl:when test="@safearray='yes'">
359 <xsl:text>SAFEARRAY *</xsl:text>
360 </xsl:when>
361 <xsl:otherwise>
362 <xsl:apply-templates select="@type"/>
363 </xsl:otherwise>
364 </xsl:choose>
365 <xsl:text> * a</xsl:text>
366 <xsl:call-template name="capitalize">
367 <xsl:with-param name="str" select="@name"/>
368 </xsl:call-template>
369 <xsl:text>) { return smth get_</xsl:text>
370 <xsl:call-template name="capitalize">
371 <xsl:with-param name="str" select="@name"/>
372 </xsl:call-template>
373 <xsl:text> (a</xsl:text>
374 <xsl:call-template name="capitalize">
375 <xsl:with-param name="str" select="@name"/>
376 </xsl:call-template>
377 <xsl:text>); }")&#x0A;</xsl:text>
378 <!-- getter: COM_FORWARD_Interface_GETTER_Name_TO_OBJ(obj) -->
379 <xsl:text>cpp_quote("#define COM_FORWARD_</xsl:text>
380 <xsl:value-of select="$parent/@name"/>
381 <xsl:text>_GETTER_</xsl:text>
382 <xsl:call-template name="capitalize">
383 <xsl:with-param name="str" select="@name"/>
384 </xsl:call-template>
385 <xsl:text>_TO_OBJ(obj) COM_FORWARD_</xsl:text>
386 <xsl:value-of select="$parent/@name"/>
387 <xsl:text>_GETTER_</xsl:text>
388 <xsl:call-template name="capitalize">
389 <xsl:with-param name="str" select="@name"/>
390 </xsl:call-template>
391 <xsl:text>_TO ((obj)->)")&#x0A;</xsl:text>
392 <!-- getter: COM_FORWARD_Interface_GETTER_Name_TO_BASE(base) -->
393 <xsl:text>cpp_quote("#define COM_FORWARD_</xsl:text>
394 <xsl:value-of select="$parent/@name"/>
395 <xsl:text>_GETTER_</xsl:text>
396 <xsl:call-template name="capitalize">
397 <xsl:with-param name="str" select="@name"/>
398 </xsl:call-template>
399 <xsl:text>_TO_BASE(base) COM_FORWARD_</xsl:text>
400 <xsl:value-of select="$parent/@name"/>
401 <xsl:text>_GETTER_</xsl:text>
402 <xsl:call-template name="capitalize">
403 <xsl:with-param name="str" select="@name"/>
404 </xsl:call-template>
405 <xsl:text>_TO (base::)")&#x0A;</xsl:text>
406 <!-- -->
407 <xsl:if test="not(@readonly='yes')">
408 <!-- setter: COM_FORWARD_Interface_SETTER_Name_TO(smth) -->
409 <xsl:text>cpp_quote("#define COM_FORWARD_</xsl:text>
410 <xsl:value-of select="$parent/@name"/>
411 <xsl:text>_SETTER_</xsl:text>
412 <xsl:call-template name="capitalize">
413 <xsl:with-param name="str" select="@name"/>
414 </xsl:call-template>
415 <xsl:text>_TO(smth) HRESULT STDMETHODCALLTYPE put_</xsl:text>
416 <xsl:call-template name="capitalize">
417 <xsl:with-param name="str" select="@name"/>
418 </xsl:call-template>
419 <xsl:text> (</xsl:text>
420 <xsl:choose>
421 <xsl:when test="@safearray='yes'">
422 <xsl:text>SAFEARRAY *</xsl:text>
423 </xsl:when>
424 <xsl:otherwise>
425 <xsl:apply-templates select="@type"/>
426 </xsl:otherwise>
427 </xsl:choose>
428 <xsl:text> a</xsl:text>
429 <xsl:call-template name="capitalize">
430 <xsl:with-param name="str" select="@name"/>
431 </xsl:call-template>
432 <xsl:text>) { return smth put_</xsl:text>
433 <xsl:call-template name="capitalize">
434 <xsl:with-param name="str" select="@name"/>
435 </xsl:call-template>
436 <xsl:text> (a</xsl:text>
437 <xsl:call-template name="capitalize">
438 <xsl:with-param name="str" select="@name"/>
439 </xsl:call-template>
440 <xsl:text>); }")&#x0A;</xsl:text>
441 <!-- setter: COM_FORWARD_Interface_SETTER_Name_TO_OBJ(obj) -->
442 <xsl:text>cpp_quote("#define COM_FORWARD_</xsl:text>
443 <xsl:value-of select="$parent/@name"/>
444 <xsl:text>_SETTER_</xsl:text>
445 <xsl:call-template name="capitalize">
446 <xsl:with-param name="str" select="@name"/>
447 </xsl:call-template>
448 <xsl:text>_TO_OBJ(obj) COM_FORWARD_</xsl:text>
449 <xsl:value-of select="$parent/@name"/>
450 <xsl:text>_SETTER_</xsl:text>
451 <xsl:call-template name="capitalize">
452 <xsl:with-param name="str" select="@name"/>
453 </xsl:call-template>
454 <xsl:text>_TO ((obj)->)")&#x0A;</xsl:text>
455 <!-- setter: COM_FORWARD_Interface_SETTER_Name_TO_BASE(base) -->
456 <xsl:text>cpp_quote("#define COM_FORWARD_</xsl:text>
457 <xsl:value-of select="$parent/@name"/>
458 <xsl:text>_SETTER_</xsl:text>
459 <xsl:call-template name="capitalize">
460 <xsl:with-param name="str" select="@name"/>
461 </xsl:call-template>
462 <xsl:text>_TO_BASE(base) COM_FORWARD_</xsl:text>
463 <xsl:value-of select="$parent/@name"/>
464 <xsl:text>_SETTER_</xsl:text>
465 <xsl:call-template name="capitalize">
466 <xsl:with-param name="str" select="@name"/>
467 </xsl:call-template>
468 <xsl:text>_TO (base::)")&#x0A;</xsl:text>
469 </xsl:if>
470 </xsl:otherwise>
471 </xsl:choose>
472
473 <xsl:apply-templates select="@if" mode="end"/>
474
475</xsl:template>
476
477
478<!--
479 * methods
480-->
481<xsl:template match="interface//method">
482 <xsl:apply-templates select="@if" mode="begin"/>
483 <xsl:text> HRESULT </xsl:text>
484 <xsl:call-template name="capitalize">
485 <xsl:with-param name="str" select="@name"/>
486 </xsl:call-template>
487 <xsl:choose>
488 <xsl:when test="param">
489 <xsl:text> (&#x0A;</xsl:text>
490 <xsl:for-each select="param [position() != last()]">
491 <xsl:text> </xsl:text>
492 <xsl:apply-templates select="."/>
493 <xsl:text>,&#x0A;</xsl:text>
494 </xsl:for-each>
495 <xsl:text> </xsl:text>
496 <xsl:apply-templates select="param [last()]"/>
497 <xsl:text>&#x0A; );&#x0A;</xsl:text>
498 </xsl:when>
499 <xsl:otherwise test="not(param)">
500 <xsl:text>();&#x0A;</xsl:text>
501 </xsl:otherwise>
502 </xsl:choose>
503 <xsl:apply-templates select="@if" mode="end"/>
504 <xsl:text>&#x0A;</xsl:text>
505</xsl:template>
506
507<xsl:template match="interface//method" mode="forwarder">
508
509 <!-- if nameOnly='yes' then only the macro name is composed followed by \ -->
510 <xsl:param name="nameOnly"/>
511
512 <xsl:variable name="parent" select="ancestor::interface"/>
513
514 <xsl:apply-templates select="@if" mode="begin"/>
515
516 <xsl:choose>
517 <xsl:when test="$nameOnly='yes'">
518 <!-- COM_FORWARD_Interface_Method_TO(smth) -->
519 <xsl:text>COM_FORWARD_</xsl:text>
520 <xsl:value-of select="$parent/@name"/>
521 <xsl:text>_</xsl:text>
522 <xsl:call-template name="capitalize">
523 <xsl:with-param name="str" select="@name"/>
524 </xsl:call-template>
525 <xsl:text>_TO (smth) </xsl:text>
526 </xsl:when>
527 <xsl:otherwise>
528 <xsl:text>cpp_quote("#define COM_FORWARD_</xsl:text>
529 <xsl:value-of select="$parent/@name"/>
530 <xsl:text>_</xsl:text>
531 <xsl:call-template name="capitalize">
532 <xsl:with-param name="str" select="@name"/>
533 </xsl:call-template>
534 <xsl:text>_TO(smth) HRESULT STDMETHODCALLTYPE </xsl:text>
535 <xsl:call-template name="capitalize">
536 <xsl:with-param name="str" select="@name"/>
537 </xsl:call-template>
538 <xsl:choose>
539 <xsl:when test="param">
540 <xsl:text> (</xsl:text>
541 <xsl:for-each select="param [position() != last()]">
542 <xsl:apply-templates select="." mode="forwarder"/>
543 <xsl:text>, </xsl:text>
544 </xsl:for-each>
545 <xsl:apply-templates select="param [last()]" mode="forwarder"/>
546 <xsl:text>) { return smth </xsl:text>
547 <xsl:call-template name="capitalize">
548 <xsl:with-param name="str" select="@name"/>
549 </xsl:call-template>
550 <xsl:text> (</xsl:text>
551 <xsl:for-each select="param [position() != last()]">
552 <xsl:text>a</xsl:text>
553 <xsl:call-template name="capitalize">
554 <xsl:with-param name="str" select="@name"/>
555 </xsl:call-template>
556 <xsl:text>, </xsl:text>
557 </xsl:for-each>
558 <xsl:text>a</xsl:text>
559 <xsl:call-template name="capitalize">
560 <xsl:with-param name="str" select="param [last()]/@name"/>
561 </xsl:call-template>
562 <xsl:text>); }</xsl:text>
563 </xsl:when>
564 <xsl:otherwise test="not(param)">
565 <xsl:text>() { return smth </xsl:text>
566 <xsl:call-template name="capitalize">
567 <xsl:with-param name="str" select="@name"/>
568 </xsl:call-template>
569 <xsl:text>(); }</xsl:text>
570 </xsl:otherwise>
571 </xsl:choose>
572 <xsl:text>")&#x0A;</xsl:text>
573 <!-- COM_FORWARD_Interface_Method_TO_OBJ(obj) -->
574 <xsl:text>cpp_quote("#define COM_FORWARD_</xsl:text>
575 <xsl:value-of select="$parent/@name"/>
576 <xsl:text>_</xsl:text>
577 <xsl:call-template name="capitalize">
578 <xsl:with-param name="str" select="@name"/>
579 </xsl:call-template>
580 <xsl:text>_TO_OBJ(obj) COM_FORWARD_</xsl:text>
581 <xsl:value-of select="$parent/@name"/>
582 <xsl:text>_</xsl:text>
583 <xsl:call-template name="capitalize">
584 <xsl:with-param name="str" select="@name"/>
585 </xsl:call-template>
586 <xsl:text>_TO ((obj)->)")&#x0A;</xsl:text>
587 <!-- COM_FORWARD_Interface_Method_TO_BASE(base) -->
588 <xsl:text>cpp_quote("#define COM_FORWARD_</xsl:text>
589 <xsl:value-of select="$parent/@name"/>
590 <xsl:text>_</xsl:text>
591 <xsl:call-template name="capitalize">
592 <xsl:with-param name="str" select="@name"/>
593 </xsl:call-template>
594 <xsl:text>_TO_BASE(base) COM_FORWARD_</xsl:text>
595 <xsl:value-of select="$parent/@name"/>
596 <xsl:text>_</xsl:text>
597 <xsl:call-template name="capitalize">
598 <xsl:with-param name="str" select="@name"/>
599 </xsl:call-template>
600 <xsl:text>_TO (base::)")&#x0A;</xsl:text>
601 </xsl:otherwise>
602 </xsl:choose>
603
604 <xsl:apply-templates select="@if" mode="end"/>
605
606</xsl:template>
607
608
609<!--
610 * modules
611-->
612<xsl:template match="module">
613 <xsl:apply-templates select="class"/>
614</xsl:template>
615
616
617<!--
618 * co-classes
619-->
620<xsl:template match="module/class">[
621 uuid(<xsl:value-of select="@uuid"/>)
622]
623<xsl:text>coclass </xsl:text>
624 <xsl:value-of select="@name"/>
625 <xsl:text>&#x0A;{&#x0A;</xsl:text>
626 <xsl:for-each select="interface">
627 <xsl:text> </xsl:text>
628 <xsl:if test="@default='yes'">
629 <xsl:text>[default] </xsl:text>
630 </xsl:if>
631 <xsl:text>interface </xsl:text>
632 <xsl:value-of select="@name"/>
633 <xsl:text>;&#x0A;</xsl:text>
634 </xsl:for-each>
635 <xsl:text>&#x0A;}; /* coclass </xsl:text>
636 <xsl:value-of select="@name"/>
637 <xsl:text> */&#x0A;&#x0A;</xsl:text>
638</xsl:template>
639
640
641<!--
642 * enums
643-->
644<xsl:template match="enum">[
645 uuid(<xsl:value-of select="@uuid"/>),
646 v1_enum
647]
648<xsl:text>typedef enum &#x0A;{&#x0A;</xsl:text>
649 <xsl:for-each select="const">
650 <xsl:text> </xsl:text>
651 <xsl:value-of select="concat(../@name,'_',@name)"/> = <xsl:value-of select="@value"/>
652 <xsl:choose>
653 <xsl:when test="position()!=last()"><xsl:text>,&#x0A;</xsl:text></xsl:when>
654 <xsl:otherwise><xsl:text>&#x0A;</xsl:text></xsl:otherwise>
655 </xsl:choose>
656 </xsl:for-each>
657 <xsl:text>} </xsl:text>
658 <xsl:value-of select="@name"/>
659 <xsl:text>;&#x0A;&#x0A;</xsl:text>
660 <!-- -->
661 <xsl:value-of select="concat('/* cross-platform type name for ', @name, ' */&#x0A;')"/>
662 <xsl:value-of select="concat('cpp_quote(&quot;#define ', @name, '_T', ' ',
663 @name, '&quot;)&#x0A;&#x0A;')"/>
664 <xsl:text>&#x0A;&#x0A;</xsl:text>
665</xsl:template>
666
667
668<!--
669 * method parameters
670-->
671<xsl:template match="method/param">
672 <xsl:text>[</xsl:text>
673 <xsl:choose>
674 <xsl:when test="@dir='in'">in</xsl:when>
675 <xsl:when test="@dir='out'">out</xsl:when>
676 <xsl:when test="@dir='return'">out, retval</xsl:when>
677 <xsl:otherwise>in</xsl:otherwise>
678 </xsl:choose>
679 <xsl:if test="@safearray='yes'">
680 <!-- VB supports only [in, out], [out] and [out, retval] arrays -->
681 <xsl:if test="@dir='in'">, out</xsl:if>
682 </xsl:if>
683 <xsl:text>] </xsl:text>
684 <xsl:if test="@safearray='yes'">
685 <xsl:text>SAFEARRAY(</xsl:text>
686 </xsl:if>
687 <xsl:apply-templates select="@type"/>
688 <xsl:if test="@safearray='yes'">
689 <xsl:text>)</xsl:text>
690 </xsl:if>
691 <xsl:if test="@dir='out' or @dir='return' or @safearray='yes'">
692 <xsl:text> *</xsl:text>
693 </xsl:if>
694 <xsl:text> a</xsl:text>
695 <xsl:call-template name="capitalize">
696 <xsl:with-param name="str" select="@name"/>
697 </xsl:call-template>
698</xsl:template>
699
700<xsl:template match="method/param" mode="forwarder">
701 <xsl:choose>
702 <xsl:when test="@safearray='yes'">
703 <xsl:text>SAFEARRAY *</xsl:text>
704 </xsl:when>
705 <xsl:otherwise>
706 <xsl:apply-templates select="@type"/>
707 </xsl:otherwise>
708 </xsl:choose>
709 <xsl:if test="@dir='out' or @dir='return' or @safearray='yes'">
710 <xsl:text> *</xsl:text>
711 </xsl:if>
712 <xsl:text> a</xsl:text>
713 <xsl:call-template name="capitalize">
714 <xsl:with-param name="str" select="@name"/>
715 </xsl:call-template>
716</xsl:template>
717
718
719<!--
720 * attribute/parameter type conversion
721-->
722<xsl:template match="attribute/@type | param/@type">
723 <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
724
725 <xsl:choose>
726 <!-- modifiers -->
727 <xsl:when test="name(current())='type' and ../@mod">
728 <xsl:choose>
729 <xsl:when test="../@mod='ptr'">
730 <xsl:choose>
731 <!-- standard types -->
732 <!--xsl:when test=".='result'">??</xsl:when-->
733 <xsl:when test=".='boolean'">BOOL *</xsl:when>
734 <xsl:when test=".='octet'">BYTE *</xsl:when>
735 <xsl:when test=".='short'">SHORT *</xsl:when>
736 <xsl:when test=".='unsigned short'">USHORT *</xsl:when>
737 <xsl:when test=".='long'">LONG *</xsl:when>
738 <xsl:when test=".='long long'">LONG64 *</xsl:when>
739 <xsl:when test=".='unsigned long'">ULONG *</xsl:when>
740 <xsl:when test=".='unsigned long long'">ULONG64 *</xsl:when>
741 <xsl:otherwise>
742 <xsl:message terminate="yes">
743 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
744 <xsl:text>attribute 'mod=</xsl:text>
745 <xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
746 <xsl:text>' cannot be used with type </xsl:text>
747 <xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
748 </xsl:message>
749 </xsl:otherwise>
750 </xsl:choose>
751 </xsl:when>
752 <xsl:when test="../@mod='string'">
753 <xsl:choose>
754 <!-- standard types -->
755 <!--xsl:when test=".='result'">??</xsl:when-->
756 <xsl:when test=".='uuid'">BSTR</xsl:when>
757 <xsl:otherwise>
758 <xsl:message terminate="yes">
759 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
760 <xsl:text>attribute 'mod=</xsl:text>
761 <xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
762 <xsl:text>' cannot be used with type </xsl:text>
763 <xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
764 </xsl:message>
765 </xsl:otherwise>
766 </xsl:choose>
767 </xsl:when>
768 <xsl:otherwise>
769 <xsl:message terminate="yes">
770 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
771 <xsl:value-of select="concat('value &quot;',../@mod,'&quot; ')"/>
772 <xsl:text>of attribute 'mod' is invalid!</xsl:text>
773 </xsl:message>
774 </xsl:otherwise>
775 </xsl:choose>
776 </xsl:when>
777 <!-- no modifiers -->
778 <xsl:otherwise>
779 <xsl:choose>
780 <!-- standard types -->
781 <xsl:when test=".='result'">HRESULT</xsl:when>
782 <xsl:when test=".='boolean'">BOOL</xsl:when>
783 <xsl:when test=".='octet'">BYTE</xsl:when>
784 <xsl:when test=".='short'">SHORT</xsl:when>
785 <xsl:when test=".='unsigned short'">USHORT</xsl:when>
786 <xsl:when test=".='long'">LONG</xsl:when>
787 <xsl:when test=".='long long'">LONG64</xsl:when>
788 <xsl:when test=".='unsigned long'">ULONG</xsl:when>
789 <xsl:when test=".='unsigned long long'">ULONG64</xsl:when>
790 <xsl:when test=".='char'">CHAR</xsl:when>
791 <xsl:when test=".='string'">CHAR *</xsl:when>
792 <xsl:when test=".='wchar'">OLECHAR</xsl:when>
793 <xsl:when test=".='wstring'">BSTR</xsl:when>
794 <!-- UUID type -->
795 <xsl:when test=".='uuid'">GUID</xsl:when>
796 <!-- system interface types -->
797 <xsl:when test=".='$unknown'">IUnknown *</xsl:when>
798 <xsl:otherwise>
799 <xsl:choose>
800 <!-- enum types -->
801 <xsl:when test="
802 (ancestor::library/enum[@name=current()]) or
803 (ancestor::library/if[@target=$self_target]/enum[@name=current()])
804 ">
805 <xsl:value-of select="."/>
806 </xsl:when>
807 <!-- custom interface types -->
808 <xsl:when test="
809 ((ancestor::library/interface[@name=current()]) or
810 (ancestor::library/if[@target=$self_target]/interface[@name=current()])
811 )
812 ">
813 <xsl:value-of select="."/><xsl:text> *</xsl:text>
814 </xsl:when>
815 <!-- other types -->
816 <xsl:otherwise>
817 <xsl:message terminate="yes">
818 <xsl:text>Unknown parameter type: </xsl:text>
819 <xsl:value-of select="."/>
820 </xsl:message>
821 </xsl:otherwise>
822 </xsl:choose>
823 </xsl:otherwise>
824 </xsl:choose>
825 </xsl:otherwise>
826 </xsl:choose>
827</xsl:template>
828
829</xsl:stylesheet>
830
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