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:
Yves
2014-07-12 19:08:39 +00:00
parent cfa59fc4e1
commit db9c20e0a9
8 changed files with 141 additions and 104 deletions
@@ -91,7 +91,7 @@ template<> void ScriptInterface::ToJSVal<const CParamNode*>(JSContext* cx, JS::V
ret = JSVAL_VOID;
}
template<> bool ScriptInterface::FromJSVal<CColor>(JSContext* cx, jsval v, CColor& out)
template<> bool ScriptInterface::FromJSVal<CColor>(JSContext* cx, JS::HandleValue v, CColor& out)
{
if (!v.isObject())
FAIL("jsval not an object");
@@ -142,7 +142,7 @@ template<> void ScriptInterface::ToJSVal<CColor>(JSContext* cx, JS::Value& ret,
ret = JS::ObjectValue(*obj);
}
template<> bool ScriptInterface::FromJSVal<fixed>(JSContext* cx, jsval v, fixed& out)
template<> bool ScriptInterface::FromJSVal<fixed>(JSContext* cx, JS::HandleValue v, fixed& out)
{
JSAutoRequest rq(cx);
double ret;
@@ -159,7 +159,7 @@ template<> void ScriptInterface::ToJSVal<fixed>(JSContext* UNUSED(cx), JS::Value
ret = JS::NumberValue(val.ToDouble());
}
template<> bool ScriptInterface::FromJSVal<CFixedVector3D>(JSContext* cx, jsval v, CFixedVector3D& out)
template<> bool ScriptInterface::FromJSVal<CFixedVector3D>(JSContext* cx, JS::HandleValue v, CFixedVector3D& out)
{
if (!v.isObject())
return false; // TODO: report type error
@@ -210,7 +210,7 @@ template<> void ScriptInterface::ToJSVal<CFixedVector3D>(JSContext* cx, JS::Valu
ret = JS::ObjectValue(*obj);
}
template<> bool ScriptInterface::FromJSVal<CFixedVector2D>(JSContext* cx, jsval v, CFixedVector2D& out)
template<> bool ScriptInterface::FromJSVal<CFixedVector2D>(JSContext* cx, JS::HandleValue v, CFixedVector2D& out)
{
JSAutoRequest rq(cx);
if (!v.isObject())