VirtualBox

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

Last change on this file since 57372 was 56596, checked in by vboxsync, 9 years ago

Main/idl: change the unit of "reservedAttributes" from read-write attributes (taking two vtable slots) to read-only attributes. It is more flexible, as one can still make a read-write attribute out of them, decrasing the reserved attribute count by 2.

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