Bug 1090592 - LazyProto for ProxyOptions. r=bholley

This commit is contained in:
Gabor Krizsanits 2015-02-10 16:29:28 +01:00
Родитель 1733a1d87b
Коммит a660165fed
2 изменённых файлов: 15 добавлений и 1 удалений

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

@ -541,13 +541,15 @@ SetReservedOrProxyPrivateSlot(JSObject *obj, size_t slot, const Value &value)
class MOZ_STACK_CLASS ProxyOptions {
protected:
/* protected constructor for subclass */
explicit ProxyOptions(bool singletonArg)
explicit ProxyOptions(bool singletonArg, bool lazyProtoArg = false)
: singleton_(singletonArg),
lazyProto_(lazyProtoArg),
clasp_(ProxyClassPtr)
{}
public:
ProxyOptions() : singleton_(false),
lazyProto_(false),
clasp_(ProxyClassPtr)
{}
@ -557,6 +559,12 @@ class MOZ_STACK_CLASS ProxyOptions {
return *this;
}
bool lazyProto() const { return lazyProto_; }
ProxyOptions &setLazyProto(bool flag) {
lazyProto_ = flag;
return *this;
}
const Class *clasp() const {
return clasp_;
}
@ -567,6 +575,7 @@ class MOZ_STACK_CLASS ProxyOptions {
private:
bool singleton_;
bool lazyProto_;
const Class *clasp_;
};

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

@ -753,6 +753,11 @@ JS_FRIEND_API(JSObject *)
js::NewProxyObject(JSContext *cx, const BaseProxyHandler *handler, HandleValue priv, JSObject *proto_,
JSObject *parent_, const ProxyOptions &options)
{
if (options.lazyProto()) {
MOZ_ASSERT(!proto_);
proto_ = TaggedProto::LazyProto;
}
return ProxyObject::New(cx, handler, priv, TaggedProto(proto_), parent_,
options);
}