Bug 1470325 - Update Codegen.py to emit Foo_Binding instead of FooBinding. - r=bz,qdot
authorJeff Gilbert <jgilbert@mozilla.com>
Mon, 25 Jun 2018 14:13:34 -0700
changeset 423858 ba24316f5d8476f56a429fdae82052e2d256983c
parent 423857 516d304306218eae927a454852d2a379513c3427
child 423859 a97feb8161b7a4c60a539d83cb702a6e50fab1b1
push id34193
push userdluca@mozilla.com
push dateWed, 27 Jun 2018 10:27:30 +0000
treeherdermozilla-central@e5fd22d48987 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, qdot
bugs1470325
milestone63.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 1470325 - Update Codegen.py to emit Foo_Binding instead of FooBinding. - r=bz,qdot MozReview-Commit-ID: CFIQpIRsXIU
dom/bindings/Codegen.py
xpcom/reflect/xptinfo/xptcodegen.py
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -51,17 +51,17 @@ def mayUseXrayExpandoSlots(descriptor, a
 def toStringBool(arg):
     """
     Converts IDL/Python Boolean (True/False) to C++ Boolean (true/false)
     """
     return str(not not arg).lower()
 
 
 def toBindingNamespace(arg):
-    return arg + "Binding"
+    return arg + "_Binding"
 
 
 def isTypeCopyConstructible(type):
     # Nullable and sequence stuff doesn't affect copy-constructibility
     type = type.unroll()
     return (type.isPrimitive() or type.isString() or type.isEnum() or
             (type.isUnion() and
              CGUnionStruct.isUnionCopyConstructible(type)) or
@@ -1738,24 +1738,24 @@ class CGClassFinalizeHook(CGAbstractClas
     def generate_code(self):
         return finalizeHook(self.descriptor, self.name,
                             self.args[0].name, self.args[1].name).define()
 
 
 def objectMovedHook(descriptor, hookName, obj, old):
     assert descriptor.wrapperCache
     return fill("""
-	if (self) {
-	  UpdateWrapper(self, self, ${obj}, ${old});
-	}
-
-	return 0;
-	""",
-	obj=obj,
-	old=old)
+        if (self) {
+          UpdateWrapper(self, self, ${obj}, ${old});
+        }
+
+        return 0;
+        """,
+        obj=obj,
+        old=old)
 
 
 class CGClassObjectMovedHook(CGAbstractClassHook):
     """
     A hook for objectMovedOp, used to update the wrapper cache when an object it
     is holding moves.
     """
     def __init__(self, descriptor):
@@ -13636,23 +13636,23 @@ class CGRegisterGlobalNames(CGAbstractMe
         CGAbstractMethod.__init__(self, None, 'RegisterWebIDLGlobalNames',
                                   'void', [])
         self.config = config
 
     def definition_body(self):
         def getCheck(desc):
             if not desc.isExposedConditionally():
                 return "nullptr"
-            return "%sBinding::ConstructorEnabled" % desc.name
+            return "%s_Binding::ConstructorEnabled" % desc.name
 
         define = ""
         currentOffset = 0
         for (name, desc) in getGlobalNames(self.config):
             length = len(name)
-            define += "WebIDLGlobalNameHash::Register(%i, %i, %sBinding::CreateInterfaceObjects, %s, constructors::id::%s);\n" % (
+            define += "WebIDLGlobalNameHash::Register(%i, %i, %s_Binding::CreateInterfaceObjects, %s, constructors::id::%s);\n" % (
                 currentOffset, length, desc.name, getCheck(desc), desc.name)
             currentOffset += length + 1 # Add trailing null.
         return define
 
 
 def dependencySortObjects(objects, dependencyGetter, nameGetter):
     """
     Sort IDL objects with dependencies on each other such that if A
@@ -14915,17 +14915,17 @@ class CGExampleClass(CGBindingImplClass)
         else:
             reflectorArg = ", JS::MutableHandle<JSObject*> aReflector"
             reflectorPassArg = ", aReflector"
             returnType = "bool"
         classImpl = ccImpl + ctordtor + "\n" + dedent("""
             ${returnType}
             ${nativeType}::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto${reflectorArg})
             {
-              return ${ifaceName}Binding::Wrap(aCx, this, aGivenProto${reflectorPassArg});
+              return ${ifaceName}_Binding::Wrap(aCx, this, aGivenProto${reflectorPassArg});
             }
 
             """)
         return string.Template(classImpl).substitute(
             ifaceName=self.descriptor.name,
             nativeType=self.nativeLeafName(self.descriptor),
             parentType=self.nativeLeafName(self.parentDesc) if self.parentIface else "",
             returnType=returnType,
@@ -15331,17 +15331,17 @@ class CGJSImplClass(CGBindingImplClass):
                          methods=self.methodDecls,
                          decorators=decorators,
                          extradeclarations=extradeclarations,
                          extradefinitions=extradefinitions)
 
     def getWrapObjectBody(self):
         return fill(
             """
-            JS::Rooted<JSObject*> obj(aCx, ${name}Binding::Wrap(aCx, this, aGivenProto));
+            JS::Rooted<JSObject*> obj(aCx, ${name}_Binding::Wrap(aCx, this, aGivenProto));
             if (!obj) {
               return nullptr;
             }
 
             // Now define it on our chrome object
             JSAutoRealm ar(aCx, mImpl->CallbackOrNull());
             if (!JS_WrapObject(aCx, &obj)) {
               return nullptr;
@@ -16851,17 +16851,17 @@ class CGIterableMethodGenerator(CGGeneri
                 """,
                 ifaceName=descriptor.interface.identifier.name))
             return
         CGGeneric.__init__(self, fill(
             """
             typedef ${iterClass} itrType;
             RefPtr<itrType> result(new itrType(self,
                                                  itrType::IterableIteratorType::${itrMethod},
-                                                 &${ifaceName}IteratorBinding::Wrap));
+                                                 &${ifaceName}Iterator_Binding::Wrap));
             """,
             iterClass=iteratorNativeType(descriptor),
             ifaceName=descriptor.interface.identifier.name,
             itrMethod=methodName.title()))
 
 
 class GlobalGenRoots():
     """
@@ -17144,22 +17144,22 @@ class GlobalGenRoots():
         curr = CGIncludeGuard('RegisterWorkletBindings', curr)
 
         # Done.
         return curr
 
     @staticmethod
     def ResolveSystemBinding(config):
         curr = CGList([], "\n")
-        
+
         descriptors = config.getDescriptors(hasInterfaceObject=True,
                                             isExposedInSystemGlobals=True,
                                             register=True)
         properties = [desc.name for desc in descriptors]
-        
+
         curr.append(CGStringTable("IdString", properties, static=True))
 
         initValues = []
         for desc in descriptors:
             bindingNS = toBindingNamespace(desc.name)
             if desc.isExposedConditionally():
                 enabled = "%s::ConstructorEnabled" % bindingNS
             else:
@@ -17168,17 +17168,17 @@ class GlobalGenRoots():
             initValues.append("{ %s, %s },\n" % (enabled, define))
         curr.append(CGGeneric(fill("""
             struct SystemProperty
             {
               WebIDLGlobalNameHash::ConstructorEnabled enabled;
               ProtoGetter define;
               PinnedStringId id;
             };
-          
+
             static SystemProperty properties[] = {
               $*{init}
             };
 
             static bool idsInited = false;
             """,
             init="".join(initValues))))
 
@@ -17633,17 +17633,17 @@ class CGEventClass(CGBindingImplClass):
 
         CGClass.__init__(self, className,
                          bases=[ClassBase(self.parentType)],
                          methods=extraMethods+self.methodDecls,
                          members=members,
                          extradeclarations=baseDeclarations)
 
     def getWrapObjectBody(self):
-        return "return %sBinding::Wrap(aCx, this, aGivenProto);\n" % self.descriptor.name
+        return "return %s_Binding::Wrap(aCx, this, aGivenProto);\n" % self.descriptor.name
 
     def needCC(self):
         return (len(self.membersNeedingCC) != 0 or
                 len(self.membersNeedingTrace) != 0)
 
     def implTraverse(self):
         retVal = ""
         for m in self.membersNeedingCC:
--- a/xpcom/reflect/xptinfo/xptcodegen.py
+++ b/xpcom/reflect/xptinfo/xptcodegen.py
@@ -373,17 +373,17 @@ def link_to_cpp(interfaces, fd):
         assert iface['shim'] is not None
 
         # Add an include for the Binding file for the shim.
         includes.add("mozilla/dom/%sBinding.h" %
                      (iface['shimfile'] or iface['shim']))
 
         # Add the property hook reference to the sPropHooks table.
         prophooks.append(
-            "mozilla::dom::%sBinding::sNativePropertyHooks, // %d = %s(%s)" %
+            "mozilla::dom::%s_Binding::sNativePropertyHooks, // %d = %s(%s)" %
             (iface['shim'], len(prophooks), iface['name'], iface['shim']))
 
     def collect_base_info(iface):
         methods = 0
         consts = 0
         while iface is not None:
             methods += len(iface['methods'])
             consts += len(iface['consts'])