/src/mozilla-central/xpcom/base/nsCOMPtr.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef nsCOMPtr_h___ |
8 | | #define nsCOMPtr_h___ |
9 | | |
10 | | /* |
11 | | * Having problems? |
12 | | * |
13 | | * See the User Manual at: |
14 | | * http://www.mozilla.org/projects/xpcom/nsCOMPtr.html |
15 | | * |
16 | | * |
17 | | * nsCOMPtr |
18 | | * better than a raw pointer |
19 | | * for owning objects |
20 | | * -- scc |
21 | | */ |
22 | | |
23 | | #include "mozilla/AlreadyAddRefed.h" |
24 | | #include "mozilla/Assertions.h" |
25 | | #include "mozilla/Attributes.h" |
26 | | #include "mozilla/Move.h" |
27 | | #include "mozilla/TypeTraits.h" |
28 | | |
29 | | #include "nsDebug.h" // for |NS_ASSERTION| |
30 | | #include "nsISupportsUtils.h" // for |nsresult|, |NS_ADDREF|, |NS_GET_TEMPLATE_IID| et al |
31 | | #include "mozilla/RefPtr.h" |
32 | | |
33 | | #include "nsCycleCollectionNoteChild.h" |
34 | | |
35 | | |
36 | | /* |
37 | | * WARNING: This file defines several macros for internal use only. These |
38 | | * macros begin with the prefix |NSCAP_|. Do not use these macros in your own |
39 | | * code. They are for internal use only for cross-platform compatibility, and |
40 | | * are subject to change without notice. |
41 | | */ |
42 | | |
43 | | |
44 | | #ifdef _MSC_VER |
45 | | // Under VC++, we win by inlining StartAssignment. |
46 | | #define NSCAP_FEATURE_INLINE_STARTASSIGNMENT |
47 | | |
48 | | // Also under VC++, at the highest warning level, we are overwhelmed with |
49 | | // warnings about (unused) inline functions being removed. This is to be |
50 | | // expected with templates, so we disable the warning. |
51 | | #pragma warning( disable: 4514 ) |
52 | | #endif |
53 | | |
54 | | #define NSCAP_FEATURE_USE_BASE |
55 | | |
56 | | #ifdef DEBUG |
57 | | #define NSCAP_FEATURE_TEST_DONTQUERY_CASES |
58 | | #undef NSCAP_FEATURE_USE_BASE |
59 | | #endif |
60 | | |
61 | | #ifdef __GNUC__ |
62 | | // Our use of nsCOMPtr_base::mRawPtr violates the C++ standard's aliasing |
63 | | // rules. Mark it with the may_alias attribute so that gcc 3.3 and higher |
64 | | // don't reorder instructions based on aliasing assumptions for |
65 | | // this variable. Fortunately, gcc versions < 3.3 do not do any |
66 | | // optimizations that break nsCOMPtr. |
67 | | |
68 | | #define NS_MAY_ALIAS_PTR(t) t* __attribute__((__may_alias__)) |
69 | | #else |
70 | | #define NS_MAY_ALIAS_PTR(t) t* |
71 | | #endif |
72 | | |
73 | | #if defined(NSCAP_DISABLE_DEBUG_PTR_TYPES) |
74 | | #define NSCAP_FEATURE_USE_BASE |
75 | | #endif |
76 | | |
77 | | /* |
78 | | * The following three macros (NSCAP_ADDREF, NSCAP_RELEASE, and |
79 | | * NSCAP_LOG_ASSIGNMENT) allow external clients the ability to add logging or |
80 | | * other interesting debug facilities. In fact, if you want |nsCOMPtr| to |
81 | | * participate in the standard logging facility, you provide |
82 | | * (e.g., in "nsISupportsImpl.h") suitable definitions |
83 | | * |
84 | | * #define NSCAP_ADDREF(this, ptr) NS_ADDREF(ptr) |
85 | | * #define NSCAP_RELEASE(this, ptr) NS_RELEASE(ptr) |
86 | | */ |
87 | | |
88 | | #ifndef NSCAP_ADDREF |
89 | 10.5M | #define NSCAP_ADDREF(this, ptr) (ptr)->AddRef() |
90 | | #endif |
91 | | |
92 | | #ifndef NSCAP_RELEASE |
93 | | #define NSCAP_RELEASE(this, ptr) (ptr)->Release() |
94 | | #endif |
95 | | |
96 | | // Clients can define |NSCAP_LOG_ASSIGNMENT| to perform logging. |
97 | | #ifdef NSCAP_LOG_ASSIGNMENT |
98 | | // Remember that |NSCAP_LOG_ASSIGNMENT| was defined by some client so that we |
99 | | // know to instantiate |~nsGetterAddRefs| in turn to note the external |
100 | | // assignment into the |nsCOMPtr|. |
101 | | #define NSCAP_LOG_EXTERNAL_ASSIGNMENT |
102 | | #else |
103 | | // ...otherwise, just strip it out of the code |
104 | | #define NSCAP_LOG_ASSIGNMENT(this, ptr) |
105 | | #endif |
106 | | |
107 | | #ifndef NSCAP_LOG_RELEASE |
108 | | #define NSCAP_LOG_RELEASE(this, ptr) |
109 | | #endif |
110 | | |
111 | | namespace mozilla { |
112 | | template<class T> class OwningNonNull; |
113 | | } // namespace mozilla |
114 | | |
115 | | template<class T> |
116 | | inline already_AddRefed<T> |
117 | | dont_AddRef(T* aRawPtr) |
118 | 7.51M | { |
119 | 7.51M | return already_AddRefed<T>(aRawPtr); |
120 | 7.51M | } already_AddRefed<nsISupports> dont_AddRef<nsISupports>(nsISupports*) Line | Count | Source | 118 | 7.51M | { | 119 | 7.51M | return already_AddRefed<T>(aRawPtr); | 120 | 7.51M | } |
Unexecuted instantiation: already_AddRefed<nsIFile> dont_AddRef<nsIFile>(nsIFile*) Unexecuted instantiation: already_AddRefed<mozilla::dom::PaymentRequestParent> dont_AddRef<mozilla::dom::PaymentRequestParent>(mozilla::dom::PaymentRequestParent*) Unexecuted instantiation: already_AddRefed<TestCOMPtr::IFoo> dont_AddRef<TestCOMPtr::IFoo>(TestCOMPtr::IFoo*) Unexecuted instantiation: already_AddRefed<TestNsRefPtr::Foo> dont_AddRef<TestNsRefPtr::Foo>(TestNsRefPtr::Foo*) |
121 | | |
122 | | template<class T> |
123 | | inline already_AddRefed<T>&& |
124 | | dont_AddRef(already_AddRefed<T>&& aAlreadyAddRefedPtr) |
125 | | { |
126 | | return std::move(aAlreadyAddRefedPtr); |
127 | | } |
128 | | |
129 | | |
130 | | /* |
131 | | * An nsCOMPtr_helper transforms commonly called getters into typesafe forms |
132 | | * that are more convenient to call, and more efficient to use with |nsCOMPtr|s. |
133 | | * Good candidates for helpers are |QueryInterface()|, |CreateInstance()|, etc. |
134 | | * |
135 | | * Here are the rules for a helper: |
136 | | * - it implements |operator()| to produce an interface pointer |
137 | | * - (except for its name) |operator()| is a valid [XP]COM `getter' |
138 | | * - the interface pointer that it returns is already |AddRef()|ed (as from |
139 | | * any good getter) |
140 | | * - it matches the type requested with the supplied |nsIID| argument |
141 | | * - its constructor provides an optional |nsresult*| that |operator()| can |
142 | | * fill in with an error when it is executed |
143 | | * |
144 | | * See |class nsGetInterface| for an example. |
145 | | */ |
146 | | class MOZ_STACK_CLASS nsCOMPtr_helper |
147 | | { |
148 | | public: |
149 | | virtual nsresult NS_FASTCALL operator()(const nsIID&, void**) const = 0; |
150 | | }; |
151 | | |
152 | | /* |
153 | | * nsQueryInterface could have been implemented as an nsCOMPtr_helper to avoid |
154 | | * adding specialized machinery in nsCOMPtr, but do_QueryInterface is called |
155 | | * often enough that the codesize savings are big enough to warrant the |
156 | | * specialcasing. |
157 | | */ |
158 | | class MOZ_STACK_CLASS nsQueryInterface final |
159 | | { |
160 | | public: |
161 | | explicit |
162 | 27.6M | nsQueryInterface(nsISupports* aRawPtr) : mRawPtr(aRawPtr) {} |
163 | | |
164 | | nsresult NS_FASTCALL operator()(const nsIID& aIID, void**) const; |
165 | | |
166 | | private: |
167 | | nsISupports* MOZ_OWNING_REF mRawPtr; |
168 | | }; |
169 | | |
170 | | class nsQueryInterfaceWithError final |
171 | | { |
172 | | public: |
173 | | nsQueryInterfaceWithError(nsISupports* aRawPtr, nsresult* aError) |
174 | | : mRawPtr(aRawPtr) |
175 | | , mErrorPtr(aError) |
176 | | { |
177 | | } |
178 | | |
179 | | nsresult NS_FASTCALL operator()(const nsIID& aIID, void**) const; |
180 | | |
181 | | private: |
182 | | nsISupports* MOZ_OWNING_REF mRawPtr; |
183 | | nsresult* mErrorPtr; |
184 | | }; |
185 | | |
186 | | inline nsQueryInterface |
187 | | do_QueryInterface(nsISupports* aRawPtr) |
188 | 27.6M | { |
189 | 27.6M | return nsQueryInterface(aRawPtr); |
190 | 27.6M | } |
191 | | |
192 | | inline nsQueryInterfaceWithError |
193 | | do_QueryInterface(nsISupports* aRawPtr, nsresult* aError) |
194 | | { |
195 | | return nsQueryInterfaceWithError(aRawPtr, aError); |
196 | | } |
197 | | |
198 | | template<class T> |
199 | | inline void |
200 | | do_QueryInterface(already_AddRefed<T>&) |
201 | | { |
202 | | // This signature exists solely to _stop_ you from doing the bad thing. |
203 | | // Saying |do_QueryInterface()| on a pointer that is not otherwise owned by |
204 | | // someone else is an automatic leak. See bug 8221. |
205 | | } |
206 | | |
207 | | template<class T> |
208 | | inline void |
209 | | do_QueryInterface(already_AddRefed<T>&, nsresult*) |
210 | | { |
211 | | // This signature exists solely to _stop_ you from doing the bad thing. |
212 | | // Saying |do_QueryInterface()| on a pointer that is not otherwise owned by |
213 | | // someone else is an automatic leak. See bug 8221. |
214 | | } |
215 | | |
216 | | |
217 | | //////////////////////////////////////////////////////////////////////////// |
218 | | // Using servicemanager with COMPtrs |
219 | | class nsGetServiceByCID final |
220 | | { |
221 | | public: |
222 | | explicit nsGetServiceByCID(const nsCID& aCID) : mCID(aCID) {} |
223 | | |
224 | | nsresult NS_FASTCALL operator()(const nsIID&, void**) const; |
225 | | |
226 | | private: |
227 | | const nsCID& mCID; |
228 | | }; |
229 | | |
230 | | class nsGetServiceByCIDWithError final |
231 | | { |
232 | | public: |
233 | | nsGetServiceByCIDWithError(const nsCID& aCID, nsresult* aErrorPtr) |
234 | | : mCID(aCID) |
235 | | , mErrorPtr(aErrorPtr) |
236 | | { |
237 | | } |
238 | | |
239 | | nsresult NS_FASTCALL operator()(const nsIID&, void**) const; |
240 | | |
241 | | private: |
242 | | const nsCID& mCID; |
243 | | nsresult* mErrorPtr; |
244 | | }; |
245 | | |
246 | | class nsGetServiceByContractID final |
247 | | { |
248 | | public: |
249 | | explicit nsGetServiceByContractID(const char* aContractID) |
250 | | : mContractID(aContractID) |
251 | | { |
252 | | } |
253 | | |
254 | | nsresult NS_FASTCALL operator()(const nsIID&, void**) const; |
255 | | |
256 | | private: |
257 | | const char* mContractID; |
258 | | }; |
259 | | |
260 | | class nsGetServiceByContractIDWithError final |
261 | | { |
262 | | public: |
263 | | nsGetServiceByContractIDWithError(const char* aContractID, nsresult* aErrorPtr) |
264 | | : mContractID(aContractID) |
265 | | , mErrorPtr(aErrorPtr) |
266 | | { |
267 | | } |
268 | | |
269 | | nsresult NS_FASTCALL operator()(const nsIID&, void**) const; |
270 | | |
271 | | private: |
272 | | const char* mContractID; |
273 | | nsresult* mErrorPtr; |
274 | | }; |
275 | | |
276 | | class nsIWeakReference; |
277 | | |
278 | | // Weak references |
279 | | class MOZ_STACK_CLASS nsQueryReferent final |
280 | | { |
281 | | public: |
282 | | nsQueryReferent(nsIWeakReference* aWeakPtr, nsresult* aError) |
283 | | : mWeakPtr(aWeakPtr) |
284 | | , mErrorPtr(aError) |
285 | | { |
286 | | } |
287 | | |
288 | | nsresult NS_FASTCALL operator()(const nsIID& aIID, void**) const; |
289 | | |
290 | | private: |
291 | | nsIWeakReference* MOZ_NON_OWNING_REF mWeakPtr; |
292 | | nsresult* mErrorPtr; |
293 | | }; |
294 | | |
295 | | /** |
296 | | * Factors implementation for all template versions of nsCOMPtr. |
297 | | * |
298 | | * Here's the way people normally do things like this: |
299 | | * |
300 | | * template<class T> class Foo { ... }; |
301 | | * template<> class Foo<void*> { ... }; |
302 | | * template<class T> class Foo<T*> : private Foo<void*> { ... }; |
303 | | */ |
304 | | class nsCOMPtr_base |
305 | | { |
306 | | public: |
307 | | explicit nsCOMPtr_base(nsISupports* aRawPtr = nullptr) : mRawPtr(aRawPtr) {} |
308 | | |
309 | | NS_CONSTRUCTOR_FASTCALL ~nsCOMPtr_base() |
310 | | { |
311 | | NSCAP_LOG_RELEASE(this, mRawPtr); |
312 | | if (mRawPtr) { |
313 | | NSCAP_RELEASE(this, mRawPtr); |
314 | | } |
315 | | } |
316 | | |
317 | | void NS_FASTCALL |
318 | | assign_with_AddRef(nsISupports*); |
319 | | void NS_FASTCALL |
320 | | assign_from_qi(const nsQueryInterface, const nsIID&); |
321 | | void NS_FASTCALL |
322 | | assign_from_qi_with_error(const nsQueryInterfaceWithError&, const nsIID&); |
323 | | void NS_FASTCALL |
324 | | assign_from_gs_cid(const nsGetServiceByCID, const nsIID&); |
325 | | void NS_FASTCALL |
326 | | assign_from_gs_cid_with_error(const nsGetServiceByCIDWithError&, const nsIID&); |
327 | | void NS_FASTCALL |
328 | | assign_from_gs_contractid(const nsGetServiceByContractID, const nsIID&); |
329 | | void NS_FASTCALL |
330 | | assign_from_gs_contractid_with_error(const nsGetServiceByContractIDWithError&, |
331 | | const nsIID&); |
332 | | void NS_FASTCALL |
333 | | assign_from_query_referent(const nsQueryReferent&, const nsIID&); |
334 | | void NS_FASTCALL |
335 | | assign_from_helper(const nsCOMPtr_helper&, const nsIID&); |
336 | | void** NS_FASTCALL |
337 | | begin_assignment(); |
338 | | |
339 | | protected: |
340 | | NS_MAY_ALIAS_PTR(nsISupports) MOZ_OWNING_REF mRawPtr; |
341 | | |
342 | | void assign_assuming_AddRef(nsISupports* aNewPtr) |
343 | | { |
344 | | // |AddRef()|ing the new value (before entering this function) before |
345 | | // |Release()|ing the old lets us safely ignore the self-assignment case. |
346 | | // We must, however, be careful only to |Release()| _after_ doing the |
347 | | // assignment, in case the |Release()| leads to our _own_ destruction, |
348 | | // which would, in turn, cause an incorrect second |Release()| of our old |
349 | | // pointer. Thank <waterson@netscape.com> for discovering this. |
350 | | nsISupports* oldPtr = mRawPtr; |
351 | | mRawPtr = aNewPtr; |
352 | | NSCAP_LOG_ASSIGNMENT(this, aNewPtr); |
353 | | NSCAP_LOG_RELEASE(this, oldPtr); |
354 | | if (oldPtr) { |
355 | | NSCAP_RELEASE(this, oldPtr); |
356 | | } |
357 | | } |
358 | | }; |
359 | | |
360 | | // template<class T> class nsGetterAddRefs; |
361 | | |
362 | | // Helper for assert_validity method |
363 | | template<class T> |
364 | | char (&TestForIID(decltype(&NS_GET_TEMPLATE_IID(T))))[2]; |
365 | | template<class T> |
366 | | char TestForIID(...); |
367 | | |
368 | | template<class T> |
369 | | class MOZ_IS_REFPTR nsCOMPtr final |
370 | | #ifdef NSCAP_FEATURE_USE_BASE |
371 | | : private nsCOMPtr_base |
372 | | #endif |
373 | | { |
374 | | |
375 | | #ifdef NSCAP_FEATURE_USE_BASE |
376 | | #define NSCAP_CTOR_BASE(x) nsCOMPtr_base(x) |
377 | | #else |
378 | | #define NSCAP_CTOR_BASE(x) mRawPtr(x) |
379 | | |
380 | | private: |
381 | | void assign_with_AddRef(nsISupports*); |
382 | | void assign_from_qi(const nsQueryInterface, const nsIID&); |
383 | | void assign_from_qi_with_error(const nsQueryInterfaceWithError&, const nsIID&); |
384 | | void assign_from_gs_cid(const nsGetServiceByCID, const nsIID&); |
385 | | void assign_from_gs_cid_with_error(const nsGetServiceByCIDWithError&, |
386 | | const nsIID&); |
387 | | void assign_from_gs_contractid(const nsGetServiceByContractID, const nsIID&); |
388 | | void assign_from_gs_contractid_with_error( |
389 | | const nsGetServiceByContractIDWithError&, const nsIID&); |
390 | | void assign_from_query_referent(const nsQueryReferent&, const nsIID&); |
391 | | void assign_from_helper(const nsCOMPtr_helper&, const nsIID&); |
392 | | void** begin_assignment(); |
393 | | |
394 | | void assign_assuming_AddRef(T* aNewPtr) |
395 | | { |
396 | | T* oldPtr = mRawPtr; |
397 | | mRawPtr = aNewPtr; |
398 | | NSCAP_LOG_ASSIGNMENT(this, aNewPtr); |
399 | | NSCAP_LOG_RELEASE(this, oldPtr); |
400 | | if (oldPtr) { |
401 | | NSCAP_RELEASE(this, oldPtr); |
402 | | } |
403 | | } |
404 | | |
405 | | private: |
406 | | T* MOZ_OWNING_REF mRawPtr; |
407 | | #endif |
408 | | |
409 | | void assert_validity() |
410 | 68.2M | { |
411 | 68.2M | static_assert(1 < sizeof(TestForIID<T>(nullptr)), "nsCOMPtr only works " |
412 | 68.2M | "for types with IIDs. Either use RefPtr; add an IID to " |
413 | 68.2M | "your type with NS_DECLARE_STATIC_IID_ACCESSOR/" |
414 | 68.2M | "NS_DEFINE_STATIC_IID_ACCESSOR; or make the nsCOMPtr point " |
415 | 68.2M | "to a base class with an IID."); |
416 | 68.2M | } nsCOMPtr<nsIObserver>::assert_validity() Line | Count | Source | 410 | 155 | { | 411 | 155 | static_assert(1 < sizeof(TestForIID<T>(nullptr)), "nsCOMPtr only works " | 412 | 155 | "for types with IIDs. Either use RefPtr; add an IID to " | 413 | 155 | "your type with NS_DECLARE_STATIC_IID_ACCESSOR/" | 414 | 155 | "NS_DEFINE_STATIC_IID_ACCESSOR; or make the nsCOMPtr point " | 415 | 155 | "to a base class with an IID."); | 416 | 155 | } |
nsCOMPtr<nsITimer>::assert_validity() Line | Count | Source | 410 | 232 | { | 411 | 232 | static_assert(1 < sizeof(TestForIID<T>(nullptr)), "nsCOMPtr only works " | 412 | 232 | "for types with IIDs. Either use RefPtr; add an IID to " | 413 | 232 | "your type with NS_DECLARE_STATIC_IID_ACCESSOR/" | 414 | 232 | "NS_DEFINE_STATIC_IID_ACCESSOR; or make the nsCOMPtr point " | 415 | 232 | "to a base class with an IID."); | 416 | 232 | } |
nsCOMPtr<nsIRunnable>::assert_validity() Line | Count | Source | 410 | 708 | { | 411 | 708 | static_assert(1 < sizeof(TestForIID<T>(nullptr)), "nsCOMPtr only works " | 412 | 708 | "for types with IIDs. Either use RefPtr; add an IID to " | 413 | 708 | "your type with NS_DECLARE_STATIC_IID_ACCESSOR/" | 414 | 708 | "NS_DEFINE_STATIC_IID_ACCESSOR; or make the nsCOMPtr point " | 415 | 708 | "to a base class with an IID."); | 416 | 708 | } |
nsCOMPtr<nsIGlobalObject>::assert_validity() Line | Count | Source | 410 | 58.4M | { | 411 | 58.4M | static_assert(1 < sizeof(TestForIID<T>(nullptr)), "nsCOMPtr only works " | 412 | 58.4M | "for types with IIDs. Either use RefPtr; add an IID to " | 413 | 58.4M | "your type with NS_DECLARE_STATIC_IID_ACCESSOR/" | 414 | 58.4M | "NS_DEFINE_STATIC_IID_ACCESSOR; or make the nsCOMPtr point " | 415 | 58.4M | "to a base class with an IID."); | 416 | 58.4M | } |
nsCOMPtr<nsIObserverService>::assert_validity() Line | Count | Source | 410 | 161 | { | 411 | 161 | static_assert(1 < sizeof(TestForIID<T>(nullptr)), "nsCOMPtr only works " | 412 | 161 | "for types with IIDs. Either use RefPtr; add an IID to " | 413 | 161 | "your type with NS_DECLARE_STATIC_IID_ACCESSOR/" | 414 | 161 | "NS_DEFINE_STATIC_IID_ACCESSOR; or make the nsCOMPtr point " | 415 | 161 | "to a base class with an IID."); | 416 | 161 | } |
nsCOMPtr<nsIInterfaceRequestor>::assert_validity() Line | Count | Source | 410 | 10 | { | 411 | 10 | static_assert(1 < sizeof(TestForIID<T>(nullptr)), "nsCOMPtr only works " | 412 | 10 | "for types with IIDs. Either use RefPtr; add an IID to " | 413 | 10 | "your type with NS_DECLARE_STATIC_IID_ACCESSOR/" | 414 | 10 | "NS_DEFINE_STATIC_IID_ACCESSOR; or make the nsCOMPtr point " | 415 | 10 | "to a base class with an IID."); | 416 | 10 | } |
nsCOMPtr<mozilla::dom::Exception>::assert_validity() Line | Count | Source | 410 | 3 | { | 411 | 3 | static_assert(1 < sizeof(TestForIID<T>(nullptr)), "nsCOMPtr only works " | 412 | 3 | "for types with IIDs. Either use RefPtr; add an IID to " | 413 | 3 | "your type with NS_DECLARE_STATIC_IID_ACCESSOR/" | 414 | 3 | "NS_DEFINE_STATIC_IID_ACCESSOR; or make the nsCOMPtr point " | 415 | 3 | "to a base class with an IID."); | 416 | 3 | } |
Unexecuted instantiation: nsCOMPtr<nsICycleCollectorLogSink>::assert_validity() nsCOMPtr<nsIConsoleService>::assert_validity() Line | Count | Source | 410 | 8.90k | { | 411 | 8.90k | static_assert(1 < sizeof(TestForIID<T>(nullptr)), "nsCOMPtr only works " | 412 | 8.90k | "for types with IIDs. Either use RefPtr; add an IID to " | 413 | 8.90k | "your type with NS_DECLARE_STATIC_IID_ACCESSOR/" | 414 | 8.90k | "NS_DEFINE_STATIC_IID_ACCESSOR; or make the nsCOMPtr point " | 415 | 8.90k | "to a base class with an IID."); | 416 | 8.90k | } |
nsCOMPtr<nsIConsoleMessage>::assert_validity() Line | Count | Source | 410 | 17.8k | { | 411 | 17.8k | static_assert(1 < sizeof(TestForIID<T>(nullptr)), "nsCOMPtr only works " | 412 | 17.8k | "for types with IIDs. Either use RefPtr; add an IID to " | 413 | 17.8k | "your type with NS_DECLARE_STATIC_IID_ACCESSOR/" | 414 | 17.8k | "NS_DEFINE_STATIC_IID_ACCESSOR; or make the nsCOMPtr point " | 415 | 17.8k | "to a base class with an IID."); | 416 | 17.8k | } |
Unexecuted instantiation: nsCOMPtr<nsIConsoleListener>::assert_validity() Unexecuted instantiation: nsCOMPtr<nsIScriptError>::assert_validity() Unexecuted instantiation: nsCOMPtr<nsISupportsPRUint64>::assert_validity() Unexecuted instantiation: nsCOMPtr<nsICycleCollectorListener>::assert_validity() Unexecuted instantiation: nsCOMPtr<nsIMemory>::assert_validity() Unexecuted instantiation: nsCOMPtr<nsIMemoryInfoDumper>::assert_validity() nsCOMPtr<nsIMemoryReporterManager>::assert_validity() Line | Count | Source | 410 | 73 | { | 411 | 73 | static_assert(1 < sizeof(TestForIID<T>(nullptr)), "nsCOMPtr only works " | 412 | 73 | "for types with IIDs. Either use RefPtr; add an IID to " | 413 | 73 | "your type with NS_DECLARE_STATIC_IID_ACCESSOR/" | 414 | 73 | "NS_DEFINE_STATIC_IID_ACCESSOR; or make the nsCOMPtr point " | 415 | 73 | "to a base class with an IID."); | 416 | 73 | } |
Unexecuted instantiation: nsCOMPtr<nsIFinishDumpingCallback>::assert_validity() Unexecuted instantiation: nsCOMPtr<nsIVariant>::assert_validity() nsCOMPtr<nsISimpleEnumerator>::assert_validity() Line | Count | Source | 410 | 52 | { | 411 | 52 | static_assert(1 < sizeof(TestForIID<T>(nullptr)), "nsCOMPtr only works " | 412 | 52 | "for types with IIDs. Either use RefPtr; add an IID to " | 413 | 52 | "your type with NS_DECLARE_STATIC_IID_ACCESSOR/" | 414 | 52 | "NS_DEFINE_STATIC_IID_ACCESSOR; or make the nsCOMPtr point " | 415 | 52 | "to a base class with an IID."); | 416 | 52 | } |
Unexecuted instantiation: nsCOMPtr<nsIDumpGCAndCCLogsCallback>::assert_validity() Unexecuted instantiation: nsCOMPtr<nsIFinishReportingCallback>::assert_validity() nsCOMPtr<nsIMemoryReporter>::assert_validity() Line | Count | Source | 410 | 74 | { | 411 | 74 | static_assert(1 < sizeof(TestForIID<T>(nullptr)), "nsCOMPtr only works " | 412 | 74 | "for types with IIDs. Either use RefPtr; add an IID to " | 413 | 74 | "your type with NS_DECLARE_STATIC_IID_ACCESSOR/" | 414 | 74 | "NS_DEFINE_STATIC_IID_ACCESSOR; or make the nsCOMPtr point " | 415 | 74 | "to a base class with an IID."); | 416 | 74 | } |
Unexecuted instantiation: nsCOMPtr<nsIHandleReportCallback>::assert_validity() nsCOMPtr<nsIXPConnectWrappedJS>::assert_validity() Line | Count | Source | 410 | 9.74M | { | 411 | 9.74M | static_assert(1 < sizeof(TestForIID<T>(nullptr)), "nsCOMPtr only works " | 412 | 9.74M | "for types with IIDs. Either use RefPtr; add an IID to " | 413 | 9.74M | "your type with NS_DECLARE_STATIC_IID_ACCESSOR/" | 414 | 9.74M | "NS_DEFINE_STATIC_IID_ACCESSOR; or make the nsCOMPtr point " | 415 | 9.74M | "to a base class with an IID."); | 416 | 9.74M | } |
nsCOMPtr<nsISupportsWeakReference>::assert_validity() Line | Count | Source | 410 | 231 | { | 411 | 231 | static_assert(1 < sizeof(TestForIID<T>(nullptr)), "nsCOMPtr only works " | 412 | 231 | "for types with IIDs. Either use RefPtr; add an IID to " | 413 | 231 | "your type with NS_DECLARE_STATIC_IID_ACCESSOR/" | 414 | 231 | "NS_DEFINE_STATIC_IID_ACCESSOR; or make the nsCOMPtr point " | 415 | 231 | "to a base class with an IID."); | 416 | 231 | } |
Unexecuted instantiation: nsCOMPtr<nsIWebBrowser>::assert_validity() Unexecuted instantiation: nsCOMPtr<nsIPrintSession>::assert_validity() Unexecuted instantiation: nsCOMPtr<nsIDroppedLinkHandler>::assert_validity() Unexecuted instantiation: nsCOMPtr<nsIXULBrowserWindow>::assert_validity() Unexecuted instantiation: nsCOMPtr<nsILoginManagerPrompter>::assert_validity() Unexecuted instantiation: nsCOMPtr<nsIProfilerStartParams>::assert_validity() Unexecuted instantiation: nsCOMPtr<IFoo>::assert_validity() Unexecuted instantiation: nsCOMPtr<IBar>::assert_validity() Unexecuted instantiation: nsCOMPtr<TestCOMPtr::IFoo>::assert_validity() Unexecuted instantiation: nsCOMPtr<TestCOMPtr::IBar>::assert_validity() Unexecuted instantiation: nsCOMPtr<TestHashtables::IFoo>::assert_validity() |
417 | | |
418 | | public: |
419 | | typedef T element_type; |
420 | | |
421 | | #ifndef NSCAP_FEATURE_USE_BASE |
422 | | ~nsCOMPtr() |
423 | | { |
424 | | NSCAP_LOG_RELEASE(this, mRawPtr); |
425 | | if (mRawPtr) { |
426 | | NSCAP_RELEASE(this, mRawPtr); |
427 | | } |
428 | | } |
429 | | #endif |
430 | | |
431 | | #ifdef NSCAP_FEATURE_TEST_DONTQUERY_CASES |
432 | | void Assert_NoQueryNeeded() |
433 | | { |
434 | | if (mRawPtr) { |
435 | | nsCOMPtr<T> query_result(do_QueryInterface(mRawPtr)); |
436 | | NS_ASSERTION(query_result.get() == mRawPtr, "QueryInterface needed"); |
437 | | } |
438 | | } |
439 | | |
440 | | #define NSCAP_ASSERT_NO_QUERY_NEEDED() Assert_NoQueryNeeded(); |
441 | | #else |
442 | | #define NSCAP_ASSERT_NO_QUERY_NEEDED() |
443 | | #endif |
444 | | |
445 | | |
446 | | // Constructors |
447 | | |
448 | | nsCOMPtr() |
449 | | : NSCAP_CTOR_BASE(nullptr) |
450 | 23.7k | { |
451 | 23.7k | assert_validity(); |
452 | 23.7k | NSCAP_LOG_ASSIGNMENT(this, nullptr); |
453 | 23.7k | } Unexecuted instantiation: nsCOMPtr<nsIGlobalObject>::nsCOMPtr() nsCOMPtr<nsIRunnable>::nsCOMPtr() Line | Count | Source | 450 | 53 | { | 451 | 53 | assert_validity(); | 452 | 53 | NSCAP_LOG_ASSIGNMENT(this, nullptr); | 453 | 53 | } |
nsCOMPtr<mozilla::dom::Exception>::nsCOMPtr() Line | Count | Source | 450 | 3 | { | 451 | 3 | assert_validity(); | 452 | 3 | NSCAP_LOG_ASSIGNMENT(this, nullptr); | 453 | 3 | } |
Unexecuted instantiation: nsCOMPtr<nsIConsoleListener>::nsCOMPtr() nsCOMPtr<nsIConsoleMessage>::nsCOMPtr() Line | Count | Source | 450 | 8.90k | { | 451 | 8.90k | assert_validity(); | 452 | 8.90k | NSCAP_LOG_ASSIGNMENT(this, nullptr); | 453 | 8.90k | } |
nsCOMPtr<nsIEventTarget>::nsCOMPtr() Line | Count | Source | 450 | 14.5k | { | 451 | 14.5k | assert_validity(); | 452 | 14.5k | NSCAP_LOG_ASSIGNMENT(this, nullptr); | 453 | 14.5k | } |
Unexecuted instantiation: nsCOMPtr<nsIMemory>::nsCOMPtr() Unexecuted instantiation: nsCOMPtr<nsIVariant>::nsCOMPtr() nsCOMPtr<nsISimpleEnumerator>::nsCOMPtr() Line | Count | Source | 450 | 32 | { | 451 | 32 | assert_validity(); | 452 | 32 | NSCAP_LOG_ASSIGNMENT(this, nullptr); | 453 | 32 | } |
Unexecuted instantiation: nsCOMPtr<nsIObserver>::nsCOMPtr() nsCOMPtr<nsITimer>::nsCOMPtr() Line | Count | Source | 450 | 232 | { | 451 | 232 | assert_validity(); | 452 | 232 | NSCAP_LOG_ASSIGNMENT(this, nullptr); | 453 | 232 | } |
Unexecuted instantiation: nsCOMPtr<nsICycleCollectorListener>::nsCOMPtr() Unexecuted instantiation: nsCOMPtr<nsICycleCollectorLogSink>::nsCOMPtr() Unexecuted instantiation: nsCOMPtr<nsIFilePicker>::nsCOMPtr() Unexecuted instantiation: nsCOMPtr<nsIColorPicker>::nsCOMPtr() Unexecuted instantiation: nsCOMPtr<nsIXULBrowserWindow>::nsCOMPtr() Unexecuted instantiation: nsCOMPtr<TestCOMPtr::IBar>::nsCOMPtr() Unexecuted instantiation: nsCOMPtr<TestCOMPtr::IFoo>::nsCOMPtr() Unexecuted instantiation: nsCOMPtr<TestHashtables::IFoo>::nsCOMPtr() Unexecuted instantiation: nsCOMPtr<nsICloneableInputStream>::nsCOMPtr() Unexecuted instantiation: nsCOMPtr<nsIThreadManager>::nsCOMPtr() |
454 | | |
455 | | MOZ_IMPLICIT nsCOMPtr(decltype(nullptr)) |
456 | | : NSCAP_CTOR_BASE(nullptr) |
457 | | { |
458 | | assert_validity(); |
459 | | NSCAP_LOG_ASSIGNMENT(this, nullptr); |
460 | | } |
461 | | |
462 | | nsCOMPtr(const nsCOMPtr<T>& aSmartPtr) |
463 | | : NSCAP_CTOR_BASE(aSmartPtr.mRawPtr) |
464 | 0 | { |
465 | 0 | assert_validity(); |
466 | 0 | if (mRawPtr) { |
467 | 0 | NSCAP_ADDREF(this, mRawPtr); |
468 | 0 | } |
469 | 0 | NSCAP_LOG_ASSIGNMENT(this, aSmartPtr.mRawPtr); |
470 | 0 | } Unexecuted instantiation: nsCOMPtr<mozilla::dom::Exception>::nsCOMPtr(nsCOMPtr<mozilla::dom::Exception> const&) Unexecuted instantiation: nsCOMPtr<nsIRunnable>::nsCOMPtr(nsCOMPtr<nsIRunnable> const&) Unexecuted instantiation: nsCOMPtr<nsIMemoryReporter>::nsCOMPtr(nsCOMPtr<nsIMemoryReporter> const&) Unexecuted instantiation: nsCOMPtr<nsIHandleReportCallback>::nsCOMPtr(nsCOMPtr<nsIHandleReportCallback> const&) Unexecuted instantiation: nsCOMPtr<mozilla::dom::DataTransfer>::nsCOMPtr(nsCOMPtr<mozilla::dom::DataTransfer> const&) |
471 | | |
472 | | nsCOMPtr(nsCOMPtr<T>&& aSmartPtr) |
473 | | : NSCAP_CTOR_BASE(aSmartPtr.mRawPtr) |
474 | 31 | { |
475 | 31 | assert_validity(); |
476 | 31 | aSmartPtr.mRawPtr = nullptr; |
477 | 31 | NSCAP_LOG_ASSIGNMENT(this, mRawPtr); |
478 | 31 | NSCAP_ASSERT_NO_QUERY_NEEDED(); |
479 | 31 | } nsCOMPtr<nsIRunnable>::nsCOMPtr(nsCOMPtr<nsIRunnable>&&) Line | Count | Source | 474 | 31 | { | 475 | 31 | assert_validity(); | 476 | 31 | aSmartPtr.mRawPtr = nullptr; | 477 | 31 | NSCAP_LOG_ASSIGNMENT(this, mRawPtr); | 478 | 31 | NSCAP_ASSERT_NO_QUERY_NEEDED(); | 479 | 31 | } |
Unexecuted instantiation: nsCOMPtr<nsIMemoryReporter>::nsCOMPtr(nsCOMPtr<nsIMemoryReporter>&&) Unexecuted instantiation: nsCOMPtr<nsIHandleReportCallback>::nsCOMPtr(nsCOMPtr<nsIHandleReportCallback>&&) |
480 | | |
481 | | MOZ_IMPLICIT nsCOMPtr(T* aRawPtr) |
482 | | : NSCAP_CTOR_BASE(aRawPtr) |
483 | 9.08k | { |
484 | 9.08k | assert_validity(); |
485 | 9.08k | if (mRawPtr) { |
486 | 9.08k | NSCAP_ADDREF(this, mRawPtr); |
487 | 9.08k | } |
488 | 9.08k | NSCAP_LOG_ASSIGNMENT(this, aRawPtr); |
489 | 9.08k | NSCAP_ASSERT_NO_QUERY_NEEDED(); |
490 | 9.08k | } nsCOMPtr<nsIRunnable>::nsCOMPtr(nsIRunnable*) Line | Count | Source | 483 | 103 | { | 484 | 103 | assert_validity(); | 485 | 103 | if (mRawPtr) { | 486 | 103 | NSCAP_ADDREF(this, mRawPtr); | 487 | 103 | } | 488 | 103 | NSCAP_LOG_ASSIGNMENT(this, aRawPtr); | 489 | 103 | NSCAP_ASSERT_NO_QUERY_NEEDED(); | 490 | 103 | } |
Unexecuted instantiation: nsCOMPtr<nsIInterfaceRequestor>::nsCOMPtr(nsIInterfaceRequestor*) nsCOMPtr<nsIConsoleMessage>::nsCOMPtr(nsIConsoleMessage*) Line | Count | Source | 483 | 8.90k | { | 484 | 8.90k | assert_validity(); | 485 | 8.90k | if (mRawPtr) { | 486 | 8.90k | NSCAP_ADDREF(this, mRawPtr); | 487 | 8.90k | } | 488 | 8.90k | NSCAP_LOG_ASSIGNMENT(this, aRawPtr); | 489 | 8.90k | NSCAP_ASSERT_NO_QUERY_NEEDED(); | 490 | 8.90k | } |
Unexecuted instantiation: nsCOMPtr<nsICycleCollectorListener>::nsCOMPtr(nsICycleCollectorListener*) Unexecuted instantiation: nsCOMPtr<nsICycleCollectorLogSink>::nsCOMPtr(nsICycleCollectorLogSink*) Unexecuted instantiation: nsCOMPtr<nsIFinishDumpingCallback>::nsCOMPtr(nsIFinishDumpingCallback*) Unexecuted instantiation: nsCOMPtr<nsIDumpGCAndCCLogsCallback>::nsCOMPtr(nsIDumpGCAndCCLogsCallback*) Unexecuted instantiation: nsCOMPtr<nsIFinishReportingCallback>::nsCOMPtr(nsIFinishReportingCallback*) nsCOMPtr<nsIMemoryReporter>::nsCOMPtr(nsIMemoryReporter*) Line | Count | Source | 483 | 74 | { | 484 | 74 | assert_validity(); | 485 | 74 | if (mRawPtr) { | 486 | 74 | NSCAP_ADDREF(this, mRawPtr); | 487 | 74 | } | 488 | 74 | NSCAP_LOG_ASSIGNMENT(this, aRawPtr); | 489 | 74 | NSCAP_ASSERT_NO_QUERY_NEEDED(); | 490 | 74 | } |
Unexecuted instantiation: nsCOMPtr<nsIHandleReportCallback>::nsCOMPtr(nsIHandleReportCallback*) Unexecuted instantiation: nsCOMPtr<mozilla::dom::nsIContentParent>::nsCOMPtr(mozilla::dom::nsIContentParent*) Unexecuted instantiation: nsCOMPtr<nsIXULBrowserWindow>::nsCOMPtr(nsIXULBrowserWindow*) Unexecuted instantiation: nsCOMPtr<nsIFocusManager>::nsCOMPtr(nsIFocusManager*) Unexecuted instantiation: nsCOMPtr<nsIProfilerStartParams>::nsCOMPtr(nsIProfilerStartParams*) Unexecuted instantiation: nsCOMPtr<IFoo>::nsCOMPtr(IFoo*) Unexecuted instantiation: nsCOMPtr<IBar>::nsCOMPtr(IBar*) |
491 | | |
492 | | MOZ_IMPLICIT nsCOMPtr(already_AddRefed<T>& aSmartPtr) |
493 | | : NSCAP_CTOR_BASE(aSmartPtr.take()) |
494 | | { |
495 | | assert_validity(); |
496 | | NSCAP_LOG_ASSIGNMENT(this, mRawPtr); |
497 | | NSCAP_ASSERT_NO_QUERY_NEEDED(); |
498 | | } |
499 | | |
500 | | // Construct from |otherComPtr.forget()|. |
501 | | MOZ_IMPLICIT nsCOMPtr(already_AddRefed<T>&& aSmartPtr) |
502 | | : NSCAP_CTOR_BASE(aSmartPtr.take()) |
503 | 305 | { |
504 | 305 | assert_validity(); |
505 | 305 | NSCAP_LOG_ASSIGNMENT(this, mRawPtr); |
506 | 305 | NSCAP_ASSERT_NO_QUERY_NEEDED(); |
507 | 305 | } nsCOMPtr<nsIObserverService>::nsCOMPtr(already_AddRefed<nsIObserverService>&&) Line | Count | Source | 503 | 151 | { | 504 | 151 | assert_validity(); | 505 | 151 | NSCAP_LOG_ASSIGNMENT(this, mRawPtr); | 506 | 151 | NSCAP_ASSERT_NO_QUERY_NEEDED(); | 507 | 151 | } |
nsCOMPtr<nsIThread>::nsCOMPtr(already_AddRefed<nsIThread>&&) Line | Count | Source | 503 | 11 | { | 504 | 11 | assert_validity(); | 505 | 11 | NSCAP_LOG_ASSIGNMENT(this, mRawPtr); | 506 | 11 | NSCAP_ASSERT_NO_QUERY_NEEDED(); | 507 | 11 | } |
nsCOMPtr<nsIRunnable>::nsCOMPtr(already_AddRefed<nsIRunnable>&&) Line | Count | Source | 503 | 55 | { | 504 | 55 | assert_validity(); | 505 | 55 | NSCAP_LOG_ASSIGNMENT(this, mRawPtr); | 506 | 55 | NSCAP_ASSERT_NO_QUERY_NEEDED(); | 507 | 55 | } |
Unexecuted instantiation: nsCOMPtr<nsICycleCollectorLogSink>::nsCOMPtr(already_AddRefed<nsICycleCollectorLogSink>&&) nsCOMPtr<nsIFile>::nsCOMPtr(already_AddRefed<nsIFile>&&) Line | Count | Source | 503 | 88 | { | 504 | 88 | assert_validity(); | 505 | 88 | NSCAP_LOG_ASSIGNMENT(this, mRawPtr); | 506 | 88 | NSCAP_ASSERT_NO_QUERY_NEEDED(); | 507 | 88 | } |
Unexecuted instantiation: nsCOMPtr<nsICycleCollectorListener>::nsCOMPtr(already_AddRefed<nsICycleCollectorListener>&&) Unexecuted instantiation: nsCOMPtr<TestCOMPtr::IFoo>::nsCOMPtr(already_AddRefed<TestCOMPtr::IFoo>&&) |
508 | | |
509 | | // Construct from |already_AddRefed|. |
510 | | template<typename U> |
511 | | MOZ_IMPLICIT nsCOMPtr(already_AddRefed<U>& aSmartPtr) |
512 | | : NSCAP_CTOR_BASE(static_cast<T*>(aSmartPtr.take())) |
513 | | { |
514 | | assert_validity(); |
515 | | // But make sure that U actually inherits from T. |
516 | | static_assert(mozilla::IsBaseOf<T, U>::value, |
517 | | "U is not a subclass of T"); |
518 | | NSCAP_LOG_ASSIGNMENT(this, static_cast<T*>(mRawPtr)); |
519 | | NSCAP_ASSERT_NO_QUERY_NEEDED(); |
520 | | } |
521 | | |
522 | | // Construct from |otherComPtr.forget()|. |
523 | | template<typename U> |
524 | | MOZ_IMPLICIT nsCOMPtr(already_AddRefed<U>&& aSmartPtr) |
525 | | : NSCAP_CTOR_BASE(static_cast<T*>(aSmartPtr.take())) |
526 | 0 | { |
527 | 0 | assert_validity(); |
528 | 0 | // But make sure that U actually inherits from T. |
529 | 0 | static_assert(mozilla::IsBaseOf<T, U>::value, |
530 | 0 | "U is not a subclass of T"); |
531 | 0 | NSCAP_LOG_ASSIGNMENT(this, static_cast<T*>(mRawPtr)); |
532 | 0 | NSCAP_ASSERT_NO_QUERY_NEEDED(); |
533 | 0 | } Unexecuted instantiation: nsCOMPtr<nsIRunnable>::nsCOMPtr<nsRunnableMethod<nsMemoryReporterManager, nsresult, true, (mozilla::RunnableKind)0> >(already_AddRefed<nsRunnableMethod<nsMemoryReporterManager, nsresult, true, (mozilla::RunnableKind)0> >&&) Unexecuted instantiation: nsCOMPtr<nsIRunnable>::nsCOMPtr<mozilla::Runnable>(already_AddRefed<mozilla::Runnable>&&) Unexecuted instantiation: nsCOMPtr<nsIRunnable>::nsCOMPtr<nsRunnableMethod<TestThreadUtils::ThreadUtilsObject, void, true, (mozilla::RunnableKind)0> >(already_AddRefed<nsRunnableMethod<TestThreadUtils::ThreadUtilsObject, void, true, (mozilla::RunnableKind)0> >&&) |
534 | | |
535 | | // Construct from |do_QueryInterface(expr)|. |
536 | | MOZ_IMPLICIT nsCOMPtr(const nsQueryInterface aQI) |
537 | | : NSCAP_CTOR_BASE(nullptr) |
538 | 11.3M | { |
539 | 11.3M | assert_validity(); |
540 | 11.3M | NSCAP_LOG_ASSIGNMENT(this, nullptr); |
541 | 11.3M | assign_from_qi(aQI, NS_GET_TEMPLATE_IID(T)); |
542 | 11.3M | } Unexecuted instantiation: nsCOMPtr<nsIScriptError>::nsCOMPtr(nsQueryInterface) Unexecuted instantiation: nsCOMPtr<nsISupportsPRUint64>::nsCOMPtr(nsQueryInterface) Unexecuted instantiation: nsCOMPtr<nsIInterfaceRequestor>::nsCOMPtr(nsQueryInterface) nsCOMPtr<nsIXPConnectWrappedJS>::nsCOMPtr(nsQueryInterface) Line | Count | Source | 538 | 9.74M | { | 539 | 9.74M | assert_validity(); | 540 | 9.74M | NSCAP_LOG_ASSIGNMENT(this, nullptr); | 541 | 9.74M | assign_from_qi(aQI, NS_GET_TEMPLATE_IID(T)); | 542 | 9.74M | } |
nsCOMPtr<nsIGlobalObject>::nsCOMPtr(nsQueryInterface) Line | Count | Source | 538 | 1.62M | { | 539 | 1.62M | assert_validity(); | 540 | 1.62M | NSCAP_LOG_ASSIGNMENT(this, nullptr); | 541 | 1.62M | assign_from_qi(aQI, NS_GET_TEMPLATE_IID(T)); | 542 | 1.62M | } |
Unexecuted instantiation: nsCOMPtr<nsIWebBrowser>::nsCOMPtr(nsQueryInterface) Unexecuted instantiation: nsCOMPtr<nsILoginManagerPrompter>::nsCOMPtr(nsQueryInterface) Unexecuted instantiation: nsCOMPtr<TestCOMPtr::IFoo>::nsCOMPtr(nsQueryInterface) Unexecuted instantiation: nsCOMPtr<TestCOMPtr::IBar>::nsCOMPtr(nsQueryInterface) Unexecuted instantiation: nsCOMPtr<TestHashtables::IFoo>::nsCOMPtr(nsQueryInterface) |
543 | | |
544 | | // Construct from |do_QueryInterface(expr, &rv)|. |
545 | | MOZ_IMPLICIT nsCOMPtr(const nsQueryInterfaceWithError& aQI) |
546 | | : NSCAP_CTOR_BASE(nullptr) |
547 | 215 | { |
548 | 215 | assert_validity(); |
549 | 215 | NSCAP_LOG_ASSIGNMENT(this, nullptr); |
550 | 215 | assign_from_qi_with_error(aQI, NS_GET_TEMPLATE_IID(T)); |
551 | 215 | } nsCOMPtr<nsISupportsWeakReference>::nsCOMPtr(nsQueryInterfaceWithError const&) Line | Count | Source | 547 | 215 | { | 548 | 215 | assert_validity(); | 549 | 215 | NSCAP_LOG_ASSIGNMENT(this, nullptr); | 550 | 215 | assign_from_qi_with_error(aQI, NS_GET_TEMPLATE_IID(T)); | 551 | 215 | } |
Unexecuted instantiation: nsCOMPtr<TestCOMPtr::IFoo>::nsCOMPtr(nsQueryInterfaceWithError const&) |
552 | | |
553 | | // Construct from |do_GetService(cid_expr)|. |
554 | | MOZ_IMPLICIT nsCOMPtr(const nsGetServiceByCID aGS) |
555 | | : NSCAP_CTOR_BASE(nullptr) |
556 | | { |
557 | | assert_validity(); |
558 | | NSCAP_LOG_ASSIGNMENT(this, nullptr); |
559 | | assign_from_gs_cid(aGS, NS_GET_TEMPLATE_IID(T)); |
560 | | } |
561 | | |
562 | | // Construct from |do_GetService(cid_expr, &rv)|. |
563 | | MOZ_IMPLICIT nsCOMPtr(const nsGetServiceByCIDWithError& aGS) |
564 | | : NSCAP_CTOR_BASE(nullptr) |
565 | | { |
566 | | assert_validity(); |
567 | | NSCAP_LOG_ASSIGNMENT(this, nullptr); |
568 | | assign_from_gs_cid_with_error(aGS, NS_GET_TEMPLATE_IID(T)); |
569 | | } |
570 | | |
571 | | // Construct from |do_GetService(contractid_expr)|. |
572 | | MOZ_IMPLICIT nsCOMPtr(const nsGetServiceByContractID aGS) |
573 | | : NSCAP_CTOR_BASE(nullptr) |
574 | 8.97k | { |
575 | 8.97k | assert_validity(); |
576 | 8.97k | NSCAP_LOG_ASSIGNMENT(this, nullptr); |
577 | 8.97k | assign_from_gs_contractid(aGS, NS_GET_TEMPLATE_IID(T)); |
578 | 8.97k | } nsCOMPtr<nsIConsoleService>::nsCOMPtr(nsGetServiceByContractID) Line | Count | Source | 574 | 8.90k | { | 575 | 8.90k | assert_validity(); | 576 | 8.90k | NSCAP_LOG_ASSIGNMENT(this, nullptr); | 577 | 8.90k | assign_from_gs_contractid(aGS, NS_GET_TEMPLATE_IID(T)); | 578 | 8.90k | } |
Unexecuted instantiation: nsCOMPtr<nsIMemoryInfoDumper>::nsCOMPtr(nsGetServiceByContractID) nsCOMPtr<nsIMemoryReporterManager>::nsCOMPtr(nsGetServiceByContractID) Line | Count | Source | 574 | 73 | { | 575 | 73 | assert_validity(); | 576 | 73 | NSCAP_LOG_ASSIGNMENT(this, nullptr); | 577 | 73 | assign_from_gs_contractid(aGS, NS_GET_TEMPLATE_IID(T)); | 578 | 73 | } |
Unexecuted instantiation: nsCOMPtr<nsIDroppedLinkHandler>::nsCOMPtr(nsGetServiceByContractID) |
579 | | |
580 | | // Construct from |do_GetService(contractid_expr, &rv)|. |
581 | | MOZ_IMPLICIT nsCOMPtr(const nsGetServiceByContractIDWithError& aGS) |
582 | | : NSCAP_CTOR_BASE(nullptr) |
583 | 0 | { |
584 | 0 | assert_validity(); |
585 | 0 | NSCAP_LOG_ASSIGNMENT(this, nullptr); |
586 | 0 | assign_from_gs_contractid_with_error(aGS, NS_GET_TEMPLATE_IID(T)); |
587 | 0 | } |
588 | | |
589 | | // Construct from |do_QueryReferent(ptr)| |
590 | | MOZ_IMPLICIT nsCOMPtr(const nsQueryReferent& aQueryReferent) |
591 | | : NSCAP_CTOR_BASE(nullptr) |
592 | 0 | { |
593 | 0 | assert_validity(); |
594 | 0 | NSCAP_LOG_ASSIGNMENT(this, nullptr); |
595 | 0 | assign_from_query_referent(aQueryReferent, NS_GET_TEMPLATE_IID(T)); |
596 | 0 | } |
597 | | |
598 | | // And finally, anything else we might need to construct from can exploit the |
599 | | // nsCOMPtr_helper facility. |
600 | | MOZ_IMPLICIT nsCOMPtr(const nsCOMPtr_helper& aHelper) |
601 | | : NSCAP_CTOR_BASE(nullptr) |
602 | 0 | { |
603 | 0 | assert_validity(); |
604 | 0 | NSCAP_LOG_ASSIGNMENT(this, nullptr); |
605 | 0 | assign_from_helper(aHelper, NS_GET_TEMPLATE_IID(T)); |
606 | 0 | NSCAP_ASSERT_NO_QUERY_NEEDED(); |
607 | 0 | } Unexecuted instantiation: nsCOMPtr<nsIWebBrowser>::nsCOMPtr(nsCOMPtr_helper const&) Unexecuted instantiation: nsCOMPtr<nsIPrintSession>::nsCOMPtr(nsCOMPtr_helper const&) Unexecuted instantiation: nsCOMPtr<nsIObserverService>::nsCOMPtr(nsCOMPtr_helper const&) |
608 | | |
609 | | // Defined in OwningNonNull.h |
610 | | template<class U> |
611 | | MOZ_IMPLICIT nsCOMPtr(const mozilla::OwningNonNull<U>& aOther); |
612 | | |
613 | | |
614 | | // Assignment operators |
615 | | |
616 | | nsCOMPtr<T>& operator=(const nsCOMPtr<T>& aRhs) |
617 | 3.95k | { |
618 | 3.95k | assign_with_AddRef(aRhs.mRawPtr); |
619 | 3.95k | return *this; |
620 | 3.95k | } nsCOMPtr<nsIFile>::operator=(nsCOMPtr<nsIFile> const&) Line | Count | Source | 617 | 3.95k | { | 618 | 3.95k | assign_with_AddRef(aRhs.mRawPtr); | 619 | 3.95k | return *this; | 620 | 3.95k | } |
Unexecuted instantiation: nsCOMPtr<nsICycleCollectorListener>::operator=(nsCOMPtr<nsICycleCollectorListener> const&) Unexecuted instantiation: nsCOMPtr<nsILoadContext>::operator=(nsCOMPtr<nsILoadContext> const&) Unexecuted instantiation: nsCOMPtr<TestCOMPtr::IFoo>::operator=(nsCOMPtr<TestCOMPtr::IFoo> const&) |
621 | | |
622 | | nsCOMPtr<T>& operator=(nsCOMPtr<T>&& aRhs) |
623 | 0 | { |
624 | 0 | assign_assuming_AddRef(aRhs.forget().take()); |
625 | 0 | NSCAP_ASSERT_NO_QUERY_NEEDED(); |
626 | 0 | return *this; |
627 | 0 | } Unexecuted instantiation: nsCOMPtr<nsIObserver>::operator=(nsCOMPtr<nsIObserver>&&) Unexecuted instantiation: nsCOMPtr<TestCOMPtr::IFoo>::operator=(nsCOMPtr<TestCOMPtr::IFoo>&&) |
628 | | |
629 | | nsCOMPtr<T>& operator=(T* aRhs) |
630 | 11.3M | { |
631 | 11.3M | assign_with_AddRef(aRhs); |
632 | 11.3M | NSCAP_ASSERT_NO_QUERY_NEEDED(); |
633 | 11.3M | return *this; |
634 | 11.3M | } nsCOMPtr<nsIGlobalObject>::operator=(nsIGlobalObject*) Line | Count | Source | 630 | 1.62M | { | 631 | 1.62M | assign_with_AddRef(aRhs); | 632 | 1.62M | NSCAP_ASSERT_NO_QUERY_NEEDED(); | 633 | 1.62M | return *this; | 634 | 1.62M | } |
nsCOMPtr<mozilla::dom::Exception>::operator=(mozilla::dom::Exception*) Line | Count | Source | 630 | 9.74M | { | 631 | 9.74M | assign_with_AddRef(aRhs); | 632 | 9.74M | NSCAP_ASSERT_NO_QUERY_NEEDED(); | 633 | 9.74M | return *this; | 634 | 9.74M | } |
nsCOMPtr<nsIEventTarget>::operator=(nsIEventTarget*) Line | Count | Source | 630 | 202 | { | 631 | 202 | assign_with_AddRef(aRhs); | 632 | 202 | NSCAP_ASSERT_NO_QUERY_NEEDED(); | 633 | 202 | return *this; | 634 | 202 | } |
Unexecuted instantiation: nsCOMPtr<nsICycleCollectorLogSink>::operator=(nsICycleCollectorLogSink*) Unexecuted instantiation: nsCOMPtr<nsIConsoleListener>::operator=(nsIConsoleListener*) Unexecuted instantiation: nsCOMPtr<nsIWebBrowserChrome3>::operator=(nsIWebBrowserChrome3*) Unexecuted instantiation: nsCOMPtr<TestHashtables::IFoo>::operator=(TestHashtables::IFoo*) |
635 | | |
636 | | nsCOMPtr<T>& operator=(decltype(nullptr)) |
637 | 180 | { |
638 | 180 | assign_assuming_AddRef(nullptr); |
639 | 180 | return *this; |
640 | 180 | } nsCOMPtr<nsITimer>::operator=(decltype(nullptr)) Line | Count | Source | 637 | 164 | { | 638 | 164 | assign_assuming_AddRef(nullptr); | 639 | 164 | return *this; | 640 | 164 | } |
Unexecuted instantiation: nsCOMPtr<mozilla::dom::Exception>::operator=(decltype(nullptr)) nsCOMPtr<nsIRunnable>::operator=(decltype(nullptr)) Line | Count | Source | 637 | 16 | { | 638 | 16 | assign_assuming_AddRef(nullptr); | 639 | 16 | return *this; | 640 | 16 | } |
Unexecuted instantiation: nsCOMPtr<nsIWebBrowserChrome3>::operator=(decltype(nullptr)) Unexecuted instantiation: nsCOMPtr<nsIWebNavigation>::operator=(decltype(nullptr)) Unexecuted instantiation: nsCOMPtr<imgIContainer>::operator=(decltype(nullptr)) |
641 | | |
642 | | // Assign from |already_AddRefed|. |
643 | | template<typename U> |
644 | | nsCOMPtr<T>& operator=(already_AddRefed<U>& aRhs) |
645 | 0 | { |
646 | 0 | // Make sure that U actually inherits from T |
647 | 0 | static_assert(mozilla::IsBaseOf<T, U>::value, |
648 | 0 | "U is not a subclass of T"); |
649 | 0 | assign_assuming_AddRef(static_cast<T*>(aRhs.take())); |
650 | 0 | NSCAP_ASSERT_NO_QUERY_NEEDED(); |
651 | 0 | return *this; |
652 | 0 | } |
653 | | |
654 | | // Assign from |otherComPtr.forget()|. |
655 | | template<typename U> |
656 | | nsCOMPtr<T>& operator=(already_AddRefed<U>&& aRhs) |
657 | 21 | { |
658 | 21 | // Make sure that U actually inherits from T |
659 | 21 | static_assert(mozilla::IsBaseOf<T, U>::value, |
660 | 21 | "U is not a subclass of T"); |
661 | 21 | assign_assuming_AddRef(static_cast<T*>(aRhs.take())); |
662 | 21 | NSCAP_ASSERT_NO_QUERY_NEEDED(); |
663 | 21 | return *this; |
664 | 21 | } nsCOMPtr<nsIFile>& nsCOMPtr<nsIFile>::operator=<nsIFile>(already_AddRefed<nsIFile>&&) Line | Count | Source | 657 | 21 | { | 658 | 21 | // Make sure that U actually inherits from T | 659 | 21 | static_assert(mozilla::IsBaseOf<T, U>::value, | 660 | 21 | "U is not a subclass of T"); | 661 | 21 | assign_assuming_AddRef(static_cast<T*>(aRhs.take())); | 662 | 21 | NSCAP_ASSERT_NO_QUERY_NEEDED(); | 663 | 21 | return *this; | 664 | 21 | } |
Unexecuted instantiation: nsCOMPtr<TestCOMPtr::IFoo>& nsCOMPtr<TestCOMPtr::IFoo>::operator=<TestCOMPtr::IFoo>(already_AddRefed<TestCOMPtr::IFoo>&&) Unexecuted instantiation: nsCOMPtr<nsIRunnable>& nsCOMPtr<nsIRunnable>::operator=<mozilla::Runnable>(already_AddRefed<mozilla::Runnable>&&) Unexecuted instantiation: nsCOMPtr<nsIThread>& nsCOMPtr<nsIThread>::operator=<nsIThread>(already_AddRefed<nsIThread>&&) Unexecuted instantiation: nsCOMPtr<nsIRunnable>& nsCOMPtr<nsIRunnable>::operator=<nsRunnableMethod<TestThreadUtils::ThreadUtilsObject, void, true, (mozilla::RunnableKind)0> >(already_AddRefed<nsRunnableMethod<TestThreadUtils::ThreadUtilsObject, void, true, (mozilla::RunnableKind)0> >&&) Unexecuted instantiation: nsCOMPtr<nsIRunnable>& nsCOMPtr<nsIRunnable>::operator=<nsRunnableMethod<TestThreadUtils::ThreadUtilsObjectNonRefCountedBase, void, true, (mozilla::RunnableKind)0> >(already_AddRefed<nsRunnableMethod<TestThreadUtils::ThreadUtilsObjectNonRefCountedBase, void, true, (mozilla::RunnableKind)0> >&&) |
665 | | |
666 | | // Assign from |do_QueryInterface(expr)|. |
667 | | nsCOMPtr<T>& operator=(const nsQueryInterface aRhs) |
668 | 0 | { |
669 | 0 | assign_from_qi(aRhs, NS_GET_TEMPLATE_IID(T)); |
670 | 0 | return *this; |
671 | 0 | } Unexecuted instantiation: nsCOMPtr<nsIObserver>::operator=(nsQueryInterface) Unexecuted instantiation: nsCOMPtr<nsIWebNavigation>::operator=(nsQueryInterface) Unexecuted instantiation: nsCOMPtr<TestCOMPtr::IFoo>::operator=(nsQueryInterface) Unexecuted instantiation: nsCOMPtr<nsIAsyncInputStreamLength>::operator=(nsQueryInterface) Unexecuted instantiation: nsCOMPtr<nsIIPCSerializableInputStream>::operator=(nsQueryInterface) |
672 | | |
673 | | // Assign from |do_QueryInterface(expr, &rv)|. |
674 | | nsCOMPtr<T>& operator=(const nsQueryInterfaceWithError& aRhs) |
675 | | { |
676 | | assign_from_qi_with_error(aRhs, NS_GET_TEMPLATE_IID(T)); |
677 | | return *this; |
678 | | } |
679 | | |
680 | | // Assign from |do_GetService(cid_expr)|. |
681 | | nsCOMPtr<T>& operator=(const nsGetServiceByCID aRhs) |
682 | | { |
683 | | assign_from_gs_cid(aRhs, NS_GET_TEMPLATE_IID(T)); |
684 | | return *this; |
685 | | } |
686 | | |
687 | | // Assign from |do_GetService(cid_expr, &rv)|. |
688 | | nsCOMPtr<T>& operator=(const nsGetServiceByCIDWithError& aRhs) |
689 | | { |
690 | | assign_from_gs_cid_with_error(aRhs, NS_GET_TEMPLATE_IID(T)); |
691 | | return *this; |
692 | | } |
693 | | |
694 | | // Assign from |do_GetService(contractid_expr)|. |
695 | | nsCOMPtr<T>& operator=(const nsGetServiceByContractID aRhs) |
696 | 0 | { |
697 | 0 | assign_from_gs_contractid(aRhs, NS_GET_TEMPLATE_IID(T)); |
698 | 0 | return *this; |
699 | 0 | } |
700 | | |
701 | | // Assign from |do_GetService(contractid_expr, &rv)|. |
702 | | nsCOMPtr<T>& operator=(const nsGetServiceByContractIDWithError& aRhs) |
703 | | { |
704 | | assign_from_gs_contractid_with_error(aRhs, NS_GET_TEMPLATE_IID(T)); |
705 | | return *this; |
706 | | } |
707 | | |
708 | | // Assign from |do_QueryReferent(ptr)|. |
709 | | nsCOMPtr<T>& operator=(const nsQueryReferent& aRhs) |
710 | | { |
711 | | assign_from_query_referent(aRhs, NS_GET_TEMPLATE_IID(T)); |
712 | | return *this; |
713 | | } |
714 | | |
715 | | // And finally, anything else we might need to assign from can exploit the |
716 | | // nsCOMPtr_helper facility. |
717 | | nsCOMPtr<T>& operator=(const nsCOMPtr_helper& aRhs) |
718 | | { |
719 | | assign_from_helper(aRhs, NS_GET_TEMPLATE_IID(T)); |
720 | | NSCAP_ASSERT_NO_QUERY_NEEDED(); |
721 | | return *this; |
722 | | } |
723 | | |
724 | | // Defined in OwningNonNull.h |
725 | | template<class U> |
726 | | nsCOMPtr<T>& operator=(const mozilla::OwningNonNull<U>& aOther); |
727 | | |
728 | | // Exchange ownership with |aRhs|; can save a pair of refcount operations. |
729 | | void swap(nsCOMPtr<T>& aRhs) |
730 | 8.65k | { |
731 | 8.65k | #ifdef NSCAP_FEATURE_USE_BASE |
732 | 8.65k | nsISupports* temp = aRhs.mRawPtr; |
733 | | #else |
734 | | T* temp = aRhs.mRawPtr; |
735 | | #endif |
736 | | NSCAP_LOG_ASSIGNMENT(&aRhs, mRawPtr); |
737 | 8.65k | NSCAP_LOG_ASSIGNMENT(this, temp); |
738 | 8.65k | NSCAP_LOG_RELEASE(this, mRawPtr); |
739 | 8.65k | NSCAP_LOG_RELEASE(&aRhs, temp); |
740 | 8.65k | aRhs.mRawPtr = mRawPtr; |
741 | 8.65k | mRawPtr = temp; |
742 | 8.65k | // |aRhs| maintains the same invariants, so we don't need to |NSCAP_ASSERT_NO_QUERY_NEEDED| |
743 | 8.65k | } nsCOMPtr<nsIConsoleMessage>::swap(nsCOMPtr<nsIConsoleMessage>&) Line | Count | Source | 730 | 8.65k | { | 731 | 8.65k | #ifdef NSCAP_FEATURE_USE_BASE | 732 | 8.65k | nsISupports* temp = aRhs.mRawPtr; | 733 | | #else | 734 | | T* temp = aRhs.mRawPtr; | 735 | | #endif | 736 | | NSCAP_LOG_ASSIGNMENT(&aRhs, mRawPtr); | 737 | 8.65k | NSCAP_LOG_ASSIGNMENT(this, temp); | 738 | 8.65k | NSCAP_LOG_RELEASE(this, mRawPtr); | 739 | 8.65k | NSCAP_LOG_RELEASE(&aRhs, temp); | 740 | 8.65k | aRhs.mRawPtr = mRawPtr; | 741 | 8.65k | mRawPtr = temp; | 742 | 8.65k | // |aRhs| maintains the same invariants, so we don't need to |NSCAP_ASSERT_NO_QUERY_NEEDED| | 743 | 8.65k | } |
Unexecuted instantiation: nsCOMPtr<nsITimer>::swap(nsCOMPtr<nsITimer>&) |
744 | | |
745 | | // Exchange ownership with |aRhs|; can save a pair of refcount operations. |
746 | | void swap(T*& aRhs) |
747 | 9.28k | { |
748 | 9.28k | #ifdef NSCAP_FEATURE_USE_BASE |
749 | 9.28k | nsISupports* temp = aRhs; |
750 | | #else |
751 | | T* temp = aRhs; |
752 | | #endif |
753 | | NSCAP_LOG_ASSIGNMENT(this, temp); |
754 | 9.28k | NSCAP_LOG_RELEASE(this, mRawPtr); |
755 | 9.28k | aRhs = reinterpret_cast<T*>(mRawPtr); |
756 | 9.28k | mRawPtr = temp; |
757 | 9.28k | NSCAP_ASSERT_NO_QUERY_NEEDED(); |
758 | 9.28k | } nsCOMPtr<nsIRunnable>::swap(nsIRunnable*&) Line | Count | Source | 747 | 602 | { | 748 | 602 | #ifdef NSCAP_FEATURE_USE_BASE | 749 | 602 | nsISupports* temp = aRhs; | 750 | | #else | 751 | | T* temp = aRhs; | 752 | | #endif | 753 | | NSCAP_LOG_ASSIGNMENT(this, temp); | 754 | 602 | NSCAP_LOG_RELEASE(this, mRawPtr); | 755 | 602 | aRhs = reinterpret_cast<T*>(mRawPtr); | 756 | 602 | mRawPtr = temp; | 757 | 602 | NSCAP_ASSERT_NO_QUERY_NEEDED(); | 758 | 602 | } |
nsCOMPtr<nsIThread>::swap(nsIThread*&) Line | Count | Source | 747 | 24 | { | 748 | 24 | #ifdef NSCAP_FEATURE_USE_BASE | 749 | 24 | nsISupports* temp = aRhs; | 750 | | #else | 751 | | T* temp = aRhs; | 752 | | #endif | 753 | | NSCAP_LOG_ASSIGNMENT(this, temp); | 754 | 24 | NSCAP_LOG_RELEASE(this, mRawPtr); | 755 | 24 | aRhs = reinterpret_cast<T*>(mRawPtr); | 756 | 24 | mRawPtr = temp; | 757 | 24 | NSCAP_ASSERT_NO_QUERY_NEEDED(); | 758 | 24 | } |
Unexecuted instantiation: nsCOMPtr<mozilla::dom::Exception>::swap(mozilla::dom::Exception*&) nsCOMPtr<nsIConsoleMessage>::swap(nsIConsoleMessage*&) Line | Count | Source | 747 | 8.65k | { | 748 | 8.65k | #ifdef NSCAP_FEATURE_USE_BASE | 749 | 8.65k | nsISupports* temp = aRhs; | 750 | | #else | 751 | | T* temp = aRhs; | 752 | | #endif | 753 | | NSCAP_LOG_ASSIGNMENT(this, temp); | 754 | 8.65k | NSCAP_LOG_RELEASE(this, mRawPtr); | 755 | 8.65k | aRhs = reinterpret_cast<T*>(mRawPtr); | 756 | 8.65k | mRawPtr = temp; | 757 | 8.65k | NSCAP_ASSERT_NO_QUERY_NEEDED(); | 758 | 8.65k | } |
Unexecuted instantiation: nsCOMPtr<nsICycleCollectorListener>::swap(nsICycleCollectorListener*&) Unexecuted instantiation: nsCOMPtr<nsICycleCollectorLogSink>::swap(nsICycleCollectorLogSink*&) Unexecuted instantiation: nsCOMPtr<nsIInterfaceRequestor>::swap(nsIInterfaceRequestor*&) Unexecuted instantiation: nsCOMPtr<TestCOMPtr::IFoo>::swap(TestCOMPtr::IFoo*&) |
759 | | |
760 | | |
761 | | // Other pointer operators |
762 | | |
763 | | // Return the value of mRawPtr and null out mRawPtr. Useful for |
764 | | // already_AddRefed return values. |
765 | | already_AddRefed<T> MOZ_MAY_CALL_AFTER_MUST_RETURN forget() |
766 | 9.26k | { |
767 | 9.26k | T* temp = nullptr; |
768 | 9.26k | swap(temp); |
769 | 9.26k | return already_AddRefed<T>(temp); |
770 | 9.26k | } nsCOMPtr<nsIRunnable>::forget() Line | Count | Source | 766 | 602 | { | 767 | 602 | T* temp = nullptr; | 768 | 602 | swap(temp); | 769 | 602 | return already_AddRefed<T>(temp); | 770 | 602 | } |
nsCOMPtr<nsIThread>::forget() Line | Count | Source | 766 | 11 | { | 767 | 11 | T* temp = nullptr; | 768 | 11 | swap(temp); | 769 | 11 | return already_AddRefed<T>(temp); | 770 | 11 | } |
Unexecuted instantiation: nsCOMPtr<mozilla::dom::Exception>::forget() nsCOMPtr<nsIConsoleMessage>::forget() Line | Count | Source | 766 | 8.65k | { | 767 | 8.65k | T* temp = nullptr; | 768 | 8.65k | swap(temp); | 769 | 8.65k | return already_AddRefed<T>(temp); | 770 | 8.65k | } |
Unexecuted instantiation: nsCOMPtr<nsICycleCollectorListener>::forget() Unexecuted instantiation: nsCOMPtr<nsICycleCollectorLogSink>::forget() Unexecuted instantiation: nsCOMPtr<nsIInterfaceRequestor>::forget() Unexecuted instantiation: nsCOMPtr<TestCOMPtr::IFoo>::forget() |
771 | | |
772 | | // Set the target of aRhs to the value of mRawPtr and null out mRawPtr. |
773 | | // Useful to avoid unnecessary AddRef/Release pairs with "out" parameters |
774 | | // where aRhs bay be a T** or an I** where I is a base class of T. |
775 | | template<typename I> |
776 | | void forget(I** aRhs) |
777 | 0 | { |
778 | 0 | NS_ASSERTION(aRhs, "Null pointer passed to forget!"); |
779 | 0 | NSCAP_LOG_RELEASE(this, mRawPtr); |
780 | 0 | *aRhs = get(); |
781 | 0 | mRawPtr = nullptr; |
782 | 0 | } Unexecuted instantiation: void nsCOMPtr<nsIConsoleMessage>::forget<nsIConsoleMessage>(nsIConsoleMessage**) Unexecuted instantiation: void nsCOMPtr<nsIConsoleListener>::forget<nsIConsoleListener>(nsIConsoleListener**) Unexecuted instantiation: void nsCOMPtr<nsIProfilerStartParams>::forget<nsIProfilerStartParams>(nsIProfilerStartParams**) |
783 | | |
784 | | // Prefer the implicit conversion provided automatically by |
785 | | // |operator T*() const|. Use |get()| to resolve ambiguity or to get a |
786 | | // castable pointer. |
787 | 1.63M | T* get() const { return reinterpret_cast<T*>(mRawPtr); } nsCOMPtr<nsIPrefBranch>::get() const Line | Count | Source | 787 | 145 | T* get() const { return reinterpret_cast<T*>(mRawPtr); } |
nsCOMPtr<nsIObserver>::get() const Line | Count | Source | 787 | 22 | T* get() const { return reinterpret_cast<T*>(mRawPtr); } |
nsCOMPtr<nsITimer>::get() const Line | Count | Source | 787 | 257 | T* get() const { return reinterpret_cast<T*>(mRawPtr); } |
nsCOMPtr<nsIGlobalObject>::get() const Line | Count | Source | 787 | 1.62M | T* get() const { return reinterpret_cast<T*>(mRawPtr); } |
nsCOMPtr<nsIObserverService>::get() const Line | Count | Source | 787 | 368 | T* get() const { return reinterpret_cast<T*>(mRawPtr); } |
Unexecuted instantiation: nsCOMPtr<nsIInterfaceRequestor>::get() const nsCOMPtr<nsIRunnable>::get() const Line | Count | Source | 787 | 137 | T* get() const { return reinterpret_cast<T*>(mRawPtr); } |
Unexecuted instantiation: nsCOMPtr<nsIConsoleMessage>::get() const Unexecuted instantiation: nsCOMPtr<nsICycleCollectorLogSink>::get() const nsCOMPtr<nsIConsoleService>::get() const Line | Count | Source | 787 | 8.90k | T* get() const { return reinterpret_cast<T*>(mRawPtr); } |
Unexecuted instantiation: nsCOMPtr<nsIScriptError>::get() const Unexecuted instantiation: nsCOMPtr<nsIConsoleListener>::get() const Unexecuted instantiation: nsCOMPtr<nsISupportsPRUint64>::get() const Unexecuted instantiation: nsCOMPtr<nsIMemory>::get() const Unexecuted instantiation: nsCOMPtr<nsIMemoryInfoDumper>::get() const nsCOMPtr<nsIMemoryReporterManager>::get() const Line | Count | Source | 787 | 73 | T* get() const { return reinterpret_cast<T*>(mRawPtr); } |
Unexecuted instantiation: nsCOMPtr<nsIFinishDumpingCallback>::get() const nsCOMPtr<nsISimpleEnumerator>::get() const Line | Count | Source | 787 | 33 | T* get() const { return reinterpret_cast<T*>(mRawPtr); } |
Unexecuted instantiation: nsCOMPtr<nsIDumpGCAndCCLogsCallback>::get() const Unexecuted instantiation: nsCOMPtr<nsICycleCollectorListener>::get() const Unexecuted instantiation: nsCOMPtr<nsIHandleReportCallback>::get() const Unexecuted instantiation: nsCOMPtr<nsIFinishReportingCallback>::get() const nsCOMPtr<nsIMemoryReporter>::get() const Line | Count | Source | 787 | 22 | T* get() const { return reinterpret_cast<T*>(mRawPtr); } |
nsCOMPtr<nsISupportsWeakReference>::get() const Line | Count | Source | 787 | 205 | T* get() const { return reinterpret_cast<T*>(mRawPtr); } |
Unexecuted instantiation: nsCOMPtr<nsIWebBrowser>::get() const Unexecuted instantiation: nsCOMPtr<nsIPrintSession>::get() const Unexecuted instantiation: nsCOMPtr<nsIDroppedLinkHandler>::get() const Unexecuted instantiation: nsCOMPtr<nsIXULBrowserWindow>::get() const Unexecuted instantiation: nsCOMPtr<nsILoginManagerPrompter>::get() const Unexecuted instantiation: nsCOMPtr<nsIProfilerStartParams>::get() const Unexecuted instantiation: nsCOMPtr<IFoo>::get() const Unexecuted instantiation: nsCOMPtr<IBar>::get() const Unexecuted instantiation: nsCOMPtr<TestCOMPtr::IBar>::get() const Unexecuted instantiation: nsCOMPtr<TestCOMPtr::IFoo>::get() const Unexecuted instantiation: nsCOMPtr<TestHashtables::IFoo>::get() const |
788 | | |
789 | | // Makes an nsCOMPtr act like its underlying raw pointer type whenever it is |
790 | | // used in a context where a raw pointer is expected. It is this operator |
791 | | // that makes an nsCOMPtr substitutable for a raw pointer. |
792 | | // |
793 | | // Prefer the implicit use of this operator to calling |get()|, except where |
794 | | // necessary to resolve ambiguity. |
795 | 56 | operator T*() const & { return get(); } nsCOMPtr<nsIPrefBranch>::operator nsIPrefBranch*() const & Line | Count | Source | 795 | 7 | operator T*() const & { return get(); } |
nsCOMPtr<nsIRunnable>::operator nsIRunnable*() const & Line | Count | Source | 795 | 5 | operator T*() const & { return get(); } |
Unexecuted instantiation: nsCOMPtr<nsIConsoleMessage>::operator nsIConsoleMessage*() const & Unexecuted instantiation: nsCOMPtr<nsICycleCollectorLogSink>::operator nsICycleCollectorLogSink*() const & Unexecuted instantiation: nsCOMPtr<nsIConsoleListener>::operator nsIConsoleListener*() const & nsCOMPtr<nsIObserver>::operator nsIObserver*() const & Line | Count | Source | 795 | 22 | operator T*() const & { return get(); } |
Unexecuted instantiation: nsCOMPtr<nsIDumpGCAndCCLogsCallback>::operator nsIDumpGCAndCCLogsCallback*() const & Unexecuted instantiation: nsCOMPtr<nsICycleCollectorListener>::operator nsICycleCollectorListener*() const & Unexecuted instantiation: nsCOMPtr<nsIHandleReportCallback>::operator nsIHandleReportCallback*() const & Unexecuted instantiation: nsCOMPtr<nsIFinishReportingCallback>::operator nsIFinishReportingCallback*() const & nsCOMPtr<nsIMemoryReporter>::operator nsIMemoryReporter*() const & Line | Count | Source | 795 | 22 | operator T*() const & { return get(); } |
Unexecuted instantiation: nsCOMPtr<nsIWebBrowserChrome3>::operator nsIWebBrowserChrome3*() const & Unexecuted instantiation: nsCOMPtr<nsIPrintSession>::operator nsIPrintSession*() const & Unexecuted instantiation: nsCOMPtr<nsIXULBrowserWindow>::operator nsIXULBrowserWindow*() const & Unexecuted instantiation: nsCOMPtr<nsIProfilerStartParams>::operator nsIProfilerStartParams*() const & Unexecuted instantiation: nsCOMPtr<IFoo>::operator IFoo*() const & Unexecuted instantiation: nsCOMPtr<IBar>::operator IBar*() const & Unexecuted instantiation: nsCOMPtr<TestCOMPtr::IBar>::operator TestCOMPtr::IBar*() const & Unexecuted instantiation: nsCOMPtr<TestCOMPtr::IFoo>::operator TestCOMPtr::IFoo*() const & Unexecuted instantiation: nsCOMPtr<TestHashtables::IFoo>::operator TestHashtables::IFoo*() const & Unexecuted instantiation: nsCOMPtr<nsIObserverService>::operator nsIObserverService*() const & Unexecuted instantiation: nsCOMPtr<nsINestedEventLoopCondition>::operator nsINestedEventLoopCondition*() const & |
796 | | |
797 | | // Don't allow implicit conversion of temporary nsCOMPtr to raw pointer, |
798 | | // because the refcount might be one and the pointer will immediately become |
799 | | // invalid. |
800 | | operator T*() const && = delete; |
801 | | |
802 | | // Needed to avoid the deleted operator above |
803 | 9.76M | explicit operator bool() const { return !!mRawPtr; } nsCOMPtr<nsITimer>::operator bool() const Line | Count | Source | 803 | 499 | explicit operator bool() const { return !!mRawPtr; } |
nsCOMPtr<nsIObserverService>::operator bool() const Line | Count | Source | 803 | 136 | explicit operator bool() const { return !!mRawPtr; } |
Unexecuted instantiation: nsCOMPtr<nsIInterfaceRequestor>::operator bool() const nsCOMPtr<nsIConsoleService>::operator bool() const Line | Count | Source | 803 | 8.90k | explicit operator bool() const { return !!mRawPtr; } |
Unexecuted instantiation: nsCOMPtr<nsIScriptError>::operator bool() const nsCOMPtr<nsIConsoleMessage>::operator bool() const Line | Count | Source | 803 | 8.90k | explicit operator bool() const { return !!mRawPtr; } |
nsCOMPtr<nsIThread>::operator bool() const Line | Count | Source | 803 | 107 | explicit operator bool() const { return !!mRawPtr; } |
nsCOMPtr<nsIRunnable>::operator bool() const Line | Count | Source | 803 | 185 | explicit operator bool() const { return !!mRawPtr; } |
Unexecuted instantiation: nsCOMPtr<nsIFinishDumpingCallback>::operator bool() const nsCOMPtr<nsISimpleEnumerator>::operator bool() const Line | Count | Source | 803 | 3 | explicit operator bool() const { return !!mRawPtr; } |
nsCOMPtr<nsIXPConnectWrappedJS>::operator bool() const Line | Count | Source | 803 | 9.74M | explicit operator bool() const { return !!mRawPtr; } |
Unexecuted instantiation: nsCOMPtr<nsIGlobalObject>::operator bool() const nsCOMPtr<nsISupportsWeakReference>::operator bool() const Line | Count | Source | 803 | 231 | explicit operator bool() const { return !!mRawPtr; } |
Unexecuted instantiation: nsCOMPtr<nsIWebBrowser>::operator bool() const Unexecuted instantiation: nsCOMPtr<nsIDroppedLinkHandler>::operator bool() const Unexecuted instantiation: nsCOMPtr<nsIXULBrowserWindow>::operator bool() const Unexecuted instantiation: nsCOMPtr<nsILoginManagerPrompter>::operator bool() const Unexecuted instantiation: nsCOMPtr<TestCOMPtr::IBar>::operator bool() const Unexecuted instantiation: nsCOMPtr<TestCOMPtr::IFoo>::operator bool() const |
804 | | |
805 | | T* operator->() const MOZ_NO_ADDREF_RELEASE_ON_RETURN |
806 | 9.76k | { |
807 | 9.76k | MOZ_ASSERT(mRawPtr != nullptr, |
808 | 9.76k | "You can't dereference a NULL nsCOMPtr with operator->()."); |
809 | 9.76k | return get(); |
810 | 9.76k | } Unexecuted instantiation: nsCOMPtr<nsIObserver>::operator->() const nsCOMPtr<nsITimer>::operator->() const Line | Count | Source | 806 | 257 | { | 807 | 257 | MOZ_ASSERT(mRawPtr != nullptr, | 808 | 257 | "You can't dereference a NULL nsCOMPtr with operator->()."); | 809 | 257 | return get(); | 810 | 257 | } |
nsCOMPtr<nsIObserverService>::operator->() const Line | Count | Source | 806 | 368 | { | 807 | 368 | MOZ_ASSERT(mRawPtr != nullptr, | 808 | 368 | "You can't dereference a NULL nsCOMPtr with operator->()."); | 809 | 368 | return get(); | 810 | 368 | } |
Unexecuted instantiation: nsCOMPtr<nsIInterfaceRequestor>::operator->() const nsCOMPtr<nsIRunnable>::operator->() const Line | Count | Source | 806 | 34 | { | 807 | 34 | MOZ_ASSERT(mRawPtr != nullptr, | 808 | 34 | "You can't dereference a NULL nsCOMPtr with operator->()."); | 809 | 34 | return get(); | 810 | 34 | } |
Unexecuted instantiation: nsCOMPtr<nsICycleCollectorLogSink>::operator->() const nsCOMPtr<nsIConsoleService>::operator->() const Line | Count | Source | 806 | 8.90k | { | 807 | 8.90k | MOZ_ASSERT(mRawPtr != nullptr, | 808 | 8.90k | "You can't dereference a NULL nsCOMPtr with operator->()."); | 809 | 8.90k | return get(); | 810 | 8.90k | } |
Unexecuted instantiation: nsCOMPtr<nsIScriptError>::operator->() const Unexecuted instantiation: nsCOMPtr<nsISupportsPRUint64>::operator->() const Unexecuted instantiation: nsCOMPtr<nsIMemory>::operator->() const Unexecuted instantiation: nsCOMPtr<nsIMemoryInfoDumper>::operator->() const Unexecuted instantiation: nsCOMPtr<nsIMemoryReporterManager>::operator->() const Unexecuted instantiation: nsCOMPtr<nsIFinishDumpingCallback>::operator->() const nsCOMPtr<nsISimpleEnumerator>::operator->() const Line | Count | Source | 806 | 13 | { | 807 | 13 | MOZ_ASSERT(mRawPtr != nullptr, | 808 | 13 | "You can't dereference a NULL nsCOMPtr with operator->()."); | 809 | 13 | return get(); | 810 | 13 | } |
Unexecuted instantiation: nsCOMPtr<nsIDumpGCAndCCLogsCallback>::operator->() const Unexecuted instantiation: nsCOMPtr<nsICycleCollectorListener>::operator->() const Unexecuted instantiation: nsCOMPtr<nsIMemoryReporter>::operator->() const Unexecuted instantiation: nsCOMPtr<nsIFinishReportingCallback>::operator->() const Unexecuted instantiation: nsCOMPtr<nsIHandleReportCallback>::operator->() const Unexecuted instantiation: nsCOMPtr<nsIGlobalObject>::operator->() const nsCOMPtr<nsISupportsWeakReference>::operator->() const Line | Count | Source | 806 | 189 | { | 807 | 189 | MOZ_ASSERT(mRawPtr != nullptr, | 808 | 189 | "You can't dereference a NULL nsCOMPtr with operator->()."); | 809 | 189 | return get(); | 810 | 189 | } |
Unexecuted instantiation: nsCOMPtr<nsIWebBrowser>::operator->() const Unexecuted instantiation: nsCOMPtr<nsIDroppedLinkHandler>::operator->() const Unexecuted instantiation: nsCOMPtr<nsIXULBrowserWindow>::operator->() const Unexecuted instantiation: nsCOMPtr<nsILoginManagerPrompter>::operator->() const Unexecuted instantiation: nsCOMPtr<TestCOMPtr::IFoo>::operator->() const Unexecuted instantiation: nsCOMPtr<TestHashtables::IFoo>::operator->() const |
811 | | |
812 | | // These are not intended to be used by clients. See |address_of| below. |
813 | 0 | nsCOMPtr<T>* get_address() { return this; } |
814 | | const nsCOMPtr<T>* get_address() const { return this; } |
815 | | |
816 | | public: |
817 | | T& operator*() const |
818 | | { |
819 | | MOZ_ASSERT(mRawPtr != nullptr, |
820 | | "You can't dereference a NULL nsCOMPtr with operator*()."); |
821 | | return *get(); |
822 | | } |
823 | | |
824 | | T** StartAssignment() |
825 | 23 | { |
826 | 23 | #ifndef NSCAP_FEATURE_INLINE_STARTASSIGNMENT |
827 | 23 | return reinterpret_cast<T**>(begin_assignment()); |
828 | | #else |
829 | | assign_assuming_AddRef(nullptr); |
830 | | return reinterpret_cast<T**>(&mRawPtr); |
831 | | #endif |
832 | | } nsCOMPtr<nsITimer>::StartAssignment() Line | Count | Source | 825 | 1 | { | 826 | 1 | #ifndef NSCAP_FEATURE_INLINE_STARTASSIGNMENT | 827 | 1 | return reinterpret_cast<T**>(begin_assignment()); | 828 | | #else | 829 | | assign_assuming_AddRef(nullptr); | 830 | | return reinterpret_cast<T**>(&mRawPtr); | 831 | | #endif | 832 | | } |
Unexecuted instantiation: nsCOMPtr<nsIMemory>::StartAssignment() nsCOMPtr<nsISimpleEnumerator>::StartAssignment() Line | Count | Source | 825 | 22 | { | 826 | 22 | #ifndef NSCAP_FEATURE_INLINE_STARTASSIGNMENT | 827 | 22 | return reinterpret_cast<T**>(begin_assignment()); | 828 | | #else | 829 | | assign_assuming_AddRef(nullptr); | 830 | | return reinterpret_cast<T**>(&mRawPtr); | 831 | | #endif | 832 | | } |
Unexecuted instantiation: nsCOMPtr<nsICycleCollectorListener>::StartAssignment() Unexecuted instantiation: nsCOMPtr<nsICycleCollectorLogSink>::StartAssignment() Unexecuted instantiation: nsCOMPtr<nsIXULBrowserWindow>::StartAssignment() Unexecuted instantiation: nsCOMPtr<TestCOMPtr::IBar>::StartAssignment() Unexecuted instantiation: nsCOMPtr<TestCOMPtr::IFoo>::StartAssignment() Unexecuted instantiation: nsCOMPtr<TestHashtables::IFoo>::StartAssignment() |
833 | | }; |
834 | | |
835 | | |
836 | | /* |
837 | | * Specializing nsCOMPtr for nsISupports allows us to use nsCOMPtr<nsISupports> |
838 | | * the same way people use nsISupports* and void*, i.e., as a `catch-all' |
839 | | * pointing to any valid [XP]COM interface. Otherwise, an nsCOMPtr<nsISupports> |
840 | | * would only be able to point to the single [XP]COM-correct nsISupports |
841 | | * instance within an object; extra querying ensues. Clients need to be able to |
842 | | * pass around arbitrary interface pointers, without hassles, through |
843 | | * intermediary code that doesn't know the exact type. |
844 | | */ |
845 | | template<> |
846 | | class nsCOMPtr<nsISupports> |
847 | | : private nsCOMPtr_base |
848 | | { |
849 | | public: |
850 | | typedef nsISupports element_type; |
851 | | |
852 | | // Constructors |
853 | | |
854 | | nsCOMPtr() |
855 | | : nsCOMPtr_base(nullptr) |
856 | 7.39M | { |
857 | 7.39M | NSCAP_LOG_ASSIGNMENT(this, nullptr); |
858 | 7.39M | } |
859 | | |
860 | | MOZ_IMPLICIT nsCOMPtr(decltype(nullptr)) |
861 | | : nsCOMPtr_base(nullptr) |
862 | | { |
863 | | NSCAP_LOG_ASSIGNMENT(this, nullptr); |
864 | | } |
865 | | |
866 | | nsCOMPtr(const nsCOMPtr<nsISupports>& aSmartPtr) |
867 | | : nsCOMPtr_base(aSmartPtr.mRawPtr) |
868 | 0 | { |
869 | 0 | if (mRawPtr) { |
870 | 0 | NSCAP_ADDREF(this, mRawPtr); |
871 | 0 | } |
872 | 0 | NSCAP_LOG_ASSIGNMENT(this, aSmartPtr.mRawPtr); |
873 | 0 | } |
874 | | |
875 | | MOZ_IMPLICIT nsCOMPtr(nsISupports* aRawPtr) |
876 | | : nsCOMPtr_base(aRawPtr) |
877 | 343 | { |
878 | 343 | if (mRawPtr) { |
879 | 343 | NSCAP_ADDREF(this, mRawPtr); |
880 | 343 | } |
881 | 343 | NSCAP_LOG_ASSIGNMENT(this, aRawPtr); |
882 | 343 | } |
883 | | |
884 | | // Construct from |already_AddRefed|. |
885 | | MOZ_IMPLICIT nsCOMPtr(already_AddRefed<nsISupports>& aSmartPtr) |
886 | | : nsCOMPtr_base(aSmartPtr.take()) |
887 | | { |
888 | | NSCAP_LOG_ASSIGNMENT(this, mRawPtr); |
889 | | } |
890 | | |
891 | | // Construct from |otherComPtr.forget()|. |
892 | | MOZ_IMPLICIT nsCOMPtr(already_AddRefed<nsISupports>&& aSmartPtr) |
893 | | : nsCOMPtr_base(aSmartPtr.take()) |
894 | 7.50M | { |
895 | 7.50M | NSCAP_LOG_ASSIGNMENT(this, mRawPtr); |
896 | 7.50M | } |
897 | | |
898 | | // Construct from |do_QueryInterface(expr)|. |
899 | | MOZ_IMPLICIT nsCOMPtr(const nsQueryInterface aQI) |
900 | | : nsCOMPtr_base(nullptr) |
901 | 6.49M | { |
902 | 6.49M | NSCAP_LOG_ASSIGNMENT(this, nullptr); |
903 | 6.49M | assign_from_qi(aQI, NS_GET_IID(nsISupports)); |
904 | 6.49M | } |
905 | | |
906 | | // Construct from |do_QueryInterface(expr, &rv)|. |
907 | | MOZ_IMPLICIT nsCOMPtr(const nsQueryInterfaceWithError& aQI) |
908 | | : nsCOMPtr_base(nullptr) |
909 | | { |
910 | | NSCAP_LOG_ASSIGNMENT(this, nullptr); |
911 | | assign_from_qi_with_error(aQI, NS_GET_IID(nsISupports)); |
912 | | } |
913 | | |
914 | | // Construct from |do_GetService(cid_expr)|. |
915 | | MOZ_IMPLICIT nsCOMPtr(const nsGetServiceByCID aGS) |
916 | | : nsCOMPtr_base(nullptr) |
917 | | { |
918 | | NSCAP_LOG_ASSIGNMENT(this, nullptr); |
919 | | assign_from_gs_cid(aGS, NS_GET_IID(nsISupports)); |
920 | | } |
921 | | |
922 | | // Construct from |do_GetService(cid_expr, &rv)|. |
923 | | MOZ_IMPLICIT nsCOMPtr(const nsGetServiceByCIDWithError& aGS) |
924 | | : nsCOMPtr_base(nullptr) |
925 | | { |
926 | | NSCAP_LOG_ASSIGNMENT(this, nullptr); |
927 | | assign_from_gs_cid_with_error(aGS, NS_GET_IID(nsISupports)); |
928 | | } |
929 | | |
930 | | // Construct from |do_GetService(contractid_expr)|. |
931 | | MOZ_IMPLICIT nsCOMPtr(const nsGetServiceByContractID aGS) |
932 | | : nsCOMPtr_base(nullptr) |
933 | | { |
934 | | NSCAP_LOG_ASSIGNMENT(this, nullptr); |
935 | | assign_from_gs_contractid(aGS, NS_GET_IID(nsISupports)); |
936 | | } |
937 | | |
938 | | // Construct from |do_GetService(contractid_expr, &rv)|. |
939 | | MOZ_IMPLICIT nsCOMPtr(const nsGetServiceByContractIDWithError& aGS) |
940 | | : nsCOMPtr_base(nullptr) |
941 | | { |
942 | | NSCAP_LOG_ASSIGNMENT(this, nullptr); |
943 | | assign_from_gs_contractid_with_error(aGS, NS_GET_IID(nsISupports)); |
944 | | } |
945 | | |
946 | | // Construct from |do_QueryReferent(ptr)| |
947 | | MOZ_IMPLICIT nsCOMPtr(const nsQueryReferent& aQueryReferent) |
948 | | : nsCOMPtr_base(nullptr) |
949 | | { |
950 | | NSCAP_LOG_ASSIGNMENT(this, nullptr); |
951 | | assign_from_query_referent(aQueryReferent, NS_GET_TEMPLATE_IID(nsISupports)); |
952 | | } |
953 | | |
954 | | // And finally, anything else we might need to construct from can exploit |
955 | | // the |nsCOMPtr_helper| facility |
956 | | MOZ_IMPLICIT nsCOMPtr(const nsCOMPtr_helper& aHelper) |
957 | | : nsCOMPtr_base(nullptr) |
958 | | { |
959 | | NSCAP_LOG_ASSIGNMENT(this, nullptr); |
960 | | assign_from_helper(aHelper, NS_GET_IID(nsISupports)); |
961 | | } |
962 | | |
963 | | |
964 | | // Assignment operators |
965 | | |
966 | | nsCOMPtr<nsISupports>& operator=(const nsCOMPtr<nsISupports>& aRhs) |
967 | | { |
968 | | assign_with_AddRef(aRhs.mRawPtr); |
969 | | return *this; |
970 | | } |
971 | | |
972 | | nsCOMPtr<nsISupports>& operator=(nsISupports* aRhs) |
973 | | { |
974 | | assign_with_AddRef(aRhs); |
975 | | return *this; |
976 | | } |
977 | | |
978 | | nsCOMPtr<nsISupports>& operator=(decltype(nullptr)) |
979 | | { |
980 | | assign_assuming_AddRef(nullptr); |
981 | | return *this; |
982 | | } |
983 | | |
984 | | // Assign from |already_AddRefed|. |
985 | | nsCOMPtr<nsISupports>& operator=(already_AddRefed<nsISupports>& aRhs) |
986 | | { |
987 | | assign_assuming_AddRef(aRhs.take()); |
988 | | return *this; |
989 | | } |
990 | | |
991 | | // Assign from |otherComPtr.forget()|. |
992 | | nsCOMPtr<nsISupports>& operator=(already_AddRefed<nsISupports>&& aRhs) |
993 | | { |
994 | | assign_assuming_AddRef(aRhs.take()); |
995 | | return *this; |
996 | | } |
997 | | |
998 | | // Assign from |do_QueryInterface(expr)|. |
999 | | nsCOMPtr<nsISupports>& operator=(const nsQueryInterface aRhs) |
1000 | | { |
1001 | | assign_from_qi(aRhs, NS_GET_IID(nsISupports)); |
1002 | | return *this; |
1003 | | } |
1004 | | |
1005 | | // Assign from |do_QueryInterface(expr, &rv)|. |
1006 | | nsCOMPtr<nsISupports>& operator=(const nsQueryInterfaceWithError& aRhs) |
1007 | | { |
1008 | | assign_from_qi_with_error(aRhs, NS_GET_IID(nsISupports)); |
1009 | | return *this; |
1010 | | } |
1011 | | |
1012 | | // Assign from |do_GetService(cid_expr)|. |
1013 | | nsCOMPtr<nsISupports>& operator=(const nsGetServiceByCID aRhs) |
1014 | | { |
1015 | | assign_from_gs_cid(aRhs, NS_GET_IID(nsISupports)); |
1016 | | return *this; |
1017 | | } |
1018 | | |
1019 | | // Assign from |do_GetService(cid_expr, &rv)|. |
1020 | | nsCOMPtr<nsISupports>& operator=(const nsGetServiceByCIDWithError& aRhs) |
1021 | | { |
1022 | | assign_from_gs_cid_with_error(aRhs, NS_GET_IID(nsISupports)); |
1023 | | return *this; |
1024 | | } |
1025 | | |
1026 | | // Assign from |do_GetService(contractid_expr)|. |
1027 | | nsCOMPtr<nsISupports>& operator=(const nsGetServiceByContractID aRhs) |
1028 | | { |
1029 | | assign_from_gs_contractid(aRhs, NS_GET_IID(nsISupports)); |
1030 | | return *this; |
1031 | | } |
1032 | | |
1033 | | // Assign from |do_GetService(contractid_expr, &rv)|. |
1034 | | nsCOMPtr<nsISupports>& operator=(const nsGetServiceByContractIDWithError& aRhs) |
1035 | | { |
1036 | | assign_from_gs_contractid_with_error(aRhs, NS_GET_IID(nsISupports)); |
1037 | | return *this; |
1038 | | } |
1039 | | |
1040 | | // Assign from |do_QueryReferent(ptr)|. |
1041 | | nsCOMPtr<nsISupports>& operator=(const nsQueryReferent& aRhs) |
1042 | | { |
1043 | | assign_from_query_referent(aRhs, NS_GET_TEMPLATE_IID(nsISupports)); |
1044 | | return *this; |
1045 | | } |
1046 | | |
1047 | | // And finally, anything else we might need to assign from can exploit the |
1048 | | // nsCOMPtr_helper facility |
1049 | | nsCOMPtr<nsISupports>& operator=(const nsCOMPtr_helper& aRhs) |
1050 | | { |
1051 | | assign_from_helper(aRhs, NS_GET_IID(nsISupports)); |
1052 | | return *this; |
1053 | | } |
1054 | | |
1055 | | // Exchange ownership with |aRhs|; can save a pair of refcount operations. |
1056 | | void swap(nsCOMPtr<nsISupports>& aRhs) |
1057 | | { |
1058 | | nsISupports* temp = aRhs.mRawPtr; |
1059 | | NSCAP_LOG_ASSIGNMENT(&aRhs, mRawPtr); |
1060 | | NSCAP_LOG_ASSIGNMENT(this, temp); |
1061 | | NSCAP_LOG_RELEASE(this, mRawPtr); |
1062 | | NSCAP_LOG_RELEASE(&aRhs, temp); |
1063 | | aRhs.mRawPtr = mRawPtr; |
1064 | | mRawPtr = temp; |
1065 | | } |
1066 | | |
1067 | | // Exchange ownership with |aRhs|; can save a pair of refcount operations. |
1068 | | void swap(nsISupports*& aRhs) |
1069 | | { |
1070 | | nsISupports* temp = aRhs; |
1071 | | NSCAP_LOG_ASSIGNMENT(this, temp); |
1072 | | NSCAP_LOG_RELEASE(this, mRawPtr); |
1073 | | aRhs = mRawPtr; |
1074 | | mRawPtr = temp; |
1075 | | } |
1076 | | |
1077 | | // Return the value of mRawPtr and null out mRawPtr. Useful for |
1078 | | // already_AddRefed return values. |
1079 | | already_AddRefed<nsISupports> forget() |
1080 | | { |
1081 | | nsISupports* temp = nullptr; |
1082 | | swap(temp); |
1083 | | return already_AddRefed<nsISupports>(temp); |
1084 | | } |
1085 | | |
1086 | | // Set the target of aRhs to the value of mRawPtr and null out mRawPtr. |
1087 | | // Useful to avoid unnecessary AddRef/Release pairs with "out" |
1088 | | // parameters. |
1089 | | void forget(nsISupports** aRhs) |
1090 | | { |
1091 | | NS_ASSERTION(aRhs, "Null pointer passed to forget!"); |
1092 | | *aRhs = nullptr; |
1093 | | swap(*aRhs); |
1094 | | } |
1095 | | |
1096 | | // Other pointer operators |
1097 | | |
1098 | | // Prefer the implicit conversion provided automatically by |
1099 | | // |operator nsISupports*() const|. Use |get()| to resolve ambiguity or to |
1100 | | // get a castable pointer. |
1101 | 44.7M | nsISupports* get() const { return reinterpret_cast<nsISupports*>(mRawPtr); } |
1102 | | |
1103 | | // Makes an nsCOMPtr act like its underlying raw pointer type whenever it is |
1104 | | // used in a context where a raw pointer is expected. It is this operator |
1105 | | // that makes an nsCOMPtr substitutable for a raw pointer. |
1106 | | // |
1107 | | // Prefer the implicit use of this operator to calling |get()|, except where |
1108 | | // necessary to resolve ambiguity/ |
1109 | 39.4M | operator nsISupports* () const { return get(); } |
1110 | | |
1111 | | nsISupports* operator->() const MOZ_NO_ADDREF_RELEASE_ON_RETURN |
1112 | | { |
1113 | | MOZ_ASSERT(mRawPtr != nullptr, |
1114 | | "You can't dereference a NULL nsCOMPtr with operator->()."); |
1115 | | return get(); |
1116 | | } |
1117 | | |
1118 | | // These are not intended to be used by clients. See |address_of| below. |
1119 | | nsCOMPtr<nsISupports>* get_address() { return this; } |
1120 | | const nsCOMPtr<nsISupports>* get_address() const { return this; } |
1121 | | |
1122 | | public: |
1123 | | |
1124 | | nsISupports& operator*() const |
1125 | | { |
1126 | | MOZ_ASSERT(mRawPtr != nullptr, |
1127 | | "You can't dereference a NULL nsCOMPtr with operator*()."); |
1128 | | return *get(); |
1129 | | } |
1130 | | |
1131 | | nsISupports** StartAssignment() |
1132 | 1.62M | { |
1133 | 1.62M | #ifndef NSCAP_FEATURE_INLINE_STARTASSIGNMENT |
1134 | 1.62M | return reinterpret_cast<nsISupports**>(begin_assignment()); |
1135 | | #else |
1136 | | assign_assuming_AddRef(nullptr); |
1137 | | return reinterpret_cast<nsISupports**>(&mRawPtr); |
1138 | | #endif |
1139 | | } |
1140 | | }; |
1141 | | |
1142 | | template<typename T> |
1143 | | inline void |
1144 | | ImplCycleCollectionUnlink(nsCOMPtr<T>& aField) |
1145 | 0 | { |
1146 | 0 | aField = nullptr; |
1147 | 0 | } Unexecuted instantiation: void ImplCycleCollectionUnlink<nsIWebBrowserChrome3>(nsCOMPtr<nsIWebBrowserChrome3>&) Unexecuted instantiation: void ImplCycleCollectionUnlink<nsIWebNavigation>(nsCOMPtr<nsIWebNavigation>&) |
1148 | | |
1149 | | template<typename T> |
1150 | | inline void |
1151 | | ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, |
1152 | | nsCOMPtr<T>& aField, |
1153 | | const char* aName, |
1154 | | uint32_t aFlags = 0) |
1155 | 0 | { |
1156 | 0 | CycleCollectionNoteChild(aCallback, aField.get(), aName, aFlags); |
1157 | 0 | } Unexecuted instantiation: void ImplCycleCollectionTraverse<nsIWebBrowserChrome3>(nsCycleCollectionTraversalCallback&, nsCOMPtr<nsIWebBrowserChrome3>&, char const*, unsigned int) Unexecuted instantiation: void ImplCycleCollectionTraverse<nsIWebNavigation>(nsCycleCollectionTraversalCallback&, nsCOMPtr<nsIWebNavigation>&, char const*, unsigned int) |
1158 | | |
1159 | | #ifndef NSCAP_FEATURE_USE_BASE |
1160 | | template<class T> |
1161 | | void |
1162 | | nsCOMPtr<T>::assign_with_AddRef(nsISupports* aRawPtr) |
1163 | | { |
1164 | | if (aRawPtr) { |
1165 | | NSCAP_ADDREF(this, aRawPtr); |
1166 | | } |
1167 | | assign_assuming_AddRef(reinterpret_cast<T*>(aRawPtr)); |
1168 | | } |
1169 | | |
1170 | | template<class T> |
1171 | | void |
1172 | | nsCOMPtr<T>::assign_from_qi(const nsQueryInterface aQI, const nsIID& aIID) |
1173 | | { |
1174 | | void* newRawPtr; |
1175 | | if (NS_FAILED(aQI(aIID, &newRawPtr))) { |
1176 | | newRawPtr = nullptr; |
1177 | | } |
1178 | | assign_assuming_AddRef(static_cast<T*>(newRawPtr)); |
1179 | | } |
1180 | | |
1181 | | template<class T> |
1182 | | void |
1183 | | nsCOMPtr<T>::assign_from_qi_with_error(const nsQueryInterfaceWithError& aQI, |
1184 | | const nsIID& aIID) |
1185 | | { |
1186 | | void* newRawPtr; |
1187 | | if (NS_FAILED(aQI(aIID, &newRawPtr))) { |
1188 | | newRawPtr = nullptr; |
1189 | | } |
1190 | | assign_assuming_AddRef(static_cast<T*>(newRawPtr)); |
1191 | | } |
1192 | | |
1193 | | template<class T> |
1194 | | void |
1195 | | nsCOMPtr<T>::assign_from_gs_cid(const nsGetServiceByCID aGS, const nsIID& aIID) |
1196 | | { |
1197 | | void* newRawPtr; |
1198 | | if (NS_FAILED(aGS(aIID, &newRawPtr))) { |
1199 | | newRawPtr = nullptr; |
1200 | | } |
1201 | | assign_assuming_AddRef(static_cast<T*>(newRawPtr)); |
1202 | | } |
1203 | | |
1204 | | template<class T> |
1205 | | void |
1206 | | nsCOMPtr<T>::assign_from_gs_cid_with_error(const nsGetServiceByCIDWithError& aGS, |
1207 | | const nsIID& aIID) |
1208 | | { |
1209 | | void* newRawPtr; |
1210 | | if (NS_FAILED(aGS(aIID, &newRawPtr))) { |
1211 | | newRawPtr = nullptr; |
1212 | | } |
1213 | | assign_assuming_AddRef(static_cast<T*>(newRawPtr)); |
1214 | | } |
1215 | | |
1216 | | template<class T> |
1217 | | void |
1218 | | nsCOMPtr<T>::assign_from_gs_contractid(const nsGetServiceByContractID aGS, |
1219 | | const nsIID& aIID) |
1220 | | { |
1221 | | void* newRawPtr; |
1222 | | if (NS_FAILED(aGS(aIID, &newRawPtr))) { |
1223 | | newRawPtr = nullptr; |
1224 | | } |
1225 | | assign_assuming_AddRef(static_cast<T*>(newRawPtr)); |
1226 | | } |
1227 | | |
1228 | | template<class T> |
1229 | | void |
1230 | | nsCOMPtr<T>::assign_from_gs_contractid_with_error( |
1231 | | const nsGetServiceByContractIDWithError& aGS, const nsIID& aIID) |
1232 | | { |
1233 | | void* newRawPtr; |
1234 | | if (NS_FAILED(aGS(aIID, &newRawPtr))) { |
1235 | | newRawPtr = nullptr; |
1236 | | } |
1237 | | assign_assuming_AddRef(static_cast<T*>(newRawPtr)); |
1238 | | } |
1239 | | |
1240 | | template<class T> |
1241 | | void |
1242 | | nsCOMPtr<T>::assign_from_query_referent( |
1243 | | const nsQueryReferent& aQueryReferent, const nsIID& aIID) |
1244 | | { |
1245 | | void* newRawPtr; |
1246 | | if (NS_FAILED(aQueryReferent(aIID, &newRawPtr))) { |
1247 | | newRawPtr = nullptr; |
1248 | | } |
1249 | | assign_assuming_AddRef(static_cast<T*>(newRawPtr)); |
1250 | | } |
1251 | | |
1252 | | template<class T> |
1253 | | void |
1254 | | nsCOMPtr<T>::assign_from_helper(const nsCOMPtr_helper& helper, const nsIID& aIID) |
1255 | | { |
1256 | | void* newRawPtr; |
1257 | | if (NS_FAILED(helper(aIID, &newRawPtr))) { |
1258 | | newRawPtr = nullptr; |
1259 | | } |
1260 | | assign_assuming_AddRef(static_cast<T*>(newRawPtr)); |
1261 | | } |
1262 | | |
1263 | | template<class T> |
1264 | | void** |
1265 | | nsCOMPtr<T>::begin_assignment() |
1266 | | { |
1267 | | assign_assuming_AddRef(nullptr); |
1268 | | union |
1269 | | { |
1270 | | T** mT; |
1271 | | void** mVoid; |
1272 | | } result; |
1273 | | result.mT = &mRawPtr; |
1274 | | return result.mVoid; |
1275 | | } |
1276 | | #endif |
1277 | | |
1278 | | template<class T> |
1279 | | inline nsCOMPtr<T>* |
1280 | | address_of(nsCOMPtr<T>& aPtr) |
1281 | 0 | { |
1282 | 0 | return aPtr.get_address(); |
1283 | 0 | } |
1284 | | |
1285 | | template<class T> |
1286 | | inline const nsCOMPtr<T>* |
1287 | | address_of(const nsCOMPtr<T>& aPtr) |
1288 | | { |
1289 | | return aPtr.get_address(); |
1290 | | } |
1291 | | |
1292 | | /** |
1293 | | * This class is designed to be used for anonymous temporary objects in the |
1294 | | * argument list of calls that return COM interface pointers, e.g., |
1295 | | * |
1296 | | * nsCOMPtr<IFoo> fooP; |
1297 | | * ...->QueryInterface(iid, getter_AddRefs(fooP)) |
1298 | | * |
1299 | | * DO NOT USE THIS TYPE DIRECTLY IN YOUR CODE. Use |getter_AddRefs()| instead. |
1300 | | * |
1301 | | * When initialized with a |nsCOMPtr|, as in the example above, it returns |
1302 | | * a |void**|, a |T**|, or an |nsISupports**| as needed, that the outer call |
1303 | | * (|QueryInterface| in this case) can fill in. |
1304 | | * |
1305 | | * This type should be a nested class inside |nsCOMPtr<T>|. |
1306 | | */ |
1307 | | template<class T> |
1308 | | class nsGetterAddRefs |
1309 | | { |
1310 | | public: |
1311 | | explicit nsGetterAddRefs(nsCOMPtr<T>& aSmartPtr) |
1312 | | : mTargetSmartPtr(aSmartPtr) |
1313 | 23 | { |
1314 | 23 | } Unexecuted instantiation: nsGetterAddRefs<nsIMemory>::nsGetterAddRefs(nsCOMPtr<nsIMemory>&) nsGetterAddRefs<nsISimpleEnumerator>::nsGetterAddRefs(nsCOMPtr<nsISimpleEnumerator>&) Line | Count | Source | 1313 | 22 | { | 1314 | 22 | } |
Unexecuted instantiation: nsGetterAddRefs<nsICycleCollectorListener>::nsGetterAddRefs(nsCOMPtr<nsICycleCollectorListener>&) Unexecuted instantiation: nsGetterAddRefs<nsICycleCollectorLogSink>::nsGetterAddRefs(nsCOMPtr<nsICycleCollectorLogSink>&) nsGetterAddRefs<nsITimer>::nsGetterAddRefs(nsCOMPtr<nsITimer>&) Line | Count | Source | 1313 | 1 | { | 1314 | 1 | } |
Unexecuted instantiation: nsGetterAddRefs<nsIXULBrowserWindow>::nsGetterAddRefs(nsCOMPtr<nsIXULBrowserWindow>&) Unexecuted instantiation: nsGetterAddRefs<TestCOMPtr::IBar>::nsGetterAddRefs(nsCOMPtr<TestCOMPtr::IBar>&) Unexecuted instantiation: nsGetterAddRefs<TestCOMPtr::IFoo>::nsGetterAddRefs(nsCOMPtr<TestCOMPtr::IFoo>&) Unexecuted instantiation: nsGetterAddRefs<TestHashtables::IFoo>::nsGetterAddRefs(nsCOMPtr<TestHashtables::IFoo>&) |
1315 | | |
1316 | | #if defined(NSCAP_FEATURE_TEST_DONTQUERY_CASES) || defined(NSCAP_LOG_EXTERNAL_ASSIGNMENT) |
1317 | | ~nsGetterAddRefs() |
1318 | | { |
1319 | | #ifdef NSCAP_LOG_EXTERNAL_ASSIGNMENT |
1320 | | NSCAP_LOG_ASSIGNMENT(reinterpret_cast<void*>(address_of(mTargetSmartPtr)), |
1321 | | mTargetSmartPtr.get()); |
1322 | | #endif |
1323 | | |
1324 | | #ifdef NSCAP_FEATURE_TEST_DONTQUERY_CASES |
1325 | | mTargetSmartPtr.Assert_NoQueryNeeded(); |
1326 | | #endif |
1327 | | } |
1328 | | #endif |
1329 | | |
1330 | | operator void**() |
1331 | 0 | { |
1332 | 0 | return reinterpret_cast<void**>(mTargetSmartPtr.StartAssignment()); |
1333 | 0 | } Unexecuted instantiation: nsGetterAddRefs<nsIAuthPrompt2>::operator void**() Unexecuted instantiation: nsGetterAddRefs<TestCOMPtr::IBar>::operator void**() Unexecuted instantiation: nsGetterAddRefs<TestCOMPtr::IFoo>::operator void**() |
1334 | | |
1335 | 20 | operator T**() { return mTargetSmartPtr.StartAssignment(); } nsGetterAddRefs<nsITimer>::operator nsITimer**() Line | Count | Source | 1335 | 1 | operator T**() { return mTargetSmartPtr.StartAssignment(); } |
Unexecuted instantiation: nsGetterAddRefs<nsIMemory>::operator nsIMemory**() nsGetterAddRefs<nsISimpleEnumerator>::operator nsISimpleEnumerator**() Line | Count | Source | 1335 | 19 | operator T**() { return mTargetSmartPtr.StartAssignment(); } |
Unexecuted instantiation: nsGetterAddRefs<nsICycleCollectorListener>::operator nsICycleCollectorListener**() Unexecuted instantiation: nsGetterAddRefs<nsICycleCollectorLogSink>::operator nsICycleCollectorLogSink**() Unexecuted instantiation: nsGetterAddRefs<nsIXULBrowserWindow>::operator nsIXULBrowserWindow**() Unexecuted instantiation: nsGetterAddRefs<TestCOMPtr::IFoo>::operator TestCOMPtr::IFoo**() Unexecuted instantiation: nsGetterAddRefs<TestHashtables::IFoo>::operator TestHashtables::IFoo**() |
1336 | | T*& operator*() { return *(mTargetSmartPtr.StartAssignment()); } |
1337 | | |
1338 | | private: |
1339 | | nsCOMPtr<T>& mTargetSmartPtr; |
1340 | | }; |
1341 | | |
1342 | | |
1343 | | template<> |
1344 | | class nsGetterAddRefs<nsISupports> |
1345 | | { |
1346 | | public: |
1347 | | explicit nsGetterAddRefs(nsCOMPtr<nsISupports>& aSmartPtr) |
1348 | | : mTargetSmartPtr(aSmartPtr) |
1349 | 1.62M | { |
1350 | 1.62M | } |
1351 | | |
1352 | | #ifdef NSCAP_LOG_EXTERNAL_ASSIGNMENT |
1353 | | ~nsGetterAddRefs() |
1354 | | { |
1355 | | NSCAP_LOG_ASSIGNMENT(reinterpret_cast<void*>(address_of(mTargetSmartPtr)), |
1356 | | mTargetSmartPtr.get()); |
1357 | | } |
1358 | | #endif |
1359 | | |
1360 | | operator void**() |
1361 | | { |
1362 | | return reinterpret_cast<void**>(mTargetSmartPtr.StartAssignment()); |
1363 | | } |
1364 | | |
1365 | 13 | operator nsISupports**() { return mTargetSmartPtr.StartAssignment(); } |
1366 | | nsISupports*& operator*() { return *(mTargetSmartPtr.StartAssignment()); } |
1367 | | |
1368 | | private: |
1369 | | nsCOMPtr<nsISupports>& mTargetSmartPtr; |
1370 | | }; |
1371 | | |
1372 | | template<class T> |
1373 | | inline nsGetterAddRefs<T> |
1374 | | getter_AddRefs(nsCOMPtr<T>& aSmartPtr) |
1375 | 1.62M | { |
1376 | 1.62M | return nsGetterAddRefs<T>(aSmartPtr); |
1377 | 1.62M | } nsGetterAddRefs<nsITimer> getter_AddRefs<nsITimer>(nsCOMPtr<nsITimer>&) Line | Count | Source | 1375 | 1 | { | 1376 | 1 | return nsGetterAddRefs<T>(aSmartPtr); | 1377 | 1 | } |
Unexecuted instantiation: nsGetterAddRefs<nsIMemory> getter_AddRefs<nsIMemory>(nsCOMPtr<nsIMemory>&) nsGetterAddRefs<nsISimpleEnumerator> getter_AddRefs<nsISimpleEnumerator>(nsCOMPtr<nsISimpleEnumerator>&) Line | Count | Source | 1375 | 22 | { | 1376 | 22 | return nsGetterAddRefs<T>(aSmartPtr); | 1377 | 22 | } |
nsGetterAddRefs<nsISupports> getter_AddRefs<nsISupports>(nsCOMPtr<nsISupports>&) Line | Count | Source | 1375 | 1.62M | { | 1376 | 1.62M | return nsGetterAddRefs<T>(aSmartPtr); | 1377 | 1.62M | } |
Unexecuted instantiation: nsGetterAddRefs<nsICycleCollectorListener> getter_AddRefs<nsICycleCollectorListener>(nsCOMPtr<nsICycleCollectorListener>&) Unexecuted instantiation: nsGetterAddRefs<nsICycleCollectorLogSink> getter_AddRefs<nsICycleCollectorLogSink>(nsCOMPtr<nsICycleCollectorLogSink>&) Unexecuted instantiation: nsGetterAddRefs<nsIXULBrowserWindow> getter_AddRefs<nsIXULBrowserWindow>(nsCOMPtr<nsIXULBrowserWindow>&) Unexecuted instantiation: nsGetterAddRefs<TestCOMPtr::IBar> getter_AddRefs<TestCOMPtr::IBar>(nsCOMPtr<TestCOMPtr::IBar>&) Unexecuted instantiation: nsGetterAddRefs<TestCOMPtr::IFoo> getter_AddRefs<TestCOMPtr::IFoo>(nsCOMPtr<TestCOMPtr::IFoo>&) Unexecuted instantiation: nsGetterAddRefs<TestHashtables::IFoo> getter_AddRefs<TestHashtables::IFoo>(nsCOMPtr<TestHashtables::IFoo>&) |
1378 | | |
1379 | | template<class T, class DestinationType> |
1380 | | inline nsresult |
1381 | | CallQueryInterface(T* aSource, nsGetterAddRefs<DestinationType> aDestination) |
1382 | | { |
1383 | | return CallQueryInterface(aSource, |
1384 | | static_cast<DestinationType**>(aDestination)); |
1385 | | } |
1386 | | |
1387 | | |
1388 | | // Comparing two |nsCOMPtr|s |
1389 | | |
1390 | | template<class T, class U> |
1391 | | inline bool |
1392 | | operator==(const nsCOMPtr<T>& aLhs, const nsCOMPtr<U>& aRhs) |
1393 | 0 | { |
1394 | 0 | return static_cast<const T*>(aLhs.get()) == static_cast<const U*>(aRhs.get()); |
1395 | 0 | } Unexecuted instantiation: bool operator==<TestCOMPtr::IFoo, TestCOMPtr::IFoo>(nsCOMPtr<TestCOMPtr::IFoo> const&, nsCOMPtr<TestCOMPtr::IFoo> const&) Unexecuted instantiation: bool operator==<nsIAsyncInputStream, nsIAsyncInputStream>(nsCOMPtr<nsIAsyncInputStream> const&, nsCOMPtr<nsIAsyncInputStream> const&) |
1396 | | |
1397 | | |
1398 | | template<class T, class U> |
1399 | | inline bool |
1400 | | operator!=(const nsCOMPtr<T>& aLhs, const nsCOMPtr<U>& aRhs) |
1401 | 0 | { |
1402 | 0 | return static_cast<const T*>(aLhs.get()) != static_cast<const U*>(aRhs.get()); |
1403 | 0 | } Unexecuted instantiation: bool operator!=<TestCOMPtr::IFoo, TestCOMPtr::IFoo>(nsCOMPtr<TestCOMPtr::IFoo> const&, nsCOMPtr<TestCOMPtr::IFoo> const&) Unexecuted instantiation: bool operator!=<nsIAsyncInputStream, nsIAsyncInputStream>(nsCOMPtr<nsIAsyncInputStream> const&, nsCOMPtr<nsIAsyncInputStream> const&) |
1404 | | |
1405 | | |
1406 | | // Comparing an |nsCOMPtr| to a raw pointer |
1407 | | |
1408 | | template<class T, class U> |
1409 | | inline bool |
1410 | | operator==(const nsCOMPtr<T>& aLhs, const U* aRhs) |
1411 | | { |
1412 | | return static_cast<const T*>(aLhs.get()) == aRhs; |
1413 | | } |
1414 | | |
1415 | | template<class T, class U> |
1416 | | inline bool |
1417 | | operator==(const U* aLhs, const nsCOMPtr<T>& aRhs) |
1418 | 0 | { |
1419 | 0 | return aLhs == static_cast<const T*>(aRhs.get()); |
1420 | 0 | } |
1421 | | |
1422 | | template<class T, class U> |
1423 | | inline bool |
1424 | | operator!=(const nsCOMPtr<T>& aLhs, const U* aRhs) |
1425 | | { |
1426 | | return static_cast<const T*>(aLhs.get()) != aRhs; |
1427 | | } |
1428 | | |
1429 | | template<class T, class U> |
1430 | | inline bool |
1431 | | operator!=(const U* aLhs, const nsCOMPtr<T>& aRhs) |
1432 | | { |
1433 | | return aLhs != static_cast<const T*>(aRhs.get()); |
1434 | | } |
1435 | | |
1436 | | template<class T, class U> |
1437 | | inline bool |
1438 | | operator==(const nsCOMPtr<T>& aLhs, U* aRhs) |
1439 | 0 | { |
1440 | 0 | return static_cast<const T*>(aLhs.get()) == const_cast<const U*>(aRhs); |
1441 | 0 | } |
1442 | | |
1443 | | template<class T, class U> |
1444 | | inline bool |
1445 | | operator==(U* aLhs, const nsCOMPtr<T>& aRhs) |
1446 | 0 | { |
1447 | 0 | return const_cast<const U*>(aLhs) == static_cast<const T*>(aRhs.get()); |
1448 | 0 | } |
1449 | | |
1450 | | template<class T, class U> |
1451 | | inline bool |
1452 | | operator!=(const nsCOMPtr<T>& aLhs, U* aRhs) |
1453 | 0 | { |
1454 | 0 | return static_cast<const T*>(aLhs.get()) != const_cast<const U*>(aRhs); |
1455 | 0 | } |
1456 | | |
1457 | | template<class T, class U> |
1458 | | inline bool |
1459 | | operator!=(U* aLhs, const nsCOMPtr<T>& aRhs) |
1460 | 0 | { |
1461 | 0 | return const_cast<const U*>(aLhs) != static_cast<const T*>(aRhs.get()); |
1462 | 0 | } |
1463 | | |
1464 | | |
1465 | | |
1466 | | // Comparing an |nsCOMPtr| to |nullptr| |
1467 | | |
1468 | | template<class T> |
1469 | | inline bool |
1470 | | operator==(const nsCOMPtr<T>& aLhs, decltype(nullptr)) |
1471 | | { |
1472 | | return aLhs.get() == nullptr; |
1473 | | } |
1474 | | |
1475 | | template<class T> |
1476 | | inline bool |
1477 | | operator==(decltype(nullptr), const nsCOMPtr<T>& aRhs) |
1478 | 0 | { |
1479 | 0 | return nullptr == aRhs.get(); |
1480 | 0 | } |
1481 | | |
1482 | | template<class T> |
1483 | | inline bool |
1484 | | operator!=(const nsCOMPtr<T>& aLhs, decltype(nullptr)) |
1485 | | { |
1486 | | return aLhs.get() != nullptr; |
1487 | | } |
1488 | | |
1489 | | template<class T> |
1490 | | inline bool |
1491 | | operator!=(decltype(nullptr), const nsCOMPtr<T>& aRhs) |
1492 | | { |
1493 | | return nullptr != aRhs.get(); |
1494 | | } |
1495 | | |
1496 | | |
1497 | | // Comparing any two [XP]COM objects for identity |
1498 | | |
1499 | | inline bool |
1500 | | SameCOMIdentity(nsISupports* aLhs, nsISupports* aRhs) |
1501 | | { |
1502 | | return nsCOMPtr<nsISupports>(do_QueryInterface(aLhs)) == |
1503 | | nsCOMPtr<nsISupports>(do_QueryInterface(aRhs)); |
1504 | | } |
1505 | | |
1506 | | |
1507 | | |
1508 | | template<class SourceType, class DestinationType> |
1509 | | inline nsresult |
1510 | | CallQueryInterface(nsCOMPtr<SourceType>& aSourcePtr, DestinationType** aDestPtr) |
1511 | | { |
1512 | | return CallQueryInterface(aSourcePtr.get(), aDestPtr); |
1513 | | } |
1514 | | |
1515 | | template <class T> |
1516 | | RefPtr<T>::RefPtr(const nsQueryReferent& aQueryReferent) |
1517 | | { |
1518 | | void* newRawPtr; |
1519 | | if (NS_FAILED(aQueryReferent(NS_GET_TEMPLATE_IID(T), &newRawPtr))) { |
1520 | | newRawPtr = nullptr; |
1521 | | } |
1522 | | mRawPtr = static_cast<T*>(newRawPtr); |
1523 | | } |
1524 | | |
1525 | | template <class T> |
1526 | | RefPtr<T>::RefPtr(const nsCOMPtr_helper& aHelper) |
1527 | 0 | { |
1528 | 0 | void* newRawPtr; |
1529 | 0 | if (NS_FAILED(aHelper(NS_GET_TEMPLATE_IID(T), &newRawPtr))) { |
1530 | 0 | newRawPtr = nullptr; |
1531 | 0 | } |
1532 | 0 | mRawPtr = static_cast<T*>(newRawPtr); |
1533 | 0 | } Unexecuted instantiation: RefPtr<TestNsRefPtr::Foo>::RefPtr(nsCOMPtr_helper const&) Unexecuted instantiation: RefPtr<TestNsRefPtr::Bar>::RefPtr(nsCOMPtr_helper const&) |
1534 | | |
1535 | | template <class T> |
1536 | | RefPtr<T>& |
1537 | | RefPtr<T>::operator=(const nsQueryReferent& aQueryReferent) |
1538 | | { |
1539 | | void* newRawPtr; |
1540 | | if (NS_FAILED(aQueryReferent(NS_GET_TEMPLATE_IID(T), &newRawPtr))) { |
1541 | | newRawPtr = nullptr; |
1542 | | } |
1543 | | assign_assuming_AddRef(static_cast<T*>(newRawPtr)); |
1544 | | return *this; |
1545 | | } |
1546 | | |
1547 | | template <class T> |
1548 | | RefPtr<T>& |
1549 | | RefPtr<T>::operator=(const nsCOMPtr_helper& aHelper) |
1550 | 0 | { |
1551 | 0 | void* newRawPtr; |
1552 | 0 | if (NS_FAILED(aHelper(NS_GET_TEMPLATE_IID(T), &newRawPtr))) { |
1553 | 0 | newRawPtr = nullptr; |
1554 | 0 | } |
1555 | 0 | assign_assuming_AddRef(static_cast<T*>(newRawPtr)); |
1556 | 0 | return *this; |
1557 | 0 | } |
1558 | | |
1559 | | template <class T> |
1560 | | inline already_AddRefed<T> |
1561 | | do_AddRef(const nsCOMPtr<T>& aObj) |
1562 | | { |
1563 | | nsCOMPtr<T> ref(aObj); |
1564 | | return ref.forget(); |
1565 | | } |
1566 | | |
1567 | | #endif // !defined(nsCOMPtr_h___) |