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/. */
10 nsQueryInterface::operator()(const nsIID
& aIID
, void** aAnswer
) const
14 status
= mRawPtr
->QueryInterface(aIID
, aAnswer
);
15 #ifdef NSCAP_FEATURE_TEST_NONNULL_QUERY_SUCCEEDS
16 NS_ASSERTION(NS_SUCCEEDED(status
),
17 "interface not found---were you expecting that?");
20 status
= NS_ERROR_NULL_POINTER
;
27 nsQueryInterfaceWithError::operator()(const nsIID
& aIID
, void** aAnswer
) const
31 status
= mRawPtr
->QueryInterface(aIID
, aAnswer
);
32 #ifdef NSCAP_FEATURE_TEST_NONNULL_QUERY_SUCCEEDS
33 NS_ASSERTION(NS_SUCCEEDED(status
),
34 "interface not found---were you expecting that?");
37 status
= NS_ERROR_NULL_POINTER
;
47 nsCOMPtr_base::assign_with_AddRef(nsISupports
* aRawPtr
)
50 NSCAP_ADDREF(this, aRawPtr
);
52 assign_assuming_AddRef(aRawPtr
);
56 nsCOMPtr_base::assign_from_qi(const nsQueryInterface aQI
, const nsIID
& aIID
)
59 if (NS_FAILED(aQI(aIID
, &newRawPtr
))) {
62 assign_assuming_AddRef(static_cast<nsISupports
*>(newRawPtr
));
66 nsCOMPtr_base::assign_from_qi_with_error(const nsQueryInterfaceWithError
& aQI
,
70 if (NS_FAILED(aQI(aIID
, &newRawPtr
))) {
73 assign_assuming_AddRef(static_cast<nsISupports
*>(newRawPtr
));
77 nsCOMPtr_base::assign_from_gs_cid(const nsGetServiceByCID aGS
,
81 if (NS_FAILED(aGS(aIID
, &newRawPtr
))) {
84 assign_assuming_AddRef(static_cast<nsISupports
*>(newRawPtr
));
88 nsCOMPtr_base::assign_from_gs_cid_with_error(
89 const nsGetServiceByCIDWithError
& aGS
, const nsIID
& aIID
)
92 if (NS_FAILED(aGS(aIID
, &newRawPtr
))) {
95 assign_assuming_AddRef(static_cast<nsISupports
*>(newRawPtr
));
99 nsCOMPtr_base::assign_from_gs_contractid(const nsGetServiceByContractID aGS
,
103 if (NS_FAILED(aGS(aIID
, &newRawPtr
))) {
106 assign_assuming_AddRef(static_cast<nsISupports
*>(newRawPtr
));
110 nsCOMPtr_base::assign_from_gs_contractid_with_error(
111 const nsGetServiceByContractIDWithError
& aGS
, const nsIID
& aIID
)
114 if (NS_FAILED(aGS(aIID
, &newRawPtr
))) {
117 assign_assuming_AddRef(static_cast<nsISupports
*>(newRawPtr
));
121 nsCOMPtr_base::assign_from_helper(const nsCOMPtr_helper
& aHelper
,
125 if (NS_FAILED(aHelper(aIID
, &newRawPtr
))) {
128 assign_assuming_AddRef(static_cast<nsISupports
*>(newRawPtr
));
132 nsCOMPtr_base::begin_assignment()
134 assign_assuming_AddRef(0);
135 return reinterpret_cast<void**>(&mRawPtr
);