Line data Source code
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 : #include "nsPrintfCString.h"
12 :
13 : using namespace mozilla;
14 :
15 : NS_IMETHODIMP
16 2155 : nsXPTCStubBase::QueryInterface(REFNSIID aIID,
17 : void **aInstancePtr)
18 : {
19 2155 : if (aIID.Equals(mEntry->IID())) {
20 969 : NS_ADDREF_THIS();
21 969 : *aInstancePtr = static_cast<nsISupports*>(this);
22 969 : return NS_OK;
23 : }
24 :
25 1186 : return mOuter->QueryInterface(aIID, aInstancePtr);
26 : }
27 :
28 : NS_IMETHODIMP_(MozExternalRefCountType)
29 2729 : nsXPTCStubBase::AddRef()
30 : {
31 2729 : return mOuter->AddRef();
32 : }
33 :
34 : NS_IMETHODIMP_(MozExternalRefCountType)
35 3186 : nsXPTCStubBase::Release()
36 : {
37 3186 : return mOuter->Release();
38 : }
39 :
40 : EXPORT_XPCOM_API(nsresult)
41 940 : NS_GetXPTCallStub(REFNSIID aIID, nsIXPTCProxy* aOuter,
42 : nsISomeInterface* *aResult)
43 : {
44 940 : if (NS_WARN_IF(!aOuter) || NS_WARN_IF(!aResult))
45 0 : return NS_ERROR_INVALID_ARG;
46 :
47 : XPTInterfaceInfoManager *iim =
48 940 : XPTInterfaceInfoManager::GetSingleton();
49 940 : if (NS_WARN_IF(!iim))
50 0 : return NS_ERROR_NOT_INITIALIZED;
51 :
52 940 : xptiInterfaceEntry *iie = iim->GetInterfaceEntryForIID(&aIID);
53 940 : if (!iie || !iie->EnsureResolved() || iie->GetBuiltinClassFlag())
54 0 : return NS_ERROR_FAILURE;
55 :
56 940 : if (iie->GetHasNotXPCOMFlag()) {
57 : #ifdef DEBUG
58 0 : nsPrintfCString msg("XPTCall will not implement interface %s because of [notxpcom] members.", iie->GetTheName());
59 0 : NS_WARNING(msg.get());
60 : #endif
61 0 : return NS_ERROR_FAILURE;
62 : }
63 :
64 940 : *aResult = new nsXPTCStubBase(aOuter, iie);
65 940 : return NS_OK;
66 : }
67 :
68 : EXPORT_XPCOM_API(void)
69 140 : NS_DestroyXPTCallStub(nsISomeInterface* aStub)
70 : {
71 140 : nsXPTCStubBase* stub = static_cast<nsXPTCStubBase*>(aStub);
72 140 : delete(stub);
73 140 : }
74 :
75 : EXPORT_XPCOM_API(size_t)
76 0 : NS_SizeOfIncludingThisXPTCallStub(const nsISomeInterface* aStub,
77 : mozilla::MallocSizeOf aMallocSizeOf)
78 : {
79 : // We could cast aStub to nsXPTCStubBase, but that class doesn't seem to own anything,
80 : // so just measure the size of the object itself.
81 0 : return aMallocSizeOf(aStub);
82 : }
|