VirtualBox

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

Last change on this file since 96407 was 96407, checked in by vboxsync, 3 years ago

scm copyright and license note update

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