зеркало из https://github.com/mozilla/gecko-dev.git
Bug 896540 - GC: Convert JS_SetProperty* to take MutableHandleValue - browser changes r=bz
This commit is contained in:
Родитель
4ad2b06d34
Коммит
e6cd070d3d
|
@ -282,7 +282,7 @@ FieldSetterImpl(JSContext *cx, JS::CallArgs args)
|
|||
if (installed) {
|
||||
JS::Rooted<JS::Value> v(cx,
|
||||
args.length() > 0 ? args[0] : JS::UndefinedValue());
|
||||
if (!::JS_SetPropertyById(cx, thisObj, id, v.address())) {
|
||||
if (!::JS_SetPropertyById(cx, thisObj, id, &v)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1404,7 +1404,7 @@ nsXULTemplateBuilder::InitHTMLTemplateRoot()
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
bool ok;
|
||||
ok = JS_SetProperty(jscontext, jselement, "database", jsdatabase.address());
|
||||
ok = JS_SetProperty(jscontext, jselement, "database", &jsdatabase);
|
||||
NS_ASSERTION(ok, "unable to set database property");
|
||||
if (! ok)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -1421,7 +1421,7 @@ nsXULTemplateBuilder::InitHTMLTemplateRoot()
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
bool ok;
|
||||
ok = JS_SetProperty(jscontext, jselement, "builder", jsbuilder.address());
|
||||
ok = JS_SetProperty(jscontext, jselement, "builder", &jsbuilder);
|
||||
if (! ok)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
|
|
@ -5539,7 +5539,7 @@ if (!v.isObject()) {
|
|||
return ThrowErrorMessage(cx, MSG_NOT_OBJECT, "%s.%s");
|
||||
}
|
||||
|
||||
return JS_SetProperty(cx, &v.toObject(), "%s", args.handleAt(0).address());""" % (attrName, self.descriptor.interface.identifier.name, attrName, forwardToAttrName))).define()
|
||||
return JS_SetProperty(cx, &v.toObject(), "%s", args.handleAt(0));""" % (attrName, self.descriptor.interface.identifier.name, attrName, forwardToAttrName))).define()
|
||||
|
||||
def memberIsCreator(member):
|
||||
return member.getExtendedAttribute("Creator") is not None
|
||||
|
@ -9987,7 +9987,7 @@ class CallbackSetter(CallbackMember):
|
|||
replacements = {
|
||||
"errorReturn" : self.getDefaultRetval(),
|
||||
"attrName": self.attrName,
|
||||
"argv": "argv.begin()",
|
||||
"argv": "argv.handleAt(0)",
|
||||
}
|
||||
return string.Template(
|
||||
'MOZ_ASSERT(argv.length() == 1);\n'
|
||||
|
|
|
@ -23,7 +23,7 @@ BEGIN_BLUETOOTH_NAMESPACE
|
|||
bool
|
||||
SetJsObject(JSContext* aContext,
|
||||
const BluetoothValue& aValue,
|
||||
JSObject* aObj)
|
||||
JS::Handle<JSObject*> aObj)
|
||||
{
|
||||
MOZ_ASSERT(aContext && aObj);
|
||||
|
||||
|
@ -36,18 +36,18 @@ SetJsObject(JSContext* aContext,
|
|||
aValue.get_ArrayOfBluetoothNamedValue();
|
||||
|
||||
for (uint32_t i = 0; i < arr.Length(); i++) {
|
||||
JS::Value val;
|
||||
JS::Rooted<JS::Value> val(aContext);
|
||||
const BluetoothValue& v = arr[i].value();
|
||||
JSString* jsData;
|
||||
|
||||
switch(v.type()) {
|
||||
case BluetoothValue::TnsString:
|
||||
jsData = JS_NewUCStringCopyN(aContext,
|
||||
case BluetoothValue::TnsString: {
|
||||
JSString* jsData = JS_NewUCStringCopyN(aContext,
|
||||
v.get_nsString().BeginReading(),
|
||||
v.get_nsString().Length());
|
||||
NS_ENSURE_TRUE(jsData, false);
|
||||
val = STRING_TO_JSVAL(jsData);
|
||||
break;
|
||||
}
|
||||
case BluetoothValue::Tuint32_t:
|
||||
val = INT_TO_JSVAL(v.get_uint32_t());
|
||||
break;
|
||||
|
@ -109,7 +109,7 @@ BroadcastSystemMessage(const nsAString& aType,
|
|||
NS_ASSERTION(!::JS_IsExceptionPending(cx),
|
||||
"Shouldn't get here when an exception is pending!");
|
||||
|
||||
JSObject* obj = JS_NewObject(cx, NULL, NULL, NULL);
|
||||
JS::RootedObject obj(cx, JS_NewObject(cx, NULL, NULL, NULL));
|
||||
if (!obj) {
|
||||
NS_WARNING("Failed to new JSObject for system message!");
|
||||
return false;
|
||||
|
|
|
@ -21,7 +21,7 @@ class BluetoothReplyRunnable;
|
|||
bool
|
||||
SetJsObject(JSContext* aContext,
|
||||
const BluetoothValue& aValue,
|
||||
JSObject* aObj);
|
||||
JS::Handle<JSObject*> aObj);
|
||||
|
||||
nsString
|
||||
GetObjectPathFromAddress(const nsAString& aAdapterPath,
|
||||
|
|
|
@ -161,27 +161,27 @@ CameraControlImpl::Get(JSContext* aCx, uint32_t aKey, JS::Value* aValue)
|
|||
|
||||
DOM_CAMERA_LOGI("top=%d\n", r->top);
|
||||
v = INT_TO_JSVAL(r->top);
|
||||
if (!JS_SetProperty(aCx, o, "top", v.address())) {
|
||||
if (!JS_SetProperty(aCx, o, "top", &v)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
DOM_CAMERA_LOGI("left=%d\n", r->left);
|
||||
v = INT_TO_JSVAL(r->left);
|
||||
if (!JS_SetProperty(aCx, o, "left", v.address())) {
|
||||
if (!JS_SetProperty(aCx, o, "left", &v)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
DOM_CAMERA_LOGI("bottom=%d\n", r->bottom);
|
||||
v = INT_TO_JSVAL(r->bottom);
|
||||
if (!JS_SetProperty(aCx, o, "bottom", v.address())) {
|
||||
if (!JS_SetProperty(aCx, o, "bottom", &v)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
DOM_CAMERA_LOGI("right=%d\n", r->right);
|
||||
v = INT_TO_JSVAL(r->right);
|
||||
if (!JS_SetProperty(aCx, o, "right", v.address())) {
|
||||
if (!JS_SetProperty(aCx, o, "right", &v)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
DOM_CAMERA_LOGI("weight=%d\n", r->weight);
|
||||
v = INT_TO_JSVAL(r->weight);
|
||||
if (!JS_SetProperty(aCx, o, "weight", v.address())) {
|
||||
if (!JS_SetProperty(aCx, o, "weight", &v)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,31 +36,31 @@ RecorderVideoProfile::GetJsObject(JSContext* aCx, JSObject** aObject)
|
|||
|
||||
JS::Rooted<JSString*> s(aCx, JS_NewStringCopyZ(aCx, codec));
|
||||
JS::Rooted<JS::Value> v(aCx, STRING_TO_JSVAL(s));
|
||||
if (!JS_SetProperty(aCx, o, "codec", v.address())) {
|
||||
if (!JS_SetProperty(aCx, o, "codec", &v)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (mBitrate != -1) {
|
||||
v = INT_TO_JSVAL(mBitrate);
|
||||
if (!JS_SetProperty(aCx, o, "bitrate", v.address())) {
|
||||
if (!JS_SetProperty(aCx, o, "bitrate", &v)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
if (mFramerate != -1) {
|
||||
v = INT_TO_JSVAL(mFramerate);
|
||||
if (!JS_SetProperty(aCx, o, "framerate", v.address())) {
|
||||
if (!JS_SetProperty(aCx, o, "framerate", &v)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
if (mWidth != -1) {
|
||||
v = INT_TO_JSVAL(mWidth);
|
||||
if (!JS_SetProperty(aCx, o, "width", v.address())) {
|
||||
if (!JS_SetProperty(aCx, o, "width", &v)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
if (mHeight != -1) {
|
||||
v = INT_TO_JSVAL(mHeight);
|
||||
if (!JS_SetProperty(aCx, o, "height", v.address())) {
|
||||
if (!JS_SetProperty(aCx, o, "height", &v)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
@ -97,25 +97,25 @@ RecorderAudioProfile::GetJsObject(JSContext* aCx, JSObject** aObject)
|
|||
|
||||
JS::Rooted<JSString*> s(aCx, JS_NewStringCopyZ(aCx, codec));
|
||||
JS::Rooted<JS::Value> v(aCx, STRING_TO_JSVAL(s));
|
||||
if (!JS_SetProperty(aCx, o, "codec", v.address())) {
|
||||
if (!JS_SetProperty(aCx, o, "codec", &v)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (mBitrate != -1) {
|
||||
v = INT_TO_JSVAL(mBitrate);
|
||||
if (!JS_SetProperty(aCx, o, "bitrate", v.address())) {
|
||||
if (!JS_SetProperty(aCx, o, "bitrate", &v)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
if (mSamplerate != -1) {
|
||||
v = INT_TO_JSVAL(mSamplerate);
|
||||
if (!JS_SetProperty(aCx, o, "samplerate", v.address())) {
|
||||
if (!JS_SetProperty(aCx, o, "samplerate", &v)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
if (mChannels != -1) {
|
||||
v = INT_TO_JSVAL(mChannels);
|
||||
if (!JS_SetProperty(aCx, o, "channels", v.address())) {
|
||||
if (!JS_SetProperty(aCx, o, "channels", &v)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ RecorderProfileManager::GetJsObject(JSContext* aCx, JSObject** aObject) const
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
JS::Rooted<JS::Value> v(aCx, OBJECT_TO_JSVAL(p));
|
||||
|
||||
if (!JS_SetProperty(aCx, o, profileName, v.address())) {
|
||||
if (!JS_SetProperty(aCx, o, profileName, &v)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -173,27 +173,27 @@ public:
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
JSObject* o = JS_NewObject(aCx, nullptr, nullptr, nullptr);
|
||||
JS::Rooted<JSObject*> o(aCx, JS_NewObject(aCx, nullptr, nullptr, nullptr));
|
||||
if (!o) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
JSString* s = JS_NewStringCopyZ(aCx, format);
|
||||
JS::Value v = STRING_TO_JSVAL(s);
|
||||
JS::Rooted<JSString*> s(aCx, JS_NewStringCopyZ(aCx, format));
|
||||
JS::Rooted<JS::Value> v(aCx, STRING_TO_JSVAL(s));
|
||||
if (!JS_SetProperty(aCx, o, "format", &v)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
JSObject* video;
|
||||
nsresult rv = mVideo.GetJsObject(aCx, &video);
|
||||
JS::Rooted<JSObject*> video(aCx);
|
||||
nsresult rv = mVideo.GetJsObject(aCx, video.address());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
v = OBJECT_TO_JSVAL(video);
|
||||
if (!JS_SetProperty(aCx, o, "video", &v)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
JSObject* audio;
|
||||
rv = mAudio.GetJsObject(aCx, &audio);
|
||||
JS::Rooted<JSObject*> audio(aCx);
|
||||
rv = mAudio.GetJsObject(aCx, audio.address());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
v = OBJECT_TO_JSVAL(audio);
|
||||
if (!JS_SetProperty(aCx, o, "audio", &v)) {
|
||||
|
|
|
@ -95,10 +95,10 @@ ParseDimensionItemAndAdd(JSContext* aCx, JS::Handle<JSObject*> aArray,
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
if (!JS_SetProperty(aCx, o, "width", w.address())) {
|
||||
if (!JS_SetProperty(aCx, o, "width", &w)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (!JS_SetProperty(aCx, o, "height", h.address())) {
|
||||
if (!JS_SetProperty(aCx, o, "height", &h)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -371,11 +371,11 @@ DOMCameraCapabilities::GetVideoSizes(JSContext* cx, JS::Value* aVideoSizes)
|
|||
for (uint32_t i = 0; i < sizes.Length(); ++i) {
|
||||
JS::Rooted<JSObject*> o(cx, JS_NewObject(cx, nullptr, nullptr, nullptr));
|
||||
JS::Rooted<JS::Value> v(cx, INT_TO_JSVAL(sizes[i].width));
|
||||
if (!JS_SetProperty(cx, o, "width", v.address())) {
|
||||
if (!JS_SetProperty(cx, o, "width", &v)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
v = INT_TO_JSVAL(sizes[i].height);
|
||||
if (!JS_SetProperty(cx, o, "height", v.address())) {
|
||||
if (!JS_SetProperty(cx, o, "height", &v)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -788,7 +788,7 @@ nsJSObjWrapper::NP_SetProperty(NPObject *npobj, NPIdentifier id,
|
|||
NS_ASSERTION(NPIdentifierIsInt(id) || NPIdentifierIsString(id),
|
||||
"id must be either string or int!\n");
|
||||
ok = ::JS_SetPropertyById(cx, npjsobj->mJSObj, NPIdentifierToJSId(id),
|
||||
v.address());
|
||||
&v);
|
||||
|
||||
// return ok == JS_TRUE to quiet down compiler warning, even if
|
||||
// return ok is what we really want.
|
||||
|
|
|
@ -634,7 +634,7 @@ bool SetStringProperty(JSContext *cx, JS::Handle<JSObject*> aObject, const char
|
|||
JSString* strValue = JS_NewUCStringCopyZ(cx, aValue.get());
|
||||
NS_ENSURE_TRUE(strValue, false);
|
||||
JS::Rooted<JS::Value> valValue(cx, STRING_TO_JSVAL(strValue));
|
||||
return JS_SetProperty(cx, aObject, aProperty, valValue.address());
|
||||
return JS_SetProperty(cx, aObject, aProperty, &valValue);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -707,14 +707,14 @@ bool DefineOSFileConstants(JSContext *cx, JS::Handle<JSObject*> global)
|
|||
}
|
||||
|
||||
JS::Rooted<JS::Value> valVersion(cx, STRING_TO_JSVAL(strVersion));
|
||||
if (!JS_SetProperty(cx, objSys, "Name", valVersion.address())) {
|
||||
if (!JS_SetProperty(cx, objSys, "Name", &valVersion)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(DEBUG)
|
||||
JS::Rooted<JS::Value> valDebug(cx, JSVAL_TRUE);
|
||||
if (!JS_SetProperty(cx, objSys, "DEBUG", valDebug.address())) {
|
||||
if (!JS_SetProperty(cx, objSys, "DEBUG", &valDebug)) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -414,7 +414,7 @@ JavaScriptChild::AnswerSet(const ObjectId &objId, const ObjectId &receiverId, co
|
|||
if (!toValue(cx, value, &val))
|
||||
return fail(cx, rs);
|
||||
|
||||
if (!JS_SetPropertyById(cx, obj, internedId, val.address()))
|
||||
if (!JS_SetPropertyById(cx, obj, internedId, &val))
|
||||
return fail(cx, rs);
|
||||
|
||||
if (!toVariant(cx, val, result))
|
||||
|
|
|
@ -436,7 +436,7 @@ JavaScriptParent::call(JSContext *cx, HandleObject proxy, const CallArgs &args)
|
|||
return false;
|
||||
|
||||
JSObject *obj = &outobjects[i].toObject();
|
||||
if (!JS_SetProperty(cx, obj, "value", v.address()))
|
||||
if (!JS_SetProperty(cx, obj, "value", &v))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1328,7 +1328,7 @@ mozJSComponentLoader::ImportInto(const nsACString &aLocation,
|
|||
JSAutoCompartment target_ac(mContext, targetObj);
|
||||
|
||||
if (!JS_WrapValue(mContext, value.address()) ||
|
||||
!JS_SetPropertyById(mContext, targetObj, symbolId, value.address())) {
|
||||
!JS_SetPropertyById(mContext, targetObj, symbolId, &value)) {
|
||||
JSAutoByteString bytes(mContext, JSID_TO_STRING(symbolId));
|
||||
if (!bytes)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
|
|
@ -2898,7 +2898,7 @@ SandboxImport(JSContext *cx, unsigned argc, Value *vp)
|
|||
XPCThrower::Throw(NS_ERROR_UNEXPECTED, cx);
|
||||
return false;
|
||||
}
|
||||
if (!JS_SetPropertyById(cx, thisObject, id, &args[0]))
|
||||
if (!JS_SetPropertyById(cx, thisObject, id, args.handleAt(0)))
|
||||
return false;
|
||||
|
||||
args.rval().setUndefined();
|
||||
|
@ -4287,7 +4287,7 @@ nsXPCComponents_Utils::MakeObjectPropsNormal(const Value &vobj, JSContext *cx)
|
|||
continue;
|
||||
|
||||
if (!WrapCallable(cx, obj, id, propobj, &v) ||
|
||||
!JS_SetPropertyById(cx, obj, id, v.address()))
|
||||
!JS_SetPropertyById(cx, obj, id, &v))
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -1366,7 +1366,7 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16_t methodIndex,
|
|||
if (param.IsIn()) {
|
||||
if (!JS_SetPropertyById(cx, out_obj,
|
||||
mRuntime->GetStringID(XPCJSRuntime::IDX_VALUE),
|
||||
val.address())) {
|
||||
&val)) {
|
||||
goto pre_call_clean_up;
|
||||
}
|
||||
}
|
||||
|
@ -1433,8 +1433,8 @@ pre_call_clean_up:
|
|||
if (XPT_MD_IS_GETTER(info->flags)) {
|
||||
success = JS_GetProperty(cx, obj, name, rval.address());
|
||||
} else if (XPT_MD_IS_SETTER(info->flags)) {
|
||||
success = JS_SetProperty(cx, obj, name, argv);
|
||||
rval = *argv;
|
||||
success = JS_SetProperty(cx, obj, name, &rval);
|
||||
} else {
|
||||
if (!JSVAL_IS_PRIMITIVE(fval)) {
|
||||
uint32_t oldOpts = JS_GetOptions(cx);
|
||||
|
|
|
@ -2348,7 +2348,7 @@ CallMethodHelper::GatherAndConvertResults()
|
|||
NS_ASSERTION(mArgv[i].isObject(), "out var is not object");
|
||||
if (!JS_SetPropertyById(mCallContext,
|
||||
&mArgv[i].toObject(),
|
||||
mIdxValueId, v.address())) {
|
||||
mIdxValueId, &v)) {
|
||||
ThrowBadParam(NS_ERROR_XPC_CANT_SET_OUT_VAL, i, mCallContext);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -261,7 +261,7 @@ nsHTTPIndex::OnStartRequest(nsIRequest *request, nsISupports* aContext)
|
|||
JS::Rooted<JS::Value> jslistener(cx, OBJECT_TO_JSVAL(jsobj));
|
||||
|
||||
// ...and stuff it into the global context
|
||||
bool ok = JS_SetProperty(cx, global, "HTTPIndex", jslistener.address());
|
||||
bool ok = JS_SetProperty(cx, global, "HTTPIndex", &jslistener);
|
||||
NS_ASSERTION(ok, "unable to set Listener property");
|
||||
if (!ok)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
|
Загрузка…
Ссылка в новой задаче