mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-24 23:47:27 +00:00
Improve JS Exception handling.
- Check for pending exceptions after function calls and script executions. - Call LOGERROR instead of JS_ReportError when there is a conversion error in FromJSVal, since that can only be called from C++ (where JS errors don't really make sense). Instead, C++ callers of FromJSVal should handle the failure and, themselves, either report an error or simply do something else. - Wrap JS_ReportError since that makes updating it later easier. This isn't a systematical fix since ToJSVal also ought return a boolean for failures, and we probably should trigger errors instead of warnings on 'implicit' conversions, rather a preparation diff. Part of the SM52 migration, stage: SM45 compatible (actually SM52 incompatible, too). Based on a patch by: Itms Comments by: Vladislavbelov, Stan` Refs #742, #4893 Differential Revision: https://code.wildfiregames.com/D3093 This was SVN commit r24187.
This commit is contained in:
@@ -50,7 +50,7 @@ JS::Value JSI_Simulation::GuiInterfaceCall(ScriptInterface::CmptPrivate* pCmptPr
|
||||
if (!cmpGuiInterface)
|
||||
return JS::UndefinedValue();
|
||||
|
||||
ScriptInterface::Request rqSim(sim->GetScriptInterface());
|
||||
ScriptRequest rqSim(sim->GetScriptInterface());
|
||||
JS::RootedValue arg(rqSim.cx, sim->GetScriptInterface().CloneValueFromOtherCompartment(*(pCmptPrivate->pScriptInterface), data));
|
||||
JS::RootedValue ret(rqSim.cx);
|
||||
cmpGuiInterface->ScriptCall(g_Game->GetViewedPlayerID(), name, arg, &ret);
|
||||
@@ -70,7 +70,7 @@ void JSI_Simulation::PostNetworkCommand(ScriptInterface::CmptPrivate* pCmptPriva
|
||||
if (!cmpCommandQueue)
|
||||
return;
|
||||
|
||||
ScriptInterface::Request rqSim(sim->GetScriptInterface());
|
||||
ScriptRequest rqSim(sim->GetScriptInterface());
|
||||
JS::RootedValue cmd2(rqSim.cx, sim->GetScriptInterface().CloneValueFromOtherCompartment(*(pCmptPrivate->pScriptInterface), cmd));
|
||||
|
||||
cmpCommandQueue->PostNetworkCommand(cmd2);
|
||||
@@ -124,7 +124,7 @@ JS::Value JSI_Simulation::GetEdgesOfStaticObstructionsOnScreenNearTo(ScriptInter
|
||||
CSimulation2* sim = g_Game->GetSimulation2();
|
||||
ENSURE(sim);
|
||||
|
||||
ScriptInterface::Request rq(pCmptPrivate);
|
||||
ScriptRequest rq(pCmptPrivate->pScriptInterface);
|
||||
JS::RootedValue edgeList(rq.cx);
|
||||
ScriptInterface::CreateArray(rq, &edgeList);
|
||||
int edgeListIndex = 0;
|
||||
|
||||
Reference in New Issue
Block a user