mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-10-14 07:17:44 +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:
@@ -35,7 +35,7 @@ class TestScriptConversions : public CxxTest::TestSuite
|
||||
{
|
||||
ScriptInterface script("Test", "Test", g_ScriptContext);
|
||||
TS_ASSERT(script.LoadGlobalScripts());
|
||||
ScriptInterface::Request rq(script);
|
||||
ScriptRequest rq(script);
|
||||
|
||||
JS::RootedValue v1(rq.cx);
|
||||
ScriptInterface::ToJSVal(rq, &v1, value);
|
||||
@@ -54,7 +54,7 @@ class TestScriptConversions : public CxxTest::TestSuite
|
||||
{
|
||||
ScriptInterface script("Test", "Test", g_ScriptContext);
|
||||
TS_ASSERT(script.LoadGlobalScripts());
|
||||
ScriptInterface::Request rq(script);
|
||||
ScriptRequest rq(script);
|
||||
|
||||
JS::RootedValue v1(rq.cx);
|
||||
ScriptInterface::ToJSVal(rq, &v1, value);
|
||||
@@ -76,7 +76,7 @@ class TestScriptConversions : public CxxTest::TestSuite
|
||||
{
|
||||
ScriptInterface script("Test", "Test", g_ScriptContext);
|
||||
TS_ASSERT(script.LoadGlobalScripts());
|
||||
ScriptInterface::Request rq(script);
|
||||
ScriptRequest rq(script);
|
||||
|
||||
JS::RootedValue v1(rq.cx);
|
||||
ScriptInterface::ToJSVal(rq, &v1, v);
|
||||
@@ -169,7 +169,7 @@ public:
|
||||
void test_integers()
|
||||
{
|
||||
ScriptInterface script("Test", "Test", g_ScriptContext);
|
||||
ScriptInterface::Request rq(script);
|
||||
ScriptRequest rq(script);
|
||||
|
||||
// using new uninitialized variables each time to be sure the test doesn't succeeed if ToJSVal doesn't touch the value at all.
|
||||
JS::RootedValue val0(rq.cx), val1(rq.cx), val2(rq.cx), val3(rq.cx), val4(rq.cx), val5(rq.cx), val6(rq.cx), val7(rq.cx), val8(rq.cx);
|
||||
@@ -201,7 +201,7 @@ public:
|
||||
convert_to<float>(std::numeric_limits<float>::quiet_NaN(), "NaN"); // can't use roundtrip since nan != nan
|
||||
|
||||
ScriptInterface script("Test", "Test", g_ScriptContext);
|
||||
ScriptInterface::Request rq(script);
|
||||
ScriptRequest rq(script);
|
||||
|
||||
float f = 0;
|
||||
JS::RootedValue testNANVal(rq.cx);
|
||||
@@ -252,7 +252,7 @@ public:
|
||||
// Fancier conversion: we store UTF8 and get UTF16 and vice-versa
|
||||
ScriptInterface script("Test", "Test", g_ScriptContext);
|
||||
TS_ASSERT(script.LoadGlobalScripts());
|
||||
ScriptInterface::Request rq(script);
|
||||
ScriptRequest rq(script);
|
||||
|
||||
std::string in_utf8("éè!§$-aezi134900°°©©¢¢ÇÇ‘{¶«¡Ç’[å»ÛÁØ");
|
||||
std::wstring in_utf16(L"éè!§$-aezi134900°°©©¢¢ÇÇ‘{¶«¡Ç’[å»ÛÁØ");
|
||||
|
||||
Reference in New Issue
Block a user