1
0
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:
elexis
2019-09-04 16:15:37 +00:00
parent c25ab670e6
commit d5c1fd09a4
5 changed files with 47 additions and 71 deletions
@@ -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;
}