Backed out changeset 32786d29daf8 (bug 830099) because of build bustage

This commit is contained in:
Ehsan Akhgari 2013-01-28 23:51:03 -05:00
Родитель f5b233966e
Коммит 728d7beaad
6 изменённых файлов: 152 добавлений и 221 удалений

Просмотреть файл

@ -248,17 +248,6 @@ DOMInterfaces = {
} }
}, },
'DummyInterface': {
'skipGen': True,
'register': False,
},
'DummyInterfaceWorkers': {
'skipGen': True,
'register': False,
'workers': True
},
'DynamicsCompressorNode': { 'DynamicsCompressorNode': {
'resultNotAddRefed': [ 'threshold', 'knee', 'ratio', 'resultNotAddRefed': [ 'threshold', 'knee', 'ratio',
'reduction', 'attack', 'release' ], 'reduction', 'attack', 'release' ],

Просмотреть файл

@ -10,7 +10,7 @@ import re
import string import string
from WebIDL import BuiltinTypes, IDLBuiltinType, IDLNullValue, IDLSequenceType, IDLType from WebIDL import BuiltinTypes, IDLBuiltinType, IDLNullValue, IDLSequenceType, IDLType
from Configuration import NoSuchDescriptorError, getTypesFromDescriptor, getTypesFromDictionary, getTypesFromCallback from Configuration import NoSuchDescriptorError
AUTOGENERATED_WARNING_COMMENT = \ AUTOGENERATED_WARNING_COMMENT = \
"/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n\n" "/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n\n"
@ -389,6 +389,45 @@ class CGIncludeGuard(CGWrapper):
declarePre='#ifndef %s\n#define %s\n\n' % (define, define), declarePre='#ifndef %s\n#define %s\n\n' % (define, define),
declarePost='\n#endif // %s\n' % define) declarePost='\n#endif // %s\n' % define)
def getTypesFromDescriptor(descriptor):
"""
Get all argument and return types for all members of the descriptor
"""
members = [m for m in descriptor.interface.members]
if descriptor.interface.ctor():
members.append(descriptor.interface.ctor())
signatures = [s for m in members if m.isMethod() for s in m.signatures()]
types = []
for s in signatures:
assert len(s) == 2
(returnType, arguments) = s
types.append(returnType)
types.extend(a.type for a in arguments)
types.extend(a.type for a in members if a.isAttr())
return types
def getTypesFromDictionary(dictionary):
"""
Get all member types for this dictionary
"""
types = []
curDict = dictionary
while curDict:
types.extend([m.type for m in curDict.members])
curDict = curDict.parent
return types
def getTypesFromCallback(callback):
"""
Get the types this callback depends on: its return type and the
types of its arguments.
"""
sig = callback.signatures()[0]
types = [sig[0]] # Return type
types.extend(arg.type for arg in sig[1]) # Arguments
return types
def getRelevantProviders(descriptor, dictionary, config): def getRelevantProviders(descriptor, dictionary, config):
assert not descriptor or not dictionary assert not descriptor or not dictionary
if descriptor is not None: if descriptor is not None:
@ -6484,16 +6523,34 @@ class CGDictionary(CGThing):
self.descriptorProvider = descriptorProvider self.descriptorProvider = descriptorProvider
self.workers = descriptorProvider.workers self.workers = descriptorProvider.workers
self.needToInitIds = not self.workers and len(dictionary.members) > 0 self.needToInitIds = not self.workers and len(dictionary.members) > 0
self.memberInfo = [ if all(CGDictionary(d, descriptorProvider).generatable for
(member, d in CGDictionary.getDictionaryDependencies(dictionary)):
getJSToNativeConversionTemplate(member.type, self.generatable = True
descriptorProvider, else:
isMember="Dictionary", self.generatable = False
isOptional=(not member.defaultValue), # Nothing else to do here
defaultValue=member.defaultValue)) return
for member in dictionary.members ] # Getting a conversion template for interface types can fail
# if we don't have a relevant descriptor when self.workers is True.
# If that happens, just mark ourselves as not being
# generatable and move on.
try:
self.memberInfo = [
(member,
getJSToNativeConversionTemplate(member.type,
descriptorProvider,
isMember="Dictionary",
isOptional=(not member.defaultValue),
defaultValue=member.defaultValue))
for member in dictionary.members ]
except NoSuchDescriptorError, err:
if not self.workers:
raise err
self.generatable = False
def declare(self): def declare(self):
if not self.generatable:
return ""
d = self.dictionary d = self.dictionary
if d.parent: if d.parent:
inheritance = ": public %s " % self.makeClassName(d.parent) inheritance = ": public %s " % self.makeClassName(d.parent)
@ -6542,6 +6599,8 @@ class CGDictionary(CGThing):
"inheritance": inheritance })) "inheritance": inheritance }))
def define(self): def define(self):
if not self.generatable:
return ""
d = self.dictionary d = self.dictionary
if d.parent: if d.parent:
initParent = ("// Per spec, we init the parent's members first\n" initParent = ("// Per spec, we init the parent's members first\n"
@ -6825,14 +6884,8 @@ class CGBindingRoot(CGThing):
descriptors = config.getDescriptors(webIDLFile=webIDLFile, descriptors = config.getDescriptors(webIDLFile=webIDLFile,
hasInterfaceOrInterfacePrototypeObject=True, hasInterfaceOrInterfacePrototypeObject=True,
skipGen=False) skipGen=False)
mainDictionaries = config.getDictionaries(webIDLFile=webIDLFile, dictionaries = config.getDictionaries(webIDLFile)
workers=False) callbacks = config.getCallbacks(webIDLFile)
workerDictionaries = config.getDictionaries(webIDLFile=webIDLFile,
workers=True)
mainCallbacks = config.getCallbacks(webIDLFile=webIDLFile,
workers=False)
workerCallbacks = config.getCallbacks(webIDLFile=webIDLFile,
workers=True)
callbackDescriptors = config.getDescriptors(webIDLFile=webIDLFile, callbackDescriptors = config.getDescriptors(webIDLFile=webIDLFile,
isCallback=True) isCallback=True)
@ -6841,23 +6894,20 @@ class CGBindingRoot(CGThing):
descriptorsForForwardDeclaration = list(descriptors) descriptorsForForwardDeclaration = list(descriptors)
ifaces = [] ifaces = []
workerIfaces = [] workerIfaces = []
def getInterfacesFromDictionary(d): for dictionary in dictionaries:
return [ type.unroll().inner dictionaryIfaces = [ type.unroll().inner
for type in getTypesFromDictionary(d) for type in getTypesFromDictionary(dictionary)
if type.unroll().isGeckoInterface() ] if type.unroll().isGeckoInterface() ]
for dictionary in mainDictionaries: ifaces.extend(dictionaryIfaces)
ifaces.extend(getInterfacesFromDictionary(dictionary)) workerIfaces.extend(dictionaryIfaces)
for dictionary in workerDictionaries:
workerIfaces.extend(getInterfacesFromDictionary(dictionary))
def getInterfacesFromCallback(c): for callback in callbacks:
return [ t.unroll().inner callbackIfaces = [ t.unroll().inner
for t in getTypesFromCallback(c) for t in getTypesFromCallback(callback)
if t.unroll().isGeckoInterface() ] if t.unroll().isGeckoInterface() ]
for callback in mainCallbacks: workerIfaces.extend(callbackIfaces)
ifaces.extend(getInterfacesFromCallback(callback)) if not callback.isWorkerOnly():
for callback in workerCallbacks: ifaces.extend(callbackIfaces)
workerIfaces.extend(getInterfacesFromCallback(callback))
for callbackDescriptor in callbackDescriptors: for callbackDescriptor in callbackDescriptors:
callbackDescriptorIfaces = [ callbackDescriptorIfaces = [
@ -6898,7 +6948,7 @@ class CGBindingRoot(CGThing):
# Now add the forward declarations we need for our union types # Now add the forward declarations we need for our union types
# and callback functions. # and callback functions.
for callback in mainCallbacks + workerCallbacks: for callback in callbacks:
forwardDeclares.extend( forwardDeclares.extend(
declareNativeType("mozilla::dom::" + str(t.unroll())) declareNativeType("mozilla::dom::" + str(t.unroll()))
for t in getTypesFromCallback(callback) for t in getTypesFromCallback(callback)
@ -6911,7 +6961,7 @@ class CGBindingRoot(CGThing):
if t.unroll().isUnion() or t.unroll().isCallback()) if t.unroll().isUnion() or t.unroll().isCallback())
# Forward declarations for callback functions used in dictionaries. # Forward declarations for callback functions used in dictionaries.
for dictionary in mainDictionaries + workerDictionaries: for dictionary in dictionaries:
forwardDeclares.extend( forwardDeclares.extend(
declareNativeType("mozilla::dom::" + str(t.unroll())) declareNativeType("mozilla::dom::" + str(t.unroll()))
for t in getTypesFromDictionary(dictionary) for t in getTypesFromDictionary(dictionary)
@ -6957,31 +7007,30 @@ class CGBindingRoot(CGThing):
# declares a dictionary which inherits from a dictionary in B and B # declares a dictionary which inherits from a dictionary in B and B
# declares a dictionary (possibly a different one!) that inherits from a # declares a dictionary (possibly a different one!) that inherits from a
# dictionary in A. The good news is that I expect this to never happen. # dictionary in A. The good news is that I expect this to never happen.
def sortDictionaries(dictionaries): reSortedDictionaries = []
reSortedDictionaries = [] dictionaries = set(dictionaries)
dictionaries = set(dictionaries) while len(dictionaries) != 0:
while len(dictionaries) != 0: # Find the dictionaries that don't depend on anything else anymore
# Find the dictionaries that don't depend on anything else # and move them over.
# anymore and move them over. toMove = [d for d in dictionaries if
toMove = [d for d in dictionaries if len(CGDictionary.getDictionaryDependencies(d) &
len(CGDictionary.getDictionaryDependencies(d) & dictionaries) == 0]
dictionaries) == 0] if len(toMove) == 0:
if len(toMove) == 0: raise TypeError("Loop in dictionary dependency graph")
raise TypeError("Loop in dictionary dependency graph") dictionaries = dictionaries - set(toMove)
dictionaries = dictionaries - set(toMove) reSortedDictionaries.extend(toMove)
reSortedDictionaries.extend(toMove)
return reSortedDictionaries
dictionaries = reSortedDictionaries
cgthings.extend([CGDictionary(d, config.getDescriptorProvider(True)) cgthings.extend([CGDictionary(d, config.getDescriptorProvider(True))
for d in sortDictionaries(workerDictionaries)]) for d in dictionaries])
cgthings.extend([CGDictionary(d, config.getDescriptorProvider(False)) cgthings.extend([CGDictionary(d, config.getDescriptorProvider(False))
for d in sortDictionaries(mainDictionaries)]) for d in dictionaries])
# Do codegen for all the callbacks. Only do non-worker codegen for now, # Do codegen for all the callbacks. Only do non-worker codegen for now,
# since we don't have a sane setup yet for invoking callbacks in workers # since we don't have a sane setup yet for invoking callbacks in workers
# and managing their lifetimes. # and managing their lifetimes.
cgthings.extend(CGCallbackFunction(c, config.getDescriptorProvider(False)) cgthings.extend(CGCallbackFunction(c, config.getDescriptorProvider(False))
for c in mainCallbacks) for c in callbacks)
# Do codegen for all the descriptors # Do codegen for all the descriptors
cgthings.extend([CGDescriptor(x) for x in descriptors]) cgthings.extend([CGDescriptor(x) for x in descriptors])
@ -7004,8 +7053,8 @@ class CGBindingRoot(CGThing):
# Add header includes. # Add header includes.
curr = CGHeaders(descriptors, curr = CGHeaders(descriptors,
mainDictionaries + workerDictionaries, dictionaries,
mainCallbacks + workerCallbacks, callbacks,
callbackDescriptors, callbackDescriptors,
['mozilla/dom/BindingDeclarations.h', ['mozilla/dom/BindingDeclarations.h',
'mozilla/ErrorResult.h', 'mozilla/ErrorResult.h',
@ -7620,22 +7669,38 @@ class CGCallback(CGClass):
name = idlObject.identifier.name name = idlObject.identifier.name
if descriptorProvider.workers: if descriptorProvider.workers:
name += "Workers" name += "Workers"
# For our public methods that needThisHandling we want most of the try:
# same args and the same return type as what CallbackMember # For our public methods that needThisHandling we want most of the
# generates. So we want to take advantage of all its # same args and the same return type as what CallbackMember
# CGNativeMember infrastructure, but that infrastructure can't deal # generates. So we want to take advantage of all its
# with templates and most especially template arguments. So just # CGNativeMember infrastructure, but that infrastructure can't deal
# cheat and have CallbackMember compute all those things for us. # with templates and most especially template arguments. So just
realMethods = [] # cheat and have CallbackMember compute all those things for us.
for method in methods: realMethods = []
if not method.needThisHandling: for method in methods:
realMethods.append(method) if not method.needThisHandling:
else: realMethods.append(method)
realMethods.extend(self.getMethodImpls(method)) else:
CGClass.__init__(self, name, realMethods.extend(self.getMethodImpls(method))
bases=[ClassBase(baseName)], CGClass.__init__(self, name,
constructors=self.getConstructors(), bases=[ClassBase(baseName)],
methods=realMethods+getters+setters) constructors=self.getConstructors(),
methods=realMethods+getters+setters)
self.generatable = True
except NoSuchDescriptorError, err:
if not descriptorProvider.workers:
raise err
self.generatable = False
def define(self):
if not self.generatable:
return ""
return CGClass.define(self)
def declare(self):
if not self.generatable:
return ""
return CGClass.declare(self)
def getConstructors(self): def getConstructors(self):
return [ClassConstructor( return [ClassConstructor(
@ -7703,6 +7768,9 @@ class CGCallback(CGClass):
class CGCallbackFunction(CGCallback): class CGCallbackFunction(CGCallback):
def __init__(self, callback, descriptorProvider): def __init__(self, callback, descriptorProvider):
if callback.isWorkerOnly() and not descriptorProvider.workers:
self.generatable = False
return
CGCallback.__init__(self, callback, descriptorProvider, CGCallback.__init__(self, callback, descriptorProvider,
"CallbackFunction", "CallbackFunction",
methods=[CallCallback(callback, descriptorProvider)]) methods=[CallCallback(callback, descriptorProvider)])

Просмотреть файл

@ -62,33 +62,10 @@ class Configuration:
descriptor.uniqueImplementation = len(otherDescriptors) == 1 descriptor.uniqueImplementation = len(otherDescriptors) == 1
self.enums = [e for e in parseData if e.isEnum()] self.enums = [e for e in parseData if e.isEnum()]
# Figure out what our main-thread and worker dictionaries and callbacks
# are.
mainTypes = set()
for descriptor in self.getDescriptors(workers=False, isExternal=False):
mainTypes |= set(getFlatTypes(getTypesFromDescriptor(descriptor)))
(mainCallbacks, mainDictionaries) = findCallbacksAndDictionaries(mainTypes)
workerTypes = set();
for descriptor in self.getDescriptors(workers=True, isExternal=False):
workerTypes |= set(getFlatTypes(getTypesFromDescriptor(descriptor)))
(workerCallbacks, workerDictionaries) = findCallbacksAndDictionaries(workerTypes)
self.dictionaries = [d for d in parseData if d.isDictionary()] self.dictionaries = [d for d in parseData if d.isDictionary()]
self.callbacks = [c for c in parseData if self.callbacks = [c for c in parseData if
c.isCallback() and not c.isInterface()] c.isCallback() and not c.isInterface()]
def flagWorkerOrMainThread(items, main, worker):
for item in items:
if item in main:
item.setUserData("mainThread", True)
if item in worker:
item.setUserData("workers", True)
flagWorkerOrMainThread(self.dictionaries, mainDictionaries,
workerDictionaries);
flagWorkerOrMainThread(self.callbacks, mainCallbacks, workerCallbacks)
# Keep the descriptor list sorted for determinism. # Keep the descriptor list sorted for determinism.
self.descriptors.sort(lambda x,y: cmp(x.name, y.name)) self.descriptors.sort(lambda x,y: cmp(x.name, y.name))
@ -118,26 +95,14 @@ class Configuration:
return curr return curr
def getEnums(self, webIDLFile): def getEnums(self, webIDLFile):
return filter(lambda e: e.filename() == webIDLFile, self.enums) return filter(lambda e: e.filename() == webIDLFile, self.enums)
def getDictionaries(self, webIDLFile=None):
@staticmethod if not webIDLFile:
def _filterForFileAndWorkers(items, filters): return self.dictionaries
"""Gets the items that match the given filters.""" return filter(lambda d: d.filename() == webIDLFile, self.dictionaries)
for key, val in filters.iteritems(): def getCallbacks(self, webIDLFile=None):
if key == 'webIDLFile': if not webIDLFile:
items = filter(lambda x: x.filename() == val, items) return self.callbacks
elif key == 'workers': return filter(lambda d: d.filename() == webIDLFile, self.callbacks)
if val:
items = filter(lambda x: x.getUserData("workers", False), items)
else:
items = filter(lambda x: x.getUserData("mainThread", False), items)
else:
assert(0) # Unknown key
return items
def getDictionaries(self, **filters):
return self._filterForFileAndWorkers(self.dictionaries, filters)
def getCallbacks(self, **filters):
return self._filterForFileAndWorkers(self.callbacks, filters)
def getDescriptor(self, interfaceName, workers): def getDescriptor(self, interfaceName, workers):
""" """
Gets the appropriate descriptor for the given interface name Gets the appropriate descriptor for the given interface name
@ -442,82 +407,3 @@ class Descriptor(DescriptorProvider):
def needsConstructHookHolder(self): def needsConstructHookHolder(self):
assert self.interface.hasInterfaceObject() assert self.interface.hasInterfaceObject()
return not self.hasInstanceInterface and not self.interface.isCallback() return not self.hasInstanceInterface and not self.interface.isCallback()
# Some utility methods
def getTypesFromDescriptor(descriptor):
"""
Get all argument and return types for all members of the descriptor
"""
members = [m for m in descriptor.interface.members]
if descriptor.interface.ctor():
members.append(descriptor.interface.ctor())
signatures = [s for m in members if m.isMethod() for s in m.signatures()]
types = []
for s in signatures:
assert len(s) == 2
(returnType, arguments) = s
types.append(returnType)
types.extend(a.type for a in arguments)
types.extend(a.type for a in members if a.isAttr())
return types
def getFlatTypes(types):
retval = set()
for type in types:
type = type.unroll()
if type.isUnion():
retval |= set(type.flatMemberTypes)
else:
retval.add(type)
return retval
def getTypesFromDictionary(dictionary):
"""
Get all member types for this dictionary
"""
types = []
curDict = dictionary
while curDict:
types.extend([m.type for m in curDict.members])
curDict = curDict.parent
return types
def getTypesFromCallback(callback):
"""
Get the types this callback depends on: its return type and the
types of its arguments.
"""
sig = callback.signatures()[0]
types = [sig[0]] # Return type
types.extend(arg.type for arg in sig[1]) # Arguments
return types
def findCallbacksAndDictionaries(inputTypes):
"""
Ensure that all callbacks and dictionaries reachable from types end up in
the returned callbacks and dictionaries sets.
Note that we assume that our initial invocation already includes all types
reachable via descriptors in "types", so we only have to deal with things
that are themeselves reachable via callbacks and dictionaries.
"""
def doFindCallbacksAndDictionaries(types, callbacks, dictionaries):
unhandledTypes = set()
for type in types:
if type.isCallback() and type not in callbacks:
unhandledTypes |= getFlatTypes(getTypesFromCallback(type))
callbacks.add(type)
elif type.isDictionary() and type.inner not in dictionaries:
d = type.inner
unhandledTypes |= getFlatTypes(getTypesFromDictionary(d))
while d:
dictionaries.add(d)
d = d.parent
if len(unhandledTypes) != 0:
doFindCallbacksAndDictionaries(unhandledTypes, callbacks, dictionaries)
retCallbacks = set()
retDictionaries = set()
doFindCallbacksAndDictionaries(inputTypes, retCallbacks, retDictionaries)
return (retCallbacks, retDictionaries)

Просмотреть файл

@ -2346,6 +2346,7 @@ class IDLCallbackType(IDLType, IDLObjectWithScope):
argument.resolve(self) argument.resolve(self)
self._treatNonCallableAsNull = False self._treatNonCallableAsNull = False
self._workerOnly = False
def isCallback(self): def isCallback(self):
return True return True
@ -2386,11 +2387,16 @@ class IDLCallbackType(IDLType, IDLObjectWithScope):
return (other.isPrimitive() or other.isString() or other.isEnum() or return (other.isPrimitive() or other.isString() or other.isEnum() or
other.isNonCallbackInterface() or other.isDate()) other.isNonCallbackInterface() or other.isDate())
def isWorkerOnly(self):
return self._workerOnly
def addExtendedAttributes(self, attrs): def addExtendedAttributes(self, attrs):
unhandledAttrs = [] unhandledAttrs = []
for attr in attrs: for attr in attrs:
if attr.identifier() == "TreatNonCallableAsNull": if attr.identifier() == "TreatNonCallableAsNull":
self._treatNonCallableAsNull = True self._treatNonCallableAsNull = True
elif attr.identifier() == "WorkerOnly":
self._workerOnly = True
else: else:
unhandledAttrs.append(attr) unhandledAttrs.append(attr)
if len(unhandledAttrs) != 0: if len(unhandledAttrs) != 0:

Просмотреть файл

@ -1,17 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
// Dummy bindings that we need to force generation of things that
// aren't actually referenced anywhere in IDL yet but are used in C++.
interface DummyInterface {
readonly attribute OnErrorEventHandlerNonNull onErrorEventHandler;
FilePropertyBag fileBag();
};
interface DummyInterfaceWorkers {
BlobPropertyBag blobBag();
};

Просмотреть файл

@ -40,7 +40,6 @@ webidl_files = \
DOMStringMap.webidl \ DOMStringMap.webidl \
DOMTokenList.webidl \ DOMTokenList.webidl \
DOMTransaction.webidl \ DOMTransaction.webidl \
DummyBinding.webidl \
DynamicsCompressorNode.webidl \ DynamicsCompressorNode.webidl \
Element.webidl \ Element.webidl \
EventHandler.webidl \ EventHandler.webidl \