VirtualBox

source: vbox/trunk/src/VBox/Main/idl/xpidl.xsl@ 50121

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

Main: finally handle the IID and CLSID stuff on XPCOM the same way as on MSCOM, those hacks won't be missed,

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 36.6 KB
Line 
1<?xml version="1.0"?>
2<!-- $Id: xpidl.xsl 50121 2014-01-20 14:31:00Z vboxsync $ -->
3
4<!--
5 * A template to generate a XPCOM IDL compatible interface definition file
6 * from the generic interface definition expressed in XML.
7
8 Copyright (C) 2006-2014 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 * translates the string to uppercase
66-->
67<xsl:template name="uppercase">
68 <xsl:param name="str" select="."/>
69 <xsl:value-of select="
70 translate($str,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')
71 "/>
72</xsl:template>
73
74
75<!--
76// templates
77/////////////////////////////////////////////////////////////////////////////
78-->
79
80
81<!--
82 * not explicitly matched elements and attributes
83-->
84<xsl:template match="*"/>
85
86
87<!--
88 * header
89-->
90<xsl:template match="/idl">
91 <xsl:text>
92/*
93 * DO NOT EDIT! This is a generated file.
94 *
95 * XPCOM IDL (XPIDL) definition for VirtualBox Main API (COM interfaces)
96 * generated from XIDL (XML interface definition).
97 *
98 * Source : src/VBox/Main/idl/VirtualBox.xidl
99 * Generator : src/VBox/Main/idl/xpidl.xsl
100 */
101
102#include "nsISupports.idl"
103#include "nsIException.idl"
104
105</xsl:text>
106 <!-- native typedefs for the 'mod="ptr"' attribute -->
107 <xsl:text>
108[ptr] native booleanPtr (PRBool);
109[ptr] native octetPtr (PRUint8);
110[ptr] native shortPtr (PRInt16);
111[ptr] native ushortPtr (PRUint16);
112[ptr] native longPtr (PRInt32);
113[ptr] native llongPtr (PRInt64);
114[ptr] native ulongPtr (PRUint32);
115[ptr] native ullongPtr (PRUint64);
116<!-- charPtr is already defined in nsrootidl.idl -->
117<!-- [ptr] native charPtr (char) -->
118[ptr] native stringPtr (string);
119[ptr] native wcharPtr (wchar);
120[ptr] native wstringPtr (wstring);
121
122</xsl:text>
123 <xsl:apply-templates/>
124</xsl:template>
125
126
127<!--
128 * ignore all |if|s except those for XPIDL target
129-->
130<xsl:template match="if">
131 <xsl:if test="@target='xpidl'">
132 <xsl:apply-templates/>
133 </xsl:if>
134</xsl:template>
135<xsl:template match="if" mode="forward">
136 <xsl:if test="@target='xpidl'">
137 <xsl:apply-templates mode="forward"/>
138 </xsl:if>
139</xsl:template>
140<xsl:template match="if" mode="forwarder">
141 <xsl:if test="@target='midl'">
142 <xsl:apply-templates mode="forwarder"/>
143 </xsl:if>
144</xsl:template>
145
146
147<!--
148 * cpp_quote
149-->
150<xsl:template match="cpp">
151 <xsl:if test="text()">
152 <xsl:text>%{C++</xsl:text>
153 <xsl:value-of select="text()"/>
154 <xsl:text>&#x0A;%}&#x0A;&#x0A;</xsl:text>
155 </xsl:if>
156 <xsl:if test="not(text()) and @line">
157 <xsl:text>%{C++&#x0A;</xsl:text>
158 <xsl:value-of select="@line"/>
159 <xsl:text>&#x0A;%}&#x0A;&#x0A;</xsl:text>
160 </xsl:if>
161</xsl:template>
162
163
164<!--
165 * #if statement (@if attribute)
166 * @note
167 * xpidl doesn't support any preprocessor defines other than #include
168 * (it just ignores them), so the generated IDL will most likely be
169 * invalid. So for now we forbid using @if attributes
170-->
171<xsl:template match="@if" mode="begin">
172 <xsl:message terminate="yes">
173 @if attributes are not currently allowed because xpidl lacks
174 support for #ifdef and stuff.
175 </xsl:message>
176 <xsl:text>#if </xsl:text>
177 <xsl:value-of select="."/>
178 <xsl:text>&#x0A;</xsl:text>
179</xsl:template>
180<xsl:template match="@if" mode="end">
181 <xsl:text>#endif&#x0A;</xsl:text>
182</xsl:template>
183
184
185<!--
186 * libraries
187-->
188<xsl:template match="library">
189 <xsl:text>%{C++&#x0A;</xsl:text>
190 <xsl:text>#ifndef VBOX_EXTERN_C&#x0A;</xsl:text>
191 <xsl:text># ifdef __cplusplus&#x0A;</xsl:text>
192 <xsl:text># define VBOX_EXTERN_C extern "C"&#x0A;</xsl:text>
193 <xsl:text># else // !__cplusplus&#x0A;</xsl:text>
194 <xsl:text># define VBOX_EXTERN_C extern&#x0A;</xsl:text>
195 <xsl:text># endif // !__cplusplus&#x0A;</xsl:text>
196 <xsl:text>#endif // !VBOX_EXTERN_C&#x0A;</xsl:text>
197 <!-- result codes -->
198 <xsl:text>// result codes declared in API spec&#x0A;</xsl:text>
199 <xsl:for-each select="result">
200 <xsl:apply-templates select="."/>
201 </xsl:for-each>
202 <xsl:text>%}&#x0A;&#x0A;</xsl:text>
203 <!-- forward declarations -->
204 <xsl:apply-templates select="if | interface" mode="forward"/>
205 <xsl:text>&#x0A;</xsl:text>
206 <!-- all enums go first -->
207 <xsl:apply-templates select="enum | if/enum"/>
208 <!-- everything else but result codes and enums -->
209 <xsl:apply-templates select="*[not(self::result or self::enum) and
210 not(self::if[result] or self::if[enum])]"/>
211 <!-- -->
212</xsl:template>
213
214
215<!--
216 * result codes
217-->
218<xsl:template match="result">
219 <xsl:value-of select="concat('#define ',@name,' ',@value)"/>
220 <xsl:text>&#x0A;</xsl:text>
221</xsl:template>
222
223
224<!--
225 * forward declarations
226-->
227<xsl:template match="interface" mode="forward">
228 <xsl:text>interface </xsl:text>
229 <xsl:value-of select="@name"/>
230 <xsl:text>;&#x0A;</xsl:text>
231</xsl:template>
232
233
234<!--
235 * interfaces
236-->
237<xsl:template match="interface">[
238 uuid(<xsl:value-of select="@uuid"/>),
239 scriptable
240]
241<xsl:text>interface </xsl:text>
242 <xsl:value-of select="@name"/>
243 <xsl:text> : </xsl:text>
244 <xsl:choose>
245 <xsl:when test="@extends='$unknown'">nsISupports</xsl:when>
246 <xsl:when test="@extends='$dispatched'">nsISupports</xsl:when>
247 <xsl:when test="@extends='$errorinfo'">nsIException</xsl:when>
248 <xsl:otherwise><xsl:value-of select="@extends"/></xsl:otherwise>
249 </xsl:choose>
250 <xsl:text>&#x0A;{&#x0A;</xsl:text>
251 <!-- attributes (properties) -->
252 <xsl:apply-templates select="attribute"/>
253 <!-- methods -->
254 <xsl:apply-templates select="method"/>
255 <!-- 'if' enclosed elements, unsorted -->
256 <xsl:apply-templates select="if"/>
257 <!-- -->
258 <xsl:text>}; /* interface </xsl:text>
259 <xsl:value-of select="@name"/>
260 <xsl:text> */&#x0A;&#x0A;</xsl:text>
261 <!-- Interface implementation forwarder macro -->
262 <xsl:text>/* Interface implementation forwarder macro */&#x0A;</xsl:text>
263 <xsl:text>%{C++&#x0A;</xsl:text>
264 <!-- 1) individual methods -->
265 <xsl:apply-templates select="attribute" mode="forwarder"/>
266 <xsl:apply-templates select="method" mode="forwarder"/>
267 <xsl:apply-templates select="if" mode="forwarder"/>
268 <!-- 2) COM_FORWARD_Interface_TO(smth) -->
269 <xsl:text>#define COM_FORWARD_</xsl:text>
270 <xsl:value-of select="@name"/>
271 <xsl:text>_TO(smth) NS_FORWARD_</xsl:text>
272 <xsl:call-template name="uppercase">
273 <xsl:with-param name="str" select="@name"/>
274 </xsl:call-template>
275 <xsl:text> (smth)&#x0A;</xsl:text>
276 <!-- 3) COM_FORWARD_Interface_TO_OBJ(obj) -->
277 <xsl:text>#define COM_FORWARD_</xsl:text>
278 <xsl:value-of select="@name"/>
279 <xsl:text>_TO_OBJ(obj) COM_FORWARD_</xsl:text>
280 <xsl:value-of select="@name"/>
281 <xsl:text>_TO ((obj)->)&#x0A;</xsl:text>
282 <!-- 4) COM_FORWARD_Interface_TO_BASE(base) -->
283 <xsl:text>#define COM_FORWARD_</xsl:text>
284 <xsl:value-of select="@name"/>
285 <xsl:text>_TO_BASE(base) COM_FORWARD_</xsl:text>
286 <xsl:value-of select="@name"/>
287 <xsl:text>_TO (base::)&#x0A;&#x0A;</xsl:text>
288 <!-- -->
289 <xsl:text>// for compatibility with Win32&#x0A;</xsl:text>
290 <xsl:text>VBOX_EXTERN_C const nsID IID_</xsl:text>
291 <xsl:value-of select="@name"/>
292 <xsl:text>;&#x0A;</xsl:text>
293 <xsl:text>%}&#x0A;&#x0A;</xsl:text>
294 <!-- end -->
295</xsl:template>
296
297
298<!--
299 * attributes
300-->
301<xsl:template match="interface//attribute">
302 <xsl:apply-templates select="@if" mode="begin"/>
303 <xsl:if test="@mod='ptr'">
304 <!-- attributes using native types must be non-scriptable -->
305 <xsl:text> [noscript]&#x0A;</xsl:text>
306 </xsl:if>
307 <xsl:choose>
308 <!-- safearray pseudo attribute -->
309 <xsl:when test="@safearray='yes'">
310 <!-- getter -->
311 <xsl:text> void get</xsl:text>
312 <xsl:call-template name="capitalize">
313 <xsl:with-param name="str" select="@name"/>
314 </xsl:call-template>
315 <xsl:text> (&#x0A;</xsl:text>
316 <!-- array size -->
317 <xsl:text> out unsigned long </xsl:text>
318 <xsl:value-of select="@name"/>
319 <xsl:text>Size,&#x0A;</xsl:text>
320 <!-- array pointer -->
321 <xsl:text> [array, size_is(</xsl:text>
322 <xsl:value-of select="@name"/>
323 <xsl:text>Size), retval] out </xsl:text>
324 <xsl:apply-templates select="@type"/>
325 <xsl:text> </xsl:text>
326 <xsl:value-of select="@name"/>
327 <xsl:text>&#x0A; );&#x0A;</xsl:text>
328 <!-- setter -->
329 <xsl:if test="not(@readonly='yes')">
330 <xsl:text> void set</xsl:text>
331 <xsl:call-template name="capitalize">
332 <xsl:with-param name="str" select="@name"/>
333 </xsl:call-template>
334 <xsl:text> (&#x0A;</xsl:text>
335 <!-- array size -->
336 <xsl:text> in unsigned long </xsl:text>
337 <xsl:value-of select="@name"/>
338 <xsl:text>Size,&#x0A;</xsl:text>
339 <!-- array pointer -->
340 <xsl:text> [array, size_is(</xsl:text>
341 <xsl:value-of select="@name"/>
342 <xsl:text>Size)] in </xsl:text>
343 <xsl:apply-templates select="@type"/>
344 <xsl:text> </xsl:text>
345 <xsl:value-of select="@name"/>
346 <xsl:text>&#x0A; );&#x0A;</xsl:text>
347 </xsl:if>
348 </xsl:when>
349 <!-- normal attribute -->
350 <xsl:otherwise>
351 <xsl:text> </xsl:text>
352 <xsl:if test="@readonly='yes'">
353 <xsl:text>readonly </xsl:text>
354 </xsl:if>
355 <xsl:text>attribute </xsl:text>
356 <xsl:apply-templates select="@type"/>
357 <xsl:text> </xsl:text>
358 <xsl:value-of select="@name"/>
359 <xsl:text>;&#x0A;</xsl:text>
360 </xsl:otherwise>
361 </xsl:choose>
362 <xsl:apply-templates select="@if" mode="end"/>
363 <xsl:text>&#x0A;</xsl:text>
364</xsl:template>
365
366<xsl:template match="interface//attribute" mode="forwarder">
367
368 <xsl:variable name="parent" select="ancestor::interface"/>
369
370 <xsl:apply-templates select="@if" mode="begin"/>
371
372 <!-- getter: COM_FORWARD_Interface_GETTER_Name_TO(smth) -->
373 <xsl:text>#define COM_FORWARD_</xsl:text>
374 <xsl:value-of select="$parent/@name"/>
375 <xsl:text>_GETTER_</xsl:text>
376 <xsl:call-template name="capitalize">
377 <xsl:with-param name="str" select="@name"/>
378 </xsl:call-template>
379 <xsl:text>_TO(smth) NS_IMETHOD Get</xsl:text>
380 <xsl:call-template name="capitalize">
381 <xsl:with-param name="str" select="@name"/>
382 </xsl:call-template>
383 <xsl:text> (</xsl:text>
384 <xsl:if test="@safearray='yes'">
385 <xsl:text>PRUint32 * a</xsl:text>
386 <xsl:call-template name="capitalize">
387 <xsl:with-param name="str" select="@name"/>
388 </xsl:call-template>
389 <xsl:text>Size, </xsl:text>
390 </xsl:if>
391 <xsl:apply-templates select="@type" mode="forwarder"/>
392 <xsl:if test="@safearray='yes'">
393 <xsl:text> *</xsl:text>
394 </xsl:if>
395 <xsl:text> * a</xsl:text>
396 <xsl:call-template name="capitalize">
397 <xsl:with-param name="str" select="@name"/>
398 </xsl:call-template>
399 <xsl:text>) { return smth Get</xsl:text>
400 <xsl:call-template name="capitalize">
401 <xsl:with-param name="str" select="@name"/>
402 </xsl:call-template>
403 <xsl:text> (</xsl:text>
404 <xsl:if test="@safearray='yes'">
405 <xsl:text>a</xsl:text>
406 <xsl:call-template name="capitalize">
407 <xsl:with-param name="str" select="@name"/>
408 </xsl:call-template>
409 <xsl:text>Size, </xsl:text>
410 </xsl:if>
411 <xsl:text>a</xsl:text>
412 <xsl:call-template name="capitalize">
413 <xsl:with-param name="str" select="@name"/>
414 </xsl:call-template>
415 <xsl:text>); }&#x0A;</xsl:text>
416 <!-- getter: COM_FORWARD_Interface_GETTER_Name_TO_OBJ(obj) -->
417 <xsl:text>#define COM_FORWARD_</xsl:text>
418 <xsl:value-of select="$parent/@name"/>
419 <xsl:text>_GETTER_</xsl:text>
420 <xsl:call-template name="capitalize">
421 <xsl:with-param name="str" select="@name"/>
422 </xsl:call-template>
423 <xsl:text>_TO_OBJ(obj) COM_FORWARD_</xsl:text>
424 <xsl:value-of select="$parent/@name"/>
425 <xsl:text>_GETTER_</xsl:text>
426 <xsl:call-template name="capitalize">
427 <xsl:with-param name="str" select="@name"/>
428 </xsl:call-template>
429 <xsl:text>_TO ((obj)->)&#x0A;</xsl:text>
430 <!-- getter: COM_FORWARD_Interface_GETTER_Name_TO_BASE(base) -->
431 <xsl:text>#define COM_FORWARD_</xsl:text>
432 <xsl:value-of select="$parent/@name"/>
433 <xsl:text>_GETTER_</xsl:text>
434 <xsl:call-template name="capitalize">
435 <xsl:with-param name="str" select="@name"/>
436 </xsl:call-template>
437 <xsl:text>_TO_BASE(base) COM_FORWARD_</xsl:text>
438 <xsl:value-of select="$parent/@name"/>
439 <xsl:text>_GETTER_</xsl:text>
440 <xsl:call-template name="capitalize">
441 <xsl:with-param name="str" select="@name"/>
442 </xsl:call-template>
443 <xsl:text>_TO (base::)&#x0A;</xsl:text>
444 <!-- -->
445 <xsl:if test="not(@readonly='yes')">
446 <!-- setter: COM_FORWARD_Interface_SETTER_Name_TO(smth) -->
447 <xsl:text>#define COM_FORWARD_</xsl:text>
448 <xsl:value-of select="$parent/@name"/>
449 <xsl:text>_SETTER_</xsl:text>
450 <xsl:call-template name="capitalize">
451 <xsl:with-param name="str" select="@name"/>
452 </xsl:call-template>
453 <xsl:text>_TO(smth) NS_IMETHOD Set</xsl:text>
454 <xsl:call-template name="capitalize">
455 <xsl:with-param name="str" select="@name"/>
456 </xsl:call-template>
457 <xsl:text> (</xsl:text>
458 <xsl:if test="@safearray='yes'">
459 <xsl:text>PRUint32 a</xsl:text>
460 <xsl:call-template name="capitalize">
461 <xsl:with-param name="str" select="@name"/>
462 </xsl:call-template>
463 <xsl:text>Size, </xsl:text>
464 </xsl:if>
465 <xsl:if test="not(@safearray='yes') and (@type='string' or @type='wstring')">
466 <xsl:text>const </xsl:text>
467 </xsl:if>
468 <xsl:apply-templates select="@type" mode="forwarder"/>
469 <xsl:if test="@safearray='yes'">
470 <xsl:text> *</xsl:text>
471 </xsl:if>
472 <xsl:text> a</xsl:text>
473 <xsl:call-template name="capitalize">
474 <xsl:with-param name="str" select="@name"/>
475 </xsl:call-template>
476 <xsl:text>) { return smth Set</xsl:text>
477 <xsl:call-template name="capitalize">
478 <xsl:with-param name="str" select="@name"/>
479 </xsl:call-template>
480 <xsl:text> (a</xsl:text>
481 <xsl:call-template name="capitalize">
482 <xsl:with-param name="str" select="@name"/>
483 </xsl:call-template>
484 <xsl:text>); }&#x0A;</xsl:text>
485 <!-- setter: COM_FORWARD_Interface_SETTER_Name_TO_OBJ(obj) -->
486 <xsl:text>#define COM_FORWARD_</xsl:text>
487 <xsl:value-of select="$parent/@name"/>
488 <xsl:text>_SETTER_</xsl:text>
489 <xsl:call-template name="capitalize">
490 <xsl:with-param name="str" select="@name"/>
491 </xsl:call-template>
492 <xsl:text>_TO_OBJ(obj) COM_FORWARD_</xsl:text>
493 <xsl:value-of select="$parent/@name"/>
494 <xsl:text>_SETTER_</xsl:text>
495 <xsl:call-template name="capitalize">
496 <xsl:with-param name="str" select="@name"/>
497 </xsl:call-template>
498 <xsl:text>_TO ((obj)->)&#x0A;</xsl:text>
499 <!-- setter: COM_FORWARD_Interface_SETTER_Name_TO_BASE(base) -->
500 <xsl:text>#define COM_FORWARD_</xsl:text>
501 <xsl:value-of select="$parent/@name"/>
502 <xsl:text>_SETTER_</xsl:text>
503 <xsl:call-template name="capitalize">
504 <xsl:with-param name="str" select="@name"/>
505 </xsl:call-template>
506 <xsl:text>_TO_BASE(base) COM_FORWARD_</xsl:text>
507 <xsl:value-of select="$parent/@name"/>
508 <xsl:text>_SETTER_</xsl:text>
509 <xsl:call-template name="capitalize">
510 <xsl:with-param name="str" select="@name"/>
511 </xsl:call-template>
512 <xsl:text>_TO (base::)&#x0A;</xsl:text>
513 </xsl:if>
514
515 <xsl:apply-templates select="@if" mode="end"/>
516
517</xsl:template>
518
519
520<!--
521 * methods
522-->
523<xsl:template match="interface//method">
524 <xsl:apply-templates select="@if" mode="begin"/>
525 <xsl:if test="param/@mod='ptr'">
526 <!-- methods using native types must be non-scriptable -->
527 <xsl:text> [noscript]&#x0A;</xsl:text>
528 </xsl:if>
529 <xsl:text> void </xsl:text>
530 <xsl:value-of select="@name"/>
531 <xsl:if test="param">
532 <xsl:text> (&#x0A;</xsl:text>
533 <xsl:for-each select="param [position() != last()]">
534 <xsl:text> </xsl:text>
535 <xsl:apply-templates select="."/>
536 <xsl:text>,&#x0A;</xsl:text>
537 </xsl:for-each>
538 <xsl:text> </xsl:text>
539 <xsl:apply-templates select="param [last()]"/>
540 <xsl:text>&#x0A; );&#x0A;</xsl:text>
541 </xsl:if>
542 <xsl:if test="not(param)">
543 <xsl:text>();&#x0A;</xsl:text>
544 </xsl:if>
545 <xsl:apply-templates select="@if" mode="end"/>
546 <xsl:text>&#x0A;</xsl:text>
547</xsl:template>
548
549<xsl:template match="interface//method" mode="forwarder">
550
551 <xsl:variable name="parent" select="ancestor::interface"/>
552
553 <xsl:apply-templates select="@if" mode="begin"/>
554
555 <xsl:text>#define COM_FORWARD_</xsl:text>
556 <xsl:value-of select="$parent/@name"/>
557 <xsl:text>_</xsl:text>
558 <xsl:call-template name="capitalize">
559 <xsl:with-param name="str" select="@name"/>
560 </xsl:call-template>
561 <xsl:text>_TO(smth) NS_IMETHOD </xsl:text>
562 <xsl:call-template name="capitalize">
563 <xsl:with-param name="str" select="@name"/>
564 </xsl:call-template>
565 <xsl:choose>
566 <xsl:when test="param">
567 <xsl:text> (</xsl:text>
568 <xsl:for-each select="param [position() != last()]">
569 <xsl:apply-templates select="." mode="forwarder"/>
570 <xsl:text>, </xsl:text>
571 </xsl:for-each>
572 <xsl:apply-templates select="param [last()]" mode="forwarder"/>
573 <xsl:text>) { return smth </xsl:text>
574 <xsl:call-template name="capitalize">
575 <xsl:with-param name="str" select="@name"/>
576 </xsl:call-template>
577 <xsl:text> (</xsl:text>
578 <xsl:for-each select="param [position() != last()]">
579 <xsl:if test="@safearray='yes'">
580 <xsl:text>a</xsl:text>
581 <xsl:call-template name="capitalize">
582 <xsl:with-param name="str" select="@name"/>
583 </xsl:call-template>
584 <xsl:text>Size+++, </xsl:text>
585 </xsl:if>
586 <xsl:text>a</xsl:text>
587 <xsl:call-template name="capitalize">
588 <xsl:with-param name="str" select="@name"/>
589 </xsl:call-template>
590 <xsl:text>, </xsl:text>
591 </xsl:for-each>
592 <xsl:if test="param [last()]/@safearray='yes'">
593 <xsl:text>a</xsl:text>
594 <xsl:call-template name="capitalize">
595 <xsl:with-param name="str" select="param [last()]/@name"/>
596 </xsl:call-template>
597 <xsl:text>Size, </xsl:text>
598 </xsl:if>
599 <xsl:text>a</xsl:text>
600 <xsl:call-template name="capitalize">
601 <xsl:with-param name="str" select="param [last()]/@name"/>
602 </xsl:call-template>
603 <xsl:text>); }</xsl:text>
604 </xsl:when>
605 <xsl:otherwise test="not(param)">
606 <xsl:text>() { return smth </xsl:text>
607 <xsl:call-template name="capitalize">
608 <xsl:with-param name="str" select="@name"/>
609 </xsl:call-template>
610 <xsl:text>(); }</xsl:text>
611 </xsl:otherwise>
612 </xsl:choose>
613 <xsl:text>&#x0A;</xsl:text>
614 <!-- COM_FORWARD_Interface_Method_TO_OBJ(obj) -->
615 <xsl:text>#define COM_FORWARD_</xsl:text>
616 <xsl:value-of select="$parent/@name"/>
617 <xsl:text>_</xsl:text>
618 <xsl:call-template name="capitalize">
619 <xsl:with-param name="str" select="@name"/>
620 </xsl:call-template>
621 <xsl:text>_TO_OBJ(obj) COM_FORWARD_</xsl:text>
622 <xsl:value-of select="$parent/@name"/>
623 <xsl:text>_</xsl:text>
624 <xsl:call-template name="capitalize">
625 <xsl:with-param name="str" select="@name"/>
626 </xsl:call-template>
627 <xsl:text>_TO ((obj)->)&#x0A;</xsl:text>
628 <!-- COM_FORWARD_Interface_Method_TO_BASE(base) -->
629 <xsl:text>#define COM_FORWARD_</xsl:text>
630 <xsl:value-of select="$parent/@name"/>
631 <xsl:text>_</xsl:text>
632 <xsl:call-template name="capitalize">
633 <xsl:with-param name="str" select="@name"/>
634 </xsl:call-template>
635 <xsl:text>_TO_BASE(base) COM_FORWARD_</xsl:text>
636 <xsl:value-of select="$parent/@name"/>
637 <xsl:text>_</xsl:text>
638 <xsl:call-template name="capitalize">
639 <xsl:with-param name="str" select="@name"/>
640 </xsl:call-template>
641 <xsl:text>_TO (base::)&#x0A;</xsl:text>
642
643 <xsl:apply-templates select="@if" mode="end"/>
644
645</xsl:template>
646
647
648<!--
649 * modules
650-->
651<xsl:template match="module">
652 <xsl:apply-templates select="class"/>
653</xsl:template>
654
655
656<!--
657 * co-classes
658-->
659<xsl:template match="module/class">
660 <!-- class and contract id -->
661 <xsl:text>%{C++&#x0A;</xsl:text>
662 <xsl:text>// Definitions for module </xsl:text>
663 <xsl:value-of select="../@name"/>
664 <xsl:text>, class </xsl:text>
665 <xsl:value-of select="@name"/>
666 <xsl:text>:&#x0A;</xsl:text>
667 <xsl:text>#define NS_</xsl:text>
668 <xsl:call-template name="uppercase">
669 <xsl:with-param name="str" select="@name"/>
670 </xsl:call-template>
671 <xsl:text>_CID { \&#x0A;</xsl:text>
672 <xsl:text> 0x</xsl:text><xsl:value-of select="substring(@uuid,1,8)"/>
673 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,10,4)"/>
674 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,15,4)"/>
675 <xsl:text>, \&#x0A; </xsl:text>
676 <xsl:text>{ 0x</xsl:text><xsl:value-of select="substring(@uuid,20,2)"/>
677 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,22,2)"/>
678 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,25,2)"/>
679 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,27,2)"/>
680 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,29,2)"/>
681 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,31,2)"/>
682 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,33,2)"/>
683 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,35,2)"/>
684 <xsl:text> } \&#x0A;}&#x0A;</xsl:text>
685 <xsl:text>#define NS_</xsl:text>
686 <xsl:call-template name="uppercase">
687 <xsl:with-param name="str" select="@name"/>
688 </xsl:call-template>
689 <!-- Contract ID -->
690 <xsl:text>_CONTRACTID &quot;@</xsl:text>
691 <xsl:value-of select="@namespace"/>
692 <xsl:text>/</xsl:text>
693 <xsl:value-of select="@name"/>
694 <xsl:text>;1&quot;&#x0A;</xsl:text>
695 <!-- CLSID_xxx declarations for XPCOM, for compatibility with Win32 -->
696 <xsl:text>// for compatibility with Win32&#x0A;</xsl:text>
697 <xsl:text>VBOX_EXTERN_C const nsCID CLSID_</xsl:text>
698 <xsl:value-of select="@name"/>
699 <xsl:text>;&#x0A;</xsl:text>
700 <xsl:text>%}&#x0A;&#x0A;</xsl:text>
701</xsl:template>
702
703
704<!--
705 * enums
706-->
707<xsl:template match="enum">[
708 uuid(<xsl:value-of select="@uuid"/>),
709 scriptable
710]
711<xsl:text>interface </xsl:text>
712 <xsl:value-of select="@name"/>
713 <xsl:text>&#x0A;{&#x0A;</xsl:text>
714 <xsl:for-each select="const">
715 <xsl:text> const PRUint32 </xsl:text>
716 <xsl:value-of select="@name"/> = <xsl:value-of select="@value"/>
717 <xsl:text>;&#x0A;</xsl:text>
718 </xsl:for-each>
719 <xsl:text>};&#x0A;&#x0A;</xsl:text>
720 <!-- -->
721 <xsl:value-of select="concat('/* cross-platform type name for ', @name, ' */&#x0A;')"/>
722 <xsl:text>%{C++&#x0A;</xsl:text>
723 <xsl:value-of select="concat('#define ', @name, '_T', ' ',
724 'PRUint32&#x0A;')"/>
725 <xsl:text>%}&#x0A;&#x0A;</xsl:text>
726 <!-- -->
727 <xsl:value-of select="concat('/* cross-platform constants for ', @name, ' */&#x0A;')"/>
728 <xsl:text>%{C++&#x0A;</xsl:text>
729 <xsl:for-each select="const">
730 <xsl:value-of select="concat('#define ', ../@name, '_', @name, ' ',
731 ../@name, '::', @name, '&#x0A;')"/>
732 </xsl:for-each>
733 <xsl:text>%}&#x0A;&#x0A;</xsl:text>
734</xsl:template>
735
736
737<!--
738 * method parameters
739-->
740<xsl:template match="method/param">
741 <xsl:choose>
742 <!-- safearray parameters -->
743 <xsl:when test="@safearray='yes'">
744 <!-- array size -->
745 <xsl:choose>
746 <xsl:when test="@dir='in'">in </xsl:when>
747 <xsl:when test="@dir='out'">out </xsl:when>
748 <xsl:when test="@dir='return'">out </xsl:when>
749 <xsl:otherwise>in </xsl:otherwise>
750 </xsl:choose>
751 <xsl:text>unsigned long </xsl:text>
752 <xsl:value-of select="@name"/>
753 <xsl:text>Size,&#x0A;</xsl:text>
754 <!-- array pointer -->
755 <xsl:text> [array, size_is(</xsl:text>
756 <xsl:value-of select="@name"/>
757 <xsl:text>Size)</xsl:text>
758 <xsl:choose>
759 <xsl:when test="@dir='in'">] in </xsl:when>
760 <xsl:when test="@dir='out'">] out </xsl:when>
761 <xsl:when test="@dir='return'"> , retval] out </xsl:when>
762 <xsl:otherwise>] in </xsl:otherwise>
763 </xsl:choose>
764 <xsl:apply-templates select="@type"/>
765 <xsl:text> </xsl:text>
766 <xsl:value-of select="@name"/>
767 </xsl:when>
768 <!-- normal and array parameters -->
769 <xsl:otherwise>
770 <xsl:choose>
771 <xsl:when test="@dir='in'">in </xsl:when>
772 <xsl:when test="@dir='out'">out </xsl:when>
773 <xsl:when test="@dir='return'">[retval] out </xsl:when>
774 <xsl:otherwise>in </xsl:otherwise>
775 </xsl:choose>
776 <xsl:apply-templates select="@type"/>
777 <xsl:text> </xsl:text>
778 <xsl:value-of select="@name"/>
779 </xsl:otherwise>
780 </xsl:choose>
781</xsl:template>
782
783<xsl:template match="method/param" mode="forwarder">
784 <xsl:if test="@safearray='yes'">
785 <xsl:text>PRUint32</xsl:text>
786 <xsl:if test="@dir='out' or @dir='return'">
787 <xsl:text> *</xsl:text>
788 </xsl:if>
789 <xsl:text> a</xsl:text>
790 <xsl:call-template name="capitalize">
791 <xsl:with-param name="str" select="@name"/>
792 </xsl:call-template>
793 <xsl:text>Size, </xsl:text>
794 </xsl:if>
795 <xsl:apply-templates select="@type" mode="forwarder"/>
796 <xsl:if test="@dir='out' or @dir='return'">
797 <xsl:text> *</xsl:text>
798 </xsl:if>
799 <xsl:if test="@safearray='yes'">
800 <xsl:text> *</xsl:text>
801 </xsl:if>
802 <xsl:text> a</xsl:text>
803 <xsl:call-template name="capitalize">
804 <xsl:with-param name="str" select="@name"/>
805 </xsl:call-template>
806</xsl:template>
807
808
809<!--
810 * attribute/parameter type conversion
811-->
812<xsl:template match="attribute/@type | param/@type">
813 <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
814
815 <xsl:choose>
816 <!-- modifiers (ignored for 'enumeration' attributes)-->
817 <xsl:when test="name(current())='type' and ../@mod">
818 <xsl:choose>
819 <xsl:when test="../@mod='ptr'">
820 <xsl:choose>
821 <!-- standard types -->
822 <!--xsl:when test=".='result'">??</xsl:when-->
823 <xsl:when test=".='boolean'">booleanPtr</xsl:when>
824 <xsl:when test=".='octet'">octetPtr</xsl:when>
825 <xsl:when test=".='short'">shortPtr</xsl:when>
826 <xsl:when test=".='unsigned short'">ushortPtr</xsl:when>
827 <xsl:when test=".='long'">longPtr</xsl:when>
828 <xsl:when test=".='long long'">llongPtr</xsl:when>
829 <xsl:when test=".='unsigned long'">ulongPtr</xsl:when>
830 <xsl:when test=".='unsigned long long'">ullongPtr</xsl:when>
831 <xsl:otherwise>
832 <xsl:message terminate="yes">
833 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
834 <xsl:text>attribute 'mod=</xsl:text>
835 <xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
836 <xsl:text>' cannot be used with type </xsl:text>
837 <xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
838 </xsl:message>
839 </xsl:otherwise>
840 </xsl:choose>
841 </xsl:when>
842 <xsl:when test="../@mod='string'">
843 <xsl:choose>
844 <!-- standard types -->
845 <!--xsl:when test=".='result'">??</xsl:when-->
846 <xsl:when test=".='uuid'">wstring</xsl:when>
847 <xsl:otherwise>
848 <xsl:message terminate="yes">
849 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
850 <xsl:text>attribute 'mod=</xsl:text>
851 <xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
852 <xsl:text>' cannot be used with type </xsl:text>
853 <xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
854 </xsl:message>
855 </xsl:otherwise>
856 </xsl:choose>
857 </xsl:when>
858 <xsl:otherwise>
859 <xsl:message terminate="yes">
860 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
861 <xsl:value-of select="concat('value &quot;',../@mod,'&quot; ')"/>
862 <xsl:text>of attribute 'mod' is invalid!</xsl:text>
863 </xsl:message>
864 </xsl:otherwise>
865 </xsl:choose>
866 </xsl:when>
867 <!-- no modifiers -->
868 <xsl:otherwise>
869 <xsl:choose>
870 <!-- standard types -->
871 <xsl:when test=".='result'">nsresult</xsl:when>
872 <xsl:when test=".='boolean'">boolean</xsl:when>
873 <xsl:when test=".='octet'">octet</xsl:when>
874 <xsl:when test=".='short'">short</xsl:when>
875 <xsl:when test=".='unsigned short'">unsigned short</xsl:when>
876 <xsl:when test=".='long'">long</xsl:when>
877 <xsl:when test=".='long long'">long long</xsl:when>
878 <xsl:when test=".='unsigned long'">unsigned long</xsl:when>
879 <xsl:when test=".='unsigned long long'">unsigned long long</xsl:when>
880 <xsl:when test=".='char'">char</xsl:when>
881 <xsl:when test=".='wchar'">wchar</xsl:when>
882 <xsl:when test=".='string'">string</xsl:when>
883 <xsl:when test=".='wstring'">wstring</xsl:when>
884 <!-- UUID type -->
885 <xsl:when test=".='uuid'">
886 <xsl:choose>
887 <xsl:when test="name(..)='attribute'">
888 <xsl:choose>
889 <xsl:when test="../@readonly='yes'">
890 <xsl:text>nsIDPtr</xsl:text>
891 </xsl:when>
892 <xsl:otherwise>
893 <xsl:message terminate="yes">
894 <xsl:value-of select="../@name"/>
895 <xsl:text>: Non-readonly uuid attributes are not supported!</xsl:text>
896 </xsl:message>
897 </xsl:otherwise>
898 </xsl:choose>
899 </xsl:when>
900 <xsl:when test="name(..)='param'">
901 <xsl:choose>
902 <xsl:when test="../@dir='in' and not(../@safearray='yes')">
903 <xsl:text>nsIDRef</xsl:text>
904 </xsl:when>
905 <xsl:otherwise>
906 <xsl:text>nsIDPtr</xsl:text>
907 </xsl:otherwise>
908 </xsl:choose>
909 </xsl:when>
910 </xsl:choose>
911 </xsl:when>
912 <!-- system interface types -->
913 <xsl:when test=".='$unknown'">nsISupports</xsl:when>
914 <xsl:otherwise>
915 <xsl:choose>
916 <!-- enum types -->
917 <xsl:when test="
918 (ancestor::library/enum[@name=current()]) or
919 (ancestor::library/if[@target=$self_target]/enum[@name=current()])
920 ">
921 <xsl:text>PRUint32</xsl:text>
922 </xsl:when>
923 <!-- custom interface types -->
924 <xsl:when test="
925 (ancestor::library/interface[@name=current()]) or
926 (ancestor::library/if[@target=$self_target]/interface[@name=current()])
927 ">
928 <xsl:value-of select="."/>
929 </xsl:when>
930 <!-- other types -->
931 <xsl:otherwise>
932 <xsl:message terminate="yes">
933 <xsl:text>Unknown parameter type: </xsl:text>
934 <xsl:value-of select="."/>
935 </xsl:message>
936 </xsl:otherwise>
937 </xsl:choose>
938 </xsl:otherwise>
939 </xsl:choose>
940 </xsl:otherwise>
941 </xsl:choose>
942</xsl:template>
943
944<xsl:template match="attribute/@type | param/@type" mode="forwarder">
945
946 <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
947
948 <xsl:choose>
949 <!-- modifiers (ignored for 'enumeration' attributes)-->
950 <xsl:when test="name(current())='type' and ../@mod">
951 <xsl:choose>
952 <xsl:when test="../@mod='ptr'">
953 <xsl:choose>
954 <!-- standard types -->
955 <!--xsl:when test=".='result'">??</xsl:when-->
956 <xsl:when test=".='boolean'">PRBool *</xsl:when>
957 <xsl:when test=".='octet'">PRUint8 *</xsl:when>
958 <xsl:when test=".='short'">PRInt16 *</xsl:when>
959 <xsl:when test=".='unsigned short'">PRUint16 *</xsl:when>
960 <xsl:when test=".='long'">PRInt32 *</xsl:when>
961 <xsl:when test=".='long long'">PRInt64 *</xsl:when>
962 <xsl:when test=".='unsigned long'">PRUint32 *</xsl:when>
963 <xsl:when test=".='unsigned long long'">PRUint64 *</xsl:when>
964 <xsl:when test=".='char'">char *</xsl:when>
965 <xsl:otherwise>
966 <xsl:message terminate="yes">
967 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
968 <xsl:text>attribute 'mod=</xsl:text>
969 <xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
970 <xsl:text>' cannot be used with type </xsl:text>
971 <xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
972 </xsl:message>
973 </xsl:otherwise>
974 </xsl:choose>
975 </xsl:when>
976 <xsl:when test="../@mod='string'">
977 <xsl:choose>
978 <!-- standard types -->
979 <!--xsl:when test=".='result'">??</xsl:when-->
980 <xsl:when test=".='uuid'">PRUnichar *</xsl:when>
981 <xsl:otherwise>
982 <xsl:message terminate="yes">
983 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
984 <xsl:text>attribute 'mod=</xsl:text>
985 <xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
986 <xsl:text>' cannot be used with type </xsl:text>
987 <xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
988 </xsl:message>
989 </xsl:otherwise>
990 </xsl:choose>
991 </xsl:when>
992 </xsl:choose>
993 </xsl:when>
994 <!-- no modifiers -->
995 <xsl:otherwise>
996 <xsl:choose>
997 <!-- standard types -->
998 <xsl:when test=".='result'">nsresult</xsl:when>
999 <xsl:when test=".='boolean'">PRBool</xsl:when>
1000 <xsl:when test=".='octet'">PRUint8</xsl:when>
1001 <xsl:when test=".='short'">PRInt16</xsl:when>
1002 <xsl:when test=".='unsigned short'">PRUint16</xsl:when>
1003 <xsl:when test=".='long'">PRInt32</xsl:when>
1004 <xsl:when test=".='long long'">PRInt64</xsl:when>
1005 <xsl:when test=".='unsigned long'">PRUint32</xsl:when>
1006 <xsl:when test=".='unsigned long long'">PRUint64</xsl:when>
1007 <xsl:when test=".='char'">char</xsl:when>
1008 <xsl:when test=".='wchar'">PRUnichar</xsl:when>
1009 <!-- string types -->
1010 <xsl:when test=".='string'">char *</xsl:when>
1011 <xsl:when test=".='wstring'">PRUnichar *</xsl:when>
1012 <!-- UUID type -->
1013 <xsl:when test=".='uuid'">
1014 <xsl:choose>
1015 <xsl:when test="name(..)='attribute'">
1016 <xsl:choose>
1017 <xsl:when test="../@readonly='yes'">
1018 <xsl:text>nsID *</xsl:text>
1019 </xsl:when>
1020 </xsl:choose>
1021 </xsl:when>
1022 <xsl:when test="name(..)='param'">
1023 <xsl:choose>
1024 <xsl:when test="../@dir='in' and not(../@safearray='yes')">
1025 <xsl:text>const nsID &amp;</xsl:text>
1026 </xsl:when>
1027 <xsl:otherwise>
1028 <xsl:text>nsID *</xsl:text>
1029 </xsl:otherwise>
1030 </xsl:choose>
1031 </xsl:when>
1032 </xsl:choose>
1033 </xsl:when>
1034 <!-- system interface types -->
1035 <xsl:when test=".='$unknown'">nsISupports *</xsl:when>
1036 <xsl:otherwise>
1037 <xsl:choose>
1038 <!-- enum types -->
1039 <xsl:when test="
1040 (ancestor::library/enum[@name=current()]) or
1041 (ancestor::library/if[@target=$self_target]/enum[@name=current()])
1042 ">
1043 <xsl:text>PRUint32</xsl:text>
1044 </xsl:when>
1045 <!-- custom interface types -->
1046 <xsl:when test="
1047 (ancestor::library/interface[@name=current()]) or
1048 (ancestor::library/if[@target=$self_target]/interface[@name=current()])
1049 ">
1050 <xsl:value-of select="."/>
1051 <xsl:text> *</xsl:text>
1052 </xsl:when>
1053 <!-- other types -->
1054 </xsl:choose>
1055 </xsl:otherwise>
1056 </xsl:choose>
1057 </xsl:otherwise>
1058 </xsl:choose>
1059</xsl:template>
1060
1061</xsl:stylesheet>
1062
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