VirtualBox

source: vbox/trunk/src/VBox/Main/cbinding/capiidl.xsl@ 52848

Last change on this file since 52848 was 52848, checked in by vboxsync, 10 years ago

Main/cbinding: define typedefs for enums for convenience

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 101.3 KB
Line 
1<?xml version="1.0"?>
2<!-- $Id: capiidl.xsl 52848 2014-09-24 15:47:25Z vboxsync $ -->
3
4<!--
5 * A template to generate a C header file for all relevant XPCOM interfaces
6 * provided or needed for calling the VirtualBox API. The header file also
7 * works on Windows, by using the C bindings header created by the MS COM IDL
8 * compiler (which simultaneously supports C and C++, unlike XPCOM).
9
10 Copyright (C) 2008-2014 Oracle Corporation
11
12 This file is part of VirtualBox Open Source Edition (OSE), as
13 available from http://www.virtualbox.org. This file is free software;
14 you can redistribute it and/or modify it under the terms of the GNU
15 General Public License (GPL) as published by the Free Software
16 Foundation, in version 2 as it comes in the "COPYING" file of the
17 VirtualBox OSE distribution. VirtualBox OSE is distributed in the
18 hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
19-->
20
21<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
22<xsl:output method="text"/>
23
24<xsl:strip-space elements="*"/>
25
26
27<!--
28// helper definitions
29/////////////////////////////////////////////////////////////////////////////
30-->
31
32<!--
33 * capitalizes the first letter
34-->
35<xsl:template name="capitalize">
36 <xsl:param name="str" select="."/>
37 <xsl:value-of select="
38 concat(
39 translate(substring($str,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ'),
40 substring($str,2)
41 )
42 "/>
43</xsl:template>
44
45<!--
46 * uncapitalizes the first letter only if the second one is not capital
47 * otherwise leaves the string unchanged
48-->
49<xsl:template name="uncapitalize">
50 <xsl:param name="str" select="."/>
51 <xsl:choose>
52 <xsl:when test="not(contains('ABCDEFGHIJKLMNOPQRSTUVWXYZ', substring($str,2,1)))">
53 <xsl:value-of select="
54 concat(
55 translate(substring($str,1,1),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),
56 substring($str,2)
57 )
58 "/>
59 </xsl:when>
60 <xsl:otherwise>
61 <xsl:value-of select="string($str)"/>
62 </xsl:otherwise>
63 </xsl:choose>
64</xsl:template>
65
66<!--
67 * translates the string to uppercase
68-->
69<xsl:template name="uppercase">
70 <xsl:param name="str" select="."/>
71 <xsl:value-of select="
72 translate($str,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')
73 "/>
74</xsl:template>
75
76
77<!--
78 * translates the string to lowercase
79-->
80<xsl:template name="lowercase">
81 <xsl:param name="str" select="."/>
82 <xsl:value-of select="
83 translate($str,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')
84 "/>
85</xsl:template>
86
87
88<!--
89// templates
90/////////////////////////////////////////////////////////////////////////////
91-->
92
93
94<!--
95 * not explicitly matched elements and attributes
96-->
97<xsl:template match="*"/>
98
99
100<!--
101 * header
102-->
103<xsl:template match="/idl">
104 <xsl:text>/*
105 * DO NOT EDIT! This is a generated file.
106 *
107 * Header file which provides C declarations for VirtualBox Main API
108 * (COM interfaces), generated from XIDL (XML interface definition).
109 * On Windows (which uses COM instead of XPCOM) the native C support
110 * is used, and most of this file is not used.
111 *
112 * Source : src/VBox/Main/idl/VirtualBox.xidl
113 * Generator : src/VBox/Main/cbinding/capiidl.xsl
114 *
115 * This file contains portions from the following Mozilla XPCOM files:
116 * xpcom/include/xpcom/nsID.h
117 * xpcom/include/nsIException.h
118 * xpcom/include/nsprpub/prtypes.h
119 * xpcom/include/xpcom/nsISupportsBase.h
120 *
121 * These files were originally triple-licensed (MPL/GPL2/LGPL2.1). Oracle
122 * elects to distribute this derived work under the LGPL2.1 only.
123 */
124
125/*
126 * Copyright (C) 2008-2014 Oracle Corporation
127 *
128 * This file is part of a free software library; you can redistribute
129 * it and/or modify it under the terms of the GNU Lesser General
130 * Public License version 2.1 as published by the Free Software
131 * Foundation and shipped in the "COPYING" file with this library.
132 * The library is distributed in the hope that it will be useful,
133 * but WITHOUT ANY WARRANTY of any kind.
134 *
135 * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if
136 * any license choice other than GPL or LGPL is available it will
137 * apply instead, Oracle elects to use only the Lesser General Public
138 * License version 2.1 (LGPLv2) at this time for any software where
139 * a choice of LGPL license versions is made available with the
140 * language indicating that LGPLv2 or any later version may be used,
141 * or where a choice of which version of the LGPL is applied is
142 * otherwise unspecified.
143 */
144
145#ifndef ___VirtualBox_CAPI_h
146#define ___VirtualBox_CAPI_h
147
148#ifdef _WIN32
149# undef COBJMACROS
150# define COBJMACROS
151# include "Windows.h"
152#endif /* _WIN32 */
153
154#ifdef WIN32
155# ifdef IN_VBOXCAPI
156# define VBOXCAPI_DECL(type) extern __declspec(dllexport) type
157# else /* !IN_VBOXCAPI */
158# define VBOXCAPI_DECL(type) __declspec(dllimport) type
159# endif /* !IN_VBOXCAPI */
160#endif /* WIN32 */
161
162#ifdef __cplusplus
163/* The C++ treatment in this file is not meant for SDK users, it only exists
164 * so that this file can be used to produce the VBoxCAPI shared library which
165 * has to use C++ as it does all the conversion magic. */
166# ifdef IN_VBOXCAPI
167# include "VBox/com/VirtualBox.h"
168# ifndef WIN32
169# include "nsIEventQueue.h"
170# endif /* !WIN32 */
171# else /* !IN_VBOXCAPI */
172# error Do not include this header file from C++ code
173# endif /* !IN_VBOXCAPI */
174#endif /* __cplusplus */
175
176#ifdef __GNUC__
177# define VBOX_EXTERN_CONST(type, name) extern const type name __attribute__((nocommon))
178#else /* !__GNUC__ */
179# define VBOX_EXTERN_CONST(type, name) extern const type name
180#endif /* !__GNUC__ */
181
182/* Treat WIN32 completely separately, as on Windows VirtualBox uses COM, not
183 * XPCOM like on all other platforms. While the code below would also compile
184 * on Windows, we need to switch to the native C support provided by the header
185 * files produced by the COM IDL compiler. */
186#ifdef WIN32
187# include "ObjBase.h"
188# include "oaidl.h"
189# include "VirtualBox.h"
190
191#ifndef __cplusplus
192/* Skip this in the C++ case as there's already a definition for CBSTR. */
193typedef const BSTR CBSTR;
194#endif /* !__cplusplus */
195
196#define VBOX_WINAPI WINAPI
197
198#define ComSafeArrayAsInParam(f) (f)
199#define ComSafeArrayAsOutParam(f) (&amp;(f))
200#define ComSafeArrayAsOutTypeParam(f,t) (&amp;(f))
201#define ComSafeArrayAsOutIfaceParam(f,t) (&amp;(f))
202
203#else /* !WIN32 */
204
205#include &lt;stddef.h&gt;
206#include "wchar.h"
207
208#ifdef IN_VBOXCAPI
209# define VBOXCAPI_DECL(type) PR_EXPORT(type)
210#else /* !IN_VBOXCAPI */
211# define VBOXCAPI_DECL(type) PR_IMPORT(type)
212#endif /* !IN_VBOXCAPI */
213
214#ifndef __cplusplus
215
216#if defined(WIN32)
217
218#define PR_EXPORT(__type) extern __declspec(dllexport) __type
219#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
220#define PR_IMPORT(__type) __declspec(dllimport) __type
221#define PR_IMPORT_DATA(__type) __declspec(dllimport) __type
222
223#define PR_EXTERN(__type) extern __declspec(dllexport) __type
224#define PR_IMPLEMENT(__type) __declspec(dllexport) __type
225#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
226#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
227
228#define PR_CALLBACK
229#define PR_CALLBACK_DECL
230#define PR_STATIC_CALLBACK(__x) static __x
231
232#elif defined(XP_BEOS)
233
234#define PR_EXPORT(__type) extern __declspec(dllexport) __type
235#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
236#define PR_IMPORT(__type) extern __declspec(dllexport) __type
237#define PR_IMPORT_DATA(__type) extern __declspec(dllexport) __type
238
239#define PR_EXTERN(__type) extern __declspec(dllexport) __type
240#define PR_IMPLEMENT(__type) __declspec(dllexport) __type
241#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
242#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
243
244#define PR_CALLBACK
245#define PR_CALLBACK_DECL
246#define PR_STATIC_CALLBACK(__x) static __x
247
248#elif defined(WIN16)
249
250#define PR_CALLBACK_DECL __cdecl
251
252#if defined(_WINDLL)
253#define PR_EXPORT(__type) extern __type _cdecl _export _loadds
254#define PR_IMPORT(__type) extern __type _cdecl _export _loadds
255#define PR_EXPORT_DATA(__type) extern __type _export
256#define PR_IMPORT_DATA(__type) extern __type _export
257
258#define PR_EXTERN(__type) extern __type _cdecl _export _loadds
259#define PR_IMPLEMENT(__type) __type _cdecl _export _loadds
260#define PR_EXTERN_DATA(__type) extern __type _export
261#define PR_IMPLEMENT_DATA(__type) __type _export
262
263#define PR_CALLBACK __cdecl __loadds
264#define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK
265
266#else /* this must be .EXE */
267#define PR_EXPORT(__type) extern __type _cdecl _export
268#define PR_IMPORT(__type) extern __type _cdecl _export
269#define PR_EXPORT_DATA(__type) extern __type _export
270#define PR_IMPORT_DATA(__type) extern __type _export
271
272#define PR_EXTERN(__type) extern __type _cdecl _export
273#define PR_IMPLEMENT(__type) __type _cdecl _export
274#define PR_EXTERN_DATA(__type) extern __type _export
275#define PR_IMPLEMENT_DATA(__type) __type _export
276
277#define PR_CALLBACK __cdecl __loadds
278#define PR_STATIC_CALLBACK(__x) __x PR_CALLBACK
279#endif /* _WINDLL */
280
281#elif defined(XP_MAC)
282
283#define PR_EXPORT(__type) extern __declspec(export) __type
284#define PR_EXPORT_DATA(__type) extern __declspec(export) __type
285#define PR_IMPORT(__type) extern __declspec(export) __type
286#define PR_IMPORT_DATA(__type) extern __declspec(export) __type
287
288#define PR_EXTERN(__type) extern __declspec(export) __type
289#define PR_IMPLEMENT(__type) __declspec(export) __type
290#define PR_EXTERN_DATA(__type) extern __declspec(export) __type
291#define PR_IMPLEMENT_DATA(__type) __declspec(export) __type
292
293#define PR_CALLBACK
294#define PR_CALLBACK_DECL
295#define PR_STATIC_CALLBACK(__x) static __x
296
297#elif defined(XP_OS2) &amp;&amp; defined(__declspec)
298
299#define PR_EXPORT(__type) extern __declspec(dllexport) __type
300#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
301#define PR_IMPORT(__type) __declspec(dllimport) __type
302#define PR_IMPORT_DATA(__type) __declspec(dllimport) __type
303
304#define PR_EXTERN(__type) extern __declspec(dllexport) __type
305#define PR_IMPLEMENT(__type) __declspec(dllexport) __type
306#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
307#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
308
309#define PR_CALLBACK
310#define PR_CALLBACK_DECL
311#define PR_STATIC_CALLBACK(__x) static __x
312
313#elif defined(XP_OS2_VACPP)
314
315#define PR_EXPORT(__type) extern __type
316#define PR_EXPORT_DATA(__type) extern __type
317#define PR_IMPORT(__type) extern __type
318#define PR_IMPORT_DATA(__type) extern __type
319
320#define PR_EXTERN(__type) extern __type
321#define PR_IMPLEMENT(__type) __type
322#define PR_EXTERN_DATA(__type) extern __type
323#define PR_IMPLEMENT_DATA(__type) __type
324#define PR_CALLBACK _Optlink
325#define PR_CALLBACK_DECL
326#define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK
327
328#else /* Unix */
329
330# ifdef VBOX_HAVE_VISIBILITY_HIDDEN
331# define PR_EXPORT(__type) __attribute__((visibility("default"))) extern __type
332# define PR_EXPORT_DATA(__type) __attribute__((visibility("default"))) extern __type
333# define PR_IMPORT(__type) extern __type
334# define PR_IMPORT_DATA(__type) extern __type
335# define PR_EXTERN(__type) __attribute__((visibility("default"))) extern __type
336# define PR_IMPLEMENT(__type) __attribute__((visibility("default"))) __type
337# define PR_EXTERN_DATA(__type) __attribute__((visibility("default"))) extern __type
338# define PR_IMPLEMENT_DATA(__type) __attribute__((visibility("default"))) __type
339# define PR_CALLBACK
340# define PR_CALLBACK_DECL
341# define PR_STATIC_CALLBACK(__x) static __x
342# else
343# define PR_EXPORT(__type) extern __type
344# define PR_EXPORT_DATA(__type) extern __type
345# define PR_IMPORT(__type) extern __type
346# define PR_IMPORT_DATA(__type) extern __type
347# define PR_EXTERN(__type) extern __type
348# define PR_IMPLEMENT(__type) __type
349# define PR_EXTERN_DATA(__type) extern __type
350# define PR_IMPLEMENT_DATA(__type) __type
351# define PR_CALLBACK
352# define PR_CALLBACK_DECL
353# define PR_STATIC_CALLBACK(__x) static __x
354# endif
355#endif
356
357#if defined(_NSPR_BUILD_)
358#define NSPR_API(__type) PR_EXPORT(__type)
359#define NSPR_DATA_API(__type) PR_EXPORT_DATA(__type)
360#else
361#define NSPR_API(__type) PR_IMPORT(__type)
362#define NSPR_DATA_API(__type) PR_IMPORT_DATA(__type)
363#endif
364
365typedef unsigned char PRUint8;
366#if (defined(HPUX) &amp;&amp; defined(__cplusplus) \
367 &amp;&amp; !defined(__GNUC__) &amp;&amp; __cplusplus &lt; 199707L) \
368 || (defined(SCO) &amp;&amp; defined(__cplusplus) \
369 &amp;&amp; !defined(__GNUC__) &amp;&amp; __cplusplus == 1L)
370typedef char PRInt8;
371#else
372typedef signed char PRInt8;
373#endif
374
375#define PR_INT8_MAX 127
376#define PR_INT8_MIN (-128)
377#define PR_UINT8_MAX 255U
378
379typedef unsigned short PRUint16;
380typedef short PRInt16;
381
382#define PR_INT16_MAX 32767
383#define PR_INT16_MIN (-32768)
384#define PR_UINT16_MAX 65535U
385
386typedef unsigned int PRUint32;
387typedef int PRInt32;
388#define PR_INT32(x) x
389#define PR_UINT32(x) x ## U
390
391#define PR_INT32_MAX PR_INT32(2147483647)
392#define PR_INT32_MIN (-PR_INT32_MAX - 1)
393#define PR_UINT32_MAX PR_UINT32(4294967295)
394
395typedef long PRInt64;
396typedef unsigned long PRUint64;
397typedef int PRIntn;
398typedef unsigned int PRUintn;
399
400typedef double PRFloat64;
401typedef size_t PRSize;
402
403typedef ptrdiff_t PRPtrdiff;
404
405typedef unsigned long PRUptrdiff;
406
407typedef PRIntn PRBool;
408
409#define PR_TRUE 1
410#define PR_FALSE 0
411
412typedef PRUint8 PRPackedBool;
413
414/*
415** Status code used by some routines that have a single point of failure or
416** special status return.
417*/
418typedef enum { PR_FAILURE = -1, PR_SUCCESS = 0 } PRStatus;
419
420#ifndef __PRUNICHAR__
421#define __PRUNICHAR__
422#if defined(WIN32) || defined(XP_MAC)
423typedef wchar_t PRUnichar;
424#else
425typedef PRUint16 PRUnichar;
426#endif
427typedef PRUnichar *BSTR;
428typedef const PRUnichar *CBSTR;
429#endif
430
431typedef long PRWord;
432typedef unsigned long PRUword;
433
434#define nsnull 0
435typedef PRUint32 nsresult;
436
437#if defined(__GNUC__) &amp;&amp; (__GNUC__ > 2)
438#define NS_LIKELY(x) (__builtin_expect((x), 1))
439#define NS_UNLIKELY(x) (__builtin_expect((x), 0))
440#else
441#define NS_LIKELY(x) (x)
442#define NS_UNLIKELY(x) (x)
443#endif
444
445#define NS_FAILED(_nsresult) (NS_UNLIKELY((_nsresult) &amp; 0x80000000))
446#define NS_SUCCEEDED(_nsresult) (NS_LIKELY(!((_nsresult) &amp; 0x80000000)))
447
448#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
449# define PR_IntervalNow VBoxNsprPR_IntervalNow
450# define PR_TicksPerSecond VBoxNsprPR_TicksPerSecond
451# define PR_SecondsToInterval VBoxNsprPR_SecondsToInterval
452# define PR_MillisecondsToInterval VBoxNsprPR_MillisecondsToInterval
453# define PR_MicrosecondsToInterval VBoxNsprPR_MicrosecondsToInterval
454# define PR_IntervalToSeconds VBoxNsprPR_IntervalToSeconds
455# define PR_IntervalToMilliseconds VBoxNsprPR_IntervalToMilliseconds
456# define PR_IntervalToMicroseconds VBoxNsprPR_IntervalToMicroseconds
457# define PR_EnterMonitor VBoxNsprPR_EnterMonitor
458# define PR_ExitMonitor VBoxNsprPR_ExitMonitor
459# define PR_Notify VBoxNsprPR_Notify
460# define PR_NotifyAll VBoxNsprPR_NotifyAll
461# define PR_Wait VBoxNsprPR_Wait
462# define PR_NewMonitor VBoxNsprPR_NewMonitor
463# define PR_DestroyMonitor VBoxNsprPR_DestroyMonitor
464#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
465
466typedef PRUint32 PRIntervalTime;
467
468#define PR_INTERVAL_MIN 1000UL
469#define PR_INTERVAL_MAX 100000UL
470#define PR_INTERVAL_NO_WAIT 0UL
471#define PR_INTERVAL_NO_TIMEOUT 0xffffffffUL
472
473NSPR_API(PRIntervalTime) PR_IntervalNow(void);
474NSPR_API(PRUint32) PR_TicksPerSecond(void);
475NSPR_API(PRIntervalTime) PR_SecondsToInterval(PRUint32 seconds);
476NSPR_API(PRIntervalTime) PR_MillisecondsToInterval(PRUint32 milli);
477NSPR_API(PRIntervalTime) PR_MicrosecondsToInterval(PRUint32 micro);
478NSPR_API(PRUint32) PR_IntervalToSeconds(PRIntervalTime ticks);
479NSPR_API(PRUint32) PR_IntervalToMilliseconds(PRIntervalTime ticks);
480NSPR_API(PRUint32) PR_IntervalToMicroseconds(PRIntervalTime ticks);
481
482typedef struct PRMonitor PRMonitor;
483
484NSPR_API(PRMonitor*) PR_NewMonitor(void);
485NSPR_API(void) PR_DestroyMonitor(PRMonitor *mon);
486NSPR_API(void) PR_EnterMonitor(PRMonitor *mon);
487NSPR_API(PRStatus) PR_ExitMonitor(PRMonitor *mon);
488NSPR_API(PRStatus) PR_Wait(PRMonitor *mon, PRIntervalTime ticks);
489NSPR_API(PRStatus) PR_Notify(PRMonitor *mon);
490NSPR_API(PRStatus) PR_NotifyAll(PRMonitor *mon);
491
492#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
493# define PR_CreateThread VBoxNsprPR_CreateThread
494# define PR_JoinThread VBoxNsprPR_JoinThread
495# define PR_Sleep VBoxNsprPR_Sleep
496# define PR_GetCurrentThread VBoxNsprPR_GetCurrentThread
497# define PR_GetThreadState VBoxNsprPR_GetThreadState
498# define PR_SetThreadPrivate VBoxNsprPR_SetThreadPrivate
499# define PR_GetThreadPrivate VBoxNsprPR_GetThreadPrivate
500# define PR_NewThreadPrivateIndex VBoxNsprPR_NewThreadPrivateIndex
501# define PR_GetThreadPriority VBoxNsprPR_GetThreadPriority
502# define PR_SetThreadPriority VBoxNsprPR_SetThreadPriority
503# define PR_Interrupt VBoxNsprPR_Interrupt
504# define PR_ClearInterrupt VBoxNsprPR_ClearInterrupt
505# define PR_BlockInterrupt VBoxNsprPR_BlockInterrupt
506# define PR_UnblockInterrupt VBoxNsprPR_UnblockInterrupt
507# define PR_GetThreadScope VBoxNsprPR_GetThreadScope
508# define PR_GetThreadType VBoxNsprPR_GetThreadType
509#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
510
511typedef struct PRThread PRThread;
512typedef struct PRThreadStack PRThreadStack;
513
514typedef enum PRThreadType {
515 PR_USER_THREAD,
516 PR_SYSTEM_THREAD
517} PRThreadType;
518
519typedef enum PRThreadScope {
520 PR_LOCAL_THREAD,
521 PR_GLOBAL_THREAD,
522 PR_GLOBAL_BOUND_THREAD
523} PRThreadScope;
524
525typedef enum PRThreadState {
526 PR_JOINABLE_THREAD,
527 PR_UNJOINABLE_THREAD
528} PRThreadState;
529
530typedef enum PRThreadPriority
531{
532 PR_PRIORITY_FIRST = 0, /* just a placeholder */
533 PR_PRIORITY_LOW = 0, /* the lowest possible priority */
534 PR_PRIORITY_NORMAL = 1, /* most common expected priority */
535 PR_PRIORITY_HIGH = 2, /* slightly more aggressive scheduling */
536 PR_PRIORITY_URGENT = 3, /* it does little good to have more than one */
537 PR_PRIORITY_LAST = 3 /* this is just a placeholder */
538} PRThreadPriority;
539
540NSPR_API(PRThread*) PR_CreateThread(PRThreadType type,
541 void (PR_CALLBACK *start)(void *arg),
542 void *arg,
543 PRThreadPriority priority,
544 PRThreadScope scope,
545 PRThreadState state,
546 PRUint32 stackSize);
547NSPR_API(PRStatus) PR_JoinThread(PRThread *thread);
548NSPR_API(PRThread*) PR_GetCurrentThread(void);
549#ifndef NO_NSPR_10_SUPPORT
550#define PR_CurrentThread() PR_GetCurrentThread() /* for nspr1.0 compat. */
551#endif /* NO_NSPR_10_SUPPORT */
552NSPR_API(PRThreadPriority) PR_GetThreadPriority(const PRThread *thread);
553NSPR_API(void) PR_SetThreadPriority(PRThread *thread, PRThreadPriority priority);
554
555typedef void (PR_CALLBACK *PRThreadPrivateDTOR)(void *priv);
556
557NSPR_API(PRStatus) PR_NewThreadPrivateIndex(
558 PRUintn *newIndex, PRThreadPrivateDTOR destructor);
559NSPR_API(PRStatus) PR_SetThreadPrivate(PRUintn tpdIndex, void *priv);
560NSPR_API(void*) PR_GetThreadPrivate(PRUintn tpdIndex);
561NSPR_API(PRStatus) PR_Interrupt(PRThread *thread);
562NSPR_API(void) PR_ClearInterrupt(void);
563NSPR_API(void) PR_BlockInterrupt(void);
564NSPR_API(void) PR_UnblockInterrupt(void);
565NSPR_API(PRStatus) PR_Sleep(PRIntervalTime ticks);
566NSPR_API(PRThreadScope) PR_GetThreadScope(const PRThread *thread);
567NSPR_API(PRThreadType) PR_GetThreadType(const PRThread *thread);
568NSPR_API(PRThreadState) PR_GetThreadState(const PRThread *thread);
569
570#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
571# define PR_DestroyLock VBoxNsprPR_DestroyLock
572# define PR_Lock VBoxNsprPR_Lock
573# define PR_NewLock VBoxNsprPR_NewLock
574# define PR_Unlock VBoxNsprPR_Unlock
575#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
576
577typedef struct PRLock PRLock;
578
579NSPR_API(PRLock*) PR_NewLock(void);
580NSPR_API(void) PR_DestroyLock(PRLock *lock);
581NSPR_API(void) PR_Lock(PRLock *lock);
582NSPR_API(PRStatus) PR_Unlock(PRLock *lock);
583
584#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
585# define PR_NewCondVar VBoxNsprPR_NewCondVar
586# define PR_DestroyCondVar VBoxNsprPR_DestroyCondVar
587# define PR_WaitCondVar VBoxNsprPR_WaitCondVar
588# define PR_NotifyCondVar VBoxNsprPR_NotifyCondVar
589# define PR_NotifyAllCondVar VBoxNsprPR_NotifyAllCondVar
590#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
591
592typedef struct PRCondVar PRCondVar;
593
594NSPR_API(PRCondVar*) PR_NewCondVar(PRLock *lock);
595NSPR_API(void) PR_DestroyCondVar(PRCondVar *cvar);
596NSPR_API(PRStatus) PR_WaitCondVar(PRCondVar *cvar, PRIntervalTime timeout);
597NSPR_API(PRStatus) PR_NotifyCondVar(PRCondVar *cvar);
598NSPR_API(PRStatus) PR_NotifyAllCondVar(PRCondVar *cvar);
599
600typedef struct PRCListStr PRCList;
601
602struct PRCListStr {
603 PRCList *next;
604 PRCList *prev;
605};
606
607#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
608# define PL_DestroyEvent VBoxNsplPL_DestroyEvent
609# define PL_HandleEvent VBoxNsplPL_HandleEvent
610# define PL_InitEvent VBoxNsplPL_InitEvent
611# define PL_CreateEventQueue VBoxNsplPL_CreateEventQueue
612# define PL_CreateMonitoredEventQueue VBoxNsplPL_CreateMonitoredEventQueue
613# define PL_CreateNativeEventQueue VBoxNsplPL_CreateNativeEventQueue
614# define PL_DequeueEvent VBoxNsplPL_DequeueEvent
615# define PL_DestroyEventQueue VBoxNsplPL_DestroyEventQueue
616# define PL_EventAvailable VBoxNsplPL_EventAvailable
617# define PL_EventLoop VBoxNsplPL_EventLoop
618# define PL_GetEvent VBoxNsplPL_GetEvent
619# define PL_GetEventOwner VBoxNsplPL_GetEventOwner
620# define PL_GetEventQueueMonitor VBoxNsplPL_GetEventQueueMonitor
621# define PL_GetEventQueueSelectFD VBoxNsplPL_GetEventQueueSelectFD
622# define PL_MapEvents VBoxNsplPL_MapEvents
623# define PL_PostEvent VBoxNsplPL_PostEvent
624# define PL_PostSynchronousEvent VBoxNsplPL_PostSynchronousEvent
625# define PL_ProcessEventsBeforeID VBoxNsplPL_ProcessEventsBeforeID
626# define PL_ProcessPendingEvents VBoxNsplPL_ProcessPendingEvents
627# define PL_RegisterEventIDFunc VBoxNsplPL_RegisterEventIDFunc
628# define PL_RevokeEvents VBoxNsplPL_RevokeEvents
629# define PL_UnregisterEventIDFunc VBoxNsplPL_UnregisterEventIDFunc
630# define PL_WaitForEvent VBoxNsplPL_WaitForEvent
631# define PL_IsQueueNative VBoxNsplPL_IsQueueNative
632# define PL_IsQueueOnCurrentThread VBoxNsplPL_IsQueueOnCurrentThread
633# define PL_FavorPerformanceHint VBoxNsplPL_FavorPerformanceHint
634#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
635
636typedef struct PLEvent PLEvent;
637typedef struct PLEventQueue PLEventQueue;
638
639PR_EXTERN(PLEventQueue*)
640PL_CreateEventQueue(const char* name, PRThread* handlerThread);
641PR_EXTERN(PLEventQueue *)
642 PL_CreateNativeEventQueue(
643 const char *name,
644 PRThread *handlerThread
645 );
646PR_EXTERN(PLEventQueue *)
647 PL_CreateMonitoredEventQueue(
648 const char *name,
649 PRThread *handlerThread
650 );
651PR_EXTERN(void)
652PL_DestroyEventQueue(PLEventQueue* self);
653PR_EXTERN(PRMonitor*)
654PL_GetEventQueueMonitor(PLEventQueue* self);
655
656#define PL_ENTER_EVENT_QUEUE_MONITOR(queue) \
657 PR_EnterMonitor(PL_GetEventQueueMonitor(queue))
658
659#define PL_EXIT_EVENT_QUEUE_MONITOR(queue) \
660 PR_ExitMonitor(PL_GetEventQueueMonitor(queue))
661
662PR_EXTERN(PRStatus) PL_PostEvent(PLEventQueue* self, PLEvent* event);
663PR_EXTERN(void*) PL_PostSynchronousEvent(PLEventQueue* self, PLEvent* event);
664PR_EXTERN(PLEvent*) PL_GetEvent(PLEventQueue* self);
665PR_EXTERN(PRBool) PL_EventAvailable(PLEventQueue* self);
666
667typedef void (PR_CALLBACK *PLEventFunProc)(PLEvent* event, void* data, PLEventQueue* queue);
668
669PR_EXTERN(void) PL_MapEvents(PLEventQueue* self, PLEventFunProc fun, void* data);
670PR_EXTERN(void) PL_RevokeEvents(PLEventQueue* self, void* owner);
671PR_EXTERN(void) PL_ProcessPendingEvents(PLEventQueue* self);
672PR_EXTERN(PLEvent*) PL_WaitForEvent(PLEventQueue* self);
673PR_EXTERN(void) PL_EventLoop(PLEventQueue* self);
674PR_EXTERN(PRInt32) PL_GetEventQueueSelectFD(PLEventQueue* self);
675PR_EXTERN(PRBool) PL_IsQueueOnCurrentThread( PLEventQueue *queue );
676PR_EXTERN(PRBool) PL_IsQueueNative(PLEventQueue *queue);
677
678typedef void* (PR_CALLBACK *PLHandleEventProc)(PLEvent* self);
679typedef void (PR_CALLBACK *PLDestroyEventProc)(PLEvent* self);
680PR_EXTERN(void)
681PL_InitEvent(PLEvent* self, void* owner,
682 PLHandleEventProc handler,
683 PLDestroyEventProc destructor);
684PR_EXTERN(void*) PL_GetEventOwner(PLEvent* self);
685PR_EXTERN(void) PL_HandleEvent(PLEvent* self);
686PR_EXTERN(void) PL_DestroyEvent(PLEvent* self);
687PR_EXTERN(void) PL_DequeueEvent(PLEvent* self, PLEventQueue* queue);
688PR_EXTERN(void) PL_FavorPerformanceHint(PRBool favorPerformanceOverEventStarvation, PRUint32 starvationDelay);
689
690struct PLEvent {
691 PRCList link;
692 PLHandleEventProc handler;
693 PLDestroyEventProc destructor;
694 void* owner;
695 void* synchronousResult;
696 PRLock* lock;
697 PRCondVar* condVar;
698 PRBool handled;
699#ifdef PL_POST_TIMINGS
700 PRIntervalTime postTime;
701#endif
702#ifdef XP_UNIX
703 unsigned long id;
704#endif /* XP_UNIX */
705 /* other fields follow... */
706};
707
708#if defined(XP_WIN) || defined(XP_OS2)
709
710PR_EXTERN(HWND)
711 PL_GetNativeEventReceiverWindow(
712 PLEventQueue *eqp
713 );
714#endif /* XP_WIN || XP_OS2 */
715
716#ifdef XP_UNIX
717
718PR_EXTERN(PRInt32)
719PL_ProcessEventsBeforeID(PLEventQueue *aSelf, unsigned long aID);
720
721typedef unsigned long (PR_CALLBACK *PLGetEventIDFunc)(void *aClosure);
722
723PR_EXTERN(void)
724PL_RegisterEventIDFunc(PLEventQueue *aSelf, PLGetEventIDFunc aFunc,
725 void *aClosure);
726PR_EXTERN(void) PL_UnregisterEventIDFunc(PLEventQueue *aSelf);
727
728#endif /* XP_UNIX */
729
730/* Standard "it worked" return value */
731#define NS_OK 0
732
733#define NS_ERROR_BASE ((nsresult) 0xC1F30000)
734
735/* Returned when an instance is not initialized */
736#define NS_ERROR_NOT_INITIALIZED (NS_ERROR_BASE + 1)
737
738/* Returned when an instance is already initialized */
739#define NS_ERROR_ALREADY_INITIALIZED (NS_ERROR_BASE + 2)
740
741/* Returned by a not implemented function */
742#define NS_ERROR_NOT_IMPLEMENTED ((nsresult) 0x80004001L)
743
744/* Returned when a given interface is not supported. */
745#define NS_NOINTERFACE ((nsresult) 0x80004002L)
746#define NS_ERROR_NO_INTERFACE NS_NOINTERFACE
747
748#define NS_ERROR_INVALID_POINTER ((nsresult) 0x80004003L)
749#define NS_ERROR_NULL_POINTER NS_ERROR_INVALID_POINTER
750
751/* Returned when a function aborts */
752#define NS_ERROR_ABORT ((nsresult) 0x80004004L)
753
754/* Returned when a function fails */
755#define NS_ERROR_FAILURE ((nsresult) 0x80004005L)
756
757/* Returned when an unexpected error occurs */
758#define NS_ERROR_UNEXPECTED ((nsresult) 0x8000ffffL)
759
760/* Returned when a memory allocation fails */
761#define NS_ERROR_OUT_OF_MEMORY ((nsresult) 0x8007000eL)
762
763/* Returned when an illegal value is passed */
764#define NS_ERROR_ILLEGAL_VALUE ((nsresult) 0x80070057L)
765#define NS_ERROR_INVALID_ARG NS_ERROR_ILLEGAL_VALUE
766
767/* Returned when a class doesn't allow aggregation */
768#define NS_ERROR_NO_AGGREGATION ((nsresult) 0x80040110L)
769
770/* Returned when an operation can't complete due to an unavailable resource */
771#define NS_ERROR_NOT_AVAILABLE ((nsresult) 0x80040111L)
772
773/* Returned when a class is not registered */
774#define NS_ERROR_FACTORY_NOT_REGISTERED ((nsresult) 0x80040154L)
775
776/* Returned when a class cannot be registered, but may be tried again later */
777#define NS_ERROR_FACTORY_REGISTER_AGAIN ((nsresult) 0x80040155L)
778
779/* Returned when a dynamically loaded factory couldn't be found */
780#define NS_ERROR_FACTORY_NOT_LOADED ((nsresult) 0x800401f8L)
781
782/* Returned when a factory doesn't support signatures */
783#define NS_ERROR_FACTORY_NO_SIGNATURE_SUPPORT \
784 (NS_ERROR_BASE + 0x101)
785
786/* Returned when a factory already is registered */
787#define NS_ERROR_FACTORY_EXISTS (NS_ERROR_BASE + 0x100)
788
789/**
790 * An "interface id" which can be used to uniquely identify a given
791 * interface.
792 * A "unique identifier". This is modeled after OSF DCE UUIDs.
793 */
794
795struct nsID {
796 PRUint32 m0;
797 PRUint16 m1;
798 PRUint16 m2;
799 PRUint8 m3[8];
800};
801
802typedef struct nsID nsID;
803typedef nsID nsIID;
804typedef nsID nsCID;
805
806#endif /* __cplusplus */
807
808#define VBOX_WINAPI
809
810/* Various COM types defined by their XPCOM equivalent */
811typedef PRInt64 LONG64;
812typedef PRInt32 LONG;
813typedef PRInt32 DWORD;
814typedef PRInt16 SHORT;
815typedef PRUint64 ULONG64;
816typedef PRUint32 ULONG;
817typedef PRUint16 USHORT;
818
819typedef PRBool BOOL;
820
821#ifndef FALSE
822#define FALSE 0
823#define TRUE 1
824#endif
825
826#define HRESULT nsresult
827#define SUCCEEDED NS_SUCCEEDED
828#define FAILED NS_FAILED
829
830/* OLE error codes */
831#define S_OK ((nsresult)NS_OK)
832#define E_UNEXPECTED NS_ERROR_UNEXPECTED
833#define E_NOTIMPL NS_ERROR_NOT_IMPLEMENTED
834#define E_OUTOFMEMORY NS_ERROR_OUT_OF_MEMORY
835#define E_INVALIDARG NS_ERROR_INVALID_ARG
836#define E_NOINTERFACE NS_ERROR_NO_INTERFACE
837#define E_POINTER NS_ERROR_NULL_POINTER
838#define E_ABORT NS_ERROR_ABORT
839#define E_FAIL NS_ERROR_FAILURE
840/* Note: a better analog for E_ACCESSDENIED would probably be
841 * NS_ERROR_NOT_AVAILABLE, but we want binary compatibility for now. */
842#define E_ACCESSDENIED ((nsresult)0x80070005L)
843
844/* Basic vartype for COM compatibility. */
845typedef enum VARTYPE
846{
847 VT_I2 = 2,
848 VT_I4 = 3,
849 VT_BSTR = 8,
850 VT_DISPATCH = 9,
851 VT_BOOL = 11,
852 VT_UNKNOWN = 13,
853 VT_I1 = 16,
854 VT_UI1 = 17,
855 VT_UI2 = 18,
856 VT_UI4 = 19,
857 VT_I8 = 20,
858 VT_UI8 = 21,
859 VT_HRESULT = 25
860} VARTYPE;
861
862/* Basic safearray type for COM compatibility. */
863typedef struct SAFEARRAY
864{
865 void *pv;
866 ULONG c;
867} SAFEARRAY;
868
869#define ComSafeArrayAsInParam(f) ((f)->c), ((f)->pv)
870#define ComSafeArrayAsOutParam(f) (&amp;((f)->c)), (&amp;((f)->pv))
871#define ComSafeArrayAsOutTypeParam(f,t) (&amp;((f)->c)), (t**)(&amp;((f)->pv))
872#define ComSafeArrayAsOutIfaceParam(f,t) (&amp;((f)->c)), (t**)(&amp;((f)->pv))
873
874/* Glossing over differences between COM and XPCOM */
875#define IErrorInfo nsIException
876#define IUnknown nsISupports
877#define IDispatch nsISupports
878
879/* Make things as COM compatible as possible */
880#define interface struct
881#ifdef CONST_VTABLE
882# define CONST_VTBL const
883#else /* !CONST_VTABLE */
884# define CONST_VTBL
885#endif /* !CONST_VTABLE */
886
887#ifndef __cplusplus
888
889/** @todo this first batch of forward declarations (and the corresponding ones
890 * generated for each interface) are 100% redundant, remove eventually. */
891interface nsISupports; /* forward declaration */
892interface nsIException; /* forward declaration */
893interface nsIStackFrame; /* forward declaration */
894interface nsIEventTarget;/* forward declaration */
895interface nsIEventQueue; /* forward declaration */
896
897typedef interface nsISupports nsISupports; /* forward declaration */
898typedef interface nsIException nsIException; /* forward declaration */
899typedef interface nsIStackFrame nsIStackFrame; /* forward declaration */
900typedef interface nsIEventTarget nsIEventTarget;/* forward declaration */
901typedef interface nsIEventQueue nsIEventQueue; /* forward declaration */
902
903/* starting interface: nsISupports */
904#define NS_ISUPPORTS_IID_STR "00000000-0000-0000-c000-000000000046"
905
906#define NS_ISUPPORTS_IID \
907 { 0x00000000, 0x0000, 0x0000, \
908 {0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} }
909
910/**
911 * Reference count values
912 *
913 * This is the return type for AddRef() and Release() in nsISupports.
914 * IUnknown of COM returns an unsigned long from equivalent functions.
915 * The following ifdef exists to maintain binary compatibility with
916 * IUnknown.
917 */
918#if defined(XP_WIN) &amp;&amp; PR_BYTES_PER_LONG == 4
919typedef unsigned long nsrefcnt;
920#else
921typedef PRUint32 nsrefcnt;
922#endif
923
924/**
925 * Basic component object model interface. Objects which implement
926 * this interface support runtime interface discovery (QueryInterface)
927 * and a reference counted memory model (AddRef/Release). This is
928 * modelled after the win32 IUnknown API.
929 */
930#ifndef VBOX_WITH_GLUE
931struct nsISupports_vtbl
932{
933 nsresult (*QueryInterface)(nsISupports *pThis, const nsID *iid, void **resultp);
934 nsrefcnt (*AddRef)(nsISupports *pThis);
935 nsrefcnt (*Release)(nsISupports *pThis);
936};
937#else /* !VBOX_WITH_GLUE */
938struct nsISupportsVtbl
939{
940 nsresult (*QueryInterface)(nsISupports *pThis, const nsID *iid, void **resultp);
941 nsrefcnt (*AddRef)(nsISupports *pThis);
942 nsrefcnt (*Release)(nsISupports *pThis);
943};
944#define nsISupports_QueryInterface(p, iid, resultp) ((p)->lpVtbl->QueryInterface(p, iid, resultp))
945#define nsISupports_AddRef(p) ((p)->lpVtbl->AddRef(p))
946#define nsISupports_Release(p) ((p)->lpVtbl->Release(p))
947#define IUnknown_QueryInterface(p, iid, resultp) ((p)->lpVtbl->QueryInterface(p, iid, resultp))
948#define IUnknown_AddRef(p) ((p)->lpVtbl->AddRef(p))
949#define IUnknown_Release(p) ((p)->lpVtbl->Release(p))
950#define IDispatch_QueryInterface(p, iid, resultp) ((p)->lpVtbl->QueryInterface(p, iid, resultp))
951#define IDispatch_AddRef(p) ((p)->lpVtbl->AddRef(p))
952#define IDispatch_Release(p) ((p)->lpVtbl->Release(p))
953#endif /* !VBOX_WITH_GLUE */
954
955interface nsISupports
956{
957#ifndef VBOX_WITH_GLUE
958 struct nsISupports_vtbl *vtbl;
959#else /* !VBOX_WITH_GLUE */
960 CONST_VTBL struct nsISupportsVtbl *lpVtbl;
961#endif /* !VBOX_WITH_GLUE */
962};
963
964/* starting interface: nsIException */
965#define NS_IEXCEPTION_IID_STR "f3a8d3b4-c424-4edc-8bf6-8974c983ba78"
966
967#define NS_IEXCEPTION_IID \
968 {0xf3a8d3b4, 0xc424, 0x4edc, \
969 { 0x8b, 0xf6, 0x89, 0x74, 0xc9, 0x83, 0xba, 0x78 }}
970
971#ifndef VBOX_WITH_GLUE
972struct nsIException_vtbl
973{
974 /* Methods from the interface nsISupports */
975 struct nsISupports_vtbl nsisupports;
976
977 nsresult (*GetMessage)(nsIException *pThis, PRUnichar * *aMessage);
978 nsresult (*GetResult)(nsIException *pThis, nsresult *aResult);
979 nsresult (*GetName)(nsIException *pThis, PRUnichar * *aName);
980 nsresult (*GetFilename)(nsIException *pThis, PRUnichar * *aFilename);
981 nsresult (*GetLineNumber)(nsIException *pThis, PRUint32 *aLineNumber);
982 nsresult (*GetColumnNumber)(nsIException *pThis, PRUint32 *aColumnNumber);
983 nsresult (*GetLocation)(nsIException *pThis, nsIStackFrame * *aLocation);
984 nsresult (*GetInner)(nsIException *pThis, nsIException * *aInner);
985 nsresult (*GetData)(nsIException *pThis, nsISupports * *aData);
986 nsresult (*ToString)(nsIException *pThis, PRUnichar **_retval);
987};
988#else /* !VBOX_WITH_GLUE */
989struct nsIExceptionVtbl
990{
991 nsresult (*QueryInterface)(nsIException *pThis, const nsID *iid, void **resultp);
992 nsrefcnt (*AddRef)(nsIException *pThis);
993 nsrefcnt (*Release)(nsIException *pThis);
994
995 nsresult (*GetMessage)(nsIException *pThis, PRUnichar * *aMessage);
996 nsresult (*GetResult)(nsIException *pThis, nsresult *aResult);
997 nsresult (*GetName)(nsIException *pThis, PRUnichar * *aName);
998 nsresult (*GetFilename)(nsIException *pThis, PRUnichar * *aFilename);
999 nsresult (*GetLineNumber)(nsIException *pThis, PRUint32 *aLineNumber);
1000 nsresult (*GetColumnNumber)(nsIException *pThis, PRUint32 *aColumnNumber);
1001 nsresult (*GetLocation)(nsIException *pThis, nsIStackFrame * *aLocation);
1002 nsresult (*GetInner)(nsIException *pThis, nsIException * *aInner);
1003 nsresult (*GetData)(nsIException *pThis, nsISupports * *aData);
1004 nsresult (*ToString)(nsIException *pThis, PRUnichar **_retval);
1005};
1006#define nsIException_QueryInterface(p, iid, resultp) ((p)->lpVtbl->QueryInterface(p, iid, resultp))
1007#define nsIException_AddRef(p) ((p)->lpVtbl->AddRef(p))
1008#define nsIException_Release(p) ((p)->lpVtbl->Release(p))
1009#define nsIException_get_Message(p, aMessage) ((p)->lpVtbl->GetMessage(p, aMessage))
1010#define nsIException_GetMessage(p, aMessage) ((p)->lpVtbl->GetMessage(p, aMessage))
1011#define nsIException_get_Result(p, aResult) ((p)->lpVtbl->GetResult(p, aResult))
1012#define nsIException_GetResult(p, aResult) ((p)->lpVtbl->GetResult(p, aResult))
1013#define nsIException_get_Name(p, aName) ((p)->lpVtbl->GetName(p, aName))
1014#define nsIException_GetName(p, aName) ((p)->lpVtbl->GetName(p, aName))
1015#define nsIException_get_Filename(p, aFilename) ((p)->lpVtbl->GetFilename(p, aFilename))
1016#define nsIException_GetFilename(p, aFilename) ((p)->lpVtbl->GetFilename(p, aFilename))
1017#define nsIException_get_LineNumber(p, aLineNumber) ((p)->lpVtbl->GetLineNumber(p, aLineNumber))
1018#define nsIException_GetLineNumber(p, aLineNumber) ((p)->lpVtbl->GetLineNumber(p, aLineNumber))
1019#define nsIException_get_ColumnNumber(p, aColumnNumber) ((p)->lpVtbl->GetColumnNumber(p, aColumnNumber))
1020#define nsIException_GetColumnNumber(p, aColumnNumber) ((p)->lpVtbl->GetColumnNumber(p, aColumnNumber))
1021#define nsIException_get_Inner(p, aInner) ((p)->lpVtbl->GetInner(p, aInner))
1022#define nsIException_GetInner(p, aInner) ((p)->lpVtbl->GetInner(p, aInner))
1023#define nsIException_get_Data(p, aData) ((p)->lpVtbl->GetData(p, aData))
1024#define nsIException_GetData(p, aData) ((p)->lpVtbl->GetData(p, aData))
1025#define nsIException_ToString(p, retval) ((p)->lpVtbl->ToString(p, retval))
1026#define IErrorInfo_QueryInterface(p, iid, resultp) ((p)->lpVtbl->QueryInterface(p, iid, resultp))
1027#define IErrorInfo_AddRef(p) ((p)->lpVtbl->AddRef(p))
1028#define IErrorInfo_Release(p) ((p)->lpVtbl->Release(p))
1029#define IErrorInfo_get_Message(p, aMessage) ((p)->lpVtbl->GetMessage(p, aMessage))
1030#define IErrorInfo_GetMessage(p, aMessage) ((p)->lpVtbl->GetMessage(p, aMessage))
1031#define IErrorInfo_get_Result(p, aResult) ((p)->lpVtbl->GetResult(p, aResult))
1032#define IErrorInfo_GetResult(p, aResult) ((p)->lpVtbl->GetResult(p, aResult))
1033#define IErrorInfo_get_Name(p, aName) ((p)->lpVtbl->GetName(p, aName))
1034#define IErrorInfo_GetName(p, aName) ((p)->lpVtbl->GetName(p, aName))
1035#define IErrorInfo_get_Filename(p, aFilename) ((p)->lpVtbl->GetFilename(p, aFilename))
1036#define IErrorInfo_GetFilename(p, aFilename) ((p)->lpVtbl->GetFilename(p, aFilename))
1037#define IErrorInfo_get_LineNumber(p, aLineNumber) ((p)->lpVtbl->GetLineNumber(p, aLineNumber))
1038#define IErrorInfo_GetLineNumber(p, aLineNumber) ((p)->lpVtbl->GetLineNumber(p, aLineNumber))
1039#define IErrorInfo_get_ColumnNumber(p, aColumnNumber) ((p)->lpVtbl->GetColumnNumber(p, aColumnNumber))
1040#define IErrorInfo_GetColumnNumber(p, aColumnNumber) ((p)->lpVtbl->GetColumnNumber(p, aColumnNumber))
1041#define IErrorInfo_get_Inner(p, aInner) ((p)->lpVtbl->GetInner(p, aInner))
1042#define IErrorInfo_GetInner(p, aInner) ((p)->lpVtbl->GetInner(p, aInner))
1043#define IErrorInfo_get_Data(p, aData) ((p)->lpVtbl->GetData(p, aData))
1044#define IErrorInfo_GetData(p, aData) ((p)->lpVtbl->GetData(p, aData))
1045#define IErrorInfo_ToString(p, retval) ((p)->lpVtbl->ToString(p, retval))
1046#endif /* !VBOX_WITH_GLUE */
1047
1048interface nsIException
1049{
1050#ifndef VBOX_WITH_GLUE
1051 struct nsIException_vtbl *vtbl;
1052#else /* !VBOX_WITH_GLUE */
1053 CONST_VTBL struct nsIExceptionVtbl *lpVtbl;
1054#endif /* !VBOX_WITH_GLUE */
1055};
1056
1057/* starting interface: nsIStackFrame */
1058#define NS_ISTACKFRAME_IID_STR "91d82105-7c62-4f8b-9779-154277c0ee90"
1059
1060#define NS_ISTACKFRAME_IID \
1061 {0x91d82105, 0x7c62, 0x4f8b, \
1062 { 0x97, 0x79, 0x15, 0x42, 0x77, 0xc0, 0xee, 0x90 }}
1063
1064#ifndef VBOX_WITH_GLUE
1065struct nsIStackFrame_vtbl
1066{
1067 /* Methods from the interface nsISupports */
1068 struct nsISupports_vtbl nsisupports;
1069
1070 nsresult (*GetLanguage)(nsIStackFrame *pThis, PRUint32 *aLanguage);
1071 nsresult (*GetLanguageName)(nsIStackFrame *pThis, PRUnichar * *aLanguageName);
1072 nsresult (*GetFilename)(nsIStackFrame *pThis, PRUnichar * *aFilename);
1073 nsresult (*GetName)(nsIStackFrame *pThis, PRUnichar * *aName);
1074 nsresult (*GetLineNumber)(nsIStackFrame *pThis, PRInt32 *aLineNumber);
1075 nsresult (*GetSourceLine)(nsIStackFrame *pThis, PRUnichar * *aSourceLine);
1076 nsresult (*GetCaller)(nsIStackFrame *pThis, nsIStackFrame * *aCaller);
1077 nsresult (*ToString)(nsIStackFrame *pThis, PRUnichar **_retval);
1078};
1079#else /* !VBOX_WITH_GLUE */
1080struct nsIStackFrameVtbl
1081{
1082 nsresult (*QueryInterface)(nsIStackFrame *pThis, const nsID *iid, void **resultp);
1083 nsrefcnt (*AddRef)(nsIStackFrame *pThis);
1084 nsrefcnt (*Release)(nsIStackFrame *pThis);
1085
1086 nsresult (*GetLanguage)(nsIStackFrame *pThis, PRUint32 *aLanguage);
1087 nsresult (*GetLanguageName)(nsIStackFrame *pThis, PRUnichar * *aLanguageName);
1088 nsresult (*GetFilename)(nsIStackFrame *pThis, PRUnichar * *aFilename);
1089 nsresult (*GetName)(nsIStackFrame *pThis, PRUnichar * *aName);
1090 nsresult (*GetLineNumber)(nsIStackFrame *pThis, PRInt32 *aLineNumber);
1091 nsresult (*GetSourceLine)(nsIStackFrame *pThis, PRUnichar * *aSourceLine);
1092 nsresult (*GetCaller)(nsIStackFrame *pThis, nsIStackFrame * *aCaller);
1093 nsresult (*ToString)(nsIStackFrame *pThis, PRUnichar **_retval);
1094};
1095#define nsIStackFrame_QueryInterface(p, iid, resultp) ((p)->lpVtbl->QueryInterface(p, iid, resultp))
1096#define nsIStackFrame_AddRef(p) ((p)->lpVtbl->AddRef(p))
1097#define nsIStackFrame_Release(p) ((p)->lpVtbl->Release(p))
1098#define nsIStackFrame_get_Language(p, aLanguage) ((p)->lpVtbl->GetLanguge(p, aLanguage))
1099#define nsIStackFrame_GetLanguage(p, aLanguage) ((p)->lpVtbl->GetLanguge(p, aLanguage))
1100#define nsIStackFrame_get_LanguageName(p, aLanguageName) ((p)->lpVtbl->GetLanguageName(p, aLanguageName))
1101#define nsIStackFrame_GetLanguageName(p, aLanguageName) ((p)->lpVtbl->GetLanguageName(p, aLanguageName))
1102#define nsIStackFrame_get_Filename(p, aFilename) ((p)->lpVtbl->GetFilename(p, aFilename))
1103#define nsIStackFrame_GetFilename(p, aFilename) ((p)->lpVtbl->GetFilename(p, aFilename))
1104#define nsIStackFrame_get_Name(p, aName) ((p)->lpVtbl->GetName(p, aName))
1105#define nsIStackFrame_GetName(p, aName) ((p)->lpVtbl->GetName(p, aName))
1106#define nsIStackFrame_get_LineNumber(p, aLineNumber) ((p)->lpVtbl->GetLineNumber(p, aLineNumber))
1107#define nsIStackFrame_GetLineNumber(p, aLineNumber) ((p)->lpVtbl->GetLineNumber(p, aLineNumber))
1108#define nsIStackFrame_get_SourceLine(p, aSourceLine) ((p)->lpVtbl->GetSourceLine(p, aSourceLine))
1109#define nsIStackFrame_GetSourceLine(p, aSourceLine) ((p)->lpVtbl->GetSourceLine(p, aSourceLine))
1110#define nsIStackFrame_get_Caller(p, aCaller) ((p)->lpVtbl->GetCaller(p, aCaller))
1111#define nsIStackFrame_GetCaller(p, aCaller) ((p)->lpVtbl->GetCaller(p, aCaller))
1112#define nsIStackFrame_ToString(p, retval) ((p)->lpVtbl->ToString(p, retval))
1113#endif /* !VBOX_WITH_GLUE */
1114
1115interface nsIStackFrame
1116{
1117#ifndef VBOX_WITH_GLUE
1118 struct nsIStackFrame_vtbl *vtbl;
1119#else /* !VBOX_WITH_GLUE */
1120 CONST_VTBL struct nsIStackFrameVtbl *lpVtbl;
1121#endif /* !VBOX_WITH_GLUE */
1122};
1123
1124/* starting interface: nsIEventTarget */
1125#define NS_IEVENTTARGET_IID_STR "ea99ad5b-cc67-4efb-97c9-2ef620a59f2a"
1126
1127#define NS_IEVENTTARGET_IID \
1128 {0xea99ad5b, 0xcc67, 0x4efb, \
1129 { 0x97, 0xc9, 0x2e, 0xf6, 0x20, 0xa5, 0x9f, 0x2a }}
1130
1131#ifndef VBOX_WITH_GLUE
1132struct nsIEventTarget_vtbl
1133{
1134 struct nsISupports_vtbl nsisupports;
1135
1136 nsresult (*PostEvent)(nsIEventTarget *pThis, PLEvent * aEvent);
1137 nsresult (*IsOnCurrentThread)(nsIEventTarget *pThis, PRBool *_retval);
1138};
1139#else /* !VBOX_WITH_GLUE */
1140struct nsIEventTargetVtbl
1141{
1142 nsresult (*QueryInterface)(nsIEventTarget *pThis, const nsID *iid, void **resultp);
1143 nsrefcnt (*AddRef)(nsIEventTarget *pThis);
1144 nsrefcnt (*Release)(nsIEventTarget *pThis);
1145
1146 nsresult (*PostEvent)(nsIEventTarget *pThis, PLEvent * aEvent);
1147 nsresult (*IsOnCurrentThread)(nsIEventTarget *pThis, PRBool *_retval);
1148};
1149#define nsIEventTarget_QueryInterface(p, iid, resultp) ((p)->lpVtbl->QueryInterface(p, iid, resultp))
1150#define nsIEventTarget_AddRef(p) ((p)->lpVtbl->AddRef(p))
1151#define nsIEventTarget_Release(p) ((p)->lpVtbl->Release(p))
1152#define nsIEventTarget_PostEvent(p, aEvent) ((p)->lpVtbl->PostEvent(p, aEvent))
1153#define nsIEventTarget_IsOnCurrentThread(p, retval) ((p)->lpVtbl->IsOnCurrentThread(p, retval))
1154#endif /* !VBOX_WITH_GLUE */
1155
1156interface nsIEventTarget
1157{
1158#ifndef VBOX_WITH_GLUE
1159 struct nsIEventTarget_vtbl *vtbl;
1160#else /* !VBOX_WITH_GLUE */
1161 CONST_VTBL struct nsIEventTargetVtbl *lpVtbl;
1162#endif /* !VBOX_WITH_GLUE */
1163};
1164
1165/* starting interface: nsIEventQueue */
1166#define NS_IEVENTQUEUE_IID_STR "176afb41-00a4-11d3-9f2a-00400553eef0"
1167
1168#define NS_IEVENTQUEUE_IID \
1169 {0x176afb41, 0x00a4, 0x11d3, \
1170 { 0x9f, 0x2a, 0x00, 0x40, 0x05, 0x53, 0xee, 0xf0 }}
1171
1172#ifndef VBOX_WITH_GLUE
1173struct nsIEventQueue_vtbl
1174{
1175 struct nsIEventTarget_vtbl nsieventtarget;
1176
1177 nsresult (*InitEvent)(nsIEventQueue *pThis, PLEvent * aEvent, void * owner, PLHandleEventProc handler, PLDestroyEventProc destructor);
1178 nsresult (*PostSynchronousEvent)(nsIEventQueue *pThis, PLEvent * aEvent, void * *aResult);
1179 nsresult (*PendingEvents)(nsIEventQueue *pThis, PRBool *_retval);
1180 nsresult (*ProcessPendingEvents)(nsIEventQueue *pThis);
1181 nsresult (*EventLoop)(nsIEventQueue *pThis);
1182 nsresult (*EventAvailable)(nsIEventQueue *pThis, PRBool *aResult);
1183 nsresult (*GetEvent)(nsIEventQueue *pThis, PLEvent * *_retval);
1184 nsresult (*HandleEvent)(nsIEventQueue *pThis, PLEvent * aEvent);
1185 nsresult (*WaitForEvent)(nsIEventQueue *pThis, PLEvent * *_retval);
1186 PRInt32 (*GetEventQueueSelectFD)(nsIEventQueue *pThis);
1187 nsresult (*Init)(nsIEventQueue *pThis, PRBool aNative);
1188 nsresult (*InitFromPRThread)(nsIEventQueue *pThis, PRThread * thread, PRBool aNative);
1189 nsresult (*InitFromPLQueue)(nsIEventQueue *pThis, PLEventQueue * aQueue);
1190 nsresult (*EnterMonitor)(nsIEventQueue *pThis);
1191 nsresult (*ExitMonitor)(nsIEventQueue *pThis);
1192 nsresult (*RevokeEvents)(nsIEventQueue *pThis, void * owner);
1193 nsresult (*GetPLEventQueue)(nsIEventQueue *pThis, PLEventQueue * *_retval);
1194 nsresult (*IsQueueNative)(nsIEventQueue *pThis, PRBool *_retval);
1195 nsresult (*StopAcceptingEvents)(nsIEventQueue *pThis);
1196};
1197#else /* !VBOX_WITH_GLUE */
1198struct nsIEventQueueVtbl
1199{
1200 nsresult (*QueryInterface)(nsIEventQueue *pThis, const nsID *iid, void **resultp);
1201 nsrefcnt (*AddRef)(nsIEventQueue *pThis);
1202 nsrefcnt (*Release)(nsIEventQueue *pThis);
1203
1204 nsresult (*PostEvent)(nsIEventQueue *pThis, PLEvent * aEvent);
1205 nsresult (*IsOnCurrentThread)(nsIEventQueue *pThis, PRBool *_retval);
1206
1207 nsresult (*InitEvent)(nsIEventQueue *pThis, PLEvent * aEvent, void * owner, PLHandleEventProc handler, PLDestroyEventProc destructor);
1208 nsresult (*PostSynchronousEvent)(nsIEventQueue *pThis, PLEvent * aEvent, void * *aResult);
1209 nsresult (*PendingEvents)(nsIEventQueue *pThis, PRBool *_retval);
1210 nsresult (*ProcessPendingEvents)(nsIEventQueue *pThis);
1211 nsresult (*EventLoop)(nsIEventQueue *pThis);
1212 nsresult (*EventAvailable)(nsIEventQueue *pThis, PRBool *aResult);
1213 nsresult (*GetEvent)(nsIEventQueue *pThis, PLEvent * *_retval);
1214 nsresult (*HandleEvent)(nsIEventQueue *pThis, PLEvent * aEvent);
1215 nsresult (*WaitForEvent)(nsIEventQueue *pThis, PLEvent * *_retval);
1216 PRInt32 (*GetEventQueueSelectFD)(nsIEventQueue *pThis);
1217 nsresult (*Init)(nsIEventQueue *pThis, PRBool aNative);
1218 nsresult (*InitFromPRThread)(nsIEventQueue *pThis, PRThread * thread, PRBool aNative);
1219 nsresult (*InitFromPLQueue)(nsIEventQueue *pThis, PLEventQueue * aQueue);
1220 nsresult (*EnterMonitor)(nsIEventQueue *pThis);
1221 nsresult (*ExitMonitor)(nsIEventQueue *pThis);
1222 nsresult (*RevokeEvents)(nsIEventQueue *pThis, void * owner);
1223 nsresult (*GetPLEventQueue)(nsIEventQueue *pThis, PLEventQueue * *_retval);
1224 nsresult (*IsQueueNative)(nsIEventQueue *pThis, PRBool *_retval);
1225 nsresult (*StopAcceptingEvents)(nsIEventQueue *pThis);
1226};
1227#define nsIEventQueue_QueryInterface(p, iid, resultp) ((p)->lpVtbl->QueryInterface(p, iid, resultp))
1228#define nsIEventQueue_AddRef(p) ((p)->lpVtbl->AddRef(p))
1229#define nsIEventQueue_Release(p) ((p)->lpVtbl->Release(p))
1230#define nsIEventQueue_PostEvent(p, aEvent) ((p)->lpVtbl->PostEvent(p, aEvent))
1231#define nsIEventQueue_IsOnCurrentThread(p, retval) ((p)->lpVtbl->IsOnCurrentThread(p, retval))
1232#define nsIEventQueue_InitEvent(p, aEvent, owner, handler, destructor) ((p)->lpVtbl->InitEvent(p, aEvent, owner, handler, destructor))
1233#define nsIEventQueue_PostSynchronousEvent(p, aEvent, aResult) ((p)->lpVtbl->PostSynchronousEvent(p, aEvent, aResult))
1234#define nsIEventQueue_ProcessPendingEvents(p) ((p)->lpVtbl->ProcessPendingEvents(p))
1235#define nsIEventQueue_EventLoop(p) ((p)->lpVtbl->EventLoop(p))
1236#define nsIEventQueue_EventAvailable(p, aResult) ((p)->lpVtbl->EventAvailable(p, aResult))
1237#define nsIEventQueue_get_Event(p, aEvent) ((p)->lpVtbl->GetEvent(p, aEvent))
1238#define nsIEventQueue_GetEvent(p, aEvent) ((p)->lpVtbl->GetEvent(p, aEvent))
1239#define nsIEventQueue_HandleEvent(p, aEvent) ((p)->lpVtbl->HandleEvent(p, aEvent))
1240#define nsIEventQueue_WaitForEvent(p, aEvent) ((p)->lpVtbl->WaitForEvent(p, aEvent))
1241#define nsIEventQueue_GetEventQueueSelectFD(p) ((p)->lpVtbl->GetEventQueueSelectFD(p))
1242#define nsIEventQueue_Init(p, aNative) ((p)->lpVtbl->Init(p, aNative))
1243#define nsIEventQueue_InitFromPLQueue(p, aQueue) ((p)->lpVtbl->InitFromPLQueue(p, aQueue))
1244#define nsIEventQueue_EnterMonitor(p) ((p)->lpVtbl->EnterMonitor(p))
1245#define nsIEventQueue_ExitMonitor(p) ((p)->lpVtbl->ExitMonitor(p))
1246#define nsIEventQueue_RevokeEvents(p, owner) ((p)->lpVtbl->RevokeEvents(p, owner))
1247#define nsIEventQueue_GetPLEventQueue(p, retval) ((p)->lpVtbl->GetPLEventQueue(p, retval))
1248#define nsIEventQueue_IsQueueNative(p, retval) ((p)->lpVtbl->IsQueueNative(p, retval))
1249#define nsIEventQueue_StopAcceptingEvents(p) ((p)->lpVtbl->StopAcceptingEvents(p))
1250#endif /* !VBOX_WITH_GLUE */
1251
1252interface nsIEventQueue
1253{
1254#ifndef VBOX_WITH_GLUE
1255 struct nsIEventQueue_vtbl *vtbl;
1256#else /* !VBOX_WITH_GLUE */
1257 CONST_VTBL struct nsIEventQueueVtbl *lpVtbl;
1258#endif /* !VBOX_WITH_GLUE */
1259};
1260
1261</xsl:text>
1262 <xsl:apply-templates/>
1263 <xsl:text>
1264
1265#endif /* __cplusplus */
1266
1267#endif /* !WIN32 */
1268
1269#ifdef __cplusplus
1270extern "C"
1271{
1272#endif /* __cplusplus */
1273
1274
1275/**
1276 * Function table for dynamic linking.
1277 * Use VBoxGetCAPIFunctions() to obtain the pointer to it.
1278 */
1279typedef struct VBOXCAPI
1280{
1281 /** The size of the structure. */
1282 unsigned cb;
1283 /** The structure version. */
1284 unsigned uVersion;
1285
1286 /** Gets the VirtualBox version, major * 1000000 + minor * 1000 + patch. */
1287 unsigned int (*pfnGetVersion)(void);
1288
1289 /** Gets the VirtualBox API version, major * 1000 + minor, e.g. 4003. */
1290 unsigned int (*pfnGetAPIVersion)(void);
1291
1292 /**
1293 * New and preferred way to initialize the C bindings for an API client.
1294 *
1295 * This way is much more flexible, as it can easily handle multiple
1296 * sessions (important with more complicated API clients, including
1297 * multithreaded ones), and even VBoxSVC crashes can be detected and
1298 * processed appropriately by listening for events from the associated
1299 * event source in VirtualBoxClient. It is completely up to the client
1300 * to decide what to do (terminate or continue after getting new
1301 * object references to server-side objects). Must be called in the
1302 * primary thread of the client, later API use can be done in any
1303 * thread.
1304 *
1305 * Note that the returned reference is owned by the caller, and thus it's
1306 * the caller's responsibility to handle the reference count appropriately.
1307 *
1308 * @param pszVirtualBoxClientIID pass IVIRTUALBOXCLIENT_IID_STR
1309 * @param ppVirtualBoxClient output parameter for VirtualBoxClient
1310 * reference, handled as usual with COM/XPCOM.
1311 * @returns COM/XPCOM error code
1312 */
1313 HRESULT (*pfnClientInitialize)(const char *pszVirtualBoxClientIID,
1314 IVirtualBoxClient **ppVirtualBoxClient);
1315 /**
1316 * Initialize the use of the C bindings in a non-primary thread.
1317 *
1318 * Must be called on any newly created thread which wants to use the
1319 * VirtualBox API.
1320 *
1321 * @returns COM/XPCOM error code
1322 */
1323 HRESULT (*pfnClientThreadInitialize)(void);
1324 /**
1325 * Uninitialize the use of the C bindings in a non-primary thread.
1326 *
1327 * Should be called before terminating the thread which initialized the
1328 * C bindings using pfnClientThreadInitialize.
1329 *
1330 * @returns COM/XPCOM error code
1331 */
1332 HRESULT (*pfnClientThreadUninitialize)(void);
1333 /**
1334 * Uninitialize the C bindings for an API client.
1335 *
1336 * Should be called when the API client is about to terminate and does
1337 * not want to use the C bindings any more. It will invalidate all
1338 * object references. It is possible, however, to change one's mind,
1339 * and call pfnClientInitialize again to continue using the API, as long
1340 * as none of the object references from before the re-initialization
1341 * are used. Must be called from the primary thread of the client.
1342 */
1343 void (*pfnClientUninitialize)(void);
1344
1345 /**
1346 * Deprecated way to initialize the C bindings and getting important
1347 * object references. Kept for backwards compatibility.
1348 *
1349 * If any returned reference is NULL then the initialization failed.
1350 * Note that the returned references are owned by the C bindings. The
1351 * number of calls to Release in the client code must match the number
1352 * of calls to AddRef, and additionally at no point in time there can
1353 * be more Release calls than AddRef calls.
1354 *
1355 * @param pszVirtualBoxIID pass IVIRTUALBOX_IID_STR
1356 * @param ppVirtualBox output parameter for VirtualBox reference,
1357 * owned by C bindings
1358 * @param pszSessionIID pass ISESSION_IID_STR
1359 * @param ppSession output parameter for Session reference,
1360 * owned by C bindings
1361 */
1362 void (*pfnComInitialize)(const char *pszVirtualBoxIID,
1363 IVirtualBox **ppVirtualBox,
1364 const char *pszSessionIID,
1365 ISession **ppSession);
1366 /**
1367 * Deprecated way to uninitialize the C bindings for an API client.
1368 * Kept for backwards compatibility and must be used if the C bindings
1369 * were initialized using pfnComInitialize. */
1370 void (*pfnComUninitialize)(void);
1371
1372 /**
1373 * Free string managed by COM/XPCOM.
1374 *
1375 * @param pwsz pointer to string to be freed
1376 */
1377 void (*pfnComUnallocString)(BSTR pwsz);
1378#ifndef WIN32
1379 /** Legacy function, was always for freeing strings only. */
1380#define pfnComUnallocMem(pv) pfnComUnallocString((BSTR)(pv))
1381#endif /* !WIN32 */
1382
1383 /**
1384 * Convert string from UTF-16 encoding to UTF-8 encoding.
1385 *
1386 * @param pwszString input string
1387 * @param ppszString output string
1388 * @returns IPRT status code
1389 */
1390 int (*pfnUtf16ToUtf8)(CBSTR pwszString, char **ppszString);
1391 /**
1392 * Convert string from UTF-8 encoding to UTF-16 encoding.
1393 *
1394 * @param pszString input string
1395 * @param ppwszString output string
1396 * @returns IPRT status code
1397 */
1398 int (*pfnUtf8ToUtf16)(const char *pszString, BSTR *ppwszString);
1399 /**
1400 * Free memory returned by pfnUtf16ToUtf8. Do not use for anything else.
1401 *
1402 * @param pszString string to be freed.
1403 */
1404 void (*pfnUtf8Free)(char *pszString);
1405 /**
1406 * Free memory returned by pfnUtf8ToUtf16. Do not use for anything else.
1407 *
1408 * @param pwszString string to be freed.
1409 */
1410 void (*pfnUtf16Free)(BSTR pwszString);
1411
1412 /**
1413 * Create a safearray (used for passing arrays to COM/XPCOM)
1414 *
1415 * Must be freed by pfnSafeArrayDestroy.
1416 *
1417 * @param vt variant type, defines the size of the elements
1418 * @param lLbound lower bound of the index, should be 0
1419 * @param cElements number of elements
1420 * @returns pointer to safearray
1421 */
1422 SAFEARRAY *(*pfnSafeArrayCreateVector)(VARTYPE vt, LONG lLbound, ULONG cElements);
1423 /**
1424 * Pre-allocate a safearray to be used by an out safearray parameter
1425 *
1426 * Must be freed by pfnSafeArrayDestroy.
1427 *
1428 * @returns pointer to safearray (system dependent, may be NULL if
1429 * there is no need to pre-allocate a safearray)
1430 */
1431 SAFEARRAY *(*pfnSafeArrayOutParamAlloc)(void);
1432 /**
1433 * Copy a C array into a safearray (for passing as an input parameter)
1434 *
1435 * @param psa pointer to already created safearray.
1436 * @param pv pointer to memory block to copy into safearray.
1437 * @param cb number of bytes to copy.
1438 * @returns COM/XPCOM error code
1439 */
1440 HRESULT (*pfnSafeArrayCopyInParamHelper)(SAFEARRAY *psa, const void *pv, ULONG cb);
1441 /**
1442 * Copy a safearray into a C array (for getting an output parameter)
1443 *
1444 * @param ppv output pointer to newly created array, which has to
1445 * be freed with pfnArrayOutFree.
1446 * @param pcb number of bytes in the output buffer.
1447 * @param vt variant type, defines the size of the elements
1448 * @param psa pointer to safearray for getting the data
1449 * @returns COM/XPCOM error code
1450 */
1451 HRESULT (*pfnSafeArrayCopyOutParamHelper)(void **ppv, ULONG *pcb, VARTYPE vt, SAFEARRAY *psa);
1452 /**
1453 * Copy a safearray into a C array (special variant for interface pointers)
1454 *
1455 * @param ppaObj output pointer to newly created array, which has
1456 * to be freed with pfnArrayOutFree. Note that it's the caller's
1457 * responsibility to call Release() on each non-NULL interface
1458 * pointer before freeing.
1459 * @param pcObj number of pointers in the output buffer.
1460 * @param psa pointer to safearray for getting the data
1461 * @returns COM/XPCOM error code
1462 */
1463 HRESULT (*pfnSafeArrayCopyOutIfaceParamHelper)(IUnknown ***ppaObj, ULONG *pcObj, SAFEARRAY *psa);
1464 /**
1465 * Free a safearray
1466 *
1467 * @param psa pointer to safearray
1468 * @returns COM/XPCOM error code
1469 */
1470 HRESULT (*pfnSafeArrayDestroy)(SAFEARRAY *psa);
1471 /**
1472 * Free an out array created by pfnSafeArrayCopyOutParamHelper or
1473 * pdnSafeArrayCopyOutIfaceParamHelper.
1474 *
1475 * @param psa pointer to memory block
1476 * @returns COM/XPCOM error code
1477 */
1478 HRESULT (*pfnArrayOutFree)(void *pv);
1479
1480#ifndef WIN32
1481 /**
1482 * Get XPCOM event queue. Deprecated!
1483 *
1484 * @param ppEventQueue output parameter for nsIEventQueue reference,
1485 * owned by C bindings.
1486 */
1487 void (*pfnGetEventQueue)(nsIEventQueue **ppEventQueue);
1488#endif /* !WIN32 */
1489
1490 /**
1491 * Get current COM/XPCOM exception.
1492 *
1493 * @param ppException output parameter for exception info reference,
1494 * may be @c NULL if no exception object has been created by
1495 * a previous COM/XPCOM call.
1496 * @returns COM/XPCOM error code
1497 */
1498 HRESULT (*pfnGetException)(IErrorInfo **ppException);
1499 /**
1500 * Clears current COM/XPCOM exception.
1501 *
1502 * @returns COM/XPCOM error code
1503 */
1504 HRESULT (*pfnClearException)(void);
1505
1506 /**
1507 * Process the event queue for a given amount of time.
1508 *
1509 * Must be called on the primary thread. Typical timeouts are from 200 to
1510 * 5000 msecs, to allow for checking a volatile variable if the event queue
1511 * processing should be terminated (,
1512 * or 0 if only the pending events should be processed, without waiting.
1513 *
1514 * @param iTimeoutMS how long to process the event queue, -1 means
1515 * infinitely long
1516 * @returns status code
1517 * @retval 0 if at least one event has been processed
1518 * @retval 1 if any signal interrupted the native system call (or returned
1519 * otherwise)
1520 * @retval 2 if the event queue was explicitly interrupted
1521 * @retval 3 if the timeout expired
1522 * @retval 4 if the function was called from the wrong thread
1523 * @retval 5 for all other (unexpected) errors
1524 */
1525 int (*pfnProcessEventQueue)(LONG64 iTimeoutMS);
1526 /**
1527 * Interrupt event queue processing.
1528 *
1529 * Can be called on any thread. Note that this function is not async-signal
1530 * safe, so never use it in such a context, instead use a volatile global
1531 * variable and a sensible timeout.
1532 * @returns 0 if successful, 1 otherwise.
1533 */
1534 int (*pfnInterruptEventQueueProcessing)(void);
1535
1536 /** Tail version, same as uVersion. */
1537 unsigned uEndVersion;
1538} VBOXCAPI;
1539/** Pointer to a const VBOXCAPI function table. */
1540typedef VBOXCAPI const *PCVBOXCAPI;
1541#ifndef WIN32
1542/** Backwards compatibility: Pointer to a const VBOXCAPI function table.
1543 * Use PCVBOXCAPI instead. */
1544typedef VBOXCAPI const *PCVBOXXPCOM;
1545#endif /* !WIN32 */
1546
1547#ifndef WIN32
1548/** Backwards compatibility: make sure old code using VBOXXPCOMC still compiles.
1549 * Use VBOXCAPI instead. */
1550#define VBOXXPCOMC VBOXCAPI
1551#endif /* !WIN32 */
1552
1553/** The current interface version.
1554 * For use with VBoxGetCAPIFunctions and to be found in VBOXCAPI::uVersion. */
1555#define VBOX_CAPI_VERSION 0x00040000U
1556
1557#ifndef WIN32
1558/** Backwards compatibility: The current interface version.
1559 * Use VBOX_CAPI_VERSION instead. */
1560#define VBOX_XPCOMC_VERSION VBOX_CAPI_VERSION
1561#endif /* !WIN32 */
1562
1563/** VBoxGetCAPIFunctions. */
1564VBOXCAPI_DECL(PCVBOXCAPI) VBoxGetCAPIFunctions(unsigned uVersion);
1565#ifndef WIN32
1566/** Backwards compatibility: VBoxGetXPCOMCFunctions.
1567 * Use VBoxGetCAPIFunctions instead. */
1568VBOXCAPI_DECL(PCVBOXCAPI) VBoxGetXPCOMCFunctions(unsigned uVersion);
1569#endif /* !WIN32 */
1570
1571/** Typedef for VBoxGetCAPIFunctions. */
1572typedef PCVBOXCAPI (*PFNVBOXGETCAPIFUNCTIONS)(unsigned uVersion);
1573#ifndef WIN32
1574/** Backwards compatibility: Typedef for VBoxGetXPCOMCFunctions.
1575 * Use PFNVBOXGETCAPIFUNCTIONS instead. */
1576typedef PCVBOXCAPI (*PFNVBOXGETXPCOMCFUNCTIONS)(unsigned uVersion);
1577#endif /* !WIN32 */
1578
1579/** The symbol name of VBoxGetCAPIFunctions. */
1580#ifdef __OS2__
1581# define VBOX_GET_CAPI_FUNCTIONS_SYMBOL_NAME "_VBoxGetCAPIFunctions"
1582#else /* !__OS2__ */
1583# define VBOX_GET_CAPI_FUNCTIONS_SYMBOL_NAME "VBoxGetCAPIFunctions"
1584#endif /* !__OS2__ */
1585#ifndef WIN32
1586/** Backwards compatibility: The symbol name of VBoxGetXPCOMCFunctions.
1587 * Use VBOX_GET_CAPI_FUNCTIONS_SYMBOL_NAME instead. */
1588# ifdef __OS2__
1589# define VBOX_GET_XPCOMC_FUNCTIONS_SYMBOL_NAME "_VBoxGetXPCOMCFunctions"
1590# else /* !__OS2__ */
1591# define VBOX_GET_XPCOMC_FUNCTIONS_SYMBOL_NAME "VBoxGetXPCOMCFunctions"
1592# endif /* !__OS2__ */
1593#endif /* !WIN32 */
1594
1595
1596#ifdef __cplusplus
1597}
1598#endif /* __cplusplus */
1599
1600#endif /* !___VirtualBox_CAPI_h */
1601</xsl:text>
1602</xsl:template>
1603
1604<!--
1605 * ignore all |if|s except those for XPIDL target
1606-->
1607<xsl:template match="if">
1608 <xsl:if test="@target='xpidl'">
1609 <xsl:apply-templates/>
1610 </xsl:if>
1611</xsl:template>
1612<xsl:template match="if" mode="forward">
1613 <xsl:if test="@target='xpidl'">
1614 <xsl:apply-templates mode="forward"/>
1615 </xsl:if>
1616</xsl:template>
1617<xsl:template match="if" mode="forwarder">
1618 <xsl:if test="@target='midl'">
1619 <xsl:apply-templates mode="forwarder"/>
1620 </xsl:if>
1621</xsl:template>
1622
1623
1624<!--
1625 * libraries
1626-->
1627<xsl:template match="library">
1628 <!-- result codes -->
1629 <xsl:text>&#x0A;</xsl:text>
1630 <xsl:for-each select="result">
1631 <xsl:apply-templates select="."/>
1632 </xsl:for-each>
1633 <xsl:text>&#x0A;&#x0A;</xsl:text>
1634 <!-- forward declarations -->
1635 <xsl:apply-templates select="interface | if/interface" mode="forward"/>
1636 <xsl:text>&#x0A;</xsl:text>
1637 <!-- typedef'ing the struct declarations -->
1638 <xsl:apply-templates select="interface | if/interface" mode="typedef"/>
1639 <xsl:text>&#x0A;</xsl:text>
1640 <!-- all enums go first -->
1641 <xsl:apply-templates select="enum | if/enum"/>
1642 <!-- everything else but result codes and enums -->
1643 <xsl:apply-templates select="*[not(self::result or self::enum) and
1644 not(self::if[result] or self::if[enum])]"/>
1645 <!-- -->
1646</xsl:template>
1647
1648
1649<!--
1650 * result codes
1651-->
1652<xsl:template match="result">
1653 <xsl:value-of select="concat('#define ',@name,' ',@value)"/>
1654 <xsl:text>&#x0A;</xsl:text>
1655</xsl:template>
1656
1657
1658<!--
1659 * forward declarations
1660-->
1661<xsl:template match="interface" mode="forward">
1662 <xsl:if test="not(@internal='yes')">
1663 <xsl:text>interface </xsl:text>
1664 <xsl:value-of select="@name"/>
1665 <xsl:text>;&#x0A;</xsl:text>
1666 </xsl:if>
1667</xsl:template>
1668
1669
1670<!--
1671 * typedef'ing the struct declarations
1672-->
1673<xsl:template match="interface" mode="typedef">
1674 <xsl:if test="not(@internal='yes')">
1675 <xsl:text>typedef interface </xsl:text>
1676 <xsl:value-of select="@name"/>
1677 <xsl:text> </xsl:text>
1678 <xsl:value-of select="@name"/>
1679 <xsl:text>;&#x0A;</xsl:text>
1680 </xsl:if>
1681</xsl:template>
1682
1683
1684<!--
1685 * COBJMACRO style convenience macros for calling methods
1686-->
1687<xsl:template match="interface" mode="cobjmacro">
1688 <xsl:param name="iface"/>
1689
1690 <xsl:variable name="extends" select="@extends"/>
1691 <xsl:choose>
1692 <xsl:when test="$extends='$unknown'">
1693 <xsl:text>#define </xsl:text>
1694 <xsl:value-of select="$iface"/>
1695 <xsl:text>_QueryInterface(p, iid, resultp) ((p)->lpVtbl->QueryInterface(p, iid, resultp))&#x0A;</xsl:text>
1696 <xsl:text>#define </xsl:text>
1697 <xsl:value-of select="$iface"/>
1698 <xsl:text>_AddRef(p) ((p)->lpVtbl->AddRef(p))&#x0A;</xsl:text>
1699 <xsl:text>#define </xsl:text>
1700 <xsl:value-of select="$iface"/>
1701 <xsl:text>_Release(p) ((p)->lpVtbl->Release(p))&#x0A;</xsl:text>
1702 </xsl:when>
1703 <xsl:when test="$extends='$errorinfo'">
1704 <xsl:text>#define </xsl:text>
1705 <xsl:value-of select="$iface"/>
1706 <xsl:text>_QueryInterface(p, iid, resultp) ((p)->lpVtbl->QueryInterface(p, iid, resultp))&#x0A;</xsl:text>
1707 <xsl:text>#define </xsl:text>
1708 <xsl:value-of select="$iface"/>
1709 <xsl:text>_AddRef(p) ((p)->lpVtbl->AddRef(p))&#x0A;</xsl:text>
1710 <xsl:text>#define </xsl:text>
1711 <xsl:value-of select="$iface"/>
1712 <xsl:text>_Release(p) ((p)->lpVtbl->Release(p))&#x0A;</xsl:text>
1713 <xsl:text>#define </xsl:text>
1714 <xsl:value-of select="$iface"/>
1715 <xsl:text>_get_Message(p, aMessage) ((p)->lpVtbl->GetMessage(p, aMessage))&#x0A;</xsl:text>
1716 <xsl:text>#define </xsl:text>
1717 <xsl:value-of select="$iface"/>
1718 <xsl:text>_GetMessage(p, aMessage) ((p)->lpVtbl->GetMessage(p, aMessage))&#x0A;</xsl:text>
1719 <xsl:text>#define </xsl:text>
1720 <xsl:value-of select="$iface"/>
1721 <xsl:text>_get_Result(p, aResult) ((p)->lpVtbl->GetResult(p, aResult))&#x0A;</xsl:text>
1722 <xsl:text>#define </xsl:text>
1723 <xsl:value-of select="$iface"/>
1724 <xsl:text>_GetResult(p, aResult) ((p)->lpVtbl->GetResult(p, aResult))&#x0A;</xsl:text>
1725 <xsl:text>#define </xsl:text>
1726 <xsl:value-of select="$iface"/>
1727 <xsl:text>_get_Name(p, aName) ((p)->lpVtbl->GetName(p, aName))&#x0A;</xsl:text>
1728 <xsl:text>#define </xsl:text>
1729 <xsl:value-of select="$iface"/>
1730 <xsl:text>_GetName(p, aName) ((p)->lpVtbl->GetName(p, aName))&#x0A;</xsl:text>
1731 <xsl:text>#define </xsl:text>
1732 <xsl:value-of select="$iface"/>
1733 <xsl:text>_get_Filename(p, aFilename) ((p)->lpVtbl->GetFilename(p, aFilename))&#x0A;</xsl:text>
1734 <xsl:text>#define </xsl:text>
1735 <xsl:value-of select="$iface"/>
1736 <xsl:text>_GetFilename(p, aFilename) ((p)->lpVtbl->GetFilename(p, aFilename))&#x0A;</xsl:text>
1737 <xsl:text>#define </xsl:text>
1738 <xsl:value-of select="$iface"/>
1739 <xsl:text>_get_LineNumber(p, aLineNumber) ((p)->lpVtbl->GetLineNumber(p, aLineNumber))&#x0A;</xsl:text>
1740 <xsl:text>#define </xsl:text>
1741 <xsl:value-of select="$iface"/>
1742 <xsl:text>_GetLineNumber(p, aLineNumber) ((p)->lpVtbl->GetLineNumber(p, aLineNumber))&#x0A;</xsl:text>
1743 <xsl:text>#define </xsl:text>
1744 <xsl:value-of select="$iface"/>
1745 <xsl:text>_get_ColumnNumber(p, aColumnNumber) ((p)->lpVtbl->GetColumnNumber(p, aColumnNumber))&#x0A;</xsl:text>
1746 <xsl:text>#define </xsl:text>
1747 <xsl:value-of select="$iface"/>
1748 <xsl:text>_GetColumnNumber(p, aColumnNumber) ((p)->lpVtbl->GetColumnNumber(p, aColumnNumber))&#x0A;</xsl:text>
1749 <xsl:text>#define </xsl:text>
1750 <xsl:value-of select="$iface"/>
1751 <xsl:text>_get_Location(p, aLocation) ((p)->lpVtbl->GetLocation(p, aLocation))&#x0A;</xsl:text>
1752 <xsl:text>#define </xsl:text>
1753 <xsl:value-of select="$iface"/>
1754 <xsl:text>_GetLocation(p, aLocation) ((p)->lpVtbl->GetLocation(p, aLocation))&#x0A;</xsl:text>
1755 <xsl:text>#define </xsl:text>
1756 <xsl:value-of select="$iface"/>
1757 <xsl:text>_get_Inner(p, aInner) ((p)->lpVtbl->GetInner(p, aInner))&#x0A;</xsl:text>
1758 <xsl:text>#define </xsl:text>
1759 <xsl:value-of select="$iface"/>
1760 <xsl:text>_GetInner(p, aInner) ((p)->lpVtbl->GetInner(p, aInner))&#x0A;</xsl:text>
1761 <xsl:text>#define </xsl:text>
1762 <xsl:value-of select="$iface"/>
1763 <xsl:text>_get_Data(p, aData) ((p)->lpVtbl->GetData(p, aData))&#x0A;</xsl:text>
1764 <xsl:text>#define </xsl:text>
1765 <xsl:value-of select="$iface"/>
1766 <xsl:text>_GetData(p, aData) ((p)->lpVtbl->GetData(p, aData))&#x0A;</xsl:text>
1767 <xsl:text>#define </xsl:text>
1768 <xsl:value-of select="$iface"/>
1769 <xsl:text>_ToString(p, retval) ((p)->lpVtbl->ToString(p, retval))&#x0A;</xsl:text>
1770 </xsl:when>
1771 <xsl:otherwise>
1772 <xsl:apply-templates select="//interface[@name=$extends]" mode="cobjmacro">
1773 <xsl:with-param name="iface" select="$iface"/>
1774 </xsl:apply-templates>
1775 </xsl:otherwise>
1776 </xsl:choose>
1777 <!-- attributes (properties) -->
1778 <xsl:apply-templates select="attribute | if/attribute" mode="cobjmacro">
1779 <xsl:with-param name="iface" select="$iface"/>
1780 </xsl:apply-templates>
1781 <!-- methods -->
1782 <xsl:apply-templates select="method | if/method" mode="cobjmacro">
1783 <xsl:with-param name="iface" select="$iface"/>
1784 </xsl:apply-templates>
1785</xsl:template>
1786
1787
1788<!--
1789 * emit flat vtable, compatible with COM
1790-->
1791<xsl:template match="interface" mode="vtab_flat">
1792 <xsl:param name="iface"/>
1793
1794 <xsl:variable name="extends" select="@extends"/>
1795 <xsl:choose>
1796 <xsl:when test="$extends='$unknown'">
1797 <xsl:text> nsresult (*QueryInterface)(</xsl:text>
1798 <xsl:value-of select="$iface"/>
1799 <xsl:text> *pThis, const nsID *iid, void **resultp);&#x0A;</xsl:text>
1800 <xsl:text> nsrefcnt (*AddRef)(</xsl:text>
1801 <xsl:value-of select="$iface"/>
1802 <xsl:text> *pThis);&#x0A;</xsl:text>
1803 <xsl:text> nsrefcnt (*Release)(</xsl:text>
1804 <xsl:value-of select="$iface"/>
1805 <xsl:text> *pThis);&#x0A;</xsl:text>
1806 </xsl:when>
1807 <xsl:when test="$extends='$errorinfo'">
1808 <xsl:text> nsresult (*QueryInterface)(</xsl:text>
1809 <xsl:value-of select="$iface"/>
1810 <xsl:text> *pThis, const nsID *iid, void **resultp);&#x0A;</xsl:text>
1811 <xsl:text> nsrefcnt (*AddRef)(</xsl:text>
1812 <xsl:value-of select="$iface"/>
1813 <xsl:text> *pThis);&#x0A;</xsl:text>
1814 <xsl:text> nsrefcnt (*Release)(</xsl:text>
1815 <xsl:value-of select="$iface"/>
1816 <xsl:text> *pThis);&#x0A;</xsl:text>
1817 <xsl:text> nsresult (*GetMessage)(</xsl:text>
1818 <xsl:value-of select="$iface"/>
1819 <xsl:text> *pThis, PRUnichar * *aMessage);&#x0A;</xsl:text>
1820 <xsl:text> nsresult (*GetResult)(</xsl:text>
1821 <xsl:value-of select="$iface"/>
1822 <xsl:text> *pThis, nsresult *aResult);&#x0A;</xsl:text>
1823 <xsl:text> nsresult (*GetName)(</xsl:text>
1824 <xsl:value-of select="$iface"/>
1825 <xsl:text>*pThis, PRUnichar * *aName);&#x0A;</xsl:text>
1826 <xsl:text> nsresult (*GetFilename)(</xsl:text>
1827 <xsl:value-of select="$iface"/>
1828 <xsl:text> *pThis, PRUnichar * *aFilename);&#x0A;</xsl:text>
1829 <xsl:text> nsresult (*GetLineNumber)(</xsl:text>
1830 <xsl:value-of select="$iface"/>
1831 <xsl:text> *pThis, PRUint32 *aLineNumber);&#x0A;</xsl:text>
1832 <xsl:text> nsresult (*GetColumnNumber)(</xsl:text>
1833 <xsl:value-of select="$iface"/>
1834 <xsl:text> *pThis, PRUint32 *aColumnNumber);&#x0A;</xsl:text>
1835 <xsl:text> nsresult (*GetLocation)(</xsl:text>
1836 <xsl:value-of select="$iface"/>
1837 <xsl:text> *pThis, nsIStackFrame * *aLocation);&#x0A;</xsl:text>
1838 <xsl:text> nsresult (*GetInner)(</xsl:text>
1839 <xsl:value-of select="$iface"/>
1840 <xsl:text> *pThis, nsIException * *aInner);&#x0A;</xsl:text>
1841 <xsl:text> nsresult (*GetData)(</xsl:text>
1842 <xsl:value-of select="$iface"/>
1843 <xsl:text> *pThis, nsISupports * *aData);&#x0A;</xsl:text>
1844 <xsl:text> nsresult (*ToString)(</xsl:text>
1845 <xsl:value-of select="$iface"/>
1846 <xsl:text> *pThis, PRUnichar **_retval);&#x0A;</xsl:text>
1847 </xsl:when>
1848 <xsl:otherwise>
1849 <xsl:apply-templates select="//interface[@name=$extends]" mode="vtab_flat">
1850 <xsl:with-param name="iface" select="$iface"/>
1851 </xsl:apply-templates>
1852 </xsl:otherwise>
1853 </xsl:choose>
1854 <!-- attributes (properties) -->
1855 <xsl:apply-templates select="attribute | if/attribute">
1856 <xsl:with-param name="iface" select="$iface"/>
1857 </xsl:apply-templates>
1858 <!-- methods -->
1859 <xsl:apply-templates select="method | if/method">
1860 <xsl:with-param name="iface" select="$iface"/>
1861 </xsl:apply-templates>
1862</xsl:template>
1863
1864
1865<!--
1866 * interfaces
1867-->
1868<xsl:template match="interface">
1869 <xsl:if test="not(@internal='yes')">
1870 <xsl:text>/* Start of struct </xsl:text>
1871 <xsl:value-of select="@name"/>
1872 <xsl:text> declaration */&#x0A;</xsl:text>
1873 <xsl:text>#define </xsl:text>
1874 <xsl:call-template name="uppercase">
1875 <xsl:with-param name="str" select="@name"/>
1876 </xsl:call-template>
1877 <xsl:value-of select="concat('_IID_STR &quot;',@uuid,'&quot;')"/>
1878 <xsl:text>&#x0A;</xsl:text>
1879 <xsl:text>#define </xsl:text>
1880 <xsl:call-template name="uppercase">
1881 <xsl:with-param name="str" select="@name"/>
1882 </xsl:call-template>
1883 <xsl:text>_IID { \&#x0A;</xsl:text>
1884 <xsl:text> 0x</xsl:text><xsl:value-of select="substring(@uuid,1,8)"/>
1885 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,10,4)"/>
1886 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,15,4)"/>
1887 <xsl:text>, \&#x0A; </xsl:text>
1888 <xsl:text>{ 0x</xsl:text><xsl:value-of select="substring(@uuid,20,2)"/>
1889 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,22,2)"/>
1890 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,25,2)"/>
1891 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,27,2)"/>
1892 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,29,2)"/>
1893 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,31,2)"/>
1894 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,33,2)"/>
1895 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,35,2)"/>
1896 <xsl:text> } \&#x0A;}&#x0A;</xsl:text>
1897 <xsl:text>/* COM compatibility */&#x0A;</xsl:text>
1898 <xsl:text>VBOX_EXTERN_CONST(nsIID, IID_</xsl:text>
1899 <xsl:value-of select="@name"/>
1900 <xsl:text>);&#x0A;</xsl:text>
1901 <xsl:text>#ifndef VBOX_WITH_GLUE&#x0A;</xsl:text>
1902 <xsl:text>struct </xsl:text>
1903 <xsl:value-of select="@name"/>
1904 <xsl:text>_vtbl&#x0A;{&#x0A;</xsl:text>
1905 <xsl:text> </xsl:text>
1906 <xsl:choose>
1907 <xsl:when test="@extends='$unknown'">struct nsISupports_vtbl nsisupports;</xsl:when>
1908 <xsl:when test="@extends='$errorinfo'">struct nsIException_vtbl nsiexception;</xsl:when>
1909 <xsl:otherwise>
1910 <xsl:text>struct </xsl:text>
1911 <xsl:value-of select="@extends"/>
1912 <xsl:text>_vtbl </xsl:text>
1913 <xsl:call-template name="lowercase">
1914 <xsl:with-param name="str" select="@extends"/>
1915 </xsl:call-template>
1916 <xsl:text>;</xsl:text>
1917 </xsl:otherwise>
1918 </xsl:choose>
1919 <xsl:text>&#x0A;&#x0A;</xsl:text>
1920 <!-- attributes (properties) -->
1921 <xsl:apply-templates select="attribute | if/attribute"/>
1922 <!-- methods -->
1923 <xsl:apply-templates select="method | if/method"/>
1924 <!-- -->
1925 <xsl:text>};&#x0A;</xsl:text>
1926 <xsl:text>#else /* VBOX_WITH_GLUE */&#x0A;</xsl:text>
1927 <xsl:text>struct </xsl:text>
1928 <xsl:value-of select="@name"/>
1929 <xsl:text>Vtbl&#x0A;{&#x0A;</xsl:text>
1930 <xsl:apply-templates select="." mode="vtab_flat">
1931 <xsl:with-param name="iface" select="@name"/>
1932 </xsl:apply-templates>
1933 <xsl:text>};&#x0A;</xsl:text>
1934 <xsl:apply-templates select="." mode="cobjmacro">
1935 <xsl:with-param name="iface" select="@name"/>
1936 </xsl:apply-templates>
1937 <!-- -->
1938 <xsl:text>#endif /* VBOX_WITH_GLUE */&#x0A;</xsl:text>
1939 <xsl:text>&#x0A;</xsl:text>
1940 <xsl:text>interface </xsl:text>
1941 <xsl:value-of select="@name"/>
1942 <xsl:text>&#x0A;{&#x0A;</xsl:text>
1943 <xsl:text>#ifndef VBOX_WITH_GLUE&#x0A;</xsl:text>
1944 <xsl:text> struct </xsl:text>
1945 <xsl:value-of select="@name"/>
1946 <xsl:text>_vtbl *vtbl;&#x0A;</xsl:text>
1947 <xsl:text>#else /* VBOX_WITH_GLUE */&#x0A;</xsl:text>
1948 <xsl:text> CONST_VTBL struct </xsl:text>
1949 <xsl:value-of select="@name"/>
1950 <xsl:text>Vtbl *lpVtbl;&#x0A;</xsl:text>
1951 <xsl:text>#endif /* VBOX_WITH_GLUE */&#x0A;</xsl:text>
1952 <xsl:text>};&#x0A;</xsl:text>
1953 <xsl:text>/* End of struct </xsl:text>
1954 <xsl:value-of select="@name"/>
1955 <xsl:text> declaration */&#x0A;&#x0A;&#x0A;</xsl:text>
1956 </xsl:if>
1957</xsl:template>
1958
1959
1960<!--
1961 * attributes
1962-->
1963<xsl:template match="attribute">
1964 <xsl:param name="iface" select="ancestor::interface/@name"/>
1965
1966 <xsl:choose>
1967 <!-- safearray pseudo attribute -->
1968 <xsl:when test="@safearray='yes'">
1969 <!-- getter -->
1970 <xsl:text> nsresult (*Get</xsl:text>
1971 <xsl:call-template name="capitalize">
1972 <xsl:with-param name="str" select="@name"/>
1973 </xsl:call-template>
1974 <xsl:text>)(</xsl:text>
1975 <xsl:value-of select="$iface" />
1976 <xsl:text> *pThis, </xsl:text>
1977 <!-- array size -->
1978 <xsl:text>PRUint32 *</xsl:text>
1979 <xsl:value-of select="@name"/>
1980 <xsl:text>Size, </xsl:text>
1981 <!-- array pointer -->
1982 <xsl:apply-templates select="@type" mode="forwarder"/>
1983 <xsl:text> **</xsl:text>
1984 <xsl:value-of select="@name"/>
1985 <xsl:text>);&#x0A;</xsl:text>
1986 <!-- setter -->
1987 <xsl:if test="not(@readonly='yes')">
1988 <xsl:text> nsresult (*Set</xsl:text>
1989 <xsl:call-template name="capitalize">
1990 <xsl:with-param name="str" select="@name"/>
1991 </xsl:call-template>
1992 <xsl:text>)(</xsl:text>
1993 <xsl:value-of select="$iface" />
1994 <xsl:text> *pThis, </xsl:text>
1995 <!-- array size -->
1996 <xsl:text>PRUint32 </xsl:text>
1997 <xsl:value-of select="@name"/>
1998 <xsl:text>Size, </xsl:text>
1999 <!-- array pointer -->
2000 <xsl:apply-templates select="@type" mode="forwarder"/>
2001 <xsl:text> *</xsl:text>
2002 <xsl:value-of select="@name"/>
2003 <xsl:text>);&#x0A;</xsl:text>
2004 </xsl:if>
2005 </xsl:when>
2006 <!-- normal attribute -->
2007 <xsl:otherwise>
2008 <xsl:text> </xsl:text>
2009 <xsl:if test="@readonly='yes'">
2010 <xsl:text>nsresult (*Get</xsl:text>
2011 <xsl:call-template name="capitalize">
2012 <xsl:with-param name="str" select="@name"/>
2013 </xsl:call-template>
2014 <xsl:text>)(</xsl:text>
2015 <xsl:value-of select="$iface" />
2016 <xsl:text> *pThis, </xsl:text>
2017 <xsl:apply-templates select="@type" mode="forwarder"/>
2018 <xsl:text> *</xsl:text>
2019 <xsl:value-of select="@name"/>
2020 <xsl:text>);&#x0A;</xsl:text>
2021 </xsl:if>
2022 <xsl:choose>
2023 <xsl:when test="@readonly='yes'">
2024 </xsl:when>
2025 <xsl:otherwise>
2026 <xsl:text>nsresult (*Get</xsl:text>
2027 <xsl:call-template name="capitalize">
2028 <xsl:with-param name="str" select="@name"/>
2029 </xsl:call-template>
2030 <xsl:text>)(</xsl:text>
2031 <xsl:value-of select="$iface" />
2032 <xsl:text> *pThis, </xsl:text>
2033 <xsl:apply-templates select="@type" mode="forwarder"/>
2034 <xsl:text> *</xsl:text>
2035 <xsl:value-of select="@name"/>
2036 <xsl:text>);&#x0A; </xsl:text>
2037 <xsl:text>nsresult (*Set</xsl:text>
2038 <xsl:call-template name="capitalize">
2039 <xsl:with-param name="str" select="@name"/>
2040 </xsl:call-template>
2041 <xsl:text>)(</xsl:text>
2042 <xsl:value-of select="$iface" />
2043 <xsl:text> *pThis, </xsl:text>
2044 <xsl:apply-templates select="@type" mode="forwarder"/>
2045 <xsl:text> </xsl:text>
2046 <xsl:value-of select="@name"/>
2047 <xsl:text>);&#x0A;</xsl:text>
2048 </xsl:otherwise>
2049 </xsl:choose>
2050 </xsl:otherwise>
2051 </xsl:choose>
2052 <xsl:text>&#x0A;</xsl:text>
2053</xsl:template>
2054
2055<xsl:template match="attribute" mode="cobjmacro">
2056 <xsl:param name="iface"/>
2057
2058 <!-- getter (COM compatible) -->
2059 <xsl:text>#define </xsl:text>
2060 <xsl:value-of select="concat($iface, '_get_')"/>
2061 <xsl:call-template name="capitalize">
2062 <xsl:with-param name="str" select="@name"/>
2063 </xsl:call-template>
2064 <xsl:text>(p, a</xsl:text>
2065 <xsl:call-template name="capitalize">
2066 <xsl:with-param name="str" select="@name"/>
2067 </xsl:call-template>
2068 <xsl:text>) ((p)->lpVtbl->Get</xsl:text>
2069 <xsl:call-template name="capitalize">
2070 <xsl:with-param name="str" select="@name"/>
2071 </xsl:call-template>
2072 <xsl:text>(p, a</xsl:text>
2073 <xsl:call-template name="capitalize">
2074 <xsl:with-param name="str" select="@name"/>
2075 </xsl:call-template>
2076 <xsl:text>))&#x0A;</xsl:text>
2077
2078 <!-- getter (XPCOM compatible) -->
2079 <xsl:text>#define </xsl:text>
2080 <xsl:value-of select="concat($iface, '_Get')"/>
2081 <xsl:call-template name="capitalize">
2082 <xsl:with-param name="str" select="@name"/>
2083 </xsl:call-template>
2084 <xsl:text>(p, a</xsl:text>
2085 <xsl:call-template name="capitalize">
2086 <xsl:with-param name="str" select="@name"/>
2087 </xsl:call-template>
2088 <xsl:text>) ((p)->lpVtbl->Get</xsl:text>
2089 <xsl:call-template name="capitalize">
2090 <xsl:with-param name="str" select="@name"/>
2091 </xsl:call-template>
2092 <xsl:text>(p, a</xsl:text>
2093 <xsl:call-template name="capitalize">
2094 <xsl:with-param name="str" select="@name"/>
2095 </xsl:call-template>
2096 <xsl:text>))&#x0A;</xsl:text>
2097
2098 <xsl:if test="not(@readonly='yes')">
2099 <!-- setter (COM compatible) -->
2100 <xsl:text>#define </xsl:text>
2101 <xsl:value-of select="concat($iface, '_put_')"/>
2102 <xsl:call-template name="capitalize">
2103 <xsl:with-param name="str" select="@name"/>
2104 </xsl:call-template>
2105 <xsl:text>(p, a</xsl:text>
2106 <xsl:call-template name="capitalize">
2107 <xsl:with-param name="str" select="@name"/>
2108 </xsl:call-template>
2109 <xsl:text>) ((p)->lpVtbl->Set</xsl:text>
2110 <xsl:call-template name="capitalize">
2111 <xsl:with-param name="str" select="@name"/>
2112 </xsl:call-template>
2113 <xsl:text>(p, a</xsl:text>
2114 <xsl:call-template name="capitalize">
2115 <xsl:with-param name="str" select="@name"/>
2116 </xsl:call-template>
2117 <xsl:text>))&#x0A;</xsl:text>
2118
2119 <!-- setter (XPCOM compatible) -->
2120 <xsl:text>#define </xsl:text>
2121 <xsl:value-of select="concat($iface, '_Set')"/>
2122 <xsl:call-template name="capitalize">
2123 <xsl:with-param name="str" select="@name"/>
2124 </xsl:call-template>
2125 <xsl:text>(p, a</xsl:text>
2126 <xsl:call-template name="capitalize">
2127 <xsl:with-param name="str" select="@name"/>
2128 </xsl:call-template>
2129 <xsl:text>) ((p)->lpVtbl->Set</xsl:text>
2130 <xsl:call-template name="capitalize">
2131 <xsl:with-param name="str" select="@name"/>
2132 </xsl:call-template>
2133 <xsl:text>(p, a</xsl:text>
2134 <xsl:call-template name="capitalize">
2135 <xsl:with-param name="str" select="@name"/>
2136 </xsl:call-template>
2137 <xsl:text>))&#x0A;</xsl:text>
2138
2139 </xsl:if>
2140</xsl:template>
2141
2142<!--
2143 * methods
2144-->
2145<xsl:template match="method">
2146 <xsl:param name="iface" select="ancestor::interface/@name"/>
2147
2148 <xsl:if test="param/@mod='ptr'">
2149 <!-- methods using native types must be non-scriptable
2150 <xsl:text> [noscript]&#x0A;</xsl:text>-->
2151 </xsl:if>
2152 <xsl:text> nsresult (*</xsl:text>
2153 <xsl:call-template name="capitalize">
2154 <xsl:with-param name="str" select="@name"/>
2155 </xsl:call-template>
2156 <xsl:if test="param">
2157 <xsl:text>)(&#x0A;</xsl:text>
2158 <xsl:text> </xsl:text>
2159 <xsl:value-of select="$iface" />
2160 <xsl:text> *pThis,&#x0A;</xsl:text>
2161 <xsl:for-each select="param [position() != last()]">
2162 <xsl:text> </xsl:text>
2163 <xsl:apply-templates select="."/>
2164 <xsl:text>,&#x0A;</xsl:text>
2165 </xsl:for-each>
2166 <xsl:text> </xsl:text>
2167 <xsl:apply-templates select="param [last()]"/>
2168 <xsl:text>&#x0A; );&#x0A;</xsl:text>
2169 </xsl:if>
2170 <xsl:if test="not(param)">
2171 <xsl:text>)(</xsl:text>
2172 <xsl:value-of select="$iface" />
2173 <xsl:text> *pThis );&#x0A;</xsl:text>
2174 </xsl:if>
2175 <xsl:text>&#x0A;</xsl:text>
2176</xsl:template>
2177
2178<xsl:template match="method" mode="cobjmacro">
2179 <xsl:param name="iface"/>
2180
2181 <xsl:text>#define </xsl:text>
2182 <xsl:value-of select="concat($iface, '_')"/>
2183 <xsl:call-template name="capitalize">
2184 <xsl:with-param name="str" select="@name"/>
2185 </xsl:call-template>
2186 <xsl:text>(p</xsl:text>
2187 <xsl:for-each select="param">
2188 <xsl:text>, a</xsl:text>
2189 <xsl:call-template name="capitalize">
2190 <xsl:with-param name="str" select="@name"/>
2191 </xsl:call-template>
2192 </xsl:for-each>
2193 <xsl:text>) ((p)->lpVtbl-></xsl:text>
2194 <xsl:call-template name="capitalize">
2195 <xsl:with-param name="str" select="@name"/>
2196 </xsl:call-template>
2197 <xsl:text>(p</xsl:text>
2198 <xsl:for-each select="param">
2199 <xsl:text>, a</xsl:text>
2200 <xsl:call-template name="capitalize">
2201 <xsl:with-param name="str" select="@name"/>
2202 </xsl:call-template>
2203 </xsl:for-each>
2204 <xsl:text>))&#x0A;</xsl:text>
2205</xsl:template>
2206
2207
2208<!--
2209 * modules
2210-->
2211<xsl:template match="module">
2212 <xsl:apply-templates select="class"/>
2213</xsl:template>
2214
2215
2216<!--
2217 * co-classes
2218-->
2219<xsl:template match="module/class">
2220 <!-- class and contract id -->
2221 <xsl:text>&#x0A;</xsl:text>
2222 <xsl:text>#define NS_</xsl:text>
2223 <xsl:call-template name="uppercase">
2224 <xsl:with-param name="str" select="@name"/>
2225 </xsl:call-template>
2226 <xsl:text>_CID { \&#x0A;</xsl:text>
2227 <xsl:text> 0x</xsl:text><xsl:value-of select="substring(@uuid,1,8)"/>
2228 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,10,4)"/>
2229 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,15,4)"/>
2230 <xsl:text>, \&#x0A; </xsl:text>
2231 <xsl:text>{ 0x</xsl:text><xsl:value-of select="substring(@uuid,20,2)"/>
2232 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,22,2)"/>
2233 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,25,2)"/>
2234 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,27,2)"/>
2235 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,29,2)"/>
2236 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,31,2)"/>
2237 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,33,2)"/>
2238 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,35,2)"/>
2239 <xsl:text> } \&#x0A;}&#x0A;</xsl:text>
2240 <xsl:text>#define NS_</xsl:text>
2241 <xsl:call-template name="uppercase">
2242 <xsl:with-param name="str" select="@name"/>
2243 </xsl:call-template>
2244 <!-- Contract ID -->
2245 <xsl:text>_CONTRACTID &quot;@</xsl:text>
2246 <xsl:value-of select="@namespace"/>
2247 <xsl:text>/</xsl:text>
2248 <xsl:value-of select="@name"/>
2249 <xsl:text>;1&quot;&#x0A;</xsl:text>
2250 <!-- CLSID_xxx declarations for XPCOM, for compatibility with Win32 -->
2251 <xsl:text>/* COM compatibility */&#x0A;</xsl:text>
2252 <xsl:text>VBOX_EXTERN_CONST(nsCID, CLSID_</xsl:text>
2253 <xsl:value-of select="@name"/>
2254 <xsl:text>);&#x0A;</xsl:text>
2255 <xsl:text>&#x0A;&#x0A;</xsl:text>
2256</xsl:template>
2257
2258
2259<!--
2260 * enums
2261-->
2262<xsl:template match="enum">
2263 <xsl:text>/* Start of enum </xsl:text>
2264 <xsl:value-of select="@name"/>
2265 <xsl:text> declaration */&#x0A;</xsl:text>
2266 <xsl:text>#define </xsl:text>
2267 <xsl:call-template name="uppercase">
2268 <xsl:with-param name="str" select="@name"/>
2269 </xsl:call-template>
2270 <xsl:value-of select="concat('_IID_STR &quot;',@uuid,'&quot;')"/>
2271 <xsl:text>&#x0A;</xsl:text>
2272 <xsl:text>#define </xsl:text>
2273 <xsl:call-template name="uppercase">
2274 <xsl:with-param name="str" select="@name"/>
2275 </xsl:call-template>
2276 <xsl:text>_IID { \&#x0A;</xsl:text>
2277 <xsl:text> 0x</xsl:text><xsl:value-of select="substring(@uuid,1,8)"/>
2278 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,10,4)"/>
2279 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,15,4)"/>
2280 <xsl:text>, \&#x0A; </xsl:text>
2281 <xsl:text>{ 0x</xsl:text><xsl:value-of select="substring(@uuid,20,2)"/>
2282 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,22,2)"/>
2283 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,25,2)"/>
2284 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,27,2)"/>
2285 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,29,2)"/>
2286 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,31,2)"/>
2287 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,33,2)"/>
2288 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,35,2)"/>
2289 <xsl:text> } \&#x0A;}&#x0A;</xsl:text>
2290 <xsl:text>typedef enum </xsl:text>
2291 <xsl:value-of select="@name"/>
2292 <xsl:text>&#x0A;{&#x0A;</xsl:text>
2293 <xsl:variable name="this" select="."/>
2294 <xsl:for-each select="const">
2295 <xsl:text> </xsl:text>
2296 <xsl:value-of select="$this/@name"/>
2297 <xsl:text>_</xsl:text>
2298 <xsl:value-of select="@name"/> = <xsl:value-of select="@value"/>
2299 <xsl:if test="position() != last()">
2300 <xsl:text>,</xsl:text>
2301 </xsl:if>
2302 <xsl:text>&#x0A;</xsl:text>
2303 </xsl:for-each>
2304 <xsl:text>} </xsl:text>
2305 <xsl:value-of select="@name"/>
2306 <xsl:text>;&#x0A;</xsl:text>
2307 <xsl:text>/* End of enum </xsl:text>
2308 <xsl:value-of select="@name"/>
2309 <xsl:text> declaration */
2310#define </xsl:text>
2311 <xsl:value-of select="concat(@name, '_T PRUint32&#x0A;&#x0A;&#x0A;')"/>
2312</xsl:template>
2313
2314
2315<!--
2316 * method parameters
2317-->
2318<xsl:template match="method/param">
2319 <xsl:choose>
2320 <!-- safearray parameters -->
2321 <xsl:when test="@safearray='yes'">
2322 <!-- array size -->
2323 <xsl:choose>
2324 <xsl:when test="@dir='in'">
2325 <xsl:text>PRUint32 </xsl:text>
2326 <xsl:value-of select="@name"/>
2327 <xsl:text>Size,&#x0A;</xsl:text>
2328 </xsl:when>
2329 <xsl:when test="@dir='out'">
2330 <xsl:text>PRUint32 *</xsl:text>
2331 <xsl:value-of select="@name"/>
2332 <xsl:text>Size,&#x0A;</xsl:text>
2333 </xsl:when>
2334 <xsl:when test="@dir='return'">
2335 <xsl:text>PRUint32 *</xsl:text>
2336 <xsl:value-of select="@name"/>
2337 <xsl:text>Size,&#x0A;</xsl:text>
2338 </xsl:when>
2339 <xsl:otherwise>
2340 <xsl:text>PRUint32 </xsl:text>
2341 <xsl:value-of select="@name"/>
2342 <xsl:text>Size,&#x0A;</xsl:text>
2343 </xsl:otherwise>
2344 </xsl:choose>
2345 <!-- array pointer -->
2346 <xsl:text> </xsl:text>
2347 <xsl:choose>
2348 <xsl:when test="@dir='in'">
2349 <xsl:apply-templates select="@type" mode="forwarder"/>
2350 <xsl:text>*</xsl:text>
2351 </xsl:when>
2352 <xsl:when test="@dir='out'">
2353 <xsl:apply-templates select="@type" mode="forwarder"/>
2354 <xsl:text>**</xsl:text>
2355 </xsl:when>
2356 <xsl:when test="@dir='return'">
2357 <xsl:apply-templates select="@type" mode="forwarder"/>
2358 <xsl:text>**</xsl:text>
2359 </xsl:when>
2360 <xsl:otherwise>
2361 <xsl:apply-templates select="@type" mode="forwarder"/>
2362 <xsl:text>*</xsl:text>
2363 </xsl:otherwise>
2364 </xsl:choose>
2365 <xsl:text> </xsl:text>
2366 <xsl:value-of select="@name"/>
2367 </xsl:when>
2368 <!-- normal and array parameters -->
2369 <xsl:otherwise>
2370 <xsl:choose>
2371 <xsl:when test="@dir='in'">
2372 <xsl:apply-templates select="@type" mode="forwarder"/>
2373 <xsl:text></xsl:text>
2374 </xsl:when>
2375 <xsl:when test="@dir='out'">
2376 <xsl:apply-templates select="@type" mode="forwarder"/>
2377 <xsl:text> *</xsl:text>
2378 </xsl:when>
2379 <xsl:when test="@dir='return'">
2380 <xsl:apply-templates select="@type" mode="forwarder"/>
2381 <xsl:text> *</xsl:text>
2382 </xsl:when>
2383 <xsl:otherwise>
2384 <xsl:apply-templates select="@type" mode="forwarder"/>
2385 <xsl:text></xsl:text>
2386 </xsl:otherwise>
2387 </xsl:choose>
2388 <xsl:text> </xsl:text>
2389 <xsl:value-of select="@name"/>
2390 </xsl:otherwise>
2391 </xsl:choose>
2392</xsl:template>
2393
2394<xsl:template match="method/param" mode="forwarder">
2395 <xsl:if test="@safearray='yes'">
2396 <xsl:text>PRUint32</xsl:text>
2397 <xsl:if test="@dir='out' or @dir='return'">
2398 <xsl:text> *</xsl:text>
2399 </xsl:if>
2400 <xsl:text> a</xsl:text>
2401 <xsl:call-template name="capitalize">
2402 <xsl:with-param name="str" select="@name"/>
2403 </xsl:call-template>
2404 <xsl:text>Size, </xsl:text>
2405 </xsl:if>
2406 <xsl:apply-templates select="@type" mode="forwarder"/>
2407 <xsl:if test="@dir='out' or @dir='return'">
2408 <xsl:text> *</xsl:text>
2409 </xsl:if>
2410 <xsl:if test="@safearray='yes'">
2411 <xsl:text> *</xsl:text>
2412 </xsl:if>
2413 <xsl:text> a</xsl:text>
2414 <xsl:call-template name="capitalize">
2415 <xsl:with-param name="str" select="@name"/>
2416 </xsl:call-template>
2417</xsl:template>
2418
2419
2420<!--
2421 * attribute/parameter type conversion
2422-->
2423<xsl:template match="attribute/@type | param/@type">
2424 <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
2425
2426 <xsl:choose>
2427 <!-- modifiers (ignored for 'enumeration' attributes)-->
2428 <xsl:when test="name(current())='type' and ../@mod">
2429 <xsl:choose>
2430 <xsl:when test="../@mod='ptr'">
2431 <xsl:choose>
2432 <!-- standard types -->
2433 <!--xsl:when test=".='result'">??</xsl:when-->
2434 <xsl:when test=".='boolean'">booleanPtr</xsl:when>
2435 <xsl:when test=".='octet'">octetPtr</xsl:when>
2436 <xsl:when test=".='short'">shortPtr</xsl:when>
2437 <xsl:when test=".='unsigned short'">ushortPtr</xsl:when>
2438 <xsl:when test=".='long'">longPtr</xsl:when>
2439 <xsl:when test=".='long long'">llongPtr</xsl:when>
2440 <xsl:when test=".='unsigned long'">ulongPtr</xsl:when>
2441 <xsl:when test=".='unsigned long long'">ullongPtr</xsl:when>
2442 <xsl:otherwise>
2443 <xsl:message terminate="yes">
2444 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
2445 <xsl:text>attribute 'mod=</xsl:text>
2446 <xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
2447 <xsl:text>' cannot be used with type </xsl:text>
2448 <xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
2449 </xsl:message>
2450 </xsl:otherwise>
2451 </xsl:choose>
2452 </xsl:when>
2453 <xsl:when test="../@mod='string'">
2454 <xsl:choose>
2455 <!-- standard types -->
2456 <!--xsl:when test=".='result'">??</xsl:when-->
2457 <xsl:when test=".='uuid'">wstring</xsl:when>
2458 <xsl:otherwise>
2459 <xsl:message terminate="yes">
2460 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
2461 <xsl:text>attribute 'mod=</xsl:text>
2462 <xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
2463 <xsl:text>' cannot be used with type </xsl:text>
2464 <xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
2465 </xsl:message>
2466 </xsl:otherwise>
2467 </xsl:choose>
2468 </xsl:when>
2469 <xsl:otherwise>
2470 <xsl:message terminate="yes">
2471 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
2472 <xsl:value-of select="concat('value &quot;',../@mod,'&quot; ')"/>
2473 <xsl:text>of attribute 'mod' is invalid!</xsl:text>
2474 </xsl:message>
2475 </xsl:otherwise>
2476 </xsl:choose>
2477 </xsl:when>
2478 <!-- no modifiers -->
2479 <xsl:otherwise>
2480 <xsl:choose>
2481 <!-- standard types -->
2482 <xsl:when test=".='result'">nsresult</xsl:when>
2483 <xsl:when test=".='boolean'">boolean</xsl:when>
2484 <xsl:when test=".='octet'">octet</xsl:when>
2485 <xsl:when test=".='short'">short</xsl:when>
2486 <xsl:when test=".='unsigned short'">unsigned short</xsl:when>
2487 <xsl:when test=".='long'">long</xsl:when>
2488 <xsl:when test=".='long long'">long long</xsl:when>
2489 <xsl:when test=".='unsigned long'">unsigned long</xsl:when>
2490 <xsl:when test=".='unsigned long long'">unsigned long long</xsl:when>
2491 <xsl:when test=".='char'">char</xsl:when>
2492 <xsl:when test=".='wchar'">wchar</xsl:when>
2493 <xsl:when test=".='string'">string</xsl:when>
2494 <xsl:when test=".='wstring'">wstring</xsl:when>
2495 <!-- UUID type -->
2496 <xsl:when test=".='uuid'">
2497 <xsl:choose>
2498 <xsl:when test="name(..)='attribute'">
2499 <xsl:choose>
2500 <xsl:when test="../@readonly='yes'">
2501 <xsl:text>nsIDPtr</xsl:text>
2502 </xsl:when>
2503 <xsl:otherwise>
2504 <xsl:message terminate="yes">
2505 <xsl:value-of select="../@name"/>
2506 <xsl:text>: Non-readonly uuid attributes are not supported!</xsl:text>
2507 </xsl:message>
2508 </xsl:otherwise>
2509 </xsl:choose>
2510 </xsl:when>
2511 <xsl:when test="name(..)='param'">
2512 <xsl:choose>
2513 <xsl:when test="../@dir='in' and not(../@safearray='yes')">
2514 <xsl:text>nsIDRef</xsl:text>
2515 </xsl:when>
2516 <xsl:otherwise>
2517 <xsl:text>nsIDPtr</xsl:text>
2518 </xsl:otherwise>
2519 </xsl:choose>
2520 </xsl:when>
2521 </xsl:choose>
2522 </xsl:when>
2523 <!-- system interface types -->
2524 <xsl:when test=".='$unknown'">nsISupports</xsl:when>
2525 <xsl:otherwise>
2526 <xsl:choose>
2527 <!-- enum types -->
2528 <xsl:when test="
2529 (ancestor::library/enum[@name=current()]) or
2530 (ancestor::library/if[@target=$self_target]/enum[@name=current()])
2531 ">
2532 <xsl:text>PRUint32</xsl:text>
2533 </xsl:when>
2534 <!-- custom interface types -->
2535 <xsl:when test="
2536 (name(current())='enumerator' and
2537 ((ancestor::library/enumerator[@name=current()]) or
2538 (ancestor::library/if[@target=$self_target]/enumerator[@name=current()]))
2539 ) or
2540 ((ancestor::library/interface[@name=current()]) or
2541 (ancestor::library/if[@target=$self_target]/interface[@name=current()])
2542 )
2543 ">
2544 <xsl:value-of select="."/>
2545 </xsl:when>
2546 <!-- other types -->
2547 <xsl:otherwise>
2548 <xsl:message terminate="yes">
2549 <xsl:text>Unknown parameter type: </xsl:text>
2550 <xsl:value-of select="."/>
2551 </xsl:message>
2552 </xsl:otherwise>
2553 </xsl:choose>
2554 </xsl:otherwise>
2555 </xsl:choose>
2556 </xsl:otherwise>
2557 </xsl:choose>
2558</xsl:template>
2559
2560<xsl:template match="attribute/@type | param/@type" mode="forwarder">
2561
2562 <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
2563
2564 <xsl:choose>
2565 <!-- modifiers (ignored for 'enumeration' attributes)-->
2566 <xsl:when test="name(current())='type' and ../@mod">
2567 <xsl:choose>
2568 <xsl:when test="../@mod='ptr'">
2569 <xsl:choose>
2570 <!-- standard types -->
2571 <!--xsl:when test=".='result'">??</xsl:when-->
2572 <xsl:when test=".='boolean'">PRBool *</xsl:when>
2573 <xsl:when test=".='octet'">PRUint8 *</xsl:when>
2574 <xsl:when test=".='short'">PRInt16 *</xsl:when>
2575 <xsl:when test=".='unsigned short'">PRUint16 *</xsl:when>
2576 <xsl:when test=".='long'">PRInt32 *</xsl:when>
2577 <xsl:when test=".='long long'">PRInt64 *</xsl:when>
2578 <xsl:when test=".='unsigned long'">PRUint32 *</xsl:when>
2579 <xsl:when test=".='unsigned long long'">PRUint64 *</xsl:when>
2580 <xsl:otherwise>
2581 <xsl:message terminate="yes">
2582 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
2583 <xsl:text>attribute 'mod=</xsl:text>
2584 <xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
2585 <xsl:text>' cannot be used with type </xsl:text>
2586 <xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
2587 </xsl:message>
2588 </xsl:otherwise>
2589 </xsl:choose>
2590 </xsl:when>
2591 <xsl:when test="../@mod='string'">
2592 <xsl:choose>
2593 <!-- standard types -->
2594 <!--xsl:when test=".='result'">??</xsl:when-->
2595 <xsl:when test=".='uuid'">PRUnichar *</xsl:when>
2596 <xsl:otherwise>
2597 <xsl:message terminate="yes">
2598 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
2599 <xsl:text>attribute 'mod=</xsl:text>
2600 <xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
2601 <xsl:text>' cannot be used with type </xsl:text>
2602 <xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
2603 </xsl:message>
2604 </xsl:otherwise>
2605 </xsl:choose>
2606 </xsl:when>
2607 </xsl:choose>
2608 </xsl:when>
2609 <!-- no modifiers -->
2610 <xsl:otherwise>
2611 <xsl:choose>
2612 <!-- standard types -->
2613 <xsl:when test=".='result'">nsresult</xsl:when>
2614 <xsl:when test=".='boolean'">PRBool</xsl:when>
2615 <xsl:when test=".='octet'">PRUint8</xsl:when>
2616 <xsl:when test=".='short'">PRInt16</xsl:when>
2617 <xsl:when test=".='unsigned short'">PRUint16</xsl:when>
2618 <xsl:when test=".='long'">PRInt32</xsl:when>
2619 <xsl:when test=".='long long'">PRInt64</xsl:when>
2620 <xsl:when test=".='unsigned long'">PRUint32</xsl:when>
2621 <xsl:when test=".='unsigned long long'">PRUint64</xsl:when>
2622 <xsl:when test=".='char'">char</xsl:when>
2623 <xsl:when test=".='wchar'">PRUnichar</xsl:when>
2624 <!-- string types -->
2625 <xsl:when test=".='string'">char *</xsl:when>
2626 <xsl:when test=".='wstring'">PRUnichar *</xsl:when>
2627 <!-- UUID type -->
2628 <xsl:when test=".='uuid'">
2629 <xsl:choose>
2630 <xsl:when test="name(..)='attribute'">
2631 <xsl:choose>
2632 <xsl:when test="../@readonly='yes'">
2633 <xsl:text>nsID *</xsl:text>
2634 </xsl:when>
2635 </xsl:choose>
2636 </xsl:when>
2637 <xsl:when test="name(..)='param'">
2638 <xsl:choose>
2639 <xsl:when test="../@dir='in' and not(../@safearray='yes')">
2640 <xsl:text>const nsID *</xsl:text>
2641 </xsl:when>
2642 <xsl:otherwise>
2643 <xsl:text>nsID *</xsl:text>
2644 </xsl:otherwise>
2645 </xsl:choose>
2646 </xsl:when>
2647 </xsl:choose>
2648 </xsl:when>
2649 <!-- system interface types -->
2650 <xsl:when test=".='$unknown'">nsISupports *</xsl:when>
2651 <xsl:otherwise>
2652 <xsl:choose>
2653 <!-- enum types -->
2654 <xsl:when test="
2655 (ancestor::library/enum[@name=current()]) or
2656 (ancestor::library/if[@target=$self_target]/enum[@name=current()])
2657 ">
2658 <xsl:text>PRUint32</xsl:text>
2659 </xsl:when>
2660 <!-- custom interface types -->
2661 <xsl:when test="
2662 (name(current())='enumerator' and
2663 ((ancestor::library/enumerator[@name=current()]) or
2664 (ancestor::library/if[@target=$self_target]/enumerator[@name=current()]))
2665 ) or
2666 ((ancestor::library/interface[@name=current()]) or
2667 (ancestor::library/if[@target=$self_target]/interface[@name=current()])
2668 )
2669 ">
2670 <xsl:value-of select="."/>
2671 <xsl:text> *</xsl:text>
2672 </xsl:when>
2673 <!-- other types -->
2674 </xsl:choose>
2675 </xsl:otherwise>
2676 </xsl:choose>
2677 </xsl:otherwise>
2678 </xsl:choose>
2679</xsl:template>
2680
2681</xsl:stylesheet>
2682
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