Bug 1470325 - Update Codegen.py to emit Foo_Binding instead of FooBinding. - r=bz,qdot draft
authorJeff Gilbert <jgilbert@mozilla.com>
Mon, 25 Jun 2018 14:13:34 -0700
changeset 810950 0d80ef0279ff8cf11b6dab71b27bbbcf30645af5
parent 804493 da28b92efe6f6acaf79545697415b82038143338
child 810951 8c675731a513758d4f439769e5dd4d955949a5e1
push id114165
push userbmo:jgilbert@mozilla.com
push dateTue, 26 Jun 2018 19:49:43 +0000
reviewersbz, qdot
bugs1470325
milestone62.0a1
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):
@@ -13633,23 +13633,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
@@ -14912,17 +14912,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,
@@ -15328,17 +15328,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;
@@ -16848,17 +16848,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():
     """
@@ -17141,22 +17141,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:
@@ -17165,17 +17165,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))))
 
@@ -17630,17 +17630,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
@@ -365,17 +365,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'])