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/. */
9 nsresult
nsQueryInterfaceISupports::operator()(const nsIID
& aIID
,
10 void** aAnswer
) const {
13 status
= mRawPtr
->QueryInterface(aIID
, aAnswer
);
15 status
= NS_ERROR_NULL_POINTER
;
21 nsresult
nsQueryInterfaceISupportsWithError::operator()(const nsIID
& aIID
,
22 void** aAnswer
) const {
25 status
= mRawPtr
->QueryInterface(aIID
, aAnswer
);
27 status
= NS_ERROR_NULL_POINTER
;
36 void nsCOMPtr_base::assign_with_AddRef(nsISupports
* aRawPtr
) {
38 NSCAP_ADDREF(this, aRawPtr
);
40 assign_assuming_AddRef(aRawPtr
);
43 void nsCOMPtr_base::assign_from_qi(const nsQueryInterfaceISupports aQI
,
46 if (NS_FAILED(aQI(aIID
, &newRawPtr
))) {
49 assign_assuming_AddRef(static_cast<nsISupports
*>(newRawPtr
));
52 void nsCOMPtr_base::assign_from_qi_with_error(
53 const nsQueryInterfaceISupportsWithError
& aQI
, const nsIID
& aIID
) {
55 if (NS_FAILED(aQI(aIID
, &newRawPtr
))) {
58 assign_assuming_AddRef(static_cast<nsISupports
*>(newRawPtr
));
61 void nsCOMPtr_base::assign_from_gs_cid(const nsGetServiceByCID aGS
,
64 if (NS_FAILED(aGS(aIID
, &newRawPtr
))) {
67 assign_assuming_AddRef(static_cast<nsISupports
*>(newRawPtr
));
70 void nsCOMPtr_base::assign_from_gs_cid_with_error(
71 const nsGetServiceByCIDWithError
& aGS
, const nsIID
& aIID
) {
73 if (NS_FAILED(aGS(aIID
, &newRawPtr
))) {
76 assign_assuming_AddRef(static_cast<nsISupports
*>(newRawPtr
));
79 void nsCOMPtr_base::assign_from_gs_contractid(
80 const nsGetServiceByContractID aGS
, const nsIID
& aIID
) {
82 if (NS_FAILED(aGS(aIID
, &newRawPtr
))) {
85 assign_assuming_AddRef(static_cast<nsISupports
*>(newRawPtr
));
88 void nsCOMPtr_base::assign_from_gs_contractid_with_error(
89 const nsGetServiceByContractIDWithError
& aGS
, const nsIID
& aIID
) {
91 if (NS_FAILED(aGS(aIID
, &newRawPtr
))) {
94 assign_assuming_AddRef(static_cast<nsISupports
*>(newRawPtr
));
97 void nsCOMPtr_base::assign_from_query_referent(
98 const nsQueryReferent
& aQueryReferent
, const nsIID
& aIID
) {
100 if (NS_FAILED(aQueryReferent(aIID
, &newRawPtr
))) {
103 assign_assuming_AddRef(static_cast<nsISupports
*>(newRawPtr
));
106 void nsCOMPtr_base::assign_from_helper(const nsCOMPtr_helper
& aHelper
,
109 if (NS_FAILED(aHelper(aIID
, &newRawPtr
))) {
112 assign_assuming_AddRef(static_cast<nsISupports
*>(newRawPtr
));