Backed out changeset 61092280cb2a (bug 882541)
authorEd Morley <emorley@mozilla.com>
Mon, 14 Oct 2013 17:30:46 +0100
changeset 164440 8a2bb26229788b6eda1325a509415fbda066e2a2
parent 164439 f313d33bdbc478698baf13e732937a7714d15d15
child 164441 b5dc6d9578e7c8f6d727e72cf768937f567271f0
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs882541
milestone27.0a1
backs out61092280cb2a3939999c7cb30b69943d4f1182cb
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
Backed out changeset 61092280cb2a (bug 882541)
dom/bindings/Codegen.py
dom/bindings/test/TestBindingHeader.h
dom/bindings/test/TestCodeGen.webidl
dom/bindings/test/TestExampleGen.webidl
dom/bindings/test/TestJSImplGen.webidl
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -2698,17 +2698,18 @@ def getJSToNativeConversionInfo(type, de
         if (defaultValue is not None and
             not isinstance(defaultValue, IDLNullValue)):
             raise TypeError("Can't handle non-null default value here")
         return handleDefault(template, codeToSetNull)
 
     # A helper function for wrapping up the template body for
     # possibly-nullable objecty stuff
     def wrapObjectTemplate(templateBody, type, codeToSetNull, failureCode=None):
-        if isNullOrUndefined and type.nullable():
+        if isNullOrUndefined:
+            assert type.nullable()
             # Just ignore templateBody and set ourselves to null.
             # Note that we don't have to worry about default values
             # here either, since we already examined this value.
             return "%s;" % codeToSetNull
 
         if not isDefinitelyObject:
             # Handle the non-object cases by wrapping up the whole
             # thing in an if cascade.
@@ -4982,16 +4983,25 @@ class CGMethodCall(CGThing):
                 code = (
                     "if (args.length() < %d) {\n"
                     '  return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "%s");\n'
                     "}" % (requiredArgs, methodName))
                 self.cgRoot.prepend(
                     CGWrapper(CGIndenter(CGGeneric(code)), pre="\n", post="\n"))
             return
 
+        # We don't handle [TreatUndefinedAs=Missing] arguments in overload
+        # resolution yet.
+        for (_, sigArgs) in signatures:
+            for arg in sigArgs:
+                if arg.treatUndefinedAs == "Missing":
+                    raise TypeError("No support for [TreatUndefinedAs=Missing] "
+                                    "handling in overload resolution yet: %s" %
+                                    arg.location)
+
         # Need to find the right overload
         maxArgCount = method.maxArgCount
         allowedArgCounts = method.allowedArgCounts
 
         argCountCases = []
         for argCount in allowedArgCounts:
             possibleSignatures = method.signaturesForArgCount(argCount)
             if len(possibleSignatures) == 1:
@@ -5071,40 +5081,32 @@ class CGMethodCall(CGThing):
                         isNullOrUndefined=False):
                 assert not isDefinitelyObject or not isNullOrUndefined
                 assert isDefinitelyObject or isNullOrUndefined
                 if isDefinitelyObject:
                     failureCode = "break;"
                 else:
                     failureCode = None
                 type = distinguishingType(signature)
-                # The argument at index distinguishingIndex can't possibly be
-                # unset here, because we've already checked that argc is large
-                # enough that we can examine this argument.  But note that we
-                # still want to claim that optional arguments are optional, in
-                # case undefined was passed in.
-                argIsOptional = (distinguishingArgument(signature).optional and
-                                 not distinguishingArgument(signature).defaultValue)
+                # The argument at index distinguishingIndex can't possibly
+                # be unset here, because we've already checked that argc is
+                # large enough that we can examine this argument.
                 testCode = instantiateJSToNativeConversion(
                     getJSToNativeConversionInfo(type, descriptor,
                                                 failureCode=failureCode,
                                                 isDefinitelyObject=isDefinitelyObject,
                                                 isNullOrUndefined=isNullOrUndefined,
-                                                isOptional=argIsOptional,
                                                 sourceDescription=(argDesc % (distinguishingIndex + 1))),
                     {
                         "declName" : "arg%d" % distinguishingIndex,
                         "holderName" : ("arg%d" % distinguishingIndex) + "_holder",
                         "val" : distinguishingArg,
                         "mutableVal" : distinguishingArg,
-                        "obj" : "obj",
-                        "haveValue": "args.hasDefined(%d)" % distinguishingIndex
-                        },
-                    checkForValue=argIsOptional
-                    )
+                        "obj" : "obj"
+                        })
                 caseBody.append(CGIndenter(testCode, indent));
                 # If we got this far, we know we unwrapped to the right
                 # C++ type, so just do the call.  Start conversion with
                 # distinguishingIndex + 1, since we already converted
                 # distinguishingIndex.
                 caseBody.append(CGIndenter(
                         getPerSignatureCall(signature, distinguishingIndex + 1),
                         indent))
@@ -5130,60 +5132,31 @@ class CGMethodCall(CGThing):
                                for t in distinguishingTypes)
                 if type.isNumeric():
                     distinguishingTypes = (distinguishingType(s) for s in
                                            possibleSignatures)
                     return any(t.isString() or t.isEnum()
                                for t in distinguishingTypes)
                 return True
 
-            def needsNullOrUndefinedCase(type):
-                """
-                Return true if the type needs a special isNullOrUndefined() case
-                """
-                return ((type.nullable() and
-                        hasConditionalConversion(type)) or
-                        type.isDictionary())
-
-            # First check for undefined and optional distinguishing arguments
-            # and output a special branch for that case.  Note that we don't
-            # use distinguishingArgument here because we actualy want to
-            # exclude variadic arguments.  Also note that we skip this check if
-            # we plan to output a isNullOrUndefined() special case for this
-            # argument anyway, since that will subsume our isUndefined() check.
-            # This is safe, because there can be at most one nullable
-            # distinguishing argument, so if we're it we'll definitely get
-            # picked up by the nullable handling.  Also, we can skip this check
-            # if the argument has an unconditional conversion later on.
-            undefSigs = [s for s in possibleSignatures if
-                         distinguishingIndex < len(s[1]) and
-                         s[1][distinguishingIndex].optional and
-                         hasConditionalConversion(s[1][distinguishingIndex].type) and
-                         not needsNullOrUndefinedCase(s[1][distinguishingIndex].type)]
-            # Can't have multiple signatures with an optional argument at the
-            # same index.
-            assert len(undefSigs) < 2
-            if len(undefSigs) > 0:
-                caseBody.append(CGGeneric("if (%s.isUndefined()) {" %
-                                          distinguishingArg))
-                tryCall(undefSigs[0], 2, isNullOrUndefined=True)
-                caseBody.append(CGGeneric("}"))
-
-            # Next, check for null or undefined.  That means looking for
+            # First check for null or undefined.  That means looking for
             # nullable arguments at the distinguishing index and outputting a
             # separate branch for them.  But if the nullable argument has an
             # unconditional conversion, we don't need to do that.  The reason
             # for that is that at most one argument at the distinguishing index
             # is nullable (since two nullable arguments are not
             # distinguishable), and null/undefined values will always fall
             # through to the unconditional conversion we have, if any, since
             # they will fail whatever the conditions on the input value are for
             # our other conversions.
-            nullOrUndefSigs = [s for s in possibleSignatures
-                               if needsNullOrUndefinedCase(distinguishingType(s))]
+            nullOrUndefSigs = [
+                s for s in possibleSignatures
+                if ((distinguishingType(s).nullable() and
+                     hasConditionalConversion(distinguishingType(s))) or
+                    distinguishingType(s).isDictionary())]
             # Can't have multiple nullable types here
             assert len(nullOrUndefSigs) < 2
             if len(nullOrUndefSigs) > 0:
                 caseBody.append(CGGeneric("if (%s.isNullOrUndefined()) {" %
                                           distinguishingArg))
                 tryCall(nullOrUndefSigs[0], 2, isNullOrUndefined=True)
                 caseBody.append(CGGeneric("}"))
 
--- a/dom/bindings/test/TestBindingHeader.h
+++ b/dom/bindings/test/TestBindingHeader.h
@@ -636,22 +636,16 @@ public:
   void Overload10(const Nullable<int32_t>&);
   void Overload10(JSContext*, JS::Handle<JSObject*>);
   void Overload11(int32_t);
   void Overload11(const nsAString&);
   void Overload12(int32_t);
   void Overload12(const Nullable<bool>&);
   void Overload13(const Nullable<int32_t>&);
   void Overload13(bool);
-  void Overload14(const Optional<int32_t>&);
-  void Overload14(TestInterface&);
-  void Overload15(int32_t);
-  void Overload15(const Optional<NonNull<TestInterface> >&);
-  void Overload16(int32_t);
-  void Overload16(const Optional<TestInterface*>&);
 
   // Variadic handling
   void PassVariadicThirdArg(const nsAString&, int32_t,
                             const Sequence<OwningNonNull<TestInterface> >&);
 
   // Conditionally exposed methods/attributes
   bool Prefable1();
   bool Prefable2();
--- a/dom/bindings/test/TestCodeGen.webidl
+++ b/dom/bindings/test/TestCodeGen.webidl
@@ -586,22 +586,16 @@ interface TestInterface {
   void overload10(long? arg);
   void overload10(object arg);
   void overload11(long arg);
   void overload11(DOMString? arg);
   void overload12(long arg);
   void overload12(boolean? arg);
   void overload13(long? arg);
   void overload13(boolean arg);
-  void overload14(optional long arg);
-  void overload14(TestInterface arg);
-  void overload15(long arg);
-  void overload15(optional TestInterface arg);
-  void overload16(long arg);
-  void overload16(optional TestInterface? arg);
 
   // Variadic handling
   void passVariadicThirdArg(DOMString arg1, long arg2, TestInterface... arg3);
 
   // Conditionally exposed methods/attributes
   [Pref="abc.def"]
   readonly attribute boolean prefable1;
   [Pref="abc.def"]
--- a/dom/bindings/test/TestExampleGen.webidl
+++ b/dom/bindings/test/TestExampleGen.webidl
@@ -483,22 +483,16 @@ interface TestExampleInterface {
   void overload10(long? arg);
   void overload10(object arg);
   void overload11(long arg);
   void overload11(DOMString? arg);
   void overload12(long arg);
   void overload12(boolean? arg);
   void overload13(long? arg);
   void overload13(boolean arg);
-  void overload14(optional long arg);
-  void overload14(TestInterface arg);
-  void overload15(long arg);
-  void overload15(optional TestInterface arg);
-  void overload16(long arg);
-  void overload16(optional TestInterface? arg);
 
   // Variadic handling
   void passVariadicThirdArg(DOMString arg1, long arg2, TestInterface... arg3);
 
   // Conditionally exposed methods/attributes
   [Pref="abc.def"]
   readonly attribute boolean prefable1;
   [Pref="abc.def"]
--- a/dom/bindings/test/TestJSImplGen.webidl
+++ b/dom/bindings/test/TestJSImplGen.webidl
@@ -511,22 +511,16 @@ interface TestJSImplInterface {
   void overload10(long? arg);
   void overload10(object arg);
   void overload11(long arg);
   void overload11(DOMString? arg);
   void overload12(long arg);
   void overload12(boolean? arg);
   void overload13(long? arg);
   void overload13(boolean arg);
-  void overload14(optional long arg);
-  void overload14(TestInterface arg);
-  void overload15(long arg);
-  void overload15(optional TestInterface arg);
-  void overload16(long arg);
-  void overload16(optional TestInterface? arg);
 
   // Variadic handling
   void passVariadicThirdArg(DOMString arg1, long arg2, TestJSImplInterface... arg3);
 
   // Miscellania
   [LenientThis] attribute long attrWithLenientThis;
   // FIXME: Bug 863954 Unforgeable things get all confused when
   // non-JS-implemented interfaces inherit from JS-implemented ones or vice