Bug 787070 - Expandos on the xray of DOM prototypes should have effect on xrays of DOM nodes, calculate parent prototype names in one place. r=bz.

--HG--
extra : rebase_source : c3ffbba076fed4ef2157ca8bb430a0d9cbaedd61
This commit is contained in:
Peter Van der Beken 2014-09-09 15:19:09 +02:00
parent 87baf25bc1
commit df682c483d
2 changed files with 17 additions and 13 deletions

View File

@ -298,9 +298,9 @@ class CGNativePropertyHooks(CGThing):
prototypeID += self.descriptor.name prototypeID += self.descriptor.name
else: else:
prototypeID += "_ID_Count" prototypeID += "_ID_Count"
parent = self.descriptor.interface.parent parentProtoName = self.descriptor.parentPrototypeName
parentHooks = (toBindingNamespace(parent.identifier.name) + "::sNativePropertyHooks" parentHooks = (toBindingNamespace(parentProtoName) + "::sNativePropertyHooks"
if parent else 'nullptr') if parentProtoName else 'nullptr')
return fill( return fill(
""" """
@ -327,10 +327,7 @@ def NativePropertyHooks(descriptor):
def DOMClass(descriptor): def DOMClass(descriptor):
def make_name(d): protoList = ['prototypes::id::' + proto for proto in descriptor.prototypeNameChain]
return "%s%s" % (d.interface.identifier.name, '_workers' if d.workers else '')
protoList = ['prototypes::id::' + make_name(descriptor.getDescriptor(proto)) for proto in descriptor.prototypeChain]
# Pad out the list to the right length with _ID_Count so we # Pad out the list to the right length with _ID_Count so we
# guarantee that all the lists are the same length. _ID_Count # guarantee that all the lists are the same length. _ID_Count
# is never the ID of any prototype, so it's safe to use as # is never the ID of any prototype, so it's safe to use as
@ -2582,7 +2579,8 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
self.properties = properties self.properties = properties
def definition_body(self): def definition_body(self):
if len(self.descriptor.prototypeChain) == 1: parentProtoName = self.descriptor.parentPrototypeName
if parentProtoName is None:
parentProtoType = "Rooted" parentProtoType = "Rooted"
if self.descriptor.interface.getExtendedAttribute("ArrayClass"): if self.descriptor.interface.getExtendedAttribute("ArrayClass"):
getParentProto = "aCx, JS_GetArrayPrototype(aCx, aGlobal)" getParentProto = "aCx, JS_GetArrayPrototype(aCx, aGlobal)"
@ -2591,13 +2589,9 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
else: else:
getParentProto = "aCx, JS_GetObjectPrototype(aCx, aGlobal)" getParentProto = "aCx, JS_GetObjectPrototype(aCx, aGlobal)"
else: else:
parentProtoName = self.descriptor.prototypeChain[-2] parentProtoType = "Handle"
parentDesc = self.descriptor.getDescriptor(parentProtoName)
if parentDesc.workers:
parentProtoName += '_workers'
getParentProto = ("%s::GetProtoObject(aCx, aGlobal)" % getParentProto = ("%s::GetProtoObject(aCx, aGlobal)" %
toBindingNamespace(parentProtoName)) toBindingNamespace(parentProtoName))
parentProtoType = "Handle"
parentWithInterfaceObject = self.descriptor.interface.parent parentWithInterfaceObject = self.descriptor.interface.parent
while (parentWithInterfaceObject and while (parentWithInterfaceObject and

View File

@ -513,6 +513,16 @@ class Descriptor(DescriptorProvider):
def binaryNameFor(self, name): def binaryNameFor(self, name):
return self._binaryNames.get(name, name) return self._binaryNames.get(name, name)
@property
def prototypeNameChain(self):
return map(lambda p: self.getDescriptor(p).name, self.prototypeChain)
@property
def parentPrototypeName(self):
if len(self.prototypeChain) == 1:
return None
return self.getDescriptor(self.prototypeChain[-2]).name
def hasInterfaceOrInterfacePrototypeObject(self): def hasInterfaceOrInterfacePrototypeObject(self):
# Forward-declared interfaces don't need either interface object or # Forward-declared interfaces don't need either interface object or