From f20e777cdb1998489f0d0c9a3f040afbb49b7269 Mon Sep 17 00:00:00 2001 From: Nika Layzell Date: Sun, 22 Apr 2018 13:24:55 -0400 Subject: [PATCH] Bug 1457972 - Part 2: Remove unused code paths in xpconnect, r=mccr8 Thanks to the changes in the previous patch, we had some unused code which we can get rid of. This patch just cleans stuff up a bit. --- js/xpconnect/src/XPCWrappedNative.cpp | 35 ++--------- xpcom/reflect/xptinfo/xptinfo.cpp | 84 --------------------------- xpcom/reflect/xptinfo/xptinfo.h | 21 ------- 3 files changed, 6 insertions(+), 134 deletions(-) diff --git a/js/xpconnect/src/XPCWrappedNative.cpp b/js/xpconnect/src/XPCWrappedNative.cpp index 7a36f54e363e..9d162e3fa0a6 100644 --- a/js/xpconnect/src/XPCWrappedNative.cpp +++ b/js/xpconnect/src/XPCWrappedNative.cpp @@ -1399,22 +1399,12 @@ CallMethodHelper::GatherAndConvertResults() const nsXPTType& type = paramInfo.GetType(); nsXPTCVariant* dp = GetDispatchParam(i); RootedValue v(mCallContext, NullValue()); - nsXPTType datum_type; bool isArray = type.IsArray(); bool isSizedString = isArray ? false : type.TagPart() == nsXPTType::T_PSTRING_SIZE_IS || type.TagPart() == nsXPTType::T_PWSTRING_SIZE_IS; - if (isArray) { - if (NS_FAILED(mIFaceInfo->GetTypeForParam(mVTableIndex, ¶mInfo, 1, - &datum_type))) { - Throw(NS_ERROR_XPC_CANT_GET_ARRAY_INFO, mCallContext); - return false; - } - } else - datum_type = type; - uint32_t array_count = 0; nsID param_iid; if (!GetInterfaceTypeFromParam(type, ¶m_iid) || @@ -1424,7 +1414,7 @@ CallMethodHelper::GatherAndConvertResults() nsresult err; if (isArray) { if (!XPCConvert::NativeArray2JS(&v, (const void**)&dp->val, - datum_type, ¶m_iid, + type.InnermostType(), ¶m_iid, array_count, &err)) { // XXX need exception scheme for arrays to indicate bad element ThrowBadParam(err, i, mCallContext); @@ -1433,13 +1423,13 @@ CallMethodHelper::GatherAndConvertResults() } else if (isSizedString) { if (!XPCConvert::NativeStringWithSize2JS(&v, (const void*)&dp->val, - datum_type, + type, array_count, &err)) { ThrowBadParam(err, i, mCallContext); return false; } } else { - if (!XPCConvert::NativeData2JS(&v, &dp->val, datum_type, + if (!XPCConvert::NativeData2JS(&v, &dp->val, type, ¶m_iid, &err)) { ThrowBadParam(err, i, mCallContext); return false; @@ -1731,7 +1721,6 @@ CallMethodHelper::ConvertDependentParam(uint8_t i) { const nsXPTParamInfo& paramInfo = mMethodInfo->GetParam(i); const nsXPTType& type = paramInfo.GetType(); - nsXPTType datum_type; bool isArray = type.IsArray(); bool isSizedString = isArray ? @@ -1742,18 +1731,6 @@ CallMethodHelper::ConvertDependentParam(uint8_t i) nsXPTCVariant* dp = GetDispatchParam(i); dp->type = type; - if (isArray) { - if (NS_FAILED(mIFaceInfo->GetTypeForParam(mVTableIndex, ¶mInfo, 1, - &datum_type))) { - Throw(NS_ERROR_XPC_CANT_GET_ARRAY_INFO, mCallContext); - return false; - } - MOZ_ASSERT(datum_type.TagPart() != nsXPTType::T_JSVAL, - "Arrays of JSVals not currently supported - see bug 693337."); - } else { - datum_type = type; - } - // Specify the correct storage/calling semantics. if (paramInfo.IsIndirect()) dp->SetIndirect(); @@ -1798,8 +1775,8 @@ CallMethodHelper::ConvertDependentParam(uint8_t i) if (isArray) { if (array_count && !XPCConvert::JSArray2Native((void**)&dp->val, src, - array_count, datum_type, ¶m_iid, - &err)) { + array_count, type.InnermostType(), + ¶m_iid, &err)) { // XXX need exception scheme for arrays to indicate bad element ThrowBadParam(err, i, mCallContext); return false; @@ -1807,7 +1784,7 @@ CallMethodHelper::ConvertDependentParam(uint8_t i) } else if (isSizedString) { if (!XPCConvert::JSStringWithSize2Native((void*)&dp->val, src, array_count, - datum_type, &err)) { + type, &err)) { ThrowBadParam(err, i, mCallContext); return false; } diff --git a/xpcom/reflect/xptinfo/xptinfo.cpp b/xpcom/reflect/xptinfo/xptinfo.cpp index 32abf97e0ff7..d707ec58f895 100644 --- a/xpcom/reflect/xptinfo/xptinfo.cpp +++ b/xpcom/reflect/xptinfo/xptinfo.cpp @@ -261,70 +261,6 @@ nsXPTInterfaceInfo::GetConstant(uint16_t aIndex, return *aName ? NS_OK : NS_ERROR_FAILURE; } -nsresult -nsXPTInterfaceInfo::GetTypeForParam(uint16_t /* UNUSED aMethodIndex */, - const nsXPTParamInfo* aParam, - uint16_t aDimension, - nsXPTType* aRetval) const -{ - const nsXPTType* type = &aParam->Type(); - for (uint16_t i = 0; i < aDimension; ++i) { - if (type->Tag() != TD_ARRAY) { - NS_ERROR("bad dimension"); - return NS_ERROR_INVALID_ARG; - } - type = &type->ArrayElementType(); - } - - *aRetval = *type; // NOTE: This copies the type, which is fine I guess? - return NS_OK; -} - -nsresult -nsXPTInterfaceInfo::GetSizeIsArgNumberForParam(uint16_t /* UNUSED aMethodIndex */, - const nsXPTParamInfo* aParam, - uint16_t aDimension, - uint8_t* aRetval) const -{ - const nsXPTType* type = &aParam->Type(); - for (uint16_t i = 0; i < aDimension; ++i) { - if (type->Tag() != TD_ARRAY) { - NS_ERROR("bad dimension"); - return NS_ERROR_INVALID_ARG; - } - type = &type->ArrayElementType(); - } - - if (type->Tag() != TD_ARRAY && - type->Tag() != TD_PSTRING_SIZE_IS && - type->Tag() != TD_PWSTRING_SIZE_IS) { - NS_ERROR("not a size_is"); - return NS_ERROR_INVALID_ARG; - } - - *aRetval = type->ArgNum(); - return NS_OK; -} - -nsresult -nsXPTInterfaceInfo::GetInterfaceIsArgNumberForParam(uint16_t /* UNUSED aMethodIndex */, - const nsXPTParamInfo* aParam, - uint8_t* aRetval) const -{ - const nsXPTType* type = &aParam->Type(); - while (type->Tag() == TD_ARRAY) { - type = &type->ArrayElementType(); - } - - if (type->Tag() != TD_INTERFACE_IS_TYPE) { - NS_ERROR("not an iid_is"); - return NS_ERROR_INVALID_ARG; - } - - *aRetval = type->ArgNum(); - return NS_OK; -} - nsresult nsXPTInterfaceInfo::IsIID(const nsIID* aIID, bool* aIs) const { @@ -360,26 +296,6 @@ nsXPTInterfaceInfo::HasAncestor(const nsIID* aIID, bool* aRetval) const return NS_OK; } -nsresult -nsXPTInterfaceInfo::GetIIDForParamNoAlloc(uint16_t aMethodIndex, - const nsXPTParamInfo* aParam, - nsIID* aIID) const -{ - const nsXPTType* type = &aParam->Type(); - while (type->Tag() == TD_ARRAY) { - type = &type->ArrayElementType(); - } - - if (type->Tag() == TD_INTERFACE_TYPE) { - const nsXPTInterfaceInfo* info = type->GetInterface(); - if (info) { - *aIID = info->IID(); - return NS_OK; - } - } - return NS_ERROR_FAILURE; -} - nsresult nsXPTInterfaceInfo::IsMainProcessScriptableOnly(bool* aRetval) const { diff --git a/xpcom/reflect/xptinfo/xptinfo.h b/xpcom/reflect/xptinfo/xptinfo.h index d7d1f1628afc..e90cec4135a3 100644 --- a/xpcom/reflect/xptinfo/xptinfo.h +++ b/xpcom/reflect/xptinfo/xptinfo.h @@ -107,23 +107,11 @@ struct nsXPTInterfaceInfo nsresult GetConstant(uint16_t aIndex, JS::MutableHandleValue constant, char** aName) const; - nsresult GetTypeForParam(uint16_t aMethodIndex, const nsXPTParamInfo* aParam, - uint16_t aDimension, nsXPTType* aRetval) const; - nsresult GetSizeIsArgNumberForParam(uint16_t aMethodIndex, - const nsXPTParamInfo* aParam, - uint16_t aDimension, - uint8_t* aRetval) const; - nsresult GetInterfaceIsArgNumberForParam(uint16_t aMethodIndex, - const nsXPTParamInfo* aParam, - uint8_t* aRetval) const; nsresult IsIID(const nsIID* aIID, bool* aIs) const; nsresult GetNameShared(const char** aName) const; nsresult GetIIDShared(const nsIID** aIID) const; nsresult IsFunction(bool* aRetval) const; nsresult HasAncestor(const nsIID* aIID, bool* aRetval) const; - nsresult GetIIDForParamNoAlloc(uint16_t aMethodIndex, - const nsXPTParamInfo* aParam, - nsIID* aIID) const; nsresult IsMainProcessScriptableOnly(bool* aRetval) const; // XXX: We can probably get away with removing this method. A shim interface @@ -248,15 +236,6 @@ public: // place in xptcall. :-( bool IsArithmetic() const { return Tag() <= TD_WCHAR; } - // We used to abuse 'pointer' flag bit in typelib format quite extensively. - // We've gotten rid of most of the cases, but there's still a fair amount - // of refactoring to be done in XPCWrappedJSClass before we can safely stop - // asking about this. In the mean time, we've got a temporary version of - // IsPointer() that should do the right thing. - bool deprecated_IsPointer() const { - return !IsArithmetic() && Tag() != TD_JSVAL; - } - bool IsInterfacePointer() const { return Tag() == TD_INTERFACE_TYPE || Tag() == TD_INTERFACE_IS_TYPE; }