Bug 683802 - Separate reindentation from previous patch for easier review. No other changes. r=mrbkap

This commit is contained in:
Bobby Holley 2011-09-23 14:50:27 -07:00
Родитель bf33201c11
Коммит 66ee33a251
1 изменённых файлов: 121 добавлений и 121 удалений

Просмотреть файл

@ -2816,147 +2816,147 @@ CallMethodHelper::ConvertIndependentParams(JSBool* foundDependentParam)
JSBool JSBool
CallMethodHelper::ConvertIndependentParam(uint8 i) CallMethodHelper::ConvertIndependentParam(uint8 i)
{ {
JSBool useAllocator = JS_FALSE; JSBool useAllocator = JS_FALSE;
const nsXPTParamInfo& paramInfo = mMethodInfo->GetParam(i); const nsXPTParamInfo& paramInfo = mMethodInfo->GetParam(i);
const nsXPTType& type = paramInfo.GetType(); const nsXPTType& type = paramInfo.GetType();
uint8 type_tag = type.TagPart(); uint8 type_tag = type.TagPart();
nsXPTCVariant* dp = GetDispatchParam(i); nsXPTCVariant* dp = GetDispatchParam(i);
dp->type = type; dp->type = type;
if(type_tag == nsXPTType::T_INTERFACE) if(type_tag == nsXPTType::T_INTERFACE)
{
dp->SetValIsInterface();
}
jsval src;
if (!GetOutParamSource(i, &src))
return JS_FALSE;
if(paramInfo.IsOut())
{
dp->SetPtrIsData();
dp->ptr = &dp->val;
if (type_tag == nsXPTType::T_JSVAL)
{ {
dp->SetValIsInterface(); JS_STATIC_ASSERT(sizeof(jsval) <= sizeof(uint64));
jsval *rootp = (jsval *)&dp->val.u64;
dp->ptr = rootp;
*rootp = JSVAL_VOID;
if (!JS_AddValueRoot(mCallContext, rootp))
return JS_FALSE;
dp->SetValIsJSRoot();
} }
jsval src; if(type.IsPointer() &&
type_tag != nsXPTType::T_INTERFACE &&
if (!GetOutParamSource(i, &src)) !paramInfo.IsShared())
return JS_FALSE;
if(paramInfo.IsOut())
{ {
dp->SetPtrIsData(); useAllocator = JS_TRUE;
dp->ptr = &dp->val; dp->SetValIsAllocated();
}
if (type_tag == nsXPTType::T_JSVAL) if(!paramInfo.IsIn())
return JS_TRUE;
}
else
{
if(type.IsPointer())
{
switch(type_tag)
{ {
JS_STATIC_ASSERT(sizeof(jsval) <= sizeof(uint64)); case nsXPTType::T_IID:
jsval *rootp = (jsval *)&dp->val.u64;
dp->ptr = rootp;
*rootp = JSVAL_VOID;
if (!JS_AddValueRoot(mCallContext, rootp))
return JS_FALSE;
dp->SetValIsJSRoot();
}
if(type.IsPointer() &&
type_tag != nsXPTType::T_INTERFACE &&
!paramInfo.IsShared())
{
useAllocator = JS_TRUE;
dp->SetValIsAllocated(); dp->SetValIsAllocated();
} useAllocator = JS_TRUE;
break;
case nsXPTType::T_CHAR_STR:
dp->SetValIsAllocated();
useAllocator = JS_TRUE;
break;
case nsXPTType::T_ASTRING:
// Fall through to the T_DOMSTRING case
if(!paramInfo.IsIn()) case nsXPTType::T_DOMSTRING:
return JS_TRUE; if(paramInfo.IsDipper())
}
else
{
if(type.IsPointer())
{
switch(type_tag)
{ {
case nsXPTType::T_IID: // Is an 'out' DOMString. Make a new nsAString
dp->SetValIsAllocated(); // now and then continue in order to skip the call to
useAllocator = JS_TRUE; // JSData2Native
break;
case nsXPTType::T_CHAR_STR:
dp->SetValIsAllocated();
useAllocator = JS_TRUE;
break;
case nsXPTType::T_ASTRING:
// Fall through to the T_DOMSTRING case
case nsXPTType::T_DOMSTRING:
if(paramInfo.IsDipper())
{
// Is an 'out' DOMString. Make a new nsAString
// now and then continue in order to skip the call to
// JSData2Native
dp->SetValIsDOMString();
if(!(dp->val.p = new nsAutoString()))
{
JS_ReportOutOfMemory(mCallContext);
return JS_FALSE;
}
return JS_TRUE;
}
// else...
// Is an 'in' DOMString. Set 'useAllocator' to indicate
// that JSData2Native should allocate a new
// nsAString.
dp->SetValIsDOMString(); dp->SetValIsDOMString();
useAllocator = JS_TRUE; if(!(dp->val.p = new nsAutoString()))
break;
case nsXPTType::T_UTF8STRING:
// Fall through to the C string case for now...
case nsXPTType::T_CSTRING:
dp->SetValIsCString();
if(paramInfo.IsDipper())
{ {
// Is an 'out' CString. JS_ReportOutOfMemory(mCallContext);
if(!(dp->val.p = new nsCString())) return JS_FALSE;
{
JS_ReportOutOfMemory(mCallContext);
return JS_FALSE;
}
return JS_TRUE;
} }
// else ... return JS_TRUE;
// Is an 'in' CString.
useAllocator = JS_TRUE;
break;
} }
} // else...
else {
if(type_tag == nsXPTType::T_JSVAL) { // Is an 'in' DOMString. Set 'useAllocator' to indicate
dp->SetValIsAllocated(); // that JSData2Native should allocate a new
useAllocator = JS_TRUE; // nsAString.
dp->SetValIsDOMString();
useAllocator = JS_TRUE;
break;
case nsXPTType::T_UTF8STRING:
// Fall through to the C string case for now...
case nsXPTType::T_CSTRING:
dp->SetValIsCString();
if(paramInfo.IsDipper())
{
// Is an 'out' CString.
if(!(dp->val.p = new nsCString()))
{
JS_ReportOutOfMemory(mCallContext);
return JS_FALSE;
}
return JS_TRUE;
} }
// else ...
// Is an 'in' CString.
useAllocator = JS_TRUE;
break;
}
}
else {
if(type_tag == nsXPTType::T_JSVAL) {
dp->SetValIsAllocated();
useAllocator = JS_TRUE;
} }
// Do this *after* the above because in the case where we have a
// "T_DOMSTRING && IsDipper()" then arg might be null since this
// is really an 'out' param masquerading as an 'in' param.
NS_ASSERTION(i < mArgc || paramInfo.IsOptional(),
"Expected either enough arguments or an optional argument");
if(i < mArgc)
src = mArgv[i];
else if(type_tag == nsXPTType::T_JSVAL)
src = JSVAL_VOID;
else
src = JSVAL_NULL;
} }
nsID param_iid; // Do this *after* the above because in the case where we have a
if(type_tag == nsXPTType::T_INTERFACE && // "T_DOMSTRING && IsDipper()" then arg might be null since this
NS_FAILED(mIFaceInfo->GetIIDForParamNoAlloc(mVTableIndex, &paramInfo, // is really an 'out' param masquerading as an 'in' param.
&param_iid))) NS_ASSERTION(i < mArgc || paramInfo.IsOptional(),
{ "Expected either enough arguments or an optional argument");
ThrowBadParam(NS_ERROR_XPC_CANT_GET_PARAM_IFACE_INFO, i, mCallContext); if(i < mArgc)
return JS_FALSE; src = mArgv[i];
} else if(type_tag == nsXPTType::T_JSVAL)
src = JSVAL_VOID;
else
src = JSVAL_NULL;
}
uintN err; nsID param_iid;
if(!XPCConvert::JSData2Native(mCallContext, &dp->val, src, type, if(type_tag == nsXPTType::T_INTERFACE &&
useAllocator, &param_iid, &err)) NS_FAILED(mIFaceInfo->GetIIDForParamNoAlloc(mVTableIndex, &paramInfo,
{ &param_iid)))
ThrowBadParam(err, i, mCallContext); {
return JS_FALSE; ThrowBadParam(NS_ERROR_XPC_CANT_GET_PARAM_IFACE_INFO, i, mCallContext);
} return JS_FALSE;
}
uintN err;
if(!XPCConvert::JSData2Native(mCallContext, &dp->val, src, type,
useAllocator, &param_iid, &err))
{
ThrowBadParam(err, i, mCallContext);
return JS_FALSE;
}
return JS_TRUE; return JS_TRUE;
} }