VirtualBox

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

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

Cbinding: Updated the VBoxXPCOMC.cpp so that only one function
namely VBoxGetXPCOMCFunctions(VBOX_XPCOMC_VERSION) is exported
and rest are accessed through a function table. Updated the
respective example as well.

  • Property svn:eol-style set to native
File size: 62.5 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#ifndef ___VirtualBox_CXPCOM_h
118#define ___VirtualBox_CXPCOM_h
119
120#ifdef __cplusplus
121# include "VirtualBox_XPCOM.h"
122#else /* !__cplusplus */
123
124#include &lt;stddef.h&gt;
125#include "wchar.h"
126
127#if defined(WIN32)
128
129#define PR_EXPORT(__type) extern __declspec(dllexport) __type
130#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
131#define PR_IMPORT(__type) __declspec(dllimport) __type
132#define PR_IMPORT_DATA(__type) __declspec(dllimport) __type
133
134#define PR_EXTERN(__type) extern __declspec(dllexport) __type
135#define PR_IMPLEMENT(__type) __declspec(dllexport) __type
136#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
137#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
138
139#define PR_CALLBACK
140#define PR_CALLBACK_DECL
141#define PR_STATIC_CALLBACK(__x) static __x
142
143#elif defined(XP_BEOS)
144
145#define PR_EXPORT(__type) extern __declspec(dllexport) __type
146#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
147#define PR_IMPORT(__type) extern __declspec(dllexport) __type
148#define PR_IMPORT_DATA(__type) extern __declspec(dllexport) __type
149
150#define PR_EXTERN(__type) extern __declspec(dllexport) __type
151#define PR_IMPLEMENT(__type) __declspec(dllexport) __type
152#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
153#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
154
155#define PR_CALLBACK
156#define PR_CALLBACK_DECL
157#define PR_STATIC_CALLBACK(__x) static __x
158
159#elif defined(WIN16)
160
161#define PR_CALLBACK_DECL __cdecl
162
163#if defined(_WINDLL)
164#define PR_EXPORT(__type) extern __type _cdecl _export _loadds
165#define PR_IMPORT(__type) extern __type _cdecl _export _loadds
166#define PR_EXPORT_DATA(__type) extern __type _export
167#define PR_IMPORT_DATA(__type) extern __type _export
168
169#define PR_EXTERN(__type) extern __type _cdecl _export _loadds
170#define PR_IMPLEMENT(__type) __type _cdecl _export _loadds
171#define PR_EXTERN_DATA(__type) extern __type _export
172#define PR_IMPLEMENT_DATA(__type) __type _export
173
174#define PR_CALLBACK __cdecl __loadds
175#define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK
176
177#else /* this must be .EXE */
178#define PR_EXPORT(__type) extern __type _cdecl _export
179#define PR_IMPORT(__type) extern __type _cdecl _export
180#define PR_EXPORT_DATA(__type) extern __type _export
181#define PR_IMPORT_DATA(__type) extern __type _export
182
183#define PR_EXTERN(__type) extern __type _cdecl _export
184#define PR_IMPLEMENT(__type) __type _cdecl _export
185#define PR_EXTERN_DATA(__type) extern __type _export
186#define PR_IMPLEMENT_DATA(__type) __type _export
187
188#define PR_CALLBACK __cdecl __loadds
189#define PR_STATIC_CALLBACK(__x) __x PR_CALLBACK
190#endif /* _WINDLL */
191
192#elif defined(XP_MAC)
193
194#define PR_EXPORT(__type) extern __declspec(export) __type
195#define PR_EXPORT_DATA(__type) extern __declspec(export) __type
196#define PR_IMPORT(__type) extern __declspec(export) __type
197#define PR_IMPORT_DATA(__type) extern __declspec(export) __type
198
199#define PR_EXTERN(__type) extern __declspec(export) __type
200#define PR_IMPLEMENT(__type) __declspec(export) __type
201#define PR_EXTERN_DATA(__type) extern __declspec(export) __type
202#define PR_IMPLEMENT_DATA(__type) __declspec(export) __type
203
204#define PR_CALLBACK
205#define PR_CALLBACK_DECL
206#define PR_STATIC_CALLBACK(__x) static __x
207
208#elif defined(XP_OS2) &amp;&amp; defined(__declspec)
209
210#define PR_EXPORT(__type) extern __declspec(dllexport) __type
211#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
212#define PR_IMPORT(__type) __declspec(dllimport) __type
213#define PR_IMPORT_DATA(__type) __declspec(dllimport) __type
214
215#define PR_EXTERN(__type) extern __declspec(dllexport) __type
216#define PR_IMPLEMENT(__type) __declspec(dllexport) __type
217#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
218#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
219
220#define PR_CALLBACK
221#define PR_CALLBACK_DECL
222#define PR_STATIC_CALLBACK(__x) static __x
223
224#elif defined(XP_OS2_VACPP)
225
226#define PR_EXPORT(__type) extern __type
227#define PR_EXPORT_DATA(__type) extern __type
228#define PR_IMPORT(__type) extern __type
229#define PR_IMPORT_DATA(__type) extern __type
230
231#define PR_EXTERN(__type) extern __type
232#define PR_IMPLEMENT(__type) __type
233#define PR_EXTERN_DATA(__type) extern __type
234#define PR_IMPLEMENT_DATA(__type) __type
235#define PR_CALLBACK _Optlink
236#define PR_CALLBACK_DECL
237#define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK
238
239#else /* Unix */
240
241# ifdef VBOX_HAVE_VISIBILITY_HIDDEN
242# define PR_EXPORT(__type) __attribute__((visibility("default"))) extern __type
243# define PR_EXPORT_DATA(__type) __attribute__((visibility("default"))) extern __type
244# define PR_IMPORT(__type) extern __type
245# define PR_IMPORT_DATA(__type) extern __type
246# define PR_EXTERN(__type) __attribute__((visibility("default"))) extern __type
247# define PR_IMPLEMENT(__type) __attribute__((visibility("default"))) __type
248# define PR_EXTERN_DATA(__type) __attribute__((visibility("default"))) extern __type
249# define PR_IMPLEMENT_DATA(__type) __attribute__((visibility("default"))) __type
250# define PR_CALLBACK
251# define PR_CALLBACK_DECL
252# define PR_STATIC_CALLBACK(__x) static __x
253# else
254# define PR_EXPORT(__type) extern __type
255# define PR_EXPORT_DATA(__type) extern __type
256# define PR_IMPORT(__type) extern __type
257# define PR_IMPORT_DATA(__type) extern __type
258# define PR_EXTERN(__type) extern __type
259# define PR_IMPLEMENT(__type) __type
260# define PR_EXTERN_DATA(__type) extern __type
261# define PR_IMPLEMENT_DATA(__type) __type
262# define PR_CALLBACK
263# define PR_CALLBACK_DECL
264# define PR_STATIC_CALLBACK(__x) static __x
265# endif
266#endif
267
268#if defined(_NSPR_BUILD_)
269#define NSPR_API(__type) PR_EXPORT(__type)
270#define NSPR_DATA_API(__type) PR_EXPORT_DATA(__type)
271#else
272#define NSPR_API(__type) PR_IMPORT(__type)
273#define NSPR_DATA_API(__type) PR_IMPORT_DATA(__type)
274#endif
275
276typedef unsigned char PRUint8;
277#if (defined(HPUX) &amp;&amp; defined(__cplusplus) \
278 &amp;&amp; !defined(__GNUC__) &amp;&amp; __cplusplus &lt; 199707L) \
279 || (defined(SCO) &amp;&amp; defined(__cplusplus) \
280 &amp;&amp; !defined(__GNUC__) &amp;&amp; __cplusplus == 1L)
281typedef char PRInt8;
282#else
283typedef signed char PRInt8;
284#endif
285
286#define PR_INT8_MAX 127
287#define PR_INT8_MIN (-128)
288#define PR_UINT8_MAX 255U
289
290typedef unsigned short PRUint16;
291typedef short PRInt16;
292
293#define PR_INT16_MAX 32767
294#define PR_INT16_MIN (-32768)
295#define PR_UINT16_MAX 65535U
296
297typedef unsigned int PRUint32;
298typedef int PRInt32;
299#define PR_INT32(x) x
300#define PR_UINT32(x) x ## U
301
302#define PR_INT32_MAX PR_INT32(2147483647)
303#define PR_INT32_MIN (-PR_INT32_MAX - 1)
304#define PR_UINT32_MAX PR_UINT32(4294967295)
305
306typedef long PRInt64;
307typedef unsigned long PRUint64;
308typedef int PRIntn;
309typedef unsigned int PRUintn;
310
311typedef double PRFloat64;
312typedef size_t PRSize;
313
314typedef ptrdiff_t PRPtrdiff;
315
316typedef unsigned long PRUptrdiff;
317
318typedef PRIntn PRBool;
319
320#define PR_TRUE 1
321#define PR_FALSE 0
322
323typedef PRUint8 PRPackedBool;
324
325/*
326** Status code used by some routines that have a single point of failure or
327** special status return.
328*/
329typedef enum { PR_FAILURE = -1, PR_SUCCESS = 0 } PRStatus;
330
331#ifndef __PRUNICHAR__
332#define __PRUNICHAR__
333#if defined(WIN32) || defined(XP_MAC)
334typedef wchar_t PRUnichar;
335#else
336typedef PRUint16 PRUnichar;
337#endif
338#endif
339
340typedef long PRWord;
341typedef unsigned long PRUword;
342
343#define nsnull 0
344typedef PRUint32 nsresult;
345
346#if defined(__GNUC__) &amp;&amp; (__GNUC__ > 2)
347#define NS_LIKELY(x) (__builtin_expect((x), 1))
348#define NS_UNLIKELY(x) (__builtin_expect((x), 0))
349#else
350#define NS_LIKELY(x) (x)
351#define NS_UNLIKELY(x) (x)
352#endif
353
354#define NS_FAILED(_nsresult) (NS_UNLIKELY((_nsresult) &amp; 0x80000000))
355#define NS_SUCCEEDED(_nsresult) (NS_LIKELY(!((_nsresult) &amp; 0x80000000)))
356
357/**
358 * An "interface id" which can be used to uniquely identify a given
359 * interface.
360 * A "unique identifier". This is modeled after OSF DCE UUIDs.
361 */
362
363struct nsID {
364 PRUint32 m0;
365 PRUint16 m1;
366 PRUint16 m2;
367 PRUint8 m3[8];
368};
369
370typedef struct nsID nsID;
371typedef nsID nsIID;
372
373struct nsISupports; /* forward declaration */
374struct nsIStackFrame; /* forward declaration */
375struct nsIException; /* forward declaration */
376typedef struct nsISupports nsISupports; /* forward declaration */
377typedef struct nsIStackFrame nsIStackFrame; /* forward declaration */
378typedef struct nsIException nsIException; /* forward declaration */
379
380/**
381 * IID for the nsISupports interface
382 * {00000000-0000-0000-c000-000000000046}
383 *
384 * To maintain binary compatibility with COM's IUnknown, we define the IID
385 * of nsISupports to be the same as that of COM's IUnknown.
386 */
387#define NS_ISUPPORTS_IID \
388 { 0x00000000, 0x0000, 0x0000, \
389 {0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} }
390
391/**
392 * Reference count values
393 *
394 * This is the return type for AddRef() and Release() in nsISupports.
395 * IUnknown of COM returns an unsigned long from equivalent functions.
396 * The following ifdef exists to maintain binary compatibility with
397 * IUnknown.
398 */
399
400/**
401 * Basic component object model interface. Objects which implement
402 * this interface support runtime interface discovery (QueryInterface)
403 * and a reference counted memory model (AddRef/Release). This is
404 * modelled after the win32 IUnknown API.
405 */
406struct nsISupports_vtbl {
407
408 /**
409 * @name Methods
410 */
411
412 /**
413 * A run time mechanism for interface discovery.
414 * @param aIID [in] A requested interface IID
415 * @param aInstancePtr [out] A pointer to an interface pointer to
416 * receive the result.
417 * @return NS_OK if the interface is supported by the associated
418 * instance, NS_NOINTERFACE if it is not.
419 * NS_ERROR_INVALID_POINTER if aInstancePtr is NULL.
420 */
421 nsresult (*QueryInterface)(nsISupports *this_, const nsID *iid, void **resultp);
422 /**
423 * Increases the reference count for this interface.
424 * The associated instance will not be deleted unless
425 * the reference count is returned to zero.
426 *
427 * @return The resulting reference count.
428 */
429 nsresult (*AddRef)(nsISupports *this_);
430
431 /**
432 * Decreases the reference count for this interface.
433 * Generally, if the reference count returns to zero,
434 * the associated instance is deleted.
435 *
436 * @return The resulting reference count.
437 */
438 nsresult (*Release)(nsISupports *this_);
439
440};
441
442struct nsISupports {
443 struct nsISupports_vtbl *vtbl;
444};
445
446/* starting interface: nsIException */
447#define NS_IEXCEPTION_IID_STR "f3a8d3b4-c424-4edc-8bf6-8974c983ba78"
448
449#define NS_IEXCEPTION_IID \
450 {0xf3a8d3b4, 0xc424, 0x4edc, \
451 { 0x8b, 0xf6, 0x89, 0x74, 0xc9, 0x83, 0xba, 0x78 }}
452
453struct nsIException_vtbl {
454
455 /* Methods from the Class nsISupports */
456 struct nsISupports_vtbl nsisupports;
457
458 /* readonly attribute string message; */
459 nsresult (*GetMessage)(nsIException *this_, PRUnichar * *aMessage);
460
461 /* readonly attribute nsresult (*result; */
462 nsresult (*GetResult)(nsIException *this_, nsresult *aResult);
463
464 /* readonly attribute string name; */
465 nsresult (*GetName)(nsIException *this_, PRUnichar * *aName);
466
467 /* readonly attribute string filename; */
468 nsresult (*GetFilename)(nsIException *this_, PRUnichar * *aFilename);
469
470 /* readonly attribute PRUint32 lineNumber; */
471 nsresult (*GetLineNumber)(nsIException *this_, PRUint32 *aLineNumber);
472
473 /* readonly attribute PRUint32 columnNumber; */
474 nsresult (*GetColumnNumber)(nsIException *this_, PRUint32 *aColumnNumber);
475
476 /* readonly attribute nsIStackFrame location; */
477 nsresult (*GetLocation)(nsIException *this_, nsIStackFrame * *aLocation);
478
479 /* readonly attribute nsIException inner; */
480 nsresult (*GetInner)(nsIException *this_, nsIException * *aInner);
481
482 /* readonly attribute nsISupports data; */
483 nsresult (*GetData)(nsIException *this_, nsISupports * *aData);
484
485 /* string toString (); */
486 nsresult (*ToString)(nsIException *this_, PRUnichar **_retval);
487};
488
489struct nsIException {
490 struct nsIException_vtbl *vtbl;
491};
492
493/* starting interface: nsIStackFrame */
494#define NS_ISTACKFRAME_IID_STR "91d82105-7c62-4f8b-9779-154277c0ee90"
495
496#define NS_ISTACKFRAME_IID \
497 {0x91d82105, 0x7c62, 0x4f8b, \
498 { 0x97, 0x79, 0x15, 0x42, 0x77, 0xc0, 0xee, 0x90 }}
499
500struct nsIStackFrame_vtbl {
501
502 /* Methods from the Class nsISupports */
503 struct nsISupports_vtbl nsisupports;
504
505 /* readonly attribute PRUint32 language; */
506 nsresult (*GetLanguage)(nsIStackFrame *this_, PRUint32 *aLanguage);
507
508 /* readonly attribute string languageName; */
509 nsresult (*GetLanguageName)(nsIStackFrame *this_, PRUnichar * *aLanguageName);
510
511 /* readonly attribute string filename; */
512 nsresult (*GetFilename)(nsIStackFrame *this_, PRUnichar * *aFilename);
513
514 /* readonly attribute string name; */
515 nsresult (*GetName)(nsIStackFrame *this_, PRUnichar * *aName);
516
517 /* readonly attribute PRInt32 lineNumber; */
518 nsresult (*GetLineNumber)(nsIStackFrame *this_, PRInt32 *aLineNumber);
519
520 /* readonly attribute string sourceLine; */
521 nsresult (*GetSourceLine)(nsIStackFrame *this_, PRUnichar * *aSourceLine);
522
523 /* readonly attribute nsIStackFrame caller; */
524 nsresult (*GetCaller)(nsIStackFrame *this_, nsIStackFrame * *aCaller);
525
526 /* string toString (); */
527 nsresult (*ToString)(nsIStackFrame *this_, PRUnichar **_retval);
528};
529
530struct nsIStackFrame {
531 struct nsIStackFrame_vtbl *vtbl;
532};
533
534</xsl:text>
535 <xsl:apply-templates/>
536<xsl:text>
537#endif /* !__cplusplus */
538
539#ifdef IN_VBOXXPCOMC
540# define VBOXXPCOMC_DECL(type) PR_EXPORT(type)
541#else
542# define VBOXXPCOMC_DECL(type) PR_IMPORT(type)
543#endif
544
545#ifdef __cplusplus
546extern "C" {
547#endif
548
549
550/**
551 * Function table for dynamic linking.
552 * Use VBoxGetFunctions() to obtain the pointer to it.
553 */
554typedef struct VBOXXPCOMC
555{
556 /** The size of the structure. */
557 unsigned cb;
558 /** The structure version. */
559 unsigned uVersion;
560 void (*pfnComInitialize)(IVirtualBox **virtualBox, ISession **session);
561 void (*pfnComUninitialize)(void);
562
563 void (*pfnComUnallocMem)(void *pv);
564 void (*pfnUtf16Free)(PRUnichar *pwszString);
565 void (*pfnUtf8Free)(char *pszString);
566
567 int (*pfnUtf16ToUtf8)(const PRUnichar *pwszString, char **ppszString);
568 int (*pfnUtf8ToUtf16)(const char *pszString, PRUnichar **ppwszString);
569
570 const char * (*pfnGetEnv)(const char *pszVar);
571 int (*pfnSetEnv)(const char *pszVar, const char *pszValue);
572 /** Tail version, same as uVersion. */
573 unsigned uEndVersion;
574} VBOXXPCOMC;
575/** Pointer to a const VBoxXPCOMC function table. */
576typedef VBOXXPCOMC const *PCVBOXXPCOM;
577
578/** The current interface version.
579 * For use with VBoxGetXPCOMCFunctions and to be found in
580 * VBOXXPCOMC::uVersion. */
581#define VBOX_XPCOMC_VERSION 0x00010000U
582
583VBOXXPCOMC_DECL(PCVBOXXPCOM) VBoxGetXPCOMCFunctions(unsigned uVersion);
584/** Typedef for VBoxGetXPCOMCFunctions. */
585typedef PCVBOXXPCOM (*PFNVBOXGETXPCOMCFUNCTIONS)(unsigned uVersion);
586
587/** The symbol name of VBoxGetXPCOMCFunctions. */
588#if defined(__OS2__)
589# define VBOX_GET_XPCOMC_FUNCTIONS_SYMBOL_NAME "_VBoxGetXPCOMCFunctions"
590#else
591# define VBOX_GET_XPCOMC_FUNCTIONS_SYMBOL_NAME "VBoxGetXPCOMCFunctions"
592#endif
593
594
595#ifdef __cplusplus
596}
597#endif
598
599#endif /* !___VirtualBox_CXPCOM_h */
600</xsl:text>
601</xsl:template>
602
603<!--
604 * ignore all |if|s except those for XPIDL target
605<xsl:template match="if">
606 <xsl:if test="@target='xpidl'">
607 <xsl:apply-templates/>
608 </xsl:if>
609</xsl:template>
610<xsl:template match="if" mode="forward">
611 <xsl:if test="@target='xpidl'">
612 <xsl:apply-templates mode="forward"/>
613 </xsl:if>
614</xsl:template>
615<xsl:template match="if" mode="forwarder">
616 <xsl:if test="@target='midl'">
617 <xsl:apply-templates mode="forwarder"/>
618 </xsl:if>
619</xsl:template>
620
621-->
622
623<!--
624 * cpp_quote
625<xsl:template match="cpp">
626 <xsl:if test="text()">
627 <xsl:text>%{C++</xsl:text>
628 <xsl:value-of select="text()"/>
629 <xsl:text>&#x0A;%}&#x0A;&#x0A;</xsl:text>
630 </xsl:if>
631 <xsl:if test="not(text()) and @line">
632 <xsl:text>%{C++&#x0A;</xsl:text>
633 <xsl:value-of select="@line"/>
634 <xsl:text>&#x0A;%}&#x0A;&#x0A;</xsl:text>
635 </xsl:if>
636</xsl:template>
637-->
638
639
640<!--
641 * #if statement (@if attribute)
642 * @note
643 * xpidl doesn't support any preprocessor defines other than #include
644 * (it just ignores them), so the generated IDL will most likely be
645 * invalid. So for now we forbid using @if attributes
646-->
647<xsl:template match="@if" mode="begin">
648 <xsl:message terminate="yes">
649 @if attributes are not currently allowed because xpidl lacks
650 support for #ifdef and stuff.
651 </xsl:message>
652 <xsl:text>#if </xsl:text>
653 <xsl:value-of select="."/>
654 <xsl:text>&#x0A;</xsl:text>
655</xsl:template>
656<xsl:template match="@if" mode="end">
657 <xsl:text>#endif&#x0A;</xsl:text>
658</xsl:template>
659
660
661<!--
662 * libraries
663-->
664<xsl:template match="library">
665 <!-- result codes -->
666 <xsl:text>&#x0A;</xsl:text>
667 <xsl:for-each select="result">
668 <xsl:apply-templates select="."/>
669 </xsl:for-each>
670 <xsl:text>&#x0A;&#x0A;</xsl:text>
671 <!-- forward declarations -->
672 <xsl:apply-templates select="if | interface | collection | enumerator" mode="forward"/>
673 <xsl:text>&#x0A;</xsl:text>
674 <!-- typedef'ing the struct declarations -->
675 <xsl:apply-templates select="if | interface | collection | enumerator" mode="typedef"/>
676 <xsl:text>&#x0A;</xsl:text>
677 <!-- all enums go first -->
678 <xsl:apply-templates select="enum | if/enum"/>
679 <!-- everything else but result codes and enums -->
680 <xsl:apply-templates select="*[not(self::result or self::enum) and
681 not(self::if[result] or self::if[enum])]"/>
682 <!-- -->
683</xsl:template>
684
685
686<!--
687 * result codes
688-->
689<xsl:template match="result">
690 <xsl:value-of select="concat('#define ',@name,' ',@value)"/>
691 <xsl:text>&#x0A;</xsl:text>
692</xsl:template>
693
694
695<!--
696 * forward declarations
697-->
698<xsl:template match="interface | collection | enumerator" mode="forward">
699 <xsl:text>struct </xsl:text>
700 <xsl:value-of select="@name"/>
701 <xsl:text>;&#x0A;</xsl:text>
702</xsl:template>
703
704
705<!--
706 * typedef'ing the struct declarations
707-->
708<xsl:template match="interface | collection | enumerator" mode="typedef">
709 <xsl:text>typedef struct </xsl:text>
710 <xsl:value-of select="@name"/>
711 <xsl:text> </xsl:text>
712 <xsl:value-of select="@name"/>
713 <xsl:text>;&#x0A;</xsl:text>
714</xsl:template>
715
716
717<!--
718 * interfaces
719-->
720<xsl:template match="interface">
721 <xsl:text>/* Start of struct </xsl:text>
722 <xsl:value-of select="@name"/>
723 <xsl:text> Declaration */&#x0A;</xsl:text>
724 <xsl:text>#define </xsl:text>
725 <xsl:call-template name="uppercase">
726 <xsl:with-param name="str" select="@name"/>
727 </xsl:call-template>
728 <xsl:value-of select="concat('_IID_STR &quot;',@uuid,'&quot;')"/>
729 <xsl:text>&#x0A;</xsl:text>
730 <xsl:text>#define </xsl:text>
731 <xsl:call-template name="uppercase">
732 <xsl:with-param name="str" select="@name"/>
733 </xsl:call-template>
734 <xsl:text>_IID { \&#x0A;</xsl:text>
735 <xsl:text> 0x</xsl:text><xsl:value-of select="substring(@uuid,1,8)"/>
736 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,10,4)"/>
737 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,15,4)"/>
738 <xsl:text>, \&#x0A; </xsl:text>
739 <xsl:text>{ 0x</xsl:text><xsl:value-of select="substring(@uuid,20,2)"/>
740 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,22,2)"/>
741 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,25,2)"/>
742 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,27,2)"/>
743 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,29,2)"/>
744 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,31,2)"/>
745 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,33,2)"/>
746 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,35,2)"/>
747 <xsl:text> } \&#x0A;}&#x0A;</xsl:text>
748 <xsl:text>struct </xsl:text>
749 <xsl:value-of select="@name"/>
750 <xsl:text>_vtbl&#x0A;{&#x0A;</xsl:text>
751 <xsl:text> </xsl:text>
752 <xsl:choose>
753 <xsl:when test="@extends='$unknown'">struct nsISupports_vtbl nsisupports;</xsl:when>
754 <xsl:when test="@extends='$dispatched'">struct nsISupports_vtbl nsisupports;</xsl:when>
755 <xsl:when test="@extends='$errorinfo'">struct nsIException_vtbl nsiexception;</xsl:when>
756 <xsl:otherwise>
757 <xsl:text>struct </xsl:text>
758 <xsl:value-of select="@extends"/>
759 <xsl:text>_vtbl </xsl:text>
760 <xsl:call-template name="lowercase">
761 <xsl:with-param name="str" select="@extends"/>
762 </xsl:call-template>
763 <xsl:text>;</xsl:text>
764 </xsl:otherwise>
765 </xsl:choose>
766 <xsl:text>&#x0A;&#x0A;</xsl:text>
767 <!-- attributes (properties) -->
768 <xsl:apply-templates select="attribute"/>
769 <!-- methods -->
770 <xsl:apply-templates select="method"/>
771 <!-- 'if' enclosed elements, unsorted -->
772 <xsl:apply-templates select="if"/>
773 <!-- -->
774 <xsl:text>};</xsl:text>
775 <xsl:text>&#x0A;&#x0A;</xsl:text>
776 <xsl:text>struct </xsl:text>
777 <xsl:value-of select="@name"/>
778 <xsl:text>&#x0A;{&#x0A; struct </xsl:text>
779 <xsl:value-of select="@name"/>
780 <xsl:text>_vtbl *vtbl;&#x0A;};&#x0A;</xsl:text>
781 <xsl:text>/* End of struct </xsl:text>
782 <xsl:value-of select="@name"/>
783 <xsl:text> Declaration */&#x0A;&#x0A;&#x0A;</xsl:text>
784</xsl:template>
785
786
787<!--
788 * attributes
789-->
790<xsl:template match="interface//attribute | collection//attribute">
791 <xsl:if test="@array">
792 <xsl:message terminate="yes">
793 <xsl:value-of select="concat(../../@name,'::',../@name,'::',@name,': ')"/>
794 <xsl:text>'array' attributes are not supported, use 'safearray="yes"' instead.</xsl:text>
795 </xsl:message>
796 </xsl:if>
797 <xsl:apply-templates select="@if" mode="begin"/>
798 <xsl:if test="@mod='ptr'">
799 <!-- attributes using native types must be non-scriptable
800 <xsl:text> [noscript]&#x0A;</xsl:text>-->
801 </xsl:if>
802 <xsl:choose>
803 <!-- safearray pseudo attribute -->
804 <xsl:when test="@safearray='yes'">
805 <!-- getter -->
806 <xsl:text> nsresult (*Get</xsl:text>
807 <xsl:call-template name="capitalize">
808 <xsl:with-param name="str" select="@name"/>
809 </xsl:call-template>
810 <xsl:text>)(</xsl:text>
811 <xsl:value-of select="../@name" />
812 <xsl:text> *this_, </xsl:text>
813 <!-- array size -->
814 <xsl:text>PRUint32 *</xsl:text>
815 <xsl:value-of select="@name"/>
816 <xsl:text>Size, </xsl:text>
817 <!-- array pointer -->
818 <xsl:apply-templates select="@type" mode="forwarder"/>
819 <xsl:text> **</xsl:text>
820 <xsl:value-of select="@name"/>
821 <xsl:text>);&#x0A;</xsl:text>
822 <!-- setter -->
823 <xsl:if test="not(@readonly='yes')">
824 <xsl:text> nsresult set</xsl:text>
825 <xsl:call-template name="capitalize">
826 <xsl:with-param name="str" select="@name"/>
827 </xsl:call-template>
828 <xsl:text> (&#x0A;</xsl:text>
829 <!-- array size -->
830 <xsl:text> in unsigned long </xsl:text>
831 <xsl:value-of select="@name"/>
832 <xsl:text>Size,&#x0A;</xsl:text>
833 <!-- array pointer -->
834 <xsl:text> [array, size_is(</xsl:text>
835 <xsl:value-of select="@name"/>
836 <xsl:text>Size)] in </xsl:text>
837 <xsl:apply-templates select="@type" mode="forwarder"/>
838 <xsl:text> </xsl:text>
839 <xsl:value-of select="@name"/>
840 <xsl:text>&#x0A; );&#x0A;</xsl:text>
841 </xsl:if>
842 </xsl:when>
843 <!-- normal attribute -->
844 <xsl:otherwise>
845 <xsl:text> </xsl:text>
846 <xsl:if test="@readonly='yes'">
847 <xsl:text>nsresult (*Get</xsl:text>
848 <xsl:call-template name="capitalize">
849 <xsl:with-param name="str" select="@name"/>
850 </xsl:call-template>
851 <xsl:text>)(</xsl:text>
852 <xsl:value-of select="../@name" />
853 <xsl:text> *this_, </xsl:text>
854 <xsl:apply-templates select="@type" mode="forwarder"/>
855 <xsl:text> *</xsl:text>
856 <xsl:value-of select="@name"/>
857 <xsl:text>);&#x0A;</xsl:text>
858 </xsl:if>
859 <xsl:choose>
860 <xsl:when test="@readonly='yes'">
861 </xsl:when>
862 <xsl:otherwise>
863 <xsl:text>nsresult (*Get</xsl:text>
864 <xsl:call-template name="capitalize">
865 <xsl:with-param name="str" select="@name"/>
866 </xsl:call-template>
867 <xsl:text>)(</xsl:text>
868 <xsl:value-of select="../@name" />
869 <xsl:text> *this_, </xsl:text>
870 <xsl:apply-templates select="@type" mode="forwarder"/>
871 <xsl:text> *</xsl:text>
872 <xsl:value-of select="@name"/>
873 <xsl:text>);&#x0A; </xsl:text>
874 <xsl:text>nsresult (*Set</xsl:text>
875 <xsl:call-template name="capitalize">
876 <xsl:with-param name="str" select="@name"/>
877 </xsl:call-template>
878 <xsl:text>)(</xsl:text>
879 <xsl:value-of select="../@name" />
880 <xsl:text> *this_, </xsl:text>
881 <xsl:apply-templates select="@type" mode="forwarder"/>
882 <xsl:text> </xsl:text>
883 <xsl:value-of select="@name"/>
884 <xsl:text>);&#x0A;</xsl:text>
885 </xsl:otherwise>
886 </xsl:choose>
887 </xsl:otherwise>
888 </xsl:choose>
889 <xsl:apply-templates select="@if" mode="end"/>
890 <xsl:text>&#x0A;</xsl:text>
891</xsl:template>
892
893<xsl:template match="interface//attribute | collection//attribute" mode="forwarder">
894
895 <xsl:variable name="parent" select="ancestor::interface | ancestor::collection"/>
896
897 <xsl:apply-templates select="@if" mode="begin"/>
898
899 <!-- getter: COM_FORWARD_Interface_GETTER_Name_TO(smth) -->
900 <xsl:text>#define COM_FORWARD_</xsl:text>
901 <xsl:value-of select="$parent/@name"/>
902 <xsl:text>_GETTER_</xsl:text>
903 <xsl:call-template name="capitalize">
904 <xsl:with-param name="str" select="@name"/>
905 </xsl:call-template>
906 <xsl:text>_TO(smth) NS_IMETHOD Get</xsl:text>
907 <xsl:call-template name="capitalize">
908 <xsl:with-param name="str" select="@name"/>
909 </xsl:call-template>
910 <xsl:text> (</xsl:text>
911 <xsl:if test="@safearray='yes'">
912 <xsl:text>PRUint32 * a</xsl:text>
913 <xsl:call-template name="capitalize">
914 <xsl:with-param name="str" select="@name"/>
915 </xsl:call-template>
916 <xsl:text>Size, </xsl:text>
917 </xsl:if>
918 <xsl:apply-templates select="@type" mode="forwarder"/>
919 <xsl:if test="@safearray='yes'">
920 <xsl:text> *</xsl:text>
921 </xsl:if>
922 <xsl:text> * a</xsl:text>
923 <xsl:call-template name="capitalize">
924 <xsl:with-param name="str" select="@name"/>
925 </xsl:call-template>
926 <xsl:text>) { return smth Get</xsl:text>
927 <xsl:call-template name="capitalize">
928 <xsl:with-param name="str" select="@name"/>
929 </xsl:call-template>
930 <xsl:text> (</xsl:text>
931 <xsl:if test="@safearray='yes'">
932 <xsl:text>a</xsl:text>
933 <xsl:call-template name="capitalize">
934 <xsl:with-param name="str" select="@name"/>
935 </xsl:call-template>
936 <xsl:text>Size, </xsl:text>
937 </xsl:if>
938 <xsl:text>a</xsl:text>
939 <xsl:call-template name="capitalize">
940 <xsl:with-param name="str" select="@name"/>
941 </xsl:call-template>
942 <xsl:text>); }&#x0A;</xsl:text>
943 <!-- getter: COM_FORWARD_Interface_GETTER_Name_TO_OBJ(obj) -->
944 <xsl:text>#define COM_FORWARD_</xsl:text>
945 <xsl:value-of select="$parent/@name"/>
946 <xsl:text>_GETTER_</xsl:text>
947 <xsl:call-template name="capitalize">
948 <xsl:with-param name="str" select="@name"/>
949 </xsl:call-template>
950 <xsl:text>_TO_OBJ(obj) COM_FORWARD_</xsl:text>
951 <xsl:value-of select="$parent/@name"/>
952 <xsl:text>_GETTER_</xsl:text>
953 <xsl:call-template name="capitalize">
954 <xsl:with-param name="str" select="@name"/>
955 </xsl:call-template>
956 <xsl:text>_TO ((obj)->)&#x0A;</xsl:text>
957 <!-- getter: COM_FORWARD_Interface_GETTER_Name_TO_BASE(base) -->
958 <xsl:text>#define COM_FORWARD_</xsl:text>
959 <xsl:value-of select="$parent/@name"/>
960 <xsl:text>_GETTER_</xsl:text>
961 <xsl:call-template name="capitalize">
962 <xsl:with-param name="str" select="@name"/>
963 </xsl:call-template>
964 <xsl:text>_TO_BASE(base) COM_FORWARD_</xsl:text>
965 <xsl:value-of select="$parent/@name"/>
966 <xsl:text>_GETTER_</xsl:text>
967 <xsl:call-template name="capitalize">
968 <xsl:with-param name="str" select="@name"/>
969 </xsl:call-template>
970 <xsl:text>_TO (base::)&#x0A;</xsl:text>
971 <!-- -->
972 <xsl:if test="not(@readonly='yes')">
973 <!-- setter: COM_FORWARD_Interface_SETTER_Name_TO(smth) -->
974 <xsl:text>#define COM_FORWARD_</xsl:text>
975 <xsl:value-of select="$parent/@name"/>
976 <xsl:text>_SETTER_</xsl:text>
977 <xsl:call-template name="capitalize">
978 <xsl:with-param name="str" select="@name"/>
979 </xsl:call-template>
980 <xsl:text>_TO(smth) NS_IMETHOD Set</xsl:text>
981 <xsl:call-template name="capitalize">
982 <xsl:with-param name="str" select="@name"/>
983 </xsl:call-template>
984 <xsl:text> (</xsl:text>
985 <xsl:if test="@safearray='yes'">
986 <xsl:text>PRUint32 a</xsl:text>
987 <xsl:call-template name="capitalize">
988 <xsl:with-param name="str" select="@name"/>
989 </xsl:call-template>
990 <xsl:text>Size, </xsl:text>
991 </xsl:if>
992 <xsl:if test="not(@safearray='yes') and (@type='string' or @type='wstring')">
993 <xsl:text>const </xsl:text>
994 </xsl:if>
995 <xsl:apply-templates select="@type" mode="forwarder"/>
996 <xsl:if test="@safearray='yes'">
997 <xsl:text> *</xsl:text>
998 </xsl:if>
999 <xsl:text> a</xsl:text>
1000 <xsl:call-template name="capitalize">
1001 <xsl:with-param name="str" select="@name"/>
1002 </xsl:call-template>
1003 <xsl:text>) { return smth Set</xsl:text>
1004 <xsl:call-template name="capitalize">
1005 <xsl:with-param name="str" select="@name"/>
1006 </xsl:call-template>
1007 <xsl:text> (a</xsl:text>
1008 <xsl:call-template name="capitalize">
1009 <xsl:with-param name="str" select="@name"/>
1010 </xsl:call-template>
1011 <xsl:text>); }&#x0A;</xsl:text>
1012 <!-- setter: COM_FORWARD_Interface_SETTER_Name_TO_OBJ(obj) -->
1013 <xsl:text>#define COM_FORWARD_</xsl:text>
1014 <xsl:value-of select="$parent/@name"/>
1015 <xsl:text>_SETTER_</xsl:text>
1016 <xsl:call-template name="capitalize">
1017 <xsl:with-param name="str" select="@name"/>
1018 </xsl:call-template>
1019 <xsl:text>_TO_OBJ(obj) COM_FORWARD_</xsl:text>
1020 <xsl:value-of select="$parent/@name"/>
1021 <xsl:text>_SETTER_</xsl:text>
1022 <xsl:call-template name="capitalize">
1023 <xsl:with-param name="str" select="@name"/>
1024 </xsl:call-template>
1025 <xsl:text>_TO ((obj)->)&#x0A;</xsl:text>
1026 <!-- setter: COM_FORWARD_Interface_SETTER_Name_TO_BASE(base) -->
1027 <xsl:text>#define COM_FORWARD_</xsl:text>
1028 <xsl:value-of select="$parent/@name"/>
1029 <xsl:text>_SETTER_</xsl:text>
1030 <xsl:call-template name="capitalize">
1031 <xsl:with-param name="str" select="@name"/>
1032 </xsl:call-template>
1033 <xsl:text>_TO_BASE(base) COM_FORWARD_</xsl:text>
1034 <xsl:value-of select="$parent/@name"/>
1035 <xsl:text>_SETTER_</xsl:text>
1036 <xsl:call-template name="capitalize">
1037 <xsl:with-param name="str" select="@name"/>
1038 </xsl:call-template>
1039 <xsl:text>_TO (base::)&#x0A;</xsl:text>
1040 </xsl:if>
1041
1042 <xsl:apply-templates select="@if" mode="end"/>
1043
1044</xsl:template>
1045
1046
1047<!--
1048 * methods
1049-->
1050<xsl:template match="interface//method | collection//method">
1051 <xsl:apply-templates select="@if" mode="begin"/>
1052 <xsl:if test="param/@mod='ptr'">
1053 <!-- methods using native types must be non-scriptable
1054 <xsl:text> [noscript]&#x0A;</xsl:text>-->
1055 </xsl:if>
1056 <xsl:text> nsresult (*</xsl:text>
1057 <xsl:call-template name="capitalize">
1058 <xsl:with-param name="str" select="@name"/>
1059 </xsl:call-template>
1060 <xsl:if test="param">
1061 <xsl:text>)(&#x0A;</xsl:text>
1062 <xsl:text> </xsl:text>
1063 <xsl:value-of select="../@name" />
1064 <xsl:text> *this_,&#x0A;</xsl:text>
1065 <xsl:for-each select="param [position() != last()]">
1066 <xsl:text> </xsl:text>
1067 <xsl:apply-templates select="."/>
1068 <xsl:text>,&#x0A;</xsl:text>
1069 </xsl:for-each>
1070 <xsl:text> </xsl:text>
1071 <xsl:apply-templates select="param [last()]"/>
1072 <xsl:text>&#x0A; );&#x0A;</xsl:text>
1073 </xsl:if>
1074 <xsl:if test="not(param)">
1075 <xsl:text>)(</xsl:text>
1076 <xsl:value-of select="../@name" />
1077 <xsl:text> *this_ );&#x0A;</xsl:text>
1078 </xsl:if>
1079 <xsl:apply-templates select="@if" mode="end"/>
1080 <xsl:text>&#x0A;</xsl:text>
1081</xsl:template>
1082
1083<xsl:template match="interface//method | collection//method" mode="forwarder">
1084
1085 <xsl:variable name="parent" select="ancestor::interface | ancestor::collection"/>
1086
1087 <xsl:apply-templates select="@if" mode="begin"/>
1088
1089 <xsl:text>#define COM_FORWARD_</xsl:text>
1090 <xsl:value-of select="$parent/@name"/>
1091 <xsl:text>_</xsl:text>
1092 <xsl:call-template name="capitalize">
1093 <xsl:with-param name="str" select="@name"/>
1094 </xsl:call-template>
1095 <xsl:text>_TO(smth) NS_IMETHOD </xsl:text>
1096 <xsl:call-template name="capitalize">
1097 <xsl:with-param name="str" select="@name"/>
1098 </xsl:call-template>
1099 <xsl:choose>
1100 <xsl:when test="param">
1101 <xsl:text> (</xsl:text>
1102 <xsl:for-each select="param [position() != last()]">
1103 <xsl:apply-templates select="." mode="forwarder"/>
1104 <xsl:text>, </xsl:text>
1105 </xsl:for-each>
1106 <xsl:apply-templates select="param [last()]" mode="forwarder"/>
1107 <xsl:text>) { return smth </xsl:text>
1108 <xsl:call-template name="capitalize">
1109 <xsl:with-param name="str" select="@name"/>
1110 </xsl:call-template>
1111 <xsl:text> (</xsl:text>
1112 <xsl:for-each select="param [position() != last()]">
1113 <xsl:if test="@safearray='yes'">
1114 <xsl:text>a</xsl:text>
1115 <xsl:call-template name="capitalize">
1116 <xsl:with-param name="str" select="@name"/>
1117 </xsl:call-template>
1118 <xsl:text>Size+++, </xsl:text>
1119 </xsl:if>
1120 <xsl:text>a</xsl:text>
1121 <xsl:call-template name="capitalize">
1122 <xsl:with-param name="str" select="@name"/>
1123 </xsl:call-template>
1124 <xsl:text>, </xsl:text>
1125 </xsl:for-each>
1126 <xsl:if test="param [last()]/@safearray='yes'">
1127 <xsl:text>a</xsl:text>
1128 <xsl:call-template name="capitalize">
1129 <xsl:with-param name="str" select="param [last()]/@name"/>
1130 </xsl:call-template>
1131 <xsl:text>Size, </xsl:text>
1132 </xsl:if>
1133 <xsl:text>a</xsl:text>
1134 <xsl:call-template name="capitalize">
1135 <xsl:with-param name="str" select="param [last()]/@name"/>
1136 </xsl:call-template>
1137 <xsl:text>); }</xsl:text>
1138 </xsl:when>
1139 <xsl:otherwise test="not(param)">
1140 <xsl:text>() { return smth </xsl:text>
1141 <xsl:call-template name="capitalize">
1142 <xsl:with-param name="str" select="@name"/>
1143 </xsl:call-template>
1144 <xsl:text>(); }</xsl:text>
1145 </xsl:otherwise>
1146 </xsl:choose>
1147 <xsl:text>&#x0A;</xsl:text>
1148 <!-- COM_FORWARD_Interface_Method_TO_OBJ(obj) -->
1149 <xsl:text>#define COM_FORWARD_</xsl:text>
1150 <xsl:value-of select="$parent/@name"/>
1151 <xsl:text>_</xsl:text>
1152 <xsl:call-template name="capitalize">
1153 <xsl:with-param name="str" select="@name"/>
1154 </xsl:call-template>
1155 <xsl:text>_TO_OBJ(obj) COM_FORWARD_</xsl:text>
1156 <xsl:value-of select="$parent/@name"/>
1157 <xsl:text>_</xsl:text>
1158 <xsl:call-template name="capitalize">
1159 <xsl:with-param name="str" select="@name"/>
1160 </xsl:call-template>
1161 <xsl:text>_TO ((obj)->)&#x0A;</xsl:text>
1162 <!-- COM_FORWARD_Interface_Method_TO_BASE(base) -->
1163 <xsl:text>#define COM_FORWARD_</xsl:text>
1164 <xsl:value-of select="$parent/@name"/>
1165 <xsl:text>_</xsl:text>
1166 <xsl:call-template name="capitalize">
1167 <xsl:with-param name="str" select="@name"/>
1168 </xsl:call-template>
1169 <xsl:text>_TO_BASE(base) COM_FORWARD_</xsl:text>
1170 <xsl:value-of select="$parent/@name"/>
1171 <xsl:text>_</xsl:text>
1172 <xsl:call-template name="capitalize">
1173 <xsl:with-param name="str" select="@name"/>
1174 </xsl:call-template>
1175 <xsl:text>_TO (base::)&#x0A;</xsl:text>
1176
1177 <xsl:apply-templates select="@if" mode="end"/>
1178
1179</xsl:template>
1180
1181
1182<!--
1183 * modules
1184-->
1185<xsl:template match="module">
1186 <xsl:apply-templates select="class"/>
1187</xsl:template>
1188
1189
1190<!--
1191 * co-classes
1192-->
1193<xsl:template match="module/class">
1194 <!-- class and contract id -->
1195 <xsl:text>&#x0A;</xsl:text>
1196 <xsl:text>#define NS_</xsl:text>
1197 <xsl:call-template name="uppercase">
1198 <xsl:with-param name="str" select="@name"/>
1199 </xsl:call-template>
1200 <xsl:text>_CID { \&#x0A;</xsl:text>
1201 <xsl:text> 0x</xsl:text><xsl:value-of select="substring(@uuid,1,8)"/>
1202 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,10,4)"/>
1203 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,15,4)"/>
1204 <xsl:text>, \&#x0A; </xsl:text>
1205 <xsl:text>{ 0x</xsl:text><xsl:value-of select="substring(@uuid,20,2)"/>
1206 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,22,2)"/>
1207 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,25,2)"/>
1208 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,27,2)"/>
1209 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,29,2)"/>
1210 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,31,2)"/>
1211 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,33,2)"/>
1212 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,35,2)"/>
1213 <xsl:text> } \&#x0A;}&#x0A;</xsl:text>
1214 <xsl:text>#define NS_</xsl:text>
1215 <xsl:call-template name="uppercase">
1216 <xsl:with-param name="str" select="@name"/>
1217 </xsl:call-template>
1218 <!-- Contract ID -->
1219 <xsl:text>_CONTRACTID &quot;@</xsl:text>
1220 <xsl:value-of select="@namespace"/>
1221 <xsl:text>/</xsl:text>
1222 <xsl:value-of select="@name"/>
1223 <xsl:text>;1&quot;&#x0A;</xsl:text>
1224 <!-- CLSID_xxx declarations for XPCOM, for compatibility with Win32 -->
1225 <xsl:text>/* for compatibility with Win32 */&#x0A;</xsl:text>
1226 <xsl:text>#define CLSID_</xsl:text>
1227 <xsl:value-of select="@name"/>
1228 <xsl:text> (nsCID) NS_</xsl:text>
1229 <xsl:call-template name="uppercase">
1230 <xsl:with-param name="str" select="@name"/>
1231 </xsl:call-template>
1232 <xsl:text>_CID&#x0A;</xsl:text>
1233 <xsl:text>&#x0A;&#x0A;</xsl:text>
1234</xsl:template>
1235
1236
1237<!--
1238 * enumerators
1239-->
1240<xsl:template match="enumerator">
1241 <xsl:text>/* Start of struct </xsl:text>
1242 <xsl:value-of select="@name"/>
1243 <xsl:text> Declaration */&#x0A;</xsl:text>
1244 <xsl:text>#define </xsl:text>
1245 <xsl:call-template name="uppercase">
1246 <xsl:with-param name="str" select="@name"/>
1247 </xsl:call-template>
1248 <xsl:value-of select="concat('_IID_STR &quot;',@uuid,'&quot;')"/>
1249 <xsl:text>&#x0A;</xsl:text>
1250 <xsl:text>#define </xsl:text>
1251 <xsl:call-template name="uppercase">
1252 <xsl:with-param name="str" select="@name"/>
1253 </xsl:call-template>
1254 <xsl:text>_IID { \&#x0A;</xsl:text>
1255 <xsl:text> 0x</xsl:text><xsl:value-of select="substring(@uuid,1,8)"/>
1256 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,10,4)"/>
1257 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,15,4)"/>
1258 <xsl:text>, \&#x0A; </xsl:text>
1259 <xsl:text>{ 0x</xsl:text><xsl:value-of select="substring(@uuid,20,2)"/>
1260 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,22,2)"/>
1261 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,25,2)"/>
1262 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,27,2)"/>
1263 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,29,2)"/>
1264 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,31,2)"/>
1265 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,33,2)"/>
1266 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,35,2)"/>
1267 <xsl:text> } \&#x0A;}&#x0A;</xsl:text>
1268 <xsl:text>struct </xsl:text>
1269 <xsl:value-of select="@name"/>
1270 <xsl:text>_vtbl&#x0A;{&#x0A;</xsl:text>
1271 <xsl:text> struct nsISupports_vtbl nsisupports;&#x0A;&#x0A;</xsl:text>
1272 <!-- attributes (properties) -->
1273 <xsl:text> nsresult (*HasMore)(</xsl:text>
1274 <xsl:value-of select="@name" />
1275 <xsl:text> *this_, PRBool *more);&#x0A;&#x0A;</xsl:text>
1276 <!-- GetNext -->
1277 <xsl:text> nsresult (*GetNext)(</xsl:text>
1278 <xsl:value-of select="@name" />
1279 <xsl:text> *this_, </xsl:text>
1280 <xsl:apply-templates select="@type" mode="forwarder"/>
1281 <xsl:text> *next);&#x0A;&#x0A;</xsl:text>
1282 <xsl:text>};</xsl:text>
1283 <xsl:text>&#x0A;&#x0A;</xsl:text>
1284 <xsl:text>struct </xsl:text>
1285 <xsl:value-of select="@name"/>
1286 <xsl:text>&#x0A;{&#x0A; struct </xsl:text>
1287 <xsl:value-of select="@name"/>
1288 <xsl:text>_vtbl *vtbl;&#x0A;};&#x0A;</xsl:text>
1289 <xsl:text>/* End of struct </xsl:text>
1290 <xsl:value-of select="@name"/>
1291 <xsl:text> Declaration */&#x0A;&#x0A;&#x0A;</xsl:text>
1292</xsl:template>
1293
1294
1295<!--
1296 * collections
1297-->
1298<xsl:template match="collection">
1299 <xsl:if test="not(@readonly='yes')">
1300 <xsl:message terminate="yes">
1301 <xsl:value-of select="concat(@name,': ')"/>
1302 <xsl:text>non-readonly collections are not currently supported</xsl:text>
1303 </xsl:message>
1304 </xsl:if>
1305 <xsl:text>/* Start of struct </xsl:text>
1306 <xsl:value-of select="@name"/>
1307 <xsl:text> Declaration */&#x0A;</xsl:text>
1308 <xsl:text>#define </xsl:text>
1309 <xsl:call-template name="uppercase">
1310 <xsl:with-param name="str" select="@name"/>
1311 </xsl:call-template>
1312 <xsl:value-of select="concat('_IID_STR &quot;',@uuid,'&quot;')"/>
1313 <xsl:text>&#x0A;</xsl:text>
1314 <xsl:text>#define </xsl:text>
1315 <xsl:call-template name="uppercase">
1316 <xsl:with-param name="str" select="@name"/>
1317 </xsl:call-template>
1318 <xsl:text>_IID { \&#x0A;</xsl:text>
1319 <xsl:text> 0x</xsl:text><xsl:value-of select="substring(@uuid,1,8)"/>
1320 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,10,4)"/>
1321 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,15,4)"/>
1322 <xsl:text>, \&#x0A; </xsl:text>
1323 <xsl:text>{ 0x</xsl:text><xsl:value-of select="substring(@uuid,20,2)"/>
1324 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,22,2)"/>
1325 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,25,2)"/>
1326 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,27,2)"/>
1327 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,29,2)"/>
1328 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,31,2)"/>
1329 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,33,2)"/>
1330 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,35,2)"/>
1331 <xsl:text> } \&#x0A;}&#x0A;</xsl:text>
1332 <xsl:text>struct </xsl:text>
1333 <xsl:value-of select="@name"/>
1334 <xsl:text>_vtbl&#x0A;{&#x0A;</xsl:text>
1335 <xsl:text> struct nsISupports_vtbl nsisupports;&#x0A;&#x0A;</xsl:text>
1336 <!-- Count -->
1337 <xsl:text> nsresult (*GetCount)(</xsl:text>
1338 <xsl:value-of select="@name" />
1339 <xsl:text> *this_, PRUint32 *aCount);&#x0A;&#x0A;</xsl:text>
1340 <!-- GetItemAt -->
1341 <xsl:text> nsresult (*GetItemAt)(</xsl:text>
1342 <xsl:value-of select="@name" />
1343 <xsl:text> *this_, PRUint32 index, </xsl:text>
1344 <xsl:apply-templates select="@type" mode="forwarder"/>
1345 <xsl:text> **item);&#x0A;&#x0A;</xsl:text>
1346 <!-- Enumerate -->
1347 <xsl:text> nsresult (*Enumerate)(</xsl:text>
1348 <xsl:value-of select="@name" />
1349 <xsl:text> *this_, </xsl:text>
1350 <xsl:apply-templates select="@enumerator"/>
1351 <xsl:text> **enumerator);&#x0A;&#x0A;</xsl:text>
1352 <!-- other extra attributes (properties) -->
1353 <xsl:apply-templates select="attribute"/>
1354 <!-- other extra methods -->
1355 <xsl:apply-templates select="method"/>
1356 <!-- 'if' enclosed elements, unsorted -->
1357 <xsl:apply-templates select="if"/>
1358 <xsl:text>};</xsl:text>
1359 <xsl:text>&#x0A;&#x0A;</xsl:text>
1360 <xsl:text>struct </xsl:text>
1361 <xsl:value-of select="@name"/>
1362 <xsl:text>&#x0A;{&#x0A; struct </xsl:text>
1363 <xsl:value-of select="@name"/>
1364 <xsl:text>_vtbl *vtbl;&#x0A;};&#x0A;</xsl:text>
1365 <xsl:text>/* End of struct </xsl:text>
1366 <xsl:value-of select="@name"/>
1367 <xsl:text> Declaration */&#x0A;&#x0A;&#x0A;</xsl:text>
1368</xsl:template>
1369
1370
1371<!--
1372 * enums
1373-->
1374<xsl:template match="enum">
1375 <xsl:text>/* Start of enum </xsl:text>
1376 <xsl:value-of select="@name"/>
1377 <xsl:text> Declaration */&#x0A;</xsl:text>
1378 <xsl:text>#define </xsl:text>
1379 <xsl:call-template name="uppercase">
1380 <xsl:with-param name="str" select="@name"/>
1381 </xsl:call-template>
1382 <xsl:value-of select="concat('_IID_STR &quot;',@uuid,'&quot;')"/>
1383 <xsl:text>&#x0A;</xsl:text>
1384 <xsl:text>#define </xsl:text>
1385 <xsl:call-template name="uppercase">
1386 <xsl:with-param name="str" select="@name"/>
1387 </xsl:call-template>
1388 <xsl:text>_IID { \&#x0A;</xsl:text>
1389 <xsl:text> 0x</xsl:text><xsl:value-of select="substring(@uuid,1,8)"/>
1390 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,10,4)"/>
1391 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,15,4)"/>
1392 <xsl:text>, \&#x0A; </xsl:text>
1393 <xsl:text>{ 0x</xsl:text><xsl:value-of select="substring(@uuid,20,2)"/>
1394 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,22,2)"/>
1395 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,25,2)"/>
1396 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,27,2)"/>
1397 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,29,2)"/>
1398 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,31,2)"/>
1399 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,33,2)"/>
1400 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,35,2)"/>
1401 <xsl:text> } \&#x0A;}&#x0A;</xsl:text>
1402 <xsl:text>enum </xsl:text>
1403 <xsl:value-of select="@name"/>
1404 <xsl:text>&#x0A;{&#x0A;</xsl:text>
1405 <xsl:variable name="this" select="."/>
1406 <xsl:for-each select="const">
1407 <xsl:text> </xsl:text>
1408 <xsl:value-of select="$this/@name"/>
1409 <xsl:text>_</xsl:text>
1410 <xsl:value-of select="@name"/> = <xsl:value-of select="@value"/>
1411 <xsl:if test="position() != last()">
1412 <xsl:text>,</xsl:text>
1413 </xsl:if>
1414 <xsl:text>&#x0A;</xsl:text>
1415 </xsl:for-each>
1416 <xsl:text>};&#x0A;</xsl:text>
1417 <xsl:text>/* End of enum </xsl:text>
1418 <xsl:value-of select="@name"/>
1419 <xsl:text> Declaration */&#x0A;&#x0A;&#x0A;</xsl:text>
1420</xsl:template>
1421
1422
1423<!--
1424 * method parameters
1425-->
1426<xsl:template match="method/param">
1427 <xsl:choose>
1428 <!-- safearray parameters -->
1429 <xsl:when test="@safearray='yes'">
1430 <!-- array size -->
1431 <xsl:choose>
1432 <xsl:when test="@dir='in'">
1433 <xsl:text>PRUint32 </xsl:text>
1434 <xsl:value-of select="@name"/>
1435 <xsl:text>Size,&#x0A;</xsl:text>
1436 </xsl:when>
1437 <xsl:when test="@dir='out'">
1438 <xsl:text>PRUint32 *</xsl:text>
1439 <xsl:value-of select="@name"/>
1440 <xsl:text>Size,&#x0A;</xsl:text>
1441 </xsl:when>
1442 <xsl:when test="@dir='return'">
1443 <xsl:text>PRUint32 *</xsl:text>
1444 <xsl:value-of select="@name"/>
1445 <xsl:text>Size,&#x0A;</xsl:text>
1446 </xsl:when>
1447 <xsl:otherwise>
1448 <xsl:text>PRUint32 </xsl:text>
1449 <xsl:value-of select="@name"/>
1450 <xsl:text>Size,&#x0A;</xsl:text>
1451 </xsl:otherwise>
1452 </xsl:choose>
1453 <!-- array pointer -->
1454 <xsl:text> </xsl:text>
1455 <xsl:choose>
1456 <xsl:when test="@dir='in'">
1457 <xsl:apply-templates select="@type" mode="forwarder"/>
1458 <xsl:text>*</xsl:text>
1459 </xsl:when>
1460 <xsl:when test="@dir='out'">
1461 <xsl:apply-templates select="@type" mode="forwarder"/>
1462 <xsl:if test="@type='wstring'">
1463 <xsl:text>*</xsl:text>
1464 </xsl:if>
1465 <xsl:text>*</xsl:text>
1466 </xsl:when>
1467 <xsl:when test="@dir='return'">
1468 <xsl:apply-templates select="@type" mode="forwarder"/>
1469 <xsl:text>**</xsl:text>
1470 </xsl:when>
1471 <xsl:otherwise>
1472 <xsl:apply-templates select="@type" mode="forwarder"/>
1473 <xsl:text>*</xsl:text>
1474 </xsl:otherwise>
1475 </xsl:choose>
1476 <xsl:text> </xsl:text>
1477 <xsl:value-of select="@name"/>
1478 </xsl:when>
1479 <!-- normal and array parameters -->
1480 <xsl:otherwise>
1481 <xsl:if test="@array">
1482 <xsl:if test="@dir='return'">
1483 <xsl:message terminate="yes">
1484 <xsl:value-of select="concat(../../@name,'::',../@name,'::',@name,': ')"/>
1485 <xsl:text>return 'array' parameters are not supported, use 'safearray="yes"' instead.</xsl:text>
1486 </xsl:message>
1487 </xsl:if>
1488 <xsl:text>[array, </xsl:text>
1489 <xsl:choose>
1490 <xsl:when test="../param[@name=current()/@array]">
1491 <xsl:if test="../param[@name=current()/@array]/@dir != @dir">
1492 <xsl:message terminate="yes">
1493 <xsl:value-of select="concat(../../@name,'::',../@name,': ')"/>
1494 <xsl:value-of select="concat(@name,' and ',../param[@name=current()/@array]/@name)"/>
1495 <xsl:text> must have the same direction</xsl:text>
1496 </xsl:message>
1497 </xsl:if>
1498 <xsl:text>size_is(</xsl:text>
1499 <xsl:value-of select="@array"/>
1500 <xsl:text>)</xsl:text>
1501 </xsl:when>
1502 <xsl:otherwise>
1503 <xsl:message terminate="yes">
1504 <xsl:value-of select="concat(../../@name,'::',../@name,'::',@name,': ')"/>
1505 <xsl:text>array attribute refers to non-existent param: </xsl:text>
1506 <xsl:value-of select="@array"/>
1507 </xsl:message>
1508 </xsl:otherwise>
1509 </xsl:choose>
1510 <xsl:text>] </xsl:text>
1511 </xsl:if>
1512 <xsl:choose>
1513 <xsl:when test="@dir='in'">
1514 <xsl:apply-templates select="@type" mode="forwarder"/>
1515 <xsl:text></xsl:text>
1516 </xsl:when>
1517 <xsl:when test="@dir='out'">
1518 <xsl:apply-templates select="@type" mode="forwarder"/>
1519 <xsl:text> *</xsl:text>
1520 </xsl:when>
1521 <xsl:when test="@dir='return'">
1522 <xsl:apply-templates select="@type" mode="forwarder"/>
1523 <xsl:text> *</xsl:text>
1524 </xsl:when>
1525 <xsl:otherwise>
1526 <xsl:apply-templates select="@type" mode="forwarder"/>
1527 <xsl:text></xsl:text>
1528 </xsl:otherwise>
1529 </xsl:choose>
1530 <xsl:text> </xsl:text>
1531 <xsl:value-of select="@name"/>
1532 </xsl:otherwise>
1533 </xsl:choose>
1534</xsl:template>
1535
1536<xsl:template match="method/param" mode="forwarder">
1537 <xsl:if test="@safearray='yes'">
1538 <xsl:text>PRUint32</xsl:text>
1539 <xsl:if test="@dir='out' or @dir='return'">
1540 <xsl:text> *</xsl:text>
1541 </xsl:if>
1542 <xsl:text> a</xsl:text>
1543 <xsl:call-template name="capitalize">
1544 <xsl:with-param name="str" select="@name"/>
1545 </xsl:call-template>
1546 <xsl:text>Size, </xsl:text>
1547 </xsl:if>
1548 <xsl:apply-templates select="@type" mode="forwarder"/>
1549 <xsl:if test="@dir='out' or @dir='return'">
1550 <xsl:text> *</xsl:text>
1551 </xsl:if>
1552 <xsl:if test="@safearray='yes'">
1553 <xsl:text> *</xsl:text>
1554 </xsl:if>
1555 <xsl:text> a</xsl:text>
1556 <xsl:call-template name="capitalize">
1557 <xsl:with-param name="str" select="@name"/>
1558 </xsl:call-template>
1559</xsl:template>
1560
1561
1562<!--
1563 * attribute/parameter type conversion
1564-->
1565<xsl:template match="
1566 attribute/@type | param/@type |
1567 enumerator/@type | collection/@type | collection/@enumerator
1568">
1569 <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
1570
1571 <xsl:if test="../@array and ../@safearray='yes'">
1572 <xsl:message terminate="yes">
1573 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
1574 <xsl:text>either 'array' or 'safearray="yes"' attribute is allowed, but not both!</xsl:text>
1575 </xsl:message>
1576 </xsl:if>
1577
1578 <xsl:choose>
1579 <!-- modifiers (ignored for 'enumeration' attributes)-->
1580 <xsl:when test="name(current())='type' and ../@mod">
1581 <xsl:choose>
1582 <xsl:when test="../@mod='ptr'">
1583 <xsl:choose>
1584 <!-- standard types -->
1585 <!--xsl:when test=".='result'">??</xsl:when-->
1586 <xsl:when test=".='boolean'">booleanPtr</xsl:when>
1587 <xsl:when test=".='octet'">octetPtr</xsl:when>
1588 <xsl:when test=".='short'">shortPtr</xsl:when>
1589 <xsl:when test=".='unsigned short'">ushortPtr</xsl:when>
1590 <xsl:when test=".='long'">longPtr</xsl:when>
1591 <xsl:when test=".='long long'">llongPtr</xsl:when>
1592 <xsl:when test=".='unsigned long'">ulongPtr</xsl:when>
1593 <xsl:when test=".='unsigned long long'">ullongPtr</xsl:when>
1594 <xsl:when test=".='char'">charPtr</xsl:when>
1595 <!--xsl:when test=".='string'">??</xsl:when-->
1596 <xsl:when test=".='wchar'">wcharPtr</xsl:when>
1597 <!--xsl:when test=".='wstring'">??</xsl:when-->
1598 <xsl:otherwise>
1599 <xsl:message terminate="yes">
1600 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
1601 <xsl:text>attribute 'mod=</xsl:text>
1602 <xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
1603 <xsl:text>' cannot be used with type </xsl:text>
1604 <xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
1605 </xsl:message>
1606 </xsl:otherwise>
1607 </xsl:choose>
1608 </xsl:when>
1609 <xsl:otherwise>
1610 <xsl:message terminate="yes">
1611 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
1612 <xsl:value-of select="concat('value &quot;',../@mod,'&quot; ')"/>
1613 <xsl:text>of attribute 'mod' is invalid!</xsl:text>
1614 </xsl:message>
1615 </xsl:otherwise>
1616 </xsl:choose>
1617 </xsl:when>
1618 <!-- no modifiers -->
1619 <xsl:otherwise>
1620 <xsl:choose>
1621 <!-- standard types -->
1622 <xsl:when test=".='result'">nsresult</xsl:when>
1623 <xsl:when test=".='boolean'">boolean</xsl:when>
1624 <xsl:when test=".='octet'">octet</xsl:when>
1625 <xsl:when test=".='short'">short</xsl:when>
1626 <xsl:when test=".='unsigned short'">unsigned short</xsl:when>
1627 <xsl:when test=".='long'">long</xsl:when>
1628 <xsl:when test=".='long long'">long long</xsl:when>
1629 <xsl:when test=".='unsigned long'">unsigned long</xsl:when>
1630 <xsl:when test=".='unsigned long long'">unsigned long long</xsl:when>
1631 <xsl:when test=".='char'">char</xsl:when>
1632 <xsl:when test=".='wchar'">wchar</xsl:when>
1633 <xsl:when test=".='string'">string</xsl:when>
1634 <xsl:when test=".='wstring'">wstring</xsl:when>
1635 <!-- UUID type -->
1636 <xsl:when test=".='uuid'">
1637 <xsl:choose>
1638 <xsl:when test="name(..)='attribute'">
1639 <xsl:choose>
1640 <xsl:when test="../@readonly='yes'">
1641 <xsl:text>nsIDPtr</xsl:text>
1642 </xsl:when>
1643 <xsl:otherwise>
1644 <xsl:message terminate="yes">
1645 <xsl:value-of select="../@name"/>
1646 <xsl:text>: Non-readonly uuid attributes are not supported!</xsl:text>
1647 </xsl:message>
1648 </xsl:otherwise>
1649 </xsl:choose>
1650 </xsl:when>
1651 <xsl:when test="name(..)='param'">
1652 <xsl:choose>
1653 <xsl:when test="../@dir='in' and not(../@safearray='yes')">
1654 <xsl:text>nsIDRef</xsl:text>
1655 </xsl:when>
1656 <xsl:otherwise>
1657 <xsl:text>nsIDPtr</xsl:text>
1658 </xsl:otherwise>
1659 </xsl:choose>
1660 </xsl:when>
1661 </xsl:choose>
1662 </xsl:when>
1663 <!-- system interface types -->
1664 <xsl:when test=".='$unknown'">nsISupports</xsl:when>
1665 <xsl:otherwise>
1666 <xsl:choose>
1667 <!-- enum types -->
1668 <xsl:when test="
1669 (ancestor::library/enum[@name=current()]) or
1670 (ancestor::library/if[@target=$self_target]/enum[@name=current()])
1671 ">
1672 <xsl:text>PRUint32</xsl:text>
1673 </xsl:when>
1674 <!-- custom interface types -->
1675 <xsl:when test="
1676 (name(current())='enumerator' and
1677 ((ancestor::library/enumerator[@name=current()]) or
1678 (ancestor::library/if[@target=$self_target]/enumerator[@name=current()]))
1679 ) or
1680 ((ancestor::library/interface[@name=current()]) or
1681 (ancestor::library/if[@target=$self_target]/interface[@name=current()])
1682 ) or
1683 ((ancestor::library/collection[@name=current()]) or
1684 (ancestor::library/if[@target=$self_target]/collection[@name=current()])
1685 )
1686 ">
1687 <xsl:value-of select="."/>
1688 </xsl:when>
1689 <!-- other types -->
1690 <xsl:otherwise>
1691 <xsl:message terminate="yes">
1692 <xsl:text>Unknown parameter type: </xsl:text>
1693 <xsl:value-of select="."/>
1694 </xsl:message>
1695 </xsl:otherwise>
1696 </xsl:choose>
1697 </xsl:otherwise>
1698 </xsl:choose>
1699 </xsl:otherwise>
1700 </xsl:choose>
1701</xsl:template>
1702
1703<xsl:template match="
1704 attribute/@type | param/@type |
1705 enumerator/@type | collection/@type | collection/@enumerator
1706" mode="forwarder">
1707
1708 <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
1709
1710 <xsl:choose>
1711 <!-- modifiers (ignored for 'enumeration' attributes)-->
1712 <xsl:when test="name(current())='type' and ../@mod">
1713 <xsl:choose>
1714 <xsl:when test="../@mod='ptr'">
1715 <xsl:choose>
1716 <!-- standard types -->
1717 <!--xsl:when test=".='result'">??</xsl:when-->
1718 <xsl:when test=".='boolean'">PRBool *</xsl:when>
1719 <xsl:when test=".='octet'">PRUint8 *</xsl:when>
1720 <xsl:when test=".='short'">PRInt16 *</xsl:when>
1721 <xsl:when test=".='unsigned short'">PRUint16 *</xsl:when>
1722 <xsl:when test=".='long'">PRInt32 *</xsl:when>
1723 <xsl:when test=".='long long'">PRInt64 *</xsl:when>
1724 <xsl:when test=".='unsigned long'">PRUint32 *</xsl:when>
1725 <xsl:when test=".='unsigned long long'">PRUint64 *</xsl:when>
1726 <xsl:when test=".='char'">char *</xsl:when>
1727 <!--xsl:when test=".='string'">??</xsl:when-->
1728 <xsl:when test=".='wchar'">PRUnichar *</xsl:when>
1729 <!--xsl:when test=".='wstring'">??</xsl:when-->
1730 </xsl:choose>
1731 </xsl:when>
1732 </xsl:choose>
1733 </xsl:when>
1734 <!-- no modifiers -->
1735 <xsl:otherwise>
1736 <xsl:choose>
1737 <!-- standard types -->
1738 <xsl:when test=".='result'">nsresult</xsl:when>
1739 <xsl:when test=".='boolean'">PRBool</xsl:when>
1740 <xsl:when test=".='octet'">PRUint8</xsl:when>
1741 <xsl:when test=".='short'">PRInt16</xsl:when>
1742 <xsl:when test=".='unsigned short'">PRUint16</xsl:when>
1743 <xsl:when test=".='long'">PRInt32</xsl:when>
1744 <xsl:when test=".='long long'">PRInt64</xsl:when>
1745 <xsl:when test=".='unsigned long'">PRUint32</xsl:when>
1746 <xsl:when test=".='unsigned long long'">PRUint64</xsl:when>
1747 <xsl:when test=".='char'">char</xsl:when>
1748 <xsl:when test=".='wchar'">PRUnichar</xsl:when>
1749 <!-- string types -->
1750 <xsl:when test=".='string'">char *</xsl:when>
1751 <xsl:when test=".='wstring'">PRUnichar *</xsl:when>
1752 <!-- UUID type -->
1753 <xsl:when test=".='uuid'">
1754 <xsl:choose>
1755 <xsl:when test="name(..)='attribute'">
1756 <xsl:choose>
1757 <xsl:when test="../@readonly='yes'">
1758 <xsl:text>nsID *</xsl:text>
1759 </xsl:when>
1760 </xsl:choose>
1761 </xsl:when>
1762 <xsl:when test="name(..)='param'">
1763 <xsl:choose>
1764 <xsl:when test="../@dir='in' and not(../@safearray='yes')">
1765 <xsl:text>const nsID *</xsl:text>
1766 </xsl:when>
1767 <xsl:otherwise>
1768 <xsl:text>nsID *</xsl:text>
1769 </xsl:otherwise>
1770 </xsl:choose>
1771 </xsl:when>
1772 </xsl:choose>
1773 </xsl:when>
1774 <!-- system interface types -->
1775 <xsl:when test=".='$unknown'">nsISupports *</xsl:when>
1776 <xsl:otherwise>
1777 <xsl:choose>
1778 <!-- enum types -->
1779 <xsl:when test="
1780 (ancestor::library/enum[@name=current()]) or
1781 (ancestor::library/if[@target=$self_target]/enum[@name=current()])
1782 ">
1783 <xsl:text>PRUint32</xsl:text>
1784 </xsl:when>
1785 <!-- custom interface types -->
1786 <xsl:when test="
1787 (name(current())='enumerator' and
1788 ((ancestor::library/enumerator[@name=current()]) or
1789 (ancestor::library/if[@target=$self_target]/enumerator[@name=current()]))
1790 ) or
1791 ((ancestor::library/interface[@name=current()]) or
1792 (ancestor::library/if[@target=$self_target]/interface[@name=current()])
1793 ) or
1794 ((ancestor::library/collection[@name=current()]) or
1795 (ancestor::library/if[@target=$self_target]/collection[@name=current()])
1796 )
1797 ">
1798 <xsl:value-of select="."/>
1799 <xsl:text> *</xsl:text>
1800 </xsl:when>
1801 <!-- other types -->
1802 </xsl:choose>
1803 </xsl:otherwise>
1804 </xsl:choose>
1805 </xsl:otherwise>
1806 </xsl:choose>
1807</xsl:template>
1808
1809</xsl:stylesheet>
1810
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