VirtualBox

source: vbox/trunk/src/VBox/Main/cbinding/xpcidl.xsl@ 16483

Last change on this file since 16483 was 16406, checked in by vboxsync, 16 years ago

cbindings to OSE

  • Property svn:eol-style set to native
File size: 53.7 KB
Line 
1<?xml version="1.0"?>
2<!-- $Id: xpidl.xsl 39869 2008-11-25 13:37:40Z dmik $ -->
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-2009 Sun Microsystems, Inc.
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 Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
19 Clara, CA 95054 USA or visit http://www.sun.com if you need
20 additional information or have any questions.
21-->
22
23<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
24<xsl:output method="text"/>
25
26<xsl:strip-space elements="*"/>
27
28
29<!--
30// helper definitions
31/////////////////////////////////////////////////////////////////////////////
32-->
33
34<!--
35 * capitalizes the first letter
36-->
37<xsl:template name="capitalize">
38 <xsl:param name="str" select="."/>
39 <xsl:value-of select="
40 concat(
41 translate(substring($str,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ'),
42 substring($str,2)
43 )
44 "/>
45</xsl:template>
46
47<!--
48 * uncapitalizes the first letter only if the second one is not capital
49 * otherwise leaves the string unchanged
50-->
51<xsl:template name="uncapitalize">
52 <xsl:param name="str" select="."/>
53 <xsl:choose>
54 <xsl:when test="not(contains('ABCDEFGHIJKLMNOPQRSTUVWXYZ', substring($str,2,1)))">
55 <xsl:value-of select="
56 concat(
57 translate(substring($str,1,1),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),
58 substring($str,2)
59 )
60 "/>
61 </xsl:when>
62 <xsl:otherwise>
63 <xsl:value-of select="string($str)"/>
64 </xsl:otherwise>
65 </xsl:choose>
66</xsl:template>
67
68<!--
69 * translates the string to uppercase
70-->
71<xsl:template name="uppercase">
72 <xsl:param name="str" select="."/>
73 <xsl:value-of select="
74 translate($str,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')
75 "/>
76</xsl:template>
77
78
79<!--
80 * translates the string to lowercase
81-->
82<xsl:template name="lowercase">
83 <xsl:param name="str" select="."/>
84 <xsl:value-of select="
85 translate($str,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')
86 "/>
87</xsl:template>
88
89
90<!--
91// templates
92/////////////////////////////////////////////////////////////////////////////
93-->
94
95
96<!--
97 * not explicitly matched elements and attributes
98-->
99<xsl:template match="*"/>
100
101
102<!--
103 * header
104-->
105<xsl:template match="/idl">
106 <xsl:text>
107/*
108 * DO NOT EDIT! This is a generated file.
109 *
110 * XPCOM IDL (XPIDL) definition for VirtualBox Main API (COM interfaces)
111 * generated from XIDL (XML interface definition).
112 *
113 * Source : src/VBox/Main/idl/VirtualBox.xidl
114 * Generator : src/VBox/Main/idl/xpcidl.xsl
115 */
116
117#include "wchar.h"
118#include "prtypes.h"
119
120#define nsnull 0
121typedef PRUint32 nsresult;
122
123#if defined(__GNUC__) &amp;&amp; (__GNUC__ > 2)
124#define NS_LIKELY(x) (__builtin_expect((x), 1))
125#define NS_UNLIKELY(x) (__builtin_expect((x), 0))
126#else
127#define NS_LIKELY(x) (x)
128#define NS_UNLIKELY(x) (x)
129#endif
130
131#define NS_FAILED(_nsresult) (NS_UNLIKELY((_nsresult) &amp; 0x80000000))
132#define NS_SUCCEEDED(_nsresult) (NS_LIKELY(!((_nsresult) &amp; 0x80000000)))
133
134/**
135 * An "interface id" which can be used to uniquely identify a given
136 * interface.
137 * A "unique identifier". This is modeled after OSF DCE UUIDs.
138 */
139
140struct nsID {
141 PRUint32 m0;
142 PRUint16 m1;
143 PRUint16 m2;
144 PRUint8 m3[8];
145};
146
147typedef struct nsID nsID;
148typedef nsID nsIID;
149
150struct nsISupports; /* forward declaration */
151struct nsIStackFrame; /* forward declaration */
152struct nsIException; /* forward declaration */
153typedef struct nsISupports nsISupports; /* forward declaration */
154typedef struct nsIStackFrame nsIStackFrame; /* forward declaration */
155typedef struct nsIException nsIException; /* forward declaration */
156
157/**
158 * IID for the nsISupports interface
159 * {00000000-0000-0000-c000-000000000046}
160 *
161 * To maintain binary compatibility with COM's IUnknown, we define the IID
162 * of nsISupports to be the same as that of COM's IUnknown.
163 */
164#define NS_ISUPPORTS_IID \
165 { 0x00000000, 0x0000, 0x0000, \
166 {0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} }
167
168/**
169 * Reference count values
170 *
171 * This is the return type for AddRef() and Release() in nsISupports.
172 * IUnknown of COM returns an unsigned long from equivalent functions.
173 * The following ifdef exists to maintain binary compatibility with
174 * IUnknown.
175 */
176
177/**
178 * Basic component object model interface. Objects which implement
179 * this interface support runtime interface discovery (QueryInterface)
180 * and a reference counted memory model (AddRef/Release). This is
181 * modelled after the win32 IUnknown API.
182 */
183struct nsISupports_vtbl {
184
185 /**
186 * @name Methods
187 */
188
189 /**
190 * A run time mechanism for interface discovery.
191 * @param aIID [in] A requested interface IID
192 * @param aInstancePtr [out] A pointer to an interface pointer to
193 * receive the result.
194 * @return NS_OK if the interface is supported by the associated
195 * instance, NS_NOINTERFACE if it is not.
196 * NS_ERROR_INVALID_POINTER if aInstancePtr is NULL.
197 */
198 nsresult (*QueryInterface)(nsISupports *this_, const nsID *iid, void **resultp);
199 /**
200 * Increases the reference count for this interface.
201 * The associated instance will not be deleted unless
202 * the reference count is returned to zero.
203 *
204 * @return The resulting reference count.
205 */
206 nsresult (*AddRef)(nsISupports *this_);
207
208 /**
209 * Decreases the reference count for this interface.
210 * Generally, if the reference count returns to zero,
211 * the associated instance is deleted.
212 *
213 * @return The resulting reference count.
214 */
215 nsresult (*Release)(nsISupports *this_);
216
217};
218
219struct nsISupports {
220 struct nsISupports_vtbl *vtbl;
221};
222
223/* starting interface: nsIException */
224#define NS_IEXCEPTION_IID_STR "f3a8d3b4-c424-4edc-8bf6-8974c983ba78"
225
226#define NS_IEXCEPTION_IID \
227 {0xf3a8d3b4, 0xc424, 0x4edc, \
228 { 0x8b, 0xf6, 0x89, 0x74, 0xc9, 0x83, 0xba, 0x78 }}
229
230struct nsIException_vtbl {
231
232 /* Methods from the Class nsISupports */
233 struct nsISupports_vtbl nsisupports;
234
235 /* readonly attribute string message; */
236 nsresult (*GetMessage)(nsIException *this_, PRUnichar * *aMessage);
237
238 /* readonly attribute nsresult (*result; */
239 nsresult (*GetResult)(nsIException *this_, nsresult *aResult);
240
241 /* readonly attribute string name; */
242 nsresult (*GetName)(nsIException *this_, PRUnichar * *aName);
243
244 /* readonly attribute string filename; */
245 nsresult (*GetFilename)(nsIException *this_, PRUnichar * *aFilename);
246
247 /* readonly attribute PRUint32 lineNumber; */
248 nsresult (*GetLineNumber)(nsIException *this_, PRUint32 *aLineNumber);
249
250 /* readonly attribute PRUint32 columnNumber; */
251 nsresult (*GetColumnNumber)(nsIException *this_, PRUint32 *aColumnNumber);
252
253 /* readonly attribute nsIStackFrame location; */
254 nsresult (*GetLocation)(nsIException *this_, nsIStackFrame * *aLocation);
255
256 /* readonly attribute nsIException inner; */
257 nsresult (*GetInner)(nsIException *this_, nsIException * *aInner);
258
259 /* readonly attribute nsISupports data; */
260 nsresult (*GetData)(nsIException *this_, nsISupports * *aData);
261
262 /* string toString (); */
263 nsresult (*ToString)(nsIException *this_, PRUnichar **_retval);
264};
265
266struct nsIException {
267 struct nsIException_vtbl *vtbl;
268};
269
270/* starting interface: nsIStackFrame */
271#define NS_ISTACKFRAME_IID_STR "91d82105-7c62-4f8b-9779-154277c0ee90"
272
273#define NS_ISTACKFRAME_IID \
274 {0x91d82105, 0x7c62, 0x4f8b, \
275 { 0x97, 0x79, 0x15, 0x42, 0x77, 0xc0, 0xee, 0x90 }}
276
277struct nsIStackFrame_vtbl {
278
279 /* Methods from the Class nsISupports */
280 struct nsISupports_vtbl nsisupports;
281
282 /* readonly attribute PRUint32 language; */
283 nsresult (*GetLanguage)(nsIStackFrame *this_, PRUint32 *aLanguage);
284
285 /* readonly attribute string languageName; */
286 nsresult (*GetLanguageName)(nsIStackFrame *this_, PRUnichar * *aLanguageName);
287
288 /* readonly attribute string filename; */
289 nsresult (*GetFilename)(nsIStackFrame *this_, PRUnichar * *aFilename);
290
291 /* readonly attribute string name; */
292 nsresult (*GetName)(nsIStackFrame *this_, PRUnichar * *aName);
293
294 /* readonly attribute PRInt32 lineNumber; */
295 nsresult (*GetLineNumber)(nsIStackFrame *this_, PRInt32 *aLineNumber);
296
297 /* readonly attribute string sourceLine; */
298 nsresult (*GetSourceLine)(nsIStackFrame *this_, PRUnichar * *aSourceLine);
299
300 /* readonly attribute nsIStackFrame caller; */
301 nsresult (*GetCaller)(nsIStackFrame *this_, nsIStackFrame * *aCaller);
302
303 /* string toString (); */
304 nsresult (*ToString)(nsIStackFrame *this_, PRUnichar **_retval);
305};
306
307struct nsIStackFrame {
308 struct nsIStackFrame_vtbl *vtbl;
309};
310
311</xsl:text>
312 <xsl:apply-templates/>
313</xsl:template>
314
315<!--
316 * ignore all |if|s except those for XPIDL target
317<xsl:template match="if">
318 <xsl:if test="@target='xpidl'">
319 <xsl:apply-templates/>
320 </xsl:if>
321</xsl:template>
322<xsl:template match="if" mode="forward">
323 <xsl:if test="@target='xpidl'">
324 <xsl:apply-templates mode="forward"/>
325 </xsl:if>
326</xsl:template>
327<xsl:template match="if" mode="forwarder">
328 <xsl:if test="@target='midl'">
329 <xsl:apply-templates mode="forwarder"/>
330 </xsl:if>
331</xsl:template>
332
333-->
334
335<!--
336 * cpp_quote
337<xsl:template match="cpp">
338 <xsl:if test="text()">
339 <xsl:text>%{C++</xsl:text>
340 <xsl:value-of select="text()"/>
341 <xsl:text>&#x0A;%}&#x0A;&#x0A;</xsl:text>
342 </xsl:if>
343 <xsl:if test="not(text()) and @line">
344 <xsl:text>%{C++&#x0A;</xsl:text>
345 <xsl:value-of select="@line"/>
346 <xsl:text>&#x0A;%}&#x0A;&#x0A;</xsl:text>
347 </xsl:if>
348</xsl:template>
349-->
350
351
352<!--
353 * #if statement (@if attribute)
354 * @note
355 * xpidl doesn't support any preprocessor defines other than #include
356 * (it just ignores them), so the generated IDL will most likely be
357 * invalid. So for now we forbid using @if attributes
358-->
359<xsl:template match="@if" mode="begin">
360 <xsl:message terminate="yes">
361 @if attributes are not currently allowed because xpidl lacks
362 support for #ifdef and stuff.
363 </xsl:message>
364 <xsl:text>#if </xsl:text>
365 <xsl:value-of select="."/>
366 <xsl:text>&#x0A;</xsl:text>
367</xsl:template>
368<xsl:template match="@if" mode="end">
369 <xsl:text>#endif&#x0A;</xsl:text>
370</xsl:template>
371
372
373<!--
374 * libraries
375-->
376<xsl:template match="library">
377 <!-- result codes -->
378 <xsl:text>&#x0A;</xsl:text>
379 <xsl:for-each select="result">
380 <xsl:apply-templates select="."/>
381 </xsl:for-each>
382 <xsl:text>&#x0A;&#x0A;</xsl:text>
383 <!-- forward declarations -->
384 <xsl:apply-templates select="if | interface | collection | enumerator" mode="forward"/>
385 <xsl:text>&#x0A;</xsl:text>
386 <!-- typedef'ing the struct declarations -->
387 <xsl:apply-templates select="if | interface | collection | enumerator" mode="typedef"/>
388 <xsl:text>&#x0A;</xsl:text>
389 <!-- all enums go first -->
390 <xsl:apply-templates select="enum | if/enum"/>
391 <!-- everything else but result codes and enums -->
392 <xsl:apply-templates select="*[not(self::result or self::enum) and
393 not(self::if[result] or self::if[enum])]"/>
394 <!-- -->
395</xsl:template>
396
397
398<!--
399 * result codes
400-->
401<xsl:template match="result">
402 <xsl:value-of select="concat('#define ',@name,' ',@value)"/>
403 <xsl:text>&#x0A;</xsl:text>
404</xsl:template>
405
406
407<!--
408 * forward declarations
409-->
410<xsl:template match="interface | collection | enumerator" mode="forward">
411 <xsl:text>struct </xsl:text>
412 <xsl:value-of select="@name"/>
413 <xsl:text>;&#x0A;</xsl:text>
414</xsl:template>
415
416
417<!--
418 * typedef'ing the struct declarations
419-->
420<xsl:template match="interface | collection | enumerator" mode="typedef">
421 <xsl:text>typedef struct </xsl:text>
422 <xsl:value-of select="@name"/>
423 <xsl:text> </xsl:text>
424 <xsl:value-of select="@name"/>
425 <xsl:text>;&#x0A;</xsl:text>
426</xsl:template>
427
428
429<!--
430 * interfaces
431-->
432<xsl:template match="interface">
433 <xsl:text>/* Start of struct </xsl:text>
434 <xsl:value-of select="@name"/>
435 <xsl:text> Declaration */&#x0A;</xsl:text>
436 <xsl:text>#define </xsl:text>
437 <xsl:call-template name="uppercase">
438 <xsl:with-param name="str" select="@name"/>
439 </xsl:call-template>
440 <xsl:value-of select="concat('_IID_STR &quot;',@uuid,'&quot;')"/>
441 <xsl:text>&#x0A;</xsl:text>
442 <xsl:text>#define </xsl:text>
443 <xsl:call-template name="uppercase">
444 <xsl:with-param name="str" select="@name"/>
445 </xsl:call-template>
446 <xsl:text>_IID { \&#x0A;</xsl:text>
447 <xsl:text> 0x</xsl:text><xsl:value-of select="substring(@uuid,1,8)"/>
448 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,10,4)"/>
449 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,15,4)"/>
450 <xsl:text>, \&#x0A; </xsl:text>
451 <xsl:text>{ 0x</xsl:text><xsl:value-of select="substring(@uuid,20,2)"/>
452 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,22,2)"/>
453 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,25,2)"/>
454 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,27,2)"/>
455 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,29,2)"/>
456 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,31,2)"/>
457 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,33,2)"/>
458 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,35,2)"/>
459 <xsl:text> } \&#x0A;}&#x0A;</xsl:text>
460 <xsl:text>struct </xsl:text>
461 <xsl:value-of select="@name"/>
462 <xsl:text>_vtbl&#x0A;{&#x0A;</xsl:text>
463 <xsl:text> </xsl:text>
464 <xsl:choose>
465 <xsl:when test="@extends='$unknown'">struct nsISupports_vtbl nsisupports;</xsl:when>
466 <xsl:when test="@extends='$dispatched'">struct nsISupports_vtbl nsisupports;</xsl:when>
467 <xsl:when test="@extends='$errorinfo'">struct nsIException_vtbl nsiexception;</xsl:when>
468 <xsl:otherwise>
469 <xsl:text>struct </xsl:text>
470 <xsl:value-of select="@extends"/>
471 <xsl:text>_vtbl </xsl:text>
472 <xsl:call-template name="lowercase">
473 <xsl:with-param name="str" select="@extends"/>
474 </xsl:call-template>
475 <xsl:text>;</xsl:text>
476 </xsl:otherwise>
477 </xsl:choose>
478 <xsl:text>&#x0A;&#x0A;</xsl:text>
479 <!-- attributes (properties) -->
480 <xsl:apply-templates select="attribute"/>
481 <!-- methods -->
482 <xsl:apply-templates select="method"/>
483 <!-- 'if' enclosed elements, unsorted -->
484 <xsl:apply-templates select="if"/>
485 <!-- -->
486 <xsl:text>};</xsl:text>
487 <xsl:text>&#x0A;&#x0A;</xsl:text>
488 <xsl:text>struct </xsl:text>
489 <xsl:value-of select="@name"/>
490 <xsl:text>&#x0A;{&#x0A; struct </xsl:text>
491 <xsl:value-of select="@name"/>
492 <xsl:text>_vtbl *vtbl;&#x0A;};&#x0A;</xsl:text>
493 <xsl:text>/* End of struct </xsl:text>
494 <xsl:value-of select="@name"/>
495 <xsl:text> Declaration */&#x0A;&#x0A;&#x0A;</xsl:text>
496</xsl:template>
497
498
499<!--
500 * attributes
501-->
502<xsl:template match="interface//attribute | collection//attribute">
503 <xsl:if test="@array">
504 <xsl:message terminate="yes">
505 <xsl:value-of select="concat(../../@name,'::',../@name,'::',@name,': ')"/>
506 <xsl:text>'array' attributes are not supported, use 'safearray="yes"' instead.</xsl:text>
507 </xsl:message>
508 </xsl:if>
509 <xsl:apply-templates select="@if" mode="begin"/>
510 <xsl:if test="@mod='ptr'">
511 <!-- attributes using native types must be non-scriptable
512 <xsl:text> [noscript]&#x0A;</xsl:text>-->
513 </xsl:if>
514 <xsl:choose>
515 <!-- safearray pseudo attribute -->
516 <xsl:when test="@safearray='yes'">
517 <!-- getter -->
518 <xsl:text> nsresult (*Get</xsl:text>
519 <xsl:call-template name="capitalize">
520 <xsl:with-param name="str" select="@name"/>
521 </xsl:call-template>
522 <xsl:text>)(</xsl:text>
523 <xsl:value-of select="../@name" />
524 <xsl:text> *this_, </xsl:text>
525 <!-- array size -->
526 <xsl:text>PRUint32 *</xsl:text>
527 <xsl:value-of select="@name"/>
528 <xsl:text>Size, </xsl:text>
529 <!-- array pointer -->
530 <xsl:apply-templates select="@type" mode="forwarder"/>
531 <xsl:text> **</xsl:text>
532 <xsl:value-of select="@name"/>
533 <xsl:text>);&#x0A;</xsl:text>
534 <!-- setter -->
535 <xsl:if test="not(@readonly='yes')">
536 <xsl:text> nsresult set</xsl:text>
537 <xsl:call-template name="capitalize">
538 <xsl:with-param name="str" select="@name"/>
539 </xsl:call-template>
540 <xsl:text> (&#x0A;</xsl:text>
541 <!-- array size -->
542 <xsl:text> in unsigned long </xsl:text>
543 <xsl:value-of select="@name"/>
544 <xsl:text>Size,&#x0A;</xsl:text>
545 <!-- array pointer -->
546 <xsl:text> [array, size_is(</xsl:text>
547 <xsl:value-of select="@name"/>
548 <xsl:text>Size)] in </xsl:text>
549 <xsl:apply-templates select="@type" mode="forwarder"/>
550 <xsl:text> </xsl:text>
551 <xsl:value-of select="@name"/>
552 <xsl:text>&#x0A; );&#x0A;</xsl:text>
553 </xsl:if>
554 </xsl:when>
555 <!-- normal attribute -->
556 <xsl:otherwise>
557 <xsl:text> </xsl:text>
558 <xsl:if test="@readonly='yes'">
559 <xsl:text>nsresult (*Get</xsl:text>
560 <xsl:call-template name="capitalize">
561 <xsl:with-param name="str" select="@name"/>
562 </xsl:call-template>
563 <xsl:text>)(</xsl:text>
564 <xsl:value-of select="../@name" />
565 <xsl:text> *this_, </xsl:text>
566 <xsl:apply-templates select="@type" mode="forwarder"/>
567 <xsl:text> *</xsl:text>
568 <xsl:value-of select="@name"/>
569 <xsl:text>);&#x0A;</xsl:text>
570 </xsl:if>
571 <xsl:choose>
572 <xsl:when test="@readonly='yes'">
573 </xsl:when>
574 <xsl:otherwise>
575 <xsl:text>nsresult (*Get</xsl:text>
576 <xsl:call-template name="capitalize">
577 <xsl:with-param name="str" select="@name"/>
578 </xsl:call-template>
579 <xsl:text>)(</xsl:text>
580 <xsl:value-of select="../@name" />
581 <xsl:text> *this_, </xsl:text>
582 <xsl:apply-templates select="@type" mode="forwarder"/>
583 <xsl:text> *</xsl:text>
584 <xsl:value-of select="@name"/>
585 <xsl:text>);&#x0A; </xsl:text>
586 <xsl:text>nsresult (*Set</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:value-of select="../@name" />
592 <xsl:text> *this_, </xsl:text>
593 <xsl:apply-templates select="@type" mode="forwarder"/>
594 <xsl:text> </xsl:text>
595 <xsl:value-of select="@name"/>
596 <xsl:text>);&#x0A;</xsl:text>
597 </xsl:otherwise>
598 </xsl:choose>
599 </xsl:otherwise>
600 </xsl:choose>
601 <xsl:apply-templates select="@if" mode="end"/>
602 <xsl:text>&#x0A;</xsl:text>
603</xsl:template>
604
605<xsl:template match="interface//attribute | collection//attribute" mode="forwarder">
606
607 <xsl:variable name="parent" select="ancestor::interface | ancestor::collection"/>
608
609 <xsl:apply-templates select="@if" mode="begin"/>
610
611 <!-- getter: COM_FORWARD_Interface_GETTER_Name_TO(smth) -->
612 <xsl:text>#define COM_FORWARD_</xsl:text>
613 <xsl:value-of select="$parent/@name"/>
614 <xsl:text>_GETTER_</xsl:text>
615 <xsl:call-template name="capitalize">
616 <xsl:with-param name="str" select="@name"/>
617 </xsl:call-template>
618 <xsl:text>_TO(smth) NS_IMETHOD Get</xsl:text>
619 <xsl:call-template name="capitalize">
620 <xsl:with-param name="str" select="@name"/>
621 </xsl:call-template>
622 <xsl:text> (</xsl:text>
623 <xsl:if test="@safearray='yes'">
624 <xsl:text>PRUint32 * a</xsl:text>
625 <xsl:call-template name="capitalize">
626 <xsl:with-param name="str" select="@name"/>
627 </xsl:call-template>
628 <xsl:text>Size, </xsl:text>
629 </xsl:if>
630 <xsl:apply-templates select="@type" mode="forwarder"/>
631 <xsl:if test="@safearray='yes'">
632 <xsl:text> *</xsl:text>
633 </xsl:if>
634 <xsl:text> * a</xsl:text>
635 <xsl:call-template name="capitalize">
636 <xsl:with-param name="str" select="@name"/>
637 </xsl:call-template>
638 <xsl:text>) { return smth Get</xsl:text>
639 <xsl:call-template name="capitalize">
640 <xsl:with-param name="str" select="@name"/>
641 </xsl:call-template>
642 <xsl:text> (</xsl:text>
643 <xsl:if test="@safearray='yes'">
644 <xsl:text>a</xsl:text>
645 <xsl:call-template name="capitalize">
646 <xsl:with-param name="str" select="@name"/>
647 </xsl:call-template>
648 <xsl:text>Size, </xsl:text>
649 </xsl:if>
650 <xsl:text>a</xsl:text>
651 <xsl:call-template name="capitalize">
652 <xsl:with-param name="str" select="@name"/>
653 </xsl:call-template>
654 <xsl:text>); }&#x0A;</xsl:text>
655 <!-- getter: COM_FORWARD_Interface_GETTER_Name_TO_OBJ(obj) -->
656 <xsl:text>#define COM_FORWARD_</xsl:text>
657 <xsl:value-of select="$parent/@name"/>
658 <xsl:text>_GETTER_</xsl:text>
659 <xsl:call-template name="capitalize">
660 <xsl:with-param name="str" select="@name"/>
661 </xsl:call-template>
662 <xsl:text>_TO_OBJ(obj) COM_FORWARD_</xsl:text>
663 <xsl:value-of select="$parent/@name"/>
664 <xsl:text>_GETTER_</xsl:text>
665 <xsl:call-template name="capitalize">
666 <xsl:with-param name="str" select="@name"/>
667 </xsl:call-template>
668 <xsl:text>_TO ((obj)->)&#x0A;</xsl:text>
669 <!-- getter: COM_FORWARD_Interface_GETTER_Name_TO_BASE(base) -->
670 <xsl:text>#define COM_FORWARD_</xsl:text>
671 <xsl:value-of select="$parent/@name"/>
672 <xsl:text>_GETTER_</xsl:text>
673 <xsl:call-template name="capitalize">
674 <xsl:with-param name="str" select="@name"/>
675 </xsl:call-template>
676 <xsl:text>_TO_BASE(base) COM_FORWARD_</xsl:text>
677 <xsl:value-of select="$parent/@name"/>
678 <xsl:text>_GETTER_</xsl:text>
679 <xsl:call-template name="capitalize">
680 <xsl:with-param name="str" select="@name"/>
681 </xsl:call-template>
682 <xsl:text>_TO (base::)&#x0A;</xsl:text>
683 <!-- -->
684 <xsl:if test="not(@readonly='yes')">
685 <!-- setter: COM_FORWARD_Interface_SETTER_Name_TO(smth) -->
686 <xsl:text>#define COM_FORWARD_</xsl:text>
687 <xsl:value-of select="$parent/@name"/>
688 <xsl:text>_SETTER_</xsl:text>
689 <xsl:call-template name="capitalize">
690 <xsl:with-param name="str" select="@name"/>
691 </xsl:call-template>
692 <xsl:text>_TO(smth) NS_IMETHOD Set</xsl:text>
693 <xsl:call-template name="capitalize">
694 <xsl:with-param name="str" select="@name"/>
695 </xsl:call-template>
696 <xsl:text> (</xsl:text>
697 <xsl:if test="@safearray='yes'">
698 <xsl:text>PRUint32 a</xsl:text>
699 <xsl:call-template name="capitalize">
700 <xsl:with-param name="str" select="@name"/>
701 </xsl:call-template>
702 <xsl:text>Size, </xsl:text>
703 </xsl:if>
704 <xsl:if test="not(@safearray='yes') and (@type='string' or @type='wstring')">
705 <xsl:text>const </xsl:text>
706 </xsl:if>
707 <xsl:apply-templates select="@type" mode="forwarder"/>
708 <xsl:if test="@safearray='yes'">
709 <xsl:text> *</xsl:text>
710 </xsl:if>
711 <xsl:text> a</xsl:text>
712 <xsl:call-template name="capitalize">
713 <xsl:with-param name="str" select="@name"/>
714 </xsl:call-template>
715 <xsl:text>) { return smth Set</xsl:text>
716 <xsl:call-template name="capitalize">
717 <xsl:with-param name="str" select="@name"/>
718 </xsl:call-template>
719 <xsl:text> (a</xsl:text>
720 <xsl:call-template name="capitalize">
721 <xsl:with-param name="str" select="@name"/>
722 </xsl:call-template>
723 <xsl:text>); }&#x0A;</xsl:text>
724 <!-- setter: COM_FORWARD_Interface_SETTER_Name_TO_OBJ(obj) -->
725 <xsl:text>#define COM_FORWARD_</xsl:text>
726 <xsl:value-of select="$parent/@name"/>
727 <xsl:text>_SETTER_</xsl:text>
728 <xsl:call-template name="capitalize">
729 <xsl:with-param name="str" select="@name"/>
730 </xsl:call-template>
731 <xsl:text>_TO_OBJ(obj) COM_FORWARD_</xsl:text>
732 <xsl:value-of select="$parent/@name"/>
733 <xsl:text>_SETTER_</xsl:text>
734 <xsl:call-template name="capitalize">
735 <xsl:with-param name="str" select="@name"/>
736 </xsl:call-template>
737 <xsl:text>_TO ((obj)->)&#x0A;</xsl:text>
738 <!-- setter: COM_FORWARD_Interface_SETTER_Name_TO_BASE(base) -->
739 <xsl:text>#define COM_FORWARD_</xsl:text>
740 <xsl:value-of select="$parent/@name"/>
741 <xsl:text>_SETTER_</xsl:text>
742 <xsl:call-template name="capitalize">
743 <xsl:with-param name="str" select="@name"/>
744 </xsl:call-template>
745 <xsl:text>_TO_BASE(base) COM_FORWARD_</xsl:text>
746 <xsl:value-of select="$parent/@name"/>
747 <xsl:text>_SETTER_</xsl:text>
748 <xsl:call-template name="capitalize">
749 <xsl:with-param name="str" select="@name"/>
750 </xsl:call-template>
751 <xsl:text>_TO (base::)&#x0A;</xsl:text>
752 </xsl:if>
753
754 <xsl:apply-templates select="@if" mode="end"/>
755
756</xsl:template>
757
758
759<!--
760 * methods
761-->
762<xsl:template match="interface//method | collection//method">
763 <xsl:apply-templates select="@if" mode="begin"/>
764 <xsl:if test="param/@mod='ptr'">
765 <!-- methods using native types must be non-scriptable
766 <xsl:text> [noscript]&#x0A;</xsl:text>-->
767 </xsl:if>
768 <xsl:text> nsresult (*</xsl:text>
769 <xsl:call-template name="capitalize">
770 <xsl:with-param name="str" select="@name"/>
771 </xsl:call-template>
772 <xsl:if test="param">
773 <xsl:text>)(&#x0A;</xsl:text>
774 <xsl:text> </xsl:text>
775 <xsl:value-of select="../@name" />
776 <xsl:text> *this_, &#x0A;</xsl:text>
777 <xsl:for-each select="param [position() != last()]">
778 <xsl:text> </xsl:text>
779 <xsl:apply-templates select="."/>
780 <xsl:text>,&#x0A;</xsl:text>
781 </xsl:for-each>
782 <xsl:text> </xsl:text>
783 <xsl:apply-templates select="param [last()]"/>
784 <xsl:text>&#x0A; );&#x0A;</xsl:text>
785 </xsl:if>
786 <xsl:if test="not(param)">
787 <xsl:text>)(</xsl:text>
788 <xsl:value-of select="../@name" />
789 <xsl:text> *this_ );&#x0A;</xsl:text>
790 </xsl:if>
791 <xsl:apply-templates select="@if" mode="end"/>
792 <xsl:text>&#x0A;</xsl:text>
793</xsl:template>
794
795<xsl:template match="interface//method | collection//method" mode="forwarder">
796
797 <xsl:variable name="parent" select="ancestor::interface | ancestor::collection"/>
798
799 <xsl:apply-templates select="@if" mode="begin"/>
800
801 <xsl:text>#define COM_FORWARD_</xsl:text>
802 <xsl:value-of select="$parent/@name"/>
803 <xsl:text>_</xsl:text>
804 <xsl:call-template name="capitalize">
805 <xsl:with-param name="str" select="@name"/>
806 </xsl:call-template>
807 <xsl:text>_TO(smth) NS_IMETHOD </xsl:text>
808 <xsl:call-template name="capitalize">
809 <xsl:with-param name="str" select="@name"/>
810 </xsl:call-template>
811 <xsl:choose>
812 <xsl:when test="param">
813 <xsl:text> (</xsl:text>
814 <xsl:for-each select="param [position() != last()]">
815 <xsl:apply-templates select="." mode="forwarder"/>
816 <xsl:text>, </xsl:text>
817 </xsl:for-each>
818 <xsl:apply-templates select="param [last()]" mode="forwarder"/>
819 <xsl:text>) { return smth </xsl:text>
820 <xsl:call-template name="capitalize">
821 <xsl:with-param name="str" select="@name"/>
822 </xsl:call-template>
823 <xsl:text> (</xsl:text>
824 <xsl:for-each select="param [position() != last()]">
825 <xsl:if test="@safearray='yes'">
826 <xsl:text>a</xsl:text>
827 <xsl:call-template name="capitalize">
828 <xsl:with-param name="str" select="@name"/>
829 </xsl:call-template>
830 <xsl:text>Size+++, </xsl:text>
831 </xsl:if>
832 <xsl:text>a</xsl:text>
833 <xsl:call-template name="capitalize">
834 <xsl:with-param name="str" select="@name"/>
835 </xsl:call-template>
836 <xsl:text>, </xsl:text>
837 </xsl:for-each>
838 <xsl:if test="param [last()]/@safearray='yes'">
839 <xsl:text>a</xsl:text>
840 <xsl:call-template name="capitalize">
841 <xsl:with-param name="str" select="param [last()]/@name"/>
842 </xsl:call-template>
843 <xsl:text>Size, </xsl:text>
844 </xsl:if>
845 <xsl:text>a</xsl:text>
846 <xsl:call-template name="capitalize">
847 <xsl:with-param name="str" select="param [last()]/@name"/>
848 </xsl:call-template>
849 <xsl:text>); }</xsl:text>
850 </xsl:when>
851 <xsl:otherwise test="not(param)">
852 <xsl:text>() { return smth </xsl:text>
853 <xsl:call-template name="capitalize">
854 <xsl:with-param name="str" select="@name"/>
855 </xsl:call-template>
856 <xsl:text>(); }</xsl:text>
857 </xsl:otherwise>
858 </xsl:choose>
859 <xsl:text>&#x0A;</xsl:text>
860 <!-- COM_FORWARD_Interface_Method_TO_OBJ(obj) -->
861 <xsl:text>#define COM_FORWARD_</xsl:text>
862 <xsl:value-of select="$parent/@name"/>
863 <xsl:text>_</xsl:text>
864 <xsl:call-template name="capitalize">
865 <xsl:with-param name="str" select="@name"/>
866 </xsl:call-template>
867 <xsl:text>_TO_OBJ(obj) COM_FORWARD_</xsl:text>
868 <xsl:value-of select="$parent/@name"/>
869 <xsl:text>_</xsl:text>
870 <xsl:call-template name="capitalize">
871 <xsl:with-param name="str" select="@name"/>
872 </xsl:call-template>
873 <xsl:text>_TO ((obj)->)&#x0A;</xsl:text>
874 <!-- COM_FORWARD_Interface_Method_TO_BASE(base) -->
875 <xsl:text>#define COM_FORWARD_</xsl:text>
876 <xsl:value-of select="$parent/@name"/>
877 <xsl:text>_</xsl:text>
878 <xsl:call-template name="capitalize">
879 <xsl:with-param name="str" select="@name"/>
880 </xsl:call-template>
881 <xsl:text>_TO_BASE(base) COM_FORWARD_</xsl:text>
882 <xsl:value-of select="$parent/@name"/>
883 <xsl:text>_</xsl:text>
884 <xsl:call-template name="capitalize">
885 <xsl:with-param name="str" select="@name"/>
886 </xsl:call-template>
887 <xsl:text>_TO (base::)&#x0A;</xsl:text>
888
889 <xsl:apply-templates select="@if" mode="end"/>
890
891</xsl:template>
892
893
894<!--
895 * modules
896-->
897<xsl:template match="module">
898 <xsl:apply-templates select="class"/>
899</xsl:template>
900
901
902<!--
903 * co-classes
904-->
905<xsl:template match="module/class">
906 <!-- class and contract id -->
907 <xsl:text>&#x0A;</xsl:text>
908 <xsl:text>#define NS_</xsl:text>
909 <xsl:call-template name="uppercase">
910 <xsl:with-param name="str" select="@name"/>
911 </xsl:call-template>
912 <xsl:text>_CID { \&#x0A;</xsl:text>
913 <xsl:text> 0x</xsl:text><xsl:value-of select="substring(@uuid,1,8)"/>
914 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,10,4)"/>
915 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,15,4)"/>
916 <xsl:text>, \&#x0A; </xsl:text>
917 <xsl:text>{ 0x</xsl:text><xsl:value-of select="substring(@uuid,20,2)"/>
918 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,22,2)"/>
919 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,25,2)"/>
920 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,27,2)"/>
921 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,29,2)"/>
922 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,31,2)"/>
923 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,33,2)"/>
924 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,35,2)"/>
925 <xsl:text> } \&#x0A;}&#x0A;</xsl:text>
926 <xsl:text>#define NS_</xsl:text>
927 <xsl:call-template name="uppercase">
928 <xsl:with-param name="str" select="@name"/>
929 </xsl:call-template>
930 <!-- Contract ID -->
931 <xsl:text>_CONTRACTID &quot;@</xsl:text>
932 <xsl:value-of select="@namespace"/>
933 <xsl:text>/</xsl:text>
934 <xsl:value-of select="@name"/>
935 <xsl:text>;1&quot;&#x0A;</xsl:text>
936 <!-- CLSID_xxx declarations for XPCOM, for compatibility with Win32 -->
937 <xsl:text>/* for compatibility with Win32 */&#x0A;</xsl:text>
938 <xsl:text>#define CLSID_</xsl:text>
939 <xsl:value-of select="@name"/>
940 <xsl:text> (nsCID) NS_</xsl:text>
941 <xsl:call-template name="uppercase">
942 <xsl:with-param name="str" select="@name"/>
943 </xsl:call-template>
944 <xsl:text>_CID&#x0A;</xsl:text>
945 <xsl:text>&#x0A;&#x0A;</xsl:text>
946</xsl:template>
947
948
949<!--
950 * enumerators
951-->
952<xsl:template match="enumerator">
953 <xsl:text>/* Start of struct </xsl:text>
954 <xsl:value-of select="@name"/>
955 <xsl:text> Declaration */&#x0A;</xsl:text>
956 <xsl:text>#define </xsl:text>
957 <xsl:call-template name="uppercase">
958 <xsl:with-param name="str" select="@name"/>
959 </xsl:call-template>
960 <xsl:value-of select="concat('_IID_STR &quot;',@uuid,'&quot;')"/>
961 <xsl:text>&#x0A;</xsl:text>
962 <xsl:text>#define </xsl:text>
963 <xsl:call-template name="uppercase">
964 <xsl:with-param name="str" select="@name"/>
965 </xsl:call-template>
966 <xsl:text>_IID { \&#x0A;</xsl:text>
967 <xsl:text> 0x</xsl:text><xsl:value-of select="substring(@uuid,1,8)"/>
968 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,10,4)"/>
969 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,15,4)"/>
970 <xsl:text>, \&#x0A; </xsl:text>
971 <xsl:text>{ 0x</xsl:text><xsl:value-of select="substring(@uuid,20,2)"/>
972 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,22,2)"/>
973 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,25,2)"/>
974 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,27,2)"/>
975 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,29,2)"/>
976 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,31,2)"/>
977 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,33,2)"/>
978 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,35,2)"/>
979 <xsl:text> } \&#x0A;}&#x0A;</xsl:text>
980 <xsl:text>struct </xsl:text>
981 <xsl:value-of select="@name"/>
982 <xsl:text>_vtbl&#x0A;{&#x0A;</xsl:text>
983 <xsl:text> struct nsISupports_vtbl nsisupports;&#x0A;&#x0A;</xsl:text>
984 <!-- attributes (properties) -->
985 <xsl:text> nsresult (*HasMore)(</xsl:text>
986 <xsl:value-of select="@name" />
987 <xsl:text> *this_, PRBool *more);&#x0A;&#x0A;</xsl:text>
988 <!-- GetNext -->
989 <xsl:text> nsresult (*GetNext)(</xsl:text>
990 <xsl:value-of select="@name" />
991 <xsl:text> *this_, </xsl:text>
992 <xsl:apply-templates select="@type" mode="forwarder"/>
993 <xsl:text> *next);&#x0A;&#x0A;</xsl:text>
994 <xsl:text>};</xsl:text>
995 <xsl:text>&#x0A;&#x0A;</xsl:text>
996 <xsl:text>struct </xsl:text>
997 <xsl:value-of select="@name"/>
998 <xsl:text>&#x0A;{&#x0A; struct </xsl:text>
999 <xsl:value-of select="@name"/>
1000 <xsl:text>_vtbl *vtbl;&#x0A;};&#x0A;</xsl:text>
1001 <xsl:text>/* End of struct </xsl:text>
1002 <xsl:value-of select="@name"/>
1003 <xsl:text> Declaration */&#x0A;&#x0A;&#x0A;</xsl:text>
1004</xsl:template>
1005
1006
1007<!--
1008 * collections
1009-->
1010<xsl:template match="collection">
1011 <xsl:if test="not(@readonly='yes')">
1012 <xsl:message terminate="yes">
1013 <xsl:value-of select="concat(@name,': ')"/>
1014 <xsl:text>non-readonly collections are not currently supported</xsl:text>
1015 </xsl:message>
1016 </xsl:if>
1017 <xsl:text>/* Start of struct </xsl:text>
1018 <xsl:value-of select="@name"/>
1019 <xsl:text> Declaration */&#x0A;</xsl:text>
1020 <xsl:text>#define </xsl:text>
1021 <xsl:call-template name="uppercase">
1022 <xsl:with-param name="str" select="@name"/>
1023 </xsl:call-template>
1024 <xsl:value-of select="concat('_IID_STR &quot;',@uuid,'&quot;')"/>
1025 <xsl:text>&#x0A;</xsl:text>
1026 <xsl:text>#define </xsl:text>
1027 <xsl:call-template name="uppercase">
1028 <xsl:with-param name="str" select="@name"/>
1029 </xsl:call-template>
1030 <xsl:text>_IID { \&#x0A;</xsl:text>
1031 <xsl:text> 0x</xsl:text><xsl:value-of select="substring(@uuid,1,8)"/>
1032 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,10,4)"/>
1033 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,15,4)"/>
1034 <xsl:text>, \&#x0A; </xsl:text>
1035 <xsl:text>{ 0x</xsl:text><xsl:value-of select="substring(@uuid,20,2)"/>
1036 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,22,2)"/>
1037 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,25,2)"/>
1038 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,27,2)"/>
1039 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,29,2)"/>
1040 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,31,2)"/>
1041 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,33,2)"/>
1042 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,35,2)"/>
1043 <xsl:text> } \&#x0A;}&#x0A;</xsl:text>
1044 <xsl:text>struct </xsl:text>
1045 <xsl:value-of select="@name"/>
1046 <xsl:text>_vtbl&#x0A;{&#x0A;</xsl:text>
1047 <xsl:text> struct nsISupports_vtbl nsisupports;&#x0A;&#x0A;</xsl:text>
1048 <!-- Count -->
1049 <xsl:text> nsresult (*GetCount)(</xsl:text>
1050 <xsl:value-of select="@name" />
1051 <xsl:text> *this_, PRUint32 *aCount);&#x0A;&#x0A;</xsl:text>
1052 <!-- GetItemAt -->
1053 <xsl:text> nsresult (*GetItemAt)(</xsl:text>
1054 <xsl:value-of select="@name" />
1055 <xsl:text> *this_, PRUint32 index, </xsl:text>
1056 <xsl:apply-templates select="@type" mode="forwarder"/>
1057 <xsl:text> **item);&#x0A;&#x0A;</xsl:text>
1058 <!-- Enumerate -->
1059 <xsl:text> nsresult (*Enumerate)(</xsl:text>
1060 <xsl:value-of select="@name" />
1061 <xsl:text> *this_, </xsl:text>
1062 <xsl:apply-templates select="@enumerator"/>
1063 <xsl:text> **enumerator);&#x0A;&#x0A;</xsl:text>
1064 <!-- other extra attributes (properties) -->
1065 <xsl:apply-templates select="attribute"/>
1066 <!-- other extra methods -->
1067 <xsl:apply-templates select="method"/>
1068 <!-- 'if' enclosed elements, unsorted -->
1069 <xsl:apply-templates select="if"/>
1070 <xsl:text>};</xsl:text>
1071 <xsl:text>&#x0A;&#x0A;</xsl:text>
1072 <xsl:text>struct </xsl:text>
1073 <xsl:value-of select="@name"/>
1074 <xsl:text>&#x0A;{&#x0A; struct </xsl:text>
1075 <xsl:value-of select="@name"/>
1076 <xsl:text>_vtbl *vtbl;&#x0A;};&#x0A;</xsl:text>
1077 <xsl:text>/* End of struct </xsl:text>
1078 <xsl:value-of select="@name"/>
1079 <xsl:text> Declaration */&#x0A;&#x0A;&#x0A;</xsl:text>
1080</xsl:template>
1081
1082
1083<!--
1084 * enums
1085-->
1086<xsl:template match="enum">
1087 <xsl:text>/* Start of enum </xsl:text>
1088 <xsl:value-of select="@name"/>
1089 <xsl:text> Declaration */&#x0A;</xsl:text>
1090 <xsl:text>#define </xsl:text>
1091 <xsl:call-template name="uppercase">
1092 <xsl:with-param name="str" select="@name"/>
1093 </xsl:call-template>
1094 <xsl:value-of select="concat('_IID_STR &quot;',@uuid,'&quot;')"/>
1095 <xsl:text>&#x0A;</xsl:text>
1096 <xsl:text>#define </xsl:text>
1097 <xsl:call-template name="uppercase">
1098 <xsl:with-param name="str" select="@name"/>
1099 </xsl:call-template>
1100 <xsl:text>_IID { \&#x0A;</xsl:text>
1101 <xsl:text> 0x</xsl:text><xsl:value-of select="substring(@uuid,1,8)"/>
1102 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,10,4)"/>
1103 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,15,4)"/>
1104 <xsl:text>, \&#x0A; </xsl:text>
1105 <xsl:text>{ 0x</xsl:text><xsl:value-of select="substring(@uuid,20,2)"/>
1106 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,22,2)"/>
1107 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,25,2)"/>
1108 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,27,2)"/>
1109 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,29,2)"/>
1110 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,31,2)"/>
1111 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,33,2)"/>
1112 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,35,2)"/>
1113 <xsl:text> } \&#x0A;}&#x0A;</xsl:text>
1114 <xsl:text>enum </xsl:text>
1115 <xsl:value-of select="@name"/>
1116 <xsl:text>&#x0A;{&#x0A;</xsl:text>
1117 <xsl:variable name="this" select="."/>
1118 <xsl:for-each select="const">
1119 <xsl:text> </xsl:text>
1120 <xsl:value-of select="$this/@name"/>
1121 <xsl:text>_</xsl:text>
1122 <xsl:value-of select="@name"/> = <xsl:value-of select="@value"/>
1123 <xsl:if test="position() != last()">
1124 <xsl:text>,</xsl:text>
1125 </xsl:if>
1126 <xsl:text>&#x0A;</xsl:text>
1127 </xsl:for-each>
1128 <xsl:text>};&#x0A;</xsl:text>
1129 <xsl:text>/* End of enum </xsl:text>
1130 <xsl:value-of select="@name"/>
1131 <xsl:text> Declaration */&#x0A;&#x0A;&#x0A;</xsl:text>
1132</xsl:template>
1133
1134
1135<!--
1136 * method parameters
1137-->
1138<xsl:template match="method/param">
1139 <xsl:choose>
1140 <!-- safearray parameters -->
1141 <xsl:when test="@safearray='yes'">
1142 <!-- array size -->
1143 <xsl:choose>
1144 <xsl:when test="@dir='in'">
1145 <xsl:text>PRUint32 </xsl:text>
1146 <xsl:value-of select="@name"/>
1147 <xsl:text>Size,&#x0A;</xsl:text>
1148 </xsl:when>
1149 <xsl:when test="@dir='out'">
1150 <xsl:text>PRUint32 *</xsl:text>
1151 <xsl:value-of select="@name"/>
1152 <xsl:text>Size,&#x0A;</xsl:text>
1153 </xsl:when>
1154 <xsl:when test="@dir='return'">
1155 <xsl:text>PRUint32 *</xsl:text>
1156 <xsl:value-of select="@name"/>
1157 <xsl:text>Size,&#x0A;</xsl:text>
1158 </xsl:when>
1159 <xsl:otherwise>
1160 <xsl:text>PRUint32 </xsl:text>
1161 <xsl:value-of select="@name"/>
1162 <xsl:text>Size,&#x0A;</xsl:text>
1163 </xsl:otherwise>
1164 </xsl:choose>
1165 <!-- array pointer -->
1166 <xsl:text> </xsl:text>
1167 <xsl:choose>
1168 <xsl:when test="@dir='in'">
1169 <xsl:apply-templates select="@type" mode="forwarder"/>
1170 <xsl:text>*</xsl:text>
1171 </xsl:when>
1172 <xsl:when test="@dir='out'">
1173 <xsl:apply-templates select="@type" mode="forwarder"/>
1174 <xsl:if test="@type='wstring'">
1175 <xsl:text>*</xsl:text>
1176 </xsl:if>
1177 <xsl:text>*</xsl:text>
1178 </xsl:when>
1179 <xsl:when test="@dir='return'">
1180 <xsl:apply-templates select="@type" mode="forwarder"/>
1181 <xsl:text>**</xsl:text>
1182 </xsl:when>
1183 <xsl:otherwise>
1184 <xsl:apply-templates select="@type" mode="forwarder"/>
1185 <xsl:text>*</xsl:text>
1186 </xsl:otherwise>
1187 </xsl:choose>
1188 <xsl:text> </xsl:text>
1189 <xsl:value-of select="@name"/>
1190 </xsl:when>
1191 <!-- normal and array parameters -->
1192 <xsl:otherwise>
1193 <xsl:if test="@array">
1194 <xsl:if test="@dir='return'">
1195 <xsl:message terminate="yes">
1196 <xsl:value-of select="concat(../../@name,'::',../@name,'::',@name,': ')"/>
1197 <xsl:text>return 'array' parameters are not supported, use 'safearray="yes"' instead.</xsl:text>
1198 </xsl:message>
1199 </xsl:if>
1200 <xsl:text>[array, </xsl:text>
1201 <xsl:choose>
1202 <xsl:when test="../param[@name=current()/@array]">
1203 <xsl:if test="../param[@name=current()/@array]/@dir != @dir">
1204 <xsl:message terminate="yes">
1205 <xsl:value-of select="concat(../../@name,'::',../@name,': ')"/>
1206 <xsl:value-of select="concat(@name,' and ',../param[@name=current()/@array]/@name)"/>
1207 <xsl:text> must have the same direction</xsl:text>
1208 </xsl:message>
1209 </xsl:if>
1210 <xsl:text>size_is(</xsl:text>
1211 <xsl:value-of select="@array"/>
1212 <xsl:text>)</xsl:text>
1213 </xsl:when>
1214 <xsl:otherwise>
1215 <xsl:message terminate="yes">
1216 <xsl:value-of select="concat(../../@name,'::',../@name,'::',@name,': ')"/>
1217 <xsl:text>array attribute refers to non-existent param: </xsl:text>
1218 <xsl:value-of select="@array"/>
1219 </xsl:message>
1220 </xsl:otherwise>
1221 </xsl:choose>
1222 <xsl:text>] </xsl:text>
1223 </xsl:if>
1224 <xsl:choose>
1225 <xsl:when test="@dir='in'">
1226 <xsl:apply-templates select="@type" mode="forwarder"/>
1227 <xsl:text></xsl:text>
1228 </xsl:when>
1229 <xsl:when test="@dir='out'">
1230 <xsl:apply-templates select="@type" mode="forwarder"/>
1231 <xsl:text> *</xsl:text>
1232 </xsl:when>
1233 <xsl:when test="@dir='return'">
1234 <xsl:apply-templates select="@type" mode="forwarder"/>
1235 <xsl:text> *</xsl:text>
1236 </xsl:when>
1237 <xsl:otherwise>
1238 <xsl:apply-templates select="@type" mode="forwarder"/>
1239 <xsl:text></xsl:text>
1240 </xsl:otherwise>
1241 </xsl:choose>
1242 <xsl:text> </xsl:text>
1243 <xsl:value-of select="@name"/>
1244 </xsl:otherwise>
1245 </xsl:choose>
1246</xsl:template>
1247
1248<xsl:template match="method/param" mode="forwarder">
1249 <xsl:if test="@safearray='yes'">
1250 <xsl:text>PRUint32</xsl:text>
1251 <xsl:if test="@dir='out' or @dir='return'">
1252 <xsl:text> *</xsl:text>
1253 </xsl:if>
1254 <xsl:text> a</xsl:text>
1255 <xsl:call-template name="capitalize">
1256 <xsl:with-param name="str" select="@name"/>
1257 </xsl:call-template>
1258 <xsl:text>Size, </xsl:text>
1259 </xsl:if>
1260 <xsl:apply-templates select="@type" mode="forwarder"/>
1261 <xsl:if test="@dir='out' or @dir='return'">
1262 <xsl:text> *</xsl:text>
1263 </xsl:if>
1264 <xsl:if test="@safearray='yes'">
1265 <xsl:text> *</xsl:text>
1266 </xsl:if>
1267 <xsl:text> a</xsl:text>
1268 <xsl:call-template name="capitalize">
1269 <xsl:with-param name="str" select="@name"/>
1270 </xsl:call-template>
1271</xsl:template>
1272
1273
1274<!--
1275 * attribute/parameter type conversion
1276-->
1277<xsl:template match="
1278 attribute/@type | param/@type |
1279 enumerator/@type | collection/@type | collection/@enumerator
1280">
1281 <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
1282
1283 <xsl:if test="../@array and ../@safearray='yes'">
1284 <xsl:message terminate="yes">
1285 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
1286 <xsl:text>either 'array' or 'safearray="yes"' attribute is allowed, but not both!</xsl:text>
1287 </xsl:message>
1288 </xsl:if>
1289
1290 <xsl:choose>
1291 <!-- modifiers (ignored for 'enumeration' attributes)-->
1292 <xsl:when test="name(current())='type' and ../@mod">
1293 <xsl:choose>
1294 <xsl:when test="../@mod='ptr'">
1295 <xsl:choose>
1296 <!-- standard types -->
1297 <!--xsl:when test=".='result'">??</xsl:when-->
1298 <xsl:when test=".='boolean'">booleanPtr</xsl:when>
1299 <xsl:when test=".='octet'">octetPtr</xsl:when>
1300 <xsl:when test=".='short'">shortPtr</xsl:when>
1301 <xsl:when test=".='unsigned short'">ushortPtr</xsl:when>
1302 <xsl:when test=".='long'">longPtr</xsl:when>
1303 <xsl:when test=".='long long'">llongPtr</xsl:when>
1304 <xsl:when test=".='unsigned long'">ulongPtr</xsl:when>
1305 <xsl:when test=".='unsigned long long'">ullongPtr</xsl:when>
1306 <xsl:when test=".='char'">charPtr</xsl:when>
1307 <!--xsl:when test=".='string'">??</xsl:when-->
1308 <xsl:when test=".='wchar'">wcharPtr</xsl:when>
1309 <!--xsl:when test=".='wstring'">??</xsl:when-->
1310 <xsl:otherwise>
1311 <xsl:message terminate="yes">
1312 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
1313 <xsl:text>attribute 'mod=</xsl:text>
1314 <xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
1315 <xsl:text>' cannot be used with type </xsl:text>
1316 <xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
1317 </xsl:message>
1318 </xsl:otherwise>
1319 </xsl:choose>
1320 </xsl:when>
1321 <xsl:otherwise>
1322 <xsl:message terminate="yes">
1323 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
1324 <xsl:value-of select="concat('value &quot;',../@mod,'&quot; ')"/>
1325 <xsl:text>of attribute 'mod' is invalid!</xsl:text>
1326 </xsl:message>
1327 </xsl:otherwise>
1328 </xsl:choose>
1329 </xsl:when>
1330 <!-- no modifiers -->
1331 <xsl:otherwise>
1332 <xsl:choose>
1333 <!-- standard types -->
1334 <xsl:when test=".='result'">nsresult</xsl:when>
1335 <xsl:when test=".='boolean'">boolean</xsl:when>
1336 <xsl:when test=".='octet'">octet</xsl:when>
1337 <xsl:when test=".='short'">short</xsl:when>
1338 <xsl:when test=".='unsigned short'">unsigned short</xsl:when>
1339 <xsl:when test=".='long'">long</xsl:when>
1340 <xsl:when test=".='long long'">long long</xsl:when>
1341 <xsl:when test=".='unsigned long'">unsigned long</xsl:when>
1342 <xsl:when test=".='unsigned long long'">unsigned long long</xsl:when>
1343 <xsl:when test=".='char'">char</xsl:when>
1344 <xsl:when test=".='wchar'">wchar</xsl:when>
1345 <xsl:when test=".='string'">string</xsl:when>
1346 <xsl:when test=".='wstring'">wstring</xsl:when>
1347 <!-- UUID type -->
1348 <xsl:when test=".='uuid'">
1349 <xsl:choose>
1350 <xsl:when test="name(..)='attribute'">
1351 <xsl:choose>
1352 <xsl:when test="../@readonly='yes'">
1353 <xsl:text>nsIDPtr</xsl:text>
1354 </xsl:when>
1355 <xsl:otherwise>
1356 <xsl:message terminate="yes">
1357 <xsl:value-of select="../@name"/>
1358 <xsl:text>: Non-readonly uuid attributes are not supported!</xsl:text>
1359 </xsl:message>
1360 </xsl:otherwise>
1361 </xsl:choose>
1362 </xsl:when>
1363 <xsl:when test="name(..)='param'">
1364 <xsl:choose>
1365 <xsl:when test="../@dir='in' and not(../@safearray='yes')">
1366 <xsl:text>nsIDRef</xsl:text>
1367 </xsl:when>
1368 <xsl:otherwise>
1369 <xsl:text>nsIDPtr</xsl:text>
1370 </xsl:otherwise>
1371 </xsl:choose>
1372 </xsl:when>
1373 </xsl:choose>
1374 </xsl:when>
1375 <!-- system interface types -->
1376 <xsl:when test=".='$unknown'">nsISupports</xsl:when>
1377 <xsl:otherwise>
1378 <xsl:choose>
1379 <!-- enum types -->
1380 <xsl:when test="
1381 (ancestor::library/enum[@name=current()]) or
1382 (ancestor::library/if[@target=$self_target]/enum[@name=current()])
1383 ">
1384 <xsl:text>PRUint32</xsl:text>
1385 </xsl:when>
1386 <!-- custom interface types -->
1387 <xsl:when test="
1388 (name(current())='enumerator' and
1389 ((ancestor::library/enumerator[@name=current()]) or
1390 (ancestor::library/if[@target=$self_target]/enumerator[@name=current()]))
1391 ) or
1392 ((ancestor::library/interface[@name=current()]) or
1393 (ancestor::library/if[@target=$self_target]/interface[@name=current()])
1394 ) or
1395 ((ancestor::library/collection[@name=current()]) or
1396 (ancestor::library/if[@target=$self_target]/collection[@name=current()])
1397 )
1398 ">
1399 <xsl:value-of select="."/>
1400 </xsl:when>
1401 <!-- other types -->
1402 <xsl:otherwise>
1403 <xsl:message terminate="yes">
1404 <xsl:text>Unknown parameter type: </xsl:text>
1405 <xsl:value-of select="."/>
1406 </xsl:message>
1407 </xsl:otherwise>
1408 </xsl:choose>
1409 </xsl:otherwise>
1410 </xsl:choose>
1411 </xsl:otherwise>
1412 </xsl:choose>
1413</xsl:template>
1414
1415<xsl:template match="
1416 attribute/@type | param/@type |
1417 enumerator/@type | collection/@type | collection/@enumerator
1418" mode="forwarder">
1419
1420 <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
1421
1422 <xsl:choose>
1423 <!-- modifiers (ignored for 'enumeration' attributes)-->
1424 <xsl:when test="name(current())='type' and ../@mod">
1425 <xsl:choose>
1426 <xsl:when test="../@mod='ptr'">
1427 <xsl:choose>
1428 <!-- standard types -->
1429 <!--xsl:when test=".='result'">??</xsl:when-->
1430 <xsl:when test=".='boolean'">PRBool *</xsl:when>
1431 <xsl:when test=".='octet'">PRUint8 *</xsl:when>
1432 <xsl:when test=".='short'">PRInt16 *</xsl:when>
1433 <xsl:when test=".='unsigned short'">PRUint16 *</xsl:when>
1434 <xsl:when test=".='long'">PRInt32 *</xsl:when>
1435 <xsl:when test=".='long long'">PRInt64 *</xsl:when>
1436 <xsl:when test=".='unsigned long'">PRUint32 *</xsl:when>
1437 <xsl:when test=".='unsigned long long'">PRUint64 *</xsl:when>
1438 <xsl:when test=".='char'">char *</xsl:when>
1439 <!--xsl:when test=".='string'">??</xsl:when-->
1440 <xsl:when test=".='wchar'">PRUnichar *</xsl:when>
1441 <!--xsl:when test=".='wstring'">??</xsl:when-->
1442 </xsl:choose>
1443 </xsl:when>
1444 </xsl:choose>
1445 </xsl:when>
1446 <!-- no modifiers -->
1447 <xsl:otherwise>
1448 <xsl:choose>
1449 <!-- standard types -->
1450 <xsl:when test=".='result'">nsresult</xsl:when>
1451 <xsl:when test=".='boolean'">PRBool</xsl:when>
1452 <xsl:when test=".='octet'">PRUint8</xsl:when>
1453 <xsl:when test=".='short'">PRInt16</xsl:when>
1454 <xsl:when test=".='unsigned short'">PRUint16</xsl:when>
1455 <xsl:when test=".='long'">PRInt32</xsl:when>
1456 <xsl:when test=".='long long'">PRInt64</xsl:when>
1457 <xsl:when test=".='unsigned long'">PRUint32</xsl:when>
1458 <xsl:when test=".='unsigned long long'">PRUint64</xsl:when>
1459 <xsl:when test=".='char'">char</xsl:when>
1460 <xsl:when test=".='wchar'">PRUnichar</xsl:when>
1461 <!-- string types -->
1462 <xsl:when test=".='string'">char *</xsl:when>
1463 <xsl:when test=".='wstring'">PRUnichar *</xsl:when>
1464 <!-- UUID type -->
1465 <xsl:when test=".='uuid'">
1466 <xsl:choose>
1467 <xsl:when test="name(..)='attribute'">
1468 <xsl:choose>
1469 <xsl:when test="../@readonly='yes'">
1470 <xsl:text>nsID *</xsl:text>
1471 </xsl:when>
1472 </xsl:choose>
1473 </xsl:when>
1474 <xsl:when test="name(..)='param'">
1475 <xsl:choose>
1476 <xsl:when test="../@dir='in' and not(../@safearray='yes')">
1477 <xsl:text>const nsID *</xsl:text>
1478 </xsl:when>
1479 <xsl:otherwise>
1480 <xsl:text>nsID *</xsl:text>
1481 </xsl:otherwise>
1482 </xsl:choose>
1483 </xsl:when>
1484 </xsl:choose>
1485 </xsl:when>
1486 <!-- system interface types -->
1487 <xsl:when test=".='$unknown'">nsISupports *</xsl:when>
1488 <xsl:otherwise>
1489 <xsl:choose>
1490 <!-- enum types -->
1491 <xsl:when test="
1492 (ancestor::library/enum[@name=current()]) or
1493 (ancestor::library/if[@target=$self_target]/enum[@name=current()])
1494 ">
1495 <xsl:text>PRUint32</xsl:text>
1496 </xsl:when>
1497 <!-- custom interface types -->
1498 <xsl:when test="
1499 (name(current())='enumerator' and
1500 ((ancestor::library/enumerator[@name=current()]) or
1501 (ancestor::library/if[@target=$self_target]/enumerator[@name=current()]))
1502 ) or
1503 ((ancestor::library/interface[@name=current()]) or
1504 (ancestor::library/if[@target=$self_target]/interface[@name=current()])
1505 ) or
1506 ((ancestor::library/collection[@name=current()]) or
1507 (ancestor::library/if[@target=$self_target]/collection[@name=current()])
1508 )
1509 ">
1510 <xsl:value-of select="."/>
1511 <xsl:text> *</xsl:text>
1512 </xsl:when>
1513 <!-- other types -->
1514 </xsl:choose>
1515 </xsl:otherwise>
1516 </xsl:choose>
1517 </xsl:otherwise>
1518 </xsl:choose>
1519</xsl:template>
1520
1521</xsl:stylesheet>
1522
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