зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1112778, part 2 - Rename js::DefaultValue -> js::OrdinaryToPrimitive. r=Waldo.
--HG-- extra : rebase_source : 90e9de457d157d0ac30308ceb633f981917645ff
This commit is contained in:
Родитель
9924535ad3
Коммит
ef7a22ceb7
|
@ -1941,14 +1941,6 @@ JS_ResolveStub(JSContext *cx, HandleObject obj, HandleId id, bool *resolvedp)
|
|||
}
|
||||
#endif /* GCC 4.4 */
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS::OrdinaryToPrimitive(JSContext *cx, HandleObject obj, JSType type, MutableHandleValue vp)
|
||||
{
|
||||
MOZ_ASSERT(type != JSTYPE_OBJECT && type != JSTYPE_FUNCTION);
|
||||
MOZ_ASSERT(obj);
|
||||
return DefaultValue(cx, obj, type, vp);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSObject *)
|
||||
JS_InitClass(JSContext *cx, HandleObject obj, HandleObject parent_proto,
|
||||
const JSClass *clasp, JSNative constructor, unsigned nargs,
|
||||
|
|
|
@ -1199,7 +1199,8 @@ ToObject(JSContext *cx, HandleValue vp)
|
|||
* as a fallback.
|
||||
*/
|
||||
extern JS_PUBLIC_API(bool)
|
||||
OrdinaryToPrimitive(JSContext *cx, HandleObject obj, JSType type, MutableHandleValue vp);
|
||||
OrdinaryToPrimitive(JSContext *cx, JS::HandleObject obj, JSType type,
|
||||
JS::MutableHandleValue vp);
|
||||
|
||||
} /* namespace JS */
|
||||
|
||||
|
|
|
@ -522,7 +522,7 @@ date_convert(JSContext *cx, HandleObject obj, JSType hint, MutableHandleValue vp
|
|||
MOZ_ASSERT(hint == JSTYPE_NUMBER || hint == JSTYPE_STRING || hint == JSTYPE_VOID);
|
||||
MOZ_ASSERT(obj->is<DateObject>());
|
||||
|
||||
return DefaultValue(cx, obj, (hint == JSTYPE_VOID) ? JSTYPE_STRING : hint, vp);
|
||||
return JS::OrdinaryToPrimitive(cx, obj, hint == JSTYPE_VOID ? JSTYPE_STRING : hint, vp);
|
||||
}
|
||||
|
||||
/* for use by date_parse */
|
||||
|
|
|
@ -2530,10 +2530,6 @@ GetElementsWithAdder(JSContext *cx, JS::HandleObject obj, JS::HandleObject recei
|
|||
JS_FRIEND_API(bool)
|
||||
ForwardToNative(JSContext *cx, JSNative native, const JS::CallArgs &args);
|
||||
|
||||
/* ES5 8.12.8. */
|
||||
extern JS_FRIEND_API(bool)
|
||||
DefaultValue(JSContext *cx, JS::HandleObject obj, JSType hint, JS::MutableHandleValue vp);
|
||||
|
||||
/*
|
||||
* Helper function. To approximate a call to the [[DefineOwnProperty]] internal
|
||||
* method described in ES5, first call this, then call JS_DefinePropertyById.
|
||||
|
|
|
@ -3229,6 +3229,19 @@ JSObject::reportNotExtensible(JSContext *cx, unsigned report)
|
|||
nullptr, nullptr);
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
JSObject::defaultValue(JSContext *cx, HandleObject obj, JSType hint, MutableHandleValue vp)
|
||||
{
|
||||
JSConvertOp op = obj->getClass()->convert;
|
||||
bool ok;
|
||||
if (!op)
|
||||
ok = JS::OrdinaryToPrimitive(cx, obj, hint, vp);
|
||||
else
|
||||
ok = op(cx, obj, hint, vp);
|
||||
MOZ_ASSERT_IF(ok, vp.isPrimitive());
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
JSObject::callMethod(JSContext *cx, HandleId id, unsigned argc, Value *argv, MutableHandleValue vp)
|
||||
{
|
||||
|
@ -3332,8 +3345,8 @@ MaybeCallMethod(JSContext *cx, HandleObject obj, HandleId id, MutableHandleValue
|
|||
return Invoke(cx, ObjectValue(*obj), vp, 0, nullptr, vp);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(bool)
|
||||
js::DefaultValue(JSContext *cx, HandleObject obj, JSType hint, MutableHandleValue vp)
|
||||
bool
|
||||
JS::OrdinaryToPrimitive(JSContext *cx, HandleObject obj, JSType hint, MutableHandleValue vp)
|
||||
{
|
||||
MOZ_ASSERT(hint == JSTYPE_NUMBER || hint == JSTYPE_STRING || hint == JSTYPE_VOID);
|
||||
|
||||
|
|
|
@ -673,17 +673,7 @@ class JSObject : public js::gc::Cell
|
|||
static inline bool unwatch(JSContext *cx, JS::HandleObject obj, JS::HandleId id);
|
||||
|
||||
static bool defaultValue(JSContext *cx, js::HandleObject obj, JSType hint,
|
||||
js::MutableHandleValue vp)
|
||||
{
|
||||
JSConvertOp op = obj->getClass()->convert;
|
||||
bool ok;
|
||||
if (!op)
|
||||
ok = js::DefaultValue(cx, obj, hint, vp);
|
||||
else
|
||||
ok = op(cx, obj, hint, vp);
|
||||
MOZ_ASSERT_IF(ok, vp.isPrimitive());
|
||||
return ok;
|
||||
}
|
||||
js::MutableHandleValue vp);
|
||||
|
||||
static JSObject *thisObject(JSContext *cx, js::HandleObject obj)
|
||||
{
|
||||
|
|
|
@ -291,7 +291,7 @@ bool
|
|||
BaseProxyHandler::defaultValue(JSContext *cx, HandleObject proxy, JSType hint,
|
||||
MutableHandleValue vp) const
|
||||
{
|
||||
return DefaultValue(cx, proxy, hint, vp);
|
||||
return OrdinaryToPrimitive(cx, proxy, hint, vp);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -69,7 +69,7 @@ SecurityWrapper<Base>::isExtensible(JSContext *cx, HandleObject wrapper, bool *e
|
|||
return true;
|
||||
}
|
||||
|
||||
// For security wrappers, we run the DefaultValue algorithm on the wrapper
|
||||
// For security wrappers, we run the OrdinaryToPrimitive algorithm on the wrapper
|
||||
// itself, which means that the existing security policy on operations like
|
||||
// toString() will take effect and do the right thing here.
|
||||
template <class Base>
|
||||
|
@ -77,7 +77,7 @@ bool
|
|||
SecurityWrapper<Base>::defaultValue(JSContext *cx, HandleObject wrapper,
|
||||
JSType hint, MutableHandleValue vp) const
|
||||
{
|
||||
return DefaultValue(cx, wrapper, hint, vp);
|
||||
return OrdinaryToPrimitive(cx, wrapper, hint, vp);
|
||||
}
|
||||
|
||||
template <class Base>
|
||||
|
|
|
@ -359,7 +359,7 @@ sandbox_convert(JSContext *cx, HandleObject obj, JSType type, MutableHandleValue
|
|||
return true;
|
||||
}
|
||||
|
||||
return JS::OrdinaryToPrimitive(cx, obj, type, vp);
|
||||
return OrdinaryToPrimitive(cx, obj, type, vp);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
|
@ -2150,11 +2150,11 @@ XrayWrapper<Base, Traits>::defaultValue(JSContext *cx, HandleObject wrapper,
|
|||
JSType hint, MutableHandleValue vp) const
|
||||
{
|
||||
// Even if this isn't a security wrapper, Xray semantics dictate that we
|
||||
// run the DefaultValue algorithm directly on the Xray wrapper.
|
||||
// run the OrdinaryToPrimitive algorithm directly on the Xray wrapper.
|
||||
//
|
||||
// NB: We don't have to worry about things with special [[DefaultValue]]
|
||||
// behavior like Date because we'll never have an XrayWrapper to them.
|
||||
return js::DefaultValue(cx, wrapper, hint, vp);
|
||||
return OrdinaryToPrimitive(cx, wrapper, hint, vp);
|
||||
}
|
||||
|
||||
template <typename Base, typename Traits>
|
||||
|
|
Загрузка…
Ссылка в новой задаче