Bug 823088 - Add a static assertion that bindings with descriptor.nativeOwnership == 'nsisupports' inherit from nsISupports; r=bz
authorMs2ger <ms2ger@gmail.com>
Sat, 22 Dec 2012 09:18:11 +0100
changeset 116682 bf26f61a07489ea75bf294e143109e1fc83e0975
parent 116681 57427d474c9a4f753380f6eba62a8d433f6cc5c1
child 116683 04abdd43606b3e77e123d1033e0f1976d3f2b782
child 116858 756335a3066f7066ca7738d531368a7e992631f4
push id24069
push userMs2ger@gmail.com
push dateSat, 22 Dec 2012 08:19:19 +0000
treeherdermozilla-central@bf26f61a0748 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs823088
milestone20.0a1
first release with
nightly linux32
bf26f61a0748 / 20.0a1 / 20121222030836 / files
nightly linux64
bf26f61a0748 / 20.0a1 / 20121222030836 / files
nightly mac
bf26f61a0748 / 20.0a1 / 20121222030836 / files
nightly win32
bf26f61a0748 / 20.0a1 / 20121222030836 / files
nightly win64
bf26f61a0748 / 20.0a1 / 20121222030836 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 823088 - Add a static assertion that bindings with descriptor.nativeOwnership == 'nsisupports' inherit from nsISupports; r=bz
dom/bindings/Codegen.py
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -748,19 +748,24 @@ class CGAbstractClassHook(CGAbstractStat
     Meant for implementing JSClass hooks, like Finalize or Trace. Does very raw
     'this' unwrapping as it assumes that the unwrapped type is always known.
     """
     def __init__(self, descriptor, name, returnType, args):
         CGAbstractStaticMethod.__init__(self, descriptor, name, returnType,
                                         args)
 
     def definition_body_prologue(self):
-        return """
+        if self.descriptor.nativeOwnership == 'nsisupports':
+            assertion = ('  MOZ_STATIC_ASSERT((IsBaseOf<nsISupports, %s>::value), '
+                         '"Must be an nsISupports class");') % self.descriptor.nativeType
+        else:
+            assertion = ''
+        return """%s
   %s* self = UnwrapDOMObject<%s>(obj);
-""" % (self.descriptor.nativeType, self.descriptor.nativeType)
+""" % (assertion, self.descriptor.nativeType, self.descriptor.nativeType)
 
     def definition_body(self):
         return self.definition_body_prologue() + self.generate_code()
 
     def generate_code(self):
         # Override me
         assert(False)