|
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 /* entry point wrappers. */ |
|
7 |
|
8 #include "xptcprivate.h" |
|
9 #include "xptiprivate.h" |
|
10 #include "mozilla/XPTInterfaceInfoManager.h" |
|
11 |
|
12 using namespace mozilla; |
|
13 |
|
14 NS_IMETHODIMP |
|
15 nsXPTCStubBase::QueryInterface(REFNSIID aIID, |
|
16 void **aInstancePtr) |
|
17 { |
|
18 if (aIID.Equals(mEntry->IID())) { |
|
19 NS_ADDREF_THIS(); |
|
20 *aInstancePtr = static_cast<nsISupports*>(this); |
|
21 return NS_OK; |
|
22 } |
|
23 |
|
24 return mOuter->QueryInterface(aIID, aInstancePtr); |
|
25 } |
|
26 |
|
27 NS_IMETHODIMP_(MozExternalRefCountType) |
|
28 nsXPTCStubBase::AddRef() |
|
29 { |
|
30 return mOuter->AddRef(); |
|
31 } |
|
32 |
|
33 NS_IMETHODIMP_(MozExternalRefCountType) |
|
34 nsXPTCStubBase::Release() |
|
35 { |
|
36 return mOuter->Release(); |
|
37 } |
|
38 |
|
39 EXPORT_XPCOM_API(nsresult) |
|
40 NS_GetXPTCallStub(REFNSIID aIID, nsIXPTCProxy* aOuter, |
|
41 nsISomeInterface* *aResult) |
|
42 { |
|
43 if (NS_WARN_IF(!aOuter) || NS_WARN_IF(!aResult)) |
|
44 return NS_ERROR_INVALID_ARG; |
|
45 |
|
46 XPTInterfaceInfoManager *iim = |
|
47 XPTInterfaceInfoManager::GetSingleton(); |
|
48 if (NS_WARN_IF(!iim)) |
|
49 return NS_ERROR_NOT_INITIALIZED; |
|
50 |
|
51 xptiInterfaceEntry *iie = iim->GetInterfaceEntryForIID(&aIID); |
|
52 if (!iie || !iie->EnsureResolved() || iie->GetBuiltinClassFlag()) |
|
53 return NS_ERROR_FAILURE; |
|
54 |
|
55 nsXPTCStubBase* newbase = new nsXPTCStubBase(aOuter, iie); |
|
56 if (!newbase) |
|
57 return NS_ERROR_OUT_OF_MEMORY; |
|
58 |
|
59 *aResult = newbase; |
|
60 return NS_OK; |
|
61 } |
|
62 |
|
63 EXPORT_XPCOM_API(void) |
|
64 NS_DestroyXPTCallStub(nsISomeInterface* aStub) |
|
65 { |
|
66 nsXPTCStubBase* stub = static_cast<nsXPTCStubBase*>(aStub); |
|
67 delete(stub); |
|
68 } |