Bug 784739 - Switch from NULL to nullptr in js/xpconnect/; r=ehsan

This commit is contained in:
Birunthan Mohanathas 2013-10-10 16:35:53 -04:00
parent 702caab246
commit 0fe811f2b7
26 changed files with 141 additions and 138 deletions

View File

@ -408,12 +408,12 @@ mozJSComponentLoader::LoadModule(FileLocation &aFile)
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;
@ -427,18 +427,18 @@ mozJSComponentLoader::LoadModule(FileLocation &aFile)
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);
@ -453,7 +453,7 @@ mozJSComponentLoader::LoadModule(FileLocation &aFile)
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();
@ -461,7 +461,7 @@ mozJSComponentLoader::LoadModule(FileLocation &aFile)
#ifdef DEBUG_shaver
fprintf(stderr, "GetJSObject of ComponentManager failed\n");
#endif
return NULL;
return nullptr;
}
nsCOMPtr<nsIXPConnectJSObjectHolder> file_holder;
@ -470,12 +470,12 @@ mozJSComponentLoader::LoadModule(FileLocation &aFile)
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);
@ -483,7 +483,7 @@ mozJSComponentLoader::LoadModule(FileLocation &aFile)
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) {
@ -491,14 +491,14 @@ mozJSComponentLoader::LoadModule(FileLocation &aFile)
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,
@ -508,7 +508,7 @@ mozJSComponentLoader::LoadModule(FileLocation &aFile)
#ifdef DEBUG
fprintf(stderr, "mJCL: couldn't get nsIModule from jsval\n");
#endif
return NULL;
return nullptr;
}
// Cache this module for later
@ -992,7 +992,7 @@ mozJSComponentLoader::ObjectForLocation(nsIFile *aComponentFile,
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);
@ -1050,7 +1050,7 @@ mozJSComponentLoader::UnloadModules()
mImports.Clear();
mThisObjects.Clear();
mModules.Enumerate(ClearModules, NULL);
mModules.Enumerate(ClearModules, nullptr);
JS_DestroyContextNoGC(mContext);
mContext = nullptr;

View File

@ -87,12 +87,12 @@ class mozJSComponentLoader : public mozilla::ModuleLoader,
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;
@ -103,7 +103,7 @@ class mozJSComponentLoader : public mozilla::ModuleLoader,
}
void Clear() {
getfactoryobj = NULL;
getfactoryobj = nullptr;
if (obj) {
JSAutoRequest ar(sSelf->mContext);
@ -117,8 +117,8 @@ class mozJSComponentLoader : public mozilla::ModuleLoader,
if (location)
NS_Free(location);
obj = NULL;
location = NULL;
obj = nullptr;
location = nullptr;
}
static already_AddRefed<nsIFactory> GetFactory(const mozilla::Module& module,

View File

@ -39,7 +39,7 @@ public:
void ForgetGlobalObject()
{
mGlobalJSObject = NULL;
mGlobalJSObject = nullptr;
}
private:
nsCOMPtr<nsIPrincipal> mPrincipal;

View File

@ -32,7 +32,7 @@ public:
}
virtual void ForgetGlobalObject() {
mGlobal = NULL;
mGlobal = nullptr;
}
virtual void SetGlobalObject(JSObject* global) {

View File

@ -596,7 +596,7 @@ static const JSClass SandboxClass = {
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[] = {
@ -1152,7 +1152,7 @@ static nsresult
GetPrincipalOrSOP(JSContext *cx, HandleObject from, nsISupports **out)
{
MOZ_ASSERT(out);
*out = NULL;
*out = nullptr;
nsXPConnect* xpc = nsXPConnect::XPConnect();
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
@ -1293,7 +1293,7 @@ GetObjPropFromOptions(JSContext *cx, HandleObject from, const char *name, JSObje
NS_ENSURE_SUCCESS(rv, rv);
if (!found) {
*prop = NULL;
*prop = nullptr;
return NS_OK;
}
@ -1725,7 +1725,7 @@ xpc::SetSandboxMetadata(JSContext *cx, HandleObject sandbox, HandleValue metadat
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);

View File

@ -1796,8 +1796,8 @@ struct MOZ_STACK_CLASS ExceptionArgParser
* 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).
@ -2910,7 +2910,7 @@ class PreciseGCRunnable : public nsRunnable
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);
}
@ -3049,7 +3049,7 @@ nsXPCComponents_Utils::CreateArrayIn(const Value &vobj, JSContext *cx, Value *rv
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;
}
@ -3149,7 +3149,7 @@ 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)

View File

@ -128,7 +128,7 @@ const JSClass xpc::SafeJSContextGlobalClass = {
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*

View File

@ -266,7 +266,7 @@ 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()
{
@ -707,9 +707,9 @@ GetIIDArg(uint32_t argc, const JS::Value& val, JSContext* cx)
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;

View File

@ -1752,7 +1752,7 @@ 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;
@ -1936,7 +1936,7 @@ 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/");
@ -2819,7 +2819,8 @@ ReadSourceFromFilename(JSContext *cx, const char *filename, jschar **src, size_t
}
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.
@ -2837,7 +2838,7 @@ ReadSourceFromFilename(JSContext *cx, const char *filename, jschar **src, size_t
// 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())

View File

@ -119,9 +119,9 @@ Native2WrappedNativeMap::newMap(int 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;
}
@ -291,9 +291,9 @@ ClassInfo2WrappedNativeProtoMap::newMap(int 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;
}

View File

@ -36,11 +36,11 @@ 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 }, \

View File

@ -264,7 +264,7 @@ xpc_qsThrowGetterSetterFailed(JSContext *cx, nsresult rv, JSObject *obj,
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
@ -294,7 +294,7 @@ 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
@ -347,7 +347,7 @@ 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
@ -370,7 +370,7 @@ xpc_qsThrowBadSetterValue(JSContext *cx, nsresult rv,
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
@ -399,7 +399,7 @@ xpc_qsGetterOnlyPropertyStub(JSContext *cx, HandleObject obj, HandleId id, bool
return JS_ReportErrorFlagsAndNumber(cx,
JSREPORT_WARNING | JSREPORT_STRICT |
JSREPORT_STRICT_MODE_ERROR,
js_GetErrorMessage, NULL,
js_GetErrorMessage, nullptr,
JSMSG_GETTER_ONLY);
}
@ -409,7 +409,7 @@ 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);
}
@ -766,7 +766,7 @@ xpc_qsJsvalToWcharStr(JSContext *cx, jsval v, jsval *pval, const PRUnichar **pst
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)))

View File

@ -101,9 +101,9 @@ static const char kXPConnectServiceContractID[] = "@mozilla.org/js/xpc/XPConnect
#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;
@ -122,7 +122,7 @@ GetLocationProperty(JSContext *cx, HandleObject obj, HandleId id, MutableHandleV
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) {
@ -133,7 +133,7 @@ GetLocationProperty(JSContext *cx, HandleObject obj, HandleId id, MutableHandleV
#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,
@ -432,11 +432,11 @@ GCZeal(JSContext *cx, unsigned argc, jsval *vp)
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;
@ -567,7 +567,7 @@ MapContextOptionNameToFlag(JSContext* cx, const char* name)
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) {
@ -614,7 +614,7 @@ Options(JSContext *cx, unsigned argc, jsval *vp)
}
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) {
@ -909,7 +909,7 @@ env_enumerate(JSContext *cx, HandleObject obj)
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;
@ -919,7 +919,7 @@ env_enumerate(JSContext *cx, HandleObject obj)
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)
@ -952,7 +952,7 @@ env_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
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);
@ -989,7 +989,7 @@ 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];
}
@ -1077,7 +1077,7 @@ ProcessFile(JSContext *cx, JS::Handle<JSObject*> obj, const char *filename, FILE
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;
@ -1104,7 +1104,7 @@ Process(JSContext *cx, JS::Handle<JSObject*> obj, const char *filename, bool for
} 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;
@ -1163,7 +1163,7 @@ ProcessArgs(JSContext *cx, JS::Handle<JSObject*> obj, char **argv, int argc, XPC
FILE *rcfile;
int i;
JS::Rooted<JSObject*> argsObj(cx);
char *filename = NULL;
char *filename = nullptr;
bool isInteractive = true;
bool forceTTY = false;
@ -1199,11 +1199,11 @@ ProcessArgs(JSContext *cx, JS::Handle<JSObject*> obj, char **argv, int argc, XPC
* 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;
}
@ -1212,7 +1212,7 @@ ProcessArgs(JSContext *cx, JS::Handle<JSObject*> obj, char **argv, int argc, XPC
if (!str)
return 1;
if (!JS_DefineElement(cx, argsObj, j, STRING_TO_JSVAL(str),
NULL, NULL, JSPROP_ENUMERATE)) {
nullptr, nullptr, JSPROP_ENUMERATE)) {
return 1;
}
}
@ -1411,7 +1411,7 @@ GetCurrentWorkingDirectory(nsAString& workingDirectory)
//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());
@ -1674,7 +1674,7 @@ XRE_XPCShellMain(int argc, char **argv, char **envp)
}
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;
@ -1687,7 +1687,7 @@ XRE_XPCShellMain(int argc, char **argv, char **envp)
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);
@ -1706,7 +1706,7 @@ XRE_XPCShellMain(int argc, char **argv, char **envp)
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
@ -1805,7 +1805,7 @@ XPCShellDirProvider::GetFile(const char *prop, bool *persistent,
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;
}

View File

@ -16,7 +16,7 @@
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)

View File

@ -347,7 +347,7 @@ nsXPCWrappedJS::GetNewOrUsed(JS::HandleObject jsObj,
XPCAutoLock lock(rt->GetMapLock());
map->Remove(root);
wrapper = NULL;
wrapper = nullptr;
}
goto return_wrapper;

View File

@ -76,7 +76,7 @@ AutoScriptEvaluate::~AutoScriptEvaluate()
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
@ -1653,11 +1653,11 @@ static const JSClass XPCOutParamClass = {
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

View File

@ -835,10 +835,11 @@ XPCWrappedNative::Destroy()
}
/*
* 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()))
@ -1381,14 +1382,15 @@ XPCWrappedNative::ReparentWrapperIfFound(XPCWrappedNativeScope* aOldScope,
// 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))
@ -1934,7 +1936,7 @@ XPCWrappedNative::GetSameCompartmentSecurityWrapper(JSContext *cx)
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;
}
@ -1947,11 +1949,11 @@ XPCWrappedNative::GetSameCompartmentSecurityWrapper(JSContext *cx)
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.

View File

@ -76,7 +76,7 @@ xpc_qsUnwrapThis<_interface>(JSContext *cx, \
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)); \

View File

@ -1442,7 +1442,7 @@ nsXPConnect::SetDebugModeWhenPossible(bool mode, bool allowSyncDisable)
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;
@ -1450,12 +1450,12 @@ nsXPConnect::GetTelemetryValue(JSContext *cx, jsval *rval)
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);

View File

@ -24,8 +24,8 @@
class xpcObjectHelper
{
public:
xpcObjectHelper(nsISupports *aObject, nsWrapperCache *aCache = NULL)
: mCanonical(NULL)
xpcObjectHelper(nsISupports *aObject, nsWrapperCache *aCache = nullptr)
: mCanonical(nullptr)
, mObject(aObject)
, mCache(aCache)
{
@ -33,7 +33,7 @@ public:
if (aObject)
CallQueryInterface(aObject, &mCache);
else
mCache = NULL;
mCache = nullptr;
}
}
@ -57,7 +57,7 @@ public:
if (!mCanonicalStrong)
mCanonicalStrong = mCanonical;
mCanonical = NULL;
mCanonical = nullptr;
return mCanonicalStrong.forget();
}

View File

@ -3085,7 +3085,7 @@ class XPCJSContextStack
{
public:
XPCJSContextStack()
: mSafeJSContext(NULL)
: mSafeJSContext(nullptr)
{ }
virtual ~XPCJSContextStack();
@ -3097,7 +3097,7 @@ public:
JSContext *Peek()
{
return mStack.IsEmpty() ? NULL : mStack[mStack.Length() - 1].cx;
return mStack.IsEmpty() ? nullptr : mStack[mStack.Length() - 1].cx;
}
JSContext *GetSafeJSContext();

View File

@ -360,7 +360,7 @@ 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.

View File

@ -29,17 +29,17 @@ 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 = {

View File

@ -69,7 +69,7 @@ ChromeObjectWrapper::getPropertyDescriptor(JSContext *cx,
{
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)) {
@ -80,7 +80,7 @@ ChromeObjectWrapper::getPropertyDescriptor(JSContext *cx,
// 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);

View File

@ -58,7 +58,7 @@ WrapperFactory::GetXrayWaiver(JSObject *obj)
MOZ_ASSERT(scope);
if (!scope->mWaiverWrapperMap)
return NULL;
return nullptr;
JSObject* xrayWaiver = scope->mWaiverWrapperMap->Find(obj);
if (xrayWaiver)
@ -585,7 +585,7 @@ WrapperFactory::WrapSOWObject(JSContext *cx, JSObject *objArg)
// 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,
@ -605,7 +605,7 @@ 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);
@ -663,7 +663,7 @@ TransplantObject(JSContext *cx, JS::HandleObject origobj, JS::HandleObject targe
return newIdentity;
if (!FixWaiverAfterTransplant(cx, oldWaiver, newIdentity))
return NULL;
return nullptr;
return newIdentity;
}
@ -682,7 +682,7 @@ TransplantObjectWithWrapper(JSContext *cx,
RootedObject newIdentity(cx, Wrapper::wrappedObject(newSameCompartmentWrapper));
MOZ_ASSERT(!js::IsWrapper(newIdentity));
if (!FixWaiverAfterTransplant(cx, oldWaiver, newIdentity))
return NULL;
return nullptr;
return newSameCompartmentWrapper;
}

View File

@ -380,7 +380,7 @@ XrayTraits::getExpandoObjectInternal(JSContext *cx, HandleObject target,
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));
@ -458,7 +458,7 @@ XrayTraits::ensureExpandoObject(JSContext *cx, HandleObject wrapper,
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());
}
@ -697,7 +697,7 @@ XPCWrappedNativeXrayTraits::resolveNativeProperty(JSContext *cx, HandleObject wr
{
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));
@ -728,8 +728,8 @@ XPCWrappedNativeXrayTraits::resolveNativeProperty(JSContext *cx, HandleObject wr
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);
@ -801,7 +801,7 @@ 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));
@ -969,7 +969,7 @@ XPCWrappedNativeXrayTraits::createHolder(JSContext *cx, JSObject *wrapper)
if (!holder)
return nullptr;
js::SetReservedSlot(holder, JSSLOT_RESOLVING, PrivateValue(NULL));
js::SetReservedSlot(holder, JSSLOT_RESOLVING, PrivateValue(nullptr));
return holder;
}
@ -1330,7 +1330,7 @@ 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;
}
@ -1343,7 +1343,7 @@ XrayWrapper<Base, Traits>::getPropertyDescriptor(JSContext *cx, HandleObject wra
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;
}
@ -1361,7 +1361,7 @@ XrayWrapper<Base, Traits>::getPropertyDescriptor(JSContext *cx, HandleObject wra
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;
@ -1436,8 +1436,8 @@ XrayWrapper<Base, Traits>::getPropertyDescriptor(JSContext *cx, HandleObject wra
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));
}
@ -1490,7 +1490,7 @@ XrayWrapper<Base, Traits>::getOwnPropertyDescriptor(JSContext *cx, HandleObject
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;
}