зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1323190 - Remove Proxy friendapi. r=arai
This commit is contained in:
Родитель
e9602402f6
Коммит
ee102bc0e9
|
@ -364,61 +364,8 @@ extern JS_FRIEND_DATA(const js::ObjectOps) ProxyObjectOps;
|
|||
#define PROXY_CLASS_DEF(name, flags) \
|
||||
PROXY_CLASS_WITH_EXT(name, flags, &js::ProxyClassExtension)
|
||||
|
||||
/*
|
||||
* Proxy stubs, similar to JS_*Stub, for embedder proxy class definitions.
|
||||
*
|
||||
* NB: Should not be called directly.
|
||||
*/
|
||||
|
||||
extern JS_FRIEND_API(bool)
|
||||
proxy_LookupProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleObject objp,
|
||||
JS::MutableHandle<Shape*> propp);
|
||||
extern JS_FRIEND_API(bool)
|
||||
proxy_DefineProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id,
|
||||
JS::Handle<JS::PropertyDescriptor> desc,
|
||||
JS::ObjectOpResult& result);
|
||||
extern JS_FRIEND_API(bool)
|
||||
proxy_HasProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, bool* foundp);
|
||||
extern JS_FRIEND_API(bool)
|
||||
proxy_GetProperty(JSContext* cx, JS::HandleObject obj, JS::HandleValue receiver, JS::HandleId id,
|
||||
JS::MutableHandleValue vp);
|
||||
extern JS_FRIEND_API(bool)
|
||||
proxy_SetProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::HandleValue bp,
|
||||
JS::HandleValue receiver, JS::ObjectOpResult& result);
|
||||
extern JS_FRIEND_API(bool)
|
||||
proxy_GetOwnPropertyDescriptor(JSContext* cx, JS::HandleObject obj, JS::HandleId id,
|
||||
JS::MutableHandle<JS::PropertyDescriptor> desc);
|
||||
extern JS_FRIEND_API(bool)
|
||||
proxy_DeleteProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id,
|
||||
JS::ObjectOpResult& result);
|
||||
|
||||
extern JS_FRIEND_API(void)
|
||||
proxy_Trace(JSTracer* trc, JSObject* obj);
|
||||
extern JS_FRIEND_API(JSObject*)
|
||||
proxy_WeakmapKeyDelegate(JSObject* obj);
|
||||
extern JS_FRIEND_API(bool)
|
||||
proxy_Convert(JSContext* cx, JS::HandleObject proxy, JSType hint, JS::MutableHandleValue vp);
|
||||
extern JS_FRIEND_API(void)
|
||||
proxy_Finalize(FreeOp* fop, JSObject* obj);
|
||||
extern JS_FRIEND_API(void)
|
||||
proxy_ObjectMoved(JSObject* obj, const JSObject* old);
|
||||
extern JS_FRIEND_API(bool)
|
||||
proxy_HasInstance(JSContext* cx, JS::HandleObject proxy, JS::MutableHandleValue v, bool* bp);
|
||||
extern JS_FRIEND_API(bool)
|
||||
proxy_Call(JSContext* cx, unsigned argc, JS::Value* vp);
|
||||
extern JS_FRIEND_API(bool)
|
||||
proxy_Construct(JSContext* cx, unsigned argc, JS::Value* vp);
|
||||
extern JS_FRIEND_API(JSObject*)
|
||||
proxy_innerObject(JSObject* obj);
|
||||
extern JS_FRIEND_API(bool)
|
||||
proxy_Watch(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::HandleObject callable);
|
||||
extern JS_FRIEND_API(bool)
|
||||
proxy_Unwatch(JSContext* cx, JS::HandleObject obj, JS::HandleId id);
|
||||
extern JS_FRIEND_API(bool)
|
||||
proxy_GetElements(JSContext* cx, JS::HandleObject proxy, uint32_t begin, uint32_t end,
|
||||
ElementAdder* adder);
|
||||
extern JS_FRIEND_API(JSString*)
|
||||
proxy_FunToString(JSContext* cx, JS::HandleObject proxy, unsigned indent);
|
||||
|
||||
/**
|
||||
* A class of objects that return source code on demand.
|
||||
|
|
|
@ -543,9 +543,9 @@ Proxy::trace(JSTracer* trc, JSObject* proxy)
|
|||
handler->trace(trc, proxy);
|
||||
}
|
||||
|
||||
bool
|
||||
js::proxy_LookupProperty(JSContext* cx, HandleObject obj, HandleId id,
|
||||
MutableHandleObject objp, MutableHandleShape propp)
|
||||
static bool
|
||||
proxy_LookupProperty(JSContext* cx, HandleObject obj, HandleId id,
|
||||
MutableHandleObject objp, MutableHandleShape propp)
|
||||
{
|
||||
bool found;
|
||||
if (!Proxy::has(cx, obj, id, &found))
|
||||
|
@ -561,56 +561,14 @@ js::proxy_LookupProperty(JSContext* cx, HandleObject obj, HandleId id,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
js::proxy_DefineProperty(JSContext* cx, HandleObject obj, HandleId id,
|
||||
Handle<PropertyDescriptor> desc,
|
||||
ObjectOpResult& result)
|
||||
{
|
||||
return Proxy::defineProperty(cx, obj, id, desc, result);
|
||||
}
|
||||
|
||||
bool
|
||||
js::proxy_HasProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, bool* foundp)
|
||||
{
|
||||
return Proxy::has(cx, obj, id, foundp);
|
||||
}
|
||||
|
||||
bool
|
||||
js::proxy_GetProperty(JSContext* cx, HandleObject obj, HandleValue receiver, HandleId id,
|
||||
MutableHandleValue vp)
|
||||
{
|
||||
return Proxy::get(cx, obj, receiver, id, vp);
|
||||
}
|
||||
|
||||
bool
|
||||
js::proxy_SetProperty(JSContext* cx, HandleObject obj, HandleId id, HandleValue v,
|
||||
HandleValue receiver, ObjectOpResult& result)
|
||||
{
|
||||
return Proxy::set(cx, obj, id, v, receiver, result);
|
||||
}
|
||||
|
||||
bool
|
||||
js::proxy_GetOwnPropertyDescriptor(JSContext* cx, HandleObject obj, HandleId id,
|
||||
MutableHandle<PropertyDescriptor> desc)
|
||||
{
|
||||
return Proxy::getOwnPropertyDescriptor(cx, obj, id, desc);
|
||||
}
|
||||
|
||||
bool
|
||||
js::proxy_DeleteProperty(JSContext* cx, HandleObject obj, HandleId id, ObjectOpResult& result)
|
||||
static bool
|
||||
proxy_DeleteProperty(JSContext* cx, HandleObject obj, HandleId id, ObjectOpResult& result)
|
||||
{
|
||||
if (!Proxy::delete_(cx, obj, id, result))
|
||||
return false;
|
||||
return SuppressDeletedProperty(cx, obj, id); // XXX is this necessary?
|
||||
}
|
||||
|
||||
void
|
||||
js::proxy_Trace(JSTracer* trc, JSObject* obj)
|
||||
{
|
||||
MOZ_ASSERT(obj->is<ProxyObject>());
|
||||
ProxyObject::trace(trc, obj);
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
ProxyObject::trace(JSTracer* trc, JSObject* obj)
|
||||
{
|
||||
|
@ -656,30 +614,24 @@ js::proxy_WeakmapKeyDelegate(JSObject* obj)
|
|||
return obj->as<ProxyObject>().handler()->weakmapKeyDelegate(obj);
|
||||
}
|
||||
|
||||
void
|
||||
js::proxy_Finalize(FreeOp* fop, JSObject* obj)
|
||||
static void
|
||||
proxy_Finalize(FreeOp* fop, JSObject* obj)
|
||||
{
|
||||
// Suppress a bogus warning about finalize().
|
||||
JS::AutoSuppressGCAnalysis nogc;
|
||||
|
||||
MOZ_ASSERT(obj->is<ProxyObject>());
|
||||
obj->as<ProxyObject>().handler()->finalize(fop, obj);
|
||||
js_free(detail::GetProxyDataLayout(obj)->values);
|
||||
js_free(js::detail::GetProxyDataLayout(obj)->values);
|
||||
}
|
||||
|
||||
void
|
||||
js::proxy_ObjectMoved(JSObject* obj, const JSObject* old)
|
||||
static void
|
||||
proxy_ObjectMoved(JSObject* obj, const JSObject* old)
|
||||
{
|
||||
MOZ_ASSERT(obj->is<ProxyObject>());
|
||||
obj->as<ProxyObject>().handler()->objectMoved(obj, old);
|
||||
}
|
||||
|
||||
bool
|
||||
js::proxy_HasInstance(JSContext* cx, HandleObject proxy, MutableHandleValue v, bool* bp)
|
||||
{
|
||||
return Proxy::hasInstance(cx, proxy, v, bp);
|
||||
}
|
||||
|
||||
bool
|
||||
js::proxy_Call(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
|
@ -698,31 +650,6 @@ js::proxy_Construct(JSContext* cx, unsigned argc, Value* vp)
|
|||
return Proxy::construct(cx, proxy, args);
|
||||
}
|
||||
|
||||
bool
|
||||
js::proxy_Watch(JSContext* cx, HandleObject obj, HandleId id, HandleObject callable)
|
||||
{
|
||||
return Proxy::watch(cx, obj, id, callable);
|
||||
}
|
||||
|
||||
bool
|
||||
js::proxy_Unwatch(JSContext* cx, HandleObject obj, HandleId id)
|
||||
{
|
||||
return Proxy::unwatch(cx, obj, id);
|
||||
}
|
||||
|
||||
bool
|
||||
js::proxy_GetElements(JSContext* cx, HandleObject proxy, uint32_t begin, uint32_t end,
|
||||
ElementAdder* adder)
|
||||
{
|
||||
return Proxy::getElements(cx, proxy, begin, end, adder);
|
||||
}
|
||||
|
||||
JSString*
|
||||
js::proxy_FunToString(JSContext* cx, HandleObject proxy, unsigned indent)
|
||||
{
|
||||
return Proxy::fun_toString(cx, proxy, indent);
|
||||
}
|
||||
|
||||
const ClassOps js::ProxyClassOps = {
|
||||
nullptr, /* addProperty */
|
||||
nullptr, /* delProperty */
|
||||
|
@ -731,29 +658,29 @@ const ClassOps js::ProxyClassOps = {
|
|||
nullptr, /* enumerate */
|
||||
nullptr, /* resolve */
|
||||
nullptr, /* mayResolve */
|
||||
js::proxy_Finalize, /* finalize */
|
||||
proxy_Finalize, /* finalize */
|
||||
nullptr, /* call */
|
||||
js::proxy_HasInstance, /* hasInstance */
|
||||
Proxy::hasInstance, /* hasInstance */
|
||||
nullptr, /* construct */
|
||||
js::proxy_Trace, /* trace */
|
||||
ProxyObject::trace, /* trace */
|
||||
};
|
||||
|
||||
const ClassExtension js::ProxyClassExtension = PROXY_MAKE_EXT(
|
||||
js::proxy_ObjectMoved
|
||||
proxy_ObjectMoved
|
||||
);
|
||||
|
||||
const ObjectOps js::ProxyObjectOps = {
|
||||
js::proxy_LookupProperty,
|
||||
js::proxy_DefineProperty,
|
||||
js::proxy_HasProperty,
|
||||
js::proxy_GetProperty,
|
||||
js::proxy_SetProperty,
|
||||
js::proxy_GetOwnPropertyDescriptor,
|
||||
js::proxy_DeleteProperty,
|
||||
js::proxy_Watch, js::proxy_Unwatch,
|
||||
js::proxy_GetElements,
|
||||
proxy_LookupProperty,
|
||||
Proxy::defineProperty,
|
||||
Proxy::has,
|
||||
Proxy::get,
|
||||
Proxy::set,
|
||||
Proxy::getOwnPropertyDescriptor,
|
||||
proxy_DeleteProperty,
|
||||
Proxy::watch, Proxy::unwatch,
|
||||
Proxy::getElements,
|
||||
nullptr, /* enumerate */
|
||||
js::proxy_FunToString
|
||||
Proxy::fun_toString
|
||||
};
|
||||
|
||||
const Class js::ProxyObject::proxyClass =
|
||||
|
|
|
@ -74,6 +74,11 @@ class Proxy
|
|||
static void trace(JSTracer* trc, JSObject* obj);
|
||||
};
|
||||
|
||||
bool
|
||||
proxy_Call(JSContext* cx, unsigned argc, Value* vp);
|
||||
bool
|
||||
proxy_Construct(JSContext* cx, unsigned argc, Value* vp);
|
||||
|
||||
} /* namespace js */
|
||||
|
||||
#endif /* proxy_Proxy_h */
|
||||
|
|
|
@ -91,13 +91,10 @@ class ProxyObject : public ShapedObject
|
|||
// are "sane". They have to quack enough like proxies for us to belive
|
||||
// they should be treated as such.
|
||||
|
||||
// proxy_Trace is just a trivial wrapper around ProxyObject::trace for
|
||||
// friend api exposure.
|
||||
|
||||
// Proxy classes are not allowed to have call or construct hooks directly. Their
|
||||
// callability is instead decided by handler()->isCallable().
|
||||
return clasp->isProxy() &&
|
||||
clasp->isTrace(proxy_Trace) &&
|
||||
clasp->isTrace(ProxyObject::trace) &&
|
||||
!clasp->getCall() && !clasp->getConstruct();
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче