Bug 1370794 - Replace some 0 by false in the dom bindings code generation r?ehsan draft
authorSylvestre Ledru <sledru@mozilla.com>
Wed, 07 Feb 2018 12:05:45 +0100
changeset 752060 0da6edf23a3967476177727288290bd8e5fb653a
parent 751903 e1954b02d9e39bdb7c1f17aa95ca9cad5d5c14ae
child 752061 109a3298f9d3e116359b34a436fc167cba74c929
push id98157
push userbmo:sledru@mozilla.com
push dateWed, 07 Feb 2018 14:27:36 +0000
reviewersehsan
bugs1370794
milestone60.0a1
Bug 1370794 - Replace some 0 by false in the dom bindings code generation r?ehsan MozReview-Commit-ID: IRErUEAlkTc
dom/bindings/Codegen.py
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -5377,17 +5377,17 @@ def getJSToNativeConversionInfo(type, de
                 if booleanConversion:
                     other.append(CGIfWrapper(booleanConversion[0],
                                              "${val}.isBoolean()"))
                 other.append(numericConversion[0])
             else:
                 assert booleanConversion
                 other.append(booleanConversion[0])
 
-            other = CGWrapper(CGIndenter(other), pre="do {\n", post="} while (0);\n")
+            other = CGWrapper(CGIndenter(other), pre="do {\n", post="} while (false);\n")
             if hasObjectTypes or setDictionary:
                 other = CGWrapper(CGIndenter(other), "{\n", post="}\n")
                 if object:
                     templateBody = CGElseChain([templateBody, other])
                 else:
                     other = CGWrapper(other, pre="if (!done) ")
                     templateBody = CGList([templateBody, other])
             else:
@@ -6774,17 +6774,17 @@ def getWrapTemplateForType(type, descrip
             // Scope for 'tmp'
             {
               JS::Rooted<JS::Value> tmp(cx);
               for (uint32_t ${index} = 0; ${index} < length; ++${index}) {
                 // Control block to let us common up the JS_DefineElement calls when there
                 // are different ways to succeed at wrapping the object.
                 do {
                   $*{innerTemplate}
-                } while (0);
+                } while (false);
                 if (!JS_DefineElement(cx, returnArray, ${index}, tmp,
                                       JSPROP_ENUMERATE)) {
                   $*{exceptionCode}
                 }
               }
             }
             $*{set}
             """,
@@ -6840,17 +6840,17 @@ def getWrapTemplateForType(type, descrip
             {
               JS::Rooted<JS::Value> tmp(cx);
               for (auto& entry : ${result}.Entries()) {
                 auto& ${valueName} = entry.mValue;
                 // Control block to let us common up the JS_DefineUCProperty calls when there
                 // are different ways to succeed at wrapping the value.
                 do {
                   $*{innerTemplate}
-                } while (0);
+                } while (false);
                 $*{expandedKeyDecl}
                 if (!JS_DefineUCProperty(cx, returnObj,
                                          ${keyName}.BeginReading(),
                                          ${keyName}.Length(), tmp,
                                          JSPROP_ENUMERATE)) {
                   $*{exceptionCode}
                 }
               }
@@ -8095,17 +8095,17 @@ class CGPerSignatureCall(CGThing):
 
             wrapCode = fill(
                 """
                 {
                   JS::Rooted<JSObject*> conversionScope(cx, ${conversionScope});
                   JSAutoCompartment ac(cx, conversionScope);
                   do { // block we break out of when done wrapping
                     $*{wrapCode}
-                  } while (0);
+                  } while (false);
                   $*{postConversionSteps}
                 }
                 { // And now store things in the compartment of our slotStorage.
                   JSAutoCompartment ac(cx, slotStorage);
                   $*{slotStorageSteps}
                 }
                 // And now make sure args.rval() is in the caller compartment
                 return ${maybeWrap}(cx, args.rval());
@@ -8498,17 +8498,17 @@ class CGMethodCall(CGThing):
                 # above.
                 caseBody.append(CGGeneric("if (%s.isObject()) {\n" %
                                           distinguishingArg))
                 for sig in objectSigs:
                     caseBody.append(CGIndenter(CGGeneric("do {\n")))
                     # Indent by 4, since we need to indent further
                     # than our "do" statement
                     tryCall(sig, 4, isDefinitelyObject=True)
-                    caseBody.append(CGIndenter(CGGeneric("} while (0);\n")))
+                    caseBody.append(CGIndenter(CGGeneric("} while (false);\n")))
 
                 caseBody.append(CGGeneric("}\n"))
 
             # Now we only have to consider booleans, numerics, and strings.  If
             # we only have one of them, then we can just output it.  But if not,
             # then we need to output some of the cases conditionally: if we have
             # a string overload, then boolean and numeric are conditional, and
             # if not then boolean is conditional if we have a numeric overload.
@@ -13672,17 +13672,17 @@ class CGDictionary(CGThing):
 
         # Now make sure that our successCode can actually break out of the
         # conversion.  This incidentally gives us a scope for 'temp' and
         # 'currentValue'.
         conversion = CGWrapper(
             CGIndenter(conversion),
             pre=("do {\n"
                  "  // block for our 'break' successCode and scope for 'temp' and 'currentValue'\n"),
-            post="} while(0);\n")
+            post="} while(false);\n")
         if member.canHaveMissingValue():
             # Only do the conversion if we have a value
             conversion = CGIfWrapper(conversion, "%s.WasPassed()" % memberLoc)
         (conditions, conditionsSetup) = getConditionList(member, "cx", "obj")
         if conditionsSetup is not None:
             raise TypeError("We don't support Pref annotations on dictionary "
                             "members.  If we start to, we need to make sure all "
                             "the variable names conditionsSetup uses for a "
@@ -16219,17 +16219,17 @@ class CallbackMember(CGNativeMember):
 
         # Do them back to front, so our argc modifications will work
         # correctly, because we examine trailing arguments first.
         argConversions.reverse()
         # Wrap each one in a scope so that any locals it has don't leak out, and
         # also so that we can just "break;" for our successCode.
         argConversions = [CGWrapper(CGIndenter(CGGeneric(c)),
                                     pre="do {\n",
-                                    post="} while (0);\n")
+                                    post="} while (false);\n")
                           for c in argConversions]
         if self.argCount > 0:
             argConversions.insert(0, self.getArgcDecl())
         # And slap them together.
         return CGList(argConversions, "\n").define() + "\n"
 
     def getArgConversion(self, i, arg):
         argval = arg.identifier.name