зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1257037 part 11. Get rid of getRelevantProviders, since all the places that use it have a Configuration. r=khuey
This commit is contained in:
Родитель
584c6019b6
Коммит
f3fde63185
|
@ -978,12 +978,6 @@ class CGIncludeGuard(CGWrapper):
|
|||
declarePost='\n#endif // %s\n' % define)
|
||||
|
||||
|
||||
def getRelevantProviders(descriptor, config):
|
||||
if descriptor is not None:
|
||||
return [descriptor]
|
||||
return [config]
|
||||
|
||||
|
||||
class CGHeaders(CGWrapper):
|
||||
"""
|
||||
Generates the appropriate include statements.
|
||||
|
@ -1046,12 +1040,11 @@ class CGHeaders(CGWrapper):
|
|||
bindingHeaders = set()
|
||||
declareIncludes = set(declareIncludes)
|
||||
|
||||
def addHeadersForType((t, descriptor, dictionary)):
|
||||
def addHeadersForType((t, dictionary)):
|
||||
"""
|
||||
Add the relevant headers for this type. We use descriptor and
|
||||
dictionary, if passed, to decide what to do with interface types.
|
||||
Add the relevant headers for this type. We use dictionary, if
|
||||
passed, to decide what to do with interface types.
|
||||
"""
|
||||
assert not descriptor or not dictionary
|
||||
# Dictionaries have members that need to be actually
|
||||
# declared, not just forward-declared.
|
||||
if dictionary:
|
||||
|
@ -1082,22 +1075,20 @@ class CGHeaders(CGWrapper):
|
|||
headerSet = declareIncludes
|
||||
headerSet.add("mozilla/dom/TypedArray.h")
|
||||
else:
|
||||
providers = getRelevantProviders(descriptor, config)
|
||||
for p in providers:
|
||||
try:
|
||||
typeDesc = p.getDescriptor(unrolled.inner.identifier.name)
|
||||
except NoSuchDescriptorError:
|
||||
continue
|
||||
# Dictionaries with interface members rely on the
|
||||
# actual class definition of that interface member
|
||||
# being visible in the binding header, because they
|
||||
# store them in RefPtr and have inline
|
||||
# constructors/destructors.
|
||||
#
|
||||
# XXXbz maybe dictionaries with interface members
|
||||
# should just have out-of-line constructors and
|
||||
# destructors?
|
||||
headerSet.add(typeDesc.headerFile)
|
||||
try:
|
||||
typeDesc = config.getDescriptor(unrolled.inner.identifier.name)
|
||||
except NoSuchDescriptorError:
|
||||
return
|
||||
# Dictionaries with interface members rely on the
|
||||
# actual class definition of that interface member
|
||||
# being visible in the binding header, because they
|
||||
# store them in RefPtr and have inline
|
||||
# constructors/destructors.
|
||||
#
|
||||
# XXXbz maybe dictionaries with interface members
|
||||
# should just have out-of-line constructors and
|
||||
# destructors?
|
||||
headerSet.add(typeDesc.headerFile)
|
||||
elif unrolled.isDictionary():
|
||||
headerSet.add(self.getDeclarationFilename(unrolled.inner))
|
||||
elif unrolled.isCallback():
|
||||
|
@ -1118,7 +1109,7 @@ class CGHeaders(CGWrapper):
|
|||
bindingHeaders.add("mozilla/dom/MozMap.h")
|
||||
# Also add headers for the type the MozMap is
|
||||
# parametrized over, if needed.
|
||||
addHeadersForType((t.inner, descriptor, dictionary))
|
||||
addHeadersForType((t.inner, dictionary))
|
||||
|
||||
map(addHeadersForType,
|
||||
getAllTypes(descriptors + callbackDescriptors, dictionaries,
|
||||
|
@ -1168,10 +1159,10 @@ class CGHeaders(CGWrapper):
|
|||
# convenience functions
|
||||
if desc.interface.maplikeOrSetlikeOrIterable.hasKeyType():
|
||||
addHeadersForType((desc.interface.maplikeOrSetlikeOrIterable.keyType,
|
||||
desc, None))
|
||||
None))
|
||||
if desc.interface.maplikeOrSetlikeOrIterable.hasValueType():
|
||||
addHeadersForType((desc.interface.maplikeOrSetlikeOrIterable.valueType,
|
||||
desc, None))
|
||||
None))
|
||||
|
||||
for d in dictionaries:
|
||||
if d.parent:
|
||||
|
@ -1252,19 +1243,17 @@ def SortedDictValues(d):
|
|||
|
||||
def UnionsForFile(config, webIDLFile):
|
||||
"""
|
||||
Returns a list of tuples each containing two elements (type and descriptor)
|
||||
for all union types that are only used in webIDLFile. If webIDLFile is None
|
||||
this will return the list of tuples for union types that are used in more
|
||||
than one WebIDL file.
|
||||
Returns a list of union types for all union types that are only used in
|
||||
webIDLFile. If webIDLFile is None this will return the list of tuples for
|
||||
union types that are used in more than one WebIDL file.
|
||||
"""
|
||||
return config.unionsPerFilename.get(webIDLFile, [])
|
||||
|
||||
|
||||
def UnionTypes(unionTypes, config):
|
||||
"""
|
||||
The unionTypes argument should be a list of tuples, each containing two
|
||||
elements: a union type and a descriptor. This is typically the list
|
||||
generated by UnionsForFile.
|
||||
The unionTypes argument should be a list of union types. This is typically
|
||||
the list generated by UnionsForFile.
|
||||
|
||||
Returns a tuple containing a set of header filenames to include in
|
||||
the header for the types in unionTypes, a set of header filenames to
|
||||
|
@ -1282,10 +1271,9 @@ def UnionTypes(unionTypes, config):
|
|||
traverseMethods = dict()
|
||||
unlinkMethods = dict()
|
||||
|
||||
for (t, descriptor) in unionTypes:
|
||||
for t in unionTypes:
|
||||
name = str(t)
|
||||
if name not in unionStructs:
|
||||
providers = getRelevantProviders(descriptor, config)
|
||||
unionStructs[name] = t
|
||||
|
||||
def addHeadersForType(f):
|
||||
|
@ -1298,23 +1286,22 @@ def UnionTypes(unionTypes, config):
|
|||
headers.add("jsfriendapi.h")
|
||||
headers.add("mozilla/dom/TypedArray.h")
|
||||
else:
|
||||
for p in providers:
|
||||
try:
|
||||
typeDesc = p.getDescriptor(f.inner.identifier.name)
|
||||
except NoSuchDescriptorError:
|
||||
continue
|
||||
if typeDesc.interface.isCallback() or isSequence:
|
||||
# Callback interfaces always use strong refs, so
|
||||
# we need to include the right header to be able
|
||||
# to Release() in our inlined code.
|
||||
#
|
||||
# Similarly, sequences always contain strong
|
||||
# refs, so we'll need the header to handler
|
||||
# those.
|
||||
headers.add(typeDesc.headerFile)
|
||||
else:
|
||||
declarations.add((typeDesc.nativeType, False))
|
||||
implheaders.add(typeDesc.headerFile)
|
||||
try:
|
||||
typeDesc = config.getDescriptor(f.inner.identifier.name)
|
||||
except NoSuchDescriptorError:
|
||||
return
|
||||
if typeDesc.interface.isCallback() or isSequence:
|
||||
# Callback interfaces always use strong refs, so
|
||||
# we need to include the right header to be able
|
||||
# to Release() in our inlined code.
|
||||
#
|
||||
# Similarly, sequences always contain strong
|
||||
# refs, so we'll need the header to handler
|
||||
# those.
|
||||
headers.add(typeDesc.headerFile)
|
||||
else:
|
||||
declarations.add((typeDesc.nativeType, False))
|
||||
implheaders.add(typeDesc.headerFile)
|
||||
elif f.isDictionary():
|
||||
# For a dictionary, we need to see its declaration in
|
||||
# UnionTypes.h so we have its sizeof and know how big to
|
||||
|
@ -1369,26 +1356,23 @@ def UnionConversions(unionTypes, config):
|
|||
headers = set()
|
||||
unionConversions = dict()
|
||||
|
||||
for (t, descriptor) in unionTypes:
|
||||
for t in unionTypes:
|
||||
name = str(t)
|
||||
if name not in unionConversions:
|
||||
providers = getRelevantProviders(descriptor, config)
|
||||
unionConversions[name] = CGUnionConversionStruct(t, providers[0])
|
||||
unionConversions[name] = CGUnionConversionStruct(t, config)
|
||||
|
||||
def addHeadersForType(f, providers):
|
||||
def addHeadersForType(f):
|
||||
f = f.unroll()
|
||||
if f.isInterface():
|
||||
if f.isSpiderMonkeyInterface():
|
||||
headers.add("jsfriendapi.h")
|
||||
headers.add("mozilla/dom/TypedArray.h")
|
||||
elif f.inner.isExternal():
|
||||
providers = getRelevantProviders(descriptor, config)
|
||||
for p in providers:
|
||||
try:
|
||||
typeDesc = p.getDescriptor(f.inner.identifier.name)
|
||||
except NoSuchDescriptorError:
|
||||
continue
|
||||
headers.add(typeDesc.headerFile)
|
||||
try:
|
||||
typeDesc = config.getDescriptor(f.inner.identifier.name)
|
||||
except NoSuchDescriptorError:
|
||||
return
|
||||
headers.add(typeDesc.headerFile)
|
||||
else:
|
||||
headers.add(CGHeaders.getDeclarationFilename(f.inner))
|
||||
elif f.isDictionary():
|
||||
|
@ -1398,14 +1382,14 @@ def UnionConversions(unionTypes, config):
|
|||
elif f.isMozMap():
|
||||
headers.add("mozilla/dom/MozMap.h")
|
||||
# And the internal type of the MozMap
|
||||
addHeadersForType(f.inner, providers)
|
||||
addHeadersForType(f.inner)
|
||||
|
||||
# We plan to include UnionTypes.h no matter what, so it's
|
||||
# OK if we throw it into the set here.
|
||||
headers.add(CGHeaders.getUnionDeclarationFilename(config, t))
|
||||
|
||||
for f in t.flatMemberTypes:
|
||||
addHeadersForType(f, providers)
|
||||
addHeadersForType(f)
|
||||
|
||||
return (headers,
|
||||
CGWrapper(CGList(SortedDictValues(unionConversions), "\n"),
|
||||
|
@ -16451,7 +16435,7 @@ class GlobalGenRoots():
|
|||
unionTypes = []
|
||||
for l in config.unionsPerFilename.itervalues():
|
||||
unionTypes.extend(l)
|
||||
unionTypes.sort(key=lambda u: u[0].name)
|
||||
unionTypes.sort(key=lambda u: u.name)
|
||||
headers, unions = UnionConversions(unionTypes,
|
||||
config)
|
||||
|
||||
|
|
|
@ -105,15 +105,15 @@ class Configuration(DescriptorProvider):
|
|||
# union types with that name are used.
|
||||
self.filenamesPerUnion = defaultdict(set)
|
||||
|
||||
# Dictionary mapping from a filename to a list of tuples containing a
|
||||
# type and descriptor for the union types used in that file. If a union
|
||||
# type is used in multiple files then it will be added to the list
|
||||
# for the None key. Note that the list contains a tuple for every use of
|
||||
# a union type, so there can be multiple tuples with union types that
|
||||
# have the same name.
|
||||
# Dictionary mapping from a filename to a list of types for
|
||||
# the union types used in that file. If a union type is used
|
||||
# in multiple files then it will be added to the list for the
|
||||
# None key. Note that the list contains a type for every use
|
||||
# of a union type, so there can be multiple entries with union
|
||||
# types that have the same name.
|
||||
self.unionsPerFilename = defaultdict(list)
|
||||
|
||||
for (t, descriptor, _) in getAllTypes(self.descriptors, self.dictionaries, self.callbacks):
|
||||
for (t, _) in getAllTypes(self.descriptors, self.dictionaries, self.callbacks):
|
||||
while True:
|
||||
if t.isMozMap():
|
||||
t = t.inner
|
||||
|
@ -149,7 +149,7 @@ class Configuration(DescriptorProvider):
|
|||
# unions for the file where we previously found
|
||||
# them.
|
||||
unionsForFilename = self.unionsPerFilename[f]
|
||||
unionsForFilename = filter(lambda u: u[0].name != t.name,
|
||||
unionsForFilename = filter(lambda u: u.name != t.name,
|
||||
unionsForFilename)
|
||||
if len(unionsForFilename) == 0:
|
||||
del self.unionsPerFilename[f]
|
||||
|
@ -158,7 +158,7 @@ class Configuration(DescriptorProvider):
|
|||
# Unions with this name appear in multiple files, record
|
||||
# the filename as None, so that we can detect that.
|
||||
uniqueFilenameForUnion = None
|
||||
self.unionsPerFilename[uniqueFilenameForUnion].append((t, descriptor))
|
||||
self.unionsPerFilename[uniqueFilenameForUnion].append(t)
|
||||
filenamesForUnion.add(t.filename())
|
||||
|
||||
def getInterface(self, ifname):
|
||||
|
@ -828,21 +828,20 @@ def getTypesFromCallback(callback):
|
|||
def getAllTypes(descriptors, dictionaries, callbacks):
|
||||
"""
|
||||
Generate all the types we're dealing with. For each type, a tuple
|
||||
containing type, descriptor, dictionary is yielded. The
|
||||
descriptor and dictionary can be None if the type does not come
|
||||
from a descriptor or dictionary; they will never both be non-None.
|
||||
containing type, dictionary is yielded. The dictionary can be None if the
|
||||
type does not come from a dictionary.
|
||||
"""
|
||||
for d in descriptors:
|
||||
if d.interface.isExternal():
|
||||
continue
|
||||
for t in getTypesFromDescriptor(d):
|
||||
yield (t, d, None)
|
||||
yield (t, None)
|
||||
for dictionary in dictionaries:
|
||||
for t in getTypesFromDictionary(dictionary):
|
||||
yield (t, None, dictionary)
|
||||
yield (t, dictionary)
|
||||
for callback in callbacks:
|
||||
for t in getTypesFromCallback(callback):
|
||||
yield (t, None, None)
|
||||
yield (t, None)
|
||||
|
||||
def iteratorNativeType(descriptor):
|
||||
assert descriptor.interface.isIterable()
|
||||
|
|
Загрузка…
Ссылка в новой задаче