1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/xpcom/reflect/xptcall/src/xptcall.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,68 @@ 1.4 +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +/* entry point wrappers. */ 1.10 + 1.11 +#include "xptcprivate.h" 1.12 +#include "xptiprivate.h" 1.13 +#include "mozilla/XPTInterfaceInfoManager.h" 1.14 + 1.15 +using namespace mozilla; 1.16 + 1.17 +NS_IMETHODIMP 1.18 +nsXPTCStubBase::QueryInterface(REFNSIID aIID, 1.19 + void **aInstancePtr) 1.20 +{ 1.21 + if (aIID.Equals(mEntry->IID())) { 1.22 + NS_ADDREF_THIS(); 1.23 + *aInstancePtr = static_cast<nsISupports*>(this); 1.24 + return NS_OK; 1.25 + } 1.26 + 1.27 + return mOuter->QueryInterface(aIID, aInstancePtr); 1.28 +} 1.29 + 1.30 +NS_IMETHODIMP_(MozExternalRefCountType) 1.31 +nsXPTCStubBase::AddRef() 1.32 +{ 1.33 + return mOuter->AddRef(); 1.34 +} 1.35 + 1.36 +NS_IMETHODIMP_(MozExternalRefCountType) 1.37 +nsXPTCStubBase::Release() 1.38 +{ 1.39 + return mOuter->Release(); 1.40 +} 1.41 + 1.42 +EXPORT_XPCOM_API(nsresult) 1.43 +NS_GetXPTCallStub(REFNSIID aIID, nsIXPTCProxy* aOuter, 1.44 + nsISomeInterface* *aResult) 1.45 +{ 1.46 + if (NS_WARN_IF(!aOuter) || NS_WARN_IF(!aResult)) 1.47 + return NS_ERROR_INVALID_ARG; 1.48 + 1.49 + XPTInterfaceInfoManager *iim = 1.50 + XPTInterfaceInfoManager::GetSingleton(); 1.51 + if (NS_WARN_IF(!iim)) 1.52 + return NS_ERROR_NOT_INITIALIZED; 1.53 + 1.54 + xptiInterfaceEntry *iie = iim->GetInterfaceEntryForIID(&aIID); 1.55 + if (!iie || !iie->EnsureResolved() || iie->GetBuiltinClassFlag()) 1.56 + return NS_ERROR_FAILURE; 1.57 + 1.58 + nsXPTCStubBase* newbase = new nsXPTCStubBase(aOuter, iie); 1.59 + if (!newbase) 1.60 + return NS_ERROR_OUT_OF_MEMORY; 1.61 + 1.62 + *aResult = newbase; 1.63 + return NS_OK; 1.64 +} 1.65 + 1.66 +EXPORT_XPCOM_API(void) 1.67 +NS_DestroyXPTCallStub(nsISomeInterface* aStub) 1.68 +{ 1.69 + nsXPTCStubBase* stub = static_cast<nsXPTCStubBase*>(aStub); 1.70 + delete(stub); 1.71 +}