mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-21 03:06:29 +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:
+4
-4
@@ -39,7 +39,7 @@ CmdLineArgs g_args;
|
||||
|
||||
JS::Value Mod::GetAvailableMods(const ScriptInterface& scriptInterface)
|
||||
{
|
||||
ScriptInterface::Request rq(scriptInterface);
|
||||
ScriptRequest rq(scriptInterface);
|
||||
JS::RootedObject obj(rq.cx, JS_NewPlainObject(rq.cx));
|
||||
|
||||
const Paths paths(g_args);
|
||||
@@ -107,7 +107,7 @@ JS::Value Mod::GetAvailableMods(const ScriptInterface& scriptInterface)
|
||||
void Mod::CacheEnabledModVersions(const shared_ptr<ScriptContext>& scriptContext)
|
||||
{
|
||||
ScriptInterface scriptInterface("Engine", "CacheEnabledModVersions", scriptContext);
|
||||
ScriptInterface::Request rq(scriptInterface);
|
||||
ScriptRequest rq(scriptInterface);
|
||||
|
||||
JS::RootedValue availableMods(rq.cx, GetAvailableMods(scriptInterface));
|
||||
|
||||
@@ -130,7 +130,7 @@ void Mod::CacheEnabledModVersions(const shared_ptr<ScriptContext>& scriptContext
|
||||
|
||||
JS::Value Mod::GetLoadedModsWithVersions(const ScriptInterface& scriptInterface)
|
||||
{
|
||||
ScriptInterface::Request rq(scriptInterface);
|
||||
ScriptRequest rq(scriptInterface);
|
||||
JS::RootedValue returnValue(rq.cx);
|
||||
scriptInterface.ToJSVal(rq, &returnValue, g_LoadedModVersions);
|
||||
return returnValue;
|
||||
@@ -138,7 +138,7 @@ JS::Value Mod::GetLoadedModsWithVersions(const ScriptInterface& scriptInterface)
|
||||
|
||||
JS::Value Mod::GetEngineInfo(const ScriptInterface& scriptInterface)
|
||||
{
|
||||
ScriptInterface::Request rq(scriptInterface);
|
||||
ScriptRequest rq(scriptInterface);
|
||||
|
||||
JS::RootedValue mods(rq.cx, Mod::GetLoadedModsWithVersions(scriptInterface));
|
||||
JS::RootedValue metainfo(rq.cx);
|
||||
|
||||
Reference in New Issue
Block a user