зеркало из 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 {
|
class MOZ_STACK_CLASS ProxyOptions {
|
||||||
protected:
|
protected:
|
||||||
/* protected constructor for subclass */
|
/* protected constructor for subclass */
|
||||||
explicit ProxyOptions(bool singletonArg)
|
explicit ProxyOptions(bool singletonArg, bool lazyProtoArg = false)
|
||||||
: singleton_(singletonArg),
|
: singleton_(singletonArg),
|
||||||
|
lazyProto_(lazyProtoArg),
|
||||||
clasp_(ProxyClassPtr)
|
clasp_(ProxyClassPtr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ProxyOptions() : singleton_(false),
|
ProxyOptions() : singleton_(false),
|
||||||
|
lazyProto_(false),
|
||||||
clasp_(ProxyClassPtr)
|
clasp_(ProxyClassPtr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -557,6 +559,12 @@ class MOZ_STACK_CLASS ProxyOptions {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool lazyProto() const { return lazyProto_; }
|
||||||
|
ProxyOptions &setLazyProto(bool flag) {
|
||||||
|
lazyProto_ = flag;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
const Class *clasp() const {
|
const Class *clasp() const {
|
||||||
return clasp_;
|
return clasp_;
|
||||||
}
|
}
|
||||||
|
@ -567,6 +575,7 @@ class MOZ_STACK_CLASS ProxyOptions {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool singleton_;
|
bool singleton_;
|
||||||
|
bool lazyProto_;
|
||||||
const Class *clasp_;
|
const Class *clasp_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -753,6 +753,11 @@ JS_FRIEND_API(JSObject *)
|
||||||
js::NewProxyObject(JSContext *cx, const BaseProxyHandler *handler, HandleValue priv, JSObject *proto_,
|
js::NewProxyObject(JSContext *cx, const BaseProxyHandler *handler, HandleValue priv, JSObject *proto_,
|
||||||
JSObject *parent_, const ProxyOptions &options)
|
JSObject *parent_, const ProxyOptions &options)
|
||||||
{
|
{
|
||||||
|
if (options.lazyProto()) {
|
||||||
|
MOZ_ASSERT(!proto_);
|
||||||
|
proto_ = TaggedProto::LazyProto;
|
||||||
|
}
|
||||||
|
|
||||||
return ProxyObject::New(cx, handler, priv, TaggedProto(proto_), parent_,
|
return ProxyObject::New(cx, handler, priv, TaggedProto(proto_), parent_,
|
||||||
options);
|
options);
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче