Files
palemoon27/xpcom/base/nsQueryObject.h
T
roytam1 43fb101b11 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1145017. Use the new proto setup for custom element prototypes when possible. r=wchen,bholley (67789348c)
- Bug 1183450, properly wrappercache URL object, r=baku (ce6ef8436)
- space cleanup (2de44c12c)
- Bug 1155477 - Convert nsINode::Slots::mChildNodes to an nsRefPtr; r=baku (721d52f31)
- Bug 1156009 - Mark nsChildContentList::mNode as MOZ_NON_OWNING_REF; r=baku (acaba6531)
- remaining of 1155477 (d1dc03fc0)
- spacing like gecko, even if bad (7ff16eeae)
- Bug 1155475 - Mark nsINode::Slots::mWeakReference as MOZ_NON_OWNING_REF; r=baku (59b241ae6)
- Bug 1156011 - Mark nsINode::mFirstChild as MOZ_NON_OWNING_REF; r=baku (5255acaa5)
- Bug 1156013 - Mark nsINode::mSubtreeRoot as MOZ_NON_OWNING_REF; r=baku (4da7e61cf)
- Bug 1156012 - Mark nsINode::m{Next,Previous}Sibling as MOZ_NON_OWNING_REF; r=baku (33022b4e0)
- Bug 1156010 - Mark nsINode::mParent as MOZ_OWNING_REF; r=smaug (3c975656a)
- fix typo (c06ca0d92)
- Bug 1165184 - Move nsChildContentList to its own header. r=peterv (408a2cb2e)
- Bug 1167390 - Mark nsNodeWeakReference::mNode as MOZ_NON_OWNING_REF. r=smaug (5a2ab3838)
- missing bit 1117172 part 3 (ab0b032b9)
- Bug 1184065, properly support WrapperCache on DestinationInsertionPointList, r=wchen (4afc484a7)
- missing bit of Bug 1095098 - followup - add back some static analysis attributes lost in a rebase; r=me (08d509ef7)
- Bug 1156790 - mark various nsCOMPtr_helper-esque classes as final; r=mccr8 (826d1f5ca)
2022-01-11 10:25:40 +08:00

110 lines
2.7 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsQueryObject_h
#define nsQueryObject_h
#include "mozilla/Attributes.h"
#include "nsCOMPtr.h"
#include "mozilla/RefPtr.h"
/*****************************************************************************/
template<class T>
class MOZ_STACK_CLASS nsQueryObject final : public nsCOMPtr_helper
{
public:
explicit nsQueryObject(T* aRawPtr)
: mRawPtr(aRawPtr)
{
}
virtual nsresult NS_FASTCALL operator()(const nsIID& aIID,
void** aResult) const
{
nsresult status = mRawPtr ? mRawPtr->QueryInterface(aIID, aResult)
: NS_ERROR_NULL_POINTER;
return status;
}
private:
T* MOZ_NON_OWNING_REF mRawPtr;
};
template<class T>
class MOZ_STACK_CLASS nsQueryObjectWithError final : public nsCOMPtr_helper
{
public:
nsQueryObjectWithError(T* aRawPtr, nsresult* aErrorPtr)
: mRawPtr(aRawPtr), mErrorPtr(aErrorPtr)
{
}
virtual nsresult NS_FASTCALL operator()(const nsIID& aIID,
void** aResult) const
{
nsresult status = mRawPtr ? mRawPtr->QueryInterface(aIID, aResult)
: NS_ERROR_NULL_POINTER;
if (mErrorPtr) {
*mErrorPtr = status;
}
return status;
}
private:
T* MOZ_NON_OWNING_REF mRawPtr;
nsresult* mErrorPtr;
};
/*****************************************************************************/
/*****************************************************************************/
template<class T>
inline nsQueryObject<T>
do_QueryObject(T* aRawPtr)
{
return nsQueryObject<T>(aRawPtr);
}
template<class T>
inline nsQueryObject<T>
do_QueryObject(nsCOMPtr<T>& aRawPtr)
{
return nsQueryObject<T>(aRawPtr);
}
template<class T>
inline nsQueryObject<T>
do_QueryObject(nsRefPtr<T>& aRawPtr)
{
return nsQueryObject<T>(aRawPtr);
}
template<class T>
inline nsQueryObjectWithError<T>
do_QueryObject(T* aRawPtr, nsresult* aErrorPtr)
{
return nsQueryObjectWithError<T>(aRawPtr, aErrorPtr);
}
template<class T>
inline nsQueryObjectWithError<T>
do_QueryObject(nsCOMPtr<T>& aRawPtr, nsresult* aErrorPtr)
{
return nsQueryObjectWithError<T>(aRawPtr, aErrorPtr);
}
template<class T>
inline nsQueryObjectWithError<T>
do_QueryObject(nsRefPtr<T>& aRawPtr, nsresult* aErrorPtr)
{
return nsQueryObjectWithError<T>(aRawPtr, aErrorPtr);
}
/*****************************************************************************/
#endif // !defined(nsQueryObject_h)