mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-21 01:04:06 +00:00
Fix missing JSAutoRequest before JS_ReportError in various commits.
Differential Revision: https://code.wildfiregames.com/D2256 Tested on: clang 8.0.1, Jenkins This was SVN commit r22949.
This commit is contained in:
@@ -51,6 +51,7 @@ bool CGUISetting<CGUIColor>::FromJSVal(JSContext* cx, JS::HandleValue Value, con
|
||||
|
||||
if (!settingValue.ParseString(m_pObject.GetGUI(), name))
|
||||
{
|
||||
JSAutoRequest rq(cx);
|
||||
JS_ReportError(cx, "Invalid color '%s'", name.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -166,18 +166,21 @@ template<> bool ScriptInterface::FromJSVal<CSize>(JSContext* cx, JS::HandleValue
|
||||
{
|
||||
if (!v.isObject())
|
||||
{
|
||||
JSAutoRequest rq(cx);
|
||||
JS_ReportError(cx, "CSize value must be an object!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!FromJSProperty(cx, v, "width", out.cx))
|
||||
{
|
||||
JSAutoRequest rq(cx);
|
||||
JS_ReportError(cx, "Failed to get CSize.cx property");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!FromJSProperty(cx, v, "height", out.cy))
|
||||
{
|
||||
JSAutoRequest rq(cx);
|
||||
JS_ReportError(cx, "Failed to get CSize.cy property");
|
||||
return false;
|
||||
}
|
||||
@@ -194,18 +197,21 @@ template<> bool ScriptInterface::FromJSVal<CPos>(JSContext* cx, JS::HandleValue
|
||||
{
|
||||
if (!v.isObject())
|
||||
{
|
||||
JSAutoRequest rq(cx);
|
||||
JS_ReportError(cx, "CPos value must be an object!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!FromJSProperty(cx, v, "x", out.x))
|
||||
{
|
||||
JSAutoRequest rq(cx);
|
||||
JS_ReportError(cx, "Failed to get CPos.x property");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!FromJSProperty(cx, v, "y", out.y))
|
||||
{
|
||||
JSAutoRequest rq(cx);
|
||||
JS_ReportError(cx, "Failed to get CPos.y property");
|
||||
return false;
|
||||
}
|
||||
@@ -273,6 +279,7 @@ template<> void ScriptInterface::ToJSVal<EVAlign>(JSContext* cx, JS::MutableHand
|
||||
|
||||
default:
|
||||
word = "error";
|
||||
JSAutoRequest rq(cx);
|
||||
JS_ReportError(cx, "Invalid EVAlign");
|
||||
break;
|
||||
}
|
||||
@@ -293,6 +300,7 @@ template<> bool ScriptInterface::FromJSVal<EVAlign>(JSContext* cx, JS::HandleVal
|
||||
else
|
||||
{
|
||||
out = EVAlign_Top;
|
||||
JSAutoRequest rq(cx);
|
||||
JS_ReportError(cx, "Invalid alignment (should be 'left', 'right' or 'center')");
|
||||
return false;
|
||||
}
|
||||
@@ -315,6 +323,7 @@ template<> void ScriptInterface::ToJSVal<EAlign>(JSContext* cx, JS::MutableHandl
|
||||
break;
|
||||
default:
|
||||
word = "error";
|
||||
JSAutoRequest rq(cx);
|
||||
JS_ReportError(cx, "Invalid alignment (should be 'left', 'right' or 'center')");
|
||||
break;
|
||||
}
|
||||
@@ -335,6 +344,7 @@ template<> bool ScriptInterface::FromJSVal<EAlign>(JSContext* cx, JS::HandleValu
|
||||
else
|
||||
{
|
||||
out = EAlign_Left;
|
||||
JSAutoRequest rq(cx);
|
||||
JS_ReportError(cx, "Invalid alignment (should be 'left', 'right' or 'center')");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -101,7 +101,9 @@ bool JSI_Game::IsPaused(ScriptInterface::CxPrivate* pCxPrivate)
|
||||
{
|
||||
if (!g_Game)
|
||||
{
|
||||
JS_ReportError(pCxPrivate->pScriptInterface->GetContext(), "Game is not started");
|
||||
JSContext* cx = pCxPrivate->pScriptInterface->GetContext();
|
||||
JSAutoRequest rq(cx);
|
||||
JS_ReportError(cx, "Game is not started");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -112,7 +114,9 @@ void JSI_Game::SetPaused(ScriptInterface::CxPrivate* pCxPrivate, bool pause, boo
|
||||
{
|
||||
if (!g_Game)
|
||||
{
|
||||
JS_ReportError(pCxPrivate->pScriptInterface->GetContext(), "Game is not started");
|
||||
JSContext* cx = pCxPrivate->pScriptInterface->GetContext();
|
||||
JSAutoRequest rq(cx);
|
||||
JS_ReportError(cx, "Game is not started");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -228,10 +228,9 @@ bool JSI_VFS::PathRestrictionMet(ScriptInterface::CxPrivate* pCxPrivate, const s
|
||||
allowedPaths += L"\"" + validPaths[i] + L"\"";
|
||||
}
|
||||
|
||||
JS_ReportError(
|
||||
pCxPrivate->pScriptInterface->GetContext(),
|
||||
"This part of the engine may only read from %s!",
|
||||
utf8_from_wstring(allowedPaths).c_str());
|
||||
JSContext* cx = pCxPrivate->pScriptInterface->GetContext();
|
||||
JSAutoRequest rq(cx);
|
||||
JS_ReportError(cx, "This part of the engine may only read from %s!", utf8_from_wstring(allowedPaths).c_str());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -214,6 +214,7 @@ bool deepfreeze(JSContext* cx, uint argc, JS::Value* vp)
|
||||
|
||||
if (args.length() != 1 || !args.get(0).isObject())
|
||||
{
|
||||
JSAutoRequest rq(cx);
|
||||
JS_ReportError(cx, "deepfreeze requires exactly one object as an argument.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -90,10 +90,11 @@ template<> void ScriptInterface::ToJSVal<const CParamNode*>(JSContext* cx, JS::M
|
||||
|
||||
template<> bool ScriptInterface::FromJSVal<CColor>(JSContext* cx, JS::HandleValue v, CColor& out)
|
||||
{
|
||||
JSAutoRequest rq(cx);
|
||||
|
||||
if (!v.isObject())
|
||||
FAIL("JS::HandleValue not an object");
|
||||
|
||||
JSAutoRequest rq(cx);
|
||||
JS::RootedObject obj(cx, &v.toObject());
|
||||
|
||||
JS::RootedValue r(cx);
|
||||
@@ -262,10 +263,11 @@ template<> void ScriptInterface::ToJSVal<Grid<u16> >(JSContext* cx, JS::MutableH
|
||||
|
||||
template<> bool ScriptInterface::FromJSVal<TNSpline>(JSContext* cx, JS::HandleValue v, TNSpline& out)
|
||||
{
|
||||
JSAutoRequest rq(cx);
|
||||
|
||||
if (!v.isObject())
|
||||
FAIL("Argument must be an object");
|
||||
|
||||
JSAutoRequest rq(cx);
|
||||
JS::RootedObject obj(cx, &v.toObject());
|
||||
bool isArray;
|
||||
if (!JS_IsArrayObject(cx, obj, &isArray) || !isArray)
|
||||
@@ -300,10 +302,11 @@ template<> bool ScriptInterface::FromJSVal<TNSpline>(JSContext* cx, JS::HandleVa
|
||||
|
||||
template<> bool ScriptInterface::FromJSVal<CCinemaPath>(JSContext* cx, JS::HandleValue v, CCinemaPath& out)
|
||||
{
|
||||
JSAutoRequest rq(cx);
|
||||
|
||||
if (!v.isObject())
|
||||
FAIL("Argument must be an object");
|
||||
|
||||
JSAutoRequest rq(cx);
|
||||
JS::RootedObject obj(cx, &v.toObject());
|
||||
|
||||
CCinemaData pathData;
|
||||
|
||||
Reference in New Issue
Block a user