Bug 1505891 - Allow XPIDL CEnums to be infallible; r=froydnj
authorKyle Machulis <kyle@nonpolynomial.com>
Thu, 08 Nov 2018 20:46:27 +0000
changeset 445199 eb0561d39ac05e07e2a1c25a56a6e12d91840882
parent 445198 d31484f1f03f4d607486cb2531ed0f5839b88332
child 445200 5e71bebd92b581ca9a205b21d0da4a6817d9ac8b
push id35012
push userbtara@mozilla.com
push dateFri, 09 Nov 2018 05:26:19 +0000
treeherdermozilla-central@63eb34f9b171 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1505891
milestone65.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 1505891 - Allow XPIDL CEnums to be infallible; r=froydnj They're just integers, so there's no reason they need to be fallible since they're basically a built-in anyways. Differential Revision: https://phabricator.services.mozilla.com/D11363
xpcom/idl-parser/xpidl/header.py
xpcom/idl-parser/xpidl/xpidl.py
--- a/xpcom/idl-parser/xpidl/header.py
+++ b/xpcom/idl-parser/xpidl/header.py
@@ -409,17 +409,17 @@ def write_interface(iface, fd):
         fd.write("  /* %s */\n" % a.toIDL())
 
         fd.write("  %s%s = 0;\n" % (runScriptAnnotation(a),
                                     attributeAsNative(a, True)))
         if a.infallible:
             realtype = a.realtype.nativeType('in')
             tmpl = attr_builtin_infallible_tmpl
 
-            if a.realtype.kind != 'builtin':
+            if a.realtype.kind != 'builtin' and a.realtype.kind != 'cenum':
                 assert realtype.endswith(' *'), "bad infallible type"
                 tmpl = attr_refcnt_infallible_tmpl
                 realtype = realtype[:-2]  # strip trailing pointer
 
             fd.write(tmpl % {'realtype': realtype,
                              'nativename': attributeNativeName(a, getter=True),
                              'args': '' if not a.implicit_jscontext else 'JSContext* cx',
                              'argnames': '' if not a.implicit_jscontext else 'cx, '})
--- a/xpcom/idl-parser/xpidl/xpidl.py
+++ b/xpcom/idl-parser/xpidl/xpidl.py
@@ -1036,19 +1036,20 @@ class Attribute(object):
                 raise IDLError("Unexpected attribute '%s'" % name, aloc)
 
     def resolve(self, iface):
         self.iface = iface
         self.realtype = iface.idl.getName(self.type, self.location)
         if self.infallible and self.realtype.kind not in ['builtin',
                                                           'interface',
                                                           'forward',
-                                                          'webidl']:
+                                                          'webidl',
+                                                          'cenum']:
             raise IDLError('[infallible] only works on interfaces, domobjects, and builtin types '
-                           '(numbers, booleans, and raw char types)',
+                           '(numbers, booleans, cenum, and raw char types)',
                            self.location)
         if self.infallible and not iface.attributes.builtinclass:
             raise IDLError('[infallible] attributes are only allowed on '
                            '[builtinclass] interfaces',
                            self.location)
 
     def toIDL(self):
         attribs = attlistToIDL(self.attlist)