VirtualBox

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

Last change on this file since 62485 was 61958, checked in by vboxsync, 8 years ago

Main/idl/{m,xp}idl.xsl: need to cast the custom return values (Windows uses a signed type, XPCOM unsigned) for consistent behavior (e.g. when throwing raw error codes without using setError etc.)

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