зеркало из https://github.com/mozilla/gecko-dev.git
Fix for bug 818219 (Replace HTMLElement quickstubs with new binding methods) - Support castable types in unions. r=bz.
--HG-- extra : rebase_source : 633d2b350be0cf11ac0bb010a0ad427b10863ef4
This commit is contained in:
Родитель
1ce6802d2a
Коммит
aeb1d53352
|
@ -607,40 +607,45 @@ def UnionTypes(descriptors, dictionaries, callbacks, config):
|
||||||
return (headers, implheaders, declarations,
|
return (headers, implheaders, declarations,
|
||||||
CGList(SortedDictValues(unionStructs), "\n"))
|
CGList(SortedDictValues(unionStructs), "\n"))
|
||||||
|
|
||||||
def UnionConversions(descriptors):
|
def UnionConversions(descriptors, dictionaries, callbacks, config):
|
||||||
"""
|
"""
|
||||||
Returns a CGThing to declare all union argument conversion helper structs.
|
Returns a CGThing to declare all union argument conversion helper structs.
|
||||||
"""
|
"""
|
||||||
# Now find all the things we'll need as arguments because we
|
# Now find all the things we'll need as arguments because we
|
||||||
# need to unwrap them.
|
# need to unwrap them.
|
||||||
|
headers = set()
|
||||||
unionConversions = dict()
|
unionConversions = dict()
|
||||||
for d in descriptors:
|
|
||||||
if d.interface.isExternal():
|
|
||||||
continue
|
|
||||||
|
|
||||||
def addUnionTypes(type):
|
def addInfoForType(t, descriptor=None, dictionary=None):
|
||||||
if type.isUnion():
|
"""
|
||||||
type = type.unroll()
|
Add info for the given type. descriptor and dictionary, if passed, are
|
||||||
name = str(type)
|
used to figure out what to do with interface types.
|
||||||
if not name in unionConversions:
|
"""
|
||||||
unionConversions[name] = CGUnionConversionStruct(type, d)
|
assert not descriptor or not dictionary
|
||||||
|
t = t.unroll()
|
||||||
|
if not t.isUnion():
|
||||||
|
return
|
||||||
|
name = str(t)
|
||||||
|
if not name in unionConversions:
|
||||||
|
providers = getRelevantProviders(descriptor, dictionary,
|
||||||
|
config)
|
||||||
|
unionConversions[name] = CGUnionConversionStruct(t, providers[0])
|
||||||
|
for f in t.flatMemberTypes:
|
||||||
|
f = f.unroll()
|
||||||
|
if f.isInterface():
|
||||||
|
if f.isSpiderMonkeyInterface():
|
||||||
|
headers.add("jsfriendapi.h")
|
||||||
|
headers.add("mozilla/dom/TypedArray.h")
|
||||||
|
elif not f.inner.isExternal():
|
||||||
|
headers.add(CGHeaders.getDeclarationFilename(f.inner))
|
||||||
|
elif f.isDictionary():
|
||||||
|
headers.add(CGHeaders.getDeclarationFilename(f.inner))
|
||||||
|
|
||||||
members = [m for m in d.interface.members]
|
callForEachType(descriptors, dictionaries, callbacks, addInfoForType)
|
||||||
if d.interface.ctor():
|
|
||||||
members.append(d.interface.ctor())
|
|
||||||
signatures = [s for m in members if m.isMethod() for s in m.signatures()]
|
|
||||||
for s in signatures:
|
|
||||||
assert len(s) == 2
|
|
||||||
(_, arguments) = s
|
|
||||||
for a in arguments:
|
|
||||||
addUnionTypes(a.type)
|
|
||||||
|
|
||||||
for m in members:
|
return (headers,
|
||||||
if m.isAttr() and not m.readonly:
|
CGWrapper(CGList(SortedDictValues(unionConversions), "\n"),
|
||||||
addUnionTypes(m.type)
|
post="\n\n"))
|
||||||
|
|
||||||
return CGWrapper(CGList(SortedDictValues(unionConversions), "\n"),
|
|
||||||
post="\n\n")
|
|
||||||
|
|
||||||
class Argument():
|
class Argument():
|
||||||
"""
|
"""
|
||||||
|
@ -7776,14 +7781,18 @@ struct PrototypeIDMap;
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def UnionConversions(config):
|
def UnionConversions(config):
|
||||||
|
|
||||||
unions = UnionConversions(config.getDescriptors())
|
(headers, unions) = UnionConversions(config.getDescriptors(),
|
||||||
|
config.getDictionaries(),
|
||||||
|
config.getCallbacks(),
|
||||||
|
config)
|
||||||
|
|
||||||
# Wrap all of that in our namespaces.
|
# Wrap all of that in our namespaces.
|
||||||
curr = CGNamespace.build(['mozilla', 'dom'], unions)
|
curr = CGNamespace.build(['mozilla', 'dom'], unions)
|
||||||
|
|
||||||
curr = CGWrapper(curr, post='\n')
|
curr = CGWrapper(curr, post='\n')
|
||||||
|
|
||||||
curr = CGHeaders([], [], [], ["nsDebug.h", "mozilla/dom/UnionTypes.h", "nsDOMQS.h", "XPCWrapper.h"], [], curr)
|
headers.update(["nsDebug.h", "mozilla/dom/UnionTypes.h", "nsDOMQS.h", "XPCWrapper.h"])
|
||||||
|
curr = CGHeaders([], [], [], headers, [], curr)
|
||||||
|
|
||||||
# Add include guards.
|
# Add include guards.
|
||||||
curr = CGIncludeGuard('UnionConversions', curr)
|
curr = CGIncludeGuard('UnionConversions', curr)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче