/* * Rewrap *idp and the fields of *desc for the current compartment. Also: * defining a property on a proxy requires pd_ to contain a descriptor object, * so reconstitute desc->pd_ if needed. */ bool PropDesc::wrapInto(JSContext *cx, HandleObject obj, const jsid &id, jsid *wrappedId, PropDesc *desc) const { MOZ_ASSERT(!isUndefined()); JSCompartment *comp = cx->compartment; *wrappedId = id; if (!comp->wrapId(cx, wrappedId)) return false; *desc = *this; RootedValue value(cx, desc->value_); RootedValue get(cx, desc->get_); RootedValue set(cx, desc->set_); if (!comp->wrap(cx, &value) || !comp->wrap(cx, &get) || !comp->wrap(cx, &set)) return false; desc->value_ = value; desc->get_ = get; desc->set_ = set; return !obj->isProxy() || desc->makeObject(cx); }
static bool TryPreserveReflector(JSContext *cx, HandleObject obj) { if (obj->getClass()->ext.isWrappedNative || (obj->getClass()->flags & JSCLASS_IS_DOMJSCLASS) || (obj->isProxy() && GetProxyHandler(obj)->family() == GetDOMProxyHandlerFamily())) { JS_ASSERT(cx->runtime()->preserveWrapperCallback); if (!cx->runtime()->preserveWrapperCallback(cx, obj)) { JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_BAD_WEAKMAP_KEY); return false; } } return true; }