1 | /* ***** BEGIN LICENSE BLOCK *****
|
---|
2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
---|
3 | *
|
---|
4 | * The contents of this file are subject to the Mozilla Public License Version
|
---|
5 | * 1.1 (the "License"); you may not use this file except in compliance with
|
---|
6 | * the License. You may obtain a copy of the License at
|
---|
7 | * http://www.mozilla.org/MPL/
|
---|
8 | *
|
---|
9 | * Software distributed under the License is distributed on an "AS IS" basis,
|
---|
10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
---|
11 | * for the specific language governing rights and limitations under the
|
---|
12 | * License.
|
---|
13 | *
|
---|
14 | * The Original Code is XPCOM.
|
---|
15 | *
|
---|
16 | * The Initial Developer of the Original Code is Netscape Communications Corp.
|
---|
17 | * Portions created by the Initial Developer are Copyright (C) 2001
|
---|
18 | * the Initial Developer. All Rights Reserved.
|
---|
19 | *
|
---|
20 | * Contributor(s):
|
---|
21 | *
|
---|
22 | * Alternatively, the contents of this file may be used under the terms of
|
---|
23 | * either the GNU General Public License Version 2 or later (the "GPL"), or
|
---|
24 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
---|
25 | * in which case the provisions of the GPL or the LGPL are applicable instead
|
---|
26 | * of those above. If you wish to allow use of your version of this file only
|
---|
27 | * under the terms of either the GPL or the LGPL, and not to allow others to
|
---|
28 | * use your version of this file under the terms of the MPL, indicate your
|
---|
29 | * decision by deleting the provisions above and replace them with the notice
|
---|
30 | * and other provisions required by the GPL or the LGPL. If you do not delete
|
---|
31 | * the provisions above, a recipient may use your version of this file under
|
---|
32 | * the terms of any one of the MPL, the GPL or the LGPL.
|
---|
33 | *
|
---|
34 | * ***** END LICENSE BLOCK ***** */
|
---|
35 |
|
---|
36 |
|
---|
37 | #ifndef nsISupportsImpl_h__
|
---|
38 | #define nsISupportsImpl_h__
|
---|
39 |
|
---|
40 | #ifndef nscore_h___
|
---|
41 | #include "nscore.h"
|
---|
42 | #endif
|
---|
43 |
|
---|
44 | #ifndef nsISupportsBase_h__
|
---|
45 | #include "nsISupportsBase.h"
|
---|
46 | #endif
|
---|
47 |
|
---|
48 | #include "nsDebug.h"
|
---|
49 | #include "nsTraceRefcnt.h"
|
---|
50 | #ifdef VBOX
|
---|
51 | # include <iprt/asm.h>
|
---|
52 | # include <iprt/assert.h>
|
---|
53 | # include <iprt/thread.h>
|
---|
54 | #endif
|
---|
55 |
|
---|
56 | ////////////////////////////////////////////////////////////////////////////////
|
---|
57 | // Macros to help detect thread-safety:
|
---|
58 |
|
---|
59 | #if defined(NS_DEBUG)
|
---|
60 |
|
---|
61 | class nsAutoOwningThread {
|
---|
62 | public:
|
---|
63 | nsAutoOwningThread() { mThread = RTThreadSelf(); }
|
---|
64 | void *GetThread() const { return mThread; }
|
---|
65 |
|
---|
66 | private:
|
---|
67 | void *mThread;
|
---|
68 | };
|
---|
69 |
|
---|
70 | #define NS_DECL_OWNINGTHREAD nsAutoOwningThread _mOwningThread;
|
---|
71 | #define NS_ASSERT_OWNINGTHREAD(_class) \
|
---|
72 | NS_CheckThreadSafe(_mOwningThread.GetThread(), #_class " not thread-safe")
|
---|
73 |
|
---|
74 | #else // !(defined(NS_DEBUG))
|
---|
75 |
|
---|
76 | #define NS_DECL_OWNINGTHREAD /* nothing */
|
---|
77 | #define NS_ASSERT_OWNINGTHREAD(_class) ((void)0)
|
---|
78 |
|
---|
79 | #endif // !(defined(NS_DEBUG))
|
---|
80 |
|
---|
81 | class nsAutoRefCnt {
|
---|
82 |
|
---|
83 | public:
|
---|
84 | nsAutoRefCnt() : mValue(0)
|
---|
85 | #ifdef VBOX
|
---|
86 | , mState(0)
|
---|
87 | #endif
|
---|
88 | {}
|
---|
89 | nsAutoRefCnt(nsrefcnt aValue) : mValue(aValue) {}
|
---|
90 |
|
---|
91 | // only support prefix increment/decrement
|
---|
92 | nsrefcnt operator++() { return ++mValue; }
|
---|
93 | nsrefcnt operator--() { return --mValue; }
|
---|
94 |
|
---|
95 | nsrefcnt operator=(nsrefcnt aValue) { return (mValue = aValue); }
|
---|
96 | operator nsrefcnt() const { return mValue; }
|
---|
97 | nsrefcnt get() const { return mValue; }
|
---|
98 | #ifdef VBOX
|
---|
99 | nsrefcnt *ref() { return &mValue; }
|
---|
100 | PRUint32 getState() const { return mState; }
|
---|
101 | PRUint32 *refState() { return &mState; }
|
---|
102 | #endif
|
---|
103 | private:
|
---|
104 | // do not define these to enforce the faster prefix notation
|
---|
105 | nsrefcnt operator++(int);
|
---|
106 | nsrefcnt operator--(int);
|
---|
107 | nsrefcnt mValue;
|
---|
108 | #ifdef VBOX
|
---|
109 | PRUint32 mState;
|
---|
110 | #endif
|
---|
111 | };
|
---|
112 |
|
---|
113 | ///////////////////////////////////////////////////////////////////////////////
|
---|
114 |
|
---|
115 | /**
|
---|
116 | * Declare the reference count variable and the implementations of the
|
---|
117 | * AddRef and QueryInterface methods.
|
---|
118 | */
|
---|
119 |
|
---|
120 | #define NS_DECL_ISUPPORTS \
|
---|
121 | public: \
|
---|
122 | NS_IMETHOD QueryInterface(REFNSIID aIID, \
|
---|
123 | void** aInstancePtr) NS_OVERRIDE; \
|
---|
124 | NS_IMETHOD_(nsrefcnt) AddRef(void) NS_OVERRIDE; \
|
---|
125 | NS_IMETHOD_(nsrefcnt) Release(void) NS_OVERRIDE; \
|
---|
126 | protected: \
|
---|
127 | nsAutoRefCnt mRefCnt; \
|
---|
128 | NS_DECL_OWNINGTHREAD \
|
---|
129 | public:
|
---|
130 |
|
---|
131 |
|
---|
132 | ///////////////////////////////////////////////////////////////////////////////
|
---|
133 |
|
---|
134 | /**
|
---|
135 | * Previously used to initialize the reference count, but no longer needed.
|
---|
136 | *
|
---|
137 | * DEPRECATED.
|
---|
138 | */
|
---|
139 | #define NS_INIT_ISUPPORTS() ((void)0)
|
---|
140 |
|
---|
141 | /**
|
---|
142 | * Use this macro to implement the AddRef method for a given <i>_class</i>
|
---|
143 | * @param _class The name of the class implementing the method
|
---|
144 | */
|
---|
145 | #define NS_IMPL_ADDREF(_class) \
|
---|
146 | NS_IMETHODIMP_(nsrefcnt) _class::AddRef(void) \
|
---|
147 | { \
|
---|
148 | NS_PRECONDITION(PRInt32(mRefCnt) >= 0, "illegal refcnt"); \
|
---|
149 | NS_ASSERT_OWNINGTHREAD(_class); \
|
---|
150 | ++mRefCnt; \
|
---|
151 | NS_LOG_ADDREF(this, mRefCnt, #_class, sizeof(*this)); \
|
---|
152 | return mRefCnt; \
|
---|
153 | }
|
---|
154 |
|
---|
155 | /**
|
---|
156 | * Use this macro to implement the AddRef method for a given <i>_class</i>
|
---|
157 | * implemented as a wholly owned aggregated object intended to implement
|
---|
158 | * interface(s) for its owner
|
---|
159 | * @param _class The name of the class implementing the method
|
---|
160 | * @param _aggregator the owning/containing object
|
---|
161 | */
|
---|
162 | #define NS_IMPL_ADDREF_USING_AGGREGATOR(_class, _aggregator) \
|
---|
163 | NS_IMETHODIMP_(nsrefcnt) _class::AddRef(void) \
|
---|
164 | { \
|
---|
165 | NS_PRECONDITION(_aggregator, "null aggregator"); \
|
---|
166 | return (_aggregator)->AddRef(); \
|
---|
167 | }
|
---|
168 |
|
---|
169 | /**
|
---|
170 | * Use this macro to implement the Release method for a given
|
---|
171 | * <i>_class</i>.
|
---|
172 | * @param _class The name of the class implementing the method
|
---|
173 | * @param _destroy A statement that is executed when the object's
|
---|
174 | * refcount drops to zero.
|
---|
175 | *
|
---|
176 | * For example,
|
---|
177 | *
|
---|
178 | * NS_IMPL_RELEASE_WITH_DESTROY(Foo, Destroy(this))
|
---|
179 | *
|
---|
180 | * will cause
|
---|
181 | *
|
---|
182 | * Destroy(this);
|
---|
183 | *
|
---|
184 | * to be invoked when the object's refcount drops to zero. This
|
---|
185 | * allows for arbitrary teardown activity to occur (e.g., deallocation
|
---|
186 | * of object allocated with placement new).
|
---|
187 | */
|
---|
188 | #define NS_IMPL_RELEASE_WITH_DESTROY(_class, _destroy) \
|
---|
189 | NS_IMETHODIMP_(nsrefcnt) _class::Release(void) \
|
---|
190 | { \
|
---|
191 | NS_PRECONDITION(0 != mRefCnt, "dup release"); \
|
---|
192 | NS_ASSERT_OWNINGTHREAD(_class); \
|
---|
193 | --mRefCnt; \
|
---|
194 | NS_LOG_RELEASE(this, mRefCnt, #_class); \
|
---|
195 | if (mRefCnt == 0) { \
|
---|
196 | mRefCnt = 1; /* stabilize */ \
|
---|
197 | _destroy; \
|
---|
198 | return 0; \
|
---|
199 | } \
|
---|
200 | return mRefCnt; \
|
---|
201 | }
|
---|
202 |
|
---|
203 | /**
|
---|
204 | * Use this macro to implement the Release method for a given <i>_class</i>
|
---|
205 | * @param _class The name of the class implementing the method
|
---|
206 | *
|
---|
207 | * A note on the 'stabilization' of the refcnt to one. At that point,
|
---|
208 | * the object's refcount will have gone to zero. The object's
|
---|
209 | * destructor may trigger code that attempts to QueryInterface() and
|
---|
210 | * Release() 'this' again. Doing so will temporarily increment and
|
---|
211 | * decrement the refcount. (Only a logic error would make one try to
|
---|
212 | * keep a permanent hold on 'this'.) To prevent re-entering the
|
---|
213 | * destructor, we make sure that no balanced refcounting can return
|
---|
214 | * the refcount to |0|.
|
---|
215 | */
|
---|
216 | #define NS_IMPL_RELEASE(_class) \
|
---|
217 | NS_IMPL_RELEASE_WITH_DESTROY(_class, NS_DELETEXPCOM(this))
|
---|
218 |
|
---|
219 | /**
|
---|
220 | * Use this macro to implement the Release method for a given <i>_class</i>
|
---|
221 | * implemented as a wholly owned aggregated object intended to implement
|
---|
222 | * interface(s) for its owner
|
---|
223 | * @param _class The name of the class implementing the method
|
---|
224 | * @param _aggregator the owning/containing object
|
---|
225 | */
|
---|
226 | #define NS_IMPL_RELEASE_USING_AGGREGATOR(_class, _aggregator) \
|
---|
227 | NS_IMETHODIMP_(nsrefcnt) _class::Release(void) \
|
---|
228 | { \
|
---|
229 | NS_PRECONDITION(_aggregator, "null aggregator"); \
|
---|
230 | return (_aggregator)->Release(); \
|
---|
231 | }
|
---|
232 |
|
---|
233 |
|
---|
234 |
|
---|
235 | ///////////////////////////////////////////////////////////////////////////////
|
---|
236 |
|
---|
237 | /*
|
---|
238 | * Some convenience macros for implementing QueryInterface
|
---|
239 | */
|
---|
240 |
|
---|
241 | /**
|
---|
242 | * This implements query interface with two assumptions: First, the
|
---|
243 | * class in question implements nsISupports and its own interface and
|
---|
244 | * nothing else. Second, the implementation of the class's primary
|
---|
245 | * inheritance chain leads to its own interface.
|
---|
246 | *
|
---|
247 | * @param _class The name of the class implementing the method
|
---|
248 | * @param _classiiddef The name of the #define symbol that defines the IID
|
---|
249 | * for the class (e.g. NS_ISUPPORTS_IID)
|
---|
250 | */
|
---|
251 |
|
---|
252 | #define NS_IMPL_QUERY_HEAD(_class) \
|
---|
253 | NS_IMETHODIMP _class::QueryInterface(REFNSIID aIID, void** aInstancePtr) \
|
---|
254 | { \
|
---|
255 | NS_ASSERTION(aInstancePtr, \
|
---|
256 | "QueryInterface requires a non-NULL destination!"); \
|
---|
257 | nsISupports* foundInterface;
|
---|
258 |
|
---|
259 | #define NS_IMPL_QUERY_BODY(_interface) \
|
---|
260 | if ( aIID.Equals(NS_GET_IID(_interface)) ) \
|
---|
261 | foundInterface = NS_STATIC_CAST(_interface*, this); \
|
---|
262 | else
|
---|
263 |
|
---|
264 | #define NS_IMPL_QUERY_BODY_CONDITIONAL(_interface, condition) \
|
---|
265 | if ( (condition) && aIID.Equals(NS_GET_IID(_interface))) \
|
---|
266 | foundInterface = NS_STATIC_CAST(_interface*, this); \
|
---|
267 | else
|
---|
268 |
|
---|
269 | #define NS_IMPL_QUERY_BODY_AMBIGUOUS(_interface, _implClass) \
|
---|
270 | if ( aIID.Equals(NS_GET_IID(_interface)) ) \
|
---|
271 | foundInterface = NS_STATIC_CAST(_interface*, \
|
---|
272 | NS_STATIC_CAST(_implClass*, this)); \
|
---|
273 | else
|
---|
274 |
|
---|
275 | #define NS_IMPL_QUERY_BODY_AGGREGATED(_interface, _aggregate) \
|
---|
276 | if ( aIID.Equals(NS_GET_IID(_interface)) ) \
|
---|
277 | foundInterface = NS_STATIC_CAST(_interface*, _aggregate); \
|
---|
278 | else
|
---|
279 |
|
---|
280 | #define NS_IMPL_QUERY_TAIL_GUTS \
|
---|
281 | foundInterface = 0; \
|
---|
282 | nsresult status; \
|
---|
283 | if ( !foundInterface ) \
|
---|
284 | status = NS_NOINTERFACE; \
|
---|
285 | else \
|
---|
286 | { \
|
---|
287 | NS_ADDREF(foundInterface); \
|
---|
288 | status = NS_OK; \
|
---|
289 | } \
|
---|
290 | *aInstancePtr = foundInterface; \
|
---|
291 | return status; \
|
---|
292 | }
|
---|
293 |
|
---|
294 | #define NS_IMPL_QUERY_TAIL_INHERITING(_baseclass) \
|
---|
295 | foundInterface = 0; \
|
---|
296 | nsresult status; \
|
---|
297 | if ( !foundInterface ) \
|
---|
298 | status = _baseclass::QueryInterface(aIID, (void**)&foundInterface); \
|
---|
299 | else \
|
---|
300 | { \
|
---|
301 | NS_ADDREF(foundInterface); \
|
---|
302 | status = NS_OK; \
|
---|
303 | } \
|
---|
304 | *aInstancePtr = foundInterface; \
|
---|
305 | return status; \
|
---|
306 | }
|
---|
307 |
|
---|
308 | #define NS_IMPL_QUERY_TAIL_USING_AGGREGATOR(_aggregator) \
|
---|
309 | foundInterface = 0; \
|
---|
310 | nsresult status; \
|
---|
311 | if ( !foundInterface ) { \
|
---|
312 | NS_ASSERTION(_aggregator, "null aggregator"); \
|
---|
313 | status = _aggregator->QueryInterface(aIID, (void**)&foundInterface); \
|
---|
314 | } else \
|
---|
315 | { \
|
---|
316 | NS_ADDREF(foundInterface); \
|
---|
317 | status = NS_OK; \
|
---|
318 | } \
|
---|
319 | *aInstancePtr = foundInterface; \
|
---|
320 | return status; \
|
---|
321 | }
|
---|
322 |
|
---|
323 | #define NS_IMPL_QUERY_TAIL(_supports_interface) \
|
---|
324 | NS_IMPL_QUERY_BODY_AMBIGUOUS(nsISupports, _supports_interface) \
|
---|
325 | NS_IMPL_QUERY_TAIL_GUTS
|
---|
326 |
|
---|
327 |
|
---|
328 | /*
|
---|
329 | This is the new scheme. Using this notation now will allow us to switch to
|
---|
330 | a table driven mechanism when it's ready. Note the difference between this
|
---|
331 | and the (currently) underlying NS_IMPL_QUERY_INTERFACE mechanism. You must
|
---|
332 | explicitly mention |nsISupports| when using the interface maps.
|
---|
333 | */
|
---|
334 | #define NS_INTERFACE_MAP_BEGIN(_implClass) NS_IMPL_QUERY_HEAD(_implClass)
|
---|
335 | #define NS_INTERFACE_MAP_ENTRY(_interface) NS_IMPL_QUERY_BODY(_interface)
|
---|
336 | #define NS_INTERFACE_MAP_ENTRY_CONDITIONAL(_interface, condition) \
|
---|
337 | NS_IMPL_QUERY_BODY_CONDITIONAL(_interface, condition)
|
---|
338 | #define NS_INTERFACE_MAP_ENTRY_AGGREGATED(_interface,_aggregate) \
|
---|
339 | NS_IMPL_QUERY_BODY_AGGREGATED(_interface,_aggregate)
|
---|
340 |
|
---|
341 | #define NS_INTERFACE_MAP_END NS_IMPL_QUERY_TAIL_GUTS
|
---|
342 | #define NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(_interface, _implClass) \
|
---|
343 | NS_IMPL_QUERY_BODY_AMBIGUOUS(_interface, _implClass)
|
---|
344 | #define NS_INTERFACE_MAP_END_INHERITING(_baseClass) \
|
---|
345 | NS_IMPL_QUERY_TAIL_INHERITING(_baseClass)
|
---|
346 | #define NS_INTERFACE_MAP_END_AGGREGATED(_aggregator) \
|
---|
347 | NS_IMPL_QUERY_TAIL_USING_AGGREGATOR(_aggregator)
|
---|
348 |
|
---|
349 | #define NS_IMPL_QUERY_INTERFACE0(_class) \
|
---|
350 | NS_INTERFACE_MAP_BEGIN(_class) \
|
---|
351 | NS_INTERFACE_MAP_ENTRY(nsISupports) \
|
---|
352 | NS_INTERFACE_MAP_END
|
---|
353 |
|
---|
354 | #define NS_IMPL_QUERY_INTERFACE1(_class, _i1) \
|
---|
355 | NS_INTERFACE_MAP_BEGIN(_class) \
|
---|
356 | NS_INTERFACE_MAP_ENTRY(_i1) \
|
---|
357 | NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1) \
|
---|
358 | NS_INTERFACE_MAP_END
|
---|
359 |
|
---|
360 | #define NS_IMPL_QUERY_INTERFACE2(_class, _i1, _i2) \
|
---|
361 | NS_INTERFACE_MAP_BEGIN(_class) \
|
---|
362 | NS_INTERFACE_MAP_ENTRY(_i1) \
|
---|
363 | NS_INTERFACE_MAP_ENTRY(_i2) \
|
---|
364 | NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1) \
|
---|
365 | NS_INTERFACE_MAP_END
|
---|
366 |
|
---|
367 | #define NS_IMPL_QUERY_INTERFACE3(_class, _i1, _i2, _i3) \
|
---|
368 | NS_INTERFACE_MAP_BEGIN(_class) \
|
---|
369 | NS_INTERFACE_MAP_ENTRY(_i1) \
|
---|
370 | NS_INTERFACE_MAP_ENTRY(_i2) \
|
---|
371 | NS_INTERFACE_MAP_ENTRY(_i3) \
|
---|
372 | NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1) \
|
---|
373 | NS_INTERFACE_MAP_END
|
---|
374 |
|
---|
375 | #define NS_IMPL_QUERY_INTERFACE4(_class, _i1, _i2, _i3, _i4) \
|
---|
376 | NS_INTERFACE_MAP_BEGIN(_class) \
|
---|
377 | NS_INTERFACE_MAP_ENTRY(_i1) \
|
---|
378 | NS_INTERFACE_MAP_ENTRY(_i2) \
|
---|
379 | NS_INTERFACE_MAP_ENTRY(_i3) \
|
---|
380 | NS_INTERFACE_MAP_ENTRY(_i4) \
|
---|
381 | NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1) \
|
---|
382 | NS_INTERFACE_MAP_END
|
---|
383 |
|
---|
384 | #define NS_IMPL_QUERY_INTERFACE5(_class, _i1, _i2, _i3, _i4, _i5) \
|
---|
385 | NS_INTERFACE_MAP_BEGIN(_class) \
|
---|
386 | NS_INTERFACE_MAP_ENTRY(_i1) \
|
---|
387 | NS_INTERFACE_MAP_ENTRY(_i2) \
|
---|
388 | NS_INTERFACE_MAP_ENTRY(_i3) \
|
---|
389 | NS_INTERFACE_MAP_ENTRY(_i4) \
|
---|
390 | NS_INTERFACE_MAP_ENTRY(_i5) \
|
---|
391 | NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1) \
|
---|
392 | NS_INTERFACE_MAP_END
|
---|
393 |
|
---|
394 | #define NS_IMPL_QUERY_INTERFACE6(_class, _i1, _i2, _i3, _i4, _i5, _i6) \
|
---|
395 | NS_INTERFACE_MAP_BEGIN(_class) \
|
---|
396 | NS_INTERFACE_MAP_ENTRY(_i1) \
|
---|
397 | NS_INTERFACE_MAP_ENTRY(_i2) \
|
---|
398 | NS_INTERFACE_MAP_ENTRY(_i3) \
|
---|
399 | NS_INTERFACE_MAP_ENTRY(_i4) \
|
---|
400 | NS_INTERFACE_MAP_ENTRY(_i5) \
|
---|
401 | NS_INTERFACE_MAP_ENTRY(_i6) \
|
---|
402 | NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1) \
|
---|
403 | NS_INTERFACE_MAP_END
|
---|
404 |
|
---|
405 | #define NS_IMPL_QUERY_INTERFACE7(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7) \
|
---|
406 | NS_INTERFACE_MAP_BEGIN(_class) \
|
---|
407 | NS_INTERFACE_MAP_ENTRY(_i1) \
|
---|
408 | NS_INTERFACE_MAP_ENTRY(_i2) \
|
---|
409 | NS_INTERFACE_MAP_ENTRY(_i3) \
|
---|
410 | NS_INTERFACE_MAP_ENTRY(_i4) \
|
---|
411 | NS_INTERFACE_MAP_ENTRY(_i5) \
|
---|
412 | NS_INTERFACE_MAP_ENTRY(_i6) \
|
---|
413 | NS_INTERFACE_MAP_ENTRY(_i7) \
|
---|
414 | NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1) \
|
---|
415 | NS_INTERFACE_MAP_END
|
---|
416 |
|
---|
417 | #define NS_IMPL_QUERY_INTERFACE8(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
|
---|
418 | _i7, _i8) \
|
---|
419 | NS_INTERFACE_MAP_BEGIN(_class) \
|
---|
420 | NS_INTERFACE_MAP_ENTRY(_i1) \
|
---|
421 | NS_INTERFACE_MAP_ENTRY(_i2) \
|
---|
422 | NS_INTERFACE_MAP_ENTRY(_i3) \
|
---|
423 | NS_INTERFACE_MAP_ENTRY(_i4) \
|
---|
424 | NS_INTERFACE_MAP_ENTRY(_i5) \
|
---|
425 | NS_INTERFACE_MAP_ENTRY(_i6) \
|
---|
426 | NS_INTERFACE_MAP_ENTRY(_i7) \
|
---|
427 | NS_INTERFACE_MAP_ENTRY(_i8) \
|
---|
428 | NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1) \
|
---|
429 | NS_INTERFACE_MAP_END
|
---|
430 |
|
---|
431 | #define NS_IMPL_QUERY_INTERFACE9(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
|
---|
432 | _i7, _i8, _i9) \
|
---|
433 | NS_INTERFACE_MAP_BEGIN(_class) \
|
---|
434 | NS_INTERFACE_MAP_ENTRY(_i1) \
|
---|
435 | NS_INTERFACE_MAP_ENTRY(_i2) \
|
---|
436 | NS_INTERFACE_MAP_ENTRY(_i3) \
|
---|
437 | NS_INTERFACE_MAP_ENTRY(_i4) \
|
---|
438 | NS_INTERFACE_MAP_ENTRY(_i5) \
|
---|
439 | NS_INTERFACE_MAP_ENTRY(_i6) \
|
---|
440 | NS_INTERFACE_MAP_ENTRY(_i7) \
|
---|
441 | NS_INTERFACE_MAP_ENTRY(_i8) \
|
---|
442 | NS_INTERFACE_MAP_ENTRY(_i9) \
|
---|
443 | NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1) \
|
---|
444 | NS_INTERFACE_MAP_END
|
---|
445 |
|
---|
446 | #define NS_IMPL_QUERY_INTERFACE10(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
|
---|
447 | _i7, _i8, _i9, _i10) \
|
---|
448 | NS_INTERFACE_MAP_BEGIN(_class) \
|
---|
449 | NS_INTERFACE_MAP_ENTRY(_i1) \
|
---|
450 | NS_INTERFACE_MAP_ENTRY(_i2) \
|
---|
451 | NS_INTERFACE_MAP_ENTRY(_i3) \
|
---|
452 | NS_INTERFACE_MAP_ENTRY(_i4) \
|
---|
453 | NS_INTERFACE_MAP_ENTRY(_i5) \
|
---|
454 | NS_INTERFACE_MAP_ENTRY(_i6) \
|
---|
455 | NS_INTERFACE_MAP_ENTRY(_i7) \
|
---|
456 | NS_INTERFACE_MAP_ENTRY(_i8) \
|
---|
457 | NS_INTERFACE_MAP_ENTRY(_i9) \
|
---|
458 | NS_INTERFACE_MAP_ENTRY(_i10) \
|
---|
459 | NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1) \
|
---|
460 | NS_INTERFACE_MAP_END
|
---|
461 |
|
---|
462 | #define NS_IMPL_QUERY_INTERFACE11(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
|
---|
463 | _i7, _i8, _i9, _i10, _i11) \
|
---|
464 | NS_INTERFACE_MAP_BEGIN(_class) \
|
---|
465 | NS_INTERFACE_MAP_ENTRY(_i1) \
|
---|
466 | NS_INTERFACE_MAP_ENTRY(_i2) \
|
---|
467 | NS_INTERFACE_MAP_ENTRY(_i3) \
|
---|
468 | NS_INTERFACE_MAP_ENTRY(_i4) \
|
---|
469 | NS_INTERFACE_MAP_ENTRY(_i5) \
|
---|
470 | NS_INTERFACE_MAP_ENTRY(_i6) \
|
---|
471 | NS_INTERFACE_MAP_ENTRY(_i7) \
|
---|
472 | NS_INTERFACE_MAP_ENTRY(_i8) \
|
---|
473 | NS_INTERFACE_MAP_ENTRY(_i9) \
|
---|
474 | NS_INTERFACE_MAP_ENTRY(_i10) \
|
---|
475 | NS_INTERFACE_MAP_ENTRY(_i11) \
|
---|
476 | NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1) \
|
---|
477 | NS_INTERFACE_MAP_END
|
---|
478 |
|
---|
479 |
|
---|
480 | #define NS_IMPL_THREADSAFE_QUERY_INTERFACE0 NS_IMPL_QUERY_INTERFACE0
|
---|
481 | #define NS_IMPL_THREADSAFE_QUERY_INTERFACE1 NS_IMPL_QUERY_INTERFACE1
|
---|
482 | #define NS_IMPL_THREADSAFE_QUERY_INTERFACE2 NS_IMPL_QUERY_INTERFACE2
|
---|
483 | #define NS_IMPL_THREADSAFE_QUERY_INTERFACE3 NS_IMPL_QUERY_INTERFACE3
|
---|
484 | #define NS_IMPL_THREADSAFE_QUERY_INTERFACE4 NS_IMPL_QUERY_INTERFACE4
|
---|
485 | #define NS_IMPL_THREADSAFE_QUERY_INTERFACE5 NS_IMPL_QUERY_INTERFACE5
|
---|
486 | #define NS_IMPL_THREADSAFE_QUERY_INTERFACE6 NS_IMPL_QUERY_INTERFACE6
|
---|
487 | #define NS_IMPL_THREADSAFE_QUERY_INTERFACE7 NS_IMPL_QUERY_INTERFACE7
|
---|
488 | #define NS_IMPL_THREADSAFE_QUERY_INTERFACE8 NS_IMPL_QUERY_INTERFACE8
|
---|
489 | #define NS_IMPL_THREADSAFE_QUERY_INTERFACE9 NS_IMPL_QUERY_INTERFACE9
|
---|
490 | #define NS_IMPL_THREADSAFE_QUERY_INTERFACE10 NS_IMPL_QUERY_INTERFACE10
|
---|
491 | #define NS_IMPL_THREADSAFE_QUERY_INTERFACE11 NS_IMPL_QUERY_INTERFACE11
|
---|
492 |
|
---|
493 | /**
|
---|
494 | * Declare that you're going to inherit from something that already
|
---|
495 | * implements nsISupports, but also implements an additional interface, thus
|
---|
496 | * causing an ambiguity. In this case you don't need another mRefCnt, you
|
---|
497 | * just need to forward the definitions to the appropriate superclass. E.g.
|
---|
498 | *
|
---|
499 | * class Bar : public Foo, public nsIBar { // both provide nsISupports
|
---|
500 | * public:
|
---|
501 | * NS_DECL_ISUPPORTS_INHERITED
|
---|
502 | * ...other nsIBar and Bar methods...
|
---|
503 | * };
|
---|
504 | */
|
---|
505 | #define NS_DECL_ISUPPORTS_INHERITED \
|
---|
506 | public: \
|
---|
507 | NS_IMETHOD QueryInterface(REFNSIID aIID, \
|
---|
508 | void** aInstancePtr) NS_OVERRIDE; \
|
---|
509 | NS_IMETHOD_(nsrefcnt) AddRef(void) NS_OVERRIDE; \
|
---|
510 | NS_IMETHOD_(nsrefcnt) Release(void) NS_OVERRIDE; \
|
---|
511 |
|
---|
512 | /**
|
---|
513 | * These macros can be used in conjunction with NS_DECL_ISUPPORTS_INHERITED
|
---|
514 | * to implement the nsISupports methods, forwarding the invocations to a
|
---|
515 | * superclass that already implements nsISupports.
|
---|
516 | *
|
---|
517 | * Note that I didn't make these inlined because they're virtual methods.
|
---|
518 | */
|
---|
519 |
|
---|
520 | #define NS_IMPL_ADDREF_INHERITED(Class, Super) \
|
---|
521 | NS_IMETHODIMP_(nsrefcnt) Class::AddRef(void) \
|
---|
522 | { \
|
---|
523 | return Super::AddRef(); \
|
---|
524 | } \
|
---|
525 |
|
---|
526 | #define NS_IMPL_RELEASE_INHERITED(Class, Super) \
|
---|
527 | NS_IMETHODIMP_(nsrefcnt) Class::Release(void) \
|
---|
528 | { \
|
---|
529 | return Super::Release(); \
|
---|
530 | } \
|
---|
531 |
|
---|
532 | #define NS_IMPL_QUERY_INTERFACE_INHERITED0(Class, Super) \
|
---|
533 | NS_IMPL_QUERY_HEAD(Class) \
|
---|
534 | NS_IMPL_QUERY_TAIL_INHERITING(Super) \
|
---|
535 |
|
---|
536 | #define NS_IMPL_QUERY_INTERFACE_INHERITED1(Class, Super, i1) \
|
---|
537 | NS_IMPL_QUERY_HEAD(Class) \
|
---|
538 | NS_IMPL_QUERY_BODY(i1) \
|
---|
539 | NS_IMPL_QUERY_TAIL_INHERITING(Super) \
|
---|
540 |
|
---|
541 | #define NS_IMPL_QUERY_INTERFACE_INHERITED2(Class, Super, i1, i2) \
|
---|
542 | NS_IMPL_QUERY_HEAD(Class) \
|
---|
543 | NS_IMPL_QUERY_BODY(i1) \
|
---|
544 | NS_IMPL_QUERY_BODY(i2) \
|
---|
545 | NS_IMPL_QUERY_TAIL_INHERITING(Super) \
|
---|
546 |
|
---|
547 | #define NS_IMPL_QUERY_INTERFACE_INHERITED3(Class, Super, i1, i2, i3) \
|
---|
548 | NS_IMPL_QUERY_HEAD(Class) \
|
---|
549 | NS_IMPL_QUERY_BODY(i1) \
|
---|
550 | NS_IMPL_QUERY_BODY(i2) \
|
---|
551 | NS_IMPL_QUERY_BODY(i3) \
|
---|
552 | NS_IMPL_QUERY_TAIL_INHERITING(Super) \
|
---|
553 |
|
---|
554 | #define NS_IMPL_QUERY_INTERFACE_INHERITED4(Class, Super, i1, i2, i3, i4) \
|
---|
555 | NS_IMPL_QUERY_HEAD(Class) \
|
---|
556 | NS_IMPL_QUERY_BODY(i1) \
|
---|
557 | NS_IMPL_QUERY_BODY(i2) \
|
---|
558 | NS_IMPL_QUERY_BODY(i3) \
|
---|
559 | NS_IMPL_QUERY_BODY(i4) \
|
---|
560 | NS_IMPL_QUERY_TAIL_INHERITING(Super) \
|
---|
561 |
|
---|
562 | #define NS_IMPL_QUERY_INTERFACE_INHERITED5(Class,Super,i1,i2,i3,i4,i5) \
|
---|
563 | NS_IMPL_QUERY_HEAD(Class) \
|
---|
564 | NS_IMPL_QUERY_BODY(i1) \
|
---|
565 | NS_IMPL_QUERY_BODY(i2) \
|
---|
566 | NS_IMPL_QUERY_BODY(i3) \
|
---|
567 | NS_IMPL_QUERY_BODY(i4) \
|
---|
568 | NS_IMPL_QUERY_BODY(i5) \
|
---|
569 | NS_IMPL_QUERY_TAIL_INHERITING(Super) \
|
---|
570 |
|
---|
571 | #define NS_IMPL_QUERY_INTERFACE_INHERITED6(Class,Super,i1,i2,i3,i4,i5,i6) \
|
---|
572 | NS_IMPL_QUERY_HEAD(Class) \
|
---|
573 | NS_IMPL_QUERY_BODY(i1) \
|
---|
574 | NS_IMPL_QUERY_BODY(i2) \
|
---|
575 | NS_IMPL_QUERY_BODY(i3) \
|
---|
576 | NS_IMPL_QUERY_BODY(i4) \
|
---|
577 | NS_IMPL_QUERY_BODY(i5) \
|
---|
578 | NS_IMPL_QUERY_BODY(i6) \
|
---|
579 | NS_IMPL_QUERY_TAIL_INHERITING(Super) \
|
---|
580 |
|
---|
581 | /**
|
---|
582 | * Convenience macros for implementing all nsISupports methods for
|
---|
583 | * a simple class.
|
---|
584 | * @param _class The name of the class implementing the method
|
---|
585 | * @param _classiiddef The name of the #define symbol that defines the IID
|
---|
586 | * for the class (e.g. NS_ISUPPORTS_IID)
|
---|
587 | */
|
---|
588 |
|
---|
589 | #define NS_IMPL_ISUPPORTS0(_class) \
|
---|
590 | NS_IMPL_ADDREF(_class) \
|
---|
591 | NS_IMPL_RELEASE(_class) \
|
---|
592 | NS_IMPL_QUERY_INTERFACE0(_class)
|
---|
593 |
|
---|
594 | #define NS_IMPL_ISUPPORTS1(_class, _interface) \
|
---|
595 | NS_IMPL_ADDREF(_class) \
|
---|
596 | NS_IMPL_RELEASE(_class) \
|
---|
597 | NS_IMPL_QUERY_INTERFACE1(_class, _interface)
|
---|
598 |
|
---|
599 | #define NS_IMPL_ISUPPORTS2(_class, _i1, _i2) \
|
---|
600 | NS_IMPL_ADDREF(_class) \
|
---|
601 | NS_IMPL_RELEASE(_class) \
|
---|
602 | NS_IMPL_QUERY_INTERFACE2(_class, _i1, _i2)
|
---|
603 |
|
---|
604 | #define NS_IMPL_ISUPPORTS3(_class, _i1, _i2, _i3) \
|
---|
605 | NS_IMPL_ADDREF(_class) \
|
---|
606 | NS_IMPL_RELEASE(_class) \
|
---|
607 | NS_IMPL_QUERY_INTERFACE3(_class, _i1, _i2, _i3)
|
---|
608 |
|
---|
609 | #define NS_IMPL_ISUPPORTS4(_class, _i1, _i2, _i3, _i4) \
|
---|
610 | NS_IMPL_ADDREF(_class) \
|
---|
611 | NS_IMPL_RELEASE(_class) \
|
---|
612 | NS_IMPL_QUERY_INTERFACE4(_class, _i1, _i2, _i3, _i4)
|
---|
613 |
|
---|
614 | #define NS_IMPL_ISUPPORTS5(_class, _i1, _i2, _i3, _i4, _i5) \
|
---|
615 | NS_IMPL_ADDREF(_class) \
|
---|
616 | NS_IMPL_RELEASE(_class) \
|
---|
617 | NS_IMPL_QUERY_INTERFACE5(_class, _i1, _i2, _i3, _i4, _i5)
|
---|
618 |
|
---|
619 | #define NS_IMPL_ISUPPORTS6(_class, _i1, _i2, _i3, _i4, _i5, _i6) \
|
---|
620 | NS_IMPL_ADDREF(_class) \
|
---|
621 | NS_IMPL_RELEASE(_class) \
|
---|
622 | NS_IMPL_QUERY_INTERFACE6(_class, _i1, _i2, _i3, _i4, _i5, _i6)
|
---|
623 |
|
---|
624 | #define NS_IMPL_ISUPPORTS7(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7) \
|
---|
625 | NS_IMPL_ADDREF(_class) \
|
---|
626 | NS_IMPL_RELEASE(_class) \
|
---|
627 | NS_IMPL_QUERY_INTERFACE7(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7)
|
---|
628 |
|
---|
629 | #define NS_IMPL_ISUPPORTS8(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7, _i8) \
|
---|
630 | NS_IMPL_ADDREF(_class) \
|
---|
631 | NS_IMPL_RELEASE(_class) \
|
---|
632 | NS_IMPL_QUERY_INTERFACE8(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7, _i8)
|
---|
633 |
|
---|
634 | #define NS_IMPL_ISUPPORTS9(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7, _i8, \
|
---|
635 | _i9) \
|
---|
636 | NS_IMPL_ADDREF(_class) \
|
---|
637 | NS_IMPL_RELEASE(_class) \
|
---|
638 | NS_IMPL_QUERY_INTERFACE9(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7, _i8, _i9)
|
---|
639 |
|
---|
640 | #define NS_IMPL_ISUPPORTS10(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7, _i8, \
|
---|
641 | _i9, _i10) \
|
---|
642 | NS_IMPL_ADDREF(_class) \
|
---|
643 | NS_IMPL_RELEASE(_class) \
|
---|
644 | NS_IMPL_QUERY_INTERFACE10(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7, _i8, \
|
---|
645 | _i9, _i10)
|
---|
646 |
|
---|
647 | #define NS_IMPL_ISUPPORTS11(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7, _i8, \
|
---|
648 | _i9, _i10, _i11) \
|
---|
649 | NS_IMPL_ADDREF(_class) \
|
---|
650 | NS_IMPL_RELEASE(_class) \
|
---|
651 | NS_IMPL_QUERY_INTERFACE11(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7, _i8, \
|
---|
652 | _i9, _i10, _i11)
|
---|
653 |
|
---|
654 | #define NS_IMPL_ISUPPORTS_INHERITED0(Class, Super) \
|
---|
655 | NS_IMPL_QUERY_INTERFACE_INHERITED0(Class, Super) \
|
---|
656 | NS_IMPL_ADDREF_INHERITED(Class, Super) \
|
---|
657 | NS_IMPL_RELEASE_INHERITED(Class, Super) \
|
---|
658 |
|
---|
659 | #define NS_IMPL_ISUPPORTS_INHERITED1(Class, Super, i1) \
|
---|
660 | NS_IMPL_QUERY_INTERFACE_INHERITED1(Class, Super, i1) \
|
---|
661 | NS_IMPL_ADDREF_INHERITED(Class, Super) \
|
---|
662 | NS_IMPL_RELEASE_INHERITED(Class, Super) \
|
---|
663 |
|
---|
664 | #define NS_IMPL_ISUPPORTS_INHERITED2(Class, Super, i1, i2) \
|
---|
665 | NS_IMPL_QUERY_INTERFACE_INHERITED2(Class, Super, i1, i2) \
|
---|
666 | NS_IMPL_ADDREF_INHERITED(Class, Super) \
|
---|
667 | NS_IMPL_RELEASE_INHERITED(Class, Super) \
|
---|
668 |
|
---|
669 | #define NS_IMPL_ISUPPORTS_INHERITED3(Class, Super, i1, i2, i3) \
|
---|
670 | NS_IMPL_QUERY_INTERFACE_INHERITED3(Class, Super, i1, i2, i3) \
|
---|
671 | NS_IMPL_ADDREF_INHERITED(Class, Super) \
|
---|
672 | NS_IMPL_RELEASE_INHERITED(Class, Super) \
|
---|
673 |
|
---|
674 | #define NS_IMPL_ISUPPORTS_INHERITED4(Class, Super, i1, i2, i3, i4) \
|
---|
675 | NS_IMPL_QUERY_INTERFACE_INHERITED4(Class, Super, i1, i2, i3, i4) \
|
---|
676 | NS_IMPL_ADDREF_INHERITED(Class, Super) \
|
---|
677 | NS_IMPL_RELEASE_INHERITED(Class, Super) \
|
---|
678 |
|
---|
679 | #define NS_IMPL_ISUPPORTS_INHERITED5(Class, Super, i1, i2, i3, i4, i5) \
|
---|
680 | NS_IMPL_QUERY_INTERFACE_INHERITED5(Class, Super, i1, i2, i3, i4, i5) \
|
---|
681 | NS_IMPL_ADDREF_INHERITED(Class, Super) \
|
---|
682 | NS_IMPL_RELEASE_INHERITED(Class, Super) \
|
---|
683 |
|
---|
684 | #define NS_IMPL_ISUPPORTS_INHERITED6(Class, Super, i1, i2, i3, i4, i5, i6) \
|
---|
685 | NS_IMPL_QUERY_INTERFACE_INHERITED6(Class, Super, i1, i2, i3, i4, i5, i6) \
|
---|
686 | NS_IMPL_ADDREF_INHERITED(Class, Super) \
|
---|
687 | NS_IMPL_RELEASE_INHERITED(Class, Super) \
|
---|
688 |
|
---|
689 | ///////////////////////////////////////////////////////////////////////////////
|
---|
690 | /**
|
---|
691 | *
|
---|
692 | * Threadsafe implementations of the ISupports convenience macros
|
---|
693 | *
|
---|
694 | */
|
---|
695 |
|
---|
696 | /**
|
---|
697 | * Use this macro to implement the AddRef method for a given <i>_class</i>
|
---|
698 | * @param _class The name of the class implementing the method
|
---|
699 | */
|
---|
700 |
|
---|
701 | #ifdef VBOX
|
---|
702 | #define NS_IMPL_THREADSAFE_ADDREF(_class) \
|
---|
703 | NS_IMETHODIMP_(nsrefcnt) _class::AddRef(void) \
|
---|
704 | { \
|
---|
705 | nsrefcnt count = mRefCnt.get(); \
|
---|
706 | PRUint32 state = mRefCnt.getState(); \
|
---|
707 | AssertReleaseMsg( state <= 1 \
|
---|
708 | && ( (state == 0 && count == 0) \
|
---|
709 | || (state == 1 && count < PR_UINT32_MAX/2)), \
|
---|
710 | ("AddRef: illegal refcnt=%u state=%d\n", count, state)); \
|
---|
711 | switch (state) \
|
---|
712 | { \
|
---|
713 | case 0: \
|
---|
714 | if (!ASMAtomicCmpXchgU32(mRefCnt.refState(), 1, 0)) \
|
---|
715 | AssertReleaseMsgFailed(("AddRef: racing for first increment\n")); \
|
---|
716 | count = ASMAtomicIncU32(mRefCnt.ref()); \
|
---|
717 | AssertReleaseMsg(count == 1, \
|
---|
718 | ("AddRef: unexpected refcnt=%u\n", count)); \
|
---|
719 | break; \
|
---|
720 | case 1: \
|
---|
721 | count = ASMAtomicIncU32(mRefCnt.ref()); \
|
---|
722 | AssertReleaseMsg(count <= PR_UINT32_MAX/2, \
|
---|
723 | ("AddRef: unexpected refcnt=%u\n", count)); \
|
---|
724 | break; \
|
---|
725 | case 2: \
|
---|
726 | AssertReleaseMsgFailed(("AddRef: freed object\n")); \
|
---|
727 | break; \
|
---|
728 | default: \
|
---|
729 | AssertReleaseMsgFailed(("AddRef: garbage object\n")); \
|
---|
730 | } \
|
---|
731 | NS_LOG_ADDREF(this, count, #_class, sizeof(*this)); \
|
---|
732 | return count; \
|
---|
733 | }
|
---|
734 | #else
|
---|
735 | #define NS_IMPL_THREADSAFE_ADDREF(_class) \
|
---|
736 | NS_IMETHODIMP_(nsrefcnt) _class::AddRef(void) \
|
---|
737 | { \
|
---|
738 | NS_PRECONDITION(PRInt32(mRefCnt) >= 0, "illegal refcnt"); \
|
---|
739 | nsrefcnt count; \
|
---|
740 | count = ASMAtomicIncU32((volatile uint32_t *)&mRefCnt); \
|
---|
741 | NS_LOG_ADDREF(this, count, #_class, sizeof(*this)); \
|
---|
742 | return count; \
|
---|
743 | }
|
---|
744 | #endif
|
---|
745 |
|
---|
746 | /**
|
---|
747 | * Use this macro to implement the Release method for a given <i>_class</i>
|
---|
748 | * @param _class The name of the class implementing the method
|
---|
749 | */
|
---|
750 |
|
---|
751 | #ifdef VBOX
|
---|
752 | #define NS_IMPL_THREADSAFE_RELEASE(_class) \
|
---|
753 | NS_IMETHODIMP_(nsrefcnt) _class::Release(void) \
|
---|
754 | { \
|
---|
755 | nsrefcnt count = mRefCnt.get(); \
|
---|
756 | PRUint32 state = mRefCnt.getState(); \
|
---|
757 | AssertReleaseMsg(state == 1 && count <= PR_UINT32_MAX/2, \
|
---|
758 | ("Release: illegal refcnt=%u state=%d\n", count, state)); \
|
---|
759 | switch (state) \
|
---|
760 | { \
|
---|
761 | case 0: \
|
---|
762 | AssertReleaseMsgFailed(("Release: new object\n")); \
|
---|
763 | break; \
|
---|
764 | case 1: \
|
---|
765 | count = ASMAtomicDecU32(mRefCnt.ref()); \
|
---|
766 | AssertReleaseMsg(count < PR_UINT32_MAX/2, \
|
---|
767 | ("Release: unexpected refcnt=%u\n", count)); \
|
---|
768 | if (count == 0) \
|
---|
769 | { \
|
---|
770 | if (!ASMAtomicCmpXchgU32(mRefCnt.refState(), 2, 1)) \
|
---|
771 | AssertReleaseMsgFailed(("Release: racing for state free\n")); \
|
---|
772 | /* Use better stabilization: reserve everything with top bit set. */ \
|
---|
773 | if (!ASMAtomicCmpXchgU32(mRefCnt.ref(), PR_UINT32_MAX/4*3, 0)) \
|
---|
774 | AssertReleaseMsgFailed(("Release: racing for refcnt stabilize\n")); \
|
---|
775 | NS_DELETEXPCOM(this); \
|
---|
776 | } \
|
---|
777 | break; \
|
---|
778 | case 2: \
|
---|
779 | AssertReleaseMsgFailed(("Release: freed object\n")); \
|
---|
780 | break; \
|
---|
781 | default: \
|
---|
782 | AssertReleaseMsgFailed(("Release: garbage object\n")); \
|
---|
783 | } \
|
---|
784 | NS_LOG_RELEASE(this, count, #_class); \
|
---|
785 | return count; \
|
---|
786 | }
|
---|
787 | #else
|
---|
788 | #define NS_IMPL_THREADSAFE_RELEASE(_class) \
|
---|
789 | NS_IMETHODIMP_(nsrefcnt) _class::Release(void) \
|
---|
790 | { \
|
---|
791 | nsrefcnt count; \
|
---|
792 | NS_PRECONDITION(0 != mRefCnt, "dup release"); \
|
---|
793 | count = ASMAtomicDecI32((volatile uint32_t *)&mRefCnt); \
|
---|
794 | NS_LOG_RELEASE(this, count, #_class); \
|
---|
795 | if (0 == count) { \
|
---|
796 | mRefCnt = 1; /* stabilize */ \
|
---|
797 | /* enable this to find non-threadsafe destructors: */ \
|
---|
798 | /* NS_ASSERT_OWNINGTHREAD(_class); */ \
|
---|
799 | NS_DELETEXPCOM(this); \
|
---|
800 | return 0; \
|
---|
801 | } \
|
---|
802 | return count; \
|
---|
803 | }
|
---|
804 | #endif
|
---|
805 |
|
---|
806 | #define NS_IMPL_THREADSAFE_ISUPPORTS0(_class) \
|
---|
807 | NS_IMPL_THREADSAFE_ADDREF(_class) \
|
---|
808 | NS_IMPL_THREADSAFE_RELEASE(_class) \
|
---|
809 | NS_IMPL_THREADSAFE_QUERY_INTERFACE0(_class)
|
---|
810 |
|
---|
811 | #define NS_IMPL_THREADSAFE_ISUPPORTS1(_class, _interface) \
|
---|
812 | NS_IMPL_THREADSAFE_ADDREF(_class) \
|
---|
813 | NS_IMPL_THREADSAFE_RELEASE(_class) \
|
---|
814 | NS_IMPL_THREADSAFE_QUERY_INTERFACE1(_class, _interface)
|
---|
815 |
|
---|
816 | #define NS_IMPL_THREADSAFE_ISUPPORTS2(_class, _i1, _i2) \
|
---|
817 | NS_IMPL_THREADSAFE_ADDREF(_class) \
|
---|
818 | NS_IMPL_THREADSAFE_RELEASE(_class) \
|
---|
819 | NS_IMPL_THREADSAFE_QUERY_INTERFACE2(_class, _i1, _i2)
|
---|
820 |
|
---|
821 | #define NS_IMPL_THREADSAFE_ISUPPORTS3(_class, _i1, _i2, _i3) \
|
---|
822 | NS_IMPL_THREADSAFE_ADDREF(_class) \
|
---|
823 | NS_IMPL_THREADSAFE_RELEASE(_class) \
|
---|
824 | NS_IMPL_THREADSAFE_QUERY_INTERFACE3(_class, _i1, _i2, _i3)
|
---|
825 |
|
---|
826 | #define NS_IMPL_THREADSAFE_ISUPPORTS4(_class, _i1, _i2, _i3, _i4) \
|
---|
827 | NS_IMPL_THREADSAFE_ADDREF(_class) \
|
---|
828 | NS_IMPL_THREADSAFE_RELEASE(_class) \
|
---|
829 | NS_IMPL_THREADSAFE_QUERY_INTERFACE4(_class, _i1, _i2, _i3, _i4)
|
---|
830 |
|
---|
831 | #define NS_IMPL_THREADSAFE_ISUPPORTS5(_class, _i1, _i2, _i3, _i4, _i5) \
|
---|
832 | NS_IMPL_THREADSAFE_ADDREF(_class) \
|
---|
833 | NS_IMPL_THREADSAFE_RELEASE(_class) \
|
---|
834 | NS_IMPL_THREADSAFE_QUERY_INTERFACE5(_class, _i1, _i2, _i3, _i4, _i5)
|
---|
835 |
|
---|
836 | #define NS_IMPL_THREADSAFE_ISUPPORTS6(_class, _i1, _i2, _i3, _i4, _i5, _i6) \
|
---|
837 | NS_IMPL_THREADSAFE_ADDREF(_class) \
|
---|
838 | NS_IMPL_THREADSAFE_RELEASE(_class) \
|
---|
839 | NS_IMPL_THREADSAFE_QUERY_INTERFACE6(_class, _i1, _i2, _i3, _i4, _i5, _i6)
|
---|
840 |
|
---|
841 | #define NS_IMPL_THREADSAFE_ISUPPORTS7(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
|
---|
842 | _i7) \
|
---|
843 | NS_IMPL_THREADSAFE_ADDREF(_class) \
|
---|
844 | NS_IMPL_THREADSAFE_RELEASE(_class) \
|
---|
845 | NS_IMPL_THREADSAFE_QUERY_INTERFACE7(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
|
---|
846 | _i7)
|
---|
847 |
|
---|
848 | #define NS_IMPL_THREADSAFE_ISUPPORTS8(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
|
---|
849 | _i7, _i8) \
|
---|
850 | NS_IMPL_THREADSAFE_ADDREF(_class) \
|
---|
851 | NS_IMPL_THREADSAFE_RELEASE(_class) \
|
---|
852 | NS_IMPL_THREADSAFE_QUERY_INTERFACE8(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
|
---|
853 | _i7, _i8)
|
---|
854 |
|
---|
855 | #define NS_IMPL_THREADSAFE_ISUPPORTS9(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
|
---|
856 | _i7, _i8, _i9) \
|
---|
857 | NS_IMPL_THREADSAFE_ADDREF(_class) \
|
---|
858 | NS_IMPL_THREADSAFE_RELEASE(_class) \
|
---|
859 | NS_IMPL_THREADSAFE_QUERY_INTERFACE9(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
|
---|
860 | _i7, _i8, _i9)
|
---|
861 |
|
---|
862 | #define NS_IMPL_THREADSAFE_ISUPPORTS10(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
|
---|
863 | _i7, _i8, _i9, _i10) \
|
---|
864 | NS_IMPL_THREADSAFE_ADDREF(_class) \
|
---|
865 | NS_IMPL_THREADSAFE_RELEASE(_class) \
|
---|
866 | NS_IMPL_THREADSAFE_QUERY_INTERFACE10(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
|
---|
867 | _i7, _i8, _i9, _i10)
|
---|
868 |
|
---|
869 | #define NS_IMPL_THREADSAFE_ISUPPORTS11(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
|
---|
870 | _i7, _i8, _i9, _i10, _i11) \
|
---|
871 | NS_IMPL_THREADSAFE_ADDREF(_class) \
|
---|
872 | NS_IMPL_THREADSAFE_RELEASE(_class) \
|
---|
873 | NS_IMPL_THREADSAFE_QUERY_INTERFACE11(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
|
---|
874 | _i7, _i8, _i9, _i10, _i11)
|
---|
875 |
|
---|
876 | ///////////////////////////////////////////////////////////////////////////////
|
---|
877 | // Macros for implementing nsIClassInfo-related stuff.
|
---|
878 | ///////////////////////////////////////////////////////////////////////////////
|
---|
879 |
|
---|
880 | // include here instead of at the top because it requires the nsISupport decl
|
---|
881 | #include "nsIClassInfo.h"
|
---|
882 |
|
---|
883 | #define NS_CLASSINFO_NAME(_class) _class##_classInfoGlobal
|
---|
884 | #define NS_CI_INTERFACE_GETTER_NAME(_class) _class##_GetInterfacesHelper
|
---|
885 |
|
---|
886 | #define NS_DECL_CI_INTERFACE_GETTER(_class) \
|
---|
887 | extern NS_IMETHODIMP NS_CI_INTERFACE_GETTER_NAME(_class)(PRUint32 *, \
|
---|
888 | nsIID ***);
|
---|
889 |
|
---|
890 | #define NS_DECL_CLASSINFO(_class) \
|
---|
891 | NS_DECL_CI_INTERFACE_GETTER(_class) \
|
---|
892 | nsIClassInfo *NS_CLASSINFO_NAME(_class);
|
---|
893 |
|
---|
894 | #define NS_IMPL_QUERY_CLASSINFO(_class) \
|
---|
895 | if ( aIID.Equals(NS_GET_IID(nsIClassInfo)) ) { \
|
---|
896 | extern nsIClassInfo *NS_CLASSINFO_NAME(_class); \
|
---|
897 | foundInterface = NS_STATIC_CAST(nsIClassInfo*, NS_CLASSINFO_NAME(_class));\
|
---|
898 | } else
|
---|
899 |
|
---|
900 | #define NS_CLASSINFO_HELPER_BEGIN(_class, _c) \
|
---|
901 | NS_IMETHODIMP \
|
---|
902 | NS_CI_INTERFACE_GETTER_NAME(_class)(PRUint32 *count, nsIID ***array) \
|
---|
903 | { \
|
---|
904 | *count = _c; \
|
---|
905 | *array = (nsIID **)nsMemory::Alloc(sizeof (nsIID *) * _c);
|
---|
906 |
|
---|
907 | #define NS_CLASSINFO_HELPER_ENTRY(_i, _interface) \
|
---|
908 | (*array)[_i] = (nsIID *)nsMemory::Clone(&NS_GET_IID(_interface), \
|
---|
909 | sizeof(nsIID));
|
---|
910 |
|
---|
911 | #define NS_CLASSINFO_HELPER_END \
|
---|
912 | return NS_OK; \
|
---|
913 | }
|
---|
914 |
|
---|
915 | #define NS_IMPL_CI_INTERFACE_GETTER1(_class, _interface) \
|
---|
916 | NS_CLASSINFO_HELPER_BEGIN(_class, 1) \
|
---|
917 | NS_CLASSINFO_HELPER_ENTRY(0, _interface) \
|
---|
918 | NS_CLASSINFO_HELPER_END
|
---|
919 |
|
---|
920 | #define NS_IMPL_QUERY_INTERFACE1_CI(_class, _i1) \
|
---|
921 | NS_INTERFACE_MAP_BEGIN(_class) \
|
---|
922 | NS_INTERFACE_MAP_ENTRY(_i1) \
|
---|
923 | NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1) \
|
---|
924 | NS_IMPL_QUERY_CLASSINFO(_class) \
|
---|
925 | NS_INTERFACE_MAP_END
|
---|
926 |
|
---|
927 | #define NS_IMPL_ISUPPORTS1_CI(_class, _interface) \
|
---|
928 | NS_IMPL_ADDREF(_class) \
|
---|
929 | NS_IMPL_RELEASE(_class) \
|
---|
930 | NS_IMPL_QUERY_INTERFACE1_CI(_class, _interface) \
|
---|
931 | NS_IMPL_CI_INTERFACE_GETTER1(_class, _interface)
|
---|
932 |
|
---|
933 | #define NS_IMPL_CI_INTERFACE_GETTER2(_class, _i1, _i2) \
|
---|
934 | NS_CLASSINFO_HELPER_BEGIN(_class, 2) \
|
---|
935 | NS_CLASSINFO_HELPER_ENTRY(0, _i1) \
|
---|
936 | NS_CLASSINFO_HELPER_ENTRY(1, _i2) \
|
---|
937 | NS_CLASSINFO_HELPER_END
|
---|
938 |
|
---|
939 | #define NS_IMPL_QUERY_INTERFACE2_CI(_class, _i1, _i2) \
|
---|
940 | NS_INTERFACE_MAP_BEGIN(_class) \
|
---|
941 | NS_INTERFACE_MAP_ENTRY(_i1) \
|
---|
942 | NS_INTERFACE_MAP_ENTRY(_i2) \
|
---|
943 | NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1) \
|
---|
944 | NS_IMPL_QUERY_CLASSINFO(_class) \
|
---|
945 | NS_INTERFACE_MAP_END
|
---|
946 |
|
---|
947 | #define NS_IMPL_ISUPPORTS2_CI(_class, _i1, _i2) \
|
---|
948 | NS_IMPL_ADDREF(_class) \
|
---|
949 | NS_IMPL_RELEASE(_class) \
|
---|
950 | NS_IMPL_QUERY_INTERFACE2_CI(_class, _i1, _i2) \
|
---|
951 | NS_IMPL_CI_INTERFACE_GETTER2(_class, _i1, _i2)
|
---|
952 |
|
---|
953 | #define NS_IMPL_CI_INTERFACE_GETTER3(_class, _i1, _i2, _i3) \
|
---|
954 | NS_CLASSINFO_HELPER_BEGIN(_class, 3) \
|
---|
955 | NS_CLASSINFO_HELPER_ENTRY(0, _i1) \
|
---|
956 | NS_CLASSINFO_HELPER_ENTRY(1, _i2) \
|
---|
957 | NS_CLASSINFO_HELPER_ENTRY(2, _i3) \
|
---|
958 | NS_CLASSINFO_HELPER_END
|
---|
959 |
|
---|
960 | #define NS_IMPL_QUERY_INTERFACE3_CI(_class, _i1, _i2, _i3) \
|
---|
961 | NS_INTERFACE_MAP_BEGIN(_class) \
|
---|
962 | NS_INTERFACE_MAP_ENTRY(_i1) \
|
---|
963 | NS_INTERFACE_MAP_ENTRY(_i2) \
|
---|
964 | NS_INTERFACE_MAP_ENTRY(_i3) \
|
---|
965 | NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1) \
|
---|
966 | NS_IMPL_QUERY_CLASSINFO(_class) \
|
---|
967 | NS_INTERFACE_MAP_END
|
---|
968 |
|
---|
969 | #define NS_IMPL_ISUPPORTS3_CI(_class, _i1, _i2, _i3) \
|
---|
970 | NS_IMPL_ADDREF(_class) \
|
---|
971 | NS_IMPL_RELEASE(_class) \
|
---|
972 | NS_IMPL_QUERY_INTERFACE3_CI(_class, _i1, _i2, _i3) \
|
---|
973 | NS_IMPL_CI_INTERFACE_GETTER3(_class, _i1, _i2, _i3)
|
---|
974 |
|
---|
975 | #define NS_IMPL_CI_INTERFACE_GETTER4(_class, _i1, _i2, _i3, _i4) \
|
---|
976 | NS_CLASSINFO_HELPER_BEGIN(_class, 4) \
|
---|
977 | NS_CLASSINFO_HELPER_ENTRY(0, _i1) \
|
---|
978 | NS_CLASSINFO_HELPER_ENTRY(1, _i2) \
|
---|
979 | NS_CLASSINFO_HELPER_ENTRY(2, _i3) \
|
---|
980 | NS_CLASSINFO_HELPER_ENTRY(3, _i4) \
|
---|
981 | NS_CLASSINFO_HELPER_END
|
---|
982 |
|
---|
983 | #define NS_IMPL_QUERY_INTERFACE4_CI(_class, _i1, _i2, _i3, _i4) \
|
---|
984 | NS_INTERFACE_MAP_BEGIN(_class) \
|
---|
985 | NS_INTERFACE_MAP_ENTRY(_i1) \
|
---|
986 | NS_INTERFACE_MAP_ENTRY(_i2) \
|
---|
987 | NS_INTERFACE_MAP_ENTRY(_i3) \
|
---|
988 | NS_INTERFACE_MAP_ENTRY(_i4) \
|
---|
989 | NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1) \
|
---|
990 | NS_IMPL_QUERY_CLASSINFO(_class) \
|
---|
991 | NS_INTERFACE_MAP_END
|
---|
992 |
|
---|
993 | #define NS_IMPL_ISUPPORTS4_CI(_class, _i1, _i2, _i3, _i4) \
|
---|
994 | NS_IMPL_ADDREF(_class) \
|
---|
995 | NS_IMPL_RELEASE(_class) \
|
---|
996 | NS_IMPL_QUERY_INTERFACE4_CI(_class, _i1, _i2, _i3, _i4) \
|
---|
997 | NS_IMPL_CI_INTERFACE_GETTER4(_class, _i1, _i2, _i3, _i4)
|
---|
998 |
|
---|
999 | #define NS_IMPL_CI_INTERFACE_GETTER5(_class, _i1, _i2, _i3, _i4, _i5) \
|
---|
1000 | NS_CLASSINFO_HELPER_BEGIN(_class, 5) \
|
---|
1001 | NS_CLASSINFO_HELPER_ENTRY(0, _i1) \
|
---|
1002 | NS_CLASSINFO_HELPER_ENTRY(1, _i2) \
|
---|
1003 | NS_CLASSINFO_HELPER_ENTRY(2, _i3) \
|
---|
1004 | NS_CLASSINFO_HELPER_ENTRY(3, _i4) \
|
---|
1005 | NS_CLASSINFO_HELPER_ENTRY(4, _i5) \
|
---|
1006 | NS_CLASSINFO_HELPER_END
|
---|
1007 |
|
---|
1008 | #define NS_IMPL_QUERY_INTERFACE5_CI(_class, _i1, _i2, _i3, _i4, _i5) \
|
---|
1009 | NS_INTERFACE_MAP_BEGIN(_class) \
|
---|
1010 | NS_INTERFACE_MAP_ENTRY(_i1) \
|
---|
1011 | NS_INTERFACE_MAP_ENTRY(_i2) \
|
---|
1012 | NS_INTERFACE_MAP_ENTRY(_i3) \
|
---|
1013 | NS_INTERFACE_MAP_ENTRY(_i4) \
|
---|
1014 | NS_INTERFACE_MAP_ENTRY(_i5) \
|
---|
1015 | NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1) \
|
---|
1016 | NS_IMPL_QUERY_CLASSINFO(_class) \
|
---|
1017 | NS_INTERFACE_MAP_END
|
---|
1018 |
|
---|
1019 | #define NS_IMPL_ISUPPORTS5_CI(_class, _i1, _i2, _i3, _i4, _i5) \
|
---|
1020 | NS_IMPL_ADDREF(_class) \
|
---|
1021 | NS_IMPL_RELEASE(_class) \
|
---|
1022 | NS_IMPL_QUERY_INTERFACE5_CI(_class, _i1, _i2, _i3, _i4, _i5) \
|
---|
1023 | NS_IMPL_CI_INTERFACE_GETTER5(_class, _i1, _i2, _i3, _i4, _i5)
|
---|
1024 |
|
---|
1025 | #define NS_IMPL_CI_INTERFACE_GETTER6(_class, _i1, _i2, _i3, _i4, _i5, _i6) \
|
---|
1026 | NS_CLASSINFO_HELPER_BEGIN(_class, 6) \
|
---|
1027 | NS_CLASSINFO_HELPER_ENTRY(0, _i1) \
|
---|
1028 | NS_CLASSINFO_HELPER_ENTRY(1, _i2) \
|
---|
1029 | NS_CLASSINFO_HELPER_ENTRY(2, _i3) \
|
---|
1030 | NS_CLASSINFO_HELPER_ENTRY(3, _i4) \
|
---|
1031 | NS_CLASSINFO_HELPER_ENTRY(4, _i5) \
|
---|
1032 | NS_CLASSINFO_HELPER_ENTRY(5, _i6) \
|
---|
1033 | NS_CLASSINFO_HELPER_END
|
---|
1034 |
|
---|
1035 | #define NS_IMPL_QUERY_INTERFACE6_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6) \
|
---|
1036 | NS_INTERFACE_MAP_BEGIN(_class) \
|
---|
1037 | NS_INTERFACE_MAP_ENTRY(_i1) \
|
---|
1038 | NS_INTERFACE_MAP_ENTRY(_i2) \
|
---|
1039 | NS_INTERFACE_MAP_ENTRY(_i3) \
|
---|
1040 | NS_INTERFACE_MAP_ENTRY(_i4) \
|
---|
1041 | NS_INTERFACE_MAP_ENTRY(_i5) \
|
---|
1042 | NS_INTERFACE_MAP_ENTRY(_i6) \
|
---|
1043 | NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1) \
|
---|
1044 | NS_IMPL_QUERY_CLASSINFO(_class) \
|
---|
1045 | NS_INTERFACE_MAP_END
|
---|
1046 |
|
---|
1047 | #define NS_IMPL_ISUPPORTS6_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6) \
|
---|
1048 | NS_IMPL_ADDREF(_class) \
|
---|
1049 | NS_IMPL_RELEASE(_class) \
|
---|
1050 | NS_IMPL_QUERY_INTERFACE6_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6) \
|
---|
1051 | NS_IMPL_CI_INTERFACE_GETTER6(_class, _i1, _i2, _i3, _i4, _i5, _i6)
|
---|
1052 |
|
---|
1053 | #define NS_IMPL_CI_INTERFACE_GETTER7(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
|
---|
1054 | _i7) \
|
---|
1055 | NS_CLASSINFO_HELPER_BEGIN(_class, 7) \
|
---|
1056 | NS_CLASSINFO_HELPER_ENTRY(0, _i1) \
|
---|
1057 | NS_CLASSINFO_HELPER_ENTRY(1, _i2) \
|
---|
1058 | NS_CLASSINFO_HELPER_ENTRY(2, _i3) \
|
---|
1059 | NS_CLASSINFO_HELPER_ENTRY(3, _i4) \
|
---|
1060 | NS_CLASSINFO_HELPER_ENTRY(4, _i5) \
|
---|
1061 | NS_CLASSINFO_HELPER_ENTRY(5, _i6) \
|
---|
1062 | NS_CLASSINFO_HELPER_ENTRY(6, _i7) \
|
---|
1063 | NS_CLASSINFO_HELPER_END
|
---|
1064 |
|
---|
1065 | #define NS_IMPL_QUERY_INTERFACE7_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
|
---|
1066 | _i7) \
|
---|
1067 | NS_INTERFACE_MAP_BEGIN(_class) \
|
---|
1068 | NS_INTERFACE_MAP_ENTRY(_i1) \
|
---|
1069 | NS_INTERFACE_MAP_ENTRY(_i2) \
|
---|
1070 | NS_INTERFACE_MAP_ENTRY(_i3) \
|
---|
1071 | NS_INTERFACE_MAP_ENTRY(_i4) \
|
---|
1072 | NS_INTERFACE_MAP_ENTRY(_i5) \
|
---|
1073 | NS_INTERFACE_MAP_ENTRY(_i6) \
|
---|
1074 | NS_INTERFACE_MAP_ENTRY(_i7) \
|
---|
1075 | NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1) \
|
---|
1076 | NS_IMPL_QUERY_CLASSINFO(_class) \
|
---|
1077 | NS_INTERFACE_MAP_END
|
---|
1078 |
|
---|
1079 | #define NS_IMPL_ISUPPORTS7_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7) \
|
---|
1080 | NS_IMPL_ADDREF(_class) \
|
---|
1081 | NS_IMPL_RELEASE(_class) \
|
---|
1082 | NS_IMPL_QUERY_INTERFACE7_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7) \
|
---|
1083 | NS_IMPL_CI_INTERFACE_GETTER7(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7)
|
---|
1084 |
|
---|
1085 | #define NS_IMPL_CI_INTERFACE_GETTER8(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
|
---|
1086 | _i7, _i8) \
|
---|
1087 | NS_CLASSINFO_HELPER_BEGIN(_class, 8) \
|
---|
1088 | NS_CLASSINFO_HELPER_ENTRY(0, _i1) \
|
---|
1089 | NS_CLASSINFO_HELPER_ENTRY(1, _i2) \
|
---|
1090 | NS_CLASSINFO_HELPER_ENTRY(2, _i3) \
|
---|
1091 | NS_CLASSINFO_HELPER_ENTRY(3, _i4) \
|
---|
1092 | NS_CLASSINFO_HELPER_ENTRY(4, _i5) \
|
---|
1093 | NS_CLASSINFO_HELPER_ENTRY(5, _i6) \
|
---|
1094 | NS_CLASSINFO_HELPER_ENTRY(6, _i7) \
|
---|
1095 | NS_CLASSINFO_HELPER_ENTRY(7, _i8) \
|
---|
1096 | NS_CLASSINFO_HELPER_END
|
---|
1097 |
|
---|
1098 | #define NS_IMPL_QUERY_INTERFACE8_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
|
---|
1099 | _i7, _i8) \
|
---|
1100 | NS_INTERFACE_MAP_BEGIN(_class) \
|
---|
1101 | NS_INTERFACE_MAP_ENTRY(_i1) \
|
---|
1102 | NS_INTERFACE_MAP_ENTRY(_i2) \
|
---|
1103 | NS_INTERFACE_MAP_ENTRY(_i3) \
|
---|
1104 | NS_INTERFACE_MAP_ENTRY(_i4) \
|
---|
1105 | NS_INTERFACE_MAP_ENTRY(_i5) \
|
---|
1106 | NS_INTERFACE_MAP_ENTRY(_i6) \
|
---|
1107 | NS_INTERFACE_MAP_ENTRY(_i7) \
|
---|
1108 | NS_INTERFACE_MAP_ENTRY(_i8) \
|
---|
1109 | NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1) \
|
---|
1110 | NS_IMPL_QUERY_CLASSINFO(_class) \
|
---|
1111 | NS_INTERFACE_MAP_END
|
---|
1112 |
|
---|
1113 | #define NS_IMPL_ISUPPORTS8_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7, _i8) \
|
---|
1114 | NS_IMPL_ADDREF(_class) \
|
---|
1115 | NS_IMPL_RELEASE(_class) \
|
---|
1116 | NS_IMPL_QUERY_INTERFACE8_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7, _i8) \
|
---|
1117 | NS_IMPL_CI_INTERFACE_GETTER8(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7, _i8)
|
---|
1118 |
|
---|
1119 | #define NS_IMPL_CI_INTERFACE_GETTER9(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
|
---|
1120 | _i7, _i8, _i9) \
|
---|
1121 | NS_CLASSINFO_HELPER_BEGIN(_class, 9) \
|
---|
1122 | NS_CLASSINFO_HELPER_ENTRY(0, _i1) \
|
---|
1123 | NS_CLASSINFO_HELPER_ENTRY(1, _i2) \
|
---|
1124 | NS_CLASSINFO_HELPER_ENTRY(2, _i3) \
|
---|
1125 | NS_CLASSINFO_HELPER_ENTRY(3, _i4) \
|
---|
1126 | NS_CLASSINFO_HELPER_ENTRY(4, _i5) \
|
---|
1127 | NS_CLASSINFO_HELPER_ENTRY(5, _i6) \
|
---|
1128 | NS_CLASSINFO_HELPER_ENTRY(6, _i7) \
|
---|
1129 | NS_CLASSINFO_HELPER_ENTRY(7, _i8) \
|
---|
1130 | NS_CLASSINFO_HELPER_ENTRY(8, _i9) \
|
---|
1131 | NS_CLASSINFO_HELPER_END
|
---|
1132 |
|
---|
1133 | #define NS_IMPL_QUERY_INTERFACE9_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
|
---|
1134 | _i7, _i8, _i9) \
|
---|
1135 | NS_INTERFACE_MAP_BEGIN(_class) \
|
---|
1136 | NS_INTERFACE_MAP_ENTRY(_i1) \
|
---|
1137 | NS_INTERFACE_MAP_ENTRY(_i2) \
|
---|
1138 | NS_INTERFACE_MAP_ENTRY(_i3) \
|
---|
1139 | NS_INTERFACE_MAP_ENTRY(_i4) \
|
---|
1140 | NS_INTERFACE_MAP_ENTRY(_i5) \
|
---|
1141 | NS_INTERFACE_MAP_ENTRY(_i6) \
|
---|
1142 | NS_INTERFACE_MAP_ENTRY(_i7) \
|
---|
1143 | NS_INTERFACE_MAP_ENTRY(_i8) \
|
---|
1144 | NS_INTERFACE_MAP_ENTRY(_i9) \
|
---|
1145 | NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1) \
|
---|
1146 | NS_IMPL_QUERY_CLASSINFO(_class) \
|
---|
1147 | NS_INTERFACE_MAP_END
|
---|
1148 |
|
---|
1149 | #define NS_IMPL_ISUPPORTS9_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7, \
|
---|
1150 | _i8, _i9) \
|
---|
1151 | NS_IMPL_ADDREF(_class) \
|
---|
1152 | NS_IMPL_RELEASE(_class) \
|
---|
1153 | NS_IMPL_QUERY_INTERFACE9_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7, \
|
---|
1154 | _i8, _i9) \
|
---|
1155 | NS_IMPL_CI_INTERFACE_GETTER9(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7, \
|
---|
1156 | _i8, _i9)
|
---|
1157 |
|
---|
1158 | #define NS_IMPL_CI_INTERFACE_GETTER10(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
|
---|
1159 | _i7, _i8, _i9, _i10) \
|
---|
1160 | NS_CLASSINFO_HELPER_BEGIN(_class, 10) \
|
---|
1161 | NS_CLASSINFO_HELPER_ENTRY(0, _i1) \
|
---|
1162 | NS_CLASSINFO_HELPER_ENTRY(1, _i2) \
|
---|
1163 | NS_CLASSINFO_HELPER_ENTRY(2, _i3) \
|
---|
1164 | NS_CLASSINFO_HELPER_ENTRY(3, _i4) \
|
---|
1165 | NS_CLASSINFO_HELPER_ENTRY(4, _i5) \
|
---|
1166 | NS_CLASSINFO_HELPER_ENTRY(5, _i6) \
|
---|
1167 | NS_CLASSINFO_HELPER_ENTRY(6, _i7) \
|
---|
1168 | NS_CLASSINFO_HELPER_ENTRY(7, _i8) \
|
---|
1169 | NS_CLASSINFO_HELPER_ENTRY(8, _i9) \
|
---|
1170 | NS_CLASSINFO_HELPER_ENTRY(9, _i10) \
|
---|
1171 | NS_CLASSINFO_HELPER_END
|
---|
1172 |
|
---|
1173 | #define NS_IMPL_CI_INTERFACE_GETTER11(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
|
---|
1174 | _i7, _i8, _i9, _i10, _i11) \
|
---|
1175 | NS_CLASSINFO_HELPER_BEGIN(_class, 10) \
|
---|
1176 | NS_CLASSINFO_HELPER_ENTRY(0, _i1) \
|
---|
1177 | NS_CLASSINFO_HELPER_ENTRY(1, _i2) \
|
---|
1178 | NS_CLASSINFO_HELPER_ENTRY(2, _i3) \
|
---|
1179 | NS_CLASSINFO_HELPER_ENTRY(3, _i4) \
|
---|
1180 | NS_CLASSINFO_HELPER_ENTRY(4, _i5) \
|
---|
1181 | NS_CLASSINFO_HELPER_ENTRY(5, _i6) \
|
---|
1182 | NS_CLASSINFO_HELPER_ENTRY(6, _i7) \
|
---|
1183 | NS_CLASSINFO_HELPER_ENTRY(7, _i8) \
|
---|
1184 | NS_CLASSINFO_HELPER_ENTRY(8, _i9) \
|
---|
1185 | NS_CLASSINFO_HELPER_ENTRY(9, _i10) \
|
---|
1186 | NS_CLASSINFO_HELPER_ENTRY(10, _i11) \
|
---|
1187 | NS_CLASSINFO_HELPER_END
|
---|
1188 |
|
---|
1189 | #define NS_IMPL_QUERY_INTERFACE10_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
|
---|
1190 | _i7, _i8, _i9, _i10) \
|
---|
1191 | NS_INTERFACE_MAP_BEGIN(_class) \
|
---|
1192 | NS_INTERFACE_MAP_ENTRY(_i1) \
|
---|
1193 | NS_INTERFACE_MAP_ENTRY(_i2) \
|
---|
1194 | NS_INTERFACE_MAP_ENTRY(_i3) \
|
---|
1195 | NS_INTERFACE_MAP_ENTRY(_i4) \
|
---|
1196 | NS_INTERFACE_MAP_ENTRY(_i5) \
|
---|
1197 | NS_INTERFACE_MAP_ENTRY(_i6) \
|
---|
1198 | NS_INTERFACE_MAP_ENTRY(_i7) \
|
---|
1199 | NS_INTERFACE_MAP_ENTRY(_i8) \
|
---|
1200 | NS_INTERFACE_MAP_ENTRY(_i9) \
|
---|
1201 | NS_INTERFACE_MAP_ENTRY(_i10) \
|
---|
1202 | NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1) \
|
---|
1203 | NS_IMPL_QUERY_CLASSINFO(_class) \
|
---|
1204 | NS_INTERFACE_MAP_END
|
---|
1205 |
|
---|
1206 | #define NS_IMPL_QUERY_INTERFACE11_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
|
---|
1207 | _i7, _i8, _i9, _i10, _i11) \
|
---|
1208 | NS_INTERFACE_MAP_BEGIN(_class) \
|
---|
1209 | NS_INTERFACE_MAP_ENTRY(_i1) \
|
---|
1210 | NS_INTERFACE_MAP_ENTRY(_i2) \
|
---|
1211 | NS_INTERFACE_MAP_ENTRY(_i3) \
|
---|
1212 | NS_INTERFACE_MAP_ENTRY(_i4) \
|
---|
1213 | NS_INTERFACE_MAP_ENTRY(_i5) \
|
---|
1214 | NS_INTERFACE_MAP_ENTRY(_i6) \
|
---|
1215 | NS_INTERFACE_MAP_ENTRY(_i7) \
|
---|
1216 | NS_INTERFACE_MAP_ENTRY(_i8) \
|
---|
1217 | NS_INTERFACE_MAP_ENTRY(_i9) \
|
---|
1218 | NS_INTERFACE_MAP_ENTRY(_i10) \
|
---|
1219 | NS_INTERFACE_MAP_ENTRY(_i11) \
|
---|
1220 | NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1) \
|
---|
1221 | NS_IMPL_QUERY_CLASSINFO(_class) \
|
---|
1222 | NS_INTERFACE_MAP_END
|
---|
1223 |
|
---|
1224 | #define NS_IMPL_ISUPPORTS10_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7, \
|
---|
1225 | _i8, _i9, _i10) \
|
---|
1226 | NS_IMPL_ADDREF(_class) \
|
---|
1227 | NS_IMPL_RELEASE(_class) \
|
---|
1228 | NS_IMPL_QUERY_INTERFACE10_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7, \
|
---|
1229 | _i8, _i9, _i10) \
|
---|
1230 | NS_IMPL_CI_INTERFACE_GETTER10(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7, \
|
---|
1231 | _i8, _i9, _i10)
|
---|
1232 |
|
---|
1233 | #define NS_IMPL_ISUPPORTS11_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7, \
|
---|
1234 | _i8, _i9, _i10, _i11) \
|
---|
1235 | NS_IMPL_ADDREF(_class) \
|
---|
1236 | NS_IMPL_RELEASE(_class) \
|
---|
1237 | NS_IMPL_QUERY_INTERFACE11_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7, \
|
---|
1238 | _i8, _i9, _i10, _i11) \
|
---|
1239 | NS_IMPL_CI_INTERFACE_GETTER11(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7, \
|
---|
1240 | _i8, _i9, _i10, _i11)
|
---|
1241 |
|
---|
1242 | #define NS_INTERFACE_MAP_END_THREADSAFE NS_IMPL_QUERY_TAIL_GUTS
|
---|
1243 |
|
---|
1244 | #endif
|
---|