michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* vim: set ts=8 sts=4 et sw=4 tw=99: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef qsObjectHelper_h michael@0: #define qsObjectHelper_h michael@0: michael@0: #include "xpcObjectHelper.h" michael@0: michael@0: #include "nsAutoPtr.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsWrapperCache.h" michael@0: #include "mozilla/TypeTraits.h" michael@0: michael@0: class qsObjectHelper : public xpcObjectHelper michael@0: { michael@0: public: michael@0: template michael@0: inline michael@0: qsObjectHelper(T *aObject, nsWrapperCache *aCache) michael@0: : xpcObjectHelper(ToSupports(aObject), ToCanonicalSupports(aObject), michael@0: aCache) michael@0: {} michael@0: michael@0: template michael@0: inline michael@0: qsObjectHelper(nsCOMPtr& aObject, nsWrapperCache *aCache) michael@0: : xpcObjectHelper(ToSupports(aObject.get()), michael@0: ToCanonicalSupports(aObject.get()), aCache) michael@0: { michael@0: if (mCanonical) { michael@0: // Transfer the strong reference. michael@0: mCanonicalStrong = dont_AddRef(mCanonical); michael@0: aObject.forget(); michael@0: } michael@0: } michael@0: michael@0: template michael@0: inline michael@0: qsObjectHelper(nsRefPtr& aObject, nsWrapperCache *aCache) michael@0: : xpcObjectHelper(ToSupports(aObject.get()), michael@0: ToCanonicalSupports(aObject.get()), aCache) michael@0: { michael@0: if (mCanonical) { michael@0: // Transfer the strong reference. michael@0: mCanonicalStrong = dont_AddRef(mCanonical); michael@0: aObject.forget(); michael@0: } michael@0: } michael@0: }; michael@0: michael@0: #endif