author | Birunthan Mohanathas <birunthan@mohanathas.com> |
Thu, 10 Oct 2013 16:35:53 -0400 | |
changeset 150391 | 9ee0459d73363b3eeabc9e8ab4e79bf13fd51be9 |
parent 150390 | d5adee3511dc0883e69471f7fdcef6ba3fba2aad |
child 150392 | 01fa498691752a5998bb0a848f47a299648dc21c |
push id | 25437 |
push user | kwierso@gmail.com |
push date | Fri, 11 Oct 2013 02:00:22 +0000 |
treeherder | autoland@672cd63528d3 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | ehsan |
bugs | 784739 |
milestone | 27.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/js/xpconnect/loader/mozJSComponentLoader.cpp +++ b/js/xpconnect/loader/mozJSComponentLoader.cpp @@ -403,117 +403,117 @@ mozJSComponentLoader::LoadModule(FileLoc nsCOMPtr<nsIFile> file = aFile.GetBaseFile(); nsCString spec; aFile.GetURIString(spec); nsCOMPtr<nsIURI> uri; nsresult rv = NS_NewURI(getter_AddRefs(uri), spec); if (NS_FAILED(rv)) - return NULL; + return nullptr; if (!mInitialized) { rv = ReallyInit(); if (NS_FAILED(rv)) - return NULL; + return nullptr; } ModuleEntry* mod; if (mModules.Get(spec, &mod)) return mod; nsAutoPtr<ModuleEntry> entry(new ModuleEntry); JSAutoRequest ar(mContext); RootedValue dummy(mContext); rv = ObjectForLocation(file, uri, &entry->obj, &entry->location, false, &dummy); if (NS_FAILED(rv)) { - return NULL; + return nullptr; } nsCOMPtr<nsIXPConnect> xpc = do_GetService(kXPConnectServiceContractID, &rv); if (NS_FAILED(rv)) - return NULL; + return nullptr; nsCOMPtr<nsIComponentManager> cm; rv = NS_GetComponentManager(getter_AddRefs(cm)); if (NS_FAILED(rv)) - return NULL; + return nullptr; JSCLContextHelper cx(mContext); JSAutoCompartment ac(cx, entry->obj); nsCOMPtr<nsIXPConnectJSObjectHolder> cm_holder; rv = xpc->WrapNative(cx, entry->obj, cm, NS_GET_IID(nsIComponentManager), getter_AddRefs(cm_holder)); if (NS_FAILED(rv)) { #ifdef DEBUG_shaver fprintf(stderr, "WrapNative(%p,%p,nsIComponentManager) failed: %x\n", (void *)(JSContext*)cx, (void *)mCompMgr, rv); #endif - return NULL; + return nullptr; } JSObject* cm_jsobj = cm_holder->GetJSObject(); if (!cm_jsobj) { #ifdef DEBUG_shaver fprintf(stderr, "GetJSObject of ComponentManager failed\n"); #endif - return NULL; + return nullptr; } nsCOMPtr<nsIXPConnectJSObjectHolder> file_holder; rv = xpc->WrapNative(cx, entry->obj, file, NS_GET_IID(nsIFile), getter_AddRefs(file_holder)); if (NS_FAILED(rv)) { - return NULL; + return nullptr; } JSObject* file_jsobj = file_holder->GetJSObject(); if (!file_jsobj) { - return NULL; + return nullptr; } JSCLAutoErrorReporterSetter aers(cx, xpc::SystemErrorReporter); RootedValue NSGetFactory_val(cx); if (!JS_GetProperty(cx, entry->obj, "NSGetFactory", &NSGetFactory_val) || JSVAL_IS_VOID(NSGetFactory_val)) { - return NULL; + return nullptr; } if (JS_TypeOfValue(cx, NSGetFactory_val) != JSTYPE_FUNCTION) { nsAutoCString spec; uri->GetSpec(spec); JS_ReportError(cx, "%s has NSGetFactory property that is not a function", spec.get()); - return NULL; + return nullptr; } RootedObject jsGetFactoryObj(cx); if (!JS_ValueToObject(cx, NSGetFactory_val, &jsGetFactoryObj) || !jsGetFactoryObj) { /* XXX report error properly */ - return NULL; + return nullptr; } rv = xpc->WrapJS(cx, jsGetFactoryObj, NS_GET_IID(xpcIJSGetFactory), getter_AddRefs(entry->getfactoryobj)); if (NS_FAILED(rv)) { /* XXX report error properly */ #ifdef DEBUG fprintf(stderr, "mJCL: couldn't get nsIModule from jsval\n"); #endif - return NULL; + return nullptr; } // Cache this module for later mModules.Put(spec, entry); // Set the location information for the new global, so that tools like // about:memory may use that information if (!mReuseLoaderGlobal) { @@ -987,17 +987,17 @@ mozJSComponentLoader::ObjectForLocation( } mThisObjects.Put(tableScript, obj); uint32_t oldopts = JS_GetOptions(cx); JS_SetOptions(cx, oldopts | (aPropagateExceptions ? JSOPTION_DONT_REPORT_UNCAUGHT : 0)); bool ok = false; if (script) { - ok = JS_ExecuteScriptVersion(cx, obj, script, NULL, JSVERSION_LATEST); + ok = JS_ExecuteScriptVersion(cx, obj, script, nullptr, JSVERSION_LATEST); } else { jsval rval; ok = JS_CallFunction(cx, obj, function, 0, nullptr, &rval); } JS_SetOptions(cx, oldopts); if (!ok) { if (aPropagateExceptions) { @@ -1045,17 +1045,17 @@ mozJSComponentLoader::UnloadModules() mLoaderGlobal = nullptr; } mInProgressImports.Clear(); mImports.Clear(); mThisObjects.Clear(); - mModules.Enumerate(ClearModules, NULL); + mModules.Enumerate(ClearModules, nullptr); JS_DestroyContextNoGC(mContext); mContext = nullptr; mRuntimeService = nullptr; #ifdef DEBUG_shaver_off fprintf(stderr, "mJCL: UnloadAll(%d)\n", aWhen); #endif
--- a/js/xpconnect/loader/mozJSComponentLoader.h +++ b/js/xpconnect/loader/mozJSComponentLoader.h @@ -82,48 +82,48 @@ class mozJSComponentLoader : public mozi JSRuntime *mRuntime; JSContext *mContext; class ModuleEntry : public mozilla::Module { public: ModuleEntry() : mozilla::Module() { mVersion = mozilla::Module::kVersion; - mCIDs = NULL; - mContractIDs = NULL; - mCategoryEntries = NULL; + mCIDs = nullptr; + mContractIDs = nullptr; + mCategoryEntries = nullptr; getFactoryProc = GetFactory; - loadProc = NULL; - unloadProc = NULL; + loadProc = nullptr; + unloadProc = nullptr; obj = nullptr; location = nullptr; } ~ModuleEntry() { Clear(); } void Clear() { - getfactoryobj = NULL; + getfactoryobj = nullptr; if (obj) { JSAutoRequest ar(sSelf->mContext); JSAutoCompartment ac(sSelf->mContext, obj); JS_SetAllNonReservedSlotsToUndefined(sSelf->mContext, obj); JS_RemoveObjectRoot(sSelf->mContext, &obj); } if (location) NS_Free(location); - obj = NULL; - location = NULL; + obj = nullptr; + location = nullptr; } static already_AddRefed<nsIFactory> GetFactory(const mozilla::Module& module, const mozilla::Module::CIDEntry& entry); nsCOMPtr<xpcIJSGetFactory> getfactoryobj; JSObject *obj; char *location;
--- a/js/xpconnect/public/SandboxPrivate.h +++ b/js/xpconnect/public/SandboxPrivate.h @@ -34,16 +34,16 @@ public: JSObject *GetGlobalJSObject() { return mGlobalJSObject; } void ForgetGlobalObject() { - mGlobalJSObject = NULL; + mGlobalJSObject = nullptr; } private: nsCOMPtr<nsIPrincipal> mPrincipal; JSObject *mGlobalJSObject; }; #endif // __SANDBOXPRIVATE_H__
--- a/js/xpconnect/src/BackstagePass.h +++ b/js/xpconnect/src/BackstagePass.h @@ -27,17 +27,17 @@ public: return mPrincipal; } virtual JSObject* GetGlobalJSObject() { return mGlobal; } virtual void ForgetGlobalObject() { - mGlobal = NULL; + mGlobal = nullptr; } virtual void SetGlobalObject(JSObject* global) { mGlobal = global; } BackstagePass(nsIPrincipal *prin) : mPrincipal(prin)
--- a/js/xpconnect/src/Sandbox.cpp +++ b/js/xpconnect/src/Sandbox.cpp @@ -591,17 +591,17 @@ sandbox_convert(JSContext *cx, HandleObj #define XPCONNECT_SANDBOX_CLASS_METADATA_SLOT (XPCONNECT_GLOBAL_EXTRA_SLOT_OFFSET) static const JSClass SandboxClass = { "Sandbox", XPCONNECT_GLOBAL_FLAGS_WITH_EXTRA_SLOTS(1), JS_PropertyStub, JS_DeletePropertyStub, JS_PropertyStub, JS_StrictPropertyStub, sandbox_enumerate, sandbox_resolve, sandbox_convert, sandbox_finalize, - NULL, NULL, NULL, NULL, TraceXPCGlobal + nullptr, nullptr, nullptr, nullptr, TraceXPCGlobal }; static const JSFunctionSpec SandboxFunctions[] = { JS_FS("dump", SandboxDump, 1,0), JS_FS("debug", SandboxDebug, 1,0), JS_FS("importFunction", SandboxImport, 1,0), JS_FS_END }; @@ -1147,17 +1147,17 @@ GetPrincipalFromString(JSContext *cx, Ha /* * For sandbox constructor the first argument can be a principal object or * a script object principal (Document, Window). */ static nsresult GetPrincipalOrSOP(JSContext *cx, HandleObject from, nsISupports **out) { MOZ_ASSERT(out); - *out = NULL; + *out = nullptr; nsXPConnect* xpc = nsXPConnect::XPConnect(); nsCOMPtr<nsIXPConnectWrappedNative> wrapper; xpc->GetWrappedNativeOfJSObject(cx, from, getter_AddRefs(wrapper)); NS_ENSURE_TRUE(wrapper, NS_ERROR_INVALID_ARG); @@ -1288,17 +1288,17 @@ GetObjPropFromOptions(JSContext *cx, Han MOZ_ASSERT(prop); RootedValue value(cx); bool found; nsresult rv = GetPropFromOptions(cx, from, name, &value, &found); NS_ENSURE_SUCCESS(rv, rv); if (!found) { - *prop = NULL; + *prop = nullptr; return NS_OK; } NS_ENSURE_TRUE(value.isObject(), NS_ERROR_INVALID_ARG); *prop = &value.toObject(); return NS_OK; } @@ -1720,15 +1720,15 @@ nsresult xpc::SetSandboxMetadata(JSContext *cx, HandleObject sandbox, HandleValue metadataArg) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(IsSandbox(sandbox)); RootedValue metadata(cx); JSAutoCompartment ac(cx, sandbox); - if (!JS_StructuredClone(cx, metadataArg, metadata.address(), NULL, NULL)) + if (!JS_StructuredClone(cx, metadataArg, metadata.address(), nullptr, nullptr)) return NS_ERROR_UNEXPECTED; JS_SetReservedSlot(sandbox, XPCONNECT_SANDBOX_CLASS_METADATA_SLOT, metadata); return NS_OK; }
--- a/js/xpconnect/src/XPCComponents.cpp +++ b/js/xpconnect/src/XPCComponents.cpp @@ -1791,18 +1791,18 @@ struct MOZ_STACK_CLASS ExceptionArgParse /* * The Components.Exception takes a series of arguments, all of them * optional: * * Argument 0: Exception message (defaults to 'exception'). * Argument 1: Result code (defaults to NS_ERROR_FAILURE) _or_ options * object (see below). * Argument 2: Stack (defaults to the current stack, which we trigger - * by leaving this NULL in the parser). - * Argument 3: Optional user data (defaults to NULL). + * by leaving this nullptr in the parser). + * Argument 3: Optional user data (defaults to nullptr). * * To dig our way out of this clunky API, we now support passing an * options object as the second parameter (as opposed to a result code). * If this is the case, all subsequent arguments are ignored, and the * following properties are parsed out of the object (using the * associated default if the property does not exist): * * result: Result code (see argument 1). @@ -2905,17 +2905,17 @@ class PreciseGCRunnable : public nsRunna : mCallback(aCallback), mShrinking(aShrinking) {} NS_IMETHOD Run() { JSRuntime* rt = nsXPConnect::GetRuntimeInstance()->Runtime(); JSContext *cx; JSContext *iter = nullptr; - while ((cx = JS_ContextIterator(rt, &iter)) != NULL) { + while ((cx = JS_ContextIterator(rt, &iter)) != nullptr) { if (JS_IsRunning(cx)) { return NS_DispatchToMainThread(this); } } JS::PrepareForFullGC(rt); if (mShrinking) JS::ShrinkingGC(rt, JS::gcreason::COMPONENT_UTILS); @@ -3044,17 +3044,17 @@ nsXPCComponents_Utils::CreateArrayIn(con // first argument must be an object if (vobj.isPrimitive()) return NS_ERROR_XPC_BAD_CONVERT_JS; RootedObject scope(cx, js::UncheckedUnwrap(&vobj.toObject())); RootedObject obj(cx); { JSAutoCompartment ac(cx, scope); - obj = JS_NewArrayObject(cx, 0, NULL); + obj = JS_NewArrayObject(cx, 0, nullptr); if (!obj) return NS_ERROR_FAILURE; } if (!JS_WrapObject(cx, obj.address())) return NS_ERROR_FAILURE; *rval = ObjectValue(*obj); @@ -3144,17 +3144,17 @@ nsXPCComponents_Utils::IsDeadWrapper(con /* void recomputerWrappers(jsval vobj); */ NS_IMETHODIMP nsXPCComponents_Utils::RecomputeWrappers(const jsval &vobj, JSContext *cx) { // Determine the compartment of the given object, if any. JSCompartment *c = vobj.isObject() ? js::GetObjectCompartment(js::UncheckedUnwrap(&vobj.toObject())) - : NULL; + : nullptr; // If no compartment was given, recompute all. if (!c) js::RecomputeWrappers(cx, js::AllCompartments(), js::AllCompartments()); // Otherwise, recompute wrappers for the given compartment. else js::RecomputeWrappers(cx, js::SingleCompartment(c), js::AllCompartments()) && js::RecomputeWrappers(cx, js::AllCompartments(), js::SingleCompartment(c));
--- a/js/xpconnect/src/XPCJSContextStack.cpp +++ b/js/xpconnect/src/XPCJSContextStack.cpp @@ -123,17 +123,17 @@ SafeFinalize(JSFreeOp *fop, JSObject* ob DestroyProtoAndIfaceCache(obj); } const JSClass xpc::SafeJSContextGlobalClass = { "global_for_XPCJSContextStack_SafeJSContext", XPCONNECT_GLOBAL_FLAGS, JS_PropertyStub, JS_DeletePropertyStub, JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, SafeGlobalResolve, JS_ConvertStub, SafeFinalize, - NULL, NULL, NULL, NULL, TraceXPCGlobal + nullptr, nullptr, nullptr, nullptr, TraceXPCGlobal }; JSContext* XPCJSContextStack::GetSafeJSContext() { if (mSafeJSContext) return mSafeJSContext;
--- a/js/xpconnect/src/XPCJSID.cpp +++ b/js/xpconnect/src/XPCJSID.cpp @@ -261,17 +261,17 @@ NS_METHOD GetSharedScriptableHelperForJS { 0x00000000, 0x0000, 0x0000, \ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } NS_DECL_CI_INTERFACE_GETTER(nsJSIID) NS_IMPL_CLASSINFO(nsJSIID, GetSharedScriptableHelperForJSIID, nsIClassInfo::THREADSAFE, NULL_CID) NS_DECL_CI_INTERFACE_GETTER(nsJSCID) -NS_IMPL_CLASSINFO(nsJSCID, NULL, nsIClassInfo::THREADSAFE, NULL_CID) +NS_IMPL_CLASSINFO(nsJSCID, nullptr, nsIClassInfo::THREADSAFE, NULL_CID) void xpc_DestroyJSxIDClassObjects() { if (gClassObjectsWereInited) { NS_IF_RELEASE(NS_CLASSINFO_NAME(nsJSIID)); NS_IF_RELEASE(NS_CLASSINFO_NAME(nsJSCID)); NS_IF_RELEASE(gSharedScriptableHelperForJSIID); @@ -702,19 +702,19 @@ GetIIDArg(uint32_t argc, const JS::Value iid = &NS_GET_IID(nsISupports); return iid; } static void GetWrapperObject(MutableHandleObject obj) { - obj.set(NULL); + obj.set(nullptr); nsXPConnect* xpc = nsXPConnect::XPConnect(); - nsAXPCNativeCallContext *ccxp = NULL; + nsAXPCNativeCallContext *ccxp = nullptr; xpc->GetCurrentNativeCallContext(&ccxp); if (!ccxp) return; nsCOMPtr<nsIXPConnectWrappedNative> wrapper; ccxp->GetCalleeWrapper(getter_AddRefs(wrapper)); obj.set(wrapper->GetJSObject()); }
--- a/js/xpconnect/src/XPCJSRuntime.cpp +++ b/js/xpconnect/src/XPCJSRuntime.cpp @@ -1747,17 +1747,17 @@ private: NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(JSMallocSizeOf) namespace xpc { static nsresult ReportZoneStats(const JS::ZoneStats &zStats, const xpc::ZoneStatsExtras &extras, nsIMemoryReporterCallback *cb, - nsISupports *closure, size_t *gcTotalOut = NULL) + nsISupports *closure, size_t *gcTotalOut = nullptr) { const nsAutoCString& pathPrefix = extras.pathPrefix; size_t gcTotal = 0, sundriesGCHeap = 0, sundriesMallocHeap = 0; ZCREPORT_GC_BYTES(pathPrefix + NS_LITERAL_CSTRING("gc-heap-arena-admin"), zStats.gcHeapArenaAdmin, "Memory on the garbage-collected JavaScript " "heap, within arenas, that is used (a) to hold internal " @@ -1931,17 +1931,17 @@ ReportZoneStats(const JS::ZoneStats &zSt # undef STRING_LENGTH } static nsresult ReportCompartmentStats(const JS::CompartmentStats &cStats, const xpc::CompartmentStatsExtras &extras, amIAddonManager *addonManager, nsIMemoryReporterCallback *cb, - nsISupports *closure, size_t *gcTotalOut = NULL) + nsISupports *closure, size_t *gcTotalOut = nullptr) { static const nsDependentCString addonPrefix("explicit/add-ons/"); size_t gcTotal = 0, sundriesGCHeap = 0, sundriesMallocHeap = 0; nsAutoCString cJSPathPrefix = extras.jsPathPrefix; nsAutoCString cDOMPathPrefix = extras.domPathPrefix; // Only attempt to prefix if we got a location and the path wasn't already @@ -2814,17 +2814,18 @@ ReadSourceFromFilename(JSContext *cx, co rv = scriptStream->Read(reinterpret_cast<char *>(ptr), end - ptr, &bytesRead); if (NS_FAILED(rv)) return rv; MOZ_ASSERT(bytesRead > 0, "stream promised more bytes before EOF"); ptr += bytesRead; } nsString decoded; - rv = nsScriptLoader::ConvertToUTF16(scriptChannel, buf, rawLen, EmptyString(), NULL, decoded); + rv = nsScriptLoader::ConvertToUTF16(scriptChannel, buf, rawLen, EmptyString(), + nullptr, decoded); NS_ENSURE_SUCCESS(rv, rv); // Copy to JS engine. *len = decoded.Length(); *src = static_cast<jschar *>(JS_malloc(cx, decoded.Length()*sizeof(jschar))); if (!*src) return NS_ERROR_FAILURE; memcpy(*src, decoded.get(), decoded.Length()*sizeof(jschar)); @@ -2832,17 +2833,17 @@ ReadSourceFromFilename(JSContext *cx, co return NS_OK; } // The JS engine calls this object's 'load' member function when it needs // the source for a chrome JS function. See the comment in the XPCJSRuntime // constructor. class XPCJSSourceHook: public js::SourceHook { bool load(JSContext *cx, const char *filename, jschar **src, size_t *length) { - *src = NULL; + *src = nullptr; *length = 0; if (!nsContentUtils::IsCallerChrome()) return true; if (!filename) return true;
--- a/js/xpconnect/src/XPCMaps.cpp +++ b/js/xpconnect/src/XPCMaps.cpp @@ -114,19 +114,19 @@ JSObject2WrappedJSMap::ShutdownMarker() // static Native2WrappedNativeMap* Native2WrappedNativeMap::newMap(int size) { Native2WrappedNativeMap* map = new Native2WrappedNativeMap(size); if (map && map->mTable) return map; // Allocation of the map or the creation of its hash table has - // failed. This will cause a NULL deref later when we attempt to - // use the map, so we abort immediately to provide a more useful - // crash stack. + // failed. This will cause a nullptr deref later when we attempt + // to use the map, so we abort immediately to provide a more + // useful crash stack. NS_RUNTIMEABORT("Ran out of memory."); return nullptr; } Native2WrappedNativeMap::Native2WrappedNativeMap(int size) { mTable = PL_NewDHashTable(PL_DHashGetStubOps(), nullptr, sizeof(Entry), size); @@ -286,19 +286,19 @@ ClassInfo2NativeSetMap::ShallowSizeOfInc // static ClassInfo2WrappedNativeProtoMap* ClassInfo2WrappedNativeProtoMap::newMap(int size) { ClassInfo2WrappedNativeProtoMap* map = new ClassInfo2WrappedNativeProtoMap(size); if (map && map->mTable) return map; // Allocation of the map or the creation of its hash table has - // failed. This will cause a NULL deref later when we attempt to - // use the map, so we abort immediately to provide a more useful - // crash stack. + // failed. This will cause a nullptr deref later when we attempt + // to use the map, so we abort immediately to provide a more + // useful crash stack. NS_RUNTIMEABORT("Ran out of memory."); return nullptr; } ClassInfo2WrappedNativeProtoMap::ClassInfo2WrappedNativeProtoMap(int size) { mTable = PL_NewDHashTable(PL_DHashGetStubOps(), nullptr, sizeof(Entry), size);
--- a/js/xpconnect/src/XPCModule.h +++ b/js/xpconnect/src/XPCModule.h @@ -31,21 +31,21 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(mozJSSubS NS_DEFINE_NAMED_CID(NS_JS_ID_CID); NS_DEFINE_NAMED_CID(NS_XPCONNECT_CID); NS_DEFINE_NAMED_CID(NS_XPCEXCEPTION_CID); NS_DEFINE_NAMED_CID(NS_SCRIPTERROR_CID); NS_DEFINE_NAMED_CID(MOZJSCOMPONENTLOADER_CID); NS_DEFINE_NAMED_CID(MOZ_JSSUBSCRIPTLOADER_CID); #define XPCONNECT_CIDENTRIES \ - { &kNS_JS_ID_CID, false, NULL, nsJSIDConstructor }, \ - { &kNS_XPCONNECT_CID, false, NULL, nsIXPConnectConstructor }, \ - { &kNS_SCRIPTERROR_CID, false, NULL, nsScriptErrorConstructor }, \ - { &kMOZJSCOMPONENTLOADER_CID, false, NULL, mozJSComponentLoaderConstructor },\ - { &kMOZ_JSSUBSCRIPTLOADER_CID, false, NULL, mozJSSubScriptLoaderConstructor }, + { &kNS_JS_ID_CID, false, nullptr, nsJSIDConstructor }, \ + { &kNS_XPCONNECT_CID, false, nullptr, nsIXPConnectConstructor }, \ + { &kNS_SCRIPTERROR_CID, false, nullptr, nsScriptErrorConstructor }, \ + { &kMOZJSCOMPONENTLOADER_CID, false, nullptr, mozJSComponentLoaderConstructor },\ + { &kMOZ_JSSUBSCRIPTLOADER_CID, false, nullptr, mozJSSubScriptLoaderConstructor }, #define XPCONNECT_CONTRACTS \ { XPC_ID_CONTRACTID, &kNS_JS_ID_CID }, \ { XPC_XPCONNECT_CONTRACTID, &kNS_XPCONNECT_CID }, \ { XPC_CONTEXT_STACK_CONTRACTID, &kNS_XPCONNECT_CID }, \ { XPC_RUNTIME_CONTRACTID, &kNS_XPCONNECT_CID }, \ { NS_SCRIPTERROR_CONTRACTID, &kNS_SCRIPTERROR_CID }, \ { MOZJSCOMPONENTLOADER_CONTRACTID, &kMOZJSCOMPONENTLOADER_CID }, \
--- a/js/xpconnect/src/XPCQuickStubs.cpp +++ b/js/xpconnect/src/XPCQuickStubs.cpp @@ -259,17 +259,17 @@ ThrowCallFailed(JSContext *cx, nsresult bool xpc_qsThrowGetterSetterFailed(JSContext *cx, nsresult rv, JSObject *obj, jsid memberIdArg) { RootedId memberId(cx, memberIdArg); const char *ifaceName; GetMemberInfo(obj, memberId, &ifaceName); - return ThrowCallFailed(cx, rv, ifaceName, memberId, NULL); + return ThrowCallFailed(cx, rv, ifaceName, memberId, nullptr); } bool xpc_qsThrowGetterSetterFailed(JSContext *cx, nsresult rv, JSObject *objArg, const char* memberName) { RootedObject obj(cx, objArg); JSString *str = JS_InternString(cx, memberName); @@ -289,17 +289,17 @@ xpc_qsThrowGetterSetterFailed(JSContext } bool xpc_qsThrowMethodFailed(JSContext *cx, nsresult rv, jsval *vp) { const char *ifaceName; RootedId memberId(cx); GetMethodInfo(cx, vp, &ifaceName, memberId.address()); - return ThrowCallFailed(cx, rv, ifaceName, memberId, NULL); + return ThrowCallFailed(cx, rv, ifaceName, memberId, nullptr); } bool xpc_qsThrowMethodFailedWithCcx(XPCCallContext &ccx, nsresult rv) { ThrowBadResult(rv, ccx); return false; } @@ -342,17 +342,17 @@ ThrowBadArg(JSContext *cx, nsresult rv, } void xpc_qsThrowBadArg(JSContext *cx, nsresult rv, jsval *vp, unsigned paramnum) { const char *ifaceName; RootedId memberId(cx); GetMethodInfo(cx, vp, &ifaceName, memberId.address()); - ThrowBadArg(cx, rv, ifaceName, memberId, NULL, paramnum); + ThrowBadArg(cx, rv, ifaceName, memberId, nullptr, paramnum); } void xpc_qsThrowBadArgWithCcx(XPCCallContext &ccx, nsresult rv, unsigned paramnum) { XPCThrower::ThrowBadParam(rv, paramnum, ccx); } @@ -365,17 +365,17 @@ xpc_qsThrowBadArgWithDetails(JSContext * void xpc_qsThrowBadSetterValue(JSContext *cx, nsresult rv, JSObject *obj, jsid propIdArg) { RootedId propId(cx, propIdArg); const char *ifaceName; GetMemberInfo(obj, propId, &ifaceName); - ThrowBadArg(cx, rv, ifaceName, propId, NULL, 0); + ThrowBadArg(cx, rv, ifaceName, propId, nullptr, 0); } void xpc_qsThrowBadSetterValue(JSContext *cx, nsresult rv, JSObject *objArg, const char* propName) { RootedObject obj(cx, objArg); JSString *str = JS_InternString(cx, propName); @@ -394,27 +394,27 @@ xpc_qsThrowBadSetterValue(JSContext *cx, bool xpc_qsGetterOnlyPropertyStub(JSContext *cx, HandleObject obj, HandleId id, bool strict, MutableHandleValue vp) { return JS_ReportErrorFlagsAndNumber(cx, JSREPORT_WARNING | JSREPORT_STRICT | JSREPORT_STRICT_MODE_ERROR, - js_GetErrorMessage, NULL, + js_GetErrorMessage, nullptr, JSMSG_GETTER_ONLY); } bool xpc_qsGetterOnlyNativeStub(JSContext *cx, unsigned argc, jsval *vp) { return JS_ReportErrorFlagsAndNumber(cx, JSREPORT_WARNING | JSREPORT_STRICT | JSREPORT_STRICT_MODE_ERROR, - js_GetErrorMessage, NULL, + js_GetErrorMessage, nullptr, JSMSG_GETTER_ONLY); } xpc_qsDOMString::xpc_qsDOMString(JSContext *cx, jsval v, jsval *pval, StringificationBehavior nullBehavior, StringificationBehavior undefinedBehavior) { typedef implementation_type::char_traits traits; @@ -761,17 +761,17 @@ xpc_qsJsvalToCharStr(JSContext *cx, jsva bool xpc_qsJsvalToWcharStr(JSContext *cx, jsval v, jsval *pval, const PRUnichar **pstr) { JSString *str; if (JSVAL_IS_STRING(v)) { str = JSVAL_TO_STRING(v); } else if (JSVAL_IS_VOID(v) || JSVAL_IS_NULL(v)) { - *pstr = NULL; + *pstr = nullptr; return true; } else { if (!(str = JS_ValueToString(cx, v))) return false; *pval = STRING_TO_JSVAL(str); // Root the new string. } const jschar *chars = JS_GetStringCharsZ(cx, str);
--- a/js/xpconnect/src/XPCShellImpl.cpp +++ b/js/xpconnect/src/XPCShellImpl.cpp @@ -96,19 +96,19 @@ private: #define DoEndRequest(cx) ((void)0) #endif static const char kXPConnectServiceContractID[] = "@mozilla.org/js/xpc/XPConnect;1"; #define EXITCODE_RUNTIME_ERROR 3 #define EXITCODE_FILE_NOT_FOUND 4 -static FILE *gOutFile = NULL; -static FILE *gErrFile = NULL; -static FILE *gInFile = NULL; +static FILE *gOutFile = nullptr; +static FILE *gErrFile = nullptr; +static FILE *gInFile = nullptr; static int gExitCode = 0; static bool gIgnoreReportedErrors = false; static bool gQuitting = false; static bool reportWarnings = true; static bool compileOnly = false; static JSPrincipals *gJSPrincipals = nullptr; @@ -117,28 +117,28 @@ static nsAutoString *gWorkingDirectory = static bool GetLocationProperty(JSContext *cx, HandleObject obj, HandleId id, MutableHandleValue vp) { #if !defined(XP_WIN) && !defined(XP_UNIX) //XXX: your platform should really implement this return false; #else JS::RootedScript script(cx); - JS_DescribeScriptedCaller(cx, &script, NULL); + JS_DescribeScriptedCaller(cx, &script, nullptr); const char *filename = JS_GetScriptFilename(cx, script); if (filename) { nsresult rv; nsCOMPtr<nsIXPConnect> xpc = do_GetService(kXPConnectServiceContractID, &rv); #if defined(XP_WIN) // convert from the system codepage to UTF-16 int bufferSize = MultiByteToWideChar(CP_ACP, 0, filename, - -1, NULL, 0); + -1, nullptr, 0); nsAutoString filenameString; filenameString.SetLength(bufferSize); MultiByteToWideChar(CP_ACP, 0, filename, -1, (LPWSTR)filenameString.BeginWriting(), filenameString.Length()); // remove the null terminator filenameString.SetLength(bufferSize - 1); @@ -427,21 +427,21 @@ GCZeal(JSContext *cx, unsigned argc, jsv } #endif #ifdef DEBUG static bool DumpHeap(JSContext *cx, unsigned argc, jsval *vp) { - void* startThing = NULL; + void* startThing = nullptr; JSGCTraceKind startTraceKind = JSTRACE_OBJECT; - void *thingToFind = NULL; + void *thingToFind = nullptr; size_t maxDepth = (size_t)-1; - void *thingToIgnore = NULL; + void *thingToIgnore = nullptr; FILE *dumpFile; bool ok; jsval *argv = JS_ARGV(cx, vp); JS_SET_RVAL(cx, vp, JSVAL_VOID); vp = argv + 0; JSAutoByteString fileName; @@ -562,17 +562,17 @@ static const struct JSOption { static uint32_t MapContextOptionNameToFlag(JSContext* cx, const char* name) { for (size_t i = 0; i < ArrayLength(js_options); ++i) { if (strcmp(name, js_options[i].name) == 0) return js_options[i].flag; } - char* msg = JS_sprintf_append(NULL, + char* msg = JS_sprintf_append(nullptr, "unknown option name '%s'." " The valid names are ", name); for (size_t i = 0; i < ArrayLength(js_options); ++i) { if (!msg) break; msg = JS_sprintf_append(msg, "%s%s", js_options[i].name, (i + 2 < ArrayLength(js_options) ? ", " @@ -609,17 +609,17 @@ Options(JSContext *cx, unsigned argc, js return false; flag = MapContextOptionNameToFlag(cx, opt.ptr()); if (!flag) return false; optset |= flag; } optset = JS_ToggleOptions(cx, optset); - names = NULL; + names = nullptr; found = false; for (size_t i = 0; i < ArrayLength(js_options); i++) { if (js_options[i].flag & optset) { found = true; names = JS_sprintf_append(names, "%s%s", names ? "," : "", js_options[i].name); if (!names) break; @@ -904,27 +904,27 @@ env_enumerate(JSContext *cx, HandleObjec static bool reflected; char **evp, *name, *value; JSString *valstr; bool ok; if (reflected) return true; - for (evp = (char **)JS_GetPrivate(obj); (name = *evp) != NULL; evp++) { + for (evp = (char **)JS_GetPrivate(obj); (name = *evp) != nullptr; evp++) { value = strchr(name, '='); if (!value) continue; *value++ = '\0'; valstr = JS_NewStringCopyZ(cx, value); if (!valstr) { ok = false; } else { ok = JS_DefineProperty(cx, obj, name, STRING_TO_JSVAL(valstr), - NULL, NULL, JSPROP_ENUMERATE); + nullptr, nullptr, JSPROP_ENUMERATE); } value[-1] = '='; if (!ok) return false; } reflected = true; return true; @@ -947,17 +947,17 @@ env_resolve(JSContext *cx, HandleObject if (!name) return false; const char *value = getenv(name.ptr()); if (value) { valstr = JS_NewStringCopyZ(cx, value); if (!valstr) return false; if (!JS_DefinePropertyById(cx, obj, id, STRING_TO_JSVAL(valstr), - NULL, NULL, JSPROP_ENUMERATE)) { + nullptr, nullptr, JSPROP_ENUMERATE)) { return false; } objp.set(obj); } return true; } static const JSClass env_class = { @@ -984,17 +984,17 @@ static const JSErrorFormatString jsShell #include "jsshell.msg" #undef MSG_DEF }; static const JSErrorFormatString * my_GetErrorMessage(void *userRef, const char *locale, const unsigned errorNumber) { if (errorNumber == 0 || errorNumber >= JSShellErr_Limit) - return NULL; + return nullptr; return &jsShell_ErrorFormatString[errorNumber]; } static void ProcessFile(JSContext *cx, JS::Handle<JSObject*> obj, const char *filename, FILE *file, bool forceTTY) { @@ -1072,17 +1072,17 @@ ProcessFile(JSContext *cx, JS::Handle<JS strlen(buffer), "typein", startline); if (script) { JSErrorReporter older; if (!compileOnly) { ok = JS_ExecuteScript(cx, obj, script, result.address()); if (ok && result != JSVAL_VOID) { /* Suppress error reports from JS_ValueToString(). */ - older = JS_SetErrorReporter(cx, NULL); + older = JS_SetErrorReporter(cx, nullptr); str = JS_ValueToString(cx, result); JS_SetErrorReporter(cx, older); JSAutoByteString bytes; if (str && bytes.encodeLatin1(cx, str)) fprintf(gOutFile, "%s\n", bytes.ptr()); else ok = false; } @@ -1099,17 +1099,17 @@ Process(JSContext *cx, JS::Handle<JSObje { FILE *file; if (forceTTY || !filename || strcmp(filename, "-") == 0) { file = stdin; } else { file = fopen(filename, "r"); if (!file) { - JS_ReportErrorNumber(cx, my_GetErrorMessage, NULL, + JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr, JSSMSG_CANT_OPEN, filename, strerror(errno)); gExitCode = EXITCODE_FILE_NOT_FOUND; return; } } ProcessFile(cx, obj, filename, file, forceTTY); @@ -1158,17 +1158,17 @@ ProcessArgsForCompartment(JSContext *cx, static int ProcessArgs(JSContext *cx, JS::Handle<JSObject*> obj, char **argv, int argc, XPCShellDirProvider* aDirProvider) { const char rcfilename[] = "xpcshell.js"; FILE *rcfile; int i; JS::Rooted<JSObject*> argsObj(cx); - char *filename = NULL; + char *filename = nullptr; bool isInteractive = true; bool forceTTY = false; rcfile = fopen(rcfilename, "r"); if (rcfile) { printf("[loading '%s'...]\n", rcfilename); ProcessFile(cx, obj, rcfilename, rcfile, false); fclose(rcfile); @@ -1194,30 +1194,30 @@ ProcessArgs(JSContext *cx, JS::Handle<JS default:; } } /* * Create arguments early and define it to root it, so it's safe from any * GC calls nested below, and so it is available to -f <file> arguments. */ - argsObj = JS_NewArrayObject(cx, 0, NULL); + argsObj = JS_NewArrayObject(cx, 0, nullptr); if (!argsObj) return 1; if (!JS_DefineProperty(cx, obj, "arguments", OBJECT_TO_JSVAL(argsObj), - NULL, NULL, 0)) { + nullptr, nullptr, 0)) { return 1; } for (size_t j = 0, length = argc - i; j < length; j++) { JSString *str = JS_NewStringCopyZ(cx, argv[i++]); if (!str) return 1; if (!JS_DefineElement(cx, argsObj, j, STRING_TO_JSVAL(str), - NULL, NULL, JSPROP_ENUMERATE)) { + nullptr, nullptr, JSPROP_ENUMERATE)) { return 1; } } for (i = 0; i < argc; i++) { if (argv[i][0] != '-' || argv[i][1] == '\0') { filename = argv[i++]; isInteractive = false; @@ -1406,17 +1406,17 @@ ContextCallback(JSContext *cx, unsigned static bool GetCurrentWorkingDirectory(nsAString& workingDirectory) { #if !defined(XP_WIN) && !defined(XP_UNIX) //XXX: your platform should really implement this return false; #elif XP_WIN - DWORD requiredLength = GetCurrentDirectoryW(0, NULL); + DWORD requiredLength = GetCurrentDirectoryW(0, nullptr); workingDirectory.SetLength(requiredLength); GetCurrentDirectoryW(workingDirectory.Length(), (LPWSTR)workingDirectory.BeginWriting()); // we got a trailing null there workingDirectory.SetLength(requiredLength); workingDirectory.Replace(workingDirectory.Length() - 1, 1, L'\\'); #elif defined(XP_UNIX) nsAutoCString cwd; @@ -1669,30 +1669,30 @@ XRE_XPCShellMain(int argc, char **argv, if (!JS_DefineFunctions(cx, glob, glob_functions) || !JS_DefineProfilingFunctions(cx, glob)) { JS_EndRequest(cx); return 1; } JS::Rooted<JSObject*> envobj(cx); - envobj = JS_DefineObject(cx, glob, "environment", &env_class, NULL, 0); + envobj = JS_DefineObject(cx, glob, "environment", &env_class, nullptr, 0); if (!envobj) { JS_EndRequest(cx); return 1; } JS_SetPrivate(envobj, envp); nsAutoString workingDirectory; if (GetCurrentWorkingDirectory(workingDirectory)) gWorkingDirectory = &workingDirectory; JS_DefineProperty(cx, glob, "__LOCATION__", JSVAL_VOID, - GetLocationProperty, NULL, 0); + GetLocationProperty, nullptr, 0); JS_AddValueRoot(cx, &sScriptedOperationCallback); result = ProcessArgs(cx, glob, argv, argc, &dirprovider); JS_RemoveValueRoot(cx, &sScriptedOperationCallback); JS_DropPrincipals(rt, gJSPrincipals); JS_SetAllNonReservedSlotsToUndefined(cx, glob); JS_GC(rt); @@ -1701,17 +1701,17 @@ XRE_XPCShellMain(int argc, char **argv, JS_GC(rt); JS_DestroyContext(cx); } // this scopes the nsCOMPtrs if (!XRE_ShutdownTestShell()) NS_ERROR("problem shutting down testshell"); // no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM - rv = NS_ShutdownXPCOM( NULL ); + rv = NS_ShutdownXPCOM( nullptr ); MOZ_ASSERT(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed"); #ifdef TEST_CALL_ON_WRAPPED_JS_AFTER_SHUTDOWN // test of late call and release (see above) JSContext* bogusCX; bogus->Peek(&bogusCX); bogus = nullptr; #endif @@ -1800,17 +1800,17 @@ XPCShellDirProvider::GetFile(const char // For xpcshell, we pretend that the update root directory is always // the same as the GRE directory, except for Windows, where we immitate // the algorithm defined in nsXREDirProvider::GetUpdateRootDir. *persistent = true; #ifdef XP_WIN char appData[MAX_PATH] = {'\0'}; char path[MAX_PATH] = {'\0'}; LPITEMIDLIST pItemIDList; - if (FAILED(SHGetSpecialFolderLocation(NULL, CSIDL_LOCAL_APPDATA, &pItemIDList)) || + if (FAILED(SHGetSpecialFolderLocation(nullptr, CSIDL_LOCAL_APPDATA, &pItemIDList)) || FAILED(SHGetPathFromIDListA(pItemIDList, appData))) { return NS_ERROR_FAILURE; } nsAutoString pathName; pathName.AssignASCII(appData); nsCOMPtr<nsIFile> localFile; nsresult rv = NS_NewLocalFile(pathName, true, getter_AddRefs(localFile)); if (NS_FAILED(rv)) {
--- a/js/xpconnect/src/XPCVariant.cpp +++ b/js/xpconnect/src/XPCVariant.cpp @@ -11,17 +11,17 @@ #include "jsfriendapi.h" #include "jsprf.h" #include "jswrapper.h" using namespace JS; using namespace mozilla; -NS_IMPL_CLASSINFO(XPCVariant, NULL, 0, XPCVARIANT_CID) +NS_IMPL_CLASSINFO(XPCVariant, nullptr, 0, XPCVARIANT_CID) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(XPCVariant) NS_INTERFACE_MAP_ENTRY(XPCVariant) NS_INTERFACE_MAP_ENTRY(nsIVariant) NS_INTERFACE_MAP_ENTRY(nsISupports) NS_IMPL_QUERY_CLASSINFO(XPCVariant) NS_INTERFACE_MAP_END NS_IMPL_CI_INTERFACE_GETTER2(XPCVariant, XPCVariant, nsIVariant)
--- a/js/xpconnect/src/XPCWrappedJS.cpp +++ b/js/xpconnect/src/XPCWrappedJS.cpp @@ -342,17 +342,17 @@ nsXPCWrappedJS::GetNewOrUsed(JS::HandleO XPCAutoLock lock(rt->GetMapLock()); map->Add(cx, root); } if (!CheckMainThreadOnly(root)) { XPCAutoLock lock(rt->GetMapLock()); map->Remove(root); - wrapper = NULL; + wrapper = nullptr; } goto return_wrapper; } else { // just a root wrapper nsXPCWrappedJSClass* rootClazz = nullptr; nsXPCWrappedJSClass::GetNewOrUsed(cx, NS_GET_IID(nsISupports), &rootClazz);
--- a/js/xpconnect/src/XPCWrappedJSClass.cpp +++ b/js/xpconnect/src/XPCWrappedJSClass.cpp @@ -71,17 +71,17 @@ AutoScriptEvaluate::~AutoScriptEvaluate( if (mState) JS_RestoreExceptionState(mJSContext, mState); else JS_ClearPendingException(mJSContext); JS_EndRequest(mJSContext); if (mErrorReporterSet) - JS_SetErrorReporter(mJSContext, NULL); + JS_SetErrorReporter(mJSContext, nullptr); } // It turns out that some errors may be not worth reporting. So, this // function is factored out to manage that. bool xpc_IsReportableErrorCode(nsresult code) { if (NS_SUCCEEDED(code)) return false; @@ -1648,21 +1648,21 @@ static const JSClass XPCOutParamClass = JS_PropertyStub, JS_DeletePropertyStub, JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, FinalizeStub, - NULL, /* checkAccess */ - NULL, /* call */ - NULL, /* hasInstance */ - NULL, /* construct */ - NULL /* trace */ + nullptr, /* checkAccess */ + nullptr, /* call */ + nullptr, /* hasInstance */ + nullptr, /* construct */ + nullptr /* trace */ }; bool xpc::IsOutObject(JSContext* cx, JSObject* obj) { return js::GetObjectJSClass(obj) == &XPCOutParamClass; }
--- a/js/xpconnect/src/XPCWrappedNative.cpp +++ b/js/xpconnect/src/XPCWrappedNative.cpp @@ -830,20 +830,21 @@ XPCWrappedNative::Destroy() nsContentUtils::DeferredFinalize(mIdentity); mIdentity = nullptr; } else { NS_RELEASE(mIdentity); } } /* - * The only time GetRuntime() will be NULL is if Destroy is called a second - * time on a wrapped native. Since we already unregistered the pointer the - * first time, there's no need to unregister again. Unregistration is safe - * the first time because mWrapper isn't used afterwards. + * The only time GetRuntime() will be nullptr is if Destroy is called a + * second time on a wrapped native. Since we already unregistered the + * pointer the first time, there's no need to unregister again. + * Unregistration is safe the first time because mWrapper isn't used + * afterwards. */ if (XPCJSRuntime *rt = GetRuntime()) { if (IsIncrementalBarrierNeeded(rt->Runtime())) IncrementalObjectBarrier(GetWrapperPreserveColor()); mWrapper.setToCrashOnTouch(); } else { MOZ_ASSERT(mWrapper.isSetToCrashOnTouch()); } @@ -1376,24 +1377,25 @@ XPCWrappedNative::ReparentWrapperIfFound aNewParent)); if (!newobj) return NS_ERROR_FAILURE; // At this point, both |flat| and |newobj| point to the same wrapped // native, which is bad, because one of them will end up finalizing // a wrapped native it does not own. |cloneGuard| ensures that if we // exit before calling clearing |flat|'s private the private of - // |newobj| will be set to NULL. |flat| will go away soon, because + // |newobj| will be set to nullptr. |flat| will go away soon, because // we swap it with another object during the transplant and let that // object die. RootedObject propertyHolder(cx); { AutoClonePrivateGuard cloneGuard(cx, flat, newobj); - propertyHolder = JS_NewObjectWithGivenProto(cx, NULL, NULL, aNewParent); + propertyHolder = JS_NewObjectWithGivenProto(cx, nullptr, nullptr, + aNewParent); if (!propertyHolder) return NS_ERROR_OUT_OF_MEMORY; if (!JS_CopyPropertiesFrom(cx, propertyHolder, flat)) return NS_ERROR_FAILURE; // Expandos from other compartments are attached to the target JS object. // Copy them over, and let the old ones die a natural death. SetWNExpandoChain(newobj, nullptr); @@ -1929,34 +1931,34 @@ XPCWrappedNative::GetSameCompartmentSecu // If we already have a wrapper, it must be what we want. if (wrapper) return wrapper; // Chrome callers don't need same-compartment security wrappers. JSCompartment *cxCompartment = js::GetContextCompartment(cx); MOZ_ASSERT(cxCompartment == js::GetObjectCompartment(flat)); if (xpc::AccessCheck::isChrome(cxCompartment)) { - MOZ_ASSERT(wrapper == NULL); + MOZ_ASSERT(wrapper == nullptr); return flat; } // Check the possibilities. Note that we need to check for null in each // case in order to distinguish between the 'no need for wrapper' and // 'wrapping failed' cases. // // NB: We don't make SOWs for remote XUL domains where XBL scopes are // disallowed. if (NeedsSOW() && xpc::AllowXBLScope(js::GetContextCompartment(cx))) { wrapper = xpc::WrapperFactory::WrapSOWObject(cx, flat); if (!wrapper) - return NULL; + return nullptr; } else if (xpc::WrapperFactory::IsComponentsObject(flat)) { wrapper = xpc::WrapperFactory::WrapComponentsObject(cx, flat); if (!wrapper) - return NULL; + return nullptr; } // If we made a wrapper, cache it and return it. if (wrapper) { SetWrapper(wrapper); return wrapper; }
--- a/js/xpconnect/src/nsDOMQS.h +++ b/js/xpconnect/src/nsDOMQS.h @@ -71,17 +71,17 @@ xpc_qsUnwrapThis<_interface>(JSContext * bool failureFatal) \ { \ nsresult rv; \ nsISupports *native = \ castNativeFromWrapper(cx, obj, _bit, \ ProtoIDAndDepth<_interface>::PrototypeID, \ ProtoIDAndDepth<_interface>::Depth, \ pThisRef, pThisVal, &rv); \ - *ppThis = NULL; /* avoids uninitialized warnings in callers */ \ + *ppThis = nullptr; /* avoids uninitialized warnings in callers */ \ if (failureFatal && !native) \ return xpc_qsThrow(cx, rv); \ *ppThis = static_cast<_interface*>(static_cast<_base*>(native)); \ return true; \ } \ \ template <> \ MOZ_ALWAYS_INLINE nsresult \
--- a/js/xpconnect/src/nsXPConnect.cpp +++ b/js/xpconnect/src/nsXPConnect.cpp @@ -1437,30 +1437,30 @@ nsXPConnect::SetDebugModeWhenPossible(bo if (!mode && allowSyncDisable) CheckForDebugMode(mRuntime->Runtime()); return NS_OK; } NS_IMETHODIMP nsXPConnect::GetTelemetryValue(JSContext *cx, jsval *rval) { - RootedObject obj(cx, JS_NewObject(cx, NULL, NULL, NULL)); + RootedObject obj(cx, JS_NewObject(cx, nullptr, nullptr, nullptr)); if (!obj) return NS_ERROR_OUT_OF_MEMORY; unsigned attrs = JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT; size_t i = JS_SetProtoCalled(cx); RootedValue v(cx, DOUBLE_TO_JSVAL(i)); - if (!JS_DefineProperty(cx, obj, "setProto", v, NULL, NULL, attrs)) + if (!JS_DefineProperty(cx, obj, "setProto", v, nullptr, nullptr, attrs)) return NS_ERROR_OUT_OF_MEMORY; i = JS_GetCustomIteratorCount(cx); v = DOUBLE_TO_JSVAL(i); - if (!JS_DefineProperty(cx, obj, "customIter", v, NULL, NULL, attrs)) + if (!JS_DefineProperty(cx, obj, "customIter", v, nullptr, nullptr, attrs)) return NS_ERROR_OUT_OF_MEMORY; *rval = OBJECT_TO_JSVAL(obj); return NS_OK; } NS_IMETHODIMP nsXPConnect::NotifyDidPaint()
--- a/js/xpconnect/src/xpcObjectHelper.h +++ b/js/xpconnect/src/xpcObjectHelper.h @@ -19,26 +19,26 @@ #include "nsIClassInfo.h" #include "nsISupports.h" #include "nsIXPCScriptable.h" #include "nsWrapperCache.h" class xpcObjectHelper { public: - xpcObjectHelper(nsISupports *aObject, nsWrapperCache *aCache = NULL) - : mCanonical(NULL) + xpcObjectHelper(nsISupports *aObject, nsWrapperCache *aCache = nullptr) + : mCanonical(nullptr) , mObject(aObject) , mCache(aCache) { if (!mCache) { if (aObject) CallQueryInterface(aObject, &mCache); else - mCache = NULL; + mCache = nullptr; } } nsISupports *Object() { return mObject; } @@ -52,17 +52,17 @@ public: } already_AddRefed<nsISupports> forgetCanonical() { MOZ_ASSERT(mCanonical, "Huh, no canonical to forget?"); if (!mCanonicalStrong) mCanonicalStrong = mCanonical; - mCanonical = NULL; + mCanonical = nullptr; return mCanonicalStrong.forget(); } nsIClassInfo *GetClassInfo() { if (mXPCClassInfo) return mXPCClassInfo; if (!mClassInfo)
--- a/js/xpconnect/src/xpcprivate.h +++ b/js/xpconnect/src/xpcprivate.h @@ -3080,29 +3080,29 @@ bool PushJSContextNoScriptContext(JSCont void PopJSContextNoScriptContext(); } /* namespace xpc */ class XPCJSContextStack { public: XPCJSContextStack() - : mSafeJSContext(NULL) + : mSafeJSContext(nullptr) { } virtual ~XPCJSContextStack(); uint32_t Count() { return mStack.Length(); } JSContext *Peek() { - return mStack.IsEmpty() ? NULL : mStack[mStack.Length() - 1].cx; + return mStack.IsEmpty() ? nullptr : mStack[mStack.Length() - 1].cx; } JSContext *GetSafeJSContext(); bool HasJSContext(JSContext *cx); const InfallibleTArray<XPCJSContextInfo>* GetStack() { return &mStack; }
--- a/js/xpconnect/src/xpcpublic.h +++ b/js/xpconnect/src/xpcpublic.h @@ -355,17 +355,17 @@ private: // This reports all the stats in |rtStats| that belong in the "explicit" tree, // (which isn't all of them). // @see ZoneStatsExtras // @see CompartmentStatsExtras nsresult ReportJSRuntimeExplicitTreeStats(const JS::RuntimeStats &rtStats, const nsACString &rtPath, nsIMemoryReporterCallback *cb, - nsISupports *closure, size_t *rtTotal = NULL); + nsISupports *closure, size_t *rtTotal = nullptr); /** * Throws an exception on cx and returns false. */ bool Throw(JSContext *cx, nsresult rv); /**
--- a/js/xpconnect/tests/components/native/xpctest_module.cpp +++ b/js/xpconnect/tests/components/native/xpctest_module.cpp @@ -24,27 +24,27 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(xpcTestObjectReadOnly) NS_GENERIC_FACTORY_CONSTRUCTOR(xpcTestObjectReadWrite) NS_GENERIC_FACTORY_CONSTRUCTOR(nsXPCTestParams) NS_DEFINE_NAMED_CID(NS_XPCTESTOBJECTREADONLY_CID); NS_DEFINE_NAMED_CID(NS_XPCTESTOBJECTREADWRITE_CID); NS_DEFINE_NAMED_CID(NS_XPCTESTPARAMS_CID); static const mozilla::Module::CIDEntry kXPCTestCIDs[] = { - { &kNS_XPCTESTOBJECTREADONLY_CID, false, NULL, xpcTestObjectReadOnlyConstructor }, - { &kNS_XPCTESTOBJECTREADWRITE_CID, false, NULL, xpcTestObjectReadWriteConstructor }, - { &kNS_XPCTESTPARAMS_CID, false, NULL, nsXPCTestParamsConstructor }, - { NULL } + { &kNS_XPCTESTOBJECTREADONLY_CID, false, nullptr, xpcTestObjectReadOnlyConstructor }, + { &kNS_XPCTESTOBJECTREADWRITE_CID, false, nullptr, xpcTestObjectReadWriteConstructor }, + { &kNS_XPCTESTPARAMS_CID, false, nullptr, nsXPCTestParamsConstructor }, + { nullptr } }; static const mozilla::Module::ContractIDEntry kXPCTestContracts[] = { { "@mozilla.org/js/xpc/test/native/ObjectReadOnly;1", &kNS_XPCTESTOBJECTREADONLY_CID }, { "@mozilla.org/js/xpc/test/native/ObjectReadWrite;1", &kNS_XPCTESTOBJECTREADWRITE_CID }, { "@mozilla.org/js/xpc/test/native/Params;1", &kNS_XPCTESTPARAMS_CID }, - { NULL } + { nullptr } }; static const mozilla::Module kXPCTestModule = { mozilla::Module::kVersion, kXPCTestCIDs, kXPCTestContracts };
--- a/js/xpconnect/wrappers/ChromeObjectWrapper.cpp +++ b/js/xpconnect/wrappers/ChromeObjectWrapper.cpp @@ -64,28 +64,28 @@ bool ChromeObjectWrapper::getPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id, JS::MutableHandle<JSPropertyDescriptor> desc, unsigned flags) { assertEnteredPolicy(cx, wrapper, id); // First, try a lookup on the base wrapper if permitted. - desc.object().set(NULL); + desc.object().set(nullptr); if (AllowedByBase(cx, wrapper, id, Wrapper::GET) && !ChromeObjectWrapperBase::getPropertyDescriptor(cx, wrapper, id, desc, flags)) { return false; } // If the property is something that can be found on a standard prototype, // prefer the one we'll get via the prototype chain in the content // compartment. if (desc.object() && PropIsFromStandardPrototype(cx, desc)) - desc.object().set(NULL); + desc.object().set(nullptr); // If we found something or have no proto, we're done. RootedObject wrapperProto(cx); if (!JS_GetPrototype(cx, wrapper, &wrapperProto)) return false; if (desc.object() || !wrapperProto) return true;
--- a/js/xpconnect/wrappers/WrapperFactory.cpp +++ b/js/xpconnect/wrappers/WrapperFactory.cpp @@ -53,17 +53,17 @@ WrapperFactory::GetXrayWaiver(JSObject * { // Object should come fully unwrapped but outerized. MOZ_ASSERT(obj == UncheckedUnwrap(obj)); MOZ_ASSERT(!js::GetObjectClass(obj)->ext.outerObject); XPCWrappedNativeScope *scope = GetObjectScope(obj); MOZ_ASSERT(scope); if (!scope->mWaiverWrapperMap) - return NULL; + return nullptr; JSObject* xrayWaiver = scope->mWaiverWrapperMap->Find(obj); if (xrayWaiver) JS::ExposeObjectToActiveJS(xrayWaiver); return xrayWaiver; } @@ -580,17 +580,17 @@ WrapperFactory::WrapSOWObject(JSContext RootedObject obj(cx, objArg); RootedObject proto(cx); // If we're not allowing XBL scopes, that means we're running as a remote // XUL domain, in which we can't have SOWs. We should never be called in // that case. MOZ_ASSERT(xpc::AllowXBLScope(js::GetContextCompartment(cx))); if (!JS_GetPrototype(cx, obj, &proto)) - return NULL; + return nullptr; JSObject *wrapperObj = Wrapper::New(cx, obj, proto, JS_GetGlobalForObject(cx, obj), &FilteringWrapper<SameCompartmentSecurityWrapper, Opaque>::singleton); return wrapperObj; } bool @@ -600,17 +600,17 @@ WrapperFactory::IsComponentsObject(JSObj return name[0] == 'n' && !strcmp(name, "nsXPCComponents"); } JSObject * WrapperFactory::WrapComponentsObject(JSContext *cx, HandleObject obj) { RootedObject proto(cx); if (!JS_GetPrototype(cx, obj, &proto)) - return NULL; + return nullptr; JSObject *wrapperObj = Wrapper::New(cx, obj, proto, JS_GetGlobalForObject(cx, obj), &FilteringWrapper<SameCompartmentSecurityWrapper, ComponentsObjectPolicy>::singleton); return wrapperObj; } bool @@ -658,17 +658,17 @@ JSObject * TransplantObject(JSContext *cx, JS::HandleObject origobj, JS::HandleObject target) { RootedObject oldWaiver(cx, WrapperFactory::GetXrayWaiver(origobj)); RootedObject newIdentity(cx, JS_TransplantObject(cx, origobj, target)); if (!newIdentity || !oldWaiver) return newIdentity; if (!FixWaiverAfterTransplant(cx, oldWaiver, newIdentity)) - return NULL; + return nullptr; return newIdentity; } JSObject * TransplantObjectWithWrapper(JSContext *cx, HandleObject origobj, HandleObject origwrapper, HandleObject targetobj, HandleObject targetwrapper) { @@ -677,17 +677,17 @@ TransplantObjectWithWrapper(JSContext *c js_TransplantObjectWithWrapper(cx, origobj, origwrapper, targetobj, targetwrapper)); if (!newSameCompartmentWrapper || !oldWaiver) return newSameCompartmentWrapper; RootedObject newIdentity(cx, Wrapper::wrappedObject(newSameCompartmentWrapper)); MOZ_ASSERT(!js::IsWrapper(newIdentity)); if (!FixWaiverAfterTransplant(cx, oldWaiver, newIdentity)) - return NULL; + return nullptr; return newSameCompartmentWrapper; } nsIGlobalObject * GetNativeForGlobal(JSObject *obj) { MOZ_ASSERT(JS_IsGlobalObject(obj)); if (!EnsureCompartmentPrivate(obj)->scope)
--- a/js/xpconnect/wrappers/XrayWrapper.cpp +++ b/js/xpconnect/wrappers/XrayWrapper.cpp @@ -375,17 +375,17 @@ XrayTraits::getExpandoObjectInternal(JSC nsIPrincipal *origin, JSObject *exclusiveGlobalArg) { // The expando object lives in the compartment of the target, so all our // work needs to happen there. RootedObject exclusiveGlobal(cx, exclusiveGlobalArg); JSAutoCompartment ac(cx, target); if (!JS_WrapObject(cx, exclusiveGlobal.address())) - return NULL; + return nullptr; // Iterate through the chain, looking for a same-origin object. RootedObject head(cx, getExpandoChain(target)); while (head) { if (expandoObjectMatchesConsumer(cx, head, origin, exclusiveGlobal)) return head; head = JS_GetReservedSlot(head, JSSLOT_EXPANDO_NEXT).toObjectOrNull(); } @@ -453,17 +453,17 @@ XrayTraits::ensureExpandoObject(JSContex // If the object is a sandbox, we don't want it to share expandos with // anyone else, so we tag it with the sandbox global. // // NB: We first need to check the class, _then_ wrap for the target's // compartment. RootedObject consumerGlobal(cx, js::GetGlobalForObjectCrossCompartment(wrapper)); bool isSandbox = !strcmp(js::GetObjectJSClass(consumerGlobal)->name, "Sandbox"); if (!JS_WrapObject(cx, consumerGlobal.address())) - return NULL; + return nullptr; expandoObject = attachExpandoObject(cx, target, ObjectPrincipal(wrapper), isSandbox ? (HandleObject)consumerGlobal : NullPtr()); } return expandoObject; } bool XrayTraits::cloneExpandoChain(JSContext *cx, HandleObject dst, HandleObject src) @@ -692,17 +692,17 @@ XPCWrappedNativeXrayTraits::preserveWrap bool XPCWrappedNativeXrayTraits::resolveNativeProperty(JSContext *cx, HandleObject wrapper, HandleObject holder, HandleId id, MutableHandle<JSPropertyDescriptor> desc, unsigned flags) { MOZ_ASSERT(js::GetObjectJSClass(holder) == &HolderClass); - desc.object().set(NULL); + desc.object().set(nullptr); // This will do verification and the method lookup for us. RootedObject target(cx, getTargetObject(wrapper)); XPCCallContext ccx(JS_CALLER, cx, target, NullPtr(), id); // There are no native numeric properties, so we can shortcut here. We will // not find the property. However we want to support non shadowing dom // specific collection properties like window.frames, so we still have to @@ -723,18 +723,18 @@ XPCWrappedNativeXrayTraits::resolveNativ } else if (!(iface = ccx.GetInterface()) || !(member = ccx.GetMember())) { /* Not found */ return resolveDOMCollectionProperty(cx, wrapper, holder, id, desc, flags); } desc.object().set(holder); desc.setAttributes(JSPROP_ENUMERATE); - desc.setGetter(NULL); - desc.setSetter(NULL); + desc.setGetter(nullptr); + desc.setSetter(nullptr); desc.setShortId(0); desc.value().set(JSVAL_VOID); RootedValue fval(cx, JSVAL_VOID); if (member->IsConstant()) { if (!member->GetConstantValue(ccx, iface, desc.value().address())) { JS_ReportError(cx, "Failed to convert constant native property to JS value"); return false; @@ -796,17 +796,17 @@ wrappedJSObject_getter(JSContext *cx, Ha return WrapperFactory::WaiveXrayAndWrap(cx, vp.address()); } bool XrayTraits::resolveOwnProperty(JSContext *cx, Wrapper &jsWrapper, HandleObject wrapper, HandleObject holder, HandleId id, MutableHandle<JSPropertyDescriptor> desc, unsigned flags) { - desc.object().set(NULL); + desc.object().set(nullptr); RootedObject target(cx, getTargetObject(wrapper)); RootedObject expando(cx, getExpandoObject(cx, target, wrapper)); // Check for expando properties first. Note that the expando object lives // in the target compartment. if (expando) { JSAutoCompartment ac(cx, expando); if (!JS_GetPropertyDescriptorById(cx, expando, id, 0, desc)) @@ -964,17 +964,17 @@ JSObject * XPCWrappedNativeXrayTraits::createHolder(JSContext *cx, JSObject *wrapper) { JSObject *global = JS_GetGlobalForObject(cx, wrapper); JSObject *holder = JS_NewObjectWithGivenProto(cx, &HolderClass, nullptr, global); if (!holder) return nullptr; - js::SetReservedSlot(holder, JSSLOT_RESOLVING, PrivateValue(NULL)); + js::SetReservedSlot(holder, JSSLOT_RESOLVING, PrivateValue(nullptr)); return holder; } bool XPCWrappedNativeXrayTraits::call(JSContext *cx, HandleObject wrapper, const JS::CallArgs &args, js::Wrapper& baseInstance) { @@ -1325,30 +1325,30 @@ XrayWrapper<Base, Traits>::isExtensible( return true; } template <typename Base, typename Traits> bool XrayWrapper<Base, Traits>::preventExtensions(JSContext *cx, HandleObject wrapper) { // See above. - JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_CHANGE_EXTENSIBILITY); + JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_CHANGE_EXTENSIBILITY); return false; } template <typename Base, typename Traits> bool XrayWrapper<Base, Traits>::getPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id, JS::MutableHandle<JSPropertyDescriptor> desc, unsigned flags) { assertEnteredPolicy(cx, wrapper, id); RootedObject holder(cx, Traits::singleton.ensureHolder(cx, wrapper)); if (Traits::isResolving(cx, holder, id)) { - desc.object().set(NULL); + desc.object().set(nullptr); return true; } typename Traits::ResolvingIdImpl resolving(cx, wrapper, id); if (!holder) return false; @@ -1356,17 +1356,17 @@ XrayWrapper<Base, Traits>::getPropertyDe // get .wrappedJSObject. We can check this by determining if the compartment // of the wrapper subsumes that of the wrappee. XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance(); if (AccessCheck::wrapperSubsumes(wrapper) && id == rt->GetStringID(XPCJSRuntime::IDX_WRAPPED_JSOBJECT)) { desc.object().set(wrapper); desc.setAttributes(JSPROP_ENUMERATE|JSPROP_SHARED); desc.setGetter(wrappedJSObject_getter); - desc.setSetter(NULL); + desc.setSetter(nullptr); desc.setShortId(0); desc.value().set(JSVAL_VOID); return true; } // Ordering is important here. // // We first need to call resolveOwnProperty, even before checking the holder, @@ -1431,18 +1431,18 @@ XrayWrapper<Base, Traits>::getPropertyDe { JSFunction *toString = JS_NewFunction(cx, XrayToString, 0, 0, holder, "toString"); if (!toString) return false; desc.object().set(wrapper); desc.setAttributes(0); - desc.setGetter(NULL); - desc.setSetter(NULL); + desc.setGetter(nullptr); + desc.setSetter(nullptr); desc.setShortId(0); desc.value().setObject(*JS_GetFunctionObject(toString)); } // If we're a special scope for in-content XBL, our script expects to see // the bound XBL methods and attributes when accessing content. However, // these members are implemented in content via custom-spliced prototypes, // and thus aren't visible through Xray wrappers unless we handle them @@ -1485,17 +1485,17 @@ template <typename Base, typename Traits bool XrayWrapper<Base, Traits>::getOwnPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id, JS::MutableHandle<JSPropertyDescriptor> desc, unsigned flags) { assertEnteredPolicy(cx, wrapper, id); RootedObject holder(cx, Traits::singleton.ensureHolder(cx, wrapper)); if (Traits::isResolving(cx, holder, id)) { - desc.object().set(NULL); + desc.object().set(nullptr); return true; } typename Traits::ResolvingIdImpl resolving(cx, wrapper, id); // NB: Nothing we do here acts on the wrapped native itself, so we don't // enter our policy.