Bug 1023280 - Rename dictionary.ToObject to ToObjectInternal, r=bz

This commit is contained in:
Olli Pettay 2014-06-11 22:38:55 +03:00
Родитель 4270912f32
Коммит 0040a9cd76
15 изменённых файлов: 49 добавлений и 38 удалений

Просмотреть файл

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "Activity.h"
#include "mozilla/dom/ToJSValue.h"
#include "nsContentUtils.h"
#include "nsDOMClassInfo.h"
#include "nsIConsoleService.h"
@ -67,7 +67,7 @@ Activity::Initialize(nsPIDOMWindow* aWindow,
NS_ENSURE_SUCCESS(rv, rv);
JS::Rooted<JS::Value> optionsValue(aCx);
if (!aOptions.ToObject(aCx, &optionsValue)) {
if (!ToJSValue(aCx, aOptions, &optionsValue)) {
return NS_ERROR_FAILURE;
}

Просмотреть файл

@ -697,7 +697,7 @@ Console::ProfileMethod(JSContext* aCx, const nsAString& aAction,
}
JS::Rooted<JS::Value> eventValue(aCx);
if (!event.ToObject(aCx, &eventValue)) {
if (!ToJSValue(aCx, event, &eventValue)) {
return;
}
@ -1111,7 +1111,7 @@ Console::ProcessCallData(ConsoleCallData* aData)
JSAutoCompartment ac2(cx, xpc::GetJunkScope());
JS::Rooted<JS::Value> eventValue(cx);
if (!event.ToObject(cx, &eventValue)) {
if (!ToJSValue(cx, event, &eventValue)) {
return;
}
@ -1485,7 +1485,7 @@ Console::StartTimer(JSContext* aCx, const JS::Value& aName,
RootedDictionary<ConsoleTimerError> error(aCx);
JS::Rooted<JS::Value> value(aCx);
if (!error.ToObject(aCx, &value)) {
if (!ToJSValue(aCx, error, &value)) {
return JS::UndefinedValue();
}
@ -1517,7 +1517,7 @@ Console::StartTimer(JSContext* aCx, const JS::Value& aName,
timer.mStarted = aTimestamp;
JS::Rooted<JS::Value> value(aCx);
if (!timer.ToObject(aCx, &value)) {
if (!ToJSValue(aCx, timer, &value)) {
return JS::UndefinedValue();
}
@ -1551,7 +1551,7 @@ Console::StopTimer(JSContext* aCx, const JS::Value& aName,
timer.mDuration = aTimestamp - entry;
JS::Rooted<JS::Value> value(aCx);
if (!timer.ToObject(aCx, &value)) {
if (!ToJSValue(aCx, timer, &value)) {
return JS::UndefinedValue();
}
@ -1599,7 +1599,7 @@ Console::IncreaseCounter(JSContext* aCx, const ConsoleStackEntry& aFrame,
RootedDictionary<ConsoleCounterError> error(aCx);
JS::Rooted<JS::Value> value(aCx);
if (!error.ToObject(aCx, &value)) {
if (!ToJSValue(aCx, error, &value)) {
return JS::UndefinedValue();
}
@ -1615,7 +1615,7 @@ Console::IncreaseCounter(JSContext* aCx, const ConsoleStackEntry& aFrame,
data.mCount = count;
JS::Rooted<JS::Value> value(aCx);
if (!data.ToObject(aCx, &value)) {
if (!ToJSValue(aCx, data, &value)) {
return JS::UndefinedValue();
}

Просмотреть файл

@ -59,6 +59,7 @@
#include "nsCCUncollectableMarker.h"
#include "mozilla/dom/workers/Workers.h"
#include "mozilla/dom/MessagePortList.h"
#include "mozilla/dom/ToJSValue.h"
#include "nsJSPrincipals.h"
#include "mozilla/Attributes.h"
#include "mozilla/Debug.h"
@ -5825,7 +5826,7 @@ nsGlobalWindow::DispatchResizeEvent(const nsIntSize& aSize)
detail.mWidth = aSize.width;
detail.mHeight = aSize.height;
JS::Rooted<JS::Value> detailValue(cx);
if (!detail.ToObject(cx, &detailValue)) {
if (!ToJSValue(cx, detail, &detailValue)) {
return false;
}

Просмотреть файл

@ -5443,7 +5443,7 @@ def getWrapTemplateForType(type, descriptorProvider, result, successCode,
False)
if type.isDictionary():
return (wrapAndSetPtr("%s.ToObject(cx, ${jsvalHandle})" % result),
return (wrapAndSetPtr("%s.ToObjectInternal(cx, ${jsvalHandle})" % result),
False)
if type.isDate():
@ -10651,7 +10651,7 @@ class CGDictionary(CGThing):
return Init(cx, json);
"""))
def toObjectMethod(self):
def toObjectInternalMethod(self):
body = ""
if self.needToInitIds:
body += fill(
@ -10668,7 +10668,7 @@ class CGDictionary(CGThing):
body += fill(
"""
// Per spec, we define the parent's members first
if (!${dictName}::ToObject(cx, rval)) {
if (!${dictName}::ToObjectInternal(cx, rval)) {
return false;
}
JS::Rooted<JSObject*> obj(cx, &rval.toObject());
@ -10691,7 +10691,7 @@ class CGDictionary(CGThing):
for m in self.memberInfo)
body += "\nreturn true;\n"
return ClassMethod("ToObject", "bool", [
return ClassMethod("ToObjectInternal", "bool", [
Argument('JSContext*', 'cx'),
Argument('JS::MutableHandle<JS::Value>', 'rval'),
], const=True, body=body)
@ -10777,11 +10777,11 @@ class CGDictionary(CGThing):
methods.append(self.initMethod())
methods.append(self.initFromJSONMethod())
try:
methods.append(self.toObjectMethod())
methods.append(self.toObjectInternalMethod())
except MethodNotNewObjectError:
# If we can't have a ToObject() because one of our members can only
# be returned from [NewObject] methods, then just skip generating
# ToObject().
# If we can't have a ToObjectInternal() because one of our members
# can only be returned from [NewObject] methods, then just skip
# generating ToObjectInternal().
pass
methods.append(self.traceDictionaryMethod())

Просмотреть файл

@ -209,7 +209,7 @@ ToJSValue(JSContext* aCx,
const T& aArgument,
JS::MutableHandle<JS::Value> aValue)
{
return aArgument.ToObject(aCx, aValue);
return aArgument.ToObjectInternal(aCx, aValue);
}
// Accept existing JS values (which may not be same-compartment with us

Просмотреть файл

@ -15,6 +15,7 @@
#include "BrowserElementParent.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/dom/HTMLIFrameElement.h"
#include "mozilla/dom/ToJSValue.h"
#include "nsIDOMCustomEvent.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsVariant.h"
@ -160,7 +161,7 @@ BrowserElementParent::DispatchOpenWindowEvent(Element* aOpenerFrameElement,
JS::Rooted<JSObject*> global(cx, sgo->GetGlobalJSObject());
JSAutoCompartment ac(cx, global);
if (!detail.ToObject(cx, &val)) {
if (!ToJSValue(cx, detail, &val)) {
MOZ_CRASH("Failed to convert dictionary to JS::Value due to OOM.");
return BrowserElementParent::OPEN_WINDOW_IGNORED;
}
@ -332,7 +333,7 @@ NS_IMETHODIMP DispatchAsyncScrollEventRunnable::Run()
JSAutoCompartment ac(cx, globalJSObject);
JS::Rooted<JS::Value> val(cx);
if (!detail.ToObject(cx, &val)) {
if (!ToJSValue(cx, detail, &val)) {
MOZ_CRASH("Failed to convert dictionary to JS::Value due to OOM.");
return NS_ERROR_FAILURE;
}

Просмотреть файл

@ -10,6 +10,7 @@
#include "DataStoreService.h"
#include "mozilla/dom/DataStoreBinding.h"
#include "mozilla/dom/indexedDB/IDBObjectStore.h"
#include "mozilla/dom/ToJSValue.h"
#include "nsIDOMEvent.h"
namespace mozilla {
@ -57,7 +58,7 @@ DataStoreRevision::AddRevision(JSContext* aCx,
}
JS::Rooted<JS::Value> value(aCx);
if (!data.ToObject(aCx, &value)) {
if (!ToJSValue(aCx, data, &value)) {
return NS_ERROR_FAILURE;
}

Просмотреть файл

@ -10,6 +10,7 @@
#include "mozilla/dom/MozClirModeEvent.h"
#include "mozilla/dom/MozEmergencyCbModeEvent.h"
#include "mozilla/dom/MozOtaStatusEvent.h"
#include "mozilla/dom/ToJSValue.h"
#include "mozilla/dom/USSDReceivedEvent.h"
#include "mozilla/Preferences.h"
#include "mozilla/Services.h"
@ -605,7 +606,7 @@ MobileConnection::SetCallForwardingOption(const MozCallForwardingOptions& aOptio
AutoSafeJSContext cx;
JS::Rooted<JS::Value> options(cx);
if (!aOptions.ToObject(cx, &options)) {
if (!ToJSValue(cx, aOptions, &options)) {
aRv.Throw(NS_ERROR_TYPE_ERR);
return nullptr;
}
@ -636,7 +637,7 @@ MobileConnection::GetCallBarringOption(const MozCallBarringOptions& aOptions,
AutoSafeJSContext cx;
JS::Rooted<JS::Value> options(cx);
if (!aOptions.ToObject(cx, &options)) {
if (!ToJSValue(cx, aOptions, &options)) {
aRv.Throw(NS_ERROR_TYPE_ERR);
return nullptr;
}
@ -667,7 +668,7 @@ MobileConnection::SetCallBarringOption(const MozCallBarringOptions& aOptions,
AutoSafeJSContext cx;
JS::Rooted<JS::Value> options(cx);
if (!aOptions.ToObject(cx, &options)) {
if (!ToJSValue(cx, aOptions, &options)) {
aRv.Throw(NS_ERROR_TYPE_ERR);
return nullptr;
}
@ -698,7 +699,7 @@ MobileConnection::ChangeCallBarringPassword(const MozCallBarringOptions& aOption
AutoSafeJSContext cx;
JS::Rooted<JS::Value> options(cx);
if (!aOptions.ToObject(cx, &options)) {
if (!ToJSValue(cx, aOptions, &options)) {
aRv.Throw(NS_ERROR_TYPE_ERR);
return nullptr;
}

Просмотреть файл

@ -4,6 +4,7 @@
#include "mozilla/dom/DesktopNotification.h"
#include "mozilla/dom/DesktopNotificationBinding.h"
#include "mozilla/dom/AppNotificationServiceOptionsBinding.h"
#include "mozilla/dom/ToJSValue.h"
#include "nsContentPermissionHelper.h"
#include "nsXULAppAPI.h"
#include "mozilla/dom/PBrowserChild.h"
@ -101,7 +102,7 @@ DesktopNotification::PostDesktopNotification()
ops.mTextClickable = true;
ops.mManifestURL = manifestUrl;
if (!ops.ToObject(cx, &val)) {
if (!ToJSValue(cx, ops, &val)) {
return NS_ERROR_FAILURE;
}

Просмотреть файл

@ -606,7 +606,7 @@ Notification::ShowInternal()
ops.mLang = mLang;
ops.mTag = mTag;
if (!ops.ToObject(cx, &val)) {
if (!ToJSValue(cx, ops, &val)) {
NS_WARNING("Converting dict to object failed!");
return;
}

Просмотреть файл

@ -7,6 +7,7 @@
#include <nsThreadUtils.h>
#include "mozilla/ModuleUtils.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/dom/ToJSValue.h"
#include "nsXULAppAPI.h"
#include "nsCxPusher.h"
@ -240,7 +241,7 @@ NetworkWorker::DispatchNetworkResult(const NetworkResultOptions& aOptions)
mozilla::AutoSafeJSContext cx;
JS::RootedValue val(cx);
if (!aOptions.ToObject(cx, &val)) {
if (!ToJSValue(cx, aOptions, &val)) {
return;
}

Просмотреть файл

@ -8,6 +8,7 @@
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/ModuleUtils.h"
#include "mozilla/RefPtr.h"
#include "mozilla/dom/ToJSValue.h"
#include "cert.h"
#include "certdb.h"
#include "CryptoTask.h"
@ -255,7 +256,7 @@ WifiCertService::DispatchResult(const WifiCertServiceResultOptions& aOptions)
JS::RootedValue val(cx);
nsCString dummyInterface;
if (!aOptions.ToObject(cx, &val)) {
if (!ToJSValue(cx, aOptions, &val)) {
return;
}

Просмотреть файл

@ -6,6 +6,7 @@
#include "nsServiceManagerUtils.h"
#include "mozilla/ModuleUtils.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/dom/ToJSValue.h"
#include "nsXULAppAPI.h"
#include "WifiUtils.h"
#include "nsCxPusher.h"
@ -291,7 +292,7 @@ WifiProxyService::DispatchWifiResult(const WifiResultOptions& aOptions, const ns
mozilla::AutoSafeJSContext cx;
JS::Rooted<JS::Value> val(cx);
if (!aOptions.ToObject(cx, &val)) {
if (!ToJSValue(cx, aOptions, &val)) {
return;
}

Просмотреть файл

@ -38,6 +38,7 @@
#include "nsRuleProcessorData.h"
#include "nsCSSRuleProcessor.h"
#include "mozilla/dom/InspectorUtilsBinding.h"
#include "mozilla/dom/ToJSValue.h"
#include "nsCSSProps.h"
#include "nsColor.h"
#include "nsStyleSet.h"
@ -651,7 +652,7 @@ inDOMUtils::ColorNameToRGB(const nsAString& aColorName, JSContext* aCx,
triple.mG = NS_GET_G(color);
triple.mB = NS_GET_B(color);
if (!triple.ToObject(aCx, aValue)) {
if (!ToJSValue(aCx, triple, aValue)) {
return NS_ERROR_FAILURE;
}

Просмотреть файл

@ -3,6 +3,7 @@
* file, You can obtain one at http:mozilla.org/MPL/2.0/. */
#include "mozilla/dom/NetDashboardBinding.h"
#include "mozilla/dom/ToJSValue.h"
#include "mozilla/net/Dashboard.h"
#include "mozilla/net/HttpInfo.h"
#include "nsCxPusher.h"
@ -20,6 +21,7 @@
using mozilla::AutoSafeJSContext;
using mozilla::dom::Sequence;
using mozilla::dom::ToJSValue;
namespace mozilla {
namespace net {
@ -318,7 +320,7 @@ LookupHelper::ConstructAnswer(LookupArgument *aArgument)
}
JS::RootedValue val(cx);
if (!dict.ToObject(cx, &val)) {
if (!ToJSValue(cx, dict, &val)) {
return NS_ERROR_FAILURE;
}
@ -402,7 +404,7 @@ Dashboard::GetSockets(SocketData *aSocketData)
dict.mSent += socketData->mTotalSent;
dict.mReceived += socketData->mTotalRecv;
JS::RootedValue val(cx);
if (!dict.ToObject(cx, &val))
if (!ToJSValue(cx, dict, &val))
return NS_ERROR_FAILURE;
socketData->mCallback->OnDashboardDataAvailable(val);
@ -502,7 +504,7 @@ Dashboard::GetHttpConnections(HttpData *aHttpData)
}
JS::RootedValue val(cx);
if (!dict.ToObject(cx, &val)) {
if (!ToJSValue(cx, dict, &val)) {
return NS_ERROR_FAILURE;
}
@ -630,7 +632,7 @@ Dashboard::GetWebSocketConnections(WebSocketRequest *aWsRequest)
}
JS::RootedValue val(cx);
if (!dict.ToObject(cx, &val)) {
if (!ToJSValue(cx, dict, &val)) {
return NS_ERROR_FAILURE;
}
wsRequest->mCallback->OnDashboardDataAvailable(val);
@ -718,7 +720,7 @@ Dashboard::GetDNSCacheEntries(DnsData *dnsData)
}
JS::RootedValue val(cx);
if (!dict.ToObject(cx, &val)) {
if (!ToJSValue(cx, dict, &val)) {
return NS_ERROR_FAILURE;
}
dnsData->mCallback->OnDashboardDataAvailable(val);
@ -822,7 +824,7 @@ Dashboard::GetConnectionStatus(ConnectionData *aConnectionData)
dict.mStatus = connectionData->mStatus;
JS::RootedValue val(cx);
if (!dict.ToObject(cx, &val))
if (!ToJSValue(cx, dict, &val))
return NS_ERROR_FAILURE;
connectionData->mCallback->OnDashboardDataAvailable(val);