Bug 827486, part 1: add JSImplementation extended attribute. r=bz

This commit is contained in:
Andrew McCreight 2013-03-18 16:04:24 -07:00
parent 65d4ad2e50
commit 76ed2433f1
2 changed files with 23 additions and 4 deletions

View File

@ -376,8 +376,11 @@ class Descriptor(DescriptorProvider):
else:
add('all', [config], attribute)
for attribute in ['implicitJSContext', 'resultNotAddRefed']:
addExtendedAttribute(attribute, desc.get(attribute, {}))
if self.interface.isJSImplemented():
addExtendedAttribute('implicitJSContext', ['constructor'])
else:
for attribute in ['implicitJSContext', 'resultNotAddRefed']:
addExtendedAttribute(attribute, desc.get(attribute, {}))
self.binaryNames = desc.get('binaryNames', {})
if '__legacycaller' not in self.binaryNames:
@ -420,9 +423,9 @@ class Descriptor(DescriptorProvider):
attrs.append("infallible")
name = member.identifier.name
throws = self.interface.isJSImplemented() or member.getExtendedAttribute("Throws")
if member.isMethod():
attrs = self.extendedAttributes['all'].get(name, [])
throws = member.getExtendedAttribute("Throws")
maybeAppendInfallibleToAttrs(attrs, throws)
return attrs
@ -430,7 +433,6 @@ class Descriptor(DescriptorProvider):
assert bool(getter) != bool(setter)
key = 'getterOnly' if getter else 'setterOnly'
attrs = self.extendedAttributes['all'].get(name, []) + self.extendedAttributes[key].get(name, [])
throws = member.getExtendedAttribute("Throws")
if throws is None:
throwsAttr = "GetterThrows" if getter else "SetterThrows"
throws = member.getExtendedAttribute(throwsAttr)

View File

@ -475,6 +475,12 @@ class IDLExternalInterface(IDLObjectWithIdentifier):
def resolve(self, parentScope):
pass
def getJSImplementation(self):
return None
def isJSImplemented(self):
return False
def _getDependentObjects(self):
return set()
@ -956,6 +962,17 @@ class IDLInterface(IDLObjectWithScope):
# Put the new members at the beginning
self.members = members + self.members
def getJSImplementation(self):
classId = self.getExtendedAttribute("JSImplementation")
if not classId:
return classId
assert isinstance(classId, list)
assert len(classId) == 1
return classId[0]
def isJSImplemented(self):
return bool(self.getJSImplementation())
def _getDependentObjects(self):
deps = set(self.members)
deps.union(self.implementedInterfaces)