Bug 803068 - Remove toBaseProxyHandler and toWrapper. r=ejpbruel
authorBobby Holley <bobbyholley@gmail.com>
Mon, 29 Oct 2012 16:52:54 +0100
changeset 111813 8a2b481bb4d141668205f2cb032180f4e408cf8b
parent 111812 44d874f51c28266628fd367311002929b8c8197a
child 111814 f677f91c89c057cc63f40c94c7b52602724c91b5
child 111820 b3b933d6790d9a0b637fadfd49ff46f9eb5de327
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersejpbruel
bugs803068
milestone19.0a1
Bug 803068 - Remove toBaseProxyHandler and toWrapper. r=ejpbruel
js/src/jsproxy.h
js/src/jswrapper.cpp
js/src/jswrapper.h
--- a/js/src/jsproxy.h
+++ b/js/src/jsproxy.h
@@ -66,30 +66,16 @@ class JS_FRIEND_API(BaseProxyHandler) {
     inline void *family() {
         return mFamily;
     }
 
     virtual bool isOuterWindow() {
         return false;
     }
 
-    /*
-     * The function Wrapper::wrapperHandler takes a pointer to a
-     * BaseProxyHandler and returns a pointer to a Wrapper if and only if the
-     * BaseProxyHandler is a wrapper handler (otherwise, it returns NULL).
-     *
-     * Unfortunately, we can't inherit Wrapper from BaseProxyHandler, since that
-     * would create a dreaded diamond, and we can't use dynamic_cast to cast
-     * BaseProxyHandler to Wrapper, since that would require us to compile with
-     * run-time type information. Hence the need for this virtual function.
-     */
-    virtual Wrapper *toWrapper() {
-        return NULL;
-    }
-
     /* ES5 Harmony fundamental proxy traps. */
     virtual bool getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id,
                                        bool set, PropertyDescriptor *desc) = 0;
     virtual bool getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy,
                                           jsid id, bool set,
                                           PropertyDescriptor *desc) = 0;
     virtual bool defineProperty(JSContext *cx, JSObject *proxy, jsid id,
                                 PropertyDescriptor *desc) = 0;
--- a/js/src/jswrapper.cpp
+++ b/js/src/jswrapper.cpp
@@ -47,25 +47,25 @@ Wrapper::New(JSContext *cx, JSObject *ob
 
 #if JS_HAS_XML_SUPPORT
     if (obj->isXML()) {
         JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
                              JSMSG_CANT_WRAP_XML_OBJECT);
         return NULL;
     }
 #endif
-    return NewProxyObject(cx, handler->toBaseProxyHandler(), ObjectValue(*obj),
-                          proto, parent, obj->isCallable() ? obj : NULL, NULL);
+    return NewProxyObject(cx, handler, ObjectValue(*obj), proto, parent,
+                          obj->isCallable() ? obj : NULL, NULL);
 }
 
 Wrapper *
 Wrapper::wrapperHandler(RawObject wrapper)
 {
     JS_ASSERT(wrapper->isWrapper());
-    return GetProxyHandler(wrapper)->toWrapper();
+    return static_cast<Wrapper*>(GetProxyHandler(wrapper));
 }
 
 JSObject *
 Wrapper::wrappedObject(RawObject wrapper)
 {
     JS_ASSERT(wrapper->isWrapper());
     return GetProxyTargetObject(wrapper);
 }
--- a/js/src/jswrapper.h
+++ b/js/src/jswrapper.h
@@ -87,24 +87,16 @@ class JS_FRIEND_API(Wrapper) : public Di
      */
     virtual bool enter(JSContext *cx, JSObject *wrapper, jsid id, Action act,
                        bool *bp);
 
     explicit Wrapper(unsigned flags, bool hasPrototype = false);
 
     virtual ~Wrapper();
 
-    virtual BaseProxyHandler* toBaseProxyHandler() {
-        return this;
-    }
-
-    virtual Wrapper *toWrapper() {
-        return this;
-    }
-
     /* ES5 Harmony fundamental wrapper traps. */
     virtual bool getPropertyDescriptor(JSContext *cx, JSObject *wrapper,
                                        jsid id, bool set,
                                        PropertyDescriptor *desc) MOZ_OVERRIDE;
     virtual bool getOwnPropertyDescriptor(JSContext *cx, JSObject *wrapper,
                                           jsid id, bool set,
                                           PropertyDescriptor *desc) MOZ_OVERRIDE;
     virtual bool defineProperty(JSContext *cx, JSObject *wrapper, jsid id,