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