зеркало из https://github.com/mozilla/gecko-dev.git
Bug 965830 - Convert use of JS_CallFunction and related APIs uses to HandleValueArray r=terrence r=smaug
This commit is contained in:
Родитель
457e5b82c5
Коммит
c3759c40ff
|
@ -1031,7 +1031,7 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
|
|||
}
|
||||
|
||||
if (!JS_CallFunctionValue(cx, thisObject,
|
||||
funval, 1, argv.address(), rval.address())) {
|
||||
funval, argv, rval.address())) {
|
||||
nsJSUtils::ReportPendingException(cx);
|
||||
continue;
|
||||
}
|
||||
|
@ -1419,7 +1419,7 @@ nsFrameScriptExecutor::LoadFrameScriptInternal(const nsAString& aURL,
|
|||
JS::Rooted<JS::Value> rval(cx);
|
||||
JS::Rooted<JS::Value> methodVal(cx, JS::ObjectValue(*method));
|
||||
ok = JS_CallFunctionValue(cx, global, methodVal,
|
||||
0, nullptr, rval.address());
|
||||
JS::EmptyValueArray, rval.address());
|
||||
} else if (script) {
|
||||
ok = JS_ExecuteScript(cx, global, script, nullptr);
|
||||
}
|
||||
|
|
|
@ -3225,8 +3225,7 @@ nsObjectLoadingContent::LegacyCall(JSContext* aCx,
|
|||
}
|
||||
|
||||
JS::Rooted<JS::Value> retval(aCx);
|
||||
bool ok = JS::Call(aCx, thisVal, pi_obj, args.length(), args.begin(),
|
||||
&retval);
|
||||
bool ok = JS::Call(aCx, thisVal, pi_obj, args, &retval);
|
||||
if (!ok) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return JS::UndefinedValue();
|
||||
|
|
|
@ -2043,7 +2043,9 @@ BaseStubConstructor(nsIWeakReference* aWeakOwner,
|
|||
// we also pass in the calling window as the first argument
|
||||
unsigned argc = args.length() + 1;
|
||||
JS::AutoValueVector argv(cx);
|
||||
argv.resize(argc);
|
||||
if (!argv.resize(argc)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> currentWin(do_GetInterface(currentInner));
|
||||
rv = WrapNative(cx, obj, currentWin, &NS_GET_IID(nsIDOMWindow),
|
||||
|
@ -2058,9 +2060,7 @@ BaseStubConstructor(nsIWeakReference* aWeakOwner,
|
|||
}
|
||||
|
||||
JS::Rooted<JS::Value> frval(cx);
|
||||
bool ret = JS_CallFunctionValue(cx, thisObject, funval,
|
||||
argc, argv.begin(),
|
||||
frval.address());
|
||||
bool ret = JS_CallFunctionValue(cx, thisObject, funval, argv, frval.address());
|
||||
|
||||
if (!ret) {
|
||||
return NS_ERROR_FAILURE;
|
||||
|
|
|
@ -1608,7 +1608,7 @@ NativeToString(JSContext* cx, JS::Handle<JSObject*> wrapper,
|
|||
}
|
||||
MOZ_ASSERT(JS_ObjectIsCallable(cx, &toString.toObject()));
|
||||
JS::Rooted<JS::Value> toStringResult(cx);
|
||||
if (JS_CallFunctionValue(cx, obj, toString, 0, nullptr,
|
||||
if (JS_CallFunctionValue(cx, obj, toString, JS::EmptyValueArray,
|
||||
toStringResult.address())) {
|
||||
str = toStringResult.toString();
|
||||
} else {
|
||||
|
|
|
@ -11294,14 +11294,12 @@ class CallbackMethod(CallbackMember):
|
|||
"callGuard": self.getCallGuard()
|
||||
}
|
||||
if self.argCount > 0:
|
||||
replacements["argv"] = "argv.begin()"
|
||||
replacements["argc"] = "argc"
|
||||
replacements["args"] = "JS::HandleValueArray::subarray(argv, 0, argc)"
|
||||
else:
|
||||
replacements["argv"] = "nullptr"
|
||||
replacements["argc"] = "0"
|
||||
replacements["args"] = "JS::EmptyValueArray"
|
||||
return string.Template("${getCallable}"
|
||||
"if (${callGuard}!JS::Call(cx, ${thisVal}, callable,\n"
|
||||
" ${argc}, ${argv}, &rval)) {\n"
|
||||
" ${args}, &rval)) {\n"
|
||||
" aRv.Throw(NS_ERROR_UNEXPECTED);\n"
|
||||
" return${errorReturn};\n"
|
||||
"}\n").substitute(replacements)
|
||||
|
|
|
@ -659,8 +659,7 @@ doInvoke(NPObject *npobj, NPIdentifier method, const NPVariant *args,
|
|||
ok = true;
|
||||
}
|
||||
} else {
|
||||
ok = ::JS_CallFunctionValue(cx, npjsobj->mJSObj, fv, jsargs.length(),
|
||||
jsargs.begin(), v.address());
|
||||
ok = ::JS_CallFunctionValue(cx, npjsobj->mJSObj, fv, jsargs, v.address());
|
||||
}
|
||||
|
||||
if (ok)
|
||||
|
@ -1606,7 +1605,7 @@ NPObjWrapper_Convert(JSContext *cx, JS::Handle<JSObject*> obj, JSType hint, JS::
|
|||
if (!JS_GetProperty(cx, obj, "toString", &v))
|
||||
return false;
|
||||
if (!JSVAL_IS_PRIMITIVE(v) && JS_ObjectIsCallable(cx, JSVAL_TO_OBJECT(v))) {
|
||||
if (!JS_CallFunctionValue(cx, obj, v, 0, nullptr, vp.address()))
|
||||
if (!JS_CallFunctionValue(cx, obj, v, JS::EmptyValueArray, vp.address()))
|
||||
return false;
|
||||
if (JSVAL_IS_PRIMITIVE(vp))
|
||||
return true;
|
||||
|
|
|
@ -220,7 +220,7 @@ nsJSON::EncodeInternal(JSContext* cx, const JS::Value& aValue,
|
|||
toJSON.isObject() &&
|
||||
JS_ObjectIsCallable(cx, &toJSON.toObject())) {
|
||||
// If toJSON is implemented, it must not throw
|
||||
if (!JS_CallFunctionValue(cx, obj, toJSON, 0, nullptr, val.address())) {
|
||||
if (!JS_CallFunctionValue(cx, obj, toJSON, JS::EmptyValueArray, val.address())) {
|
||||
if (JS_IsExceptionPending(cx))
|
||||
// passing NS_OK will throw the pending exception
|
||||
return NS_OK;
|
||||
|
|
|
@ -321,18 +321,13 @@ private:
|
|||
stackValue = JS::ObjectValue(*stackObj);
|
||||
}
|
||||
|
||||
JS::AutoValueVector argv(cx);
|
||||
if (!argv.resize(3)) {
|
||||
return;
|
||||
}
|
||||
|
||||
argv[0] = methodValue;
|
||||
argv[1] = argumentsValue;
|
||||
argv[2] = stackValue;
|
||||
JS::AutoValueArray<3> args(cx);
|
||||
args[0].set(methodValue);
|
||||
args[1].set(argumentsValue);
|
||||
args[2].set(stackValue);
|
||||
|
||||
JS::Rooted<JS::Value> ret(cx);
|
||||
JS_CallFunctionName(cx, consoleObj, "queueCall", argv.length(),
|
||||
argv.begin(), ret.address());
|
||||
JS_CallFunctionName(cx, consoleObj, "queueCall", args, ret.address());
|
||||
}
|
||||
|
||||
WorkerConsole* mConsole;
|
||||
|
|
|
@ -5388,10 +5388,10 @@ WorkerPrivate::RunExpiredTimeouts(JSContext* aCx)
|
|||
* unsafeGet() is needed below because the argument is a not a const
|
||||
* pointer, even though values are not modified.
|
||||
*/
|
||||
if (!JS_CallFunctionValue(aCx, global, info->mTimeoutCallable,
|
||||
info->mExtraArgVals.Length(),
|
||||
info->mExtraArgVals.Elements()->unsafeGet(),
|
||||
rval.address()) &&
|
||||
JS::HandleValueArray args =
|
||||
JS::HandleValueArray::fromMarkedLocation(info->mExtraArgVals.Length(),
|
||||
info->mExtraArgVals.Elements()->unsafeGet());
|
||||
if (!JS_CallFunctionValue(aCx, global, info->mTimeoutCallable, args, rval.address()) &&
|
||||
!JS_ReportPendingException(aCx)) {
|
||||
retval = false;
|
||||
break;
|
||||
|
|
|
@ -335,7 +335,7 @@ nsXBLProtoImplAnonymousMethod::Execute(nsIContent* aBoundElement)
|
|||
if (scriptAllowed) {
|
||||
JS::Rooted<JS::Value> retval(cx);
|
||||
ok = ::JS_CallFunctionValue(cx, thisObject, OBJECT_TO_JSVAL(method),
|
||||
0 /* argc */, nullptr /* argv */, retval.address());
|
||||
JS::EmptyValueArray, retval.address());
|
||||
}
|
||||
|
||||
if (!ok) {
|
||||
|
|
|
@ -157,17 +157,17 @@ private:
|
|||
bool
|
||||
DispatchNFCEvent::RunTask(JSContext* aCx)
|
||||
{
|
||||
JSObject* obj = JS::CurrentGlobalOrNull(aCx);
|
||||
JS::Rooted<JSObject*> obj(aCx, JS::CurrentGlobalOrNull(aCx));
|
||||
|
||||
JSObject* array = JS_NewUint8Array(aCx, mMessage->mSize);
|
||||
if (!array) {
|
||||
return false;
|
||||
}
|
||||
JS::Rooted<JS::Value> arrayVal(aCx, JS::ObjectValue(*array));
|
||||
|
||||
memcpy(JS_GetArrayBufferViewData(array), mMessage->mData, mMessage->mSize);
|
||||
JS::Value argv[] = { OBJECT_TO_JSVAL(array) };
|
||||
return JS_CallFunctionName(aCx, obj, "onNfcMessage",
|
||||
mozilla::ArrayLength(argv), argv, argv);
|
||||
JS::Rooted<JS::Value> rval(aCx);
|
||||
return JS_CallFunctionName(aCx, obj, "onNfcMessage", arrayVal, rval.address());
|
||||
}
|
||||
|
||||
class NfcConnector : public mozilla::ipc::UnixSocketConnector
|
||||
|
|
|
@ -164,17 +164,17 @@ private:
|
|||
bool
|
||||
DispatchRILEvent::RunTask(JSContext *aCx)
|
||||
{
|
||||
JSObject *obj = JS::CurrentGlobalOrNull(aCx);
|
||||
JS::Rooted<JSObject*> obj(aCx, JS::CurrentGlobalOrNull(aCx));
|
||||
|
||||
JSObject *array = JS_NewUint8Array(aCx, mMessage->mSize);
|
||||
if (!array) {
|
||||
return false;
|
||||
}
|
||||
JS::Rooted<JS::Value> arrayVal(aCx, JS::ObjectValue(*array));
|
||||
|
||||
memcpy(JS_GetArrayBufferViewData(array), mMessage->mData, mMessage->mSize);
|
||||
JS::Value argv[] = { OBJECT_TO_JSVAL(array) };
|
||||
return JS_CallFunctionName(aCx, obj, "onRILMessage",
|
||||
mozilla::ArrayLength(argv), argv, argv);
|
||||
JS::Rooted<JS::Value> rval(aCx);
|
||||
return JS_CallFunctionName(aCx, obj, "onRILMessage", arrayVal, rval.address());
|
||||
}
|
||||
|
||||
class RilConnector : public mozilla::ipc::UnixSocketConnector
|
||||
|
|
|
@ -73,8 +73,7 @@ TestShellCommandParent::RunCallback(const nsString& aResponse)
|
|||
JS::Rooted<JS::Value> strVal(mCx, JS::StringValue(str));
|
||||
|
||||
JS::Rooted<JS::Value> rval(mCx);
|
||||
bool ok = JS_CallFunctionValue(mCx, global, mCallback, 1, strVal.address(),
|
||||
rval.address());
|
||||
bool ok = JS_CallFunctionValue(mCx, global, mCallback, strVal, rval.address());
|
||||
NS_ENSURE_TRUE(ok, false);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -501,7 +501,8 @@ JavaScriptChild::AnswerCall(const ObjectId &objId, const nsTArray<JSParam> &argv
|
|||
AutoSaveContextOptions asco(cx);
|
||||
ContextOptionsRef(cx).setDontReportUncaught(true);
|
||||
|
||||
bool success = JS::Call(cx, vals[1], vals[0], vals.length() - 2, vals.begin() + 2, &rval);
|
||||
HandleValueArray args = HandleValueArray::subarray(vals, 2, vals.length() - 2);
|
||||
bool success = JS::Call(cx, vals[1], vals[0], args, &rval);
|
||||
if (!success)
|
||||
return fail(cx, rs);
|
||||
}
|
||||
|
|
|
@ -6185,8 +6185,7 @@ CClosure::ClosureStub(ffi_cif* cif, void* result, void** args, void* userData)
|
|||
// Call the JS function. 'thisObj' may be nullptr, in which case the JS
|
||||
// engine will find an appropriate object to use.
|
||||
RootedValue rval(cx);
|
||||
bool success = JS_CallFunctionValue(cx, thisObj, OBJECT_TO_JSVAL(jsfnObj),
|
||||
cif->nargs, argv.begin(), rval.address());
|
||||
bool success = JS_CallFunctionValue(cx, thisObj, OBJECT_TO_JSVAL(jsfnObj), argv, rval.address());
|
||||
|
||||
// Convert the result. Note that we pass 'isArgument = false', such that
|
||||
// ImplicitConvert will *not* autoconvert a JS string into a pointer-to-char
|
||||
|
|
|
@ -20,7 +20,7 @@ BEGIN_TEST(test_BindCallable)
|
|||
CHECK(newCallable);
|
||||
|
||||
JS::RootedValue retval(cx);
|
||||
bool called = JS_CallFunctionValue(cx, nullptr, OBJECT_TO_JSVAL(newCallable), 0, nullptr,
|
||||
bool called = JS_CallFunctionValue(cx, nullptr, OBJECT_TO_JSVAL(newCallable), JS::EmptyValueArray,
|
||||
retval.address());
|
||||
CHECK(called);
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ BEGIN_TEST(test_CallNonGenericMethodOnProxy)
|
|||
CHECK(customMethodA);
|
||||
|
||||
JS::RootedValue rval(cx);
|
||||
CHECK(JS_CallFunction(cx, customA, customMethodA, 0, nullptr, rval.address()));
|
||||
CHECK(JS_CallFunction(cx, customA, customMethodA, JS::EmptyValueArray, rval.address()));
|
||||
CHECK_SAME(rval, Int32Value(17));
|
||||
|
||||
// Now create the second global object and compartment...
|
||||
|
@ -73,14 +73,14 @@ BEGIN_TEST(test_CallNonGenericMethodOnProxy)
|
|||
CHECK(customMethodB);
|
||||
|
||||
JS::RootedValue rval(cx);
|
||||
CHECK(JS_CallFunction(cx, customB, customMethodB, 0, nullptr, rval.address()));
|
||||
CHECK(JS_CallFunction(cx, customB, customMethodB, JS::EmptyValueArray, rval.address()));
|
||||
CHECK_SAME(rval, Int32Value(42));
|
||||
|
||||
JS::RootedObject wrappedCustomA(cx, customA);
|
||||
CHECK(JS_WrapObject(cx, &wrappedCustomA));
|
||||
|
||||
JS::RootedValue rval2(cx);
|
||||
CHECK(JS_CallFunction(cx, wrappedCustomA, customMethodB, 0, nullptr, rval2.address()));
|
||||
CHECK(JS_CallFunction(cx, wrappedCustomA, customMethodB, JS::EmptyValueArray, rval2.address()));
|
||||
CHECK_SAME(rval, Int32Value(42));
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ CallTrusted(JSContext *cx, unsigned argc, jsval *vp)
|
|||
{
|
||||
JSAutoCompartment ac(cx, trusted_glob);
|
||||
ok = JS_CallFunctionValue(cx, nullptr, JS::ObjectValue(*trusted_fun),
|
||||
0, nullptr, vp);
|
||||
JS::EmptyValueArray, vp);
|
||||
}
|
||||
JS_RestoreFrameChain(cx);
|
||||
return ok;
|
||||
|
@ -91,7 +91,7 @@ BEGIN_TEST(testChromeBuffer)
|
|||
bytes, strlen(bytes), options));
|
||||
|
||||
JS::RootedValue rval(cx);
|
||||
CHECK(JS_CallFunction(cx, nullptr, fun, 1, v.address(), rval.address()));
|
||||
CHECK(JS_CallFunction(cx, nullptr, fun, v, rval.address()));
|
||||
CHECK(JSVAL_TO_INT(rval) == 100);
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ BEGIN_TEST(testChromeBuffer)
|
|||
bytes, strlen(bytes), options));
|
||||
|
||||
JS::RootedValue rval(cx);
|
||||
CHECK(JS_CallFunction(cx, nullptr, fun, 1, v.address(), rval.address()));
|
||||
CHECK(JS_CallFunction(cx, nullptr, fun, v, rval.address()));
|
||||
bool match;
|
||||
CHECK(JS_StringEqualsAscii(cx, JSVAL_TO_STRING(rval), "From trusted: InternalError: too much recursion", &match));
|
||||
CHECK(match);
|
||||
|
@ -171,7 +171,7 @@ BEGIN_TEST(testChromeBuffer)
|
|||
|
||||
JS::RootedValue arg(cx, JS::ObjectValue(*callTrusted));
|
||||
JS::RootedValue rval(cx);
|
||||
CHECK(JS_CallFunction(cx, nullptr, fun, 1, arg.address(), rval.address()));
|
||||
CHECK(JS_CallFunction(cx, nullptr, fun, arg, rval.address()));
|
||||
CHECK(JSVAL_TO_INT(rval) == 42);
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ BEGIN_TEST(testClassGetter_isCalled)
|
|||
|
||||
for (int i = 1; i < 9; i++) {
|
||||
JS::RootedValue rval(cx);
|
||||
CHECK(JS_CallFunctionName(cx, global, "check", 0, nullptr, rval.address()));
|
||||
CHECK(JS_CallFunctionName(cx, global, "check", JS::EmptyValueArray, rval.address()));
|
||||
CHECK_SAME(INT_TO_JSVAL(called_test_fn), INT_TO_JSVAL(i));
|
||||
CHECK_SAME(INT_TO_JSVAL(called_test_prop_get), INT_TO_JSVAL(4 * i));
|
||||
}
|
||||
|
|
|
@ -137,8 +137,8 @@ BEGIN_TEST(test_cloneScriptWithPrincipals)
|
|||
CHECK(JS_GetScriptPrincipals(script) == principalsB);
|
||||
|
||||
JS::RootedValue v(cx);
|
||||
JS::Value args[] = { JS::Int32Value(1) };
|
||||
CHECK(JS_CallFunctionValue(cx, B, JS::ObjectValue(*cloned), 1, args, v.address()));
|
||||
JS::RootedValue arg(cx, JS::Int32Value(1));
|
||||
CHECK(JS_CallFunctionValue(cx, B, JS::ObjectValue(*cloned), arg, v.address()));
|
||||
CHECK(v.isObject());
|
||||
|
||||
JSObject *funobj = &v.toObject();
|
||||
|
|
|
@ -224,10 +224,9 @@ bool testIndirectEval(JS::HandleObject scope, const char *code)
|
|||
JSAutoCompartment ae(cx, scope);
|
||||
JSString *codestr = JS_NewStringCopyZ(cx, code);
|
||||
CHECK(codestr);
|
||||
JS::AutoValueArray<1> args(cx);
|
||||
args[1].setString(codestr);
|
||||
JS::RootedValue arg(cx, JS::StringValue(codestr));
|
||||
JS::RootedValue v(cx);
|
||||
CHECK(JS_CallFunctionName(cx, scope, "eval", 1, args.begin(), v.address()));
|
||||
CHECK(JS_CallFunctionName(cx, scope, "eval", arg, v.address()));
|
||||
}
|
||||
|
||||
JS::RootedValue hitsv(cx);
|
||||
|
|
|
@ -20,7 +20,7 @@ BEGIN_TEST(testErrorCopying_columnCopied)
|
|||
|
||||
JS::RootedValue rval(cx);
|
||||
JS_SetErrorReporter(cx, my_ErrorReporter);
|
||||
CHECK(!JS_CallFunctionName(cx, global, "check", 0, nullptr, rval.address()));
|
||||
CHECK(!JS_CallFunctionName(cx, global, "check", JS::EmptyValueArray, rval.address()));
|
||||
CHECK(column == 27);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ BEGIN_TEST(testException_bug860435)
|
|||
CHECK(fun.isObject());
|
||||
|
||||
JS::RootedValue v(cx);
|
||||
JS_CallFunctionValue(cx, global, fun, 0, v.address(), v.address());
|
||||
JS_CallFunctionValue(cx, global, fun, JS::EmptyValueArray, v.address());
|
||||
CHECK(v.isObject());
|
||||
JS::RootedObject obj(cx, &v.toObject());
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ BEGIN_TEST(testOps_bug559006)
|
|||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
JS::RootedValue rval(cx);
|
||||
CHECK(JS_CallFunctionName(cx, global, "main", 0, nullptr, rval.address()));
|
||||
CHECK(JS_CallFunctionName(cx, global, "main", JS::EmptyValueArray, rval.address()));
|
||||
CHECK_SAME(rval, INT_TO_JSVAL(123));
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -42,7 +42,7 @@ test_fn2(JSContext *cx, unsigned argc, jsval *vp)
|
|||
{
|
||||
JS::RootedValue r(cx);
|
||||
JS::RootedObject global(cx, JS::CurrentGlobalOrNull(cx));
|
||||
return JS_CallFunctionName(cx, global, "d", 0, nullptr, r.address());
|
||||
return JS_CallFunctionName(cx, global, "d", JS::EmptyValueArray, r.address());
|
||||
}
|
||||
|
||||
static bool
|
||||
|
@ -104,13 +104,13 @@ BEGIN_TEST(testProfileStrings_isCalledWithInterpreter)
|
|||
{
|
||||
JS::RootedValue rval(cx);
|
||||
/* Make sure the stack resets and we have an entry for each stack */
|
||||
CHECK(JS_CallFunctionName(cx, global, "check", 0, nullptr, rval.address()));
|
||||
CHECK(JS_CallFunctionName(cx, global, "check", JS::EmptyValueArray, rval.address()));
|
||||
CHECK(psize == 0);
|
||||
CHECK(max_stack >= 8);
|
||||
CHECK(cx->runtime()->spsProfiler.stringsCount() == 8);
|
||||
/* Make sure the stack resets and we added no new entries */
|
||||
max_stack = 0;
|
||||
CHECK(JS_CallFunctionName(cx, global, "check", 0, nullptr, rval.address()));
|
||||
CHECK(JS_CallFunctionName(cx, global, "check", JS::EmptyValueArray, rval.address()));
|
||||
CHECK(psize == 0);
|
||||
CHECK(max_stack >= 8);
|
||||
CHECK(cx->runtime()->spsProfiler.stringsCount() == 8);
|
||||
|
@ -118,7 +118,7 @@ BEGIN_TEST(testProfileStrings_isCalledWithInterpreter)
|
|||
reset(cx);
|
||||
{
|
||||
JS::RootedValue rval(cx);
|
||||
CHECK(JS_CallFunctionName(cx, global, "check2", 0, nullptr, rval.address()));
|
||||
CHECK(JS_CallFunctionName(cx, global, "check2", JS::EmptyValueArray, rval.address()));
|
||||
CHECK(cx->runtime()->spsProfiler.stringsCount() == 5);
|
||||
CHECK(max_stack >= 6);
|
||||
CHECK(psize == 0);
|
||||
|
@ -129,7 +129,7 @@ BEGIN_TEST(testProfileStrings_isCalledWithInterpreter)
|
|||
{
|
||||
JS::RootedValue rval(cx);
|
||||
pstack[3].setLabel((char*) 1234);
|
||||
CHECK(JS_CallFunctionName(cx, global, "check", 0, nullptr, rval.address()));
|
||||
CHECK(JS_CallFunctionName(cx, global, "check", JS::EmptyValueArray, rval.address()));
|
||||
CHECK((size_t) pstack[3].label() == 1234);
|
||||
CHECK(max_stack >= 8);
|
||||
CHECK(psize == 0);
|
||||
|
@ -158,14 +158,14 @@ BEGIN_TEST(testProfileStrings_isCalledWithJIT)
|
|||
{
|
||||
JS::RootedValue rval(cx);
|
||||
/* Make sure the stack resets and we have an entry for each stack */
|
||||
CHECK(JS_CallFunctionName(cx, global, "check", 0, nullptr, rval.address()));
|
||||
CHECK(JS_CallFunctionName(cx, global, "check", JS::EmptyValueArray, rval.address()));
|
||||
CHECK(psize == 0);
|
||||
CHECK(max_stack >= 8);
|
||||
|
||||
/* Make sure the stack resets and we added no new entries */
|
||||
uint32_t cnt = cx->runtime()->spsProfiler.stringsCount();
|
||||
max_stack = 0;
|
||||
CHECK(JS_CallFunctionName(cx, global, "check", 0, nullptr, rval.address()));
|
||||
CHECK(JS_CallFunctionName(cx, global, "check", JS::EmptyValueArray, rval.address()));
|
||||
CHECK(psize == 0);
|
||||
CHECK(cx->runtime()->spsProfiler.stringsCount() == cnt);
|
||||
CHECK(max_stack >= 8);
|
||||
|
@ -178,7 +178,7 @@ BEGIN_TEST(testProfileStrings_isCalledWithJIT)
|
|||
/* Limit the size of the stack and make sure we don't overflow */
|
||||
JS::RootedValue rval(cx);
|
||||
pstack[3].setLabel((char*) 1234);
|
||||
CHECK(JS_CallFunctionName(cx, global, "check", 0, nullptr, rval.address()));
|
||||
CHECK(JS_CallFunctionName(cx, global, "check", JS::EmptyValueArray, rval.address()));
|
||||
CHECK(psize == 0);
|
||||
CHECK(max_stack >= 8);
|
||||
CHECK((size_t) pstack[3].label() == 1234);
|
||||
|
@ -200,7 +200,7 @@ BEGIN_TEST(testProfileStrings_isCalledWhenError)
|
|||
{
|
||||
JS::RootedValue rval(cx);
|
||||
/* Make sure the stack resets and we have an entry for each stack */
|
||||
bool ok = JS_CallFunctionName(cx, global, "check2", 0, nullptr, rval.address());
|
||||
bool ok = JS_CallFunctionName(cx, global, "check2", JS::EmptyValueArray, rval.address());
|
||||
CHECK(!ok);
|
||||
CHECK(psize == 0);
|
||||
CHECK(cx->runtime()->spsProfiler.stringsCount() == 1);
|
||||
|
@ -224,7 +224,7 @@ BEGIN_TEST(testProfileStrings_worksWhenEnabledOnTheFly)
|
|||
{
|
||||
/* enable it in the middle of JS and make sure things check out */
|
||||
JS::RootedValue rval(cx);
|
||||
JS_CallFunctionName(cx, global, "a", 0, nullptr, rval.address());
|
||||
JS_CallFunctionName(cx, global, "a", JS::EmptyValueArray, rval.address());
|
||||
CHECK(psize == 0);
|
||||
CHECK(max_stack >= 1);
|
||||
CHECK(cx->runtime()->spsProfiler.stringsCount() == 1);
|
||||
|
@ -236,7 +236,7 @@ BEGIN_TEST(testProfileStrings_worksWhenEnabledOnTheFly)
|
|||
{
|
||||
/* now disable in the middle of js */
|
||||
JS::RootedValue rval(cx);
|
||||
JS_CallFunctionName(cx, global, "c", 0, nullptr, rval.address());
|
||||
JS_CallFunctionName(cx, global, "c", JS::EmptyValueArray, rval.address());
|
||||
CHECK(psize == 0);
|
||||
}
|
||||
|
||||
|
@ -245,7 +245,7 @@ BEGIN_TEST(testProfileStrings_worksWhenEnabledOnTheFly)
|
|||
{
|
||||
/* now disable in the middle of js, but re-enable before final exit */
|
||||
JS::RootedValue rval(cx);
|
||||
JS_CallFunctionName(cx, global, "e", 0, nullptr, rval.address());
|
||||
JS_CallFunctionName(cx, global, "e", JS::EmptyValueArray, rval.address());
|
||||
CHECK(psize == 0);
|
||||
CHECK(max_stack >= 3);
|
||||
}
|
||||
|
@ -259,7 +259,7 @@ BEGIN_TEST(testProfileStrings_worksWhenEnabledOnTheFly)
|
|||
JS::RootedValue rval(cx);
|
||||
/* disable, and make sure that if we try to re-enter the JIT the pop
|
||||
* will still happen */
|
||||
JS_CallFunctionName(cx, global, "f", 0, nullptr, rval.address());
|
||||
JS_CallFunctionName(cx, global, "f", JS::EmptyValueArray, rval.address());
|
||||
CHECK(psize == 0);
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -4957,32 +4957,32 @@ JS_EvaluateScript(JSContext *cx, JSObject *objArg, const char *bytes, unsigned n
|
|||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_CallFunction(JSContext *cx, JSObject *objArg, JSFunction *fun, unsigned argc, jsval *argv,
|
||||
JS_CallFunction(JSContext *cx, JSObject *objArg, JSFunction *fun, const JS::HandleValueArray& args,
|
||||
jsval *rval)
|
||||
{
|
||||
RootedObject obj(cx, objArg);
|
||||
JS_ASSERT(!cx->runtime()->isAtomsCompartment(cx->compartment()));
|
||||
AssertHeapIsIdle(cx);
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, fun, JSValueArray(argv, argc));
|
||||
assertSameCompartment(cx, obj, fun, args);
|
||||
AutoLastFrameCheck lfc(cx);
|
||||
|
||||
RootedValue rv(cx);
|
||||
if (!Invoke(cx, ObjectOrNullValue(obj), ObjectValue(*fun), argc, argv, &rv))
|
||||
if (!Invoke(cx, ObjectOrNullValue(obj), ObjectValue(*fun), args.length(), args.begin(), &rv))
|
||||
return false;
|
||||
*rval = rv;
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_CallFunctionName(JSContext *cx, JSObject *objArg, const char *name, unsigned argc, jsval *argv,
|
||||
jsval *rval)
|
||||
JS_CallFunctionName(JSContext *cx, JSObject *objArg, const char *name,
|
||||
const JS::HandleValueArray& args, jsval *rval)
|
||||
{
|
||||
RootedObject obj(cx, objArg);
|
||||
JS_ASSERT(!cx->runtime()->isAtomsCompartment(cx->compartment()));
|
||||
AssertHeapIsIdle(cx);
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, JSValueArray(argv, argc));
|
||||
assertSameCompartment(cx, obj, args);
|
||||
AutoLastFrameCheck lfc(cx);
|
||||
|
||||
JSAtom *atom = Atomize(cx, name, strlen(name));
|
||||
|
@ -4995,40 +4995,40 @@ JS_CallFunctionName(JSContext *cx, JSObject *objArg, const char *name, unsigned
|
|||
return false;
|
||||
|
||||
RootedValue rv(cx);
|
||||
if (!Invoke(cx, ObjectOrNullValue(obj), v, argc, argv, &rv))
|
||||
if (!Invoke(cx, ObjectOrNullValue(obj), v, args.length(), args.begin(), &rv))
|
||||
return false;
|
||||
*rval = rv;
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_CallFunctionValue(JSContext *cx, JSObject *objArg, jsval fval, unsigned argc, jsval *argv,
|
||||
JS_CallFunctionValue(JSContext *cx, JSObject *objArg, jsval fval, const JS::HandleValueArray& args,
|
||||
jsval *rval)
|
||||
{
|
||||
RootedObject obj(cx, objArg);
|
||||
JS_ASSERT(!cx->runtime()->isAtomsCompartment(cx->compartment()));
|
||||
AssertHeapIsIdle(cx);
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, fval, JSValueArray(argv, argc));
|
||||
assertSameCompartment(cx, obj, fval, args);
|
||||
AutoLastFrameCheck lfc(cx);
|
||||
|
||||
RootedValue rv(cx);
|
||||
if (!Invoke(cx, ObjectOrNullValue(obj), fval, argc, argv, &rv))
|
||||
if (!Invoke(cx, ObjectOrNullValue(obj), fval, args.length(), args.begin(), &rv))
|
||||
return false;
|
||||
*rval = rv;
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS::Call(JSContext *cx, jsval thisv, jsval fval, unsigned argc, jsval *argv,
|
||||
JS::Call(JSContext *cx, jsval thisv, jsval fval, const JS::HandleValueArray& args,
|
||||
MutableHandleValue rval)
|
||||
{
|
||||
AssertHeapIsIdle(cx);
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, thisv, fval, JSValueArray(argv, argc));
|
||||
assertSameCompartment(cx, thisv, fval, args);
|
||||
AutoLastFrameCheck lfc(cx);
|
||||
|
||||
return Invoke(cx, thisv, fval, argc, argv, rval);
|
||||
return Invoke(cx, thisv, fval, args.length(), args.begin(), rval);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSObject *)
|
||||
|
|
|
@ -3911,48 +3911,49 @@ Evaluate(JSContext *cx, JS::HandleObject obj, const ReadOnlyCompileOptions &opti
|
|||
} /* namespace JS */
|
||||
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_CallFunction(JSContext *cx, JSObject *obj, JSFunction *fun, unsigned argc,
|
||||
jsval *argv, jsval *rval);
|
||||
JS_CallFunction(JSContext *cx, JSObject *obj, JSFunction *fun, const JS::HandleValueArray& args,
|
||||
jsval *rval);
|
||||
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_CallFunctionName(JSContext *cx, JSObject *obj, const char *name, unsigned argc,
|
||||
jsval *argv, jsval *rval);
|
||||
JS_CallFunctionName(JSContext *cx, JSObject *obj, const char *name, const JS::HandleValueArray& args,
|
||||
jsval *rval);
|
||||
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_CallFunctionValue(JSContext *cx, JSObject *obj, jsval fval, unsigned argc,
|
||||
jsval *argv, jsval *rval);
|
||||
JS_CallFunctionValue(JSContext *cx, JSObject *obj, jsval fval, const JS::HandleValueArray& args,
|
||||
jsval *rval);
|
||||
|
||||
namespace JS {
|
||||
|
||||
static inline bool
|
||||
Call(JSContext *cx, JSObject *thisObj, JSFunction *fun, unsigned argc, jsval *argv,
|
||||
Call(JSContext *cx, JSObject *thisObj, JSFunction *fun, const JS::HandleValueArray &args,
|
||||
MutableHandleValue rval)
|
||||
{
|
||||
return !!JS_CallFunction(cx, thisObj, fun, argc, argv, rval.address());
|
||||
return !!JS_CallFunction(cx, thisObj, fun, args, rval.address());
|
||||
}
|
||||
|
||||
static inline bool
|
||||
Call(JSContext *cx, JSObject *thisObj, const char *name, unsigned argc, jsval *argv,
|
||||
Call(JSContext *cx, JSObject *thisObj, const char *name, const JS::HandleValueArray& args,
|
||||
MutableHandleValue rval)
|
||||
{
|
||||
return !!JS_CallFunctionName(cx, thisObj, name, argc, argv, rval.address());
|
||||
return !!JS_CallFunctionName(cx, thisObj, name, args, rval.address());
|
||||
}
|
||||
|
||||
static inline bool
|
||||
Call(JSContext *cx, JSObject *thisObj, jsval fun, unsigned argc, jsval *argv,
|
||||
Call(JSContext *cx, JSObject *thisObj, jsval fun, const JS::HandleValueArray& args,
|
||||
MutableHandleValue rval)
|
||||
{
|
||||
return !!JS_CallFunctionValue(cx, thisObj, fun, argc, argv, rval.address());
|
||||
return !!JS_CallFunctionValue(cx, thisObj, fun, args, rval.address());
|
||||
}
|
||||
|
||||
extern JS_PUBLIC_API(bool)
|
||||
Call(JSContext *cx, jsval thisv, jsval fun, unsigned argc, jsval *argv, MutableHandleValue rval);
|
||||
Call(JSContext *cx, jsval thisv, jsval fun, const JS::HandleValueArray& args,
|
||||
MutableHandleValue rval);
|
||||
|
||||
static inline bool
|
||||
Call(JSContext *cx, jsval thisv, JSObject *funObj, unsigned argc, jsval *argv,
|
||||
Call(JSContext *cx, jsval thisv, JSObject *funObj, const JS::HandleValueArray& args,
|
||||
MutableHandleValue rval)
|
||||
{
|
||||
return Call(cx, thisv, OBJECT_TO_JSVAL(funObj), argc, argv, rval);
|
||||
return Call(cx, thisv, OBJECT_TO_JSVAL(funObj), args, rval);
|
||||
}
|
||||
|
||||
} /* namespace JS */
|
||||
|
|
|
@ -72,6 +72,11 @@ class CompartmentChecker
|
|||
check(obj->compartment());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void check(const Rooted<T>& rooted) {
|
||||
check(rooted.get());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void check(Handle<T> handle) {
|
||||
check(handle.get());
|
||||
|
@ -99,6 +104,11 @@ class CompartmentChecker
|
|||
check(arr.array[i]);
|
||||
}
|
||||
|
||||
void check(const JS::HandleValueArray &arr) {
|
||||
for (size_t i = 0; i < arr.length(); i++)
|
||||
check(arr[i]);
|
||||
}
|
||||
|
||||
void check(const CallArgs &args) {
|
||||
for (Value *p = args.base(); p != args.end(); ++p)
|
||||
check(*p);
|
||||
|
|
|
@ -1257,10 +1257,10 @@ GetOuterObject(JSContext *cx, js::HandleObject obj)
|
|||
|
||||
class JSValueArray {
|
||||
public:
|
||||
jsval *array;
|
||||
const jsval *array;
|
||||
size_t length;
|
||||
|
||||
JSValueArray(jsval *v, size_t c) : array(v), length(c) {}
|
||||
JSValueArray(const jsval *v, size_t c) : array(v), length(c) {}
|
||||
};
|
||||
|
||||
class ValueArray {
|
||||
|
|
|
@ -323,7 +323,7 @@ ShellOperationCallback(JSContext *cx)
|
|||
if (!gTimeoutFunc.isNull()) {
|
||||
JSAutoCompartment ac(cx, &gTimeoutFunc.toObject());
|
||||
RootedValue returnedValue(cx);
|
||||
if (!JS_CallFunctionValue(cx, nullptr, gTimeoutFunc, 0, nullptr, returnedValue.address()))
|
||||
if (!JS_CallFunctionValue(cx, nullptr, gTimeoutFunc, JS::EmptyValueArray, returnedValue.address()))
|
||||
return false;
|
||||
if (returnedValue.isBoolean())
|
||||
result = returnedValue.toBoolean();
|
||||
|
@ -3944,8 +3944,7 @@ class ShellSourceHook: public SourceHook {
|
|||
RootedValue filenameValue(cx, StringValue(str));
|
||||
|
||||
RootedValue result(cx);
|
||||
if (!Call(cx, UndefinedValue(), &fun->as<JSFunction>(),
|
||||
1, filenameValue.address(), &result))
|
||||
if (!Call(cx, UndefinedValue(), &fun->as<JSFunction>(), filenameValue, &result))
|
||||
return false;
|
||||
|
||||
str = JS::ToString(cx, result);
|
||||
|
@ -3991,7 +3990,7 @@ WithSourceHook(JSContext *cx, unsigned argc, jsval *vp)
|
|||
|
||||
SourceHook *savedHook = js::ForgetSourceHook(cx->runtime());
|
||||
js::SetSourceHook(cx->runtime(), hook);
|
||||
bool result = Call(cx, UndefinedValue(), &args[1].toObject(), 0, nullptr, args.rval());
|
||||
bool result = Call(cx, UndefinedValue(), &args[1].toObject(), JS::EmptyValueArray, args.rval());
|
||||
js::SetSourceHook(cx->runtime(), savedHook);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -499,7 +499,7 @@ js::Invoke(JSContext *cx, CallArgs args, MaybeConstruct construct)
|
|||
}
|
||||
|
||||
bool
|
||||
js::Invoke(JSContext *cx, const Value &thisv, const Value &fval, unsigned argc, Value *argv,
|
||||
js::Invoke(JSContext *cx, const Value &thisv, const Value &fval, unsigned argc, const Value *argv,
|
||||
MutableHandleValue rval)
|
||||
{
|
||||
InvokeArgs args(cx);
|
||||
|
|
|
@ -129,7 +129,7 @@ Invoke(JSContext *cx, CallArgs args, MaybeConstruct construct = NO_CONSTRUCT);
|
|||
* arguments onto the stack.
|
||||
*/
|
||||
extern bool
|
||||
Invoke(JSContext *cx, const Value &thisv, const Value &fval, unsigned argc, Value *argv,
|
||||
Invoke(JSContext *cx, const Value &thisv, const Value &fval, unsigned argc, const Value *argv,
|
||||
MutableHandleValue rval);
|
||||
|
||||
/*
|
||||
|
|
|
@ -999,7 +999,7 @@ mozJSComponentLoader::ObjectForLocation(nsIFile *aComponentFile,
|
|||
ok = JS_ExecuteScriptVersion(cx, obj, script, nullptr, JSVERSION_LATEST);
|
||||
} else {
|
||||
RootedValue rval(cx);
|
||||
ok = JS_CallFunction(cx, obj, function, 0, nullptr, rval.address());
|
||||
ok = JS_CallFunction(cx, obj, function, JS::EmptyValueArray, rval.address());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -349,7 +349,7 @@ mozJSSubScriptLoader::DoLoadSubScriptWithOptions(const nsAString &url,
|
|||
|
||||
bool ok = false;
|
||||
if (function) {
|
||||
ok = JS_CallFunction(cx, targetObj, function, 0, nullptr, retval.address());
|
||||
ok = JS_CallFunction(cx, targetObj, function, JS::EmptyValueArray, retval.address());
|
||||
} else {
|
||||
ok = JS_ExecuteScriptVersion(cx, targetObj, script, retval.address(), version);
|
||||
}
|
||||
|
|
|
@ -766,8 +766,7 @@ xpc::SandboxCallableProxyHandler::call(JSContext *cx, JS::Handle<JSObject*> prox
|
|||
thisVal = ObjectValue(*js::GetProxyTargetObject(sandboxProxy));
|
||||
}
|
||||
|
||||
return JS::Call(cx, thisVal, js::GetProxyPrivate(proxy), args.length(), args.array(),
|
||||
args.rval());
|
||||
return JS::Call(cx, thisVal, js::GetProxyPrivate(proxy), args, args.rval());
|
||||
}
|
||||
|
||||
xpc::SandboxCallableProxyHandler xpc::sandboxCallableProxyHandler;
|
||||
|
@ -1748,7 +1747,7 @@ NonCloningFunctionForwarder(JSContext *cx, unsigned argc, Value *vp)
|
|||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
return JS_CallFunctionValue(cx, obj, v, args.length(), args.array(), vp);
|
||||
return JS_CallFunctionValue(cx, obj, v, args, vp);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1778,8 +1777,7 @@ CloningFunctionForwarder(JSContext *cx, unsigned argc, Value *vp)
|
|||
RootedValue functionVal(cx);
|
||||
functionVal.setObject(*origFunObj);
|
||||
|
||||
if (!JS_CallFunctionValue(cx, nullptr, functionVal, args.length(), args.array(),
|
||||
args.rval().address()))
|
||||
if (!JS_CallFunctionValue(cx, nullptr, functionVal, args, args.rval().address()))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -2155,13 +2155,9 @@ nsXPCConstructor::CallOrConstruct(nsIXPConnectWrappedNative *wrapper,JSContext *
|
|||
return ThrowAndFail(NS_ERROR_XPC_CANT_CREATE_WN, cx, _retval);
|
||||
}
|
||||
|
||||
JS::AutoValueVector argv(cx);
|
||||
MOZ_ALWAYS_TRUE(argv.resize(1));
|
||||
argv[0].setObject(*iidObj);
|
||||
|
||||
JS::Rooted<JS::Value> arg(cx, ObjectValue(*iidObj));
|
||||
RootedValue rval(cx);
|
||||
if (!JS_CallFunctionName(cx, cidObj, "createInstance", 1, argv.begin(),
|
||||
rval.address()) ||
|
||||
if (!JS_CallFunctionName(cx, cidObj, "createInstance", arg, rval.address()) ||
|
||||
rval.isPrimitive()) {
|
||||
// createInstance will have thrown an exception
|
||||
*_retval = false;
|
||||
|
@ -2181,7 +2177,7 @@ nsXPCConstructor::CallOrConstruct(nsIXPConnectWrappedNative *wrapper,JSContext *
|
|||
}
|
||||
|
||||
RootedValue dummy(cx);
|
||||
if (!JS_CallFunctionValue(cx, newObj, fun, args.length(), args.array(), dummy.address())) {
|
||||
if (!JS_CallFunctionValue(cx, newObj, fun, args, dummy.address())) {
|
||||
// function should have thrown an exception
|
||||
*_retval = false;
|
||||
return NS_OK;
|
||||
|
@ -3386,7 +3382,7 @@ nsXPCComponents_Utils::GetIncumbentGlobal(HandleValue aCallback,
|
|||
// Invoke the callback, if passed.
|
||||
if (aCallback.isObject()) {
|
||||
RootedValue ignored(aCx);
|
||||
if (!JS_CallFunctionValue(aCx, nullptr, aCallback, 1, globalVal.address(), ignored.address()))
|
||||
if (!JS_CallFunctionValue(aCx, nullptr, aCallback, globalVal, ignored.address()))
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -652,7 +652,7 @@ XPCShellOperationCallback(JSContext *cx)
|
|||
JSAutoCompartment ac(cx, &sScriptedOperationCallback.toObject());
|
||||
RootedValue rv(cx);
|
||||
if (!JS_CallFunctionValue(cx, nullptr, sScriptedOperationCallback,
|
||||
0, nullptr, rv.address()) || !rv.isBoolean())
|
||||
JS::EmptyValueArray, rv.address()) || !rv.isBoolean())
|
||||
{
|
||||
NS_WARNING("Scripted operation callback failed! Terminating script.");
|
||||
JS_ClearPendingException(cx);
|
||||
|
|
|
@ -233,11 +233,8 @@ nsXPCWrappedJSClass::CallQueryInterfaceOnJSObject(JSContext* cx,
|
|||
{
|
||||
AutoSaveContextOptions asco(cx);
|
||||
ContextOptionsRef(cx).setDontReportUncaught(true);
|
||||
JS::AutoValueVector argv(cx);
|
||||
MOZ_ALWAYS_TRUE(argv.resize(1));
|
||||
argv[0].setObject(*id);
|
||||
success = JS_CallFunctionValue(cx, jsobj, fun, 1, argv.begin(),
|
||||
retval.address());
|
||||
RootedValue arg(cx, JS::ObjectValue(*id));
|
||||
success = JS_CallFunctionValue(cx, jsobj, fun, arg, retval.address());
|
||||
}
|
||||
|
||||
if (!success && JS_IsExceptionPending(cx)) {
|
||||
|
@ -1287,7 +1284,7 @@ pre_call_clean_up:
|
|||
AutoSaveContextOptions asco(cx);
|
||||
ContextOptionsRef(cx).setDontReportUncaught(true);
|
||||
|
||||
success = JS_CallFunctionValue(cx, thisObj, fval, argc, argv, rval.address());
|
||||
success = JS_CallFunctionValue(cx, thisObj, fval, args, rval.address());
|
||||
} else {
|
||||
// The property was not an object so can't be a function.
|
||||
// Let's build and 'throw' an exception.
|
||||
|
|
|
@ -685,14 +685,13 @@ ProxyAutoConfig::GetProxyForURI(const nsCString &aTestURI,
|
|||
JS::RootedString hostString(cx, JS_NewStringCopyZ(cx, aTestHost.get()));
|
||||
|
||||
if (uriString && hostString) {
|
||||
JS::AutoValueVector argv(cx);
|
||||
MOZ_ALWAYS_TRUE(argv.resize(2));
|
||||
argv[0].setString(uriString);
|
||||
argv[1].setString(hostString);
|
||||
JS::AutoValueArray<2> args(cx);
|
||||
args[0].setString(uriString);
|
||||
args[1].setString(hostString);
|
||||
|
||||
JS::Rooted<JS::Value> rval(cx);
|
||||
bool ok = JS_CallFunctionName(cx, mJSRuntime->Global(),
|
||||
"FindProxyForURL", 2, argv.begin(), rval.address());
|
||||
"FindProxyForURL", args, rval.address());
|
||||
|
||||
if (ok && rval.isString()) {
|
||||
nsDependentJSString pacString;
|
||||
|
|
|
@ -169,8 +169,7 @@ nsHTTPIndex::OnFTPControlLog(bool server, const char *msg)
|
|||
JSString* jsMsgStr = JS_NewUCStringCopyZ(cx, unicodeMsg.get());
|
||||
NS_ENSURE_TRUE(jsMsgStr, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
JS::AutoValueVector params(cx);
|
||||
MOZ_ALWAYS_TRUE(params.resize(2));
|
||||
JS::AutoValueArray<2> params(cx);
|
||||
params[0].setBoolean(server);
|
||||
params[1].setString(jsMsgStr);
|
||||
|
||||
|
@ -178,8 +177,7 @@ nsHTTPIndex::OnFTPControlLog(bool server, const char *msg)
|
|||
JS_CallFunctionName(cx,
|
||||
global,
|
||||
"OnFTPControlLog",
|
||||
2,
|
||||
params.begin(),
|
||||
params,
|
||||
val.address());
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче