Bug 547140, part 3 - Remove flags argument from DefineNativeProperty. r=Waldo.

This commit is contained in:
Jason Orendorff 2014-04-25 16:11:02 -05:00
Родитель 6e21c723d2
Коммит 2a9babf664
18 изменённых файлов: 50 добавлений и 48 удалений

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

@ -2078,10 +2078,10 @@ IteratorResultShape(ExclusiveContext *cx, BytecodeEmitter *bce, unsigned *shape)
Rooted<jsid> value_id(cx, AtomToId(cx->names().value));
Rooted<jsid> done_id(cx, AtomToId(cx->names().done));
if (!DefineNativeProperty(cx, obj, value_id, UndefinedHandleValue, nullptr, nullptr,
JSPROP_ENUMERATE, 0, 0))
JSPROP_ENUMERATE))
return false;
if (!DefineNativeProperty(cx, obj, done_id, UndefinedHandleValue, nullptr, nullptr,
JSPROP_ENUMERATE, 0, 0))
JSPROP_ENUMERATE))
return false;
ObjectBox *objbox = bce->parser->newObjectBox(obj);
@ -5975,7 +5975,7 @@ EmitObject(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *pn)
Rooted<jsid> id(cx, AtomToId(pn3->pn_atom));
RootedValue undefinedValue(cx, UndefinedValue());
if (!DefineNativeProperty(cx, obj, id, undefinedValue, nullptr,
nullptr, JSPROP_ENUMERATE, 0, 0))
nullptr, JSPROP_ENUMERATE))
{
return false;
}

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

@ -732,7 +732,7 @@ CreateExportObject(JSContext *cx, Handle<AsmJSModuleObject*> moduleObj)
JS_ASSERT(func.maybeFieldName() != nullptr);
RootedId id(cx, NameToId(func.maybeFieldName()));
RootedValue val(cx, ObjectValue(*fun));
if (!DefineNativeProperty(cx, obj, id, val, nullptr, nullptr, JSPROP_ENUMERATE, 0))
if (!DefineNativeProperty(cx, obj, id, val, nullptr, nullptr, JSPROP_ENUMERATE))
return nullptr;
}

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

@ -7370,7 +7370,7 @@ DoSetPropFallback(JSContext *cx, BaselineFrame *frame, ICSetProp_Fallback *stub_
if (op == JSOP_INITPROP) {
MOZ_ASSERT(name != cx->names().proto, "should have used JSOP_MUTATEPROTO");
MOZ_ASSERT(obj->is<JSObject>());
if (!DefineNativeProperty(cx, obj, id, rhs, nullptr, nullptr, JSPROP_ENUMERATE, 0))
if (!DefineNativeProperty(cx, obj, id, rhs, nullptr, nullptr, JSPROP_ENUMERATE))
return false;
} else if (op == JSOP_SETNAME || op == JSOP_SETGNAME) {
if (!SetNameOperation(cx, script, pc, obj, rhs))

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

@ -2126,7 +2126,7 @@ AnalyzePoppedThis(JSContext *cx, types::TypeObject *type,
DebugOnly<unsigned> slotSpan = baseobj->slotSpan();
if (!DefineNativeProperty(cx, baseobj, id, UndefinedHandleValue, nullptr, nullptr,
JSPROP_ENUMERATE, 0))
JSPROP_ENUMERATE))
{
return false;
}

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

@ -226,7 +226,7 @@ InitProp(JSContext *cx, HandleObject obj, HandlePropertyName name, HandleValue v
MOZ_ASSERT(name != cx->names().proto,
"__proto__ should have been handled by JSOP_MUTATEPROTO");
return DefineNativeProperty(cx, obj, id, rval, nullptr, nullptr, JSPROP_ENUMERATE, 0, 0);
return DefineNativeProperty(cx, obj, id, rval, nullptr, nullptr, JSPROP_ENUMERATE);
}
template<bool Equal>

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

@ -3006,8 +3006,6 @@ DefinePropertyById(JSContext *cx, HandleObject obj, HandleId id, HandleValue val
: nullptr);
JSAutoResolveFlags rf(cx, 0);
if (flags != 0 && obj->isNative())
return DefineNativeProperty(cx, obj, id, value, getter, setter, attrs, flags);
return JSObject::defineGeneric(cx, obj, id, value, getter, setter, attrs);
}

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

@ -312,7 +312,7 @@ js::fun_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
}
if (!DefineNativeProperty(cx, fun, id, v, JS_PropertyStub, JS_StrictPropertyStub,
JSPROP_PERMANENT | JSPROP_READONLY, 0)) {
JSPROP_PERMANENT | JSPROP_READONLY)) {
return false;
}
objp.set(fun);
@ -341,7 +341,7 @@ js::fun_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
setter = JS_StrictPropertyStub;
}
if (!DefineNativeProperty(cx, fun, id, UndefinedHandleValue, getter, setter, attrs, 0))
if (!DefineNativeProperty(cx, fun, id, UndefinedHandleValue, getter, setter, attrs))
return false;
objp.set(fun);
return true;

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

@ -1243,10 +1243,10 @@ js_InitNumberClass(JSContext *cx, HandleObject obj)
/* ES5 15.1.1.1, 15.1.1.2 */
if (!DefineNativeProperty(cx, global, cx->names().NaN, valueNaN,
JS_PropertyStub, JS_StrictPropertyStub,
JSPROP_PERMANENT | JSPROP_READONLY, 0) ||
JSPROP_PERMANENT | JSPROP_READONLY) ||
!DefineNativeProperty(cx, global, cx->names().Infinity, valueInfinity,
JS_PropertyStub, JS_StrictPropertyStub,
JSPROP_PERMANENT | JSPROP_READONLY, 0))
JSPROP_PERMANENT | JSPROP_READONLY))
{
return nullptr;
}

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

@ -2071,7 +2071,7 @@ js::XDRObjectLiteral(XDRState<mode> *xdr, MutableHandleObject obj)
return false;
if (mode == XDR_DECODE) {
if (!DefineNativeProperty(cx, obj, id, tmpValue, NULL, NULL, JSPROP_ENUMERATE, 0))
if (!DefineNativeProperty(cx, obj, id, tmpValue, NULL, NULL, JSPROP_ENUMERATE))
return false;
}
}
@ -3469,7 +3469,7 @@ bool
baseops::DefineGeneric(ExclusiveContext *cx, HandleObject obj, HandleId id, HandleValue value,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
return DefineNativeProperty(cx, obj, id, value, getter, setter, attrs, 0);
return DefineNativeProperty(cx, obj, id, value, getter, setter, attrs);
}
/* static */ bool
@ -3503,7 +3503,7 @@ baseops::DefineElement(ExclusiveContext *cx, HandleObject obj, uint32_t index, H
RootedId id(cx);
if (index <= JSID_INT_MAX) {
id = INT_TO_JSID(index);
return DefineNativeProperty(cx, obj, id, value, getter, setter, attrs, 0);
return DefineNativeProperty(cx, obj, id, value, getter, setter, attrs);
}
AutoRooterGetterSetter gsRoot(cx, attrs, &getter, &setter);
@ -3511,7 +3511,7 @@ baseops::DefineElement(ExclusiveContext *cx, HandleObject obj, uint32_t index, H
if (!IndexToId(cx, index, &id))
return false;
return DefineNativeProperty(cx, obj, id, value, getter, setter, attrs, 0);
return DefineNativeProperty(cx, obj, id, value, getter, setter, attrs);
}
/* static */ bool
@ -3667,7 +3667,7 @@ static inline bool
DefinePropertyOrElement(typename ExecutionModeTraits<mode>::ExclusiveContextType cx,
HandleObject obj, HandleId id,
PropertyOp getter, StrictPropertyOp setter,
unsigned attrs, unsigned flags, HandleValue value,
unsigned attrs, HandleValue value,
bool callSetterAfterwards, bool setterIsStrict)
{
/* Use dense storage for new indexed properties where possible. */
@ -3736,7 +3736,7 @@ DefinePropertyOrElement(typename ExecutionModeTraits<mode>::ExclusiveContextType
AutoRooterGetterSetter gsRoot(cx, attrs, &getter, &setter);
RootedShape shape(cx, JSObject::putProperty<mode>(cx, obj, id, getter, setter,
SHAPE_INVALID_SLOT, attrs, flags));
SHAPE_INVALID_SLOT, attrs, 0));
if (!shape)
return false;
@ -3783,7 +3783,7 @@ NativeLookupOwnProperty(ExclusiveContext *cx, HandleObject obj, HandleId id, uns
bool
js::DefineNativeProperty(ExclusiveContext *cx, HandleObject obj, HandleId id, HandleValue value,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs,
unsigned flags, unsigned defineHow /* = 0 */)
unsigned defineHow /* = 0 */)
{
JS_ASSERT((defineHow & ~DNP_DONT_PURGE) == 0);
JS_ASSERT(!(attrs & JSPROP_NATIVE_ACCESSORS));
@ -3801,7 +3801,7 @@ js::DefineNativeProperty(ExclusiveContext *cx, HandleObject obj, HandleId id, Ha
* If we are defining a getter whose setter was already defined, or
* vice versa, finish the job via obj->changeProperty.
*/
if (!NativeLookupOwnProperty(cx, obj, id, flags, &shape))
if (!NativeLookupOwnProperty(cx, obj, id, 0, &shape))
return false;
if (shape) {
if (IsImplicitDenseOrTypedArrayElement(shape)) {
@ -3849,7 +3849,7 @@ js::DefineNativeProperty(ExclusiveContext *cx, HandleObject obj, HandleId id, Ha
if (!shape) {
return DefinePropertyOrElement<SequentialExecution>(cx, obj, id, getter, setter,
attrs, flags, value, false, false);
attrs, value, false, false);
}
JS_ALWAYS_TRUE(UpdateShapeTypeAndValue<SequentialExecution>(cx, obj, shape, value));
@ -4928,7 +4928,6 @@ baseops::SetPropertyHelper(typename ExecutionModeTraits<mode>::ContextType cxArg
* prototypes; or shape is non-null, meaning id was found directly in pobj.
*/
unsigned attrs = JSPROP_ENUMERATE;
unsigned flags = 0;
const Class *clasp = obj->getClass();
PropertyOp getter = clasp->getProperty;
StrictPropertyOp setter = clasp->setProperty;
@ -5088,7 +5087,7 @@ baseops::SetPropertyHelper(typename ExecutionModeTraits<mode>::ContextType cxArg
}
return DefinePropertyOrElement<mode>(cxArg, obj, id, getter, setter,
attrs, flags, vp, true, strict);
attrs, vp, true, strict);
}
return NativeSet<mode>(cxArg, obj, receiver, shape, strict, vp);

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

@ -1367,10 +1367,16 @@ DeepCloneObjectLiteral(JSContext *cx, HandleObject obj, NewObjectKind newKind =
/*
* Flags for the defineHow parameter of DefineNativeProperty.
*/
const unsigned DNP_DONT_PURGE = 1; /* suppress js_PurgeScopeChain */
const unsigned DNP_UNQUALIFIED = 2; /* Unqualified property set. Only used in
the defineHow argument of
js_SetPropertyHelper. */
enum {
/* Suppress js_PurgeScopeChain. */
DNP_DONT_PURGE = 1,
/*
* Unqualified property set. Only used in the defineHow argument of
* js_SetPropertyHelper.
*/
DNP_UNQUALIFIED = 2
};
/*
* Return successfully added or changed shape or nullptr on error.
@ -1378,7 +1384,7 @@ const unsigned DNP_UNQUALIFIED = 2; /* Unqualified property set. Only used i
extern bool
DefineNativeProperty(ExclusiveContext *cx, HandleObject obj, HandleId id, HandleValue value,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs,
unsigned flags, unsigned defineHow = 0);
unsigned defineHow = 0);
/*
* Specialized subroutine that allows caller to preset JSRESOLVE_* flags.

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

@ -1074,10 +1074,10 @@ NewObjectMetadata(ExclusiveContext *cxArg, JSObject **pmetadata)
inline bool
DefineNativeProperty(ExclusiveContext *cx, HandleObject obj, PropertyName *name, HandleValue value,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs,
unsigned flags, unsigned defineHow = 0)
unsigned defineHow = 0)
{
Rooted<jsid> id(cx, NameToId(name));
return DefineNativeProperty(cx, obj, id, value, getter, setter, attrs, flags, defineHow);
return DefineNativeProperty(cx, obj, id, value, getter, setter, attrs, defineHow);
}
inline bool

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

@ -648,7 +648,7 @@ js_Stringify(JSContext *cx, MutableHandleValue vp, JSObject *replacer_, Value sp
/* Step 10. */
RootedId emptyId(cx, NameToId(cx->names().empty));
if (!DefineNativeProperty(cx, wrapper, emptyId, vp, JS_PropertyStub, JS_StrictPropertyStub,
JSPROP_ENUMERATE, 0))
JSPROP_ENUMERATE))
{
return false;
}

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

@ -595,7 +595,7 @@ JSONParser::createFinishedObject(PropertyVector &properties)
propid = properties[i].id;
value = properties[i].value;
if (!DefineNativeProperty(cx, obj, propid, value, JS_PropertyStub, JS_StrictPropertyStub,
JSPROP_ENUMERATE, 0)) {
JSPROP_ENUMERATE)) {
return nullptr;
}
}

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

@ -3057,7 +3057,7 @@ CopyProperty(JSContext *cx, HandleObject obj, HandleObject referent, HandleId id
objp.set(obj);
return DefineNativeProperty(cx, obj, id, desc.value(), desc.getter(), desc.setter(),
desc.attributes(), 0);
desc.attributes());
}
static bool

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

@ -894,7 +894,7 @@ Debugger::newCompletionValue(JSContext *cx, JSTrapStatus status, Value value_,
if (!obj ||
!wrapDebuggeeValue(cx, &value) ||
!DefineNativeProperty(cx, obj, key, value, JS_PropertyStub, JS_StrictPropertyStub,
JSPROP_ENUMERATE, 0))
JSPROP_ENUMERATE))
{
return false;
}
@ -4470,7 +4470,7 @@ DebuggerFrame_getArguments(JSContext *cx, unsigned argc, Value *vp)
RootedValue fargcVal(cx, Int32Value(fargc));
if (!DefineNativeProperty(cx, argsobj, cx->names().length,
fargcVal, nullptr, nullptr,
JSPROP_PERMANENT | JSPROP_READONLY, 0))
JSPROP_PERMANENT | JSPROP_READONLY))
{
return false;
}
@ -4487,7 +4487,7 @@ DebuggerFrame_getArguments(JSContext *cx, unsigned argc, Value *vp)
if (!getobj ||
!DefineNativeProperty(cx, argsobj, id, UndefinedHandleValue,
JS_DATA_TO_FUNC_PTR(PropertyOp, getobj.get()), nullptr,
JSPROP_ENUMERATE | JSPROP_SHARED | JSPROP_GETTER, 0))
JSPROP_ENUMERATE | JSPROP_SHARED | JSPROP_GETTER))
{
return false;
}
@ -4788,7 +4788,7 @@ DebuggerGenericEval(JSContext *cx, const char *fullMethodName, const Value &code
id = keys[i];
MutableHandleValue val = values.handleAt(i);
if (!cx->compartment()->wrap(cx, val) ||
!DefineNativeProperty(cx, env, id, val, nullptr, nullptr, 0, 0))
!DefineNativeProperty(cx, env, id, val, nullptr, nullptr, 0))
{
return false;
}

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

@ -3172,7 +3172,7 @@ CASE(JSOP_INITPROP)
RootedId &id = rootId0;
id = NameToId(name);
if (!DefineNativeProperty(cx, obj, id, rval, nullptr, nullptr, JSPROP_ENUMERATE, 0, 0))
if (!DefineNativeProperty(cx, obj, id, rval, nullptr, nullptr, JSPROP_ENUMERATE))
goto error;
REGS.sp--;

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

@ -321,7 +321,7 @@ js_InitSharedArrayBufferClass(JSContext *cx, HandleObject obj)
return nullptr;
RootedId byteLengthId(cx, NameToId(cx->names().byteLength));
unsigned flags = JSPROP_SHARED | JSPROP_GETTER | JSPROP_PERMANENT;
unsigned attrs = JSPROP_SHARED | JSPROP_GETTER | JSPROP_PERMANENT;
JSObject *getter = NewFunction(cx, NullPtr(), SharedArrayBufferObject::byteLengthGetter, 0,
JSFunction::NATIVE_FUN, global, NullPtr());
if (!getter)
@ -329,7 +329,7 @@ js_InitSharedArrayBufferClass(JSContext *cx, HandleObject obj)
RootedValue value(cx, UndefinedValue());
if (!DefineNativeProperty(cx, proto, byteLengthId, value,
JS_DATA_TO_FUNC_PTR(PropertyOp, getter), nullptr, flags, 0, 0))
JS_DATA_TO_FUNC_PTR(PropertyOp, getter), nullptr, attrs))
{
return nullptr;
}

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

@ -470,7 +470,7 @@ class TypedArrayObjectTemplate : public TypedArrayObject
DefineGetter(JSContext *cx, HandleObject proto, PropertyName *name, Native native)
{
RootedId id(cx, NameToId(name));
unsigned flags = JSPROP_SHARED | JSPROP_GETTER | JSPROP_PERMANENT;
unsigned attrs = JSPROP_SHARED | JSPROP_GETTER | JSPROP_PERMANENT;
Rooted<GlobalObject*> global(cx, cx->compartment()->maybeGlobal());
JSObject *getter = NewFunction(cx, NullPtr(), native, 0,
@ -480,7 +480,7 @@ class TypedArrayObjectTemplate : public TypedArrayObject
return DefineNativeProperty(cx, proto, id, UndefinedHandleValue,
JS_DATA_TO_FUNC_PTR(PropertyOp, getter), nullptr,
flags, 0, 0);
attrs);
}
static
@ -2264,14 +2264,14 @@ InitArrayBufferClass(JSContext *cx)
return nullptr;
RootedId byteLengthId(cx, NameToId(cx->names().byteLength));
unsigned flags = JSPROP_SHARED | JSPROP_GETTER | JSPROP_PERMANENT;
unsigned attrs = JSPROP_SHARED | JSPROP_GETTER | JSPROP_PERMANENT;
JSObject *getter = NewFunction(cx, NullPtr(), ArrayBufferObject::byteLengthGetter, 0,
JSFunction::NATIVE_FUN, global, NullPtr());
if (!getter)
return nullptr;
if (!DefineNativeProperty(cx, arrayBufferProto, byteLengthId, UndefinedHandleValue,
JS_DATA_TO_FUNC_PTR(PropertyOp, getter), nullptr, flags, 0, 0))
JS_DATA_TO_FUNC_PTR(PropertyOp, getter), nullptr, attrs))
return nullptr;
if (!JS_DefineFunctions(cx, ctor, ArrayBufferObject::jsstaticfuncs))
@ -2364,7 +2364,7 @@ bool
DataViewObject::defineGetter(JSContext *cx, PropertyName *name, HandleObject proto)
{
RootedId id(cx, NameToId(name));
unsigned flags = JSPROP_SHARED | JSPROP_GETTER | JSPROP_PERMANENT;
unsigned attrs = JSPROP_SHARED | JSPROP_GETTER | JSPROP_PERMANENT;
Rooted<GlobalObject*> global(cx, cx->compartment()->maybeGlobal());
JSObject *getter = NewFunction(cx, NullPtr(), DataViewObject::getter<ValueGetter>, 0,
@ -2373,8 +2373,7 @@ DataViewObject::defineGetter(JSContext *cx, PropertyName *name, HandleObject pro
return false;
return DefineNativeProperty(cx, proto, id, UndefinedHandleValue,
JS_DATA_TO_FUNC_PTR(PropertyOp, getter), nullptr,
flags, 0, 0);
JS_DATA_TO_FUNC_PTR(PropertyOp, getter), nullptr, attrs);
}
/* static */ bool