VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/xpcom/glue/nsISupportsImpl.h@ 102122

Last change on this file since 102122 was 101967, checked in by vboxsync, 15 months ago

libs/xpcom/xpcom: Convert PR_Atomic* to ASMAtomic*, bugref:10545

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