mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Backed out changeset a71766c2c85d
This commit is contained in:
parent
75d88ff353
commit
41104cbff1
@ -5,53 +5,46 @@
|
||||
import os
|
||||
import cPickle
|
||||
from Configuration import Configuration
|
||||
from Codegen import CGBindingRoot
|
||||
from Codegen import CGBindingRoot, replaceFileIfChanged
|
||||
|
||||
def generate_binding_header(config, outputprefix, srcprefix, webidlfile):
|
||||
def generate_binding_header(config, outputprefix, webidlfile):
|
||||
"""
|
||||
|config| Is the configuration object.
|
||||
|outputprefix| is a prefix to use for the header guards and filename.
|
||||
"""
|
||||
|
||||
filename = outputprefix + ".h"
|
||||
depsname = ".deps/" + filename + ".pp"
|
||||
root = CGBindingRoot(config, outputprefix, webidlfile)
|
||||
with open(filename, 'wb') as f:
|
||||
f.write(root.declare())
|
||||
with open(depsname, 'wb') as f:
|
||||
f.write("\n".join(filename + ": " + os.path.join(srcprefix, x) for x in root.deps()))
|
||||
if replaceFileIfChanged(filename, root.declare()):
|
||||
print "Generating binding header: %s" % (filename)
|
||||
|
||||
def generate_binding_cpp(config, outputprefix, srcprefix, webidlfile):
|
||||
def generate_binding_cpp(config, outputprefix, webidlfile):
|
||||
"""
|
||||
|config| Is the configuration object.
|
||||
|outputprefix| is a prefix to use for the header guards and filename.
|
||||
"""
|
||||
|
||||
filename = outputprefix + ".cpp"
|
||||
depsname = ".deps/" + filename + ".pp"
|
||||
root = CGBindingRoot(config, outputprefix, webidlfile)
|
||||
with open(filename, 'wb') as f:
|
||||
f.write(root.define())
|
||||
with open(depsname, 'wb') as f:
|
||||
f.write("\n".join(filename + ": " + os.path.join(srcprefix, x) for x in root.deps()))
|
||||
if replaceFileIfChanged(filename, root.define()):
|
||||
print "Generating binding implementation: %s" % (filename)
|
||||
|
||||
def main():
|
||||
|
||||
# Parse arguments.
|
||||
from optparse import OptionParser
|
||||
usagestring = "usage: %prog [header|cpp] configFile outputPrefix srcPrefix webIDLFile"
|
||||
usagestring = "usage: %prog [header|cpp] configFile outputPrefix webIDLFile"
|
||||
o = OptionParser(usage=usagestring)
|
||||
o.add_option("--verbose-errors", action='store_true', default=False,
|
||||
help="When an error happens, display the Python traceback.")
|
||||
(options, args) = o.parse_args()
|
||||
|
||||
if len(args) != 5 or (args[0] != "header" and args[0] != "cpp"):
|
||||
if len(args) != 4 or (args[0] != "header" and args[0] != "cpp"):
|
||||
o.error(usagestring)
|
||||
buildTarget = args[0]
|
||||
configFile = os.path.normpath(args[1])
|
||||
outputPrefix = args[2]
|
||||
srcPrefix = os.path.normpath(args[3])
|
||||
webIDLFile = os.path.normpath(args[4])
|
||||
webIDLFile = os.path.normpath(args[3])
|
||||
|
||||
# Load the parsing results
|
||||
f = open('ParserResults.pkl', 'rb')
|
||||
@ -63,9 +56,9 @@ def main():
|
||||
|
||||
# Generate the prototype classes.
|
||||
if buildTarget == "header":
|
||||
generate_binding_header(config, outputPrefix, srcPrefix, webIDLFile);
|
||||
generate_binding_header(config, outputPrefix, webIDLFile);
|
||||
elif buildTarget == "cpp":
|
||||
generate_binding_cpp(config, outputPrefix, srcPrefix, webIDLFile);
|
||||
generate_binding_cpp(config, outputPrefix, webIDLFile);
|
||||
else:
|
||||
assert False # not reached
|
||||
|
||||
|
@ -6442,8 +6442,6 @@ class CGDescriptor(CGThing):
|
||||
|
||||
assert not descriptor.concrete or descriptor.interface.hasInterfacePrototypeObject()
|
||||
|
||||
self._deps = descriptor.interface.getDeps()
|
||||
|
||||
cgThings = []
|
||||
# These are set to true if at least one non-static
|
||||
# method/getter/setter exist on the interface.
|
||||
|
@ -75,6 +75,7 @@ EXPORTS_$(binding_include_path) = \
|
||||
TypedArray.h \
|
||||
UnionConversions.h \
|
||||
UnionTypes.h \
|
||||
$(exported_binding_headers) \
|
||||
$(NULL)
|
||||
|
||||
LOCAL_INCLUDES += -I$(topsrcdir)/js/xpconnect/src \
|
||||
@ -96,34 +97,8 @@ LOCAL_INCLUDES += \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
# XXXkhuey this is a terrible hack to avoid blowing out the command line
|
||||
ifneq (,$(filter-out all chrome default export realchrome tools clean clobber clobber_all distclean realclean,$(MAKECMDGOALS)))
|
||||
$(shell echo "$(addsuffix .pp,$(binding_header_files))" > pp.list)
|
||||
$(shell echo "$(addsuffix .pp,$(binding_cpp_files))" >> pp.list)
|
||||
|
||||
# The script mddepend.pl checks the dependencies and writes to stdout
|
||||
# one rule to force out-of-date objects. For example,
|
||||
# foo.o boo.o: FORCE
|
||||
# The script has an advantage over including the *.pp files directly
|
||||
# because it handles the case when header files are removed from the build.
|
||||
# 'make' would complain that there is no way to build missing headers.
|
||||
ALL_PP_RESULTS = $(shell cat pp.list | $(PERL) $(BUILD_TOOLS)/mddepend.pl)
|
||||
$(eval $(ALL_PP_RESULTS))
|
||||
|
||||
endif
|
||||
|
||||
EXPORTS_GENERATED_FILES := $(exported_binding_headers)
|
||||
EXPORTS_GENERATED_DEST := $(DIST)/include/$(binding_include_path)
|
||||
EXPORTS_GENERATED_TARGET := webidl-export
|
||||
INSTALL_TARGETS += EXPORTS_GENERATED
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
# We need to create a separate target so we can ensure that the pickle is
|
||||
# done before generating headers.
|
||||
export:: ParserResults.pkl
|
||||
$(MAKE) webidl-export
|
||||
|
||||
# If you change bindinggen_dependencies here, change it in
|
||||
# dom/bindings/test/Makefile.in too.
|
||||
bindinggen_dependencies := \
|
||||
@ -132,6 +107,7 @@ bindinggen_dependencies := \
|
||||
Configuration.py \
|
||||
Codegen.py \
|
||||
parser/WebIDL.py \
|
||||
ParserResults.pkl \
|
||||
$(GLOBAL_DEPS) \
|
||||
$(NULL)
|
||||
|
||||
|
@ -174,38 +174,6 @@ class IDLObject(object):
|
||||
def handleExtendedAttribute(self, attr):
|
||||
assert False # Override me!
|
||||
|
||||
def _getDependentObjects(self):
|
||||
assert False # Override me!
|
||||
|
||||
def getDeps(self, visited=None):
|
||||
""" Return a set of files that this object depends on. If any of
|
||||
these files are changed the parser needs to be rerun to regenerate
|
||||
a new IDLObject.
|
||||
|
||||
The visited argument is a set of all the objects already visited.
|
||||
We must test to see if we are in it, and if so, do nothing. This
|
||||
prevents infinite recursion."""
|
||||
|
||||
# NB: We can't use visited=set() above because the default value is
|
||||
# evaluated when the def statement is evaluated, not when the function
|
||||
# is executed, so there would be one set for all invocations.
|
||||
if visited == None:
|
||||
visited = set()
|
||||
|
||||
if self in visited:
|
||||
return set()
|
||||
|
||||
visited.add(self)
|
||||
|
||||
deps = set()
|
||||
if self.filename() != "<builtin>":
|
||||
deps.add(self.filename())
|
||||
|
||||
for d in self._getDependentObjects():
|
||||
deps = deps.union(d.getDeps(visited))
|
||||
|
||||
return deps
|
||||
|
||||
class IDLScope(IDLObject):
|
||||
def __init__(self, location, parentScope, identifier):
|
||||
IDLObject.__init__(self, location)
|
||||
@ -475,9 +443,6 @@ class IDLExternalInterface(IDLObjectWithIdentifier):
|
||||
def resolve(self, parentScope):
|
||||
pass
|
||||
|
||||
def _getDependentObjects(self):
|
||||
return set()
|
||||
|
||||
class IDLInterface(IDLObjectWithScope):
|
||||
def __init__(self, location, parentScope, name, parent, members,
|
||||
isPartial):
|
||||
@ -951,13 +916,6 @@ class IDLInterface(IDLObjectWithScope):
|
||||
# Put the new members at the beginning
|
||||
self.members = members + self.members
|
||||
|
||||
def _getDependentObjects(self):
|
||||
deps = set(self.members)
|
||||
deps.union(self.implementedInterfaces)
|
||||
if self.parent:
|
||||
deps.add(self.parent)
|
||||
return deps
|
||||
|
||||
class IDLDictionary(IDLObjectWithScope):
|
||||
def __init__(self, location, parentScope, name, parent, members):
|
||||
assert isinstance(parentScope, IDLScope)
|
||||
@ -1028,11 +986,6 @@ class IDLDictionary(IDLObjectWithScope):
|
||||
def addExtendedAttributes(self, attrs):
|
||||
assert len(attrs) == 0
|
||||
|
||||
def _getDependentObjects(self):
|
||||
deps = set(self.members)
|
||||
if (self.parent):
|
||||
deps.add(self.parent)
|
||||
return deps
|
||||
|
||||
class IDLEnum(IDLObjectWithIdentifier):
|
||||
def __init__(self, location, parentScope, name, values):
|
||||
@ -1061,9 +1014,6 @@ class IDLEnum(IDLObjectWithIdentifier):
|
||||
def addExtendedAttributes(self, attrs):
|
||||
assert len(attrs) == 0
|
||||
|
||||
def _getDependentObjects(self):
|
||||
return set()
|
||||
|
||||
class IDLType(IDLObject):
|
||||
Tags = enum(
|
||||
# The integer types
|
||||
@ -1353,9 +1303,6 @@ class IDLNullableType(IDLType):
|
||||
return False
|
||||
return self.inner.isDistinguishableFrom(other)
|
||||
|
||||
def _getDependentObjects(self):
|
||||
return self.inner._getDependentObjects()
|
||||
|
||||
class IDLSequenceType(IDLType):
|
||||
def __init__(self, location, parameterType):
|
||||
assert not parameterType.isVoid()
|
||||
@ -1426,9 +1373,6 @@ class IDLSequenceType(IDLType):
|
||||
return (other.isPrimitive() or other.isString() or other.isEnum() or
|
||||
other.isDate() or other.isNonCallbackInterface())
|
||||
|
||||
def _getDependentObjects(self):
|
||||
return self.inner._getDependentObjects()
|
||||
|
||||
class IDLUnionType(IDLType):
|
||||
def __init__(self, location, memberTypes):
|
||||
IDLType.__init__(self, location, "")
|
||||
@ -1532,9 +1476,6 @@ class IDLUnionType(IDLType):
|
||||
return False
|
||||
return True
|
||||
|
||||
def _getDependentObjects(self):
|
||||
return set(self.memberTypes)
|
||||
|
||||
class IDLArrayType(IDLType):
|
||||
def __init__(self, location, parameterType):
|
||||
assert not parameterType.isVoid()
|
||||
@ -1610,9 +1551,6 @@ class IDLArrayType(IDLType):
|
||||
return (other.isPrimitive() or other.isString() or other.isEnum() or
|
||||
other.isDate() or other.isNonCallbackInterface())
|
||||
|
||||
def _getDependentObjects(self):
|
||||
return self.inner._getDependentObjects()
|
||||
|
||||
class IDLTypedefType(IDLType, IDLObjectWithIdentifier):
|
||||
def __init__(self, location, innerType, name):
|
||||
IDLType.__init__(self, location, innerType.name)
|
||||
@ -1700,9 +1638,6 @@ class IDLTypedefType(IDLType, IDLObjectWithIdentifier):
|
||||
def isDistinguishableFrom(self, other):
|
||||
return self.inner.isDistinguishableFrom(other)
|
||||
|
||||
def _getDependentObjects(self):
|
||||
return self.inner._getDependentObjects()
|
||||
|
||||
class IDLWrapperType(IDLType):
|
||||
def __init__(self, location, inner):
|
||||
IDLType.__init__(self, location, inner.identifier.name)
|
||||
@ -1806,23 +1741,6 @@ class IDLWrapperType(IDLType):
|
||||
assert other.isObject()
|
||||
return False
|
||||
|
||||
def _getDependentObjects(self):
|
||||
# NB: The codegen for an interface type depends on
|
||||
# a) That the identifier is in fact an interface (as opposed to
|
||||
# a dictionary or something else).
|
||||
# b) The native type of the interface.
|
||||
# If we depend on the interface object we will also depend on
|
||||
# anything the interface depends on which is undesirable. We
|
||||
# considered implementing a dependency just on the interface type
|
||||
# file, but then every modification to an interface would cause this
|
||||
# to be regenerated which is still undesirable. We decided not to
|
||||
# depend on anything, reasoning that:
|
||||
# 1) Changing the concrete type of the interface requires modifying
|
||||
# Bindings.conf, which is still a global dependency.
|
||||
# 2) Changing an interface to a dictionary (or vice versa) with the
|
||||
# same identifier should be incredibly rare.
|
||||
return set()
|
||||
|
||||
class IDLBuiltinType(IDLType):
|
||||
|
||||
Types = enum(
|
||||
@ -1988,9 +1906,6 @@ class IDLBuiltinType(IDLType):
|
||||
(self.isTypedArray() and not other.isArrayBufferView() and not
|
||||
(other.isTypedArray() and other.name == self.name)))))
|
||||
|
||||
def _getDependentObjects(self):
|
||||
return set()
|
||||
|
||||
BuiltinTypes = {
|
||||
IDLBuiltinType.Types.byte:
|
||||
IDLBuiltinType(BuiltinLocation("<builtin type>"), "Byte",
|
||||
@ -2149,9 +2064,6 @@ class IDLValue(IDLObject):
|
||||
raise WebIDLError("Cannot coerce type %s to type %s." %
|
||||
(self.type, type), [location])
|
||||
|
||||
def _getDependentObjects(self):
|
||||
return set()
|
||||
|
||||
class IDLNullValue(IDLObject):
|
||||
def __init__(self, location):
|
||||
IDLObject.__init__(self, location)
|
||||
@ -2170,9 +2082,6 @@ class IDLNullValue(IDLObject):
|
||||
nullValue.type = type
|
||||
return nullValue
|
||||
|
||||
def _getDependentObjects(self):
|
||||
return set()
|
||||
|
||||
|
||||
class IDLInterfaceMember(IDLObjectWithIdentifier):
|
||||
|
||||
@ -2253,9 +2162,6 @@ class IDLConst(IDLInterfaceMember):
|
||||
def validate(self):
|
||||
pass
|
||||
|
||||
def _getDependentObjects(self):
|
||||
return set([self.type, self.value])
|
||||
|
||||
class IDLAttribute(IDLInterfaceMember):
|
||||
def __init__(self, location, identifier, type, readonly, inherit=False,
|
||||
static=False, stringifier=False):
|
||||
@ -2401,9 +2307,6 @@ class IDLAttribute(IDLInterfaceMember):
|
||||
def isUnforgeable(self):
|
||||
return self._unforgeable
|
||||
|
||||
def _getDependentObjects(self):
|
||||
return set([self.type])
|
||||
|
||||
class IDLArgument(IDLObjectWithIdentifier):
|
||||
def __init__(self, location, identifier, type, optional=False, defaultValue=None, variadic=False, dictionaryMember=False):
|
||||
IDLObjectWithIdentifier.__init__(self, location, None, identifier)
|
||||
@ -2476,12 +2379,6 @@ class IDLArgument(IDLObjectWithIdentifier):
|
||||
self.location)
|
||||
assert self.defaultValue
|
||||
|
||||
def _getDependentObjects(self):
|
||||
deps = set([self.type])
|
||||
if self.defaultValue:
|
||||
deps.add(self.defaultValue)
|
||||
return deps
|
||||
|
||||
class IDLCallbackType(IDLType, IDLObjectWithScope):
|
||||
def __init__(self, location, parentScope, identifier, returnType, arguments):
|
||||
assert isinstance(returnType, IDLType)
|
||||
@ -2549,9 +2446,6 @@ class IDLCallbackType(IDLType, IDLObjectWithScope):
|
||||
if len(unhandledAttrs) != 0:
|
||||
IDLType.addExtendedAttributes(self, unhandledAttrs)
|
||||
|
||||
def _getDependentObjects(self):
|
||||
return set([self._returnType] + self._arguments)
|
||||
|
||||
class IDLMethodOverload:
|
||||
"""
|
||||
A class that represents a single overload of a WebIDL method. This is not
|
||||
@ -2567,11 +2461,6 @@ class IDLMethodOverload:
|
||||
self.arguments = list(arguments)
|
||||
self.location = location
|
||||
|
||||
def _getDependentObjects(self):
|
||||
deps = set(self.arguments)
|
||||
deps.add(self.returnType)
|
||||
return deps
|
||||
|
||||
class IDLMethod(IDLInterfaceMember, IDLScope):
|
||||
|
||||
Special = enum(
|
||||
@ -2919,12 +2808,6 @@ class IDLMethod(IDLInterfaceMember, IDLScope):
|
||||
[attr.location, self.location])
|
||||
IDLInterfaceMember.handleExtendedAttribute(self, attr)
|
||||
|
||||
def _getDependentObjects(self):
|
||||
deps = set()
|
||||
for overload in self._overloads:
|
||||
deps.union(overload._getDependentObjects())
|
||||
return deps
|
||||
|
||||
class IDLImplementsStatement(IDLObject):
|
||||
def __init__(self, location, implementor, implementee):
|
||||
IDLObject.__init__(self, location)
|
||||
|
@ -44,6 +44,7 @@ bindinggen_dependencies := \
|
||||
../Configuration.py \
|
||||
../Codegen.py \
|
||||
../parser/WebIDL.py \
|
||||
../ParserResults.pkl \
|
||||
../Makefile \
|
||||
$(GLOBAL_DEPS) \
|
||||
$(NULL)
|
||||
|
Loading…
Reference in New Issue
Block a user