Bug 1097731 - emit using declarations for infallible convenience methods. r=nfroyd
authorTom Tromey <tom@tromey.com>
Wed, 12 Nov 2014 08:11:00 +0100
changeset 240735 60c584a2bfa1280807930b1a30483b1ef91c8eed
parent 240734 244ba4f17e51288130323dd4406d03d90afe7c1d
child 240736 59f3a9bd26f08ffd759aba662ca44f80d64875b9
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnfroyd
bugs1097731
milestone36.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 1097731 - emit using declarations for infallible convenience methods. r=nfroyd
xpcom/idl-parser/header.py
--- a/xpcom/idl-parser/header.py
+++ b/xpcom/idl-parser/header.py
@@ -395,33 +395,37 @@ def write_interface(iface, fd):
                     fd.write(" %s" % member.data)
                 else:
                     raise Exception("Unexpected interface member: %s" % member)
 
     fd.write(iface_epilog % names)
 
     for member in iface.members:
         if isinstance(member, xpidl.Attribute):
+            if member.infallible:
+                fd.write("\\\n  using %s::%s; " % (iface.name, attributeNativeName(member, True)))
             fd.write("\\\n  %s MOZ_OVERRIDE; " % attributeAsNative(member, True))
             if not member.readonly:
                 fd.write("\\\n  %s MOZ_OVERRIDE; " % attributeAsNative(member, False))
         elif isinstance(member, xpidl.Method):
             fd.write("\\\n  %s MOZ_OVERRIDE; " % methodAsNative(member))
     if len(iface.members) == 0:
         fd.write('\\\n  /* no methods! */')
     elif not member.kind in ('attribute', 'method'):
        fd.write('\\')
 
     fd.write(iface_forward % names)
 
-    def emitTemplate(tmpl, tmpl_notxpcom=None):
+    def emitTemplate(forward_infallible, tmpl, tmpl_notxpcom=None):
         if tmpl_notxpcom == None:
             tmpl_notxpcom = tmpl
         for member in iface.members:
             if isinstance(member, xpidl.Attribute):
+                if forward_infallible and member.infallible:
+                    fd.write("\\\n  using %s::%s; " % (iface.name, attributeNativeName(member, True)))
                 fd.write(tmpl % {'asNative': attributeAsNative(member, True),
                                  'nativeName': attributeNativeName(member, True),
                                  'paramList': attributeParamNames(member)})
                 if not member.readonly:
                     fd.write(tmpl % {'asNative': attributeAsNative(member, False),
                                      'nativeName': attributeNativeName(member, False),
                                      'paramList': attributeParamNames(member)})
             elif isinstance(member, xpidl.Method):
@@ -433,24 +437,26 @@ def write_interface(iface, fd):
                     fd.write(tmpl % {'asNative': methodAsNative(member),
                                      'nativeName': methodNativeName(member),
                                      'paramList': paramlistNames(member)})
         if len(iface.members) == 0:
             fd.write('\\\n  /* no methods! */')
         elif not member.kind in ('attribute', 'method'):
             fd.write('\\')
 
-    emitTemplate("\\\n  %(asNative)s MOZ_OVERRIDE { return _to %(nativeName)s(%(paramList)s); } ")
+    emitTemplate(True,
+                 "\\\n  %(asNative)s MOZ_OVERRIDE { return _to %(nativeName)s(%(paramList)s); } ")
 
     fd.write(iface_forward_safe % names)
 
     # Don't try to safely forward notxpcom functions, because we have no
     # sensible default error return.  Instead, the caller will have to
     # implement them.
-    emitTemplate("\\\n  %(asNative)s MOZ_OVERRIDE { return !_to ? NS_ERROR_NULL_POINTER : _to->%(nativeName)s(%(paramList)s); } ",
+    emitTemplate(False,
+                 "\\\n  %(asNative)s MOZ_OVERRIDE { return !_to ? NS_ERROR_NULL_POINTER : _to->%(nativeName)s(%(paramList)s); } ",
                  "\\\n  %(asNative)s MOZ_OVERRIDE; ")
 
     fd.write(iface_template_prolog % names)
 
     for member in iface.members:
         if isinstance(member, xpidl.ConstMember) or isinstance(member, xpidl.CDATA): continue
         fd.write("/* %s */\n" % member.toIDL())
         if isinstance(member, xpidl.Attribute):