Back to index

lightning-sunbird  0.9+nobinonly
nsISupportsImpl.h
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is XPCOM.
00015  *
00016  * The Initial Developer of the Original Code is Netscape Communications Corp.
00017  * Portions created by the Initial Developer are Copyright (C) 2001
00018  * the Initial Developer. All Rights Reserved.
00019  *
00020  * Contributor(s):
00021  *
00022  * Alternatively, the contents of this file may be used under the terms of
00023  * either the GNU General Public License Version 2 or later (the "GPL"), or
00024  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00025  * in which case the provisions of the GPL or the LGPL are applicable instead
00026  * of those above. If you wish to allow use of your version of this file only
00027  * under the terms of either the GPL or the LGPL, and not to allow others to
00028  * use your version of this file under the terms of the MPL, indicate your
00029  * decision by deleting the provisions above and replace them with the notice
00030  * and other provisions required by the GPL or the LGPL. If you do not delete
00031  * the provisions above, a recipient may use your version of this file under
00032  * the terms of any one of the MPL, the GPL or the LGPL.
00033  *
00034  * ***** END LICENSE BLOCK ***** */
00035 
00036 
00037 #ifndef nsISupportsImpl_h__
00038 #define nsISupportsImpl_h__
00039 
00040 #ifndef nscore_h___
00041 #include "nscore.h"
00042 #endif
00043 
00044 #ifndef nsISupportsBase_h__
00045 #include "nsISupportsBase.h"
00046 #endif
00047 
00048 #if defined(XPCOM_GLUE) && !defined(XPCOM_GLUE_USE_NSPR)
00049 // If we're being linked as standalone glue, we don't want a dynamic dependency
00050 // on NSPR libs, so we skip the debug thread-safety checks, and we cannot use
00051 // the THREADSAFE_ISUPPORTS macros.
00052 
00053 #define XPCOM_GLUE_AVOID_NSPR
00054 
00055 #endif
00056 
00057 
00058 #if !defined(XPCOM_GLUE_AVOID_NSPR)
00059 #include "prthread.h" /* needed for thread-safety checks */
00060 #include "pratom.h"   /* needed for PR_AtomicIncrement and PR_AtomicDecrement */
00061 #endif
00062 
00063 #include "nsDebug.h"
00064 #include "nsTraceRefcnt.h" 
00065 
00067 // Macros to help detect thread-safety:
00068 
00069 #if defined(NS_DEBUG) && !defined(XPCOM_GLUE_AVOID_NSPR)
00070 
00071 class nsAutoOwningThread {
00072 public:
00073     nsAutoOwningThread() { mThread = PR_GetCurrentThread(); }
00074     void *GetThread() const { return mThread; }
00075 
00076 private:
00077     void *mThread;
00078 };
00079 
00080 #define NS_DECL_OWNINGTHREAD            nsAutoOwningThread _mOwningThread;
00081 #define NS_ASSERT_OWNINGTHREAD(_class) \
00082   NS_CheckThreadSafe(_mOwningThread.GetThread(), #_class " not thread-safe")
00083 
00084 #else // !NS_DEBUG
00085 
00086 #define NS_DECL_OWNINGTHREAD            /* nothing */
00087 #define NS_ASSERT_OWNINGTHREAD(_class)  ((void)0)
00088 
00089 #endif // NS_DEBUG
00090 
00091 class nsAutoRefCnt {
00092 
00093  public:
00094     nsAutoRefCnt() : mValue(0) {}
00095     nsAutoRefCnt(nsrefcnt aValue) : mValue(aValue) {}
00096 
00097     // only support prefix increment/decrement
00098     nsrefcnt operator++() { return ++mValue; }
00099     nsrefcnt operator--() { return --mValue; }
00100     
00101     nsrefcnt operator=(nsrefcnt aValue) { return (mValue = aValue); }
00102     operator nsrefcnt() const { return mValue; }
00103     nsrefcnt get() const { return mValue; }
00104  private:
00105     // do not define these to enforce the faster prefix notation
00106     nsrefcnt operator++(int);
00107     nsrefcnt operator--(int);
00108     nsrefcnt mValue;
00109 };
00110 
00112 
00118 #define NS_DECL_ISUPPORTS                                                     \
00119 public:                                                                       \
00120   NS_IMETHOD QueryInterface(REFNSIID aIID,                                    \
00121                             void** aInstancePtr);                             \
00122   NS_IMETHOD_(nsrefcnt) AddRef(void);                                         \
00123   NS_IMETHOD_(nsrefcnt) Release(void);                                        \
00124 protected:                                                                    \
00125   nsAutoRefCnt mRefCnt;                                                       \
00126   NS_DECL_OWNINGTHREAD                                                        \
00127 public:
00128 
00129 
00131 
00137 #define NS_INIT_ISUPPORTS() ((void)0)
00138 
00143 #define NS_IMPL_ADDREF(_class)                                                \
00144 NS_IMETHODIMP_(nsrefcnt) _class::AddRef(void)                                 \
00145 {                                                                             \
00146   NS_PRECONDITION(PRInt32(mRefCnt) >= 0, "illegal refcnt");                   \
00147   NS_ASSERT_OWNINGTHREAD(_class);                                             \
00148   ++mRefCnt;                                                                  \
00149   NS_LOG_ADDREF(this, mRefCnt, #_class, sizeof(*this));                       \
00150   return mRefCnt;                                                             \
00151 }
00152 
00160 #define NS_IMPL_ADDREF_USING_AGGREGATOR(_class, _aggregator)                  \
00161 NS_IMETHODIMP_(nsrefcnt) _class::AddRef(void)                                 \
00162 {                                                                             \
00163   NS_PRECONDITION(_aggregator, "null aggregator");                            \
00164   return (_aggregator)->AddRef();                                             \
00165 }
00166 
00186 #define NS_IMPL_RELEASE_WITH_DESTROY(_class, _destroy)                        \
00187 NS_IMETHODIMP_(nsrefcnt) _class::Release(void)                                \
00188 {                                                                             \
00189   NS_PRECONDITION(0 != mRefCnt, "dup release");                               \
00190   NS_ASSERT_OWNINGTHREAD(_class);                                             \
00191   --mRefCnt;                                                                  \
00192   NS_LOG_RELEASE(this, mRefCnt, #_class);                                     \
00193   if (mRefCnt == 0) {                                                         \
00194     mRefCnt = 1; /* stabilize */                                              \
00195     _destroy;                                                                 \
00196     return 0;                                                                 \
00197   }                                                                           \
00198   return mRefCnt;                                                             \
00199 }
00200 
00214 #define NS_IMPL_RELEASE(_class) \
00215   NS_IMPL_RELEASE_WITH_DESTROY(_class, NS_DELETEXPCOM(this))
00216 
00224 #define NS_IMPL_RELEASE_USING_AGGREGATOR(_class, _aggregator)                 \
00225 NS_IMETHODIMP_(nsrefcnt) _class::Release(void)                                \
00226 {                                                                             \
00227   NS_PRECONDITION(_aggregator, "null aggregator");                            \
00228   return (_aggregator)->Release();                                            \
00229 }
00230 
00231 
00232 
00234 
00235 /*
00236  * Some convenience macros for implementing QueryInterface
00237  */
00238 
00250 #define NS_IMPL_QUERY_HEAD(_class)                                            \
00251 NS_IMETHODIMP _class::QueryInterface(REFNSIID aIID, void** aInstancePtr)      \
00252 {                                                                             \
00253   NS_ASSERTION(aInstancePtr,                                                  \
00254                "QueryInterface requires a non-NULL destination!");            \
00255   nsISupports* foundInterface;
00256 
00257 #define NS_IMPL_QUERY_BODY(_interface)                                        \
00258   if ( aIID.Equals(NS_GET_IID(_interface)) )                                  \
00259     foundInterface = NS_STATIC_CAST(_interface*, this);                       \
00260   else
00261 
00262 #define NS_IMPL_QUERY_BODY_CONDITIONAL(_interface, condition)                 \
00263   if ( (condition) && aIID.Equals(NS_GET_IID(_interface)))                    \
00264     foundInterface = NS_STATIC_CAST(_interface*, this);                       \
00265   else
00266 
00267 #define NS_IMPL_QUERY_BODY_AMBIGUOUS(_interface, _implClass)                  \
00268   if ( aIID.Equals(NS_GET_IID(_interface)) )                                  \
00269     foundInterface = NS_STATIC_CAST(_interface*,                              \
00270                                     NS_STATIC_CAST(_implClass*, this));       \
00271   else
00272 
00273 #define NS_IMPL_QUERY_BODY_AGGREGATED(_interface, _aggregate)                 \
00274   if ( aIID.Equals(NS_GET_IID(_interface)) )                                  \
00275     foundInterface = NS_STATIC_CAST(_interface*, _aggregate);                 \
00276   else
00277 
00278 #define NS_IMPL_QUERY_TAIL_GUTS                                               \
00279     foundInterface = 0;                                                       \
00280   nsresult status;                                                            \
00281   if ( !foundInterface )                                                      \
00282     status = NS_NOINTERFACE;                                                  \
00283   else                                                                        \
00284     {                                                                         \
00285       NS_ADDREF(foundInterface);                                              \
00286       status = NS_OK;                                                         \
00287     }                                                                         \
00288   *aInstancePtr = foundInterface;                                             \
00289   return status;                                                              \
00290 }
00291 
00292 #define NS_IMPL_QUERY_TAIL_INHERITING(_baseclass)                             \
00293     foundInterface = 0;                                                       \
00294   nsresult status;                                                            \
00295   if ( !foundInterface )                                                      \
00296     status = _baseclass::QueryInterface(aIID, (void**)&foundInterface);       \
00297   else                                                                        \
00298     {                                                                         \
00299       NS_ADDREF(foundInterface);                                              \
00300       status = NS_OK;                                                         \
00301     }                                                                         \
00302   *aInstancePtr = foundInterface;                                             \
00303   return status;                                                              \
00304 }
00305 
00306 #define NS_IMPL_QUERY_TAIL_USING_AGGREGATOR(_aggregator)                      \
00307     foundInterface = 0;                                                       \
00308   nsresult status;                                                            \
00309   if ( !foundInterface ) {                                                    \
00310     NS_ASSERTION(_aggregator, "null aggregator");                             \
00311     status = _aggregator->QueryInterface(aIID, (void**)&foundInterface);      \
00312   } else                                                                      \
00313     {                                                                         \
00314       NS_ADDREF(foundInterface);                                              \
00315       status = NS_OK;                                                         \
00316     }                                                                         \
00317   *aInstancePtr = foundInterface;                                             \
00318   return status;                                                              \
00319 }
00320 
00321 #define NS_IMPL_QUERY_TAIL(_supports_interface)                               \
00322   NS_IMPL_QUERY_BODY_AMBIGUOUS(nsISupports, _supports_interface)              \
00323   NS_IMPL_QUERY_TAIL_GUTS
00324 
00325 
00326   /*
00327     This is the new scheme.  Using this notation now will allow us to switch to
00328     a table driven mechanism when it's ready.  Note the difference between this
00329     and the (currently) underlying NS_IMPL_QUERY_INTERFACE mechanism.  You must
00330     explicitly mention |nsISupports| when using the interface maps.
00331   */
00332 #define NS_INTERFACE_MAP_BEGIN(_implClass)      NS_IMPL_QUERY_HEAD(_implClass)
00333 #define NS_INTERFACE_MAP_ENTRY(_interface)      NS_IMPL_QUERY_BODY(_interface)
00334 #define NS_INTERFACE_MAP_ENTRY_CONDITIONAL(_interface, condition)             \
00335   NS_IMPL_QUERY_BODY_CONDITIONAL(_interface, condition)
00336 #define NS_INTERFACE_MAP_ENTRY_AGGREGATED(_interface,_aggregate)              \
00337   NS_IMPL_QUERY_BODY_AGGREGATED(_interface,_aggregate)
00338 
00339 #define NS_INTERFACE_MAP_END                    NS_IMPL_QUERY_TAIL_GUTS
00340 #define NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(_interface, _implClass)              \
00341   NS_IMPL_QUERY_BODY_AMBIGUOUS(_interface, _implClass)
00342 #define NS_INTERFACE_MAP_END_INHERITING(_baseClass)                           \
00343   NS_IMPL_QUERY_TAIL_INHERITING(_baseClass)
00344 #define NS_INTERFACE_MAP_END_AGGREGATED(_aggregator)                          \
00345   NS_IMPL_QUERY_TAIL_USING_AGGREGATOR(_aggregator)
00346 
00347 #define NS_IMPL_QUERY_INTERFACE0(_class)                                      \
00348   NS_INTERFACE_MAP_BEGIN(_class)                                              \
00349     NS_INTERFACE_MAP_ENTRY(nsISupports)                                       \
00350   NS_INTERFACE_MAP_END
00351 
00352 #define NS_IMPL_QUERY_INTERFACE1(_class, _i1)                                 \
00353   NS_INTERFACE_MAP_BEGIN(_class)                                              \
00354     NS_INTERFACE_MAP_ENTRY(_i1)                                               \
00355     NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1)                        \
00356   NS_INTERFACE_MAP_END
00357 
00358 #define NS_IMPL_QUERY_INTERFACE2(_class, _i1, _i2)                            \
00359   NS_INTERFACE_MAP_BEGIN(_class)                                              \
00360     NS_INTERFACE_MAP_ENTRY(_i1)                                               \
00361     NS_INTERFACE_MAP_ENTRY(_i2)                                               \
00362     NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1)                        \
00363   NS_INTERFACE_MAP_END
00364 
00365 #define NS_IMPL_QUERY_INTERFACE3(_class, _i1, _i2, _i3)                       \
00366   NS_INTERFACE_MAP_BEGIN(_class)                                              \
00367     NS_INTERFACE_MAP_ENTRY(_i1)                                               \
00368     NS_INTERFACE_MAP_ENTRY(_i2)                                               \
00369     NS_INTERFACE_MAP_ENTRY(_i3)                                               \
00370     NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1)                        \
00371   NS_INTERFACE_MAP_END
00372 
00373 #define NS_IMPL_QUERY_INTERFACE4(_class, _i1, _i2, _i3, _i4)                  \
00374   NS_INTERFACE_MAP_BEGIN(_class)                                              \
00375     NS_INTERFACE_MAP_ENTRY(_i1)                                               \
00376     NS_INTERFACE_MAP_ENTRY(_i2)                                               \
00377     NS_INTERFACE_MAP_ENTRY(_i3)                                               \
00378     NS_INTERFACE_MAP_ENTRY(_i4)                                               \
00379     NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1)                        \
00380   NS_INTERFACE_MAP_END
00381 
00382 #define NS_IMPL_QUERY_INTERFACE5(_class, _i1, _i2, _i3, _i4, _i5)             \
00383   NS_INTERFACE_MAP_BEGIN(_class)                                              \
00384     NS_INTERFACE_MAP_ENTRY(_i1)                                               \
00385     NS_INTERFACE_MAP_ENTRY(_i2)                                               \
00386     NS_INTERFACE_MAP_ENTRY(_i3)                                               \
00387     NS_INTERFACE_MAP_ENTRY(_i4)                                               \
00388     NS_INTERFACE_MAP_ENTRY(_i5)                                               \
00389     NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1)                        \
00390   NS_INTERFACE_MAP_END
00391 
00392 #define NS_IMPL_QUERY_INTERFACE6(_class, _i1, _i2, _i3, _i4, _i5, _i6)        \
00393   NS_INTERFACE_MAP_BEGIN(_class)                                              \
00394     NS_INTERFACE_MAP_ENTRY(_i1)                                               \
00395     NS_INTERFACE_MAP_ENTRY(_i2)                                               \
00396     NS_INTERFACE_MAP_ENTRY(_i3)                                               \
00397     NS_INTERFACE_MAP_ENTRY(_i4)                                               \
00398     NS_INTERFACE_MAP_ENTRY(_i5)                                               \
00399     NS_INTERFACE_MAP_ENTRY(_i6)                                               \
00400     NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1)                        \
00401   NS_INTERFACE_MAP_END
00402 
00403 #define NS_IMPL_QUERY_INTERFACE7(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7)   \
00404   NS_INTERFACE_MAP_BEGIN(_class)                                              \
00405     NS_INTERFACE_MAP_ENTRY(_i1)                                               \
00406     NS_INTERFACE_MAP_ENTRY(_i2)                                               \
00407     NS_INTERFACE_MAP_ENTRY(_i3)                                               \
00408     NS_INTERFACE_MAP_ENTRY(_i4)                                               \
00409     NS_INTERFACE_MAP_ENTRY(_i5)                                               \
00410     NS_INTERFACE_MAP_ENTRY(_i6)                                               \
00411     NS_INTERFACE_MAP_ENTRY(_i7)                                               \
00412     NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1)                        \
00413   NS_INTERFACE_MAP_END
00414 
00415 #define NS_IMPL_QUERY_INTERFACE8(_class, _i1, _i2, _i3, _i4, _i5, _i6,        \
00416                                  _i7, _i8)                                    \
00417   NS_INTERFACE_MAP_BEGIN(_class)                                              \
00418     NS_INTERFACE_MAP_ENTRY(_i1)                                               \
00419     NS_INTERFACE_MAP_ENTRY(_i2)                                               \
00420     NS_INTERFACE_MAP_ENTRY(_i3)                                               \
00421     NS_INTERFACE_MAP_ENTRY(_i4)                                               \
00422     NS_INTERFACE_MAP_ENTRY(_i5)                                               \
00423     NS_INTERFACE_MAP_ENTRY(_i6)                                               \
00424     NS_INTERFACE_MAP_ENTRY(_i7)                                               \
00425     NS_INTERFACE_MAP_ENTRY(_i8)                                               \
00426     NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1)                        \
00427   NS_INTERFACE_MAP_END
00428 
00429 #define NS_IMPL_QUERY_INTERFACE9(_class, _i1, _i2, _i3, _i4, _i5, _i6,        \
00430                                  _i7, _i8, _i9)                               \
00431   NS_INTERFACE_MAP_BEGIN(_class)                                              \
00432     NS_INTERFACE_MAP_ENTRY(_i1)                                               \
00433     NS_INTERFACE_MAP_ENTRY(_i2)                                               \
00434     NS_INTERFACE_MAP_ENTRY(_i3)                                               \
00435     NS_INTERFACE_MAP_ENTRY(_i4)                                               \
00436     NS_INTERFACE_MAP_ENTRY(_i5)                                               \
00437     NS_INTERFACE_MAP_ENTRY(_i6)                                               \
00438     NS_INTERFACE_MAP_ENTRY(_i7)                                               \
00439     NS_INTERFACE_MAP_ENTRY(_i8)                                               \
00440     NS_INTERFACE_MAP_ENTRY(_i9)                                               \
00441     NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1)                        \
00442   NS_INTERFACE_MAP_END
00443 
00444 #define NS_IMPL_QUERY_INTERFACE10(_class, _i1, _i2, _i3, _i4, _i5, _i6,       \
00445                                   _i7, _i8, _i9, _i10)                        \
00446   NS_INTERFACE_MAP_BEGIN(_class)                                              \
00447     NS_INTERFACE_MAP_ENTRY(_i1)                                               \
00448     NS_INTERFACE_MAP_ENTRY(_i2)                                               \
00449     NS_INTERFACE_MAP_ENTRY(_i3)                                               \
00450     NS_INTERFACE_MAP_ENTRY(_i4)                                               \
00451     NS_INTERFACE_MAP_ENTRY(_i5)                                               \
00452     NS_INTERFACE_MAP_ENTRY(_i6)                                               \
00453     NS_INTERFACE_MAP_ENTRY(_i7)                                               \
00454     NS_INTERFACE_MAP_ENTRY(_i8)                                               \
00455     NS_INTERFACE_MAP_ENTRY(_i9)                                               \
00456     NS_INTERFACE_MAP_ENTRY(_i10)                                              \
00457     NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1)                        \
00458   NS_INTERFACE_MAP_END
00459 
00460 #define NS_IMPL_QUERY_INTERFACE11(_class, _i1, _i2, _i3, _i4, _i5, _i6,       \
00461                                   _i7, _i8, _i9, _i10, _i11)                  \
00462   NS_INTERFACE_MAP_BEGIN(_class)                                              \
00463     NS_INTERFACE_MAP_ENTRY(_i1)                                               \
00464     NS_INTERFACE_MAP_ENTRY(_i2)                                               \
00465     NS_INTERFACE_MAP_ENTRY(_i3)                                               \
00466     NS_INTERFACE_MAP_ENTRY(_i4)                                               \
00467     NS_INTERFACE_MAP_ENTRY(_i5)                                               \
00468     NS_INTERFACE_MAP_ENTRY(_i6)                                               \
00469     NS_INTERFACE_MAP_ENTRY(_i7)                                               \
00470     NS_INTERFACE_MAP_ENTRY(_i8)                                               \
00471     NS_INTERFACE_MAP_ENTRY(_i9)                                               \
00472     NS_INTERFACE_MAP_ENTRY(_i10)                                              \
00473     NS_INTERFACE_MAP_ENTRY(_i11)                                              \
00474     NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1)                        \
00475   NS_INTERFACE_MAP_END
00476 
00477 
00478 #define NS_IMPL_THREADSAFE_QUERY_INTERFACE0  NS_IMPL_QUERY_INTERFACE0
00479 #define NS_IMPL_THREADSAFE_QUERY_INTERFACE1  NS_IMPL_QUERY_INTERFACE1
00480 #define NS_IMPL_THREADSAFE_QUERY_INTERFACE2  NS_IMPL_QUERY_INTERFACE2
00481 #define NS_IMPL_THREADSAFE_QUERY_INTERFACE3  NS_IMPL_QUERY_INTERFACE3
00482 #define NS_IMPL_THREADSAFE_QUERY_INTERFACE4  NS_IMPL_QUERY_INTERFACE4
00483 #define NS_IMPL_THREADSAFE_QUERY_INTERFACE5  NS_IMPL_QUERY_INTERFACE5
00484 #define NS_IMPL_THREADSAFE_QUERY_INTERFACE6  NS_IMPL_QUERY_INTERFACE6
00485 #define NS_IMPL_THREADSAFE_QUERY_INTERFACE7  NS_IMPL_QUERY_INTERFACE7
00486 #define NS_IMPL_THREADSAFE_QUERY_INTERFACE8  NS_IMPL_QUERY_INTERFACE8
00487 #define NS_IMPL_THREADSAFE_QUERY_INTERFACE9  NS_IMPL_QUERY_INTERFACE9
00488 #define NS_IMPL_THREADSAFE_QUERY_INTERFACE10  NS_IMPL_QUERY_INTERFACE10
00489 #define NS_IMPL_THREADSAFE_QUERY_INTERFACE11  NS_IMPL_QUERY_INTERFACE11
00490 
00503 #define NS_DECL_ISUPPORTS_INHERITED                                           \
00504 public:                                                                       \
00505   NS_IMETHOD QueryInterface(REFNSIID aIID,                                    \
00506                             void** aInstancePtr);                             \
00507   NS_IMETHOD_(nsrefcnt) AddRef(void);                                         \
00508   NS_IMETHOD_(nsrefcnt) Release(void);                                        \
00509 
00510 
00518 #define NS_IMPL_ADDREF_INHERITED(Class, Super)                                \
00519 NS_IMETHODIMP_(nsrefcnt) Class::AddRef(void)                                  \
00520 {                                                                             \
00521   return Super::AddRef();                                                     \
00522 }                                                                             \
00523 
00524 #define NS_IMPL_RELEASE_INHERITED(Class, Super)                               \
00525 NS_IMETHODIMP_(nsrefcnt) Class::Release(void)                                 \
00526 {                                                                             \
00527   return Super::Release();                                                    \
00528 }                                                                             \
00529 
00530 #define NS_IMPL_QUERY_INTERFACE_INHERITED0(Class, Super)                      \
00531   NS_IMPL_QUERY_HEAD(Class)                                                   \
00532   NS_IMPL_QUERY_TAIL_INHERITING(Super)                                        \
00533 
00534 #define NS_IMPL_QUERY_INTERFACE_INHERITED1(Class, Super, i1)                  \
00535   NS_IMPL_QUERY_HEAD(Class)                                                   \
00536   NS_IMPL_QUERY_BODY(i1)                                                      \
00537   NS_IMPL_QUERY_TAIL_INHERITING(Super)                                        \
00538 
00539 #define NS_IMPL_QUERY_INTERFACE_INHERITED2(Class, Super, i1, i2)              \
00540   NS_IMPL_QUERY_HEAD(Class)                                                   \
00541   NS_IMPL_QUERY_BODY(i1)                                                      \
00542   NS_IMPL_QUERY_BODY(i2)                                                      \
00543   NS_IMPL_QUERY_TAIL_INHERITING(Super)                                        \
00544 
00545 #define NS_IMPL_QUERY_INTERFACE_INHERITED3(Class, Super, i1, i2, i3)          \
00546   NS_IMPL_QUERY_HEAD(Class)                                                   \
00547   NS_IMPL_QUERY_BODY(i1)                                                      \
00548   NS_IMPL_QUERY_BODY(i2)                                                      \
00549   NS_IMPL_QUERY_BODY(i3)                                                      \
00550   NS_IMPL_QUERY_TAIL_INHERITING(Super)                                        \
00551 
00552 #define NS_IMPL_QUERY_INTERFACE_INHERITED4(Class, Super, i1, i2, i3, i4)      \
00553   NS_IMPL_QUERY_HEAD(Class)                                                   \
00554   NS_IMPL_QUERY_BODY(i1)                                                      \
00555   NS_IMPL_QUERY_BODY(i2)                                                      \
00556   NS_IMPL_QUERY_BODY(i3)                                                      \
00557   NS_IMPL_QUERY_BODY(i4)                                                      \
00558   NS_IMPL_QUERY_TAIL_INHERITING(Super)                                        \
00559 
00560 #define NS_IMPL_QUERY_INTERFACE_INHERITED5(Class,Super,i1,i2,i3,i4,i5)        \
00561   NS_IMPL_QUERY_HEAD(Class)                                                   \
00562   NS_IMPL_QUERY_BODY(i1)                                                      \
00563   NS_IMPL_QUERY_BODY(i2)                                                      \
00564   NS_IMPL_QUERY_BODY(i3)                                                      \
00565   NS_IMPL_QUERY_BODY(i4)                                                      \
00566   NS_IMPL_QUERY_BODY(i5)                                                      \
00567   NS_IMPL_QUERY_TAIL_INHERITING(Super)                                        \
00568 
00569 #define NS_IMPL_QUERY_INTERFACE_INHERITED6(Class,Super,i1,i2,i3,i4,i5,i6)     \
00570   NS_IMPL_QUERY_HEAD(Class)                                                   \
00571   NS_IMPL_QUERY_BODY(i1)                                                      \
00572   NS_IMPL_QUERY_BODY(i2)                                                      \
00573   NS_IMPL_QUERY_BODY(i3)                                                      \
00574   NS_IMPL_QUERY_BODY(i4)                                                      \
00575   NS_IMPL_QUERY_BODY(i5)                                                      \
00576   NS_IMPL_QUERY_BODY(i6)                                                      \
00577   NS_IMPL_QUERY_TAIL_INHERITING(Super)                                        \
00578 
00579 
00587 #define NS_IMPL_ISUPPORTS0(_class)                                            \
00588   NS_IMPL_ADDREF(_class)                                                      \
00589   NS_IMPL_RELEASE(_class)                                                     \
00590   NS_IMPL_QUERY_INTERFACE0(_class)
00591 
00592 #define NS_IMPL_ISUPPORTS1(_class, _interface)                                \
00593   NS_IMPL_ADDREF(_class)                                                      \
00594   NS_IMPL_RELEASE(_class)                                                     \
00595   NS_IMPL_QUERY_INTERFACE1(_class, _interface)
00596 
00597 #define NS_IMPL_ISUPPORTS2(_class, _i1, _i2)                                  \
00598   NS_IMPL_ADDREF(_class)                                                      \
00599   NS_IMPL_RELEASE(_class)                                                     \
00600   NS_IMPL_QUERY_INTERFACE2(_class, _i1, _i2)
00601 
00602 #define NS_IMPL_ISUPPORTS3(_class, _i1, _i2, _i3)                             \
00603   NS_IMPL_ADDREF(_class)                                                      \
00604   NS_IMPL_RELEASE(_class)                                                     \
00605   NS_IMPL_QUERY_INTERFACE3(_class, _i1, _i2, _i3)
00606 
00607 #define NS_IMPL_ISUPPORTS4(_class, _i1, _i2, _i3, _i4)                        \
00608   NS_IMPL_ADDREF(_class)                                                      \
00609   NS_IMPL_RELEASE(_class)                                                     \
00610   NS_IMPL_QUERY_INTERFACE4(_class, _i1, _i2, _i3, _i4)
00611 
00612 #define NS_IMPL_ISUPPORTS5(_class, _i1, _i2, _i3, _i4, _i5)                   \
00613   NS_IMPL_ADDREF(_class)                                                      \
00614   NS_IMPL_RELEASE(_class)                                                     \
00615   NS_IMPL_QUERY_INTERFACE5(_class, _i1, _i2, _i3, _i4, _i5)
00616 
00617 #define NS_IMPL_ISUPPORTS6(_class, _i1, _i2, _i3, _i4, _i5, _i6)              \
00618   NS_IMPL_ADDREF(_class)                                                      \
00619   NS_IMPL_RELEASE(_class)                                                     \
00620   NS_IMPL_QUERY_INTERFACE6(_class, _i1, _i2, _i3, _i4, _i5, _i6)
00621 
00622 #define NS_IMPL_ISUPPORTS7(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7)         \
00623   NS_IMPL_ADDREF(_class)                                                      \
00624   NS_IMPL_RELEASE(_class)                                                     \
00625   NS_IMPL_QUERY_INTERFACE7(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7)
00626 
00627 #define NS_IMPL_ISUPPORTS8(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7, _i8)    \
00628   NS_IMPL_ADDREF(_class)                                                      \
00629   NS_IMPL_RELEASE(_class)                                                     \
00630   NS_IMPL_QUERY_INTERFACE8(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7, _i8)
00631 
00632 #define NS_IMPL_ISUPPORTS9(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7, _i8,    \
00633                            _i9)                                               \
00634   NS_IMPL_ADDREF(_class)                                                      \
00635   NS_IMPL_RELEASE(_class)                                                     \
00636   NS_IMPL_QUERY_INTERFACE9(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7, _i8, _i9)
00637 
00638 #define NS_IMPL_ISUPPORTS10(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7, _i8,   \
00639                             _i9, _i10)                                        \
00640   NS_IMPL_ADDREF(_class)                                                      \
00641   NS_IMPL_RELEASE(_class)                                                     \
00642   NS_IMPL_QUERY_INTERFACE10(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7, _i8,   \
00643                             _i9, _i10)
00644 
00645 #define NS_IMPL_ISUPPORTS11(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7, _i8,   \
00646                             _i9, _i10, _i11)                                  \
00647   NS_IMPL_ADDREF(_class)                                                      \
00648   NS_IMPL_RELEASE(_class)                                                     \
00649   NS_IMPL_QUERY_INTERFACE11(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7, _i8,   \
00650                             _i9, _i10, _i11)
00651 
00652 #define NS_IMPL_ISUPPORTS_INHERITED0(Class, Super)                            \
00653     NS_IMPL_QUERY_INTERFACE_INHERITED0(Class, Super)                          \
00654     NS_IMPL_ADDREF_INHERITED(Class, Super)                                    \
00655     NS_IMPL_RELEASE_INHERITED(Class, Super)                                   \
00656 
00657 #define NS_IMPL_ISUPPORTS_INHERITED1(Class, Super, i1)                        \
00658     NS_IMPL_QUERY_INTERFACE_INHERITED1(Class, Super, i1)                      \
00659     NS_IMPL_ADDREF_INHERITED(Class, Super)                                    \
00660     NS_IMPL_RELEASE_INHERITED(Class, Super)                                   \
00661 
00662 #define NS_IMPL_ISUPPORTS_INHERITED2(Class, Super, i1, i2)                    \
00663     NS_IMPL_QUERY_INTERFACE_INHERITED2(Class, Super, i1, i2)                  \
00664     NS_IMPL_ADDREF_INHERITED(Class, Super)                                    \
00665     NS_IMPL_RELEASE_INHERITED(Class, Super)                                   \
00666 
00667 #define NS_IMPL_ISUPPORTS_INHERITED3(Class, Super, i1, i2, i3)                \
00668     NS_IMPL_QUERY_INTERFACE_INHERITED3(Class, Super, i1, i2, i3)              \
00669     NS_IMPL_ADDREF_INHERITED(Class, Super)                                    \
00670     NS_IMPL_RELEASE_INHERITED(Class, Super)                                   \
00671 
00672 #define NS_IMPL_ISUPPORTS_INHERITED4(Class, Super, i1, i2, i3, i4)            \
00673     NS_IMPL_QUERY_INTERFACE_INHERITED4(Class, Super, i1, i2, i3, i4)          \
00674     NS_IMPL_ADDREF_INHERITED(Class, Super)                                    \
00675     NS_IMPL_RELEASE_INHERITED(Class, Super)                                   \
00676 
00677 #define NS_IMPL_ISUPPORTS_INHERITED5(Class, Super, i1, i2, i3, i4, i5)        \
00678     NS_IMPL_QUERY_INTERFACE_INHERITED5(Class, Super, i1, i2, i3, i4, i5)      \
00679     NS_IMPL_ADDREF_INHERITED(Class, Super)                                    \
00680     NS_IMPL_RELEASE_INHERITED(Class, Super)                                   \
00681 
00682 #define NS_IMPL_ISUPPORTS_INHERITED6(Class, Super, i1, i2, i3, i4, i5, i6)    \
00683     NS_IMPL_QUERY_INTERFACE_INHERITED6(Class, Super, i1, i2, i3, i4, i5, i6)  \
00684     NS_IMPL_ADDREF_INHERITED(Class, Super)                                    \
00685     NS_IMPL_RELEASE_INHERITED(Class, Super)                                   \
00686 
00687 
00688 
00696 #if !defined(XPCOM_GLUE_AVOID_NSPR)
00697 
00703 #define NS_IMPL_THREADSAFE_ADDREF(_class)                                     \
00704 NS_IMETHODIMP_(nsrefcnt) _class::AddRef(void)                                 \
00705 {                                                                             \
00706   NS_PRECONDITION(PRInt32(mRefCnt) >= 0, "illegal refcnt");                   \
00707   nsrefcnt count;                                                             \
00708   count = PR_AtomicIncrement((PRInt32*)&mRefCnt);                             \
00709   NS_LOG_ADDREF(this, count, #_class, sizeof(*this));                         \
00710   return count;                                                               \
00711 }
00712 
00718 #define NS_IMPL_THREADSAFE_RELEASE(_class)                                    \
00719 NS_IMETHODIMP_(nsrefcnt) _class::Release(void)                                \
00720 {                                                                             \
00721   nsrefcnt count;                                                             \
00722   NS_PRECONDITION(0 != mRefCnt, "dup release");                               \
00723   count = PR_AtomicDecrement((PRInt32 *)&mRefCnt);                            \
00724   NS_LOG_RELEASE(this, count, #_class);                                       \
00725   if (0 == count) {                                                           \
00726     mRefCnt = 1; /* stabilize */                                              \
00727     /* enable this to find non-threadsafe destructors: */                     \
00728     /* NS_ASSERT_OWNINGTHREAD(_class); */                                     \
00729     NS_DELETEXPCOM(this);                                                     \
00730     return 0;                                                                 \
00731   }                                                                           \
00732   return count;                                                               \
00733 }
00734 
00735 #else // XPCOM_GLUE_AVOID_NSPR
00736 
00737 #define NS_IMPL_THREADSAFE_ADDREF(_class)                                     \
00738   THREADSAFE_ISUPPORTS_NOT_AVAILABLE_IN_STANDALONE_GLUE;
00739 
00740 #define NS_IMPL_THREADSAFE_RELEASE(_class)                                    \
00741   THREADSAFE_ISUPPORTS_NOT_AVAILABLE_IN_STANDALONE_GLUE;
00742 
00743 #endif
00744 
00745 #define NS_IMPL_THREADSAFE_ISUPPORTS0(_class)                                 \
00746   NS_IMPL_THREADSAFE_ADDREF(_class)                                           \
00747   NS_IMPL_THREADSAFE_RELEASE(_class)                                          \
00748   NS_IMPL_THREADSAFE_QUERY_INTERFACE0(_class)
00749 
00750 #define NS_IMPL_THREADSAFE_ISUPPORTS1(_class, _interface)                     \
00751   NS_IMPL_THREADSAFE_ADDREF(_class)                                           \
00752   NS_IMPL_THREADSAFE_RELEASE(_class)                                          \
00753   NS_IMPL_THREADSAFE_QUERY_INTERFACE1(_class, _interface)
00754 
00755 #define NS_IMPL_THREADSAFE_ISUPPORTS2(_class, _i1, _i2)                       \
00756   NS_IMPL_THREADSAFE_ADDREF(_class)                                           \
00757   NS_IMPL_THREADSAFE_RELEASE(_class)                                          \
00758   NS_IMPL_THREADSAFE_QUERY_INTERFACE2(_class, _i1, _i2)
00759 
00760 #define NS_IMPL_THREADSAFE_ISUPPORTS3(_class, _i1, _i2, _i3)                  \
00761   NS_IMPL_THREADSAFE_ADDREF(_class)                                           \
00762   NS_IMPL_THREADSAFE_RELEASE(_class)                                          \
00763   NS_IMPL_THREADSAFE_QUERY_INTERFACE3(_class, _i1, _i2, _i3)
00764 
00765 #define NS_IMPL_THREADSAFE_ISUPPORTS4(_class, _i1, _i2, _i3, _i4)             \
00766   NS_IMPL_THREADSAFE_ADDREF(_class)                                           \
00767   NS_IMPL_THREADSAFE_RELEASE(_class)                                          \
00768   NS_IMPL_THREADSAFE_QUERY_INTERFACE4(_class, _i1, _i2, _i3, _i4)
00769 
00770 #define NS_IMPL_THREADSAFE_ISUPPORTS5(_class, _i1, _i2, _i3, _i4, _i5)        \
00771   NS_IMPL_THREADSAFE_ADDREF(_class)                                           \
00772   NS_IMPL_THREADSAFE_RELEASE(_class)                                          \
00773   NS_IMPL_THREADSAFE_QUERY_INTERFACE5(_class, _i1, _i2, _i3, _i4, _i5)
00774 
00775 #define NS_IMPL_THREADSAFE_ISUPPORTS6(_class, _i1, _i2, _i3, _i4, _i5, _i6)   \
00776   NS_IMPL_THREADSAFE_ADDREF(_class)                                           \
00777   NS_IMPL_THREADSAFE_RELEASE(_class)                                          \
00778   NS_IMPL_THREADSAFE_QUERY_INTERFACE6(_class, _i1, _i2, _i3, _i4, _i5, _i6)
00779 
00780 #define NS_IMPL_THREADSAFE_ISUPPORTS7(_class, _i1, _i2, _i3, _i4, _i5, _i6,   \
00781                                       _i7)                                    \
00782   NS_IMPL_THREADSAFE_ADDREF(_class)                                           \
00783   NS_IMPL_THREADSAFE_RELEASE(_class)                                          \
00784   NS_IMPL_THREADSAFE_QUERY_INTERFACE7(_class, _i1, _i2, _i3, _i4, _i5, _i6,   \
00785                                       _i7)
00786 
00787 #define NS_IMPL_THREADSAFE_ISUPPORTS8(_class, _i1, _i2, _i3, _i4, _i5, _i6,   \
00788                                       _i7, _i8)                               \
00789   NS_IMPL_THREADSAFE_ADDREF(_class)                                           \
00790   NS_IMPL_THREADSAFE_RELEASE(_class)                                          \
00791   NS_IMPL_THREADSAFE_QUERY_INTERFACE8(_class, _i1, _i2, _i3, _i4, _i5, _i6,   \
00792                                       _i7, _i8)
00793 
00794 #define NS_IMPL_THREADSAFE_ISUPPORTS9(_class, _i1, _i2, _i3, _i4, _i5, _i6,   \
00795                                       _i7, _i8, _i9)                          \
00796   NS_IMPL_THREADSAFE_ADDREF(_class)                                           \
00797   NS_IMPL_THREADSAFE_RELEASE(_class)                                          \
00798   NS_IMPL_THREADSAFE_QUERY_INTERFACE9(_class, _i1, _i2, _i3, _i4, _i5, _i6,   \
00799                                       _i7, _i8, _i9)
00800 
00801 #define NS_IMPL_THREADSAFE_ISUPPORTS10(_class, _i1, _i2, _i3, _i4, _i5, _i6,  \
00802                                        _i7, _i8, _i9, _i10)                   \
00803   NS_IMPL_THREADSAFE_ADDREF(_class)                                           \
00804   NS_IMPL_THREADSAFE_RELEASE(_class)                                          \
00805   NS_IMPL_THREADSAFE_QUERY_INTERFACE10(_class, _i1, _i2, _i3, _i4, _i5, _i6,  \
00806                                        _i7, _i8, _i9, _i10)
00807 
00808 #define NS_IMPL_THREADSAFE_ISUPPORTS11(_class, _i1, _i2, _i3, _i4, _i5, _i6,  \
00809                                        _i7, _i8, _i9, _i10, _i11)             \
00810   NS_IMPL_THREADSAFE_ADDREF(_class)                                           \
00811   NS_IMPL_THREADSAFE_RELEASE(_class)                                          \
00812   NS_IMPL_THREADSAFE_QUERY_INTERFACE11(_class, _i1, _i2, _i3, _i4, _i5, _i6,  \
00813                                        _i7, _i8, _i9, _i10, _i11)
00814 
00816 // Macros for implementing nsIClassInfo-related stuff.
00818 
00819 // include here instead of at the top because it requires the nsISupport decl
00820 #include "nsIClassInfo.h"
00821 
00822 #define NS_CLASSINFO_NAME(_class) _class##_classInfoGlobal
00823 #define NS_CI_INTERFACE_GETTER_NAME(_class) _class##_GetInterfacesHelper
00824 
00825 #define NS_DECL_CI_INTERFACE_GETTER(_class)                                   \
00826   extern NS_IMETHODIMP NS_CI_INTERFACE_GETTER_NAME(_class)(PRUint32 *,        \
00827                                                            nsIID ***);
00828 
00829 #define NS_DECL_CLASSINFO(_class)                                             \
00830   NS_DECL_CI_INTERFACE_GETTER(_class)                                         \
00831   nsIClassInfo *NS_CLASSINFO_NAME(_class);
00832 
00833 #define NS_IMPL_QUERY_CLASSINFO(_class)                                       \
00834   if ( aIID.Equals(NS_GET_IID(nsIClassInfo)) ) {                              \
00835     extern nsIClassInfo *NS_CLASSINFO_NAME(_class);                           \
00836     foundInterface = NS_STATIC_CAST(nsIClassInfo*, NS_CLASSINFO_NAME(_class));\
00837   } else
00838 
00839 #define NS_CLASSINFO_HELPER_BEGIN(_class, _c)                                 \
00840 NS_IMETHODIMP                                                                 \
00841 NS_CI_INTERFACE_GETTER_NAME(_class)(PRUint32 *count, nsIID ***array)          \
00842 {                                                                             \
00843     *count = _c;                                                              \
00844     *array = (nsIID **)nsMemory::Alloc(sizeof (nsIID *) * _c);
00845 
00846 #define NS_CLASSINFO_HELPER_ENTRY(_i, _interface)                             \
00847     (*array)[_i] = (nsIID *)nsMemory::Clone(&NS_GET_IID(_interface),          \
00848                                             sizeof(nsIID));
00849 
00850 #define NS_CLASSINFO_HELPER_END                                               \
00851     return NS_OK;                                                             \
00852 }
00853 
00854 #define NS_IMPL_CI_INTERFACE_GETTER1(_class, _interface)                      \
00855    NS_CLASSINFO_HELPER_BEGIN(_class, 1)                                       \
00856      NS_CLASSINFO_HELPER_ENTRY(0, _interface)                                 \
00857    NS_CLASSINFO_HELPER_END
00858 
00859 #define NS_IMPL_QUERY_INTERFACE1_CI(_class, _i1)                              \
00860   NS_INTERFACE_MAP_BEGIN(_class)                                              \
00861     NS_INTERFACE_MAP_ENTRY(_i1)                                               \
00862     NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1)                        \
00863     NS_IMPL_QUERY_CLASSINFO(_class)                                           \
00864   NS_INTERFACE_MAP_END
00865 
00866 #define NS_IMPL_ISUPPORTS1_CI(_class, _interface)                             \
00867   NS_IMPL_ADDREF(_class)                                                      \
00868   NS_IMPL_RELEASE(_class)                                                     \
00869   NS_IMPL_QUERY_INTERFACE1_CI(_class, _interface)                             \
00870   NS_IMPL_CI_INTERFACE_GETTER1(_class, _interface)
00871 
00872 #define NS_IMPL_CI_INTERFACE_GETTER2(_class, _i1, _i2)                        \
00873    NS_CLASSINFO_HELPER_BEGIN(_class, 2)                                       \
00874      NS_CLASSINFO_HELPER_ENTRY(0, _i1)                                        \
00875      NS_CLASSINFO_HELPER_ENTRY(1, _i2)                                        \
00876    NS_CLASSINFO_HELPER_END
00877 
00878 #define NS_IMPL_QUERY_INTERFACE2_CI(_class, _i1, _i2)                         \
00879   NS_INTERFACE_MAP_BEGIN(_class)                                              \
00880     NS_INTERFACE_MAP_ENTRY(_i1)                                               \
00881     NS_INTERFACE_MAP_ENTRY(_i2)                                               \
00882     NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1)                        \
00883     NS_IMPL_QUERY_CLASSINFO(_class)                                           \
00884   NS_INTERFACE_MAP_END
00885 
00886 #define NS_IMPL_ISUPPORTS2_CI(_class, _i1, _i2)                               \
00887   NS_IMPL_ADDREF(_class)                                                      \
00888   NS_IMPL_RELEASE(_class)                                                     \
00889   NS_IMPL_QUERY_INTERFACE2_CI(_class, _i1, _i2)                               \
00890   NS_IMPL_CI_INTERFACE_GETTER2(_class, _i1, _i2)
00891 
00892 #define NS_IMPL_CI_INTERFACE_GETTER3(_class, _i1, _i2, _i3)                   \
00893    NS_CLASSINFO_HELPER_BEGIN(_class, 3)                                       \
00894      NS_CLASSINFO_HELPER_ENTRY(0, _i1)                                        \
00895      NS_CLASSINFO_HELPER_ENTRY(1, _i2)                                        \
00896      NS_CLASSINFO_HELPER_ENTRY(2, _i3)                                        \
00897    NS_CLASSINFO_HELPER_END
00898 
00899 #define NS_IMPL_QUERY_INTERFACE3_CI(_class, _i1, _i2, _i3)                    \
00900   NS_INTERFACE_MAP_BEGIN(_class)                                              \
00901     NS_INTERFACE_MAP_ENTRY(_i1)                                               \
00902     NS_INTERFACE_MAP_ENTRY(_i2)                                               \
00903     NS_INTERFACE_MAP_ENTRY(_i3)                                               \
00904     NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1)                        \
00905     NS_IMPL_QUERY_CLASSINFO(_class)                                           \
00906   NS_INTERFACE_MAP_END
00907 
00908 #define NS_IMPL_ISUPPORTS3_CI(_class, _i1, _i2, _i3)                          \
00909   NS_IMPL_ADDREF(_class)                                                      \
00910   NS_IMPL_RELEASE(_class)                                                     \
00911   NS_IMPL_QUERY_INTERFACE3_CI(_class, _i1, _i2, _i3)                          \
00912   NS_IMPL_CI_INTERFACE_GETTER3(_class, _i1, _i2, _i3)
00913 
00914 #define NS_IMPL_CI_INTERFACE_GETTER4(_class, _i1, _i2, _i3, _i4)              \
00915    NS_CLASSINFO_HELPER_BEGIN(_class, 4)                                       \
00916      NS_CLASSINFO_HELPER_ENTRY(0, _i1)                                        \
00917      NS_CLASSINFO_HELPER_ENTRY(1, _i2)                                        \
00918      NS_CLASSINFO_HELPER_ENTRY(2, _i3)                                        \
00919      NS_CLASSINFO_HELPER_ENTRY(3, _i4)                                        \
00920    NS_CLASSINFO_HELPER_END
00921 
00922 #define NS_IMPL_QUERY_INTERFACE4_CI(_class, _i1, _i2, _i3, _i4)               \
00923   NS_INTERFACE_MAP_BEGIN(_class)                                              \
00924     NS_INTERFACE_MAP_ENTRY(_i1)                                               \
00925     NS_INTERFACE_MAP_ENTRY(_i2)                                               \
00926     NS_INTERFACE_MAP_ENTRY(_i3)                                               \
00927     NS_INTERFACE_MAP_ENTRY(_i4)                                               \
00928     NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1)                        \
00929     NS_IMPL_QUERY_CLASSINFO(_class)                                           \
00930   NS_INTERFACE_MAP_END
00931 
00932 #define NS_IMPL_ISUPPORTS4_CI(_class, _i1, _i2, _i3, _i4)                     \
00933   NS_IMPL_ADDREF(_class)                                                      \
00934   NS_IMPL_RELEASE(_class)                                                     \
00935   NS_IMPL_QUERY_INTERFACE4_CI(_class, _i1, _i2, _i3, _i4)                     \
00936   NS_IMPL_CI_INTERFACE_GETTER4(_class, _i1, _i2, _i3, _i4)
00937 
00938 #define NS_IMPL_CI_INTERFACE_GETTER5(_class, _i1, _i2, _i3, _i4, _i5)         \
00939    NS_CLASSINFO_HELPER_BEGIN(_class, 5)                                       \
00940      NS_CLASSINFO_HELPER_ENTRY(0, _i1)                                        \
00941      NS_CLASSINFO_HELPER_ENTRY(1, _i2)                                        \
00942      NS_CLASSINFO_HELPER_ENTRY(2, _i3)                                        \
00943      NS_CLASSINFO_HELPER_ENTRY(3, _i4)                                        \
00944      NS_CLASSINFO_HELPER_ENTRY(4, _i5)                                        \
00945    NS_CLASSINFO_HELPER_END
00946 
00947 #define NS_IMPL_QUERY_INTERFACE5_CI(_class, _i1, _i2, _i3, _i4, _i5)          \
00948   NS_INTERFACE_MAP_BEGIN(_class)                                              \
00949     NS_INTERFACE_MAP_ENTRY(_i1)                                               \
00950     NS_INTERFACE_MAP_ENTRY(_i2)                                               \
00951     NS_INTERFACE_MAP_ENTRY(_i3)                                               \
00952     NS_INTERFACE_MAP_ENTRY(_i4)                                               \
00953     NS_INTERFACE_MAP_ENTRY(_i5)                                               \
00954     NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1)                        \
00955     NS_IMPL_QUERY_CLASSINFO(_class)                                           \
00956   NS_INTERFACE_MAP_END
00957 
00958 #define NS_IMPL_ISUPPORTS5_CI(_class, _i1, _i2, _i3, _i4, _i5)                \
00959   NS_IMPL_ADDREF(_class)                                                      \
00960   NS_IMPL_RELEASE(_class)                                                     \
00961   NS_IMPL_QUERY_INTERFACE5_CI(_class, _i1, _i2, _i3, _i4, _i5)                \
00962   NS_IMPL_CI_INTERFACE_GETTER5(_class, _i1, _i2, _i3, _i4, _i5)
00963 
00964 #define NS_IMPL_CI_INTERFACE_GETTER6(_class, _i1, _i2, _i3, _i4, _i5, _i6)    \
00965    NS_CLASSINFO_HELPER_BEGIN(_class, 6)                                       \
00966      NS_CLASSINFO_HELPER_ENTRY(0, _i1)                                        \
00967      NS_CLASSINFO_HELPER_ENTRY(1, _i2)                                        \
00968      NS_CLASSINFO_HELPER_ENTRY(2, _i3)                                        \
00969      NS_CLASSINFO_HELPER_ENTRY(3, _i4)                                        \
00970      NS_CLASSINFO_HELPER_ENTRY(4, _i5)                                        \
00971      NS_CLASSINFO_HELPER_ENTRY(5, _i6)                                        \
00972    NS_CLASSINFO_HELPER_END
00973 
00974 #define NS_IMPL_QUERY_INTERFACE6_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6)     \
00975   NS_INTERFACE_MAP_BEGIN(_class)                                              \
00976     NS_INTERFACE_MAP_ENTRY(_i1)                                               \
00977     NS_INTERFACE_MAP_ENTRY(_i2)                                               \
00978     NS_INTERFACE_MAP_ENTRY(_i3)                                               \
00979     NS_INTERFACE_MAP_ENTRY(_i4)                                               \
00980     NS_INTERFACE_MAP_ENTRY(_i5)                                               \
00981     NS_INTERFACE_MAP_ENTRY(_i6)                                               \
00982     NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1)                        \
00983     NS_IMPL_QUERY_CLASSINFO(_class)                                           \
00984   NS_INTERFACE_MAP_END
00985 
00986 #define NS_IMPL_ISUPPORTS6_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6)           \
00987   NS_IMPL_ADDREF(_class)                                                      \
00988   NS_IMPL_RELEASE(_class)                                                     \
00989   NS_IMPL_QUERY_INTERFACE6_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6)           \
00990   NS_IMPL_CI_INTERFACE_GETTER6(_class, _i1, _i2, _i3, _i4, _i5, _i6)
00991 
00992 #define NS_IMPL_CI_INTERFACE_GETTER7(_class, _i1, _i2, _i3, _i4, _i5, _i6,    \
00993                                      _i7)                                     \
00994    NS_CLASSINFO_HELPER_BEGIN(_class, 7)                                       \
00995      NS_CLASSINFO_HELPER_ENTRY(0, _i1)                                        \
00996      NS_CLASSINFO_HELPER_ENTRY(1, _i2)                                        \
00997      NS_CLASSINFO_HELPER_ENTRY(2, _i3)                                        \
00998      NS_CLASSINFO_HELPER_ENTRY(3, _i4)                                        \
00999      NS_CLASSINFO_HELPER_ENTRY(4, _i5)                                        \
01000      NS_CLASSINFO_HELPER_ENTRY(5, _i6)                                        \
01001      NS_CLASSINFO_HELPER_ENTRY(6, _i7)                                        \
01002    NS_CLASSINFO_HELPER_END
01003 
01004 #define NS_IMPL_QUERY_INTERFACE7_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6,     \
01005                                     _i7)                                      \
01006   NS_INTERFACE_MAP_BEGIN(_class)                                              \
01007     NS_INTERFACE_MAP_ENTRY(_i1)                                               \
01008     NS_INTERFACE_MAP_ENTRY(_i2)                                               \
01009     NS_INTERFACE_MAP_ENTRY(_i3)                                               \
01010     NS_INTERFACE_MAP_ENTRY(_i4)                                               \
01011     NS_INTERFACE_MAP_ENTRY(_i5)                                               \
01012     NS_INTERFACE_MAP_ENTRY(_i6)                                               \
01013     NS_INTERFACE_MAP_ENTRY(_i7)                                               \
01014     NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1)                        \
01015     NS_IMPL_QUERY_CLASSINFO(_class)                                           \
01016   NS_INTERFACE_MAP_END
01017 
01018 #define NS_IMPL_ISUPPORTS7_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7)      \
01019   NS_IMPL_ADDREF(_class)                                                      \
01020   NS_IMPL_RELEASE(_class)                                                     \
01021   NS_IMPL_QUERY_INTERFACE7_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7)      \
01022   NS_IMPL_CI_INTERFACE_GETTER7(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7)
01023 
01024 #define NS_IMPL_CI_INTERFACE_GETTER8(_class, _i1, _i2, _i3, _i4, _i5, _i6,    \
01025                                      _i7, _i8)                                \
01026    NS_CLASSINFO_HELPER_BEGIN(_class, 8)                                       \
01027      NS_CLASSINFO_HELPER_ENTRY(0, _i1)                                        \
01028      NS_CLASSINFO_HELPER_ENTRY(1, _i2)                                        \
01029      NS_CLASSINFO_HELPER_ENTRY(2, _i3)                                        \
01030      NS_CLASSINFO_HELPER_ENTRY(3, _i4)                                        \
01031      NS_CLASSINFO_HELPER_ENTRY(4, _i5)                                        \
01032      NS_CLASSINFO_HELPER_ENTRY(5, _i6)                                        \
01033      NS_CLASSINFO_HELPER_ENTRY(6, _i7)                                        \
01034      NS_CLASSINFO_HELPER_ENTRY(7, _i8)                                        \
01035    NS_CLASSINFO_HELPER_END
01036 
01037 #define NS_IMPL_QUERY_INTERFACE8_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6,     \
01038                                     _i7, _i8)                                 \
01039   NS_INTERFACE_MAP_BEGIN(_class)                                              \
01040     NS_INTERFACE_MAP_ENTRY(_i1)                                               \
01041     NS_INTERFACE_MAP_ENTRY(_i2)                                               \
01042     NS_INTERFACE_MAP_ENTRY(_i3)                                               \
01043     NS_INTERFACE_MAP_ENTRY(_i4)                                               \
01044     NS_INTERFACE_MAP_ENTRY(_i5)                                               \
01045     NS_INTERFACE_MAP_ENTRY(_i6)                                               \
01046     NS_INTERFACE_MAP_ENTRY(_i7)                                               \
01047     NS_INTERFACE_MAP_ENTRY(_i8)                                               \
01048     NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1)                        \
01049     NS_IMPL_QUERY_CLASSINFO(_class)                                           \
01050   NS_INTERFACE_MAP_END
01051 
01052 #define NS_IMPL_ISUPPORTS8_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7, _i8) \
01053   NS_IMPL_ADDREF(_class)                                                      \
01054   NS_IMPL_RELEASE(_class)                                                     \
01055   NS_IMPL_QUERY_INTERFACE8_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7, _i8) \
01056   NS_IMPL_CI_INTERFACE_GETTER8(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7, _i8)
01057 
01058 #define NS_IMPL_CI_INTERFACE_GETTER9(_class, _i1, _i2, _i3, _i4, _i5, _i6,    \
01059                                      _i7, _i8, _i9)                           \
01060    NS_CLASSINFO_HELPER_BEGIN(_class, 9)                                       \
01061      NS_CLASSINFO_HELPER_ENTRY(0, _i1)                                        \
01062      NS_CLASSINFO_HELPER_ENTRY(1, _i2)                                        \
01063      NS_CLASSINFO_HELPER_ENTRY(2, _i3)                                        \
01064      NS_CLASSINFO_HELPER_ENTRY(3, _i4)                                        \
01065      NS_CLASSINFO_HELPER_ENTRY(4, _i5)                                        \
01066      NS_CLASSINFO_HELPER_ENTRY(5, _i6)                                        \
01067      NS_CLASSINFO_HELPER_ENTRY(6, _i7)                                        \
01068      NS_CLASSINFO_HELPER_ENTRY(7, _i8)                                        \
01069      NS_CLASSINFO_HELPER_ENTRY(8, _i9)                                        \
01070    NS_CLASSINFO_HELPER_END
01071 
01072 #define NS_IMPL_QUERY_INTERFACE9_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6,     \
01073                                     _i7, _i8, _i9)                            \
01074   NS_INTERFACE_MAP_BEGIN(_class)                                              \
01075     NS_INTERFACE_MAP_ENTRY(_i1)                                               \
01076     NS_INTERFACE_MAP_ENTRY(_i2)                                               \
01077     NS_INTERFACE_MAP_ENTRY(_i3)                                               \
01078     NS_INTERFACE_MAP_ENTRY(_i4)                                               \
01079     NS_INTERFACE_MAP_ENTRY(_i5)                                               \
01080     NS_INTERFACE_MAP_ENTRY(_i6)                                               \
01081     NS_INTERFACE_MAP_ENTRY(_i7)                                               \
01082     NS_INTERFACE_MAP_ENTRY(_i8)                                               \
01083     NS_INTERFACE_MAP_ENTRY(_i9)                                               \
01084     NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1)                        \
01085     NS_IMPL_QUERY_CLASSINFO(_class)                                           \
01086   NS_INTERFACE_MAP_END
01087 
01088 #define NS_IMPL_ISUPPORTS9_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7,      \
01089                               _i8, _i9)                                       \
01090   NS_IMPL_ADDREF(_class)                                                      \
01091   NS_IMPL_RELEASE(_class)                                                     \
01092   NS_IMPL_QUERY_INTERFACE9_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7,      \
01093                               _i8, _i9)                                       \
01094   NS_IMPL_CI_INTERFACE_GETTER9(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7,     \
01095                                _i8, _i9)
01096 
01097 #define NS_IMPL_CI_INTERFACE_GETTER10(_class, _i1, _i2, _i3, _i4, _i5, _i6,   \
01098                                       _i7, _i8, _i9, _i10)                    \
01099    NS_CLASSINFO_HELPER_BEGIN(_class, 10)                                      \
01100      NS_CLASSINFO_HELPER_ENTRY(0, _i1)                                        \
01101      NS_CLASSINFO_HELPER_ENTRY(1, _i2)                                        \
01102      NS_CLASSINFO_HELPER_ENTRY(2, _i3)                                        \
01103      NS_CLASSINFO_HELPER_ENTRY(3, _i4)                                        \
01104      NS_CLASSINFO_HELPER_ENTRY(4, _i5)                                        \
01105      NS_CLASSINFO_HELPER_ENTRY(5, _i6)                                        \
01106      NS_CLASSINFO_HELPER_ENTRY(6, _i7)                                        \
01107      NS_CLASSINFO_HELPER_ENTRY(7, _i8)                                        \
01108      NS_CLASSINFO_HELPER_ENTRY(8, _i9)                                        \
01109      NS_CLASSINFO_HELPER_ENTRY(9, _i10)                                       \
01110    NS_CLASSINFO_HELPER_END
01111 
01112 #define NS_IMPL_CI_INTERFACE_GETTER11(_class, _i1, _i2, _i3, _i4, _i5, _i6,   \
01113                                       _i7, _i8, _i9, _i10, _i11)              \
01114    NS_CLASSINFO_HELPER_BEGIN(_class, 11)                                      \
01115      NS_CLASSINFO_HELPER_ENTRY(0, _i1)                                        \
01116      NS_CLASSINFO_HELPER_ENTRY(1, _i2)                                        \
01117      NS_CLASSINFO_HELPER_ENTRY(2, _i3)                                        \
01118      NS_CLASSINFO_HELPER_ENTRY(3, _i4)                                        \
01119      NS_CLASSINFO_HELPER_ENTRY(4, _i5)                                        \
01120      NS_CLASSINFO_HELPER_ENTRY(5, _i6)                                        \
01121      NS_CLASSINFO_HELPER_ENTRY(6, _i7)                                        \
01122      NS_CLASSINFO_HELPER_ENTRY(7, _i8)                                        \
01123      NS_CLASSINFO_HELPER_ENTRY(8, _i9)                                        \
01124      NS_CLASSINFO_HELPER_ENTRY(9, _i10)                                       \
01125      NS_CLASSINFO_HELPER_ENTRY(10, _i11)                                      \
01126    NS_CLASSINFO_HELPER_END
01127 
01128 #define NS_IMPL_QUERY_INTERFACE10_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6,    \
01129                                      _i7, _i8, _i9, _i10)                     \
01130   NS_INTERFACE_MAP_BEGIN(_class)                                              \
01131     NS_INTERFACE_MAP_ENTRY(_i1)                                               \
01132     NS_INTERFACE_MAP_ENTRY(_i2)                                               \
01133     NS_INTERFACE_MAP_ENTRY(_i3)                                               \
01134     NS_INTERFACE_MAP_ENTRY(_i4)                                               \
01135     NS_INTERFACE_MAP_ENTRY(_i5)                                               \
01136     NS_INTERFACE_MAP_ENTRY(_i6)                                               \
01137     NS_INTERFACE_MAP_ENTRY(_i7)                                               \
01138     NS_INTERFACE_MAP_ENTRY(_i8)                                               \
01139     NS_INTERFACE_MAP_ENTRY(_i9)                                               \
01140     NS_INTERFACE_MAP_ENTRY(_i10)                                              \
01141     NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1)                        \
01142     NS_IMPL_QUERY_CLASSINFO(_class)                                           \
01143   NS_INTERFACE_MAP_END
01144 
01145 #define NS_IMPL_QUERY_INTERFACE11_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6,    \
01146                                      _i7, _i8, _i9, _i10, _i11)               \
01147   NS_INTERFACE_MAP_BEGIN(_class)                                              \
01148     NS_INTERFACE_MAP_ENTRY(_i1)                                               \
01149     NS_INTERFACE_MAP_ENTRY(_i2)                                               \
01150     NS_INTERFACE_MAP_ENTRY(_i3)                                               \
01151     NS_INTERFACE_MAP_ENTRY(_i4)                                               \
01152     NS_INTERFACE_MAP_ENTRY(_i5)                                               \
01153     NS_INTERFACE_MAP_ENTRY(_i6)                                               \
01154     NS_INTERFACE_MAP_ENTRY(_i7)                                               \
01155     NS_INTERFACE_MAP_ENTRY(_i8)                                               \
01156     NS_INTERFACE_MAP_ENTRY(_i9)                                               \
01157     NS_INTERFACE_MAP_ENTRY(_i10)                                              \
01158     NS_INTERFACE_MAP_ENTRY(_i11)                                              \
01159     NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _i1)                        \
01160     NS_IMPL_QUERY_CLASSINFO(_class)                                           \
01161   NS_INTERFACE_MAP_END
01162 
01163 #define NS_IMPL_ISUPPORTS10_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7,     \
01164                                _i8, _i9, _i10)                                \
01165   NS_IMPL_ADDREF(_class)                                                      \
01166   NS_IMPL_RELEASE(_class)                                                     \
01167   NS_IMPL_QUERY_INTERFACE10_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7,     \
01168                                _i8, _i9, _i10)                                \
01169   NS_IMPL_CI_INTERFACE_GETTER10(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7,    \
01170                                 _i8, _i9, _i10)
01171 
01172 #define NS_IMPL_ISUPPORTS11_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7,     \
01173                                _i8, _i9, _i10, _i11)                          \
01174   NS_IMPL_ADDREF(_class)                                                      \
01175   NS_IMPL_RELEASE(_class)                                                     \
01176   NS_IMPL_QUERY_INTERFACE11_CI(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7,     \
01177                                _i8, _i9, _i10, _i11)                          \
01178   NS_IMPL_CI_INTERFACE_GETTER11(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7,    \
01179                                 _i8, _i9, _i10, _i11)
01180 
01181 #define NS_INTERFACE_MAP_END_THREADSAFE NS_IMPL_QUERY_TAIL_GUTS
01182 
01183 #endif