VirtualBox

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

Last change on this file since 50183 was 50183, checked in by vboxsync, 11 years ago

Main/cbinding: bring the C binding to a new functionality level, making them handle both COM and XPCOM based platforms, plus some xsl cleanup to eliminate the $dispatch case which was unused for many years (and will not be used again)

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette