/work/obj-fuzz/dist/include/nsIInterfaceRequestorUtils.h
Line | Count | Source (jump to first uncovered line) |
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/. */ |
6 | | |
7 | | #ifndef __nsInterfaceRequestorUtils_h |
8 | | #define __nsInterfaceRequestorUtils_h |
9 | | |
10 | | #include "nsCOMPtr.h" |
11 | | |
12 | | // a type-safe shortcut for calling the |GetInterface()| member function |
13 | | // T must inherit from nsIInterfaceRequestor, but the cast may be ambiguous. |
14 | | template<class T, class DestinationType> |
15 | | inline nsresult |
16 | | CallGetInterface(T* aSource, DestinationType** aDestination) |
17 | 0 | { |
18 | 0 | MOZ_ASSERT(aSource, "null parameter"); |
19 | 0 | MOZ_ASSERT(aDestination, "null parameter"); |
20 | 0 |
|
21 | 0 | return aSource->GetInterface(NS_GET_TEMPLATE_IID(DestinationType), |
22 | 0 | reinterpret_cast<void**>(aDestination)); |
23 | 0 | } Unexecuted instantiation: nsresult CallGetInterface<nsIInterfaceRequestor, nsIAuthPrompt2>(nsIInterfaceRequestor*, nsIAuthPrompt2**) Unexecuted instantiation: nsresult CallGetInterface<nsDocLoader, mozIDOMWindowProxy>(nsDocLoader*, mozIDOMWindowProxy**) Unexecuted instantiation: nsresult CallGetInterface<nsDocShell, nsIPrompt>(nsDocShell*, nsIPrompt**) Unexecuted instantiation: nsresult CallGetInterface<nsDocShell, mozIDOMWindowProxy>(nsDocShell*, mozIDOMWindowProxy**) Unexecuted instantiation: nsresult CallGetInterface<nsIInterfaceRequestor, nsIWebBrowserChrome>(nsIInterfaceRequestor*, nsIWebBrowserChrome**) Unexecuted instantiation: nsresult CallGetInterface<nsIInterfaceRequestor, nsITestService>(nsIInterfaceRequestor*, nsITestService**) |
24 | | |
25 | | class MOZ_STACK_CLASS nsGetInterface final : public nsCOMPtr_helper |
26 | | { |
27 | | public: |
28 | | nsGetInterface(nsISupports* aSource, nsresult* aError) |
29 | | : mSource(aSource) |
30 | | , mErrorPtr(aError) |
31 | 0 | { |
32 | 0 | } |
33 | | |
34 | | virtual nsresult NS_FASTCALL operator()(const nsIID&, void**) const |
35 | | override; |
36 | | |
37 | | private: |
38 | | nsISupports* MOZ_NON_OWNING_REF mSource; |
39 | | nsresult* mErrorPtr; |
40 | | }; |
41 | | |
42 | | inline const nsGetInterface |
43 | | do_GetInterface(nsISupports* aSource, nsresult* aError = 0) |
44 | 0 | { |
45 | 0 | return nsGetInterface(aSource, aError); |
46 | 0 | } |
47 | | |
48 | | #endif // __nsInterfaceRequestorUtils_h |
49 | | |