Bug 868715 part 5. Give all dictionaries a single base class so we can tell when template arguments are dictionaries. r=peterv, a=lsblakk
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 20 May 2013 23:54:11 -0400
changeset 142684 9d0b0b295c8ae199c5c9e15c2fdc626005810a95
parent 142683 2ae4bcadfe9b2b0fae07b8f396f502d8d229300d
child 142685 9c3f7d2cfe56d3de7ff68ee06dc28680acf82181
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv, lsblakk
bugs868715
milestone23.0a2
Bug 868715 part 5. Give all dictionaries a single base class so we can tell when template arguments are dictionaries. r=peterv, a=lsblakk
dom/bindings/BindingDeclarations.h
dom/bindings/Codegen.py
--- a/dom/bindings/BindingDeclarations.h
+++ b/dom/bindings/BindingDeclarations.h
@@ -26,17 +26,23 @@ class nsWrapperCache;
 
 // nsGlobalWindow implements nsWrapperCache, but doesn't always use it. Don't
 // try to use it without fixing that first.
 class nsGlobalWindow;
 
 namespace mozilla {
 namespace dom {
 
-struct MainThreadDictionaryBase
+// Struct that serves as a base class for all dictionaries.  Particularly useful
+// so we can use IsBaseOf to detect dictionary template arguments.
+struct DictionaryBase
+{
+};
+
+struct MainThreadDictionaryBase : public DictionaryBase
 {
 protected:
   bool ParseJSON(JSContext *aCx, const nsAString& aJSON,
                  JS::MutableHandle<JS::Value> aVal);
 };
 
 struct EnumEntry {
   const char* value;
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -7448,28 +7448,28 @@ class CGDictionary(CGThing):
                                          isMember="Dictionary",
                                          isOptional=(not member.defaultValue),
                                          defaultValue=member.defaultValue))
             for member in dictionary.members ]
 
     def declare(self):
         d = self.dictionary
         if d.parent:
-            inheritance = ": public %s " % self.makeClassName(d.parent)
+            inheritance = "%s" % self.makeClassName(d.parent)
         elif not self.workers:
-            inheritance = ": public MainThreadDictionaryBase "
-        else:
-            inheritance = ""
+            inheritance = "MainThreadDictionaryBase"
+        else:
+            inheritance = "DictionaryBase"
         memberDecls = ["  %s %s;" %
                        (self.getMemberType(m),
                         self.makeMemberName(m[0].identifier.name))
                        for m in self.memberInfo]
 
         return (string.Template(
-                "struct ${selfName} ${inheritance}{\n"
+                "struct ${selfName} : public ${inheritance} {\n"
                 "  ${selfName}() {}\n"
                 "  bool Init(JSContext* cx, JS::Handle<JS::Value> val);\n" +
                 ("  bool Init(const nsAString& aJSON);\n" if not self.workers else "") +
                 "  bool ToObject(JSContext* cx, JS::Handle<JSObject*> parentObject, JS::Value *vp) const;\n"
                 "\n" +
                 "\n".join(memberDecls) + "\n"
                 "private:\n"
                 "  // Disallow copy-construction\n"