VirtualBox

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

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

Quick midl proxy dll experiment.

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