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
@@ -211,6 +211,16 @@ template<> bool ScriptInterface::FromJSVal<CPos>(JSContext* cx, JS::HandleValue
return true;
}
template<> void ScriptInterface::ToJSVal<CRect>(JSContext* cx, JS::MutableHandleValue ret, const CRect& val)
{
ScriptInterface::GetScriptInterfaceAndCBData(cx)->pScriptInterface->CreateObject(
ret,
"left", val.left,
"right", val.right,
"top", val.top,
"bottom", val.bottom);
}
template<> void ScriptInterface::ToJSVal<CClientArea>(JSContext* cx, JS::MutableHandleValue ret, const CClientArea& val)
{
val.ToJSVal(cx, ret);