forked from mirrors/0ad
Add ToJSVal<CRect> to make the conversion reusable, remove unused PSERROR_Scripting_ConversionFailed and dead catch.
Avoids the CRect copy or stops relying on optimization to avoid the copy. Split from D2142. Differential Revision: https://code.wildfiregames.com/D2259 Tested on: gcc 9.1.0, Jenkins This was SVN commit r22847.
This commit is contained in:
@@ -228,24 +228,7 @@ bool JSI_IGUIObject::getComputedSize(JSContext* cx, uint argc, JS::Value* vp)
|
||||
return false;
|
||||
|
||||
e->UpdateCachedSize();
|
||||
CRect size = e->m_CachedActualSize;
|
||||
ScriptInterface::ToJSVal(cx, args.rval(), e->m_CachedActualSize);
|
||||
|
||||
JS::RootedValue objVal(cx);
|
||||
try
|
||||
{
|
||||
ScriptInterface::GetScriptInterfaceAndCBData(cx)->pScriptInterface->CreateObject(
|
||||
&objVal,
|
||||
"left", size.left,
|
||||
"right", size.right,
|
||||
"top", size.top,
|
||||
"bottom", size.bottom);
|
||||
}
|
||||
catch (PSERROR_Scripting_ConversionFailed&)
|
||||
{
|
||||
debug_warn(L"Error creating size object!");
|
||||
return false;
|
||||
}
|
||||
|
||||
args.rval().set(objVal);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user