mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 692342 - Remove the obviously superfluous uses of IsPointer(). r=mrbkap
These are the easy cases, which all fall into one or more of the following categories: * A check-and-throw, followed by a switch whose default case also throws * A check of IsPointer() &&-ed with or tightly enclosing a check that implies IsPointer() * A check of something clearly enforced by the XPIDL compiler
This commit is contained in:
parent
356768725f
commit
d3ba9f6532
@ -316,10 +316,6 @@ XPCConvert::NativeData2JS(XPCLazyCallContext& lccx, jsval* d, const void* s,
|
||||
}
|
||||
|
||||
default:
|
||||
if (!type.IsPointer()) {
|
||||
XPC_LOG_ERROR(("XPCConvert::NativeData2JS : unsupported type"));
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
// set the default result
|
||||
*d = JSVAL_NULL;
|
||||
@ -658,10 +654,6 @@ XPCConvert::JSData2Native(XPCCallContext& ccx, void* d, jsval s,
|
||||
*((jsval*)d) = s;
|
||||
break;
|
||||
default:
|
||||
if (!type.IsPointer()) {
|
||||
NS_ERROR("unsupported type");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
switch (type.TagPart()) {
|
||||
case nsXPTType::T_VOID:
|
||||
@ -1907,10 +1899,6 @@ XPCConvert::NativeStringWithSize2JS(JSContext* cx,
|
||||
if (pErr)
|
||||
*pErr = NS_ERROR_XPC_BAD_CONVERT_NATIVE;
|
||||
|
||||
if (!type.IsPointer()) {
|
||||
XPC_LOG_ERROR(("XPCConvert::NativeStringWithSize2JS : unsupported type"));
|
||||
return JS_FALSE;
|
||||
}
|
||||
switch (type.TagPart()) {
|
||||
case nsXPTType::T_PSTRING_SIZE_IS:
|
||||
{
|
||||
@ -1957,10 +1945,6 @@ XPCConvert::JSStringWithSize2Native(XPCCallContext& ccx, void* d, jsval s,
|
||||
if (pErr)
|
||||
*pErr = NS_ERROR_XPC_BAD_CONVERT_NATIVE;
|
||||
|
||||
if (!type.IsPointer()) {
|
||||
XPC_LOG_ERROR(("XPCConvert::JSStringWithSize2Native : unsupported type"));
|
||||
return JS_FALSE;
|
||||
}
|
||||
switch (type.TagPart()) {
|
||||
case nsXPTType::T_PSTRING_SIZE_IS:
|
||||
{
|
||||
|
@ -883,9 +883,10 @@ nsXPCWrappedJSClass::GetArraySizeFromParam(JSContext* cx,
|
||||
const nsXPTParamInfo& arg_param = method->params[argnum];
|
||||
const nsXPTType& arg_type = arg_param.GetType();
|
||||
|
||||
// The xpidl compiler ensures this. We reaffirm it for safety.
|
||||
if (arg_type.IsPointer() || arg_type.TagPart() != nsXPTType::T_U32)
|
||||
return JS_FALSE;
|
||||
// This should be enforced by the xpidl compiler, but it's not.
|
||||
// See bug 695235.
|
||||
NS_ABORT_IF_FALSE(arg_type.TagPart() == nsXPTType::T_U32,
|
||||
"size_is references parameter of invalid type.");
|
||||
|
||||
if (arg_param.IsIndirect())
|
||||
*result = *(JSUint32*)nativeParams[argnum].val.p;
|
||||
@ -921,8 +922,8 @@ nsXPCWrappedJSClass::GetInterfaceTypeFromParam(JSContext* cx,
|
||||
|
||||
const nsXPTParamInfo& arg_param = method->params[argnum];
|
||||
const nsXPTType& arg_type = arg_param.GetType();
|
||||
if (arg_type.IsPointer() &&
|
||||
arg_type.TagPart() == nsXPTType::T_IID) {
|
||||
|
||||
if (arg_type.TagPart() == nsXPTType::T_IID) {
|
||||
if (arg_param.IsIndirect()) {
|
||||
nsID** p = (nsID**) nativeParams[argnum].val.p;
|
||||
if (!p || !*p)
|
||||
@ -1299,7 +1300,8 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex,
|
||||
const nsXPTParamInfo& firstParam = info->params[0];
|
||||
if (firstParam.IsIn()) {
|
||||
const nsXPTType& firstType = firstParam.GetType();
|
||||
if (firstType.IsPointer() && firstType.IsInterfacePointer()) {
|
||||
|
||||
if (firstType.IsInterfacePointer()) {
|
||||
nsIXPCFunctionThisTranslator* translator;
|
||||
|
||||
IID2ThisTranslatorMap* map =
|
||||
|
@ -2325,9 +2325,6 @@ CallMethodHelper::GetArraySizeFromParam(uint8 paramIndex,
|
||||
return Throw(NS_ERROR_XPC_CANT_GET_ARRAY_INFO, mCallContext);
|
||||
|
||||
const nsXPTType& type = mMethodInfo->GetParam(paramIndex).GetType();
|
||||
// The xpidl compiler ensures this. We reaffirm it for safety.
|
||||
if (type.IsPointer() || type.TagPart() != nsXPTType::T_U32)
|
||||
return Throw(NS_ERROR_XPC_CANT_GET_ARRAY_INFO, mCallContext);
|
||||
|
||||
*result = GetDispatchParam(paramIndex)->val.u32;
|
||||
|
||||
@ -2357,10 +2354,6 @@ CallMethodHelper::GetInterfaceTypeFromParam(uint8 paramIndex,
|
||||
return Throw(NS_ERROR_XPC_CANT_GET_ARRAY_INFO, mCallContext);
|
||||
|
||||
const nsXPTType& type = mMethodInfo->GetParam(paramIndex).GetType();
|
||||
// The xpidl compiler ensures this. We reaffirm it for safety.
|
||||
if (!type.IsPointer() || type.TagPart() != nsXPTType::T_IID)
|
||||
return ThrowBadParam(NS_ERROR_XPC_CANT_GET_PARAM_IFACE_INFO,
|
||||
paramIndex, mCallContext);
|
||||
|
||||
nsID* p = (nsID*) GetDispatchParam(paramIndex)->val.p;
|
||||
if (!p)
|
||||
@ -2671,28 +2664,26 @@ CallMethodHelper::ConvertIndependentParam(uint8 i)
|
||||
|
||||
if (!paramInfo.IsIn())
|
||||
return JS_TRUE;
|
||||
|
||||
} else {
|
||||
if (type.IsPointer()) {
|
||||
switch (type_tag) {
|
||||
case nsXPTType::T_IID:
|
||||
dp->SetValNeedsCleanup();
|
||||
break;
|
||||
case nsXPTType::T_CHAR_STR:
|
||||
dp->SetValNeedsCleanup();
|
||||
break;
|
||||
case nsXPTType::T_ASTRING:
|
||||
// Fall through to the T_DOMSTRING case
|
||||
switch (type_tag) {
|
||||
case nsXPTType::T_IID:
|
||||
dp->SetValNeedsCleanup();
|
||||
break;
|
||||
case nsXPTType::T_CHAR_STR:
|
||||
dp->SetValNeedsCleanup();
|
||||
break;
|
||||
case nsXPTType::T_ASTRING:
|
||||
// Fall through to the T_DOMSTRING case
|
||||
case nsXPTType::T_DOMSTRING:
|
||||
dp->SetValNeedsCleanup();
|
||||
break;
|
||||
|
||||
case nsXPTType::T_DOMSTRING:
|
||||
dp->SetValNeedsCleanup();
|
||||
break;
|
||||
|
||||
case nsXPTType::T_UTF8STRING:
|
||||
// Fall through to the C string case for now...
|
||||
case nsXPTType::T_CSTRING:
|
||||
dp->SetValNeedsCleanup();
|
||||
break;
|
||||
}
|
||||
case nsXPTType::T_UTF8STRING:
|
||||
// Fall through to the C string case for now...
|
||||
case nsXPTType::T_CSTRING:
|
||||
dp->SetValNeedsCleanup();
|
||||
break;
|
||||
}
|
||||
|
||||
// Do this *after* the above because in the case where we have a
|
||||
@ -2785,10 +2776,9 @@ CallMethodHelper::ConvertDependentParams()
|
||||
"Expected either enough arguments or an optional argument");
|
||||
src = i < mArgc ? mArgv[i] : JSVAL_NULL;
|
||||
|
||||
if ((datum_type.IsPointer() &&
|
||||
(datum_type.TagPart() == nsXPTType::T_IID ||
|
||||
datum_type.TagPart() == nsXPTType::T_PSTRING_SIZE_IS ||
|
||||
datum_type.TagPart() == nsXPTType::T_PWSTRING_SIZE_IS)) ||
|
||||
if (datum_type.TagPart() == nsXPTType::T_IID ||
|
||||
datum_type.TagPart() == nsXPTType::T_PSTRING_SIZE_IS ||
|
||||
datum_type.TagPart() == nsXPTType::T_PWSTRING_SIZE_IS ||
|
||||
(isArray && datum_type.TagPart() == nsXPTType::T_CHAR_STR)) {
|
||||
dp->SetValNeedsCleanup();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user