Fix for bug 756231 (Remove NativeToSupports, replace with reinterpret_cast). r=bz.

--HG--
extra : rebase_source : b7a2e204b9db7457312af6179aa516f4849c7f92
This commit is contained in:
Peter Van der Beken 2012-04-26 23:44:28 +02:00
parent 1a4d916fec
commit 03c93d5f62

View File

@ -509,7 +509,7 @@ class CGClassFinalizeHook(CGAbstractClassHook):
release = """
XPCJSRuntime *rt = nsXPConnect::GetRuntimeInstance();
if (rt) {
rt->DeferredRelease(NativeToSupports(self));
rt->DeferredRelease(reinterpret_cast<nsISupports*>(self));
} else {
NS_RELEASE(self);
}"""
@ -1014,24 +1014,6 @@ class CGDefineDOMInterfaceMethod(CGAbstractMethod):
*aEnabled = true;
return !!%s(aCx, global, aReceiver);""" % (getter))
class CGNativeToSupportsMethod(CGAbstractStaticMethod):
"""
A method to cast our native to an nsISupports. We do it by casting up the
interface chain in hopes of getting to something that singly-inherits from
nsISupports.
"""
def __init__(self, descriptor):
args = [Argument(descriptor.nativeType + '*', 'aNative')]
CGAbstractStaticMethod.__init__(self, descriptor, 'NativeToSupports', 'nsISupports*', args)
def definition_body(self):
cur = CGGeneric("aNative")
for proto in reversed(self.descriptor.prototypeChain[:-1]):
d = self.descriptor.getDescriptor(proto)
cast = "static_cast<%s*>(\n" % d.nativeType;
cur = CGWrapper(CGIndenter(cur), pre=cast, post=")")
return CGIndenter(CGWrapper(cur, pre="return ", post=";")).define();
class CGWrapMethod(CGAbstractMethod):
def __init__(self, descriptor):
# XXX can we wrap if we don't have an interface prototype object?
@ -2944,8 +2926,6 @@ class CGDescriptor(CGThing):
# Always have a finalize hook, regardless of whether the class wants a
# custom hook.
if descriptor.nativeIsISupports:
cgThings.append(CGNativeToSupportsMethod(descriptor))
cgThings.append(CGClassFinalizeHook(descriptor))
# Only generate a trace hook if the class wants a custom hook.