VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/xpcom/reflect/xptcall/public/xptcall.h@ 2443

Last change on this file since 2443 was 2443, checked in by vboxsync, 18 years ago

fix visibility for incompatible gcc-3.4 compilers

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.1 KB
Line 
1/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is mozilla.org code.
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1999
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
35 *
36 * ***** END LICENSE BLOCK ***** */
37
38/* Public declarations for xptcall. */
39
40#ifndef xptcall_h___
41#define xptcall_h___
42
43#include "prtypes.h"
44#include "nscore.h"
45#include "nsISupports.h"
46#include "xpt_struct.h"
47#include "xptinfo.h"
48#include "nsIInterfaceInfo.h"
49
50/***************************************************************************/
51/*
52 * The linkage of XPTC API functions differs depending on whether the file is
53 * used within the XPTC library or not. Any source file within the XPTC
54 * library should define EXPORT_XPTC_API whereas any client of the library
55 * should not.
56 */
57#ifdef EXPORT_XPTC_API
58#define XPTC_PUBLIC_API(t) PR_IMPLEMENT(t)
59#define XPTC_PUBLIC_DATA(t) PR_IMPLEMENT_DATA(t)
60#ifdef _WIN32
61# define XPTC_EXPORT __declspec(dllexport)
62#else
63# ifdef VBOX_HAVE_VISIBILITY_HIDDEN
64# define XPTC_EXPORT __attribute__((visibility("default")))
65# else
66# define XPTC_EXPORT
67# endif
68#endif
69#else
70#ifdef _WIN32
71# define XPTC_PUBLIC_API(t) __declspec(dllimport) t
72# define XPTC_PUBLIC_DATA(t) __declspec(dllimport) t
73# define XPTC_EXPORT __declspec(dllimport)
74#else
75# define XPTC_PUBLIC_API(t) PR_IMPLEMENT(t)
76# define XPTC_PUBLIC_DATA(t) t
77# define XPTC_EXPORT
78#endif
79#endif
80#define XPTC_FRIEND_API(t) XPTC_PUBLIC_API(t)
81#define XPTC_FRIEND_DATA(t) XPTC_PUBLIC_DATA(t)
82/***************************************************************************/
83
84struct nsXPTCMiniVariant
85{
86// No ctors or dtors so that we can use arrays of these on the stack
87// with no penalty.
88 union
89 {
90 PRInt8 i8;
91 PRInt16 i16;
92 PRInt32 i32;
93 PRInt64 i64;
94 PRUint8 u8;
95 PRUint16 u16;
96 PRUint32 u32;
97 PRUint64 u64;
98 float f;
99 double d;
100 PRBool b;
101 char c;
102 PRUnichar wc;
103 void* p;
104 } val;
105};
106
107struct nsXPTCVariant : public nsXPTCMiniVariant
108{
109// No ctors or dtors so that we can use arrays of these on the stack
110// with no penalty.
111
112 // inherits 'val' here
113 void* ptr;
114 nsXPTType type;
115 PRUint8 flags;
116
117 enum
118 {
119 // these are bitflags!
120 PTR_IS_DATA = 0x1, // ptr points to 'real' data in val
121 VAL_IS_ALLOCD = 0x2, // val.p holds alloc'd ptr that must be freed
122 VAL_IS_IFACE = 0x4, // val.p holds interface ptr that must be released
123 VAL_IS_ARRAY = 0x8, // val.p holds a pointer to an array needing cleanup
124 VAL_IS_DOMSTR = 0x10, // val.p holds a pointer to domstring needing cleanup
125 VAL_IS_UTF8STR = 0x20, // val.p holds a pointer to utf8string needing cleanup
126 VAL_IS_CSTR = 0x40 // val.p holds a pointer to cstring needing cleanup
127 };
128
129 void ClearFlags() {flags = 0;}
130 void SetPtrIsData() {flags |= PTR_IS_DATA;}
131 void SetValIsAllocated() {flags |= VAL_IS_ALLOCD;}
132 void SetValIsInterface() {flags |= VAL_IS_IFACE;}
133 void SetValIsArray() {flags |= VAL_IS_ARRAY;}
134 void SetValIsDOMString() {flags |= VAL_IS_DOMSTR;}
135 void SetValIsUTF8String() {flags |= VAL_IS_UTF8STR;}
136 void SetValIsCString() {flags |= VAL_IS_CSTR;}
137
138 PRBool IsPtrData() const {return 0 != (flags & PTR_IS_DATA);}
139 PRBool IsValAllocated() const {return 0 != (flags & VAL_IS_ALLOCD);}
140 PRBool IsValInterface() const {return 0 != (flags & VAL_IS_IFACE);}
141 PRBool IsValArray() const {return 0 != (flags & VAL_IS_ARRAY);}
142 PRBool IsValDOMString() const {return 0 != (flags & VAL_IS_DOMSTR);}
143 PRBool IsValUTF8String() const {return 0 != (flags & VAL_IS_UTF8STR);}
144 PRBool IsValCString() const {return 0 != (flags & VAL_IS_CSTR);}
145
146 void Init(const nsXPTCMiniVariant& mv, const nsXPTType& t, PRUint8 f)
147 {
148 type = t;
149 flags = f;
150
151 if(f & PTR_IS_DATA)
152 {
153 ptr = mv.val.p;
154 val.p = nsnull;
155 }
156 else
157 {
158 ptr = nsnull;
159 switch(t.TagPart()) {
160 case nsXPTType::T_I8: val.i8 = mv.val.i8; break;
161 case nsXPTType::T_I16: val.i16 = mv.val.i16; break;
162 case nsXPTType::T_I32: val.i32 = mv.val.i32; break;
163 case nsXPTType::T_I64: val.i64 = mv.val.i64; break;
164 case nsXPTType::T_U8: val.u8 = mv.val.u8; break;
165 case nsXPTType::T_U16: val.u16 = mv.val.u16; break;
166 case nsXPTType::T_U32: val.u32 = mv.val.u32; break;
167 case nsXPTType::T_U64: val.u64 = mv.val.u64; break;
168 case nsXPTType::T_FLOAT: val.f = mv.val.f; break;
169 case nsXPTType::T_DOUBLE: val.d = mv.val.d; break;
170 case nsXPTType::T_BOOL: val.b = mv.val.b; break;
171 case nsXPTType::T_CHAR: val.c = mv.val.c; break;
172 case nsXPTType::T_WCHAR: val.wc = mv.val.wc; break;
173 case nsXPTType::T_VOID: /* fall through */
174 case nsXPTType::T_IID: /* fall through */
175 case nsXPTType::T_DOMSTRING: /* fall through */
176 case nsXPTType::T_CHAR_STR: /* fall through */
177 case nsXPTType::T_WCHAR_STR: /* fall through */
178 case nsXPTType::T_INTERFACE: /* fall through */
179 case nsXPTType::T_INTERFACE_IS: /* fall through */
180 case nsXPTType::T_ARRAY: /* fall through */
181 case nsXPTType::T_PSTRING_SIZE_IS: /* fall through */
182 case nsXPTType::T_PWSTRING_SIZE_IS: /* fall through */
183 case nsXPTType::T_UTF8STRING: /* fall through */
184 case nsXPTType::T_CSTRING: /* fall through */
185 default: val.p = mv.val.p; break;
186 }
187 }
188 }
189};
190
191/***************************************************************************/
192
193#undef IMETHOD_VISIBILITY
194#define IMETHOD_VISIBILITY NS_VISIBILITY_DEFAULT
195
196class XPTC_EXPORT nsXPTCStubBase : public nsISupports
197{
198public:
199 // We are going to implement this to force the compiler to generate a
200 // vtbl for this class. Since this is overridden in the inheriting class
201 // we expect it to never be called.
202 // *This is needed by the Irix implementation.*
203 NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
204
205 // Include generated vtbl stub declarations.
206 // These are virtual and *also* implemented by this class..
207#include "xptcstubsdecl.inc"
208
209 // The following methods must be provided by inheritor of this class.
210
211 // return a refcounted pointer to the InterfaceInfo for this object
212 // NOTE: on some platforms this MUST not fail or we crash!
213 NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo** info) = 0;
214
215 // call this method and return result
216 NS_IMETHOD CallMethod(PRUint16 methodIndex,
217 const nsXPTMethodInfo* info,
218 nsXPTCMiniVariant* params) = 0;
219};
220
221#undef IMETHOD_VISIBILITY
222#define IMETHOD_VISIBILITY NS_VISIBILITY_HIDDEN
223
224PR_BEGIN_EXTERN_C
225
226XPTC_PUBLIC_API(nsresult)
227XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
228 PRUint32 paramCount, nsXPTCVariant* params);
229
230// Used to force linking of these obj for the static library into the dll
231extern void xptc_dummy();
232extern void xptc_dummy2();
233
234PR_END_EXTERN_C
235
236#endif /* xptcall_h___ */
Note: See TracBrowser for help on using the repository browser.

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