VirtualBox

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

Last change on this file since 66891 was 66274, checked in by vboxsync, 8 years ago

VBox/Main: ​bugref:3300: VBoxSVC from terminal server session is not 'visible' - added VBoxSDS implementation

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