зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1090592 - LazyProto for ProxyOptions. r=bholley
This commit is contained in:
Родитель
1733a1d87b
Коммит
a660165fed
|
@ -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);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче