Bug 1330536 part 2. Change Descriptor.getExtendedAttributes to include 'canOOM' information as needed. r=smaug
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 17 Jan 2017 23:52:13 -0500
changeset 374787 555c3c62d3c0bb1e06ae053da5e918e068dbfc06
parent 374786 df802158c65c7368f1b261aabe5d06f7664c954c
child 374788 ec1b482c8b7efdfaddab0378cef686b68edd85ca
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1330536
milestone53.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 1330536 part 2. Change Descriptor.getExtendedAttributes to include 'canOOM' information as needed. r=smaug
dom/bindings/Configuration.py
--- a/dom/bindings/Configuration.py
+++ b/dom/bindings/Configuration.py
@@ -563,45 +563,62 @@ class Descriptor(DescriptorProvider):
     @property
     def hasNamedPropertiesObject(self):
         if self.interface.isExternal():
             return False
 
         return self.isGlobal() and self.supportsNamedProperties()
 
     def getExtendedAttributes(self, member, getter=False, setter=False):
-        def ensureValidThrowsExtendedAttribute(attr):
+        def ensureValidBoolExtendedAttribute(attr, name):
             if (attr is not None and attr is not True):
-                raise TypeError("Unknown value for 'Throws': " + attr[0])
+                raise TypeError("Unknown value for '%s': %s" % (name, attr[0]))
+
+        def ensureValidThrowsExtendedAttribute(attr):
+            ensureValidBoolExtendedAttribute(attr, "Throws")
+
+        def ensureValidCanOOMExtendedAttribute(attr):
+            ensureValidBoolExtendedAttribute(attr, "CanOOM")
 
         def maybeAppendInfallibleToAttrs(attrs, throws):
             ensureValidThrowsExtendedAttribute(throws)
             if throws is None:
                 attrs.append("infallible")
 
+        def maybeAppendCanOOMToAttrs(attrs, canOOM):
+            ensureValidCanOOMExtendedAttribute(canOOM)
+            if canOOM is not None:
+                attrs.append("canOOM")
+
         name = member.identifier.name
         throws = self.interface.isJSImplemented() or member.getExtendedAttribute("Throws")
+        canOOM = member.getExtendedAttribute("CanOOM")
         if member.isMethod():
             # JSObject-returning [NewObject] methods must be fallible,
             # since they have to (fallibly) allocate the new JSObject.
             if (member.getExtendedAttribute("NewObject") and
                 methodReturnsJSObject(member)):
                 throws = True
             attrs = self.extendedAttributes['all'].get(name, [])
             maybeAppendInfallibleToAttrs(attrs, throws)
+            maybeAppendCanOOMToAttrs(attrs, canOOM)
             return attrs
 
         assert member.isAttr()
         assert bool(getter) != bool(setter)
         key = 'getterOnly' if getter else 'setterOnly'
         attrs = self.extendedAttributes['all'].get(name, []) + self.extendedAttributes[key].get(name, [])
         if throws is None:
             throwsAttr = "GetterThrows" if getter else "SetterThrows"
             throws = member.getExtendedAttribute(throwsAttr)
         maybeAppendInfallibleToAttrs(attrs, throws)
+        if canOOM is None:
+            canOOMAttr = "GetterCanOOM" if getter else "SetterCanOOM"
+            canOOM = member.getExtendedAttribute(canOOMAttr)
+        maybeAppendCanOOMToAttrs(attrs, canOOM)
         return attrs
 
     def supportsIndexedProperties(self):
         return self.operations['IndexedGetter'] is not None
 
     def lengthNeedsCallerType(self):
         """
         Determine whether our length getter needs a caller type; this is needed