зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1485066 - Part 9: Additional miscellaneous clean-ups around EncodeString callers. r=Waldo
This commit is contained in:
Родитель
ed962c63e5
Коммит
94cab79237
|
@ -625,7 +625,7 @@ class JS_FRIEND_API(AutoEnterPolicy)
|
|||
, enteredAction(BaseProxyHandler::NONE)
|
||||
#endif
|
||||
{}
|
||||
void reportErrorIfExceptionIsNotPending(JSContext* cx, jsid id);
|
||||
void reportErrorIfExceptionIsNotPending(JSContext* cx, HandleId id);
|
||||
bool allow;
|
||||
bool rv;
|
||||
|
||||
|
|
|
@ -1053,8 +1053,7 @@ js::obj_create(JSContext* cx, unsigned argc, Value* vp)
|
|||
}
|
||||
|
||||
if (!args[0].isObjectOrNull()) {
|
||||
RootedValue v(cx, args[0]);
|
||||
UniqueChars bytes = DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, v, nullptr);
|
||||
UniqueChars bytes = DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, args[0], nullptr);
|
||||
if (!bytes)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -1592,21 +1592,6 @@ TypedObject::createZeroed(JSContext* cx, HandleTypeDescr descr, gc::InitialHeap
|
|||
return obj;
|
||||
}
|
||||
|
||||
static bool
|
||||
ReportTypedObjTypeError(JSContext* cx,
|
||||
const unsigned errorNumber,
|
||||
HandleTypedObject obj)
|
||||
{
|
||||
// Serialize type string of obj
|
||||
RootedAtom typeReprAtom(cx, &obj->typeDescr().stringRepr());
|
||||
UniqueChars typeReprStr = StringToNewUTF8CharsZ(cx, *typeReprAtom);
|
||||
if (!typeReprStr)
|
||||
return false;
|
||||
|
||||
JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, errorNumber, typeReprStr.get());
|
||||
return false;
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
OutlineTypedObject::obj_trace(JSTracer* trc, JSObject* object)
|
||||
{
|
||||
|
@ -1696,26 +1681,20 @@ TypedObject::obj_lookupProperty(JSContext* cx, HandleObject obj, HandleId id,
|
|||
return LookupProperty(cx, proto, id, objp, propp);
|
||||
}
|
||||
|
||||
static bool
|
||||
ReportPropertyError(JSContext* cx,
|
||||
const unsigned errorNumber,
|
||||
HandleId id)
|
||||
{
|
||||
UniqueChars propName = ValueToPrintableUTF8(cx, IdToValue(id), true);
|
||||
if (!propName)
|
||||
return false;
|
||||
|
||||
JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, errorNumber, propName.get());
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
TypedObject::obj_defineProperty(JSContext* cx, HandleObject obj, HandleId id,
|
||||
Handle<PropertyDescriptor> desc,
|
||||
ObjectOpResult& result)
|
||||
{
|
||||
Rooted<TypedObject*> typedObj(cx, &obj->as<TypedObject>());
|
||||
return ReportTypedObjTypeError(cx, JSMSG_OBJECT_NOT_EXTENSIBLE, typedObj);
|
||||
// Serialize the type string of |obj|.
|
||||
RootedAtom typeReprAtom(cx, &obj->as<TypedObject>().typeDescr().stringRepr());
|
||||
UniqueChars typeReprStr = StringToNewUTF8CharsZ(cx, *typeReprAtom);
|
||||
if (!typeReprStr)
|
||||
return false;
|
||||
|
||||
JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_OBJECT_NOT_EXTENSIBLE,
|
||||
typeReprStr.get());
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -2010,8 +1989,14 @@ IsOwnId(JSContext* cx, HandleObject obj, HandleId id)
|
|||
bool
|
||||
TypedObject::obj_deleteProperty(JSContext* cx, HandleObject obj, HandleId id, ObjectOpResult& result)
|
||||
{
|
||||
if (IsOwnId(cx, obj, id))
|
||||
return ReportPropertyError(cx, JSMSG_CANT_DELETE, id);
|
||||
if (IsOwnId(cx, obj, id)) {
|
||||
UniqueChars propName = ValueToPrintableUTF8(cx, IdToValue(id), true);
|
||||
if (!propName)
|
||||
return false;
|
||||
|
||||
JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_CANT_DELETE, propName.get());
|
||||
return false;
|
||||
}
|
||||
|
||||
RootedObject proto(cx, obj->staticPrototype());
|
||||
if (!proto)
|
||||
|
|
|
@ -31,7 +31,7 @@ using namespace js::gc;
|
|||
using JS::AutoStableStringChars;
|
||||
|
||||
void
|
||||
js::AutoEnterPolicy::reportErrorIfExceptionIsNotPending(JSContext* cx, jsid id)
|
||||
js::AutoEnterPolicy::reportErrorIfExceptionIsNotPending(JSContext* cx, HandleId id)
|
||||
{
|
||||
if (JS_IsExceptionPending(cx))
|
||||
return;
|
||||
|
|
|
@ -831,8 +831,10 @@ ScriptedProxyHandler::ownPropertyKeys(JSContext* cx, HandleObject proxy, AutoIdV
|
|||
}
|
||||
|
||||
// Step 22.
|
||||
if (!uncheckedResultKeys.empty())
|
||||
return js::Throw(cx, uncheckedResultKeys.all().front(), JSMSG_CANT_REPORT_NEW);
|
||||
if (!uncheckedResultKeys.empty()) {
|
||||
RootedId id(cx, uncheckedResultKeys.all().front());
|
||||
return js::Throw(cx, id, JSMSG_CANT_REPORT_NEW);
|
||||
}
|
||||
|
||||
// Step 23.
|
||||
return props.appendAll(trapResult);
|
||||
|
|
|
@ -4750,10 +4750,9 @@ BinParse(JSContext* cx, unsigned argc, Value* vp)
|
|||
// By default, `useMultipart` is `true`.
|
||||
useMultipart = true;
|
||||
} else if (optionFormat.isString()) {
|
||||
RootedString stringFormat(cx);
|
||||
stringFormat = optionFormat.toString();
|
||||
JS::Rooted<JSLinearString*> linearFormat(cx);
|
||||
linearFormat = stringFormat->ensureLinear(cx);
|
||||
RootedLinearString linearFormat(cx, optionFormat.toString()->ensureLinear(cx));
|
||||
if (!linearFormat)
|
||||
return false;
|
||||
if (StringEqualsAscii(linearFormat, "multipart")) {
|
||||
useMultipart = true;
|
||||
} else if (StringEqualsAscii(linearFormat, "simple")) {
|
||||
|
|
|
@ -5432,7 +5432,7 @@ Debugger::wrapWasmScript(JSContext* cx, Handle<WasmInstanceObject*> wasmInstance
|
|||
}
|
||||
|
||||
static JSObject*
|
||||
DebuggerScript_check(JSContext* cx, const Value& v, const char* fnname)
|
||||
DebuggerScript_check(JSContext* cx, HandleValue v, const char* fnname)
|
||||
{
|
||||
JSObject* thisobj = NonNullObject(cx, v);
|
||||
if (!thisobj)
|
||||
|
|
|
@ -79,15 +79,14 @@ using namespace js;
|
|||
using namespace js::gc;
|
||||
|
||||
void
|
||||
js::ReportNotObject(JSContext* cx, const Value& v)
|
||||
js::ReportNotObject(JSContext* cx, HandleValue v)
|
||||
{
|
||||
MOZ_ASSERT(!v.isObject());
|
||||
|
||||
RootedValue value(cx, v);
|
||||
UniqueChars bytes = DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, value, nullptr);
|
||||
if (bytes)
|
||||
if (UniqueChars bytes = DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, v, nullptr)) {
|
||||
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, JSMSG_NOT_NONNULL_OBJECT,
|
||||
bytes.get());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -253,7 +252,7 @@ GetPropertyIfPresent(JSContext* cx, HandleObject obj, HandleId id, MutableHandle
|
|||
}
|
||||
|
||||
bool
|
||||
js::Throw(JSContext* cx, jsid id, unsigned errorNumber, const char* details)
|
||||
js::Throw(JSContext* cx, HandleId id, unsigned errorNumber, const char* details)
|
||||
{
|
||||
MOZ_ASSERT(js_ErrorFormatString[errorNumber].argCount == (details ? 2 : 1));
|
||||
MOZ_ASSERT_IF(details, JS::StringIsASCII(details));
|
||||
|
|
|
@ -1241,10 +1241,10 @@ XDRObjectLiteral(XDRState<mode>* xdr, MutableHandleObject obj);
|
|||
* Using NotNullObject is usually less code.
|
||||
*/
|
||||
extern void
|
||||
ReportNotObject(JSContext* cx, const Value& v);
|
||||
ReportNotObject(JSContext* cx, HandleValue v);
|
||||
|
||||
inline JSObject*
|
||||
NonNullObject(JSContext* cx, const Value& v)
|
||||
NonNullObject(JSContext* cx, HandleValue v)
|
||||
{
|
||||
if (v.isObject())
|
||||
return &v.toObject();
|
||||
|
@ -1292,7 +1292,7 @@ GetFirstArgumentAsObject(JSContext* cx, const CallArgs& args, const char* method
|
|||
|
||||
/* Helper for throwing, always returns false. */
|
||||
extern bool
|
||||
Throw(JSContext* cx, jsid id, unsigned errorNumber, const char* details = nullptr);
|
||||
Throw(JSContext* cx, HandleId id, unsigned errorNumber, const char* details = nullptr);
|
||||
|
||||
/*
|
||||
* ES6 rev 29 (6 Dec 2014) 7.3.13. Mark obj as non-extensible, and adjust each
|
||||
|
|
|
@ -2456,7 +2456,7 @@ js::GetNameBoundInEnvironment(JSContext* cx, HandleObject envArg, HandleId id, M
|
|||
/*** [[Set]] *************************************************************************************/
|
||||
|
||||
static bool
|
||||
MaybeReportUndeclaredVarAssignment(JSContext* cx, HandleString propname)
|
||||
MaybeReportUndeclaredVarAssignment(JSContext* cx, HandleId id)
|
||||
{
|
||||
unsigned flags;
|
||||
{
|
||||
|
@ -2475,6 +2475,7 @@ MaybeReportUndeclaredVarAssignment(JSContext* cx, HandleString propname)
|
|||
return true;
|
||||
}
|
||||
|
||||
JSString* propname = JSID_TO_STRING(id);
|
||||
UniqueChars bytes = StringToNewUTF8CharsZ(cx, *propname);
|
||||
if (!bytes)
|
||||
return false;
|
||||
|
@ -2595,8 +2596,7 @@ SetNonexistentProperty(JSContext* cx, HandleNativeObject obj, HandleId id, Handl
|
|||
HandleValue receiver, ObjectOpResult& result)
|
||||
{
|
||||
if (!IsQualified && receiver.isObject() && receiver.toObject().isUnqualifiedVarObj()) {
|
||||
RootedString idStr(cx, JSID_TO_STRING(id));
|
||||
if (!MaybeReportUndeclaredVarAssignment(cx, idStr))
|
||||
if (!MaybeReportUndeclaredVarAssignment(cx, id))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -294,14 +294,12 @@ ThrowErrorWithType(JSContext* cx, JSExnType type, const CallArgs& args)
|
|||
|
||||
UniqueChars errorArgs[3];
|
||||
for (unsigned i = 1; i < 4 && i < args.length(); i++) {
|
||||
RootedValue val(cx, args[i]);
|
||||
if (val.isInt32()) {
|
||||
HandleValue val = args[i];
|
||||
if (val.isInt32() || val.isString()) {
|
||||
JSString* str = ToString<CanGC>(cx, val);
|
||||
if (!str)
|
||||
return;
|
||||
errorArgs[i - 1] = EncodeLatin1(cx, str);
|
||||
} else if (val.isString()) {
|
||||
errorArgs[i - 1] = EncodeLatin1(cx, val.toString());
|
||||
} else {
|
||||
errorArgs[i - 1] = DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, val, nullptr);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче