зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1540301, part 1 - Make trivially static nsXPCWrappedJSClass methods static. r=bzbarsky
There are a number of nsXPCWrappedJSClass methods that don't use any data from |this|, so go ahead and make them static. This is one step towards eliminating nsXPCWrappedJSClass entirely. In addition, devirtualize a few methods, because they are going to have to get devirtualized anyways, and there's no need for them to be virtual. Differential Revision: https://phabricator.services.mozilla.com/D26214 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
e8446480e1
Коммит
5d994e0f0e
|
@ -181,7 +181,7 @@ nsXPCWrappedJS::AggregatedQueryInterface(REFNSIID aIID, void** aInstancePtr) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
return mClass->DelegatedQueryInterface(this, aIID, aInstancePtr);
|
||||
return nsXPCWrappedJSClass::DelegatedQueryInterface(this, aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -232,7 +232,7 @@ nsXPCWrappedJS::QueryInterface(REFNSIID aIID, void** aInstancePtr) {
|
|||
|
||||
// else...
|
||||
|
||||
return mClass->DelegatedQueryInterface(this, aIID, aInstancePtr);
|
||||
return nsXPCWrappedJSClass::DelegatedQueryInterface(this, aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
// For a description of nsXPCWrappedJS lifetime and reference counting, see
|
||||
|
@ -339,7 +339,8 @@ nsresult nsXPCWrappedJS::GetNewOrUsed(JSContext* cx, JS::HandleObject jsObj,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
JS::RootedObject rootJSObj(cx, clasp->GetRootJSObject(cx, jsObj));
|
||||
JS::RootedObject rootJSObj(cx,
|
||||
nsXPCWrappedJSClass::GetRootJSObject(cx, jsObj));
|
||||
if (!rootJSObj) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
|
|
@ -124,6 +124,7 @@ nsXPCWrappedJSClass::~nsXPCWrappedJSClass() {
|
|||
XPCJSRuntime::Get()->GetWrappedJSClassMap()->Remove(this);
|
||||
}
|
||||
|
||||
// static
|
||||
JSObject* nsXPCWrappedJSClass::CallQueryInterfaceOnJSObject(JSContext* cx,
|
||||
JSObject* jsobjArg,
|
||||
HandleObject scope,
|
||||
|
@ -317,10 +318,10 @@ nsCString GetFunctionName(JSContext* cx, HandleObject obj) {
|
|||
|
||||
/***************************************************************************/
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXPCWrappedJSClass::DelegatedQueryInterface(nsXPCWrappedJS* self,
|
||||
REFNSIID aIID,
|
||||
void** aInstancePtr) {
|
||||
// static
|
||||
nsresult nsXPCWrappedJSClass::DelegatedQueryInterface(nsXPCWrappedJS* self,
|
||||
REFNSIID aIID,
|
||||
void** aInstancePtr) {
|
||||
if (aIID.Equals(NS_GET_IID(nsIXPConnectJSObjectHolder))) {
|
||||
NS_ADDREF(self);
|
||||
*aInstancePtr = (void*)static_cast<nsIXPConnectJSObjectHolder*>(self);
|
||||
|
@ -469,6 +470,7 @@ nsXPCWrappedJSClass::DelegatedQueryInterface(nsXPCWrappedJS* self,
|
|||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
// static
|
||||
JSObject* nsXPCWrappedJSClass::GetRootJSObject(JSContext* cx,
|
||||
JSObject* aJSObjArg) {
|
||||
RootedObject aJSObj(cx, aJSObjArg);
|
||||
|
@ -481,10 +483,11 @@ JSObject* nsXPCWrappedJSClass::GetRootJSObject(JSContext* cx,
|
|||
return js::UncheckedUnwrap(result);
|
||||
}
|
||||
|
||||
// static
|
||||
bool nsXPCWrappedJSClass::GetArraySizeFromParam(const nsXPTMethodInfo* method,
|
||||
const nsXPTType& type,
|
||||
nsXPTCMiniVariant* nativeParams,
|
||||
uint32_t* result) const {
|
||||
uint32_t* result) {
|
||||
if (type.Tag() != nsXPTType::T_LEGACY_ARRAY &&
|
||||
type.Tag() != nsXPTType::T_PSTRING_SIZE_IS &&
|
||||
type.Tag() != nsXPTType::T_PWSTRING_SIZE_IS) {
|
||||
|
@ -511,9 +514,10 @@ bool nsXPCWrappedJSClass::GetArraySizeFromParam(const nsXPTMethodInfo* method,
|
|||
return true;
|
||||
}
|
||||
|
||||
// static
|
||||
bool nsXPCWrappedJSClass::GetInterfaceTypeFromParam(
|
||||
const nsXPTMethodInfo* method, const nsXPTType& type,
|
||||
nsXPTCMiniVariant* nativeParams, nsID* result) const {
|
||||
nsXPTCMiniVariant* nativeParams, nsID* result) {
|
||||
result->Clear();
|
||||
|
||||
const nsXPTType& inner = type.InnermostType();
|
||||
|
@ -550,10 +554,10 @@ bool nsXPCWrappedJSClass::GetInterfaceTypeFromParam(
|
|||
return true;
|
||||
}
|
||||
|
||||
// static
|
||||
void nsXPCWrappedJSClass::CleanupOutparams(const nsXPTMethodInfo* info,
|
||||
nsXPTCMiniVariant* nativeParams,
|
||||
bool inOutOnly,
|
||||
uint8_t count) const {
|
||||
bool inOutOnly, uint8_t count) {
|
||||
// clean up any 'out' params handed in
|
||||
for (uint8_t i = 0; i < count; i++) {
|
||||
const nsXPTParamInfo& param = info->GetParam(i);
|
||||
|
@ -745,10 +749,10 @@ nsresult nsXPCWrappedJSClass::CheckForException(
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16_t methodIndex,
|
||||
const nsXPTMethodInfo* info,
|
||||
nsXPTCMiniVariant* nativeParams) {
|
||||
nsresult nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper,
|
||||
uint16_t methodIndex,
|
||||
const nsXPTMethodInfo* info,
|
||||
nsXPTCMiniVariant* nativeParams) {
|
||||
Value* sp = nullptr;
|
||||
Value* argv = nullptr;
|
||||
uint8_t i;
|
||||
|
|
|
@ -1629,16 +1629,17 @@ class nsXPCWrappedJSClass final : public nsIXPCWrappedJSClass {
|
|||
const nsXPTInterfaceInfo* GetInterfaceInfo() const { return mInfo; }
|
||||
const char* GetInterfaceName();
|
||||
|
||||
NS_IMETHOD DelegatedQueryInterface(nsXPCWrappedJS* self, REFNSIID aIID,
|
||||
void** aInstancePtr);
|
||||
static nsresult DelegatedQueryInterface(nsXPCWrappedJS* self, REFNSIID aIID,
|
||||
void** aInstancePtr);
|
||||
|
||||
JSObject* GetRootJSObject(JSContext* cx, JSObject* aJSObj);
|
||||
static JSObject* GetRootJSObject(JSContext* cx, JSObject* aJSObj);
|
||||
|
||||
NS_IMETHOD CallMethod(nsXPCWrappedJS* wrapper, uint16_t methodIndex,
|
||||
const nsXPTMethodInfo* info, nsXPTCMiniVariant* params);
|
||||
nsresult CallMethod(nsXPCWrappedJS* wrapper, uint16_t methodIndex,
|
||||
const nsXPTMethodInfo* info, nsXPTCMiniVariant* params);
|
||||
|
||||
JSObject* CallQueryInterfaceOnJSObject(JSContext* cx, JSObject* jsobj,
|
||||
JS::HandleObject scope, REFNSIID aIID);
|
||||
static JSObject* CallQueryInterfaceOnJSObject(JSContext* cx, JSObject* jsobj,
|
||||
JS::HandleObject scope,
|
||||
REFNSIID aIID);
|
||||
|
||||
private:
|
||||
// aObj is the nsXPCWrappedJS's object. We used this as the callee (or |this|
|
||||
|
@ -1656,17 +1657,19 @@ class nsXPCWrappedJSClass final : public nsIXPCWrappedJSClass {
|
|||
nsXPCWrappedJSClass() = delete;
|
||||
explicit nsXPCWrappedJSClass(const nsXPTInterfaceInfo* aInfo);
|
||||
|
||||
bool GetArraySizeFromParam(const nsXPTMethodInfo* method,
|
||||
const nsXPTType& type, nsXPTCMiniVariant* params,
|
||||
uint32_t* result) const;
|
||||
static bool GetArraySizeFromParam(const nsXPTMethodInfo* method,
|
||||
const nsXPTType& type,
|
||||
nsXPTCMiniVariant* params,
|
||||
uint32_t* result);
|
||||
|
||||
bool GetInterfaceTypeFromParam(const nsXPTMethodInfo* method,
|
||||
const nsXPTType& type,
|
||||
nsXPTCMiniVariant* params, nsID* result) const;
|
||||
static bool GetInterfaceTypeFromParam(const nsXPTMethodInfo* method,
|
||||
const nsXPTType& type,
|
||||
nsXPTCMiniVariant* params,
|
||||
nsID* result);
|
||||
|
||||
void CleanupOutparams(const nsXPTMethodInfo* info,
|
||||
nsXPTCMiniVariant* nativeParams, bool inOutOnly,
|
||||
uint8_t n) const;
|
||||
static void CleanupOutparams(const nsXPTMethodInfo* info,
|
||||
nsXPTCMiniVariant* nativeParams, bool inOutOnly,
|
||||
uint8_t count);
|
||||
|
||||
private:
|
||||
const nsXPTInterfaceInfo* mInfo;
|
||||
|
|
Загрузка…
Ссылка в новой задаче