Bug 987007, part 2a - Instead of generating identical DOMProxyHandler::set() methods for many interfaces, implement it in a common base class. r=bz.
authorJason Orendorff <jorendorff@mozilla.com>
Fri, 25 Apr 2014 15:07:18 -0500
changeset 198837 cfe98fe62a8fb5138ed80d8d1024cb66687e6f8a
parent 198836 b588b9285415b66ecdf297b9bc7cbb557f94a5a4
child 198838 d13dd65b4d04253587132162137923d1e1377206
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs987007
milestone31.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 987007, part 2a - Instead of generating identical DOMProxyHandler::set() methods for many interfaces, implement it in a common base class. r=bz.
dom/bindings/Codegen.py
dom/bindings/DOMJSProxyHandler.cpp
dom/bindings/DOMJSProxyHandler.h
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -9614,40 +9614,16 @@ class CGDOMJSProxyHandler_get(ClassMetho
             $*{named}
             vp.setUndefined();
             return true;
             """,
             indexedOrExpando=getIndexedOrExpando,
             named=getNamed)
 
 
-class CGDOMJSProxyHandler_set(ClassMethod):
-    def __init__(self, descriptor):
-        args = [Argument('JSContext*', 'cx'),
-                Argument('JS::Handle<JSObject*>', 'proxy'),
-                Argument('JS::Handle<JSObject*>', 'receiver'),
-                Argument('JS::Handle<jsid>', 'id'),
-                Argument('bool', 'strict'),
-                Argument('JS::MutableHandle<JS::Value>', 'vp')]
-        ClassMethod.__init__(self, "set", "bool", args, virtual=True, override=True)
-        self.descriptor = descriptor
-
-    def getBody(self):
-        return dedent("""
-            MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
-                       "Should not have a XrayWrapper here");
-            bool done;
-            if (!setCustom(cx, proxy, id, vp, &done))
-                return false;
-            if (done)
-                return true;
-            return mozilla::dom::DOMProxyHandler::set(cx, proxy, receiver, id, strict, vp);
-            """)
-
-
 class CGDOMJSProxyHandler_setCustom(ClassMethod):
     def __init__(self, descriptor):
         args = [Argument('JSContext*', 'cx'),
                 Argument('JS::Handle<JSObject*>', 'proxy'),
                 Argument('JS::Handle<jsid>', 'id'),
                 Argument('JS::MutableHandle<JS::Value>', 'vp'),
                 Argument('bool*', 'done')]
         ClassMethod.__init__(self, "setCustom", "bool", args, virtual=True, override=True)
@@ -9827,17 +9803,16 @@ class CGDOMJSProxyHandler(CGClass):
                    CGDOMJSProxyHandler_getInstance(),
                    CGDOMJSProxyHandler_delete(descriptor)]
         if descriptor.supportsIndexedProperties():
             methods.append(CGDOMJSProxyHandler_slice(descriptor))
         if (descriptor.operations['IndexedSetter'] is not None or
             (descriptor.operations['NamedSetter'] is not None and
              descriptor.interface.getExtendedAttribute('OverrideBuiltins'))):
             methods.append(CGDOMJSProxyHandler_setCustom(descriptor))
-            methods.append(CGDOMJSProxyHandler_set(descriptor))
 
         CGClass.__init__(self, 'DOMProxyHandler',
                          bases=[ClassBase('mozilla::dom::DOMProxyHandler')],
                          methods=methods)
 
 
 class CGDOMJSProxyHandlerDeclarer(CGThing):
     """
--- a/dom/bindings/DOMJSProxyHandler.cpp
+++ b/dom/bindings/DOMJSProxyHandler.cpp
@@ -209,16 +209,32 @@ DOMProxyHandler::defineProperty(JSContex
     return false;
   }
 
   bool dummy;
   return js_DefineOwnProperty(cx, expando, id, desc, &dummy);
 }
 
 bool
+DOMProxyHandler::set(JSContext *cx, Handle<JSObject*> proxy, Handle<JSObject*> receiver,
+                     Handle<jsid> id, bool strict, MutableHandle<JS::Value> vp)
+{
+  MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
+             "Should not have a XrayWrapper here");
+  bool done;
+  if (!setCustom(cx, proxy, id, vp, &done)) {
+    return false;
+  }
+  if (done) {
+    return true;
+  }
+  return mozilla::dom::BaseDOMProxyHandler::set(cx, proxy, receiver, id, strict, vp);
+}
+
+bool
 DOMProxyHandler::delete_(JSContext* cx, JS::Handle<JSObject*> proxy,
                          JS::Handle<jsid> id, bool* bp)
 {
   JS::Rooted<JSObject*> expando(cx);
   if (!xpc::WrapperFactory::IsXrayWrapper(proxy) && (expando = GetExpandoObject(proxy))) {
     return JS_DeletePropertyById2(cx, expando, id, bp);
   }
 
--- a/dom/bindings/DOMJSProxyHandler.h
+++ b/dom/bindings/DOMJSProxyHandler.h
@@ -87,16 +87,18 @@ public:
   bool defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id,
                       JS::MutableHandle<JSPropertyDescriptor> desc) MOZ_OVERRIDE
   {
     bool unused;
     return defineProperty(cx, proxy, id, desc, &unused);
   }
   virtual bool defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id,
                               JS::MutableHandle<JSPropertyDescriptor> desc, bool* defined);
+  bool set(JSContext *cx, JS::Handle<JSObject*> proxy, JS::Handle<JSObject*> receiver,
+           JS::Handle<jsid> id, bool strict, JS::MutableHandle<JS::Value> vp) MOZ_OVERRIDE;
   bool delete_(JSContext* cx, JS::Handle<JSObject*> proxy,
                JS::Handle<jsid> id, bool* bp) MOZ_OVERRIDE;
   bool has(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) MOZ_OVERRIDE;
   bool isExtensible(JSContext *cx, JS::Handle<JSObject*> proxy, bool *extensible) MOZ_OVERRIDE;
 
   /*
    * If assigning to proxy[id] hits a named setter with OverrideBuiltins or
    * an indexed setter, call it and set *done to true on success. Otherwise, set