VirtualBox

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

Last change on this file since 49906 was 49906, checked in by vboxsync, 11 years ago

Main: Some simple COM/XPCOM performance measurements. The idea was getting a baseline before experimenting with proxy/stub stuff in midl. There is some VirtualBox.idl preps related to that. Unforuntately, the proxy/stub generator doesn't support SAFEARRAY parameters with interface pointers other than IUnknown. So, we're probably up against something difficult here.

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