ProxyClass isn't for proxies - it's for the Proxy constructor on the global.


On Wed, Jun 19, 2013 at 11:33 PM, Nicholas Nethercote <
[email protected]> wrote:

> Hi,
>
> Here's some code from jsproxy.h:
>
>
> inline bool IsObjectProxyClass(const Class *clasp)
> {
>     return clasp == &js::ObjectProxyClass || clasp ==
> &js::OuterWindowProxyClass;
> }
>
> inline bool IsFunctionProxyClass(const Class *clasp)
> {
>     return clasp == &js::FunctionProxyClass;
> }
>
> inline bool IsProxy(JSObject *obj)
> {
>     Class *clasp = GetObjectClass(obj);
>     return IsObjectProxyClass(clasp) || IsFunctionProxyClass(clasp);
> }
>
>
> So... IsProxy() succeeds if an object has one of the following
> classes:  FunctionProxyClass, ObjectProxyClass, OuterWindowProxyClass.
>  However, it fails if the object's class is ProxyClass.  This is...
> surprising.  Is it a bug?
> If I try changing IsProxy() to allow ProxyClass I get assertion failures.
>
> There's a similar case in jsfriendapi.h where ProxyClass is ignored:
>
> inline bool
> GetObjectProto(JSContext *cx, JS::Handle<JSObject*> obj,
> JS::MutableHandle<JSObject*> proto)
> {
>     // njn: hmm
>     js::Class *clasp = GetObjectClass(obj);
>     if (clasp == &js::ObjectProxyClass ||
>         clasp == &js::OuterWindowProxyClass ||
>         clasp == &js::FunctionProxyClass)
>     {
>         return JS_GetPrototype(cx, obj, proto.address());
>     }
>
>
>
> Nick
> _______________________________________________
> dev-tech-js-engine-internals mailing list
> [email protected]
> https://lists.mozilla.org/listinfo/dev-tech-js-engine-internals
>
_______________________________________________
dev-tech-js-engine-internals mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-internals

Reply via email to