mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 784739 - Switch from NULL to nullptr in js/src/ (3/9); r=ehsan
--HG-- extra : rebase_source : b6d78b3404dc885c6f559080076bbfee9acf76a2
This commit is contained in:
parent
efaf223567
commit
4715f43b1c
105
js/src/jsexn.cpp
105
js/src/jsexn.cpp
@ -66,10 +66,10 @@ const Class ErrorObject::class_ = {
|
||||
(JSResolveOp)exn_resolve,
|
||||
JS_ConvertStub,
|
||||
exn_finalize,
|
||||
NULL, /* checkAccess */
|
||||
NULL, /* call */
|
||||
NULL, /* hasInstance */
|
||||
NULL, /* construct */
|
||||
nullptr, /* checkAccess */
|
||||
nullptr, /* call */
|
||||
nullptr, /* hasInstance */
|
||||
nullptr, /* construct */
|
||||
exn_trace
|
||||
};
|
||||
|
||||
@ -156,7 +156,7 @@ CopyErrorReport(JSContext *cx, JSErrorReport *report)
|
||||
ucmessageSize + uclinebufSize + linebufSize + filenameSize;
|
||||
cursor = cx->pod_malloc<uint8_t>(mallocSize);
|
||||
if (!cursor)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
copy = (JSErrorReport *)cursor;
|
||||
memset(cursor, 0, sizeof(JSErrorReport));
|
||||
@ -171,7 +171,7 @@ CopyErrorReport(JSContext *cx, JSErrorReport *report)
|
||||
js_memcpy(cursor, report->messageArgs[i], argSize);
|
||||
cursor += argSize;
|
||||
}
|
||||
copy->messageArgs[i] = NULL;
|
||||
copy->messageArgs[i] = nullptr;
|
||||
JS_ASSERT(cursor == (uint8_t *)copy->messageArgs[0] + argsCopySize);
|
||||
}
|
||||
|
||||
@ -231,7 +231,7 @@ struct SuppressErrorsGuard
|
||||
|
||||
SuppressErrorsGuard(JSContext *cx)
|
||||
: cx(cx),
|
||||
prevReporter(JS_SetErrorReporter(cx, NULL)),
|
||||
prevReporter(JS_SetErrorReporter(cx, nullptr)),
|
||||
prevState(JS_SaveExceptionState(cx))
|
||||
{}
|
||||
|
||||
@ -274,11 +274,11 @@ InitExnPrivate(JSContext *cx, HandleObject exnObject, HandleString message,
|
||||
JSStackTraceStackElem &frame = frames.back();
|
||||
if (i.isNonEvalFunctionFrame()) {
|
||||
JSAtom *atom = i.callee()->displayAtom();
|
||||
if (atom == NULL)
|
||||
if (atom == nullptr)
|
||||
atom = cx->runtime()->emptyString;
|
||||
frame.funName = atom;
|
||||
} else {
|
||||
frame.funName = NULL;
|
||||
frame.funName = nullptr;
|
||||
}
|
||||
RootedScript script(cx, i.script());
|
||||
const char *cfilename = script->filename();
|
||||
@ -315,7 +315,7 @@ InitExnPrivate(JSContext *cx, HandleObject exnObject, HandleString message,
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
priv->errorReport = NULL;
|
||||
priv->errorReport = nullptr;
|
||||
}
|
||||
|
||||
priv->message.init(message);
|
||||
@ -390,7 +390,7 @@ exn_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
|
||||
jsval v;
|
||||
unsigned attrs;
|
||||
|
||||
objp.set(NULL);
|
||||
objp.set(nullptr);
|
||||
priv = obj->as<ErrorObject>().getExnPrivate();
|
||||
if (priv && JSID_IS_ATOM(id)) {
|
||||
RootedString str(cx, JSID_TO_STRING(id));
|
||||
@ -451,7 +451,7 @@ exn_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
|
||||
return true;
|
||||
|
||||
define:
|
||||
if (!JS_DefineProperty(cx, obj, prop, v, NULL, NULL, attrs))
|
||||
if (!JS_DefineProperty(cx, obj, prop, v, nullptr, nullptr, attrs))
|
||||
return false;
|
||||
objp.set(obj);
|
||||
return true;
|
||||
@ -461,7 +461,7 @@ JSErrorReport *
|
||||
js_ErrorFromException(jsval exn)
|
||||
{
|
||||
if (JSVAL_IS_PRIMITIVE(exn))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
// It's ok to UncheckedUnwrap here, since all we do is get the
|
||||
// JSErrorReport, and consumers are careful with the information they get
|
||||
@ -471,11 +471,11 @@ js_ErrorFromException(jsval exn)
|
||||
// will fail if they can't unwrap it.
|
||||
JSObject *obj = UncheckedUnwrap(JSVAL_TO_OBJECT(exn));
|
||||
if (!obj->is<ErrorObject>())
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
JSExnPrivate *priv = obj->as<ErrorObject>().getExnPrivate();
|
||||
if (!priv)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
return priv->errorReport;
|
||||
}
|
||||
@ -497,18 +497,18 @@ StackTraceToString(JSContext *cx, JSExnPrivate *priv)
|
||||
|
||||
if (element->funName) {
|
||||
if (!sb.append(element->funName))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (!sb.append('@'))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
if (element->filename) {
|
||||
if (!sb.appendInflated(element->filename, strlen(element->filename)))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (!sb.append(':') || !NumberValueToStringBuffer(cx, NumberValue(element->ulineno), sb) ||
|
||||
!sb.append('\n'))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -541,12 +541,12 @@ Exception(JSContext *cx, unsigned argc, Value *vp)
|
||||
return false;
|
||||
|
||||
if (!protov.isObject()) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_BAD_PROTOTYPE, "Error");
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_PROTOTYPE, "Error");
|
||||
return false;
|
||||
}
|
||||
|
||||
RootedObject obj(cx, NewObjectWithGivenProto(cx, &ErrorObject::class_, &protov.toObject(),
|
||||
NULL));
|
||||
nullptr));
|
||||
if (!obj)
|
||||
return false;
|
||||
|
||||
@ -558,14 +558,14 @@ Exception(JSContext *cx, unsigned argc, Value *vp)
|
||||
return false;
|
||||
args[0].setString(message);
|
||||
} else {
|
||||
message = NULL;
|
||||
message = nullptr;
|
||||
}
|
||||
|
||||
/* Find the scripted caller. */
|
||||
NonBuiltinScriptFrameIter iter(cx);
|
||||
|
||||
/* Set the 'fileName' property. */
|
||||
RootedScript script(cx, iter.done() ? NULL : iter.script());
|
||||
RootedScript script(cx, iter.done() ? nullptr : iter.script());
|
||||
RootedString filename(cx);
|
||||
if (args.length() > 1) {
|
||||
filename = ToString<CanGC>(cx, args[1]);
|
||||
@ -593,7 +593,7 @@ Exception(JSContext *cx, unsigned argc, Value *vp)
|
||||
}
|
||||
|
||||
int exnType = args.callee().as<JSFunction>().getExtendedSlot(0).toInt32();
|
||||
if (!InitExnPrivate(cx, obj, message, filename, lineno, column, NULL, exnType))
|
||||
if (!InitExnPrivate(cx, obj, message, filename, lineno, column, nullptr, exnType))
|
||||
return false;
|
||||
|
||||
args.rval().setObject(*obj);
|
||||
@ -609,7 +609,7 @@ exn_toString(JSContext *cx, unsigned argc, Value *vp)
|
||||
|
||||
/* Step 2. */
|
||||
if (!args.thisv().isObject()) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_BAD_PROTOTYPE, "Error");
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_PROTOTYPE, "Error");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -782,7 +782,7 @@ InitErrorClass(JSContext *cx, Handle<GlobalObject*> global, int type, HandleObje
|
||||
RootedObject errorProto(cx, global->createBlankPrototypeInheriting(cx, &ErrorObject::class_,
|
||||
*proto));
|
||||
if (!errorProto)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
RootedValue nameValue(cx, StringValue(name));
|
||||
RootedValue zeroValue(cx, Int32Value(0));
|
||||
@ -803,21 +803,21 @@ InitErrorClass(JSContext *cx, Handle<GlobalObject*> global, int type, HandleObje
|
||||
!DefineNativeProperty(cx, errorProto, columnNumberId, zeroValue,
|
||||
JS_PropertyStub, JS_StrictPropertyStub, JSPROP_ENUMERATE, 0, 0))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* Create the corresponding constructor. */
|
||||
RootedFunction ctor(cx, global->createConstructor(cx, Exception, name, 1,
|
||||
JSFunction::ExtendedFinalizeKind));
|
||||
if (!ctor)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
ctor->setExtendedSlot(0, Int32Value(int32_t(type)));
|
||||
|
||||
if (!LinkConstructorAndPrototype(cx, ctor, errorProto))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
if (!DefineConstructorAndPrototype(cx, global, key, ctor, errorProto))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
JS_ASSERT(!errorProto->getPrivate());
|
||||
|
||||
@ -834,21 +834,21 @@ js_InitExceptionClasses(JSContext *cx, HandleObject obj)
|
||||
|
||||
RootedObject objectProto(cx, global->getOrCreateObjectPrototype(cx));
|
||||
if (!objectProto)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
/* Initialize the base Error class first. */
|
||||
RootedObject errorProto(cx, InitErrorClass(cx, global, JSEXN_ERR, objectProto));
|
||||
if (!errorProto)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
/* |Error.prototype| alone has method properties. */
|
||||
if (!DefinePropertiesAndBrand(cx, errorProto, NULL, exception_methods))
|
||||
return NULL;
|
||||
if (!DefinePropertiesAndBrand(cx, errorProto, nullptr, exception_methods))
|
||||
return nullptr;
|
||||
|
||||
/* Define all remaining *Error constructors. */
|
||||
for (int i = JSEXN_ERR + 1; i < JSEXN_LIMIT; i++) {
|
||||
if (!InitErrorClass(cx, global, i, errorProto))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return errorProto;
|
||||
@ -858,11 +858,11 @@ const JSErrorFormatString*
|
||||
js_GetLocalizedErrorMessage(ExclusiveContext *cx, void *userRef, const char *locale,
|
||||
const unsigned errorNumber)
|
||||
{
|
||||
const JSErrorFormatString *errorString = NULL;
|
||||
const JSErrorFormatString *errorString = nullptr;
|
||||
|
||||
// The locale callbacks might not be thread safe, so don't call them if
|
||||
// we're not on the main thread. When used with XPConnect,
|
||||
// |localeGetErrorMessage| will be NULL anyways.
|
||||
// |localeGetErrorMessage| will be nullptr anyways.
|
||||
if (cx->isJSContext() &&
|
||||
cx->asJSContext()->runtime()->localeCallbacks &&
|
||||
cx->asJSContext()->runtime()->localeCallbacks->localeGetErrorMessage)
|
||||
@ -886,7 +886,7 @@ js::GetErrorTypeName(JSRuntime* rt, int16_t exnType)
|
||||
if (exnType <= JSEXN_NONE || exnType >= JSEXN_LIMIT ||
|
||||
exnType == JSEXN_INTERNALERR)
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
JSProtoKey key = GetExceptionProtoKey(exnType);
|
||||
return ClassName(key, rt)->chars();
|
||||
@ -921,9 +921,9 @@ js_ErrorToException(JSContext *cx, const char *message, JSErrorReport *reportp,
|
||||
/* Find the exception index associated with this error. */
|
||||
errorNumber = (JSErrNum) reportp->errorNumber;
|
||||
if (!callback || callback == js_GetErrorMessage)
|
||||
errorString = js_GetLocalizedErrorMessage(cx, NULL, NULL, errorNumber);
|
||||
errorString = js_GetLocalizedErrorMessage(cx, nullptr, nullptr, errorNumber);
|
||||
else
|
||||
errorString = callback(userRef, NULL, errorNumber);
|
||||
errorString = callback(userRef, nullptr, errorNumber);
|
||||
exn = errorString ? (JSExnType) errorString->exnType : JSEXN_NONE;
|
||||
JS_ASSERT(exn < JSEXN_LIMIT);
|
||||
|
||||
@ -960,7 +960,8 @@ js_ErrorToException(JSContext *cx, const char *message, JSErrorReport *reportp,
|
||||
return false;
|
||||
tv[0] = OBJECT_TO_JSVAL(errProto);
|
||||
|
||||
RootedObject errObject(cx, NewObjectWithGivenProto(cx, &ErrorObject::class_, errProto, NULL));
|
||||
RootedObject errObject(cx, NewObjectWithGivenProto(cx, &ErrorObject::class_,
|
||||
errProto, nullptr));
|
||||
if (!errObject)
|
||||
return false;
|
||||
tv[1] = OBJECT_TO_JSVAL(errObject);
|
||||
@ -1031,7 +1032,7 @@ js_ReportUncaughtException(JSContext *cx)
|
||||
*/
|
||||
RootedObject exnObject(cx);
|
||||
if (JSVAL_IS_PRIMITIVE(exn)) {
|
||||
exnObject = NULL;
|
||||
exnObject = nullptr;
|
||||
} else {
|
||||
exnObject = JSVAL_TO_OBJECT(exn);
|
||||
roots[0] = exn;
|
||||
@ -1107,14 +1108,14 @@ js_ReportUncaughtException(JSContext *cx)
|
||||
}
|
||||
|
||||
JSAutoByteString bytesStorage;
|
||||
const char *bytes = NULL;
|
||||
const char *bytes = nullptr;
|
||||
if (str)
|
||||
bytes = bytesStorage.encodeLatin1(cx, str);
|
||||
if (!bytes)
|
||||
bytes = "unknown (can't convert to string)";
|
||||
|
||||
if (!reportp) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr,
|
||||
JSMSG_UNCAUGHT_EXCEPTION, bytes);
|
||||
} else {
|
||||
/* Flag the error as an exception. */
|
||||
@ -1140,24 +1141,24 @@ js_CopyErrorObject(JSContext *cx, HandleObject errobj, HandleObject scope)
|
||||
|
||||
ScopedJSFreePtr<JSExnPrivate> copy(static_cast<JSExnPrivate *>(cx->malloc_(size)));
|
||||
if (!copy)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
if (priv->errorReport) {
|
||||
copy->errorReport = CopyErrorReport(cx, priv->errorReport);
|
||||
if (!copy->errorReport)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
} else {
|
||||
copy->errorReport = NULL;
|
||||
copy->errorReport = nullptr;
|
||||
}
|
||||
ScopedJSFreePtr<JSErrorReport> autoFreeErrorReport(copy->errorReport);
|
||||
|
||||
copy->message.init(priv->message);
|
||||
if (!cx->compartment()->wrap(cx, ©->message))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
JS::Anchor<JSString *> messageAnchor(copy->message);
|
||||
copy->filename.init(priv->filename);
|
||||
if (!cx->compartment()->wrap(cx, ©->filename))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
JS::Anchor<JSString *> filenameAnchor(copy->filename);
|
||||
copy->lineno = priv->lineno;
|
||||
copy->column = priv->column;
|
||||
@ -1167,10 +1168,10 @@ js_CopyErrorObject(JSContext *cx, HandleObject errobj, HandleObject scope)
|
||||
// Create the Error object.
|
||||
RootedObject proto(cx, scope->global().getOrCreateCustomErrorPrototype(cx, copy->exnType));
|
||||
if (!proto)
|
||||
return NULL;
|
||||
RootedObject copyobj(cx, NewObjectWithGivenProto(cx, &ErrorObject::class_, proto, NULL));
|
||||
return nullptr;
|
||||
RootedObject copyobj(cx, NewObjectWithGivenProto(cx, &ErrorObject::class_, proto, nullptr));
|
||||
if (!copyobj)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
SetExnPrivate(copyobj->as<ErrorObject>(), copy);
|
||||
copy.forget();
|
||||
autoFreeErrorReport.forget();
|
||||
|
@ -64,7 +64,7 @@ js_GetLocalizedErrorMessage(js::ExclusiveContext *cx, void *userRef, const char
|
||||
* cx must be in the same compartment as scope. errobj may be in a different
|
||||
* compartment, but it must be an Error object (not a wrapper of one) and it
|
||||
* must not be one of the prototype objects created by js_InitExceptionClasses
|
||||
* (errobj->getPrivate() must not be NULL).
|
||||
* (errobj->getPrivate() must not be nullptr).
|
||||
*/
|
||||
extern JSObject *
|
||||
js_CopyErrorObject(JSContext *cx, js::HandleObject errobj, js::HandleObject scope);
|
||||
|
@ -41,7 +41,7 @@ PerThreadDataFriendFields::PerThreadDataFriendFields()
|
||||
PodArrayZero(thingGCRooters);
|
||||
#endif
|
||||
#if defined(DEBUG) && defined(JS_GC_ZEAL) && defined(JSGC_ROOT_ANALYSIS) && !defined(JS_THREADSAFE)
|
||||
skipGCRooters = NULL;
|
||||
skipGCRooters = nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ JS_GetObjectFunction(JSObject *obj)
|
||||
{
|
||||
if (obj->is<JSFunction>())
|
||||
return &obj->as<JSFunction>();
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
JS_FRIEND_API(bool)
|
||||
@ -135,11 +135,12 @@ JS_NewObjectWithUniqueType(JSContext *cx, const JSClass *clasp, JSObject *protoA
|
||||
* TypeObject attached to our proto with information about our object, since
|
||||
* we're not going to be using that TypeObject anyway.
|
||||
*/
|
||||
RootedObject obj(cx, NewObjectWithGivenProto(cx, (const js::Class *)clasp, NULL, parent, SingletonObject));
|
||||
RootedObject obj(cx, NewObjectWithGivenProto(cx, (const js::Class *)clasp, nullptr,
|
||||
parent, SingletonObject));
|
||||
if (!obj)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
if (!JS_SplicePrototype(cx, obj, proto))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
return obj;
|
||||
}
|
||||
|
||||
@ -230,7 +231,7 @@ JS_SetCompartmentPrincipals(JSCompartment *compartment, JSPrincipals *principals
|
||||
// Clear out the old principals, if any.
|
||||
if (compartment->principals) {
|
||||
JS_DropPrincipals(compartment->runtimeFromMainThread(), compartment->principals);
|
||||
compartment->principals = NULL;
|
||||
compartment->principals = nullptr;
|
||||
// We'd like to assert that our new principals is always same-origin
|
||||
// with the old one, but JSPrincipals doesn't give us a way to do that.
|
||||
// But we can at least assert that we're not switching between system
|
||||
@ -431,10 +432,10 @@ js::GetOutermostEnclosingFunctionOfScriptedCaller(JSContext *cx)
|
||||
{
|
||||
ScriptFrameIter iter(cx);
|
||||
if (iter.done())
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
if (!iter.isFunctionFrame())
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
RootedFunction scriptedCaller(cx, iter.callee());
|
||||
RootedScript outermost(cx, scriptedCaller->nonLazyScript());
|
||||
@ -455,7 +456,7 @@ js::DefineFunctionWithReserved(JSContext *cx, JSObject *objArg, const char *name
|
||||
assertSameCompartment(cx, obj);
|
||||
JSAtom *atom = Atomize(cx, name, strlen(name));
|
||||
if (!atom)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
Rooted<jsid> id(cx, AtomToId(atom));
|
||||
return DefineFunction(cx, obj, id, call, nargs, attrs, JSFunction::ExtendedFinalizeKind);
|
||||
}
|
||||
@ -474,7 +475,7 @@ js::NewFunctionWithReserved(JSContext *cx, JSNative native, unsigned nargs, unsi
|
||||
if (name) {
|
||||
atom = Atomize(cx, name, strlen(name));
|
||||
if (!atom)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
JSFunction::Flags funFlags = JSAPIToJSFunctionFlags(flags);
|
||||
@ -509,7 +510,7 @@ js::InitClassWithReserved(JSContext *cx, JSObject *objArg, JSObject *parent_prot
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, parent_proto);
|
||||
return js_InitClass(cx, obj, parent_proto, Valueify(clasp), constructor,
|
||||
nargs, ps, fs, static_ps, static_fs, NULL,
|
||||
nargs, ps, fs, static_ps, static_fs, nullptr,
|
||||
JSFunction::ExtendedFinalizeKind);
|
||||
}
|
||||
|
||||
@ -641,7 +642,7 @@ js::GetWeakmapKeyDelegate(JSObject *key)
|
||||
{
|
||||
if (JSWeakmapKeyDelegateOp op = key->getClass()->ext.weakmapKeyDelegateOp)
|
||||
return op(key);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
@ -1013,12 +1014,12 @@ JS::ObjectPtr::trace(JSTracer *trc, const char *name)
|
||||
JS_FRIEND_API(JSObject *)
|
||||
js::GetTestingFunctions(JSContext *cx)
|
||||
{
|
||||
RootedObject obj(cx, JS_NewObject(cx, NULL, NULL, NULL));
|
||||
RootedObject obj(cx, JS_NewObject(cx, nullptr, nullptr, nullptr));
|
||||
if (!obj)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
if (!DefineTestingFunctions(cx, obj))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
return obj;
|
||||
}
|
||||
@ -1043,7 +1044,7 @@ js::GetDOMCallbacks(JSRuntime *rt)
|
||||
return rt->DOMcallbacks;
|
||||
}
|
||||
|
||||
static const void *gDOMProxyHandlerFamily = NULL;
|
||||
static const void *gDOMProxyHandlerFamily = nullptr;
|
||||
static uint32_t gDOMProxyExpandoSlot = 0;
|
||||
static DOMProxyShadowsCheck gDOMProxyShadowsCheck;
|
||||
|
||||
@ -1077,7 +1078,7 @@ js::GetDOMProxyShadowsCheck()
|
||||
bool
|
||||
js::detail::IdMatchesAtom(jsid id, JSAtom *atom)
|
||||
{
|
||||
return id == INTERNED_STRING_TO_JSID(NULL, atom);
|
||||
return id == INTERNED_STRING_TO_JSID(nullptr, atom);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(JSContext *)
|
||||
|
@ -119,11 +119,11 @@ JS_GetCompartmentPrincipals(JSCompartment *compartment);
|
||||
extern JS_FRIEND_API(void)
|
||||
JS_SetCompartmentPrincipals(JSCompartment *compartment, JSPrincipals *principals);
|
||||
|
||||
/* Safe to call with input obj == NULL. Returns non-NULL iff obj != NULL. */
|
||||
/* Safe to call with input obj == nullptr. Returns non-nullptr iff obj != nullptr. */
|
||||
extern JS_FRIEND_API(JSObject *)
|
||||
JS_ObjectToInnerObject(JSContext *cx, JSObject *obj);
|
||||
|
||||
/* Requires obj != NULL. */
|
||||
/* Requires obj != nullptr. */
|
||||
extern JS_FRIEND_API(JSObject *)
|
||||
JS_ObjectToOuterObject(JSContext *cx, JSObject *obj);
|
||||
|
||||
@ -198,7 +198,7 @@ struct JSFunctionSpecWithHelp {
|
||||
#define JS_FN_HELP(name,call,nargs,flags,usage,help) \
|
||||
{name, call, nargs, (flags) | JSPROP_ENUMERATE | JSFUN_STUB_GSOPS, usage, help}
|
||||
#define JS_FS_HELP_END \
|
||||
{NULL, NULL, 0, 0, NULL, NULL}
|
||||
{nullptr, nullptr, 0, 0, nullptr, nullptr}
|
||||
|
||||
extern JS_FRIEND_API(bool)
|
||||
JS_DefineFunctionsWithHelp(JSContext *cx, JSObject *obj, const JSFunctionSpecWithHelp *fs);
|
||||
@ -316,7 +316,7 @@ struct WeakMapTracer;
|
||||
* Weak map tracer callback, called once for every binding of every
|
||||
* weak map that was live at the time of the last garbage collection.
|
||||
*
|
||||
* m will be NULL if the weak map is not contained in a JS Object.
|
||||
* m will be nullptr if the weak map is not contained in a JS Object.
|
||||
*/
|
||||
typedef void
|
||||
(* WeakMapTraceCallback)(WeakMapTracer *trc, JSObject *m,
|
||||
@ -498,7 +498,7 @@ IsOriginalScriptFunction(JSFunction *fun);
|
||||
|
||||
/*
|
||||
* Return the outermost enclosing function (script) of the scripted caller.
|
||||
* This function returns NULL in several cases:
|
||||
* This function returns nullptr in several cases:
|
||||
* - no script is running on the context
|
||||
* - the caller is in global or eval code
|
||||
* In particular, this function will "stop" its outermost search at eval() and
|
||||
@ -768,7 +768,7 @@ CastToJSFreeOp(FreeOp *fop)
|
||||
|
||||
/*
|
||||
* Get an error type name from a JSExnType constant.
|
||||
* Returns NULL for invalid arguments and JSEXN_INTERNALERR
|
||||
* Returns nullptr for invalid arguments and JSEXN_INTERNALERR
|
||||
*/
|
||||
extern JS_FRIEND_API(const jschar*)
|
||||
GetErrorTypeName(JSRuntime* rt, int16_t exnType);
|
||||
@ -1084,9 +1084,9 @@ extern JS_FRIEND_API(bool)
|
||||
JS_IsFloat64Array(JSObject *obj);
|
||||
|
||||
/*
|
||||
* Unwrap Typed arrays all at once. Return NULL without throwing if the object
|
||||
* cannot be viewed as the correct typed array, or the typed array object on
|
||||
* success, filling both outparameters.
|
||||
* Unwrap Typed arrays all at once. Return nullptr without throwing if the
|
||||
* object cannot be viewed as the correct typed array, or the typed array
|
||||
* object on success, filling both outparameters.
|
||||
*/
|
||||
extern JS_FRIEND_API(JSObject *)
|
||||
JS_GetObjectAsInt8Array(JSObject *obj, uint32_t *length, int8_t **data);
|
||||
@ -1263,7 +1263,7 @@ JS_GetDataViewByteOffset(JSObject *obj);
|
||||
*
|
||||
* |obj| must have passed a JS_IsDataViewObject test, or somehow be known that
|
||||
* it would pass such a test: it is a data view or a wrapper of a data view,
|
||||
* and the unwrapping will succeed. If cx is NULL, then DEBUG builds may be
|
||||
* and the unwrapping will succeed. If cx is nullptr, then DEBUG builds may be
|
||||
* unable to assert when unwrapping should be disallowed.
|
||||
*/
|
||||
JS_FRIEND_API(uint32_t)
|
||||
@ -1274,7 +1274,7 @@ JS_GetDataViewByteLength(JSObject *obj);
|
||||
*
|
||||
* |obj| must have passed a JS_IsDataViewObject test, or somehow be known that
|
||||
* it would pass such a test: it is a data view or a wrapper of a data view,
|
||||
* and the unwrapping will succeed. If cx is NULL, then DEBUG builds may be
|
||||
* and the unwrapping will succeed. If cx is nullptr, then DEBUG builds may be
|
||||
* unable to assert when unwrapping should be disallowed.
|
||||
*/
|
||||
JS_FRIEND_API(void *)
|
||||
@ -1405,7 +1405,7 @@ struct JSJitInfo {
|
||||
};
|
||||
|
||||
#define JS_JITINFO_NATIVE_PARALLEL(op) \
|
||||
{{NULL},0,0,JSJitInfo::OpType_None,false,false,false,JSVAL_TYPE_MISSING,op}
|
||||
{{nullptr},0,0,JSJitInfo::OpType_None,false,false,false,JSVAL_TYPE_MISSING,op}
|
||||
|
||||
static JS_ALWAYS_INLINE const JSJitInfo *
|
||||
FUNCTION_VALUE_TO_JITINFO(const JS::Value& v)
|
||||
@ -1570,7 +1570,7 @@ class JS_FRIEND_API(AutoCTypesActivityCallback) {
|
||||
void DoEndCallback() {
|
||||
if (callback) {
|
||||
callback(cx, endType);
|
||||
callback = NULL;
|
||||
callback = nullptr;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
173
js/src/jsfun.cpp
173
js/src/jsfun.cpp
@ -82,12 +82,13 @@ fun_getProperty(JSContext *cx, HandleObject obj_, HandleId id, MutableHandleValu
|
||||
|
||||
if (JSID_IS_ATOM(id, cx->names().arguments)) {
|
||||
if (fun->hasRest()) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_FUNCTION_ARGUMENTS_AND_REST);
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr,
|
||||
JSMSG_FUNCTION_ARGUMENTS_AND_REST);
|
||||
return false;
|
||||
}
|
||||
/* Warn if strict about f.arguments or equivalent unqualified uses. */
|
||||
if (!JS_ReportErrorFlagsAndNumber(cx, JSREPORT_WARNING | JSREPORT_STRICT, js_GetErrorMessage,
|
||||
NULL, JSMSG_DEPRECATED_USAGE, js_arguments_str)) {
|
||||
nullptr, JSMSG_DEPRECATED_USAGE, js_arguments_str)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -134,7 +135,7 @@ fun_getProperty(JSContext *cx, HandleObject obj_, HandleId id, MutableHandleValu
|
||||
} else if (caller->is<JSFunction>()) {
|
||||
JSFunction *callerFun = &caller->as<JSFunction>();
|
||||
if (callerFun->isInterpreted() && callerFun->strict()) {
|
||||
JS_ReportErrorFlagsAndNumber(cx, JSREPORT_ERROR, js_GetErrorMessage, NULL,
|
||||
JS_ReportErrorFlagsAndNumber(cx, JSREPORT_ERROR, js_GetErrorMessage, nullptr,
|
||||
JSMSG_CALLER_IS_STRICT);
|
||||
return false;
|
||||
}
|
||||
@ -213,12 +214,12 @@ ResolveInterpretedFunctionPrototype(JSContext *cx, HandleObject obj)
|
||||
else
|
||||
objProto = obj->global().getOrCreateObjectPrototype(cx);
|
||||
if (!objProto)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
const Class *clasp = &JSObject::class_;
|
||||
|
||||
RootedObject proto(cx, NewObjectWithGivenProto(cx, clasp, objProto, NULL, SingletonObject));
|
||||
RootedObject proto(cx, NewObjectWithGivenProto(cx, clasp, objProto, nullptr, SingletonObject));
|
||||
if (!proto)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
// Per ES5 15.3.5.2 a user-defined function's .prototype property is
|
||||
// initially non-configurable, non-enumerable, and writable.
|
||||
@ -227,7 +228,7 @@ ResolveInterpretedFunctionPrototype(JSContext *cx, HandleObject obj)
|
||||
protoVal, JS_PropertyStub, JS_StrictPropertyStub,
|
||||
JSPROP_PERMANENT))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Per ES5 13.2 the prototype's .constructor property is configurable,
|
||||
@ -239,7 +240,7 @@ ResolveInterpretedFunctionPrototype(JSContext *cx, HandleObject obj)
|
||||
if (!JSObject::defineProperty(cx, proto, cx->names().constructor,
|
||||
objVal, JS_PropertyStub, JS_StrictPropertyStub, 0))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -288,7 +289,7 @@ js::fun_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
|
||||
fun->nargs - fun->hasRest();
|
||||
v.setInt32(length);
|
||||
} else {
|
||||
v.setString(fun->atom() == NULL ? cx->runtime()->emptyString : fun->atom());
|
||||
v.setString(fun->atom() == nullptr ? cx->runtime()->emptyString : fun->atom());
|
||||
}
|
||||
|
||||
if (!DefineNativeProperty(cx, fun, id, v, JS_PropertyStub, JS_StrictPropertyStub,
|
||||
@ -357,8 +358,8 @@ js::XDRInterpretedFunction(XDRState<mode> *xdr, HandleObject enclosingScope, Han
|
||||
if (!fun->isInterpreted()) {
|
||||
JSAutoByteString funNameBytes;
|
||||
if (const char *name = GetFunctionNameBytes(cx, fun, &funNameBytes)) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_NOT_SCRIPTED_FUNCTION,
|
||||
name);
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr,
|
||||
JSMSG_NOT_SCRIPTED_FUNCTION, name);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -378,19 +379,19 @@ js::XDRInterpretedFunction(XDRState<mode> *xdr, HandleObject enclosingScope, Han
|
||||
if (!xdr->codeUint32(&firstword))
|
||||
return false;
|
||||
|
||||
JSObject *proto = NULL;
|
||||
JSObject *proto = nullptr;
|
||||
if (firstword & IsStarGenerator) {
|
||||
proto = cx->global()->getOrCreateStarGeneratorFunctionPrototype(cx);
|
||||
if (!proto)
|
||||
return false;
|
||||
}
|
||||
fun = NewFunctionWithProto(cx, NullPtr(), NULL, 0, JSFunction::INTERPRETED,
|
||||
fun = NewFunctionWithProto(cx, NullPtr(), nullptr, 0, JSFunction::INTERPRETED,
|
||||
NullPtr(), NullPtr(), proto,
|
||||
JSFunction::FinalizeKind, TenuredObject);
|
||||
if (!fun)
|
||||
return false;
|
||||
atom = NULL;
|
||||
script = NULL;
|
||||
atom = nullptr;
|
||||
script = nullptr;
|
||||
}
|
||||
|
||||
if ((firstword & HasAtom) && !XDRAtom(xdr, &atom))
|
||||
@ -428,22 +429,23 @@ JSObject *
|
||||
js::CloneFunctionAndScript(JSContext *cx, HandleObject enclosingScope, HandleFunction srcFun)
|
||||
{
|
||||
/* NB: Keep this in sync with XDRInterpretedFunction. */
|
||||
JSObject *cloneProto = NULL;
|
||||
JSObject *cloneProto = nullptr;
|
||||
if (srcFun->isStarGenerator()) {
|
||||
cloneProto = cx->global()->getOrCreateStarGeneratorFunctionPrototype(cx);
|
||||
if (!cloneProto)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
RootedFunction clone(cx, NewFunctionWithProto(cx, NullPtr(), NULL, 0, JSFunction::INTERPRETED,
|
||||
NullPtr(), NullPtr(), cloneProto,
|
||||
JSFunction::FinalizeKind, TenuredObject));
|
||||
RootedFunction clone(cx, NewFunctionWithProto(cx, NullPtr(), nullptr, 0,
|
||||
JSFunction::INTERPRETED, NullPtr(), NullPtr(),
|
||||
cloneProto, JSFunction::FinalizeKind,
|
||||
TenuredObject));
|
||||
if (!clone)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
RootedScript srcScript(cx, srcFun->nonLazyScript());
|
||||
RootedScript clonedScript(cx, CloneScript(cx, enclosingScope, clone, srcScript));
|
||||
if (!clonedScript)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
clone->nargs = srcFun->nargs;
|
||||
clone->flags = srcFun->flags;
|
||||
@ -451,7 +453,7 @@ js::CloneFunctionAndScript(JSContext *cx, HandleObject enclosingScope, HandleFun
|
||||
clone->initScript(clonedScript);
|
||||
clonedScript->setFunction(clone);
|
||||
if (!JSFunction::setTypeForScriptedFunction(cx, clone))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
RootedScript cloneScript(cx, clone->nonLazyScript());
|
||||
CallNewScriptHook(cx, cloneScript, clone);
|
||||
@ -534,11 +536,11 @@ const Class JSFunction::class_ = {
|
||||
fun_enumerate,
|
||||
(JSResolveOp)js::fun_resolve,
|
||||
JS_ConvertStub,
|
||||
NULL, /* finalize */
|
||||
NULL, /* checkAccess */
|
||||
NULL, /* call */
|
||||
nullptr, /* finalize */
|
||||
nullptr, /* checkAccess */
|
||||
nullptr, /* call */
|
||||
fun_hasInstance,
|
||||
NULL, /* construct */
|
||||
nullptr, /* construct */
|
||||
fun_trace
|
||||
};
|
||||
|
||||
@ -554,7 +556,7 @@ FindBody(JSContext *cx, HandleFunction fun, StableCharPtr chars, size_t length,
|
||||
options.setFileAndLine("internal-findBody", 0)
|
||||
.setVersion(fun->nonLazyScript()->getVersion());
|
||||
AutoKeepAtoms keepAtoms(cx->perThreadData);
|
||||
TokenStream ts(cx, options, chars.get(), length, NULL);
|
||||
TokenStream ts(cx, options, chars.get(), length, nullptr);
|
||||
int nest = 0;
|
||||
bool onward = true;
|
||||
// Skip arguments list.
|
||||
@ -606,7 +608,7 @@ JSString *
|
||||
js::FunctionToString(JSContext *cx, HandleFunction fun, bool bodyOnly, bool lambdaParen)
|
||||
{
|
||||
if (fun->isInterpretedLazy() && !fun->getOrCreateScript(cx))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
// If the object is an automatically-bound arrow function, get the source
|
||||
// of the pre-binding target.
|
||||
@ -627,7 +629,7 @@ js::FunctionToString(JSContext *cx, HandleFunction fun, bool bodyOnly, bool lamb
|
||||
!out.append("\n [generator expression]\n") ||
|
||||
(!bodyOnly && !out.append("}")))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return out.finishString();
|
||||
}
|
||||
@ -636,30 +638,30 @@ js::FunctionToString(JSContext *cx, HandleFunction fun, bool bodyOnly, bool lamb
|
||||
// If we're not in pretty mode, put parentheses around lambda functions.
|
||||
if (fun->isInterpreted() && !lambdaParen && fun->isLambda() && !fun->isArrow()) {
|
||||
if (!out.append("("))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (!fun->isArrow()) {
|
||||
if (!(fun->isStarGenerator() ? out.append("function* ") : out.append("function ")))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (fun->atom()) {
|
||||
if (!out.append(fun->atom()))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
bool haveSource = fun->isInterpreted() && !fun->isSelfHostedBuiltin();
|
||||
if (haveSource && !script->scriptSource()->hasSourceData() &&
|
||||
!JSScript::loadSource(cx, script->scriptSource(), &haveSource))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (haveSource) {
|
||||
RootedString srcStr(cx, script->sourceData(cx));
|
||||
if (!srcStr)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
Rooted<JSStableString *> src(cx, srcStr->ensureStable(cx));
|
||||
if (!src)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
StableCharPtr chars = src->chars();
|
||||
bool exprBody = fun->isExprClosure();
|
||||
@ -692,22 +694,22 @@ js::FunctionToString(JSContext *cx, HandleFunction fun, bool bodyOnly, bool lamb
|
||||
// of bug 755821 should be cobbling the arguments passed into the
|
||||
// Function constructor into the source string.
|
||||
if (!out.append("("))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
// Fish out the argument names.
|
||||
BindingVector *localNames = cx->new_<BindingVector>(cx);
|
||||
ScopedJSDeletePtr<BindingVector> freeNames(localNames);
|
||||
if (!FillBindingVector(script, localNames))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
for (unsigned i = 0; i < fun->nargs; i++) {
|
||||
if ((i && !out.append(", ")) ||
|
||||
(i == unsigned(fun->nargs - 1) && fun->hasRest() && !out.append("...")) ||
|
||||
!out.append((*localNames)[i].name())) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
if (!out.append(") {\n"))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if ((bodyOnly && !funCon) || addUseStrict) {
|
||||
// We need to get at the body either because we're only supposed to
|
||||
@ -719,7 +721,7 @@ js::FunctionToString(JSContext *cx, HandleFunction fun, bool bodyOnly, bool lamb
|
||||
if (!funCon) {
|
||||
JS_ASSERT(!buildBody);
|
||||
if (!FindBody(cx, fun, chars, src->length(), &bodyStart, &bodyEnd))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
} else {
|
||||
bodyEnd = src->length();
|
||||
}
|
||||
@ -727,16 +729,16 @@ js::FunctionToString(JSContext *cx, HandleFunction fun, bool bodyOnly, bool lamb
|
||||
if (addUseStrict) {
|
||||
// Output source up to beginning of body.
|
||||
if (!out.append(chars, bodyStart))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
if (exprBody) {
|
||||
// We can't insert a statement into a function with an
|
||||
// expression body. Do what the decompiler did, and insert a
|
||||
// comment.
|
||||
if (!out.append("/* use strict */ "))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
} else {
|
||||
if (!out.append("\n\"use strict\";\n"))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -744,36 +746,36 @@ js::FunctionToString(JSContext *cx, HandleFunction fun, bool bodyOnly, bool lamb
|
||||
// closing braces (for addUseStrict).
|
||||
size_t dependentEnd = bodyOnly ? bodyEnd : src->length();
|
||||
if (!out.append(chars + bodyStart, dependentEnd - bodyStart))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
} else {
|
||||
if (!out.append(src))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (buildBody) {
|
||||
if (!out.append("\n}"))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (bodyOnly) {
|
||||
// Slap a semicolon on the end of functions with an expression body.
|
||||
if (exprBody && !out.append(";"))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
} else if (!lambdaParen && fun->isLambda() && !fun->isArrow()) {
|
||||
if (!out.append(")"))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
} else if (fun->isInterpreted() && !fun->isSelfHostedBuiltin()) {
|
||||
if ((!bodyOnly && !out.append("() {\n ")) ||
|
||||
!out.append("[sourceless code]") ||
|
||||
(!bodyOnly && !out.append("\n}")))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
if (!lambdaParen && fun->isLambda() && !fun->isArrow() && !out.append(")"))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
} else {
|
||||
JS_ASSERT(!fun->isExprClosure());
|
||||
if ((!bodyOnly && !out.append("() {\n ")) ||
|
||||
!out.append("[native code]") ||
|
||||
(!bodyOnly && !out.append("\n}")))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return out.finishString();
|
||||
}
|
||||
@ -784,11 +786,11 @@ fun_toStringHelper(JSContext *cx, HandleObject obj, unsigned indent)
|
||||
if (!obj->is<JSFunction>()) {
|
||||
if (obj->is<ProxyObject>())
|
||||
return Proxy::fun_toString(cx, obj, indent);
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr,
|
||||
JSMSG_INCOMPATIBLE_PROTO,
|
||||
js_Function_str, js_toString_str,
|
||||
"object");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RootedFunction fun(cx, &obj->as<JSFunction>());
|
||||
@ -992,7 +994,8 @@ js_fun_apply(JSContext *cx, unsigned argc, Value *vp)
|
||||
} else {
|
||||
/* Step 3. */
|
||||
if (!vp[3].isObject()) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_BAD_APPLY_ARGS, js_apply_str);
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr,
|
||||
JSMSG_BAD_APPLY_ARGS, js_apply_str);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1007,7 +1010,7 @@ js_fun_apply(JSContext *cx, unsigned argc, Value *vp)
|
||||
|
||||
/* Step 6. */
|
||||
if (length > ARGS_LENGTH_MAX) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_TOO_MANY_FUN_APPLY_ARGS);
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_TOO_MANY_FUN_APPLY_ARGS);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1114,7 +1117,7 @@ JSFunction::createScriptForLazilyInterpretedFunction(JSContext *cx, HandleFuncti
|
||||
return true;
|
||||
}
|
||||
|
||||
fun->initScript(NULL);
|
||||
fun->initScript(nullptr);
|
||||
|
||||
if (fun != lazy->function()) {
|
||||
script = lazy->function()->getOrCreateScript(cx);
|
||||
@ -1287,7 +1290,7 @@ fun_bind(JSContext *cx, unsigned argc, Value *vp)
|
||||
}
|
||||
|
||||
/* Step 3. */
|
||||
Value *boundArgs = NULL;
|
||||
Value *boundArgs = nullptr;
|
||||
unsigned argslen = 0;
|
||||
if (args.length() > 1) {
|
||||
boundArgs = args.array() + 1;
|
||||
@ -1319,19 +1322,19 @@ js_fun_bind(JSContext *cx, HandleObject target, HandleValue thisArg,
|
||||
}
|
||||
|
||||
/* Step 4-6, 10-11. */
|
||||
RootedAtom name(cx, target->is<JSFunction>() ? target->as<JSFunction>().atom() : NULL);
|
||||
RootedAtom name(cx, target->is<JSFunction>() ? target->as<JSFunction>().atom() : nullptr);
|
||||
|
||||
RootedObject funobj(cx, NewFunction(cx, NullPtr(), CallOrConstructBoundFunction, length,
|
||||
JSFunction::NATIVE_CTOR, target, name));
|
||||
if (!funobj)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
/* NB: Bound functions abuse |parent| to store their target. */
|
||||
if (!JSObject::setParent(cx, funobj, target))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
if (!funobj->as<JSFunction>().initBoundFunction(cx, thisArg, boundArgs, argslen))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
/* Steps 17, 19-21 are handled by fun_resolve. */
|
||||
/* Step 18 is the default for new functions. */
|
||||
@ -1346,7 +1349,7 @@ static bool
|
||||
OnBadFormal(JSContext *cx, TokenKind tt)
|
||||
{
|
||||
if (tt != TOK_ERROR)
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_BAD_FORMAL);
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_FORMAL);
|
||||
else
|
||||
JS_ASSERT(cx->isExceptionPending());
|
||||
return false;
|
||||
@ -1373,7 +1376,7 @@ FunctionConstructor(JSContext *cx, unsigned argc, Value *vp, GeneratorKind gener
|
||||
/* Block this call if security callbacks forbid it. */
|
||||
Rooted<GlobalObject*> global(cx, &args.callee().global());
|
||||
if (!GlobalObject::isRuntimeCodeGenEnabled(cx, global)) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CSP_BLOCKED_FUNCTION);
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CSP_BLOCKED_FUNCTION);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1476,7 +1479,7 @@ FunctionConstructor(JSContext *cx, unsigned argc, Value *vp, GeneratorKind gener
|
||||
* compile the function body.
|
||||
*/
|
||||
TokenStream ts(cx, options, collected_args.get(), args_length,
|
||||
/* strictModeGetter = */ NULL);
|
||||
/* strictModeGetter = */ nullptr);
|
||||
bool yieldIsValidName = ts.versionNumber() < JSVERSION_1_7 && !isStarGenerator;
|
||||
|
||||
/* The argument string may be empty or contain no tokens. */
|
||||
@ -1560,13 +1563,13 @@ FunctionConstructor(JSContext *cx, unsigned argc, Value *vp, GeneratorKind gener
|
||||
* and so would a call to f from another top-level's script or function.
|
||||
*/
|
||||
RootedAtom anonymousAtom(cx, cx->names().anonymous);
|
||||
JSObject *proto = NULL;
|
||||
JSObject *proto = nullptr;
|
||||
if (isStarGenerator) {
|
||||
proto = global->getOrCreateStarGeneratorFunctionPrototype(cx);
|
||||
if (!proto)
|
||||
return false;
|
||||
}
|
||||
RootedFunction fun(cx, NewFunctionWithProto(cx, NullPtr(), NULL, 0,
|
||||
RootedFunction fun(cx, NewFunctionWithProto(cx, NullPtr(), nullptr, 0,
|
||||
JSFunction::INTERPRETED_LAMBDA, global,
|
||||
anonymousAtom, proto,
|
||||
JSFunction::FinalizeKind, TenuredObject));
|
||||
@ -1609,7 +1612,7 @@ js::NewFunction(ExclusiveContext *cx, HandleObject funobjArg, Native native, uns
|
||||
gc::AllocKind allocKind /* = JSFunction::FinalizeKind */,
|
||||
NewObjectKind newKind /* = GenericObject */)
|
||||
{
|
||||
return NewFunctionWithProto(cx, funobjArg, native, nargs, flags, parent, atom, NULL,
|
||||
return NewFunctionWithProto(cx, funobjArg, native, nargs, flags, parent, atom, nullptr,
|
||||
allocKind, newKind);
|
||||
}
|
||||
|
||||
@ -1638,7 +1641,7 @@ js::NewFunctionWithProto(ExclusiveContext *cx, HandleObject funobjArg, Native na
|
||||
funobj = NewObjectWithClassProto(cx, &JSFunction::class_, proto,
|
||||
SkipScopeParent(parent), allocKind, newKind);
|
||||
if (!funobj)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
RootedFunction fun(cx, &funobj->as<JSFunction>());
|
||||
|
||||
@ -1647,12 +1650,12 @@ js::NewFunctionWithProto(ExclusiveContext *cx, HandleObject funobjArg, Native na
|
||||
fun->flags = flags;
|
||||
if (fun->isInterpreted()) {
|
||||
JS_ASSERT(!native);
|
||||
fun->mutableScript().init(NULL);
|
||||
fun->mutableScript().init(nullptr);
|
||||
fun->initEnvironment(parent);
|
||||
} else {
|
||||
JS_ASSERT(fun->isNative());
|
||||
JS_ASSERT(native);
|
||||
fun->initNative(native, NULL);
|
||||
fun->initNative(native, nullptr);
|
||||
}
|
||||
if (allocKind == JSFunction::ExtendedFinalizeKind) {
|
||||
fun->flags |= JSFunction::EXTENDED;
|
||||
@ -1675,19 +1678,19 @@ js::CloneFunctionObject(JSContext *cx, HandleFunction fun, HandleObject parent,
|
||||
!types::UseNewTypeForClone(fun);
|
||||
|
||||
if (!useSameScript && fun->isInterpretedLazy() && !fun->getOrCreateScript(cx))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
NewObjectKind newKind = useSameScript ? newKindArg : SingletonObject;
|
||||
JSObject *cloneProto = NULL;
|
||||
JSObject *cloneProto = nullptr;
|
||||
if (fun->isStarGenerator()) {
|
||||
cloneProto = cx->global()->getOrCreateStarGeneratorFunctionPrototype(cx);
|
||||
if (!cloneProto)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
JSObject *cloneobj = NewObjectWithClassProto(cx, &JSFunction::class_, cloneProto,
|
||||
SkipScopeParent(parent), allocKind, newKind);
|
||||
if (!cloneobj)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
RootedFunction clone(cx, &cloneobj->as<JSFunction>());
|
||||
|
||||
clone->nargs = fun->nargs;
|
||||
@ -1733,7 +1736,7 @@ js::CloneFunctionObject(JSContext *cx, HandleFunction fun, HandleObject parent,
|
||||
* no enclosing lexical scope (only the global scope).
|
||||
*/
|
||||
if (cloneRoot->isInterpreted() && !CloneFunctionScript(cx, fun, cloneRoot, newKindArg))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
return cloneRoot;
|
||||
}
|
||||
@ -1759,8 +1762,8 @@ js::DefineFunction(JSContext *cx, HandleObject obj, HandleId id, Native native,
|
||||
gop = JS_PropertyStub;
|
||||
sop = JS_StrictPropertyStub;
|
||||
} else {
|
||||
gop = NULL;
|
||||
sop = NULL;
|
||||
gop = nullptr;
|
||||
sop = nullptr;
|
||||
}
|
||||
|
||||
JSFunction::Flags funFlags;
|
||||
@ -1768,14 +1771,14 @@ js::DefineFunction(JSContext *cx, HandleObject obj, HandleId id, Native native,
|
||||
funFlags = JSFunction::INTERPRETED_LAZY;
|
||||
else
|
||||
funFlags = JSAPIToJSFunctionFlags(flags);
|
||||
RootedAtom atom(cx, JSID_IS_ATOM(id) ? JSID_TO_ATOM(id) : NULL);
|
||||
RootedAtom atom(cx, JSID_IS_ATOM(id) ? JSID_TO_ATOM(id) : nullptr);
|
||||
fun = NewFunction(cx, NullPtr(), native, nargs, funFlags, obj, atom, allocKind, newKind);
|
||||
if (!fun)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
RootedValue funVal(cx, ObjectValue(*fun));
|
||||
if (!JSObject::defineGeneric(cx, obj, id, funVal, gop, sop, flags & ~JSFUN_FLAGS_MASK))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
return fun;
|
||||
}
|
||||
@ -1794,7 +1797,7 @@ js::IsConstructor(const Value &v)
|
||||
JSFunction &fun = obj.as<JSFunction>();
|
||||
return fun.isNativeConstructor() || fun.isInterpretedConstructor();
|
||||
}
|
||||
return obj.getClass()->construct != NULL;
|
||||
return obj.getClass()->construct != nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
@ -1822,7 +1825,7 @@ js::ReportIncompatibleMethod(JSContext *cx, CallReceiver call, const Class *clas
|
||||
if (JSFunction *fun = ReportIfNotFunction(cx, call.calleev())) {
|
||||
JSAutoByteString funNameBytes;
|
||||
if (const char *funName = GetFunctionNameBytes(cx, fun, &funNameBytes)) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_INCOMPATIBLE_PROTO,
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO,
|
||||
clasp->name, funName, InformalValueTypeName(thisv));
|
||||
}
|
||||
}
|
||||
@ -1834,7 +1837,7 @@ js::ReportIncompatible(JSContext *cx, CallReceiver call)
|
||||
if (JSFunction *fun = ReportIfNotFunction(cx, call.calleev())) {
|
||||
JSAutoByteString funNameBytes;
|
||||
if (const char *funName = GetFunctionNameBytes(cx, fun, &funNameBytes)) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_INCOMPATIBLE_METHOD,
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_METHOD,
|
||||
funName, "method", InformalValueTypeName(call.thisv()));
|
||||
}
|
||||
}
|
||||
@ -1875,7 +1878,7 @@ CheckIsValidConstructible(Value calleev)
|
||||
if (callee->is<JSFunction>())
|
||||
JS_ASSERT(callee->as<JSFunction>().isNativeConstructor());
|
||||
else
|
||||
JS_ASSERT(callee->getClass()->construct != NULL);
|
||||
JS_ASSERT(callee->getClass()->construct != nullptr);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
@ -75,7 +75,7 @@ class JSFunction : public JSObject
|
||||
union {
|
||||
JSScript *script_; /* interpreted bytecode descriptor or null;
|
||||
use the accessor! */
|
||||
js::LazyScript *lazy_; /* lazily compiled script, or NULL */
|
||||
js::LazyScript *lazy_; /* lazily compiled script, or nullptr */
|
||||
} s;
|
||||
JSObject *env_; /* environment for new activations;
|
||||
use the accessor! */
|
||||
@ -202,14 +202,14 @@ class JSFunction : public JSObject
|
||||
flags |= EXPR_CLOSURE;
|
||||
}
|
||||
|
||||
JSAtom *atom() const { return hasGuessedAtom() ? NULL : atom_.get(); }
|
||||
js::PropertyName *name() const { return hasGuessedAtom() || !atom_ ? NULL : atom_->asPropertyName(); }
|
||||
JSAtom *atom() const { return hasGuessedAtom() ? nullptr : atom_.get(); }
|
||||
js::PropertyName *name() const { return hasGuessedAtom() || !atom_ ? nullptr : atom_->asPropertyName(); }
|
||||
void initAtom(JSAtom *atom) { atom_.init(atom); }
|
||||
JSAtom *displayAtom() const { return atom_; }
|
||||
|
||||
void setGuessedAtom(JSAtom *atom) {
|
||||
JS_ASSERT(atom_ == NULL);
|
||||
JS_ASSERT(atom != NULL);
|
||||
JS_ASSERT(atom_ == nullptr);
|
||||
JS_ASSERT(atom != nullptr);
|
||||
JS_ASSERT(!hasGuessedAtom());
|
||||
atom_ = atom;
|
||||
flags |= HAS_GUESSED_ATOM;
|
||||
@ -249,7 +249,7 @@ class JSFunction : public JSObject
|
||||
// necessary (isInterpretedLazy()).
|
||||
//
|
||||
// A lazy function will have a LazyScript if the function came from parsed
|
||||
// source, or NULL if the function is a clone of a self hosted function.
|
||||
// source, or nullptr if the function is a clone of a self hosted function.
|
||||
//
|
||||
// There are several methods to get the script of an interpreted function:
|
||||
//
|
||||
@ -269,7 +269,7 @@ class JSFunction : public JSObject
|
||||
if (isInterpretedLazy()) {
|
||||
JS::RootedFunction self(cx, this);
|
||||
if (!createScriptForLazilyInterpretedFunction(cx, self))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
JS_ASSERT(self->hasScript());
|
||||
return self->u.i.s.script_;
|
||||
}
|
||||
@ -355,7 +355,7 @@ class JSFunction : public JSObject
|
||||
}
|
||||
|
||||
JSNative maybeNative() const {
|
||||
return isInterpreted() ? NULL : native();
|
||||
return isInterpreted() ? nullptr : native();
|
||||
}
|
||||
|
||||
JSParallelNative parallelNative() const {
|
||||
@ -364,7 +364,7 @@ class JSFunction : public JSObject
|
||||
}
|
||||
|
||||
JSParallelNative maybeParallelNative() const {
|
||||
return hasParallelNative() ? parallelNative() : NULL;
|
||||
return hasParallelNative() ? parallelNative() : nullptr;
|
||||
}
|
||||
|
||||
void initNative(js::Native native, const JSJitInfo *jitinfo) {
|
||||
@ -475,7 +475,7 @@ NewFunction(ExclusiveContext *cx, HandleObject funobj, JSNative native, unsigned
|
||||
gc::AllocKind allocKind = JSFunction::FinalizeKind,
|
||||
NewObjectKind newKind = GenericObject);
|
||||
|
||||
// If proto is NULL, Function.prototype is used instead.
|
||||
// If proto is nullptr, Function.prototype is used instead.
|
||||
extern JSFunction *
|
||||
NewFunctionWithProto(ExclusiveContext *cx, HandleObject funobj, JSNative native, unsigned nargs,
|
||||
JSFunction::Flags flags, HandleObject parent, HandleAtom atom,
|
||||
|
@ -26,7 +26,7 @@ static inline JSObject *
|
||||
SkipScopeParent(JSObject *parent)
|
||||
{
|
||||
if (!parent)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
while (parent->is<ScopeObject>())
|
||||
parent = &parent->as<ScopeObject>().enclosingScope();
|
||||
return parent;
|
||||
@ -70,7 +70,7 @@ CloneFunctionObjectIfNotSingleton(JSContext *cx, HandleFunction fun, HandleObjec
|
||||
if (CanReuseFunctionForClone(cx, fun)) {
|
||||
RootedObject obj(cx, SkipScopeParent(parent));
|
||||
if (!JSObject::setParent(cx, fun, obj))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
fun->setEnvironment(parent);
|
||||
return fun;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user