Bug 823088 - Add a static assertion that bindings with descriptor.nativeOwnership == 'nsisupports' inherit from nsISupports; r=bz

This commit is contained in:
Ms2ger 2012-12-22 09:18:11 +01:00
parent e1d87b9f1f
commit 213ae1202e

View File

@ -753,9 +753,14 @@ class CGAbstractClassHook(CGAbstractStaticMethod):
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()