/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- * vim: set ts=8 sts=2 et sw=2 tw=80: * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// This method is not covered by any spec, but we follow ES 2016 // (February 11, 2016) 9.1.7.1 fairly closely.
// Step 2. (Step 1 is a superfluous assertion.) // Non-standard: Use our faster hasOwn trap. if (!hasOwn(cx, proxy, id, bp)) { returnfalse;
}
// Step 3. if (*bp) { returntrue;
}
// The spec calls this variable "parent", but that word has weird // connotations in SpiderMonkey, so let's go with "proto". // Step 4.
RootedObject proto(cx); if (!GetPrototype(cx, proxy, &proto)) { returnfalse;
}
// Step 5.,5.a. if (proto) { return HasProperty(cx, proto, id, bp);
}
// This method is not covered by any spec, but we follow ES 2016 // (January 21, 2016) 9.1.8 fairly closely.
// Step 2. (Step 1 is a superfluous assertion.)
Rooted<mozilla::Maybe<PropertyDescriptor>> desc(cx); if (!getOwnPropertyDescriptor(cx, proxy, id, &desc)) { returnfalse;
} if (desc.isSome()) {
desc->assertComplete();
}
// Step 3. if (desc.isNothing()) { // The spec calls this variable "parent", but that word has weird // connotations in SpiderMonkey, so let's go with "proto". // Step 3.a.
RootedObject proto(cx); if (!GetPrototype(cx, proxy, &proto)) { returnfalse;
}
// Step 3.b. if (!proto) {
vp.setUndefined(); returntrue;
}
// Step 3.c. return GetProperty(cx, proto, receiver, id, vp);
}
// Step 4. if (desc->isDataDescriptor()) {
vp.set(desc->value()); returntrue;
}
// This method is not covered by any spec, but we follow ES6 draft rev 28 // (2014 Oct 14) 9.1.9 fairly closely, adapting it slightly for // SpiderMonkey's particular foibles.
// Steps 2-3. (Step 1 is a superfluous assertion.)
Rooted<mozilla::Maybe<PropertyDescriptor>> ownDesc(cx); if (!getOwnPropertyDescriptor(cx, proxy, id, &ownDesc)) { returnfalse;
} if (ownDesc.isSome()) {
ownDesc->assertComplete();
}
// The rest is factored out into a separate function with a weird name. // This algorithm continues just below. return SetPropertyIgnoringNamedGetter(cx, proxy, id, v, receiver, ownDesc,
result);
}
// Step 4. if (ownDesc_.isNothing()) { // The spec calls this variable "parent", but that word has weird // connotations in SpiderMonkey, so let's go with "proto".
RootedObject proto(cx); if (!GetPrototype(cx, obj, &proto)) { returnfalse;
} if (proto) { return SetProperty(cx, proto, id, v, receiver, result);
}
if (!ownPropertyKeys(cx, proxy, props)) { returnfalse;
}
/* Select only the enumerable properties through in-place iteration. */
RootedId id(cx);
size_t i = 0; for (size_t j = 0, len = props.length(); j < len; j++) {
MOZ_ASSERT(i <= j);
id = props[j]; if (id.isSymbol()) { continue;
}
AutoWaivePolicy policy(cx, proxy, id, BaseProxyHandler::GET);
Rooted<mozilla::Maybe<PropertyDescriptor>> desc(cx); if (!getOwnPropertyDescriptor(cx, proxy, id, &desc)) { returnfalse;
} if (desc.isSome()) {
desc->assertComplete();
}
if (desc.isSome() && desc->enumerable()) {
props[i++].set(id);
}
}
MOZ_ASSERT(i <= props.length()); if (!props.resize(i)) { returnfalse;
}
// GetPropertyKeys will invoke getOwnEnumerablePropertyKeys along the proto // chain for us.
MOZ_ASSERT(props.empty()); return GetPropertyKeys(cx, proxy, 0, props);
}
bool BaseProxyHandler::setPrototype(JSContext* cx, HandleObject proxy,
HandleObject proto,
ObjectOpResult& result) const { // Disallow sets of protos on proxies with dynamic prototypes but no hook. // This keeps us away from the footgun of having the first proto set opt // you out of having dynamic protos altogether.
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
JSMSG_CANT_SET_PROTO_OF, "incompatible Proxy"); returnfalse;
}
// (NotifyGCNukeWrapper() only needs to be called on CCWs.)
// The proxy is about to be replaced, so we need to do any necessary // cleanup first.
proxy->as<ProxyObject>().handler()->finalize(cx->gcContext(), proxy);
// We don't need to call finalize here because the CCW finalizer doesn't do // anything. Skipping finalize means that |wrapper| doesn't need to be rooted // to pass the hazard analysis, which is needed because this method is called // from some tricky places inside transplanting where rooting can be // difficult.
wrapper->as<ProxyObject>().nuke();
MOZ_ASSERT(IsDeadProxyObject(wrapper));
}
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.