Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /* vim: set ts=8 sts=4 et sw=4 tw=99: */
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 qsObjectHelper_h
8 : #define qsObjectHelper_h
9 :
10 : #include "xpcObjectHelper.h"
11 :
12 : #include "nsCOMPtr.h"
13 : #include "nsWrapperCache.h"
14 : #include "mozilla/TypeTraits.h"
15 :
16 709 : class qsObjectHelper : public xpcObjectHelper
17 : {
18 : public:
19 : template <class T>
20 : inline
21 709 : qsObjectHelper(T* aObject, nsWrapperCache* aCache)
22 : : xpcObjectHelper(ToSupports(aObject), ToCanonicalSupports(aObject),
23 709 : aCache)
24 709 : {}
25 :
26 : template <class T>
27 : inline
28 : qsObjectHelper(nsCOMPtr<T>& aObject, nsWrapperCache* aCache)
29 : : xpcObjectHelper(ToSupports(aObject.get()),
30 : ToCanonicalSupports(aObject.get()), aCache)
31 : {
32 : if (mCanonical) {
33 : // Transfer the strong reference.
34 : mCanonicalStrong = dont_AddRef(mCanonical);
35 : aObject.forget();
36 : }
37 : }
38 :
39 : template <class T>
40 : inline
41 : qsObjectHelper(RefPtr<T>& aObject, nsWrapperCache* aCache)
42 : : xpcObjectHelper(ToSupports(aObject.get()),
43 : ToCanonicalSupports(aObject.get()), aCache)
44 : {
45 : if (mCanonical) {
46 : // Transfer the strong reference.
47 : mCanonicalStrong = dont_AddRef(mCanonical);
48 : aObject.forget();
49 : }
50 : }
51 : };
52 :
53 : #endif
|