Bug 1017419 - Handlify nsTArrayToJSArray, r=terrence

--HG--
extra : rebase_source : 802407d2c25fe060e16b546890859720664158ae
This commit is contained in:
Steve Fink 2014-06-02 09:40:13 -07:00
parent 11eb48ed49
commit b3dbf53538
8 changed files with 19 additions and 18 deletions

View File

@ -3198,7 +3198,7 @@ nsDOMWindowUtils::GetPlugins(JSContext* cx, JS::MutableHandle<JS::Value> aPlugin
doc->GetPlugins(plugins);
JS::Rooted<JSObject*> jsPlugins(cx);
nsresult rv = nsTArrayToJSArray(cx, plugins, jsPlugins.address());
nsresult rv = nsTArrayToJSArray(cx, plugins, &jsPlugins);
NS_ENSURE_SUCCESS(rv, rv);
aPlugins.setObject(*jsPlugins);

View File

@ -104,7 +104,7 @@ public:
}
AutoPushJSContext cx(sc->GetNativeContext());
JSObject* JsDevices = nullptr;
JS::Rooted<JSObject*> JsDevices(cx);
rv = nsTArrayToJSArray(cx, devices, &JsDevices);
if (!JsDevices) {
BT_WARNING("Cannot create JS array!");
@ -260,7 +260,7 @@ BluetoothAdapter::SetPropertyByValue(const BluetoothNamedValue& aValue)
AutoPushJSContext cx(sc->GetNativeContext());
JS::Rooted<JSObject*> uuids(cx);
if (NS_FAILED(nsTArrayToJSArray(cx, mUuids, uuids.address()))) {
if (NS_FAILED(nsTArrayToJSArray(cx, mUuids, &uuids))) {
BT_WARNING("Cannot set JS UUIDs object!");
return;
}
@ -276,8 +276,7 @@ BluetoothAdapter::SetPropertyByValue(const BluetoothNamedValue& aValue)
AutoPushJSContext cx(sc->GetNativeContext());
JS::Rooted<JSObject*> deviceAddresses(cx);
if (NS_FAILED(nsTArrayToJSArray(cx, mDeviceAddresses,
deviceAddresses.address()))) {
if (NS_FAILED(nsTArrayToJSArray(cx, mDeviceAddresses, &deviceAddresses))) {
BT_WARNING("Cannot set JS Devices object!");
return;
}

View File

@ -137,7 +137,7 @@ BluetoothDevice::SetPropertyByValue(const BluetoothNamedValue& aValue)
AutoPushJSContext cx(sc->GetNativeContext());
JS::Rooted<JSObject*> uuids(cx);
if (NS_FAILED(nsTArrayToJSArray(cx, mUuids, uuids.address()))) {
if (NS_FAILED(nsTArrayToJSArray(cx, mUuids, &uuids))) {
BT_WARNING("Cannot set JS UUIDs object!");
return;
}
@ -153,7 +153,7 @@ BluetoothDevice::SetPropertyByValue(const BluetoothNamedValue& aValue)
AutoPushJSContext cx(sc->GetNativeContext());
JS::Rooted<JSObject*> services(cx);
if (NS_FAILED(nsTArrayToJSArray(cx, mServices, services.address()))) {
if (NS_FAILED(nsTArrayToJSArray(cx, mServices, &services))) {
BT_WARNING("Cannot set JS Services object!");
return;
}

View File

@ -485,11 +485,11 @@ MmsMessage::GetSender(nsAString& aSender)
NS_IMETHODIMP
MmsMessage::GetReceivers(JSContext* aCx, JS::MutableHandle<JS::Value> aReceivers)
{
JS::Rooted<JSObject*> reveiversObj(aCx);
nsresult rv = nsTArrayToJSArray(aCx, mReceivers, reveiversObj.address());
JS::Rooted<JSObject*> receiversObj(aCx);
nsresult rv = nsTArrayToJSArray(aCx, mReceivers, &receiversObj);
NS_ENSURE_SUCCESS(rv, rv);
aReceivers.setObject(*reveiversObj);
aReceivers.setObject(*receiversObj);
return NS_OK;
}

View File

@ -150,7 +150,7 @@ MobileMessageThread::GetParticipants(JSContext* aCx,
{
JS::Rooted<JSObject*> obj(aCx);
nsresult rv = nsTArrayToJSArray(aCx, mData.participants(), obj.address());
nsresult rv = nsTArrayToJSArray(aCx, mData.participants(), &obj);
NS_ENSURE_SUCCESS(rv, rv);
aParticipants.setObject(*obj);

View File

@ -97,9 +97,8 @@ GetParamsFromSendMmsMessageRequest(JSContext* aCx,
// receivers
JS::Rooted<JSObject*> receiverArray(aCx);
if (NS_FAILED(nsTArrayToJSArray(aCx,
aRequest.receivers(),
receiverArray.address()))) {
if (NS_FAILED(nsTArrayToJSArray(aCx, aRequest.receivers(), &receiverArray)))
{
return false;
}
if (!JS_DefineProperty(aCx, paramsObj, "receivers", receiverArray, 0)) {

View File

@ -0,0 +1,3 @@
{
"expect-hazards": 2
}

View File

@ -14,7 +14,7 @@
template <class T>
inline nsresult
nsTArrayToJSArray(JSContext* aCx, const nsTArray<T>& aSourceArray,
JSObject** aResultArray)
JS::MutableHandle<JSObject*> aResultArray)
{
MOZ_ASSERT(aCx);
@ -45,7 +45,7 @@ nsTArrayToJSArray(JSContext* aCx, const nsTArray<T>& aSourceArray,
return NS_ERROR_FAILURE;
}
*aResultArray = arrayObj;
aResultArray.set(arrayObj);
return NS_OK;
}
@ -53,7 +53,7 @@ template <>
inline nsresult
nsTArrayToJSArray<nsString>(JSContext* aCx,
const nsTArray<nsString>& aSourceArray,
JSObject** aResultArray)
JS::MutableHandle<JSObject*> aResultArray)
{
MOZ_ASSERT(aCx);
@ -85,7 +85,7 @@ nsTArrayToJSArray<nsString>(JSContext* aCx,
return NS_ERROR_FAILURE;
}
*aResultArray = arrayObj;
aResultArray.set(arrayObj);
return NS_OK;
}