VirtualBox

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

Last change on this file since 25414 was 23223, checked in by vboxsync, 15 years ago

API: big medium handling change and lots of assorted other cleanups and fixes

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

© 2023 Oracle
ContactPrivacy policyTerms of Use