Clean up JSON parsing code. Refs #1374.

Fix Engine.ReadJSONFile() which did throw a JS exception that was not
caught. Discovered by s0600204.
Expose Engine.ReadJSONFile() to the gui scripts.

This was SVN commit r15959.
This commit is contained in:
leper
2014-11-13 01:26:22 +00:00
parent e1c77bb487
commit 6e788fb15e
13 changed files with 106 additions and 128 deletions
+4 -2
View File
@@ -76,7 +76,8 @@ CScriptVal JSI_Mod::GetAvailableMods(ScriptInterface::CxPrivate* pCxPrivate)
continue;
JS::RootedValue json(cx);
scriptInterface->ParseJSON(modinfo.GetAsString(), &json);
if (!scriptInterface->ParseJSON(modinfo.GetAsString(), &json))
continue;
// Valid mod, add it to our structure
JS_SetProperty(cx, obj, utf8_from_wstring(iter->string()).c_str(), json.address());
@@ -101,7 +102,8 @@ CScriptVal JSI_Mod::GetAvailableMods(ScriptInterface::CxPrivate* pCxPrivate)
continue;
JS::RootedValue json(cx);
scriptInterface->ParseJSON(modinfo.GetAsString(), &json);
if (!scriptInterface->ParseJSON(modinfo.GetAsString(), &json))
continue;
// Valid mod, add it to our structure
JS_SetProperty(cx, obj, utf8_from_wstring(iter->string()).c_str(), json.address());