1
0
forked from mirrors/0ad

Exact rooting for CallConstructor.

Refs #2415
Refs #2462

This was SVN commit r15601.
This commit is contained in:
Yves
2014-08-02 16:30:15 +00:00
parent 736d934107
commit c818b8e475
4 changed files with 30 additions and 19 deletions
+6 -5
View File
@@ -865,20 +865,21 @@ AutoGCRooter* ScriptInterface::ReplaceAutoGCRooter(AutoGCRooter* rooter)
return ret;
}
jsval ScriptInterface::CallConstructor(jsval ctor, uint argc, jsval argv)
void ScriptInterface::CallConstructor(JS::HandleValue ctor, JS::AutoValueVector& argv, JS::MutableHandleValue out)
{
JSAutoRequest rq(m->m_cx);
if (!ctor.isObject())
{
LOGERROR(L"CallConstructor: ctor is not an object");
return JS::UndefinedValue();
out.setNull();
return;
}
// Passing argc 0 and argv JSVAL_VOID causes a crash in mozjs24
if (argc == 0)
return JS::ObjectValue(*JS_New(m->m_cx, &ctor.toObject(), 0, NULL));
if (argv.length() == 0)
out.setObjectOrNull(JS_New(m->m_cx, &ctor.toObject(), 0, NULL));
else
return JS::ObjectValue(*JS_New(m->m_cx, &ctor.toObject(), argc, &argv));
out.setObjectOrNull(JS_New(m->m_cx, &ctor.toObject(), argv.length(), argv.begin()));
}
void ScriptInterface::DefineCustomObjectType(JSClass *clasp, JSNative constructor, uint minArgs, JSPropertySpec *ps, JSFunctionSpec *fs, JSPropertySpec *static_ps, JSFunctionSpec *static_fs)