mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-10-14 07:17:44 +00:00
Changes FromJSVal to take a JS::HandleValue instead of JS::Value.
JS::HandleValue is basically a wrapper around a JS::Value that is safe for exact stack rooting and moving GC. I've tried to keep this changeset rather small and isolated and therefore create additional JS::Rooted<T> values at some places where the function should eventually directly take a JS::Handle<T>. The functions "CallFunction" and "CallFunctionVoid" put their arguments inside a JS::AutoValueVector because this will be passed directly to "CallFunction_" with ESR31. Refs #2462 Refs #2415 This was SVN commit r15517.
This commit is contained in:
@@ -52,8 +52,8 @@ class TestScriptConversions : public CxxTest::TestSuite
|
||||
JSContext* cx = script.GetContext();
|
||||
JSAutoRequest rq(cx);
|
||||
|
||||
JS::Value v1;
|
||||
ScriptInterface::ToJSVal(cx, v1, value);
|
||||
JS::RootedValue v1(cx);
|
||||
ScriptInterface::ToJSVal(cx, v1.get(), value);
|
||||
|
||||
std::string source;
|
||||
TS_ASSERT(script.CallFunction(OBJECT_TO_JSVAL(JS_GetGlobalForScopeChain(cx)), "uneval", CScriptVal(v1), source));
|
||||
@@ -62,7 +62,7 @@ class TestScriptConversions : public CxxTest::TestSuite
|
||||
TS_ASSERT_STR_EQUALS(source, expected);
|
||||
|
||||
T v2 = T();
|
||||
TS_ASSERT(ScriptInterface::FromJSVal(script.GetContext(), v1, v2));
|
||||
TS_ASSERT(ScriptInterface::FromJSVal(cx, v1, v2));
|
||||
TS_ASSERT_EQUALS(value, v2);
|
||||
}
|
||||
|
||||
@@ -163,8 +163,8 @@ public:
|
||||
JSAutoRequest rq(cx);
|
||||
|
||||
float f = 0;
|
||||
JS::Value testNANVal;
|
||||
ScriptInterface::ToJSVal(cx, testNANVal, NAN);
|
||||
JS::RootedValue testNANVal(cx);
|
||||
ScriptInterface::ToJSVal(cx, testNANVal.get(), NAN);
|
||||
TS_ASSERT(ScriptInterface::FromJSVal(cx, testNANVal, f));
|
||||
TS_ASSERT(isnan(f));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user