mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1068740 - Consider putting union types in the binding files where they're used. r=bz.
--HG-- extra : rebase_source : 7e0b1e2f60757b7758704dab3672ee829f3e4085
This commit is contained in:
parent
1f90ca9c73
commit
7ced30305e
@ -16,7 +16,6 @@
|
||||
#include "mozilla/dom/indexedDB/FileInfo.h"
|
||||
#include "mozilla/dom/indexedDB/FileManager.h"
|
||||
#include "mozilla/dom/indexedDB/IndexedDatabaseManager.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsCOMPtr.h"
|
||||
@ -58,6 +57,7 @@ struct BlobPropertyBag;
|
||||
struct ChromeFilePropertyBag;
|
||||
struct FilePropertyBag;
|
||||
class FileImpl;
|
||||
class OwningArrayBufferOrArrayBufferViewOrBlobOrString;
|
||||
|
||||
class File MOZ_FINAL : public nsIDOMFile
|
||||
, public nsIXHRSendable
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "jsfriendapi.h"
|
||||
#include "mozilla/dom/BlobSet.h"
|
||||
#include "mozilla/dom/FileBinding.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsDOMClassInfoID.h"
|
||||
#include "nsIMultiplexInputStream.h"
|
||||
|
@ -17,13 +17,13 @@
|
||||
#include "DecoderTraits.h"
|
||||
#include "nsIAudioChannelAgent.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/AudioChannelBinding.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
#include "mozilla/dom/TextTrackManager.h"
|
||||
#include "MediaDecoder.h"
|
||||
#ifdef MOZ_EME
|
||||
#include "mozilla/dom/MediaKeys.h"
|
||||
#endif
|
||||
#include "nsGkAtoms.h"
|
||||
|
||||
// Something on Linux #defines None, which is an entry in the
|
||||
// MediaWaitingFor enum, so undef it here before including the binfing,
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "mozilla/dom/CanvasRenderingContext2D.h"
|
||||
#include "mozilla/dom/File.h"
|
||||
#include "mozilla/dom/HTMLCanvasElementBinding.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
#include "mozilla/dom/MouseEvent.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/gfx/Rect.h"
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/HTMLFormControlsCollectionBinding.h"
|
||||
#include "mozilla/dom/HTMLFormElement.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
#include "nsGenericHTMLElement.h" // nsGenericHTMLFormElement
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMNode.h"
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
#include "mozilla/dom/HTMLOptionElement.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsError.h"
|
||||
@ -23,6 +22,8 @@ class nsIDOMHTMLOptionElement;
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class HTMLElementOrLong;
|
||||
class HTMLOptionElementOrHTMLOptGroupElement;
|
||||
class HTMLSelectElement;
|
||||
|
||||
/**
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "mozilla/dom/HTMLOptGroupElement.h"
|
||||
#include "mozilla/dom/HTMLOptionElement.h"
|
||||
#include "mozilla/dom/HTMLSelectElementBinding.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
#include "nsContentList.h"
|
||||
#include "nsError.h"
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "nsRuleData.h"
|
||||
#include "nsHTMLStyleSheet.h"
|
||||
#include "nsMappedAttributes.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
#include "mozilla/dom/HTMLCollectionBinding.h"
|
||||
#include "mozilla/dom/HTMLTableElementBinding.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
#include "mozilla/dom/HTMLAllCollectionBinding.h"
|
||||
#include "mozilla/dom/Nullable.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
#include "nsHTMLDocument.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "mozilla/dom/HTMLDivElement.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
#include "mozilla/dom/TextTrack.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "mozilla/dom/Promise.h"
|
||||
#include "mozilla/dom/MediaKeySessionBinding.h"
|
||||
#include "mozilla/dom/MediaKeysBinding.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
|
||||
struct JSContext;
|
||||
|
||||
@ -28,6 +27,7 @@ class CDMProxy;
|
||||
|
||||
namespace dom {
|
||||
|
||||
class ArrayBufferViewOrArrayBuffer;
|
||||
class MediaKeyError;
|
||||
|
||||
class MediaKeySession MOZ_FINAL : public DOMEventTargetHelper
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "mozilla/dom/MediaKeyError.h"
|
||||
#include "mozilla/dom/MediaKeySession.h"
|
||||
#include "mozilla/dom/DOMException.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
#include "mozilla/CDMProxy.h"
|
||||
#include "mozilla/EMELog.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "nsRefPtrHashtable.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
#include "mozilla/dom/MediaKeysBinding.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
#include "mozIGeckoMediaPluginService.h"
|
||||
|
||||
namespace mozilla {
|
||||
@ -26,6 +25,7 @@ class CDMProxy;
|
||||
|
||||
namespace dom {
|
||||
|
||||
class ArrayBufferViewOrArrayBuffer;
|
||||
class MediaKeySession;
|
||||
class HTMLMediaElement;
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
#define mozilla_dom_Console_h
|
||||
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "mozilla/dom/UnionConversions.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsDataHashtable.h"
|
||||
@ -15,6 +14,8 @@
|
||||
#include "nsIObserver.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsWrapperCache.h"
|
||||
#include "nsDOMNavigationTiming.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
|
||||
class nsIConsoleAPIStorage;
|
||||
|
||||
|
@ -10,13 +10,13 @@
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsWrapperCache.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
#include "mozilla/dom/CryptoKey.h"
|
||||
#include "js/TypeDecls.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class ObjectOrString;
|
||||
class Promise;
|
||||
|
||||
typedef ArrayBufferViewOrArrayBuffer CryptoOperationData;
|
||||
|
@ -203,6 +203,7 @@
|
||||
#include "nsSandboxFlags.h"
|
||||
#include "TimeChangeObserver.h"
|
||||
#include "mozilla/dom/AudioContext.h"
|
||||
#include "mozilla/dom/BlobBinding.h"
|
||||
#include "mozilla/dom/BrowserElementDictionariesBinding.h"
|
||||
#include "mozilla/dom/Console.h"
|
||||
#include "mozilla/dom/FunctionBinding.h"
|
||||
|
@ -38,7 +38,6 @@
|
||||
#include "nsSize.h"
|
||||
#include "mozFlushType.h"
|
||||
#include "prclist.h"
|
||||
#include "mozilla/dom/RequestBinding.h"
|
||||
#include "mozilla/dom/StorageEvent.h"
|
||||
#include "mozilla/dom/StorageEventBinding.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
@ -110,6 +109,8 @@ class MozSelfSupport;
|
||||
class Navigator;
|
||||
class OwningExternalOrWindowProxy;
|
||||
class Promise;
|
||||
struct RequestInit;
|
||||
class RequestOrScalarValueString;
|
||||
class Selection;
|
||||
class SpeechSynthesis;
|
||||
class WakeLock;
|
||||
|
@ -10,8 +10,8 @@ import string
|
||||
import math
|
||||
import textwrap
|
||||
|
||||
from WebIDL import BuiltinTypes, IDLBuiltinType, IDLNullValue, IDLSequenceType, IDLType, IDLAttribute, IDLUndefinedValue, IDLEmptySequenceValue
|
||||
from Configuration import NoSuchDescriptorError, getTypesFromDescriptor, getTypesFromDictionary, getTypesFromCallback, Descriptor
|
||||
from WebIDL import BuiltinTypes, IDLBuiltinType, IDLNullValue, IDLSequenceType, IDLType, IDLAttribute, IDLUndefinedValue, IDLEmptySequenceValue, IDLDictionary
|
||||
from Configuration import NoSuchDescriptorError, getTypesFromDescriptor, getTypesFromDictionary, getTypesFromCallback, getAllTypes, Descriptor
|
||||
|
||||
AUTOGENERATED_WARNING_COMMENT = \
|
||||
"/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n\n"
|
||||
@ -1008,26 +1008,6 @@ def getRelevantProviders(descriptor, config):
|
||||
]
|
||||
|
||||
|
||||
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.
|
||||
"""
|
||||
for d in descriptors:
|
||||
if d.interface.isExternal():
|
||||
continue
|
||||
for t in getTypesFromDescriptor(d):
|
||||
yield (t, d, None)
|
||||
for dictionary in dictionaries:
|
||||
for t in getTypesFromDictionary(dictionary):
|
||||
yield (t, None, dictionary)
|
||||
for callback in callbacks:
|
||||
for t in getTypesFromCallback(callback):
|
||||
yield (t, None, None)
|
||||
|
||||
|
||||
class CGHeaders(CGWrapper):
|
||||
"""
|
||||
Generates the appropriate include statements.
|
||||
@ -1105,12 +1085,11 @@ class CGHeaders(CGWrapper):
|
||||
headerSet.add("mozilla/dom/Nullable.h")
|
||||
unrolled = t.unroll()
|
||||
if unrolled.isUnion():
|
||||
# UnionConversions.h includes UnionTypes.h
|
||||
if len(config.filenamesPerUnion[unrolled.name]) > 1:
|
||||
headerSet.add("mozilla/dom/UnionTypes.h")
|
||||
else:
|
||||
headerSet.add(self.getDeclarationFilename(unrolled))
|
||||
bindingHeaders.add("mozilla/dom/UnionConversions.h")
|
||||
if dictionary:
|
||||
# Our dictionary definition is in the header and
|
||||
# needs the union type.
|
||||
declareIncludes.add("mozilla/dom/UnionTypes.h")
|
||||
elif unrolled.isDate():
|
||||
if dictionary or jsImplementedDescriptors:
|
||||
declareIncludes.add("mozilla/dom/Date.h")
|
||||
@ -1256,43 +1235,42 @@ def SortedDictValues(d):
|
||||
"""
|
||||
return [v for k, v in sorted(d.items())]
|
||||
|
||||
|
||||
def UnionTypes(descriptors, dictionaries, callbacks, config):
|
||||
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.
|
||||
"""
|
||||
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.
|
||||
|
||||
Returns a tuple containing a set of header filenames to include in
|
||||
UnionTypes.h, a set of header filenames to include in UnionTypes.cpp, a set
|
||||
the header for the types in unionTypes, a set of header filenames to
|
||||
include in the implementation file for the types in unionTypes, a set
|
||||
of tuples containing a type declaration and a boolean if the type is a
|
||||
struct for member types of the unions and a CGList containing CGUnionStructs
|
||||
for every union.
|
||||
struct for member types of the union, a list of traverse methods,
|
||||
unlink methods and a list of union types. These last three lists only
|
||||
contain unique union types.
|
||||
"""
|
||||
|
||||
# Now find all the things we'll need as arguments and return values because
|
||||
# we need to wrap or unwrap them.
|
||||
headers = set()
|
||||
implheaders = set(["UnionTypes.h"])
|
||||
implheaders = set()
|
||||
declarations = set()
|
||||
unionStructs = dict()
|
||||
owningUnionStructs = dict()
|
||||
traverseMethods = dict()
|
||||
unlinkMethods = dict()
|
||||
|
||||
for t, descriptor, dictionary in getAllTypes(descriptors, dictionaries, callbacks):
|
||||
# Add info for the given type. descriptor and dictionary, if present, are
|
||||
# used to figure out what to do with interface types.
|
||||
assert not descriptor or not dictionary
|
||||
|
||||
t = t.unroll()
|
||||
while t.isMozMap():
|
||||
t = t.inner.unroll()
|
||||
if not t.isUnion():
|
||||
continue
|
||||
for (t, descriptor) in unionTypes:
|
||||
name = str(t)
|
||||
if name not in unionStructs:
|
||||
providers = getRelevantProviders(descriptor, config)
|
||||
# FIXME: Unions are broken in workers. See bug 809899.
|
||||
unionStructs[name] = CGUnionStruct(t, providers[0])
|
||||
owningUnionStructs[name] = CGUnionStruct(t, providers[0],
|
||||
ownsMembers=True)
|
||||
unionStructs[name] = t
|
||||
|
||||
def addHeadersForType(f):
|
||||
if f.nullable():
|
||||
@ -1343,6 +1321,10 @@ def UnionTypes(descriptors, dictionaries, callbacks, config):
|
||||
# And add headers for the type we're parametrized over
|
||||
addHeadersForType(f.inner)
|
||||
|
||||
if len(config.filenamesPerUnion[t.name]) > 1:
|
||||
implheaders.add("mozilla/dom/UnionTypes.h")
|
||||
else:
|
||||
implheaders.add(CGHeaders.getDeclarationFilename(t))
|
||||
for f in t.flatMemberTypes:
|
||||
assert not f.nullable()
|
||||
addHeadersForType(f)
|
||||
@ -1358,30 +1340,22 @@ def UnionTypes(descriptors, dictionaries, callbacks, config):
|
||||
# some compilers treat the friend declaration as a forward-declaration in
|
||||
# the class scope.
|
||||
return (headers, implheaders, declarations,
|
||||
CGList(SortedDictValues(traverseMethods) +
|
||||
SortedDictValues(unlinkMethods) +
|
||||
SortedDictValues(unionStructs) +
|
||||
SortedDictValues(owningUnionStructs),
|
||||
"\n"))
|
||||
SortedDictValues(traverseMethods), SortedDictValues(unlinkMethods),
|
||||
SortedDictValues(unionStructs))
|
||||
|
||||
def UnionConversions(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.
|
||||
|
||||
def UnionConversions(descriptors, dictionaries, callbacks, config):
|
||||
Returns a tuple containing a list of headers and 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
|
||||
# need to unwrap them.
|
||||
headers = set()
|
||||
unionConversions = dict()
|
||||
|
||||
for t, descriptor, dictionary in getAllTypes(descriptors, dictionaries, callbacks):
|
||||
# Add info for the given type. descriptor and dictionary, if passed, are
|
||||
# used to figure out what to do with interface types.
|
||||
assert not descriptor or not dictionary
|
||||
|
||||
t = t.unroll()
|
||||
if not t.isUnion():
|
||||
continue
|
||||
for (t, descriptor) in unionTypes:
|
||||
name = str(t)
|
||||
if name not in unionConversions:
|
||||
providers = getRelevantProviders(descriptor, config)
|
||||
@ -1418,6 +1392,9 @@ def UnionConversions(descriptors, dictionaries, callbacks, config):
|
||||
# And the internal type of the MozMap
|
||||
addHeadersForType(f.inner, providers)
|
||||
|
||||
if len(config.filenamesPerUnion[t.name]) == 1:
|
||||
headers.add(CGHeaders.getDeclarationFilename(t))
|
||||
|
||||
for f in t.flatMemberTypes:
|
||||
addHeadersForType(f, providers)
|
||||
|
||||
@ -3593,6 +3570,9 @@ class CGCycleCollectionTraverseForOwningUnionMethod(CGAbstractMethod):
|
||||
Argument("uint32_t", "aFlags", "0")]
|
||||
CGAbstractMethod.__init__(self, None, "ImplCycleCollectionTraverse", "void", args)
|
||||
|
||||
def deps(self):
|
||||
return self.type.getDeps()
|
||||
|
||||
def definition_body(self):
|
||||
memberNames = [getUnionMemberName(t)
|
||||
for t in self.type.flatMemberTypes
|
||||
@ -3614,9 +3594,13 @@ class CGCycleCollectionUnlinkForOwningUnionMethod(CGAbstractMethod):
|
||||
ImplCycleCollectionUnlink for owning union type.
|
||||
"""
|
||||
def __init__(self, type):
|
||||
self.type = type
|
||||
args = [Argument("%s&" % CGUnionStruct.unionTypeName(type, True), "aUnion")]
|
||||
CGAbstractMethod.__init__(self, None, "ImplCycleCollectionUnlink", "void", args)
|
||||
|
||||
def deps(self):
|
||||
return self.type.getDeps()
|
||||
|
||||
def definition_body(self):
|
||||
return "aUnion.Uninit();\n"
|
||||
|
||||
@ -8689,6 +8673,9 @@ class CGUnionStruct(CGThing):
|
||||
def define(self):
|
||||
return self.struct.define()
|
||||
|
||||
def deps(self):
|
||||
return self.type.getDeps()
|
||||
|
||||
def getStruct(self):
|
||||
|
||||
members = [ClassMember("mType", "Type", body="eUninitialized"),
|
||||
@ -9046,7 +9033,9 @@ class CGUnionConversionStruct(CGThing):
|
||||
disallowCopyConstruction=True).declare()
|
||||
|
||||
def define(self):
|
||||
return "\n"
|
||||
return ""
|
||||
def deps(self):
|
||||
return set()
|
||||
|
||||
|
||||
class ClassItem:
|
||||
@ -11856,23 +11845,6 @@ class CGDictionary(CGThing):
|
||||
def makeIdName(name):
|
||||
return IDLToCIdentifier(name) + "_id"
|
||||
|
||||
@staticmethod
|
||||
def getDictionaryDependenciesFromType(type):
|
||||
if type.isDictionary():
|
||||
return set([type.unroll().inner])
|
||||
if type.isSequence() or type.isArray():
|
||||
return CGDictionary.getDictionaryDependenciesFromType(type.unroll())
|
||||
return set()
|
||||
|
||||
@staticmethod
|
||||
def getDictionaryDependencies(dictionary):
|
||||
deps = set()
|
||||
if dictionary.parent:
|
||||
deps.add(dictionary.parent)
|
||||
for member in dictionary.members:
|
||||
deps |= CGDictionary.getDictionaryDependenciesFromType(member.type)
|
||||
return deps
|
||||
|
||||
@staticmethod
|
||||
def isDictionaryCopyConstructible(dictionary):
|
||||
if (dictionary.parent and
|
||||
@ -12127,9 +12099,12 @@ class ForwardDeclarationBuilder:
|
||||
class CGForwardDeclarations(CGWrapper):
|
||||
"""
|
||||
Code generate the forward declarations for a header file.
|
||||
additionalDeclarations is a list of tuples containing a classname and a
|
||||
boolean. If the boolean is true we will declare a struct, otherwise we'll
|
||||
declare a class.
|
||||
"""
|
||||
def __init__(self, config, descriptors, mainCallbacks, workerCallbacks,
|
||||
dictionaries, callbackInterfaces):
|
||||
dictionaries, callbackInterfaces, additionalDeclarations=[]):
|
||||
builder = ForwardDeclarationBuilder()
|
||||
|
||||
def forwardDeclareForType(t, workerness='both'):
|
||||
@ -12201,6 +12176,9 @@ class CGForwardDeclarations(CGWrapper):
|
||||
for t in getTypesFromDictionary(d):
|
||||
forwardDeclareForType(t)
|
||||
|
||||
for className, isStruct in additionalDeclarations:
|
||||
builder.add(className, isStruct=isStruct)
|
||||
|
||||
CGWrapper.__init__(self, builder.build())
|
||||
|
||||
|
||||
@ -12222,6 +12200,17 @@ class CGBindingRoot(CGThing):
|
||||
hasInterfaceOrInterfacePrototypeObject=True,
|
||||
skipGen=False)
|
||||
|
||||
unionTypes = UnionsForFile(config, webIDLFile)
|
||||
|
||||
(unionHeaders, unionImplheaders, unionDeclarations, traverseMethods,
|
||||
unlinkMethods, unionStructs) = UnionTypes(unionTypes, config)
|
||||
|
||||
bindingDeclareHeaders.update(dict.fromkeys(unionHeaders, True))
|
||||
bindingHeaders.update(dict.fromkeys(unionImplheaders, True))
|
||||
|
||||
bindingDeclareHeaders["mozilla/dom/UnionMember.h"] = len(unionStructs) > 0
|
||||
bindingDeclareHeaders["mozilla/dom/BindingUtils.h"] = len(unionStructs) > 0
|
||||
|
||||
def descriptorHasCrossOriginProperties(desc):
|
||||
def hasCrossOriginProperty(m):
|
||||
props = memberProperties(m, desc)
|
||||
@ -12333,15 +12322,53 @@ class CGBindingRoot(CGThing):
|
||||
bindingHeaders["mozilla/dom/ScriptSettings.h"] = dictionaries # AutoJSAPI
|
||||
bindingHeaders["xpcpublic.h"] = dictionaries ## xpc::UnprivilegedJunkScope
|
||||
|
||||
cgthings.extend(traverseMethods)
|
||||
cgthings.extend(unlinkMethods)
|
||||
|
||||
# Do codegen for all the dictionaries. We have to be a bit careful
|
||||
# here, because we have to generate these in order from least derived
|
||||
# to most derived so that class inheritance works out. We also have to
|
||||
# generate members before the dictionary that contains them.
|
||||
cgthings.extend([CGDictionary(d, config.getDescriptorProvider(False))
|
||||
for d in
|
||||
dependencySortObjects(dictionaries,
|
||||
CGDictionary.getDictionaryDependencies,
|
||||
lambda d: d.identifier.name)])
|
||||
|
||||
def getDependenciesFromType(type):
|
||||
if type.isDictionary():
|
||||
return set([type.unroll().inner])
|
||||
if type.isSequence() or type.isArray():
|
||||
return getDependenciesFromType(type.unroll())
|
||||
if type.isUnion():
|
||||
return set([type.unroll()])
|
||||
return set()
|
||||
|
||||
def getDependencies(unionTypeOrDictionary):
|
||||
if isinstance(unionTypeOrDictionary, IDLDictionary):
|
||||
deps = set()
|
||||
if unionTypeOrDictionary.parent:
|
||||
deps.add(unionTypeOrDictionary.parent)
|
||||
for member in unionTypeOrDictionary.members:
|
||||
deps |= getDependenciesFromType(member.type)
|
||||
return deps
|
||||
|
||||
assert unionTypeOrDictionary.isType() and unionTypeOrDictionary.isUnion()
|
||||
deps = set()
|
||||
for member in unionTypeOrDictionary.flatMemberTypes:
|
||||
deps |= getDependenciesFromType(member)
|
||||
return deps
|
||||
|
||||
def getName(unionTypeOrDictionary):
|
||||
if isinstance(unionTypeOrDictionary, IDLDictionary):
|
||||
return unionTypeOrDictionary.identifier.name
|
||||
|
||||
assert unionTypeOrDictionary.isType() and unionTypeOrDictionary.isUnion()
|
||||
return unionTypeOrDictionary.name
|
||||
|
||||
for t in dependencySortObjects(dictionaries + unionStructs, getDependencies, getName):
|
||||
if t.isDictionary():
|
||||
cgthings.append(CGDictionary(t, config.getDescriptorProvider(False)))
|
||||
else:
|
||||
assert t.isUnion()
|
||||
# FIXME: Unions are broken in workers. See bug 809899.
|
||||
cgthings.append(CGUnionStruct(t, config.getDescriptorProvider(False)))
|
||||
cgthings.append(CGUnionStruct(t, config.getDescriptorProvider(False), True))
|
||||
|
||||
# Do codegen for all the callbacks.
|
||||
cgthings.extend(CGCallbackFunction(c, config.getDescriptorProvider(False))
|
||||
@ -12377,7 +12404,8 @@ class CGBindingRoot(CGThing):
|
||||
curr = CGList([CGForwardDeclarations(config, descriptors,
|
||||
mainCallbacks, workerCallbacks,
|
||||
dictionaries,
|
||||
callbackDescriptors + jsImplemented),
|
||||
callbackDescriptors + jsImplemented,
|
||||
additionalDeclarations=unionDeclarations),
|
||||
curr],
|
||||
"\n")
|
||||
|
||||
@ -14484,12 +14512,17 @@ class GlobalGenRoots():
|
||||
|
||||
@staticmethod
|
||||
def UnionTypes(config):
|
||||
unionTypes = UnionsForFile(config, None)
|
||||
(includes, implincludes, declarations,
|
||||
traverseMethods, unlinkMethods,
|
||||
unionStructs) = UnionTypes(unionTypes, config)
|
||||
|
||||
unions = CGList(traverseMethods +
|
||||
unlinkMethods +
|
||||
[CGUnionStruct(t, config.getDescriptorProvider(False)) for t in unionStructs] +
|
||||
[CGUnionStruct(t, config.getDescriptorProvider(False), True) for t in unionStructs],
|
||||
"\n")
|
||||
|
||||
(includes, implincludes,
|
||||
declarations, unions) = UnionTypes(config.getDescriptors(),
|
||||
config.getDictionaries(),
|
||||
config.getCallbacks(),
|
||||
config)
|
||||
includes.add("mozilla/dom/OwningNonNull.h")
|
||||
includes.add("mozilla/dom/UnionMember.h")
|
||||
includes.add("mozilla/dom/BindingDeclarations.h")
|
||||
@ -14502,34 +14535,11 @@ class GlobalGenRoots():
|
||||
|
||||
curr = CGWrapper(curr, post='\n')
|
||||
|
||||
namespaces = []
|
||||
stack = [CGList([])]
|
||||
for clazz, isStruct in sorted(declarations):
|
||||
elements = clazz.split("::")
|
||||
clazz = CGClassForwardDeclare(elements.pop(), isStruct=isStruct)
|
||||
i = 0
|
||||
if len(elements) > 0:
|
||||
common = min(len(namespaces), len(elements))
|
||||
while i < common and namespaces[i] == elements[i]:
|
||||
i += 1
|
||||
builder = ForwardDeclarationBuilder()
|
||||
for className, isStruct in declarations:
|
||||
builder.add(className, isStruct=isStruct)
|
||||
|
||||
# pop all the namespaces that should be closed
|
||||
namespaces = namespaces[:i]
|
||||
|
||||
# add all the namespaces that should be opened
|
||||
for j, namespace in enumerate(elements[i:]):
|
||||
namespaces.append(namespace)
|
||||
# every CGNamespace that we add holds a CGList
|
||||
list = CGList([])
|
||||
# add the new namespace to the list on top of the stack
|
||||
stack[i + j].append(CGNamespace(namespace, list))
|
||||
# set the top of the namespace stack to the list of the new
|
||||
# namespace
|
||||
stack[i + j + 1:] = [list]
|
||||
|
||||
stack[len(elements)].append(clazz)
|
||||
|
||||
curr = CGList([stack[0], curr], "\n")
|
||||
curr = CGList([builder.build(), curr], "\n")
|
||||
|
||||
curr = CGHeaders([], [], [], [], includes, implincludes, 'UnionTypes',
|
||||
curr)
|
||||
@ -14542,10 +14552,11 @@ class GlobalGenRoots():
|
||||
|
||||
@staticmethod
|
||||
def UnionConversions(config):
|
||||
|
||||
headers, unions = UnionConversions(config.getDescriptors(),
|
||||
config.getDictionaries(),
|
||||
config.getCallbacks(),
|
||||
unionTypes = []
|
||||
for l in config.unionsPerFilename.itervalues():
|
||||
unionTypes.extend(l)
|
||||
unionTypes.sort(key=lambda u: u[0].name)
|
||||
headers, unions = UnionConversions(unionTypes,
|
||||
config)
|
||||
|
||||
# Wrap all of that in our namespaces.
|
||||
@ -15066,7 +15077,7 @@ class CGEventRoot(CGThing):
|
||||
'mozilla/dom/Nullable.h',
|
||||
'nsDOMQS.h'
|
||||
],
|
||||
"", self.root)
|
||||
"", self.root, config)
|
||||
|
||||
# And now some include guards
|
||||
self.root = CGIncludeGuard(interfaceName, self.root)
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
from WebIDL import IDLInterface, IDLExternalInterface, IDLImplementsStatement
|
||||
import os
|
||||
from collections import defaultdict
|
||||
|
||||
autogenerated_comment = "/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n"
|
||||
|
||||
@ -117,6 +118,52 @@ class Configuration:
|
||||
self.callbacks = [c for c in parseData if
|
||||
c.isCallback() and not c.isInterface()]
|
||||
|
||||
# Dictionary mapping from a union type name to a set of filenames where
|
||||
# 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.
|
||||
self.unionsPerFilename = defaultdict(list)
|
||||
|
||||
for (t, descriptor, _) in getAllTypes(self.descriptors, self.dictionaries, self.callbacks):
|
||||
if t.isMozMap():
|
||||
t = t.inner
|
||||
t = t.unroll()
|
||||
if t.isUnion():
|
||||
filenamesForUnion = self.filenamesPerUnion[t.name]
|
||||
if t.filename() not in filenamesForUnion:
|
||||
if len(filenamesForUnion) == 0:
|
||||
# This is the first file that we found a union with this
|
||||
# name in, record the union as part of the file.
|
||||
uniqueFilenameForUnion = t.filename()
|
||||
else:
|
||||
# We already found a file that contains a union with
|
||||
# this name.
|
||||
if len(filenamesForUnion) == 1:
|
||||
# This is the first time we found a union with this
|
||||
# name in another file.
|
||||
for f in filenamesForUnion:
|
||||
# Filter out unions with this name from the
|
||||
# unions for the file where we previously found
|
||||
# them.
|
||||
unionsForFilename = self.unionsPerFilename[f]
|
||||
unionsForFilename = filter(lambda u: u[0].name != t.name,
|
||||
unionsForFilename)
|
||||
if len(unionsForFilename) == 0:
|
||||
del self.unionsPerFilename[f]
|
||||
else:
|
||||
self.unionsPerFilename[f] = unionsForFilename
|
||||
# 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))
|
||||
filenamesForUnion.add(t.filename())
|
||||
|
||||
def flagWorkerOrMainThread(items, main, worker):
|
||||
for item in items:
|
||||
if item in main:
|
||||
@ -725,3 +772,22 @@ def findCallbacksAndDictionaries(inputTypes):
|
||||
retDictionaries = set()
|
||||
doFindCallbacksAndDictionaries(inputTypes, retCallbacks, retDictionaries)
|
||||
return (retCallbacks, retDictionaries)
|
||||
|
||||
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.
|
||||
"""
|
||||
for d in descriptors:
|
||||
if d.interface.isExternal():
|
||||
continue
|
||||
for t in getTypesFromDescriptor(d):
|
||||
yield (t, d, None)
|
||||
for dictionary in dictionaries:
|
||||
for t in getTypesFromDictionary(dictionary):
|
||||
yield (t, None, dictionary)
|
||||
for callback in callbacks:
|
||||
for t in getTypesFromCallback(callback):
|
||||
yield (t, None, None)
|
||||
|
@ -2061,6 +2061,10 @@ class IDLUnionType(IDLType):
|
||||
def __eq__(self, other):
|
||||
return isinstance(other, IDLUnionType) and self.memberTypes == other.memberTypes
|
||||
|
||||
def __hash__(self):
|
||||
assert self.isComplete()
|
||||
return self.name.__hash__()
|
||||
|
||||
def isVoid(self):
|
||||
return False
|
||||
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "mozilla/dom/Date.h"
|
||||
#include "mozilla/dom/MozMap.h"
|
||||
#include "mozilla/dom/TypedArray.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
|
@ -946,7 +946,7 @@ dictionary Dict : ParentDict {
|
||||
#ifdef DEBUG
|
||||
(EventInit or long) eventInitOrLong;
|
||||
(EventInit or long)? nullableEventInitOrLong;
|
||||
(Node or long)? nullableNodeOrLong;
|
||||
(HTMLElement or long)? nullableHTMLElementOrLong;
|
||||
// CustomEventInit is useful to test because it needs rooting.
|
||||
(CustomEventInit or long) eventInitOrLong2;
|
||||
(CustomEventInit or long)? nullableEventInitOrLong2;
|
||||
|
@ -13,7 +13,8 @@
|
||||
NamedConstructor=Example(DOMString str),
|
||||
NamedConstructor=Example2(DictForConstructor dict, any any1, object obj1,
|
||||
object? obj2, sequence<Dict> seq, optional any any2,
|
||||
optional object obj3, optional object? obj4)
|
||||
optional object obj3, optional object? obj4),
|
||||
NamedConstructor=Example2((long or MozMap<any>) arg1)
|
||||
]
|
||||
interface TestExampleInterface {
|
||||
// Integer types
|
||||
|
@ -98,7 +98,6 @@
|
||||
#include "mozilla/dom/HTMLVideoElement.h"
|
||||
#include "mozilla/dom/SVGMatrix.h"
|
||||
#include "mozilla/dom/TextMetrics.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
#include "mozilla/dom/SVGMatrix.h"
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
#include "nsGlobalWindow.h"
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "mozilla/JSEventHandler.h"
|
||||
#include "mozilla/Likely.h"
|
||||
#include "mozilla/dom/ErrorEvent.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "mozilla/dom/MessagePort.h"
|
||||
#include "mozilla/dom/MessagePortBinding.h"
|
||||
#include "mozilla/dom/MessagePortList.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
|
||||
#include "mozilla/HoldDropJSObjects.h"
|
||||
#include "jsapi.h"
|
||||
|
@ -6,13 +6,18 @@
|
||||
#ifndef mozilla_dom_Fetch_h
|
||||
#define mozilla_dom_Fetch_h
|
||||
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsError.h"
|
||||
#include "nsString.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
|
||||
class nsIInputStream;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class ArrayBufferOrArrayBufferViewOrBlobOrScalarValueStringOrURLSearchParams;
|
||||
class OwningArrayBufferOrArrayBufferViewOrBlobOrScalarValueStringOrURLSearchParams;
|
||||
class Promise;
|
||||
|
||||
/*
|
||||
|
@ -8,7 +8,6 @@
|
||||
#define mozilla_dom_Headers_h
|
||||
|
||||
#include "mozilla/dom/HeadersBinding.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
|
||||
#include "nsClassHashtable.h"
|
||||
#include "nsWrapperCache.h"
|
||||
@ -25,6 +24,7 @@ namespace dom {
|
||||
|
||||
template<typename T> class MozMap;
|
||||
class HeadersOrByteStringSequenceSequenceOrByteStringMozMap;
|
||||
class OwningHeadersOrByteStringSequenceSequenceOrByteStringMozMap;
|
||||
|
||||
/**
|
||||
* This Headers class is only used to represent the content facing Headers
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "mozilla/dom/HeadersBinding.h"
|
||||
#include "mozilla/dom/InternalHeaders.h"
|
||||
#include "mozilla/dom/RequestBinding.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
|
||||
#include "nsIContentPolicy.h"
|
||||
#include "nsIInputStream.h"
|
||||
|
@ -14,7 +14,6 @@
|
||||
// Required here due to certain WebIDL enums/classes being declared in both
|
||||
// files.
|
||||
#include "mozilla/dom/RequestBinding.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
|
||||
class nsPIDOMWindow;
|
||||
|
||||
@ -24,6 +23,7 @@ namespace dom {
|
||||
class Headers;
|
||||
class InternalHeaders;
|
||||
class Promise;
|
||||
class RequestOrScalarValueString;
|
||||
|
||||
class Request MOZ_FINAL : public nsISupports
|
||||
, public nsWrapperCache
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "nsPIDOMWindow.h"
|
||||
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/dom/FetchBinding.h"
|
||||
#include "mozilla/dom/Headers.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
#include "mozilla/dom/Fetch.h"
|
||||
#include "mozilla/dom/ResponseBinding.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
|
||||
#include "InternalResponse.h"
|
||||
|
||||
@ -20,6 +19,7 @@ class nsPIDOMWindow;
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class ArrayBufferOrArrayBufferViewOrScalarValueStringOrURLSearchParams;
|
||||
class Headers;
|
||||
class InternalHeaders;
|
||||
class Promise;
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "mozilla/dom/DirectoryBinding.h"
|
||||
#include "mozilla/dom/FileSystemBase.h"
|
||||
#include "mozilla/dom/FileSystemUtils.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
|
||||
// Resolve the name collision of Microsoft's API name with macros defined in
|
||||
// Windows header files. Undefine the macro of CreateDirectory to avoid
|
||||
|
@ -6,7 +6,6 @@
|
||||
#define mozilla_dom_Icc_h
|
||||
|
||||
#include "mozilla/dom/MozIccBinding.h" // For IccCardState
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
|
||||
class nsIIccInfo;
|
||||
@ -16,6 +15,7 @@ namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class DOMRequest;
|
||||
class OwningMozIccInfoOrMozGsmIccInfoOrMozCdmaIccInfo;
|
||||
|
||||
class Icc MOZ_FINAL : public DOMEventTargetHelper
|
||||
{
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "mozilla/dom/ErrorEventBinding.h"
|
||||
#include "mozilla/dom/IDBOpenDBRequestBinding.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "nsIMutable.h"
|
||||
#include "nsIXPConnect.h"
|
||||
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/dom/BlobBinding.h"
|
||||
#include "mozilla/dom/File.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#include "DOMMobileMessageError.h"
|
||||
#include "mozilla/dom/DOMMobileMessageErrorBinding.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
#include "nsIDOMMozMmsMessage.h"
|
||||
#include "nsIDOMMozSmsMessage.h"
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
#define mozilla_dom_mobilemessage_MobileMessageManager_h
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "nsIObserver.h"
|
||||
|
||||
@ -23,6 +22,7 @@ class DOMCursor;
|
||||
struct MmsParameters;
|
||||
struct MmsSendParameters;
|
||||
struct MobileMessageFilter;
|
||||
class OwningLongOrMozSmsMessageOrMozMmsMessage;
|
||||
struct SmsSendParameters;
|
||||
|
||||
class MobileMessageManager MOZ_FINAL : public DOMEventTargetHelper
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "mozilla/dom/MozMobileConnectionBinding.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
#include "mozilla/dom/TelephonyBinding.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
|
||||
#include "nsCharSeparatedTokenizer.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "mozilla/dom/Headers.h"
|
||||
#include "mozilla/dom/RequestBinding.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -18,6 +17,7 @@ namespace dom {
|
||||
class Console;
|
||||
class Function;
|
||||
class Promise;
|
||||
class RequestOrScalarValueString;
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
Loading…
Reference in New Issue
Block a user