mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Fix remaining flake8 warnings
This commit is contained in:
parent
c953931621
commit
d01648d637
28 changed files with 328 additions and 310 deletions
|
@ -170,5 +170,6 @@ def update_test_file(cachedir):
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
update_test_file(tempfile.gettempdir())
|
update_test_file(tempfile.gettempdir())
|
||||||
|
|
|
@ -359,17 +359,17 @@ class CGMethodCall(CGThing):
|
||||||
|
|
||||||
# First check for null or undefined
|
# First check for null or undefined
|
||||||
pickFirstSignature("%s.get().is_null_or_undefined()" % distinguishingArg,
|
pickFirstSignature("%s.get().is_null_or_undefined()" % distinguishingArg,
|
||||||
lambda s: (s[1][distinguishingIndex].type.nullable() or
|
lambda s: (s[1][distinguishingIndex].type.nullable()
|
||||||
s[1][distinguishingIndex].type.isDictionary()))
|
or s[1][distinguishingIndex].type.isDictionary()))
|
||||||
|
|
||||||
# Now check for distinguishingArg being an object that implements a
|
# Now check for distinguishingArg being an object that implements a
|
||||||
# non-callback interface. That includes typed arrays and
|
# non-callback interface. That includes typed arrays and
|
||||||
# arraybuffers.
|
# arraybuffers.
|
||||||
interfacesSigs = [
|
interfacesSigs = [
|
||||||
s for s in possibleSignatures
|
s for s in possibleSignatures
|
||||||
if (s[1][distinguishingIndex].type.isObject() or
|
if (s[1][distinguishingIndex].type.isObject()
|
||||||
s[1][distinguishingIndex].type.isUnion() or
|
or s[1][distinguishingIndex].type.isUnion()
|
||||||
s[1][distinguishingIndex].type.isNonCallbackInterface())]
|
or s[1][distinguishingIndex].type.isNonCallbackInterface())]
|
||||||
# There might be more than one of these; we need to check
|
# There might be more than one of these; we need to check
|
||||||
# which ones we unwrap to.
|
# which ones we unwrap to.
|
||||||
|
|
||||||
|
@ -424,24 +424,24 @@ class CGMethodCall(CGThing):
|
||||||
pickFirstSignature("%s.get().is_object() && is_array_like(*cx, %s)" %
|
pickFirstSignature("%s.get().is_object() && is_array_like(*cx, %s)" %
|
||||||
(distinguishingArg, distinguishingArg),
|
(distinguishingArg, distinguishingArg),
|
||||||
lambda s:
|
lambda s:
|
||||||
(s[1][distinguishingIndex].type.isSequence() or
|
(s[1][distinguishingIndex].type.isSequence()
|
||||||
s[1][distinguishingIndex].type.isObject()))
|
or s[1][distinguishingIndex].type.isObject()))
|
||||||
|
|
||||||
# Check for vanilla JS objects
|
# Check for vanilla JS objects
|
||||||
# XXXbz Do we need to worry about security wrappers?
|
# XXXbz Do we need to worry about security wrappers?
|
||||||
pickFirstSignature("%s.get().is_object()" %
|
pickFirstSignature("%s.get().is_object()" %
|
||||||
distinguishingArg,
|
distinguishingArg,
|
||||||
lambda s: (s[1][distinguishingIndex].type.isCallback() or
|
lambda s: (s[1][distinguishingIndex].type.isCallback()
|
||||||
s[1][distinguishingIndex].type.isCallbackInterface() or
|
or s[1][distinguishingIndex].type.isCallbackInterface()
|
||||||
s[1][distinguishingIndex].type.isDictionary() or
|
or s[1][distinguishingIndex].type.isDictionary()
|
||||||
s[1][distinguishingIndex].type.isObject()))
|
or s[1][distinguishingIndex].type.isObject()))
|
||||||
|
|
||||||
# The remaining cases are mutually exclusive. The
|
# The remaining cases are mutually exclusive. The
|
||||||
# pickFirstSignature calls are what change caseBody
|
# pickFirstSignature calls are what change caseBody
|
||||||
# Check for strings or enums
|
# Check for strings or enums
|
||||||
if pickFirstSignature(None,
|
if pickFirstSignature(None,
|
||||||
lambda s: (s[1][distinguishingIndex].type.isString() or
|
lambda s: (s[1][distinguishingIndex].type.isString()
|
||||||
s[1][distinguishingIndex].type.isEnum())):
|
or s[1][distinguishingIndex].type.isEnum())):
|
||||||
pass
|
pass
|
||||||
# Check for primitives
|
# Check for primitives
|
||||||
elif pickFirstSignature(None,
|
elif pickFirstSignature(None,
|
||||||
|
@ -482,9 +482,9 @@ class CGMethodCall(CGThing):
|
||||||
|
|
||||||
def dictionaryHasSequenceMember(dictionary):
|
def dictionaryHasSequenceMember(dictionary):
|
||||||
return (any(typeIsSequenceOrHasSequenceMember(m.type) for m in
|
return (any(typeIsSequenceOrHasSequenceMember(m.type) for m in
|
||||||
dictionary.members) or
|
dictionary.members)
|
||||||
(dictionary.parent and
|
or (dictionary.parent
|
||||||
dictionaryHasSequenceMember(dictionary.parent)))
|
and dictionaryHasSequenceMember(dictionary.parent)))
|
||||||
|
|
||||||
|
|
||||||
def typeIsSequenceOrHasSequenceMember(type):
|
def typeIsSequenceOrHasSequenceMember(type):
|
||||||
|
@ -618,22 +618,22 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
||||||
def onFailureNotAnObject(failureCode):
|
def onFailureNotAnObject(failureCode):
|
||||||
return CGWrapper(
|
return CGWrapper(
|
||||||
CGGeneric(
|
CGGeneric(
|
||||||
failureCode or
|
failureCode
|
||||||
('throw_type_error(*cx, "%s is not an object.");\n'
|
or ('throw_type_error(*cx, "%s is not an object.");\n'
|
||||||
'%s' % (firstCap(sourceDescription), exceptionCode))),
|
'%s' % (firstCap(sourceDescription), exceptionCode))),
|
||||||
post="\n")
|
post="\n")
|
||||||
|
|
||||||
def onFailureInvalidEnumValue(failureCode, passedVarName):
|
def onFailureInvalidEnumValue(failureCode, passedVarName):
|
||||||
return CGGeneric(
|
return CGGeneric(
|
||||||
failureCode or
|
failureCode
|
||||||
('throw_type_error(*cx, &format!("\'{}\' is not a valid enum value for enumeration \'%s\'.", %s)); %s'
|
or ('throw_type_error(*cx, &format!("\'{}\' is not a valid enum value for enumeration \'%s\'.", %s)); %s'
|
||||||
% (type.name, passedVarName, exceptionCode)))
|
% (type.name, passedVarName, exceptionCode)))
|
||||||
|
|
||||||
def onFailureNotCallable(failureCode):
|
def onFailureNotCallable(failureCode):
|
||||||
return CGGeneric(
|
return CGGeneric(
|
||||||
failureCode or
|
failureCode
|
||||||
('throw_type_error(*cx, \"%s is not callable.\");\n'
|
or ('throw_type_error(*cx, \"%s is not callable.\");\n'
|
||||||
'%s' % (firstCap(sourceDescription), exceptionCode)))
|
'%s' % (firstCap(sourceDescription), exceptionCode)))
|
||||||
|
|
||||||
# A helper function for handling default values.
|
# A helper function for handling default values.
|
||||||
def handleDefault(nullValue):
|
def handleDefault(nullValue):
|
||||||
|
@ -660,16 +660,16 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
||||||
# Handle the non-object cases by wrapping up the whole
|
# Handle the non-object cases by wrapping up the whole
|
||||||
# thing in an if cascade.
|
# thing in an if cascade.
|
||||||
templateBody = (
|
templateBody = (
|
||||||
"if ${val}.get().is_object() {\n" +
|
"if ${val}.get().is_object() {\n"
|
||||||
CGIndenter(CGGeneric(templateBody)).define() + "\n")
|
+ CGIndenter(CGGeneric(templateBody)).define() + "\n")
|
||||||
if type.nullable():
|
if type.nullable():
|
||||||
templateBody += (
|
templateBody += (
|
||||||
"} else if ${val}.get().is_null_or_undefined() {\n"
|
"} else if ${val}.get().is_null_or_undefined() {\n"
|
||||||
" %s\n") % nullValue
|
" %s\n") % nullValue
|
||||||
templateBody += (
|
templateBody += (
|
||||||
"} else {\n" +
|
"} else {\n"
|
||||||
CGIndenter(onFailureNotAnObject(failureCode)).define() +
|
+ CGIndenter(onFailureNotAnObject(failureCode)).define()
|
||||||
"}")
|
+ "}")
|
||||||
return templateBody
|
return templateBody
|
||||||
|
|
||||||
assert not (isEnforceRange and isClamp) # These are mutually exclusive
|
assert not (isEnforceRange and isClamp) # These are mutually exclusive
|
||||||
|
@ -713,9 +713,9 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
||||||
for memberType in type.unroll().flatMemberTypes
|
for memberType in type.unroll().flatMemberTypes
|
||||||
if memberType.isDictionary()
|
if memberType.isDictionary()
|
||||||
]
|
]
|
||||||
if (defaultValue and
|
if (defaultValue
|
||||||
not isinstance(defaultValue, IDLNullValue) and
|
and not isinstance(defaultValue, IDLNullValue)
|
||||||
not isinstance(defaultValue, IDLDefaultDictionaryValue)):
|
and not isinstance(defaultValue, IDLDefaultDictionaryValue)):
|
||||||
tag = defaultValue.type.tag()
|
tag = defaultValue.type.tag()
|
||||||
if tag is IDLType.Tags.bool:
|
if tag is IDLType.Tags.bool:
|
||||||
default = "%s::Boolean(%s)" % (
|
default = "%s::Boolean(%s)" % (
|
||||||
|
@ -1626,13 +1626,13 @@ class PropertyDefiner:
|
||||||
prefableSpecs.append(
|
prefableSpecs.append(
|
||||||
prefableTemplate % (cond, name + "_specs", len(specs) - 1))
|
prefableTemplate % (cond, name + "_specs", len(specs) - 1))
|
||||||
|
|
||||||
specsArray = ("const %s_specs: &'static [&'static[%s]] = &[\n" +
|
specsArray = ("const %s_specs: &'static [&'static[%s]] = &[\n"
|
||||||
",\n".join(specs) + "\n" +
|
+ ",\n".join(specs) + "\n"
|
||||||
"];\n") % (name, specType)
|
+ "];\n") % (name, specType)
|
||||||
|
|
||||||
prefArray = ("const %s: &'static [Guard<&'static [%s]>] = &[\n" +
|
prefArray = ("const %s: &'static [Guard<&'static [%s]>] = &[\n"
|
||||||
",\n".join(prefableSpecs) + "\n" +
|
+ ",\n".join(prefableSpecs) + "\n"
|
||||||
"];\n") % (name, specType)
|
+ "];\n") % (name, specType)
|
||||||
return specsArray + prefArray
|
return specsArray + prefArray
|
||||||
|
|
||||||
|
|
||||||
|
@ -1660,9 +1660,9 @@ class MethodDefiner(PropertyDefiner):
|
||||||
# Ignore non-static methods for callback interfaces
|
# Ignore non-static methods for callback interfaces
|
||||||
if not descriptor.interface.isCallback() or static:
|
if not descriptor.interface.isCallback() or static:
|
||||||
methods = [m for m in descriptor.interface.members if
|
methods = [m for m in descriptor.interface.members if
|
||||||
m.isMethod() and m.isStatic() == static and
|
m.isMethod() and m.isStatic() == static
|
||||||
not m.isIdentifierLess() and
|
and not m.isIdentifierLess()
|
||||||
MemberIsUnforgeable(m, descriptor) == unforgeable]
|
and MemberIsUnforgeable(m, descriptor) == unforgeable]
|
||||||
else:
|
else:
|
||||||
methods = []
|
methods = []
|
||||||
self.regular = [{"name": m.identifier.name,
|
self.regular = [{"name": m.identifier.name,
|
||||||
|
@ -1683,10 +1683,10 @@ class MethodDefiner(PropertyDefiner):
|
||||||
|
|
||||||
# Generate the keys/values/entries aliases for value iterables.
|
# Generate the keys/values/entries aliases for value iterables.
|
||||||
maplikeOrSetlikeOrIterable = descriptor.interface.maplikeOrSetlikeOrIterable
|
maplikeOrSetlikeOrIterable = descriptor.interface.maplikeOrSetlikeOrIterable
|
||||||
if (not static and not unforgeable and
|
if (not static and not unforgeable
|
||||||
(maplikeOrSetlikeOrIterable and
|
and maplikeOrSetlikeOrIterable
|
||||||
maplikeOrSetlikeOrIterable.isIterable() and
|
and maplikeOrSetlikeOrIterable.isIterable()
|
||||||
maplikeOrSetlikeOrIterable.isValueIterator())):
|
and maplikeOrSetlikeOrIterable.isValueIterator()):
|
||||||
m = maplikeOrSetlikeOrIterable
|
m = maplikeOrSetlikeOrIterable
|
||||||
|
|
||||||
# Add our keys/values/entries/forEach
|
# Add our keys/values/entries/forEach
|
||||||
|
@ -1805,8 +1805,8 @@ class AttrDefiner(PropertyDefiner):
|
||||||
self.regular = [
|
self.regular = [
|
||||||
m
|
m
|
||||||
for m in descriptor.interface.members if
|
for m in descriptor.interface.members if
|
||||||
m.isAttr() and m.isStatic() == static and
|
m.isAttr() and m.isStatic() == static
|
||||||
MemberIsUnforgeable(m, descriptor) == unforgeable
|
and MemberIsUnforgeable(m, descriptor) == unforgeable
|
||||||
]
|
]
|
||||||
self.static = static
|
self.static = static
|
||||||
self.unforgeable = unforgeable
|
self.unforgeable = unforgeable
|
||||||
|
@ -1902,6 +1902,7 @@ class ConstDefiner(PropertyDefiner):
|
||||||
'ConstantSpec',
|
'ConstantSpec',
|
||||||
PropertyDefiner.getControllingCondition, specData)
|
PropertyDefiner.getControllingCondition, specData)
|
||||||
|
|
||||||
|
|
||||||
# We'll want to insert the indent at the beginnings of lines, but we
|
# We'll want to insert the indent at the beginnings of lines, but we
|
||||||
# don't want to indent empty lines. So only indent lines that have a
|
# don't want to indent empty lines. So only indent lines that have a
|
||||||
# non-newline character on them.
|
# non-newline character on them.
|
||||||
|
@ -2003,8 +2004,8 @@ class CGImports(CGWrapper):
|
||||||
|
|
||||||
def isImportable(type):
|
def isImportable(type):
|
||||||
if not type.isType():
|
if not type.isType():
|
||||||
assert (type.isInterface() or type.isDictionary() or
|
assert (type.isInterface() or type.isDictionary()
|
||||||
type.isEnum() or type.isNamespace())
|
or type.isEnum() or type.isNamespace())
|
||||||
return True
|
return True
|
||||||
return not (type.builtin or type.isSequence() or type.isUnion())
|
return not (type.builtin or type.isSequence() or type.isUnion())
|
||||||
|
|
||||||
|
@ -2878,8 +2879,8 @@ class CGIDLInterface(CGThing):
|
||||||
def define(self):
|
def define(self):
|
||||||
interface = self.descriptor.interface
|
interface = self.descriptor.interface
|
||||||
name = self.descriptor.concreteType
|
name = self.descriptor.concreteType
|
||||||
if (interface.getUserData("hasConcreteDescendant", False) or
|
if (interface.getUserData("hasConcreteDescendant", False)
|
||||||
interface.getUserData("hasProxyDescendant", False)):
|
or interface.getUserData("hasProxyDescendant", False)):
|
||||||
depth = self.descriptor.prototypeDepth
|
depth = self.descriptor.prototypeDepth
|
||||||
check = "class.interface_chain[%s] == PrototypeList::ID::%s" % (depth, name)
|
check = "class.interface_chain[%s] == PrototypeList::ID::%s" % (depth, name)
|
||||||
elif self.descriptor.proxy:
|
elif self.descriptor.proxy:
|
||||||
|
@ -3466,9 +3467,9 @@ assert!(!proto.is_null());""" % (function,))
|
||||||
|
|
||||||
|
|
||||||
def needCx(returnType, arguments, considerTypes):
|
def needCx(returnType, arguments, considerTypes):
|
||||||
return (considerTypes and
|
return (considerTypes
|
||||||
(typeNeedsCx(returnType, True) or
|
and (typeNeedsCx(returnType, True)
|
||||||
any(typeNeedsCx(a.type) for a in arguments)))
|
or any(typeNeedsCx(a.type) for a in arguments)))
|
||||||
|
|
||||||
|
|
||||||
class CGCallGenerator(CGThing):
|
class CGCallGenerator(CGThing):
|
||||||
|
@ -3775,10 +3776,10 @@ class CGSpecializedMethod(CGAbstractExternMethod):
|
||||||
self.method)
|
self.method)
|
||||||
return CGWrapper(CGMethodCall([], nativeName, self.method.isStatic(),
|
return CGWrapper(CGMethodCall([], nativeName, self.method.isStatic(),
|
||||||
self.descriptor, self.method),
|
self.descriptor, self.method),
|
||||||
pre="let cx = SafeJSContext::from_ptr(cx);\n" +
|
pre="let cx = SafeJSContext::from_ptr(cx);\n"
|
||||||
("let this = &*(this as *const %s);\n" % self.descriptor.concreteType) +
|
+ ("let this = &*(this as *const %s);\n" % self.descriptor.concreteType)
|
||||||
"let args = &*args;\n"
|
+ "let args = &*args;\n"
|
||||||
"let argc = args.argc_;\n")
|
"let argc = args.argc_;\n")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def makeNativeName(descriptor, method):
|
def makeNativeName(descriptor, method):
|
||||||
|
@ -3868,8 +3869,8 @@ class CGSpecializedGetter(CGAbstractExternMethod):
|
||||||
|
|
||||||
return CGWrapper(CGGetterCall([], self.attr.type, nativeName,
|
return CGWrapper(CGGetterCall([], self.attr.type, nativeName,
|
||||||
self.descriptor, self.attr),
|
self.descriptor, self.attr),
|
||||||
pre="let cx = SafeJSContext::from_ptr(cx);\n" +
|
pre="let cx = SafeJSContext::from_ptr(cx);\n"
|
||||||
("let this = &*(this as *const %s);\n" % self.descriptor.concreteType))
|
+ ("let this = &*(this as *const %s);\n" % self.descriptor.concreteType))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def makeNativeName(descriptor, attr):
|
def makeNativeName(descriptor, attr):
|
||||||
|
@ -3924,8 +3925,8 @@ class CGSpecializedSetter(CGAbstractExternMethod):
|
||||||
self.attr)
|
self.attr)
|
||||||
return CGWrapper(CGSetterCall([], self.attr.type, nativeName,
|
return CGWrapper(CGSetterCall([], self.attr.type, nativeName,
|
||||||
self.descriptor, self.attr),
|
self.descriptor, self.attr),
|
||||||
pre="let cx = SafeJSContext::from_ptr(cx);\n" +
|
pre="let cx = SafeJSContext::from_ptr(cx);\n"
|
||||||
("let this = &*(this as *const %s);\n" % self.descriptor.concreteType))
|
+ ("let this = &*(this as *const %s);\n" % self.descriptor.concreteType))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def makeNativeName(descriptor, attr):
|
def makeNativeName(descriptor, attr):
|
||||||
|
@ -4191,8 +4192,8 @@ class CGMemberJITInfo(CGThing):
|
||||||
# don't want them coalesced with each other or loop-hoisted, since
|
# don't want them coalesced with each other or loop-hoisted, since
|
||||||
# their return value can change even if nothing is going on from our
|
# their return value can change even if nothing is going on from our
|
||||||
# point of view.
|
# point of view.
|
||||||
return (affects == "Nothing" and
|
return (affects == "Nothing"
|
||||||
(dependsOn != "Everything" and dependsOn != "DeviceState"))
|
and (dependsOn != "Everything" and dependsOn != "DeviceState"))
|
||||||
|
|
||||||
def aliasSet(self):
|
def aliasSet(self):
|
||||||
"""Returns the alias set to store in the jitinfo. This may not be the
|
"""Returns the alias set to store in the jitinfo. This may not be the
|
||||||
|
@ -4282,10 +4283,10 @@ class CGMemberJITInfo(CGThing):
|
||||||
|
|
||||||
if type == existingType:
|
if type == existingType:
|
||||||
return existingType
|
return existingType
|
||||||
if ((type == "JSVAL_TYPE_DOUBLE" and
|
if ((type == "JSVAL_TYPE_DOUBLE"
|
||||||
existingType == "JSVAL_TYPE_INT32") or
|
and existingType == "JSVAL_TYPE_INT32")
|
||||||
(existingType == "JSVAL_TYPE_DOUBLE" and
|
or (existingType == "JSVAL_TYPE_DOUBLE"
|
||||||
type == "JSVAL_TYPE_INT32")):
|
and type == "JSVAL_TYPE_INT32")):
|
||||||
# Promote INT32 to DOUBLE as needed
|
# Promote INT32 to DOUBLE as needed
|
||||||
return "JSVAL_TYPE_DOUBLE"
|
return "JSVAL_TYPE_DOUBLE"
|
||||||
# Different types
|
# Different types
|
||||||
|
@ -5206,8 +5207,8 @@ class CGProxyNamedOperation(CGProxySpecialOperation):
|
||||||
argName = self.arguments[0].identifier.name
|
argName = self.arguments[0].identifier.name
|
||||||
return ("let %s = jsid_to_string(*cx, Handle::from_raw(id)).expect(\"Not a string-convertible JSID?\");\n"
|
return ("let %s = jsid_to_string(*cx, Handle::from_raw(id)).expect(\"Not a string-convertible JSID?\");\n"
|
||||||
"let this = UnwrapProxy(proxy);\n"
|
"let this = UnwrapProxy(proxy);\n"
|
||||||
"let this = &*this;\n" % argName +
|
"let this = &*this;\n" % argName
|
||||||
CGProxySpecialOperation.define(self))
|
+ CGProxySpecialOperation.define(self))
|
||||||
|
|
||||||
|
|
||||||
class CGProxyNamedGetter(CGProxyNamedOperation):
|
class CGProxyNamedGetter(CGProxyNamedOperation):
|
||||||
|
@ -5288,11 +5289,11 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
||||||
'successCode': fillDescriptor,
|
'successCode': fillDescriptor,
|
||||||
'pre': 'rooted!(in(*cx) let mut result_root = UndefinedValue());'
|
'pre': 'rooted!(in(*cx) let mut result_root = UndefinedValue());'
|
||||||
}
|
}
|
||||||
get += ("if let Some(index) = index {\n" +
|
get += ("if let Some(index) = index {\n"
|
||||||
" let this = UnwrapProxy(proxy);\n" +
|
+ " let this = UnwrapProxy(proxy);\n"
|
||||||
" let this = &*this;\n" +
|
+ " let this = &*this;\n"
|
||||||
CGIndenter(CGProxyIndexedGetter(self.descriptor, templateValues)).define() + "\n" +
|
+ CGIndenter(CGProxyIndexedGetter(self.descriptor, templateValues)).define() + "\n"
|
||||||
"}\n")
|
+ "}\n")
|
||||||
|
|
||||||
namedGetter = self.descriptor.operations['NamedGetter']
|
namedGetter = self.descriptor.operations['NamedGetter']
|
||||||
if namedGetter:
|
if namedGetter:
|
||||||
|
@ -5373,16 +5374,16 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
|
||||||
|
|
||||||
indexedSetter = self.descriptor.operations['IndexedSetter']
|
indexedSetter = self.descriptor.operations['IndexedSetter']
|
||||||
if indexedSetter:
|
if indexedSetter:
|
||||||
set += ("let index = get_array_index_from_id(*cx, Handle::from_raw(id));\n" +
|
set += ("let index = get_array_index_from_id(*cx, Handle::from_raw(id));\n"
|
||||||
"if let Some(index) = index {\n" +
|
+ "if let Some(index) = index {\n"
|
||||||
" let this = UnwrapProxy(proxy);\n" +
|
+ " let this = UnwrapProxy(proxy);\n"
|
||||||
" let this = &*this;\n" +
|
+ " let this = &*this;\n"
|
||||||
CGIndenter(CGProxyIndexedSetter(self.descriptor)).define() +
|
+ CGIndenter(CGProxyIndexedSetter(self.descriptor)).define()
|
||||||
" return (*opresult).succeed();\n" +
|
+ " return (*opresult).succeed();\n"
|
||||||
"}\n")
|
+ "}\n")
|
||||||
elif self.descriptor.operations['IndexedGetter']:
|
elif self.descriptor.operations['IndexedGetter']:
|
||||||
set += ("if get_array_index_from_id(*cx, Handle::from_raw(id)).is_some() {\n" +
|
set += ("if get_array_index_from_id(*cx, Handle::from_raw(id)).is_some() {\n"
|
||||||
" return (*opresult).failNoIndexedSetter();\n" +
|
" return (*opresult).failNoIndexedSetter();\n"
|
||||||
"}\n")
|
"}\n")
|
||||||
|
|
||||||
namedSetter = self.descriptor.operations['NamedSetter']
|
namedSetter = self.descriptor.operations['NamedSetter']
|
||||||
|
@ -5390,17 +5391,17 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
|
||||||
if self.descriptor.hasUnforgeableMembers:
|
if self.descriptor.hasUnforgeableMembers:
|
||||||
raise TypeError("Can't handle a named setter on an interface that has "
|
raise TypeError("Can't handle a named setter on an interface that has "
|
||||||
"unforgeables. Figure out how that should work!")
|
"unforgeables. Figure out how that should work!")
|
||||||
set += ("if RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id) {\n" +
|
set += ("if RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id) {\n"
|
||||||
CGIndenter(CGProxyNamedSetter(self.descriptor)).define() +
|
+ CGIndenter(CGProxyNamedSetter(self.descriptor)).define()
|
||||||
" return (*opresult).succeed();\n" +
|
+ " return (*opresult).succeed();\n"
|
||||||
"}\n")
|
+ "}\n")
|
||||||
elif self.descriptor.operations['NamedGetter']:
|
elif self.descriptor.operations['NamedGetter']:
|
||||||
set += ("if RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id) {\n" +
|
set += ("if RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id) {\n"
|
||||||
CGIndenter(CGProxyNamedGetter(self.descriptor)).define() +
|
+ CGIndenter(CGProxyNamedGetter(self.descriptor)).define()
|
||||||
" if result.is_some() {\n"
|
+ " if result.is_some() {\n"
|
||||||
" return (*opresult).failNoNamedSetter();\n"
|
" return (*opresult).failNoNamedSetter();\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"}\n")
|
"}\n")
|
||||||
set += "return proxyhandler::define_property(*cx, %s);" % ", ".join(a.name for a in self.args[1:])
|
set += "return proxyhandler::define_property(*cx, %s);" % ", ".join(a.name for a in self.args[1:])
|
||||||
return set
|
return set
|
||||||
|
|
||||||
|
@ -5488,8 +5489,8 @@ class CGDOMJSProxyHandler_ownPropertyKeys(CGAbstractExternMethod):
|
||||||
|
|
||||||
class CGDOMJSProxyHandler_getOwnEnumerablePropertyKeys(CGAbstractExternMethod):
|
class CGDOMJSProxyHandler_getOwnEnumerablePropertyKeys(CGAbstractExternMethod):
|
||||||
def __init__(self, descriptor):
|
def __init__(self, descriptor):
|
||||||
assert (descriptor.operations["IndexedGetter"] and
|
assert (descriptor.operations["IndexedGetter"]
|
||||||
descriptor.interface.getExtendedAttribute("LegacyUnenumerableNamedProperties"))
|
and descriptor.interface.getExtendedAttribute("LegacyUnenumerableNamedProperties"))
|
||||||
args = [Argument('*mut JSContext', 'cx'),
|
args = [Argument('*mut JSContext', 'cx'),
|
||||||
Argument('RawHandleObject', 'proxy'),
|
Argument('RawHandleObject', 'proxy'),
|
||||||
Argument('RawMutableHandleIdVector', 'props')]
|
Argument('RawMutableHandleIdVector', 'props')]
|
||||||
|
@ -5543,14 +5544,14 @@ class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod):
|
||||||
indexedGetter = self.descriptor.operations['IndexedGetter']
|
indexedGetter = self.descriptor.operations['IndexedGetter']
|
||||||
indexed = "let cx = SafeJSContext::from_ptr(cx);\n"
|
indexed = "let cx = SafeJSContext::from_ptr(cx);\n"
|
||||||
if indexedGetter:
|
if indexedGetter:
|
||||||
indexed += ("let index = get_array_index_from_id(*cx, Handle::from_raw(id));\n" +
|
indexed += ("let index = get_array_index_from_id(*cx, Handle::from_raw(id));\n"
|
||||||
"if let Some(index) = index {\n" +
|
+ "if let Some(index) = index {\n"
|
||||||
" let this = UnwrapProxy(proxy);\n" +
|
+ " let this = UnwrapProxy(proxy);\n"
|
||||||
" let this = &*this;\n" +
|
+ " let this = &*this;\n"
|
||||||
CGIndenter(CGProxyIndexedGetter(self.descriptor)).define() + "\n" +
|
+ CGIndenter(CGProxyIndexedGetter(self.descriptor)).define() + "\n"
|
||||||
" *bp = result.is_some();\n" +
|
+ " *bp = result.is_some();\n"
|
||||||
" return true;\n" +
|
+ " return true;\n"
|
||||||
"}\n\n")
|
+ "}\n\n")
|
||||||
|
|
||||||
namedGetter = self.descriptor.operations['NamedGetter']
|
namedGetter = self.descriptor.operations['NamedGetter']
|
||||||
condition = "RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id)"
|
condition = "RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id)"
|
||||||
|
@ -5624,11 +5625,11 @@ if !expando.is_null() {
|
||||||
|
|
||||||
indexedGetter = self.descriptor.operations['IndexedGetter']
|
indexedGetter = self.descriptor.operations['IndexedGetter']
|
||||||
if indexedGetter:
|
if indexedGetter:
|
||||||
getIndexedOrExpando = ("let index = get_array_index_from_id(*cx, id_lt);\n" +
|
getIndexedOrExpando = ("let index = get_array_index_from_id(*cx, id_lt);\n"
|
||||||
"if let Some(index) = index {\n" +
|
+ "if let Some(index) = index {\n"
|
||||||
" let this = UnwrapProxy(proxy);\n" +
|
+ " let this = UnwrapProxy(proxy);\n"
|
||||||
" let this = &*this;\n" +
|
+ " let this = &*this;\n"
|
||||||
CGIndenter(CGProxyIndexedGetter(self.descriptor, templateValues)).define())
|
+ CGIndenter(CGProxyIndexedGetter(self.descriptor, templateValues)).define())
|
||||||
getIndexedOrExpando += """\
|
getIndexedOrExpando += """\
|
||||||
// Even if we don't have this index, we don't forward the
|
// Even if we don't have this index, we don't forward the
|
||||||
// get on to our expando object.
|
// get on to our expando object.
|
||||||
|
@ -5648,9 +5649,9 @@ if !expando.is_null() {
|
||||||
# 3. Set ignoreNamedProps to true.
|
# 3. Set ignoreNamedProps to true.
|
||||||
if indexedGetter:
|
if indexedGetter:
|
||||||
condition = "index.is_none() && (%s)" % condition
|
condition = "index.is_none() && (%s)" % condition
|
||||||
getNamed = ("if %s {\n" +
|
getNamed = ("if %s {\n"
|
||||||
CGIndenter(CGProxyNamedGetter(self.descriptor, templateValues)).define() +
|
+ CGIndenter(CGProxyNamedGetter(self.descriptor, templateValues)).define()
|
||||||
"}\n") % condition
|
+ "}\n") % condition
|
||||||
else:
|
else:
|
||||||
getNamed = ""
|
getNamed = ""
|
||||||
|
|
||||||
|
@ -5852,10 +5853,10 @@ class CGInterfaceTrait(CGThing):
|
||||||
|
|
||||||
def members():
|
def members():
|
||||||
for m in descriptor.interface.members:
|
for m in descriptor.interface.members:
|
||||||
if (m.isMethod() and not m.isStatic() and
|
if (m.isMethod() and not m.isStatic()
|
||||||
not m.isMaplikeOrSetlikeOrIterableMethod() and
|
and not m.isMaplikeOrSetlikeOrIterableMethod()
|
||||||
(not m.isIdentifierLess() or (m.isStringifier() and not m.underlyingAttr)) and
|
and (not m.isIdentifierLess() or (m.isStringifier() and not m.underlyingAttr))
|
||||||
not m.isDefaultToJSON()):
|
and not m.isDefaultToJSON()):
|
||||||
name = CGSpecializedMethod.makeNativeName(descriptor, m)
|
name = CGSpecializedMethod.makeNativeName(descriptor, m)
|
||||||
infallible = 'infallible' in descriptor.getExtendedAttributes(m)
|
infallible = 'infallible' in descriptor.getExtendedAttributes(m)
|
||||||
for idx, (rettype, arguments) in enumerate(m.signatures()):
|
for idx, (rettype, arguments) in enumerate(m.signatures()):
|
||||||
|
@ -6254,8 +6255,8 @@ class CGDescriptor(CGThing):
|
||||||
defaultToJSONMethod = None
|
defaultToJSONMethod = None
|
||||||
unscopableNames = []
|
unscopableNames = []
|
||||||
for m in descriptor.interface.members:
|
for m in descriptor.interface.members:
|
||||||
if (m.isMethod() and
|
if (m.isMethod()
|
||||||
(not m.isIdentifierLess() or m == descriptor.operations["Stringifier"])):
|
and (not m.isIdentifierLess() or m == descriptor.operations["Stringifier"])):
|
||||||
if m.getExtendedAttribute("Unscopable"):
|
if m.getExtendedAttribute("Unscopable"):
|
||||||
assert not m.isStatic()
|
assert not m.isStatic()
|
||||||
unscopableNames.append(m.identifier.name)
|
unscopableNames.append(m.identifier.name)
|
||||||
|
@ -6506,14 +6507,14 @@ class CGDictionary(CGThing):
|
||||||
|
|
||||||
return (string.Template(
|
return (string.Template(
|
||||||
"#[derive(${derive})]\n"
|
"#[derive(${derive})]\n"
|
||||||
"${mustRoot}" +
|
+ "${mustRoot}"
|
||||||
"pub struct ${selfName} {\n" +
|
+ "pub struct ${selfName} {\n"
|
||||||
"${inheritance}" +
|
+ "${inheritance}"
|
||||||
"\n".join(memberDecls) + "\n" +
|
+ "\n".join(memberDecls) + "\n"
|
||||||
"}").substitute({"selfName": self.makeClassName(d),
|
+ "}").substitute({"selfName": self.makeClassName(d),
|
||||||
"inheritance": inheritance,
|
"inheritance": inheritance,
|
||||||
"mustRoot": mustRoot,
|
"mustRoot": mustRoot,
|
||||||
"derive": ', '.join(derive)}))
|
"derive": ', '.join(derive)}))
|
||||||
|
|
||||||
def impl(self):
|
def impl(self):
|
||||||
d = self.dictionary
|
d = self.dictionary
|
||||||
|
@ -6769,15 +6770,15 @@ class CGRegisterProxyHandlers(CGThing):
|
||||||
descriptors = config.getDescriptors(proxy=True)
|
descriptors = config.getDescriptors(proxy=True)
|
||||||
self.root = CGList([
|
self.root = CGList([
|
||||||
CGGeneric(
|
CGGeneric(
|
||||||
"#[allow(non_upper_case_globals)]\n" +
|
"#[allow(non_upper_case_globals)]\n"
|
||||||
"pub mod proxy_handlers {\n" +
|
"pub mod proxy_handlers {\n"
|
||||||
"".join(
|
"".join(
|
||||||
" pub static %s: std::sync::atomic::AtomicPtr<libc::c_void> =\n"
|
" pub static %s: std::sync::atomic::AtomicPtr<libc::c_void> =\n"
|
||||||
" std::sync::atomic::AtomicPtr::new(std::ptr::null_mut());\n"
|
" std::sync::atomic::AtomicPtr::new(std::ptr::null_mut());\n"
|
||||||
% desc.name
|
% desc.name
|
||||||
for desc in descriptors
|
for desc in descriptors
|
||||||
) +
|
)
|
||||||
"}\n"
|
+ "}\n"
|
||||||
),
|
),
|
||||||
CGRegisterProxyHandlersMethod(descriptors),
|
CGRegisterProxyHandlersMethod(descriptors),
|
||||||
], "\n")
|
], "\n")
|
||||||
|
@ -7004,8 +7005,8 @@ class CGNativeMember(ClassMethod):
|
||||||
static=member.isStatic(),
|
static=member.isStatic(),
|
||||||
# Mark our getters, which are attrs that
|
# Mark our getters, which are attrs that
|
||||||
# have a non-void return type, as const.
|
# have a non-void return type, as const.
|
||||||
const=(not member.isStatic() and member.isAttr() and
|
const=(not member.isStatic() and member.isAttr()
|
||||||
not signature[0].isVoid()),
|
and not signature[0].isVoid()),
|
||||||
breakAfterSelf=breakAfterSelf,
|
breakAfterSelf=breakAfterSelf,
|
||||||
unsafe=unsafe,
|
unsafe=unsafe,
|
||||||
visibility=visibility)
|
visibility=visibility)
|
||||||
|
@ -7087,23 +7088,23 @@ class CGCallback(CGClass):
|
||||||
setupCall = "let s = CallSetup::new(self, aExceptionHandling);\n"
|
setupCall = "let s = CallSetup::new(self, aExceptionHandling);\n"
|
||||||
|
|
||||||
bodyWithThis = string.Template(
|
bodyWithThis = string.Template(
|
||||||
setupCall +
|
setupCall
|
||||||
"rooted!(in(*s.get_context()) let mut thisObjJS = ptr::null_mut::<JSObject>());\n"
|
+ "rooted!(in(*s.get_context()) let mut thisObjJS = ptr::null_mut::<JSObject>());\n"
|
||||||
"wrap_call_this_object(s.get_context(), thisObj, thisObjJS.handle_mut());\n"
|
"wrap_call_this_object(s.get_context(), thisObj, thisObjJS.handle_mut());\n"
|
||||||
"if thisObjJS.is_null() {\n"
|
"if thisObjJS.is_null() {\n"
|
||||||
" return Err(JSFailed);\n"
|
" return Err(JSFailed);\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"unsafe { ${methodName}(${callArgs}) }").substitute({
|
"unsafe { ${methodName}(${callArgs}) }").substitute({
|
||||||
"callArgs": ", ".join(argnamesWithThis),
|
"callArgs": ", ".join(argnamesWithThis),
|
||||||
"methodName": 'self.' + method.name,
|
"methodName": 'self.' + method.name,
|
||||||
})
|
})
|
||||||
bodyWithoutThis = string.Template(
|
bodyWithoutThis = string.Template(
|
||||||
setupCall +
|
setupCall
|
||||||
"rooted!(in(*s.get_context()) let thisObjJS = ptr::null_mut::<JSObject>());\n"
|
+ "rooted!(in(*s.get_context()) let thisObjJS = ptr::null_mut::<JSObject>());\n"
|
||||||
"unsafe { ${methodName}(${callArgs}) }").substitute({
|
"unsafe { ${methodName}(${callArgs}) }").substitute({
|
||||||
"callArgs": ", ".join(argnamesWithoutThis),
|
"callArgs": ", ".join(argnamesWithoutThis),
|
||||||
"methodName": 'self.' + method.name,
|
"methodName": 'self.' + method.name,
|
||||||
})
|
})
|
||||||
return [ClassMethod(method.name + '_', method.returnType, args,
|
return [ClassMethod(method.name + '_', method.returnType, args,
|
||||||
bodyInHeader=True,
|
bodyInHeader=True,
|
||||||
templateArgs=["T: DomObject"],
|
templateArgs=["T: DomObject"],
|
||||||
|
@ -7314,28 +7315,28 @@ class CallbackMember(CGNativeMember):
|
||||||
|
|
||||||
conversion = wrapForType(
|
conversion = wrapForType(
|
||||||
"argv_root.handle_mut()", result=argval,
|
"argv_root.handle_mut()", result=argval,
|
||||||
successCode=("{\n" +
|
successCode=("{\n"
|
||||||
"let arg = &mut argv[%s];\n" +
|
"let arg = &mut argv[%s];\n"
|
||||||
"*arg = Heap::default();\n" +
|
"*arg = Heap::default();\n"
|
||||||
"arg.set(argv_root.get());\n" +
|
"arg.set(argv_root.get());\n"
|
||||||
"}") % jsvalIndex,
|
"}") % jsvalIndex,
|
||||||
pre="rooted!(in(*cx) let mut argv_root = UndefinedValue());")
|
pre="rooted!(in(*cx) let mut argv_root = UndefinedValue());")
|
||||||
if arg.variadic:
|
if arg.variadic:
|
||||||
conversion = string.Template(
|
conversion = string.Template(
|
||||||
"for idx in 0..${arg}.len() {\n" +
|
"for idx in 0..${arg}.len() {\n"
|
||||||
CGIndenter(CGGeneric(conversion)).define() + "\n"
|
+ CGIndenter(CGGeneric(conversion)).define() + "\n"
|
||||||
"}"
|
+ "}"
|
||||||
).substitute({"arg": arg.identifier.name})
|
).substitute({"arg": arg.identifier.name})
|
||||||
elif arg.optional and not arg.defaultValue:
|
elif arg.optional and not arg.defaultValue:
|
||||||
conversion = (
|
conversion = (
|
||||||
CGIfWrapper("%s.is_some()" % arg.identifier.name,
|
CGIfWrapper("%s.is_some()" % arg.identifier.name,
|
||||||
CGGeneric(conversion)).define() +
|
CGGeneric(conversion)).define()
|
||||||
" else if argc == %d {\n"
|
+ " else if argc == %d {\n"
|
||||||
" // This is our current trailing argument; reduce argc\n"
|
" // This is our current trailing argument; reduce argc\n"
|
||||||
" argc -= 1;\n"
|
" argc -= 1;\n"
|
||||||
"} else {\n"
|
"} else {\n"
|
||||||
" argv[%d] = Heap::default();\n"
|
" argv[%d] = Heap::default();\n"
|
||||||
"}" % (i + 1, i))
|
"}" % (i + 1, i))
|
||||||
return conversion
|
return conversion
|
||||||
|
|
||||||
def getArgs(self, returnType, argList):
|
def getArgs(self, returnType, argList):
|
||||||
|
@ -7464,8 +7465,8 @@ class CallbackOperationBase(CallbackMethod):
|
||||||
return 'rooted!(in(*cx) let callable =\n' + getCallableFromProp + ');\n'
|
return 'rooted!(in(*cx) let callable =\n' + getCallableFromProp + ');\n'
|
||||||
return (
|
return (
|
||||||
'let isCallable = IsCallable(self.callback());\n'
|
'let isCallable = IsCallable(self.callback());\n'
|
||||||
'rooted!(in(*cx) let callable =\n' +
|
'rooted!(in(*cx) let callable =\n'
|
||||||
CGIndenter(
|
+ CGIndenter(
|
||||||
CGIfElseWrapper('isCallable',
|
CGIfElseWrapper('isCallable',
|
||||||
CGGeneric('ObjectValue(self.callback())'),
|
CGGeneric('ObjectValue(self.callback())'),
|
||||||
CGGeneric(getCallableFromProp))).define() + ');\n')
|
CGGeneric(getCallableFromProp))).define() + ');\n')
|
||||||
|
@ -7676,9 +7677,9 @@ class GlobalGenRoots():
|
||||||
return getModuleFromObject(d).split('::')[-1]
|
return getModuleFromObject(d).split('::')[-1]
|
||||||
|
|
||||||
descriptors = config.getDescriptors(register=True, isIteratorInterface=False)
|
descriptors = config.getDescriptors(register=True, isIteratorInterface=False)
|
||||||
descriptors = (set(toBindingNamespace(d.name) for d in descriptors) |
|
descriptors = (set(toBindingNamespace(d.name) for d in descriptors)
|
||||||
set(leafModule(d) for d in config.callbacks) |
|
| set(leafModule(d) for d in config.callbacks)
|
||||||
set(leafModule(d) for d in config.getDictionaries()))
|
| set(leafModule(d) for d in config.getDictionaries()))
|
||||||
curr = CGList([CGGeneric("pub mod %s;\n" % name) for name in sorted(descriptors)])
|
curr = CGList([CGGeneric("pub mod %s;\n" % name) for name in sorted(descriptors)])
|
||||||
curr = CGWrapper(curr, pre=AUTOGENERATED_WARNING_COMMENT)
|
curr = CGWrapper(curr, pre=AUTOGENERATED_WARNING_COMMENT)
|
||||||
return curr
|
return curr
|
||||||
|
|
|
@ -63,7 +63,8 @@ class Configuration:
|
||||||
c.isCallback() and not c.isInterface()]
|
c.isCallback() and not c.isInterface()]
|
||||||
|
|
||||||
# Keep the descriptor list sorted for determinism.
|
# Keep the descriptor list sorted for determinism.
|
||||||
cmp = lambda x, y: (x > y) - (x < y)
|
def cmp(x, y):
|
||||||
|
return (x > y) - (x < y)
|
||||||
self.descriptors.sort(key=functools.cmp_to_key(lambda x, y: cmp(x.name, y.name)))
|
self.descriptors.sort(key=functools.cmp_to_key(lambda x, y: cmp(x.name, y.name)))
|
||||||
|
|
||||||
def getInterface(self, ifname):
|
def getInterface(self, ifname):
|
||||||
|
@ -74,25 +75,35 @@ class Configuration:
|
||||||
curr = self.descriptors
|
curr = self.descriptors
|
||||||
for key, val in filters.iteritems():
|
for key, val in filters.iteritems():
|
||||||
if key == 'webIDLFile':
|
if key == 'webIDLFile':
|
||||||
getter = lambda x: x.interface.filename()
|
def getter(x):
|
||||||
|
return x.interface.filename()
|
||||||
elif key == 'hasInterfaceObject':
|
elif key == 'hasInterfaceObject':
|
||||||
getter = lambda x: x.interface.hasInterfaceObject()
|
def getter(x):
|
||||||
|
return x.interface.hasInterfaceObject()
|
||||||
elif key == 'isCallback':
|
elif key == 'isCallback':
|
||||||
getter = lambda x: x.interface.isCallback()
|
def getter(x):
|
||||||
|
return x.interface.isCallback()
|
||||||
elif key == 'isNamespace':
|
elif key == 'isNamespace':
|
||||||
getter = lambda x: x.interface.isNamespace()
|
def getter(x):
|
||||||
|
return x.interface.isNamespace()
|
||||||
elif key == 'isJSImplemented':
|
elif key == 'isJSImplemented':
|
||||||
getter = lambda x: x.interface.isJSImplemented()
|
def getter(x):
|
||||||
|
return x.interface.isJSImplemented()
|
||||||
elif key == 'isGlobal':
|
elif key == 'isGlobal':
|
||||||
getter = lambda x: x.isGlobal()
|
def getter(x):
|
||||||
|
return x.isGlobal()
|
||||||
elif key == 'isInline':
|
elif key == 'isInline':
|
||||||
getter = lambda x: x.interface.getExtendedAttribute('Inline') is not None
|
def getter(x):
|
||||||
|
return x.interface.getExtendedAttribute('Inline') is not None
|
||||||
elif key == 'isExposedConditionally':
|
elif key == 'isExposedConditionally':
|
||||||
getter = lambda x: x.interface.isExposedConditionally()
|
def getter(x):
|
||||||
|
return x.interface.isExposedConditionally()
|
||||||
elif key == 'isIteratorInterface':
|
elif key == 'isIteratorInterface':
|
||||||
getter = lambda x: x.interface.isIteratorInterface()
|
def getter(x):
|
||||||
|
return x.interface.isIteratorInterface()
|
||||||
else:
|
else:
|
||||||
getter = lambda x: getattr(x, key)
|
def getter(x):
|
||||||
|
return getattr(x, key)
|
||||||
curr = filter(lambda x: getter(x) == val, curr)
|
curr = filter(lambda x: getter(x) == val, curr)
|
||||||
return curr
|
return curr
|
||||||
|
|
||||||
|
@ -125,8 +136,8 @@ class Configuration:
|
||||||
|
|
||||||
# We should have exactly one result.
|
# We should have exactly one result.
|
||||||
if len(descriptors) != 1:
|
if len(descriptors) != 1:
|
||||||
raise NoSuchDescriptorError("For " + interfaceName + " found " +
|
raise NoSuchDescriptorError("For " + interfaceName + " found "
|
||||||
str(len(descriptors)) + " matches")
|
+ str(len(descriptors)) + " matches")
|
||||||
return descriptors[0]
|
return descriptors[0]
|
||||||
|
|
||||||
def getDescriptorProvider(self):
|
def getDescriptorProvider(self):
|
||||||
|
@ -157,10 +168,10 @@ class DescriptorProvider:
|
||||||
|
|
||||||
|
|
||||||
def MemberIsUnforgeable(member, descriptor):
|
def MemberIsUnforgeable(member, descriptor):
|
||||||
return ((member.isAttr() or member.isMethod()) and
|
return ((member.isAttr() or member.isMethod())
|
||||||
not member.isStatic() and
|
and not member.isStatic()
|
||||||
(member.isUnforgeable() or
|
and (member.isUnforgeable()
|
||||||
bool(descriptor.interface.getExtendedAttribute("Unforgeable"))))
|
or bool(descriptor.interface.getExtendedAttribute("Unforgeable"))))
|
||||||
|
|
||||||
|
|
||||||
class Descriptor(DescriptorProvider):
|
class Descriptor(DescriptorProvider):
|
||||||
|
@ -228,14 +239,14 @@ class Descriptor(DescriptorProvider):
|
||||||
|
|
||||||
# If we're concrete, we need to crawl our ancestor interfaces and mark
|
# If we're concrete, we need to crawl our ancestor interfaces and mark
|
||||||
# them as having a concrete descendant.
|
# them as having a concrete descendant.
|
||||||
self.concrete = (not self.interface.isCallback() and
|
self.concrete = (not self.interface.isCallback()
|
||||||
not self.interface.isNamespace() and
|
and not self.interface.isNamespace()
|
||||||
not self.interface.getExtendedAttribute("Abstract") and
|
and not self.interface.getExtendedAttribute("Abstract")
|
||||||
not self.interface.getExtendedAttribute("Inline") and
|
and not self.interface.getExtendedAttribute("Inline")
|
||||||
not spiderMonkeyInterface)
|
and not spiderMonkeyInterface)
|
||||||
self.hasUnforgeableMembers = (self.concrete and
|
self.hasUnforgeableMembers = (self.concrete
|
||||||
any(MemberIsUnforgeable(m, self) for m in
|
and any(MemberIsUnforgeable(m, self) for m in
|
||||||
self.interface.members))
|
self.interface.members))
|
||||||
|
|
||||||
self.operations = {
|
self.operations = {
|
||||||
'IndexedGetter': None,
|
'IndexedGetter': None,
|
||||||
|
@ -391,8 +402,8 @@ class Descriptor(DescriptorProvider):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def hasDescendants(self):
|
def hasDescendants(self):
|
||||||
return (self.interface.getUserData("hasConcreteDescendant", False) or
|
return (self.interface.getUserData("hasConcreteDescendant", False)
|
||||||
self.interface.getUserData("hasProxyDescendant", False))
|
or self.interface.getUserData("hasProxyDescendant", False))
|
||||||
|
|
||||||
def hasHTMLConstructor(self):
|
def hasHTMLConstructor(self):
|
||||||
ctor = self.interface.ctor()
|
ctor = self.interface.ctor()
|
||||||
|
@ -402,8 +413,8 @@ class Descriptor(DescriptorProvider):
|
||||||
assert self.interface.hasInterfaceObject()
|
assert self.interface.hasInterfaceObject()
|
||||||
if self.interface.getExtendedAttribute("Inline"):
|
if self.interface.getExtendedAttribute("Inline"):
|
||||||
return False
|
return False
|
||||||
return (self.interface.isCallback() or self.interface.isNamespace() or
|
return (self.interface.isCallback() or self.interface.isNamespace()
|
||||||
self.hasDescendants() or self.hasHTMLConstructor())
|
or self.hasDescendants() or self.hasHTMLConstructor())
|
||||||
|
|
||||||
def shouldCacheConstructor(self):
|
def shouldCacheConstructor(self):
|
||||||
return self.hasDescendants() or self.hasHTMLConstructor()
|
return self.hasDescendants() or self.hasHTMLConstructor()
|
||||||
|
@ -416,8 +427,8 @@ class Descriptor(DescriptorProvider):
|
||||||
Returns true if this is the primary interface for a global object
|
Returns true if this is the primary interface for a global object
|
||||||
of some sort.
|
of some sort.
|
||||||
"""
|
"""
|
||||||
return bool(self.interface.getExtendedAttribute("Global") or
|
return bool(self.interface.getExtendedAttribute("Global")
|
||||||
self.interface.getExtendedAttribute("PrimaryGlobal"))
|
or self.interface.getExtendedAttribute("PrimaryGlobal"))
|
||||||
|
|
||||||
|
|
||||||
# Some utility methods
|
# Some utility methods
|
||||||
|
@ -428,8 +439,8 @@ def MakeNativeName(name):
|
||||||
|
|
||||||
|
|
||||||
def getModuleFromObject(object):
|
def getModuleFromObject(object):
|
||||||
return ('crate::dom::bindings::codegen::Bindings::' +
|
return ('crate::dom::bindings::codegen::Bindings::'
|
||||||
os.path.basename(object.location.filename()).split('.webidl')[0] + 'Binding')
|
+ os.path.basename(object.location.filename()).split('.webidl')[0] + 'Binding')
|
||||||
|
|
||||||
|
|
||||||
def getTypesFromDescriptor(descriptor):
|
def getTypesFromDescriptor(descriptor):
|
||||||
|
|
|
@ -198,11 +198,11 @@ class Longhand(object):
|
||||||
self.gecko_pref = gecko_pref
|
self.gecko_pref = gecko_pref
|
||||||
self.has_effect_on_gecko_scrollbars = has_effect_on_gecko_scrollbars
|
self.has_effect_on_gecko_scrollbars = has_effect_on_gecko_scrollbars
|
||||||
assert (
|
assert (
|
||||||
has_effect_on_gecko_scrollbars in [None, False, True] and
|
has_effect_on_gecko_scrollbars in [None, False, True]
|
||||||
not style_struct.inherited or
|
and not style_struct.inherited
|
||||||
(gecko_pref is None) == (has_effect_on_gecko_scrollbars is None)), (
|
or (gecko_pref is None) == (has_effect_on_gecko_scrollbars is None)), (
|
||||||
"Property " + name + ": has_effect_on_gecko_scrollbars must be " +
|
"Property " + name + ": has_effect_on_gecko_scrollbars must be "
|
||||||
"specified, and must have a value of True or False, iff a " +
|
"specified, and must have a value of True or False, iff a "
|
||||||
"property is inherited and is behind a Gecko pref")
|
"property is inherited and is behind a Gecko pref")
|
||||||
# For enabled_in, the setup is as follows:
|
# For enabled_in, the setup is as follows:
|
||||||
# It needs to be one of the four values: ["", "ua", "chrome", "content"]
|
# It needs to be one of the four values: ["", "ua", "chrome", "content"]
|
||||||
|
|
|
@ -14,7 +14,7 @@ import re
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
symbol_regex = re.compile(b"D \*UND\*\t(.*) (.*)$")
|
symbol_regex = re.compile(br"D \*UND\*\t(.*) (.*)$")
|
||||||
allowed_symbols = frozenset([
|
allowed_symbols = frozenset([
|
||||||
b'unshare',
|
b'unshare',
|
||||||
b'malloc_usable_size',
|
b'malloc_usable_size',
|
||||||
|
|
|
@ -31,44 +31,44 @@ def create_gecko_session():
|
||||||
|
|
||||||
|
|
||||||
def generate_placeholder(testcase):
|
def generate_placeholder(testcase):
|
||||||
# We need to still include the failed tests, otherwise Treeherder will
|
# We need to still include the failed tests, otherwise Treeherder will
|
||||||
# consider the result to be a new test series, and thus a new graph. So we
|
# consider the result to be a new test series, and thus a new graph. So we
|
||||||
# use a placeholder with values = -1 to make Treeherder happy, and still be
|
# use a placeholder with values = -1 to make Treeherder happy, and still be
|
||||||
# able to identify failed tests (successful tests have time >=0).
|
# able to identify failed tests (successful tests have time >=0).
|
||||||
|
|
||||||
timings = {
|
timings = {
|
||||||
"testcase": testcase,
|
"testcase": testcase,
|
||||||
"title": ""
|
"title": ""
|
||||||
}
|
}
|
||||||
|
|
||||||
timing_names = [
|
timing_names = [
|
||||||
"navigationStart",
|
"navigationStart",
|
||||||
"unloadEventStart",
|
"unloadEventStart",
|
||||||
"domLoading",
|
"domLoading",
|
||||||
"fetchStart",
|
"fetchStart",
|
||||||
"responseStart",
|
"responseStart",
|
||||||
"loadEventEnd",
|
"loadEventEnd",
|
||||||
"connectStart",
|
"connectStart",
|
||||||
"domainLookupStart",
|
"domainLookupStart",
|
||||||
"redirectStart",
|
"redirectStart",
|
||||||
"domContentLoadedEventEnd",
|
"domContentLoadedEventEnd",
|
||||||
"requestStart",
|
"requestStart",
|
||||||
"secureConnectionStart",
|
"secureConnectionStart",
|
||||||
"connectEnd",
|
"connectEnd",
|
||||||
"loadEventStart",
|
"loadEventStart",
|
||||||
"domInteractive",
|
"domInteractive",
|
||||||
"domContentLoadedEventStart",
|
"domContentLoadedEventStart",
|
||||||
"redirectEnd",
|
"redirectEnd",
|
||||||
"domainLookupEnd",
|
"domainLookupEnd",
|
||||||
"unloadEventEnd",
|
"unloadEventEnd",
|
||||||
"responseEnd",
|
"responseEnd",
|
||||||
"domComplete",
|
"domComplete",
|
||||||
]
|
]
|
||||||
|
|
||||||
for name in timing_names:
|
for name in timing_names:
|
||||||
timings[name] = 0 if name == "navigationStart" else -1
|
timings[name] = 0 if name == "navigationStart" else -1
|
||||||
|
|
||||||
return [timings]
|
return [timings]
|
||||||
|
|
||||||
|
|
||||||
def run_gecko_test(testcase, url, date, timeout, is_async):
|
def run_gecko_test(testcase, url, date, timeout, is_async):
|
||||||
|
@ -91,7 +91,7 @@ def run_gecko_test(testcase, url, date, timeout, is_async):
|
||||||
"return JSON.stringify(performance.timing)"
|
"return JSON.stringify(performance.timing)"
|
||||||
)
|
)
|
||||||
))
|
))
|
||||||
except:
|
except Exception:
|
||||||
# We need to return a timing object no matter what happened.
|
# We need to return a timing object no matter what happened.
|
||||||
# See the comment in generate_placeholder() for explanation
|
# See the comment in generate_placeholder() for explanation
|
||||||
print("Failed to get a valid timing measurement.")
|
print("Failed to get a valid timing measurement.")
|
||||||
|
|
|
@ -116,7 +116,7 @@ def parse_log(log, testcase, url, date):
|
||||||
for line in block:
|
for line in block:
|
||||||
try:
|
try:
|
||||||
(_, key, value) = line.split(",")
|
(_, key, value) = line.split(",")
|
||||||
except:
|
except ValueError:
|
||||||
print("[DEBUG] failed to parse the following line:")
|
print("[DEBUG] failed to parse the following line:")
|
||||||
print(line)
|
print(line)
|
||||||
print('[DEBUG] log:')
|
print('[DEBUG] log:')
|
||||||
|
@ -133,10 +133,10 @@ def parse_log(log, testcase, url, date):
|
||||||
return timing
|
return timing
|
||||||
|
|
||||||
def valid_timing(timing, url=None):
|
def valid_timing(timing, url=None):
|
||||||
if (timing is None or
|
if (timing is None
|
||||||
testcase is None or
|
or testcase is None
|
||||||
timing.get('title') == 'Error loading page' or
|
or timing.get('title') == 'Error loading page'
|
||||||
timing.get('testcase') != url):
|
or timing.get('testcase') != url):
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -19,8 +19,8 @@ from runner import format_result_summary
|
||||||
|
|
||||||
|
|
||||||
def geometric_mean(iterable):
|
def geometric_mean(iterable):
|
||||||
filtered = list(filter(lambda x: x > 0, iterable))
|
filtered = list(filter(lambda x: x > 0, iterable))
|
||||||
return (reduce(operator.mul, filtered)) ** (1.0 / len(filtered))
|
return (reduce(operator.mul, filtered)) ** (1.0 / len(filtered))
|
||||||
|
|
||||||
|
|
||||||
def format_testcase_name(name):
|
def format_testcase_name(name):
|
||||||
|
|
|
@ -29,6 +29,7 @@ def load_data(filename):
|
||||||
results[key] = round(totals[key] / counts[key])
|
results[key] = round(totals[key] / counts[key])
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
data1 = load_data(args.file1)
|
data1 = load_data(args.file1)
|
||||||
data2 = load_data(args.file2)
|
data2 = load_data(args.file2)
|
||||||
keys = set(data1.keys()).union(data2.keys())
|
keys = set(data1.keys()).union(data2.keys())
|
||||||
|
|
|
@ -14,8 +14,8 @@ def test_format_testcase_name():
|
||||||
'http://localhost:8000/page_load_test/163.com/p.mail.163.com/'
|
'http://localhost:8000/page_load_test/163.com/p.mail.163.com/'
|
||||||
'mailinfo/shownewmsg_www_1222.htm.html')))
|
'mailinfo/shownewmsg_www_1222.htm.html')))
|
||||||
assert(('1234567890223456789032345678904234567890'
|
assert(('1234567890223456789032345678904234567890'
|
||||||
'5234567890623456789072345678908234567890') ==
|
'5234567890623456789072345678908234567890')
|
||||||
submit_to_perfherder.format_testcase_name((
|
== submit_to_perfherder.format_testcase_name((
|
||||||
'1234567890223456789032345678904234567890'
|
'1234567890223456789032345678904234567890'
|
||||||
'52345678906234567890723456789082345678909234567890')))
|
'52345678906234567890723456789082345678909234567890')))
|
||||||
assert('news.ycombinator.com' == submit_to_perfherder.format_testcase_name(
|
assert('news.ycombinator.com' == submit_to_perfherder.format_testcase_name(
|
||||||
|
|
|
@ -10,15 +10,14 @@
|
||||||
"""
|
"""
|
||||||
Created on Mon Mar 26 20:08:25 2018
|
Created on Mon Mar 26 20:08:25 2018
|
||||||
@author: Pranshu Sinha, Abhay Soni, Aayushi Agrawal
|
@author: Pranshu Sinha, Abhay Soni, Aayushi Agrawal
|
||||||
"""
|
|
||||||
|
|
||||||
"""
|
|
||||||
The below program is intended to test rendering mismatches in servo by taking screenshots of rendered html files.
|
The below program is intended to test rendering mismatches in servo by taking screenshots of rendered html files.
|
||||||
Here is the breakdown of how our code works:
|
Here is the breakdown of how our code works:
|
||||||
* A session is started on localhost:7002
|
* A session is started on localhost:7002
|
||||||
* The randomly generated webpage's (html files) data is sent as JSON to this session
|
* The randomly generated webpage's (html files) data is sent as JSON to this session
|
||||||
* Using curl request, we load the html files for this session ID based on the session we just created.
|
* Using curl request, we load the html files for this session ID based on the session we just created.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
import requests
|
import requests
|
||||||
|
@ -72,7 +71,7 @@ def render_html_files(num_of_files, url, file_url, json_string, headers, cwd):
|
||||||
image_file.write(base64.decodebytes(image_data_encoded.encode('utf-8')))
|
image_file.write(base64.decodebytes(image_data_encoded.encode('utf-8')))
|
||||||
print("################################")
|
print("################################")
|
||||||
print("The screenshot is stored in the location: {0}/screenshots/"
|
print("The screenshot is stored in the location: {0}/screenshots/"
|
||||||
+ " with filename: output_image_{1}.png".format(cwd, str(x)))
|
" with filename: output_image_{1}.png".format(cwd, str(x)))
|
||||||
print("################################")
|
print("################################")
|
||||||
|
|
||||||
|
|
||||||
|
@ -124,6 +123,7 @@ def main(argv): # take inputs from command line by considering the options para
|
||||||
# Render each HTML file and take a screenshot
|
# Render each HTML file and take a screenshot
|
||||||
render_html_files(num_of_files, url, file_url, json_string, headers, cwd)
|
render_html_files(num_of_files, url, file_url, json_string, headers, cwd)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if len(sys.argv) < 8:
|
if len(sys.argv) < 8:
|
||||||
print_help()
|
print_help()
|
||||||
|
|
|
@ -128,6 +128,7 @@ class TestPrinter:
|
||||||
def to_string(self):
|
def to_string(self):
|
||||||
return "[UNKNOWN - type = {0}]".format(str(self.val.type))
|
return "[UNKNOWN - type = {0}]".format(str(self.val.type))
|
||||||
|
|
||||||
|
|
||||||
type_map = [
|
type_map = [
|
||||||
('struct Au', AuPrinter),
|
('struct Au', AuPrinter),
|
||||||
('FlowFlags', BitFieldU8Printer),
|
('FlowFlags', BitFieldU8Printer),
|
||||||
|
|
|
@ -13,15 +13,14 @@
|
||||||
python3 -m coverage run $0
|
python3 -m coverage run $0
|
||||||
python3 -m coverage report -m --fail-under 100
|
python3 -m coverage report -m --fail-under 100
|
||||||
exit
|
exit
|
||||||
'''
|
|
||||||
|
|
||||||
"""
|
|
||||||
Run the decision task with fake Taskcluster APIs, to catch Python errors before pushing.
|
Run the decision task with fake Taskcluster APIs, to catch Python errors before pushing.
|
||||||
"""
|
'''
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from unittest.mock import MagicMock
|
from unittest.mock import MagicMock
|
||||||
|
import decision_task
|
||||||
|
|
||||||
|
|
||||||
class TaskclusterRestFailure(Exception):
|
class TaskclusterRestFailure(Exception):
|
||||||
|
@ -47,7 +46,7 @@ os.environ["GIT_REF"] = "refs/heads/auto"
|
||||||
os.environ["TASKCLUSTER_ROOT_URL"] = "https://community-tc.services.mozilla.com"
|
os.environ["TASKCLUSTER_ROOT_URL"] = "https://community-tc.services.mozilla.com"
|
||||||
os.environ["TASKCLUSTER_PROXY_URL"] = "http://taskcluster"
|
os.environ["TASKCLUSTER_PROXY_URL"] = "http://taskcluster"
|
||||||
os.environ["NEW_AMI_WORKER_TYPE"] = "-"
|
os.environ["NEW_AMI_WORKER_TYPE"] = "-"
|
||||||
import decision_task
|
|
||||||
decision_task.decisionlib.subprocess = MagicMock()
|
decision_task.decisionlib.subprocess = MagicMock()
|
||||||
|
|
||||||
print("\n# Push:")
|
print("\n# Push:")
|
||||||
|
|
|
@ -34,13 +34,13 @@ with open(sys.argv[1]) as f:
|
||||||
if "action" in entry and entry["action"] == "test_end":
|
if "action" in entry and entry["action"] == "test_end":
|
||||||
thread = None
|
thread = None
|
||||||
else:
|
else:
|
||||||
if ("action" in entry and
|
if ("action" in entry
|
||||||
entry["action"] == "test_start" and
|
and entry["action"] == "test_start"
|
||||||
entry["test"] == sys.argv[2]):
|
and entry["test"] == sys.argv[2]):
|
||||||
thread = entry["thread"]
|
thread = entry["thread"]
|
||||||
print(json.dumps(entry))
|
print(json.dumps(entry))
|
||||||
elif (full_search and
|
elif (full_search
|
||||||
"command" in entry and
|
and "command" in entry
|
||||||
sys.argv[2] in entry["command"]):
|
and sys.argv[2] in entry["command"]):
|
||||||
thread = entry["thread"]
|
thread = entry["thread"]
|
||||||
print(json.dumps(entry))
|
print(json.dumps(entry))
|
||||||
|
|
|
@ -51,6 +51,7 @@ def process_log(data):
|
||||||
|
|
||||||
return test_results
|
return test_results
|
||||||
|
|
||||||
|
|
||||||
test_results = {
|
test_results = {
|
||||||
"SKIP": [],
|
"SKIP": [],
|
||||||
"OK": [],
|
"OK": [],
|
||||||
|
|
|
@ -155,7 +155,6 @@ def wptserve_path(is_firefox, topdir, *paths):
|
||||||
|
|
||||||
def _activate_virtualenv(topdir, is_firefox):
|
def _activate_virtualenv(topdir, is_firefox):
|
||||||
virtualenv_path = os.path.join(topdir, "python", "_virtualenv%d.%d" % (sys.version_info[0], sys.version_info[1]))
|
virtualenv_path = os.path.join(topdir, "python", "_virtualenv%d.%d" % (sys.version_info[0], sys.version_info[1]))
|
||||||
check_exec_path = lambda path: path.startswith(virtualenv_path)
|
|
||||||
python = sys.executable # If there was no python, mach wouldn't have run at all!
|
python = sys.executable # If there was no python, mach wouldn't have run at all!
|
||||||
if not python:
|
if not python:
|
||||||
sys.exit('Failed to find python executable for starting virtualenv.')
|
sys.exit('Failed to find python executable for starting virtualenv.')
|
||||||
|
@ -177,7 +176,8 @@ def _activate_virtualenv(topdir, is_firefox):
|
||||||
|
|
||||||
exec(compile(open(activate_path).read(), activate_path, 'exec'), dict(__file__=activate_path))
|
exec(compile(open(activate_path).read(), activate_path, 'exec'), dict(__file__=activate_path))
|
||||||
|
|
||||||
python = _get_exec_path(PYTHON_NAMES, is_valid_path=check_exec_path)
|
python = _get_exec_path(PYTHON_NAMES,
|
||||||
|
is_valid_path=lambda path: path.startswith(virtualenv_path))
|
||||||
if not python:
|
if not python:
|
||||||
sys.exit("Python executable in virtualenv failed to activate.")
|
sys.exit("Python executable in virtualenv failed to activate.")
|
||||||
|
|
||||||
|
|
|
@ -244,7 +244,7 @@ class MachCommands(CommandBase):
|
||||||
|
|
||||||
with open(path.join(preload_path, preload_filename), 'w') as fd:
|
with open(path.join(preload_path, preload_filename), 'w') as fd:
|
||||||
json.dump(entries, fd, indent=4)
|
json.dump(entries, fd, indent=4)
|
||||||
except ValueError as e:
|
except ValueError:
|
||||||
print("Unable to parse chromium HSTS preload list, has the format changed?")
|
print("Unable to parse chromium HSTS preload list, has the format changed?")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
@ -262,8 +262,8 @@ class MachCommands(CommandBase):
|
||||||
print("Unable to download the public suffix list; are you connected to the internet?")
|
print("Unable to download the public suffix list; are you connected to the internet?")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
lines = [l.strip() for l in content.decode("utf8").split("\n")]
|
lines = [line.strip() for line in content.decode("utf8").split("\n")]
|
||||||
suffixes = [l for l in lines if not l.startswith("//") and not l == ""]
|
suffixes = [line for line in lines if not line.startswith("//") and not line == ""]
|
||||||
|
|
||||||
with open(dst_filename, "wb") as fo:
|
with open(dst_filename, "wb") as fo:
|
||||||
for suffix in suffixes:
|
for suffix in suffixes:
|
||||||
|
@ -475,7 +475,7 @@ class MachCommands(CommandBase):
|
||||||
if os.path.exists(crate_path):
|
if os.path.exists(crate_path):
|
||||||
try:
|
try:
|
||||||
delete(crate_path)
|
delete(crate_path)
|
||||||
except:
|
except (FileNotFoundError, PermissionError):
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
print("Delete %s failed!" % crate_path)
|
print("Delete %s failed!" % crate_path)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -93,8 +93,8 @@ class MachCommands(CommandBase):
|
||||||
help='Updates the selected package')
|
help='Updates the selected package')
|
||||||
@CommandArgument(
|
@CommandArgument(
|
||||||
'--all-packages', '-a', action='store_true',
|
'--all-packages', '-a', action='store_true',
|
||||||
help='Updates all packages. NOTE! This is very likely to break your ' +
|
help='Updates all packages. NOTE! This is very likely to break your '
|
||||||
'working copy, making it impossible to build servo. Only do ' +
|
'working copy, making it impossible to build servo. Only do '
|
||||||
'this if you really know what you are doing.')
|
'this if you really know what you are doing.')
|
||||||
@CommandArgument(
|
@CommandArgument(
|
||||||
'--dry-run', '-d', action='store_true',
|
'--dry-run', '-d', action='store_true',
|
||||||
|
|
|
@ -138,8 +138,8 @@ class DuplicateLine(Strategy):
|
||||||
plus_equals_statement = r".+?\s\+\=\s.*"
|
plus_equals_statement = r".+?\s\+\=\s.*"
|
||||||
minus_equals_statement = r".+?\s\-\=\s.*"
|
minus_equals_statement = r".+?\s\-\=\s.*"
|
||||||
self._replace_strategy = {
|
self._replace_strategy = {
|
||||||
'regex': (append_statement + '|' + remove_statement + '|' + push_statement +
|
'regex': (append_statement + '|' + remove_statement + '|' + push_statement
|
||||||
'|' + pop_statement + '|' + plus_equals_statement + '|' + minus_equals_statement),
|
+ '|' + pop_statement + '|' + plus_equals_statement + '|' + minus_equals_statement),
|
||||||
'replaceString': r"\g<0>\n\g<0>",
|
'replaceString': r"\g<0>\n\g<0>",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,9 +30,6 @@ from mach.decorators import (
|
||||||
Command,
|
Command,
|
||||||
)
|
)
|
||||||
from mach.registrar import Registrar
|
from mach.registrar import Registrar
|
||||||
# Note: mako cannot be imported at the top level because it breaks mach bootstrap
|
|
||||||
sys.path.append(path.join(path.dirname(__file__), "..", "..",
|
|
||||||
"components", "style", "properties", "Mako-1.1.2-py2.py3-none-any.whl"))
|
|
||||||
|
|
||||||
from servo.command_base import (
|
from servo.command_base import (
|
||||||
archive_deterministically,
|
archive_deterministically,
|
||||||
|
@ -44,6 +41,9 @@ from servo.command_base import (
|
||||||
)
|
)
|
||||||
from servo.util import delete
|
from servo.util import delete
|
||||||
|
|
||||||
|
# Note: mako cannot be imported at the top level because it breaks mach bootstrap
|
||||||
|
sys.path.append(path.join(path.dirname(__file__), "..", "..",
|
||||||
|
"components", "style", "properties", "Mako-1.1.2-py2.py3-none-any.whl"))
|
||||||
|
|
||||||
PACKAGES = {
|
PACKAGES = {
|
||||||
'android': [
|
'android': [
|
||||||
|
@ -96,18 +96,18 @@ else:
|
||||||
|
|
||||||
def get_taskcluster_secret(name):
|
def get_taskcluster_secret(name):
|
||||||
url = (
|
url = (
|
||||||
os.environ.get("TASKCLUSTER_PROXY_URL", "http://taskcluster") +
|
os.environ.get("TASKCLUSTER_PROXY_URL", "http://taskcluster")
|
||||||
"/api/secrets/v1/secret/project/servo/" +
|
+ "/api/secrets/v1/secret/project/servo/"
|
||||||
name
|
+ name
|
||||||
)
|
)
|
||||||
return json.load(urllib.request.urlopen(url))["secret"]
|
return json.load(urllib.request.urlopen(url))["secret"]
|
||||||
|
|
||||||
|
|
||||||
def otool(s):
|
def otool(s):
|
||||||
o = subprocess.Popen(['/usr/bin/otool', '-L', s], stdout=subprocess.PIPE)
|
o = subprocess.Popen(['/usr/bin/otool', '-L', s], stdout=subprocess.PIPE)
|
||||||
for l in o.stdout:
|
for line in o.stdout:
|
||||||
if l[0] == '\t':
|
if line[0] == '\t':
|
||||||
yield l.split(' ', 1)[0][1:]
|
yield line.split(' ', 1)[0][1:]
|
||||||
|
|
||||||
|
|
||||||
def listfiles(directory):
|
def listfiles(directory):
|
||||||
|
@ -781,7 +781,7 @@ def setup_uwp_signing(ms_app_store, publisher):
|
||||||
print("Packaging on TC. Using secret certificate")
|
print("Packaging on TC. Using secret certificate")
|
||||||
pfx = get_taskcluster_secret("windows-codesign-cert/latest")["pfx"]
|
pfx = get_taskcluster_secret("windows-codesign-cert/latest")["pfx"]
|
||||||
open("servo.pfx", "wb").write(base64.b64decode(pfx["base64"]))
|
open("servo.pfx", "wb").write(base64.b64decode(pfx["base64"]))
|
||||||
run_powershell_cmd('Import-PfxCertificate -FilePath .\servo.pfx -CertStoreLocation Cert:\CurrentUser\My')
|
run_powershell_cmd('Import-PfxCertificate -FilePath .\\servo.pfx -CertStoreLocation Cert:\\CurrentUser\\My')
|
||||||
os.remove("servo.pfx")
|
os.remove("servo.pfx")
|
||||||
|
|
||||||
# Powershell command that lists all certificates for publisher
|
# Powershell command that lists all certificates for publisher
|
||||||
|
@ -796,7 +796,7 @@ def setup_uwp_signing(ms_app_store, publisher):
|
||||||
# PowerShell command that creates and install signing certificate for publisher
|
# PowerShell command that creates and install signing certificate for publisher
|
||||||
cmd = '(New-SelfSignedCertificate -Type Custom -Subject ' + publisher + \
|
cmd = '(New-SelfSignedCertificate -Type Custom -Subject ' + publisher + \
|
||||||
' -FriendlyName "Allizom Signing Certificate (temporary)"' + \
|
' -FriendlyName "Allizom Signing Certificate (temporary)"' + \
|
||||||
' -KeyUsage DigitalSignature -CertStoreLocation "Cert:\CurrentUser\My"' + \
|
' -KeyUsage DigitalSignature -CertStoreLocation "Cert:\\CurrentUser\\My"' + \
|
||||||
' -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.3", "2.5.29.19={text}")).Thumbprint'
|
' -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.3", "2.5.29.19={text}")).Thumbprint'
|
||||||
thumbprint = run_powershell_cmd(cmd)
|
thumbprint = run_powershell_cmd(cmd)
|
||||||
elif len(certs) > 1:
|
elif len(certs) > 1:
|
||||||
|
|
|
@ -161,8 +161,8 @@ class PostBuildCommands(CommandBase):
|
||||||
command = rustCommand
|
command = rustCommand
|
||||||
|
|
||||||
# Prepend the debugger args.
|
# Prepend the debugger args.
|
||||||
args = ([command] + self.debuggerInfo.args +
|
args = ([command] + self.debuggerInfo.args
|
||||||
args + params)
|
+ args + params)
|
||||||
else:
|
else:
|
||||||
args = args + params
|
args = args + params
|
||||||
|
|
||||||
|
@ -208,8 +208,8 @@ class PostBuildCommands(CommandBase):
|
||||||
env = self.build_env()
|
env = self.build_env()
|
||||||
env["RUST_BACKTRACE"] = "1"
|
env["RUST_BACKTRACE"] = "1"
|
||||||
|
|
||||||
servo_cmd = [bin or self.get_nightly_binary_path(nightly) or
|
servo_cmd = [bin or self.get_nightly_binary_path(nightly)
|
||||||
self.get_binary_path(release, dev)] + params
|
or self.get_binary_path(release, dev)] + params
|
||||||
rr_cmd = ['rr', '--fatal-errors', 'record']
|
rr_cmd = ['rr', '--fatal-errors', 'record']
|
||||||
try:
|
try:
|
||||||
check_call(rr_cmd + servo_cmd)
|
check_call(rr_cmd + servo_cmd)
|
||||||
|
|
|
@ -117,8 +117,8 @@ class MachCommands(CommandBase):
|
||||||
help="Optionally select test based on "
|
help="Optionally select test based on "
|
||||||
"test file directory")
|
"test file directory")
|
||||||
@CommandArgument('--render-mode', '-rm', default=DEFAULT_RENDER_MODE,
|
@CommandArgument('--render-mode', '-rm', default=DEFAULT_RENDER_MODE,
|
||||||
help="The render mode to be used on all tests. " +
|
help="The render mode to be used on all tests. "
|
||||||
HELP_RENDER_MODE)
|
+ HELP_RENDER_MODE)
|
||||||
@CommandArgument('--release', default=False, action="store_true",
|
@CommandArgument('--release', default=False, action="store_true",
|
||||||
help="Run with a release build of servo")
|
help="Run with a release build of servo")
|
||||||
@CommandArgument('--tidy-all', default=False, action="store_true",
|
@CommandArgument('--tidy-all', default=False, action="store_true",
|
||||||
|
|
|
@ -65,15 +65,15 @@ if __name__ == '__main__':
|
||||||
while not server.got_post:
|
while not server.got_post:
|
||||||
server.handle_request()
|
server.handle_request()
|
||||||
data = json.loads(server.post_data[0])
|
data = json.loads(server.post_data[0])
|
||||||
n = 0
|
number = 0
|
||||||
l = 0
|
length = 0
|
||||||
for test in data:
|
for test in data:
|
||||||
n = max(n, len(data[test]))
|
number = max(number, len(data[test]))
|
||||||
l = max(l, len(test))
|
length = max(length, len(test))
|
||||||
print("\n Test{0} | Time".format(" " * (l - len("Test"))))
|
print("\n Test{0} | Time".format(" " * (length - len("Test"))))
|
||||||
print("-{0}-|-{1}-".format("-" * l, "-" * n))
|
print("-{0}-|-{1}-".format("-" * length, "-" * number))
|
||||||
for test in data:
|
for test in data:
|
||||||
print(" {0}{1} | {2}".format(test, " " * (l - len(test)), data[test]))
|
print(" {0}{1} | {2}".format(test, " " * (length - len(test)), data[test]))
|
||||||
proc.kill()
|
proc.kill()
|
||||||
else:
|
else:
|
||||||
print_usage()
|
print_usage()
|
||||||
|
|
|
@ -183,7 +183,7 @@ def run_http_server():
|
||||||
self.send_header("Last-Modified", self.date_time_string(fs.st_mtime))
|
self.send_header("Last-Modified", self.date_time_string(fs.st_mtime))
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
return f
|
return f
|
||||||
except:
|
except IOError:
|
||||||
f.close()
|
f.close()
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
@ -195,6 +195,7 @@ def run_http_server():
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
server.handle_request()
|
server.handle_request()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if len(sys.argv) == 4:
|
if len(sys.argv) == 4:
|
||||||
cmd = sys.argv[1]
|
cmd = sys.argv[1]
|
||||||
|
|
|
@ -134,10 +134,10 @@ def PowerParser(OutputDir, LayoutThreads):
|
||||||
|
|
||||||
TotalPower = PowerGen / float(ExperimentNum - 1)
|
TotalPower = PowerGen / float(ExperimentNum - 1)
|
||||||
TotalTime = TimeGen / float(ExperimentNum - 1)
|
TotalTime = TimeGen / float(ExperimentNum - 1)
|
||||||
ResultFile.write(str(layoutT) + " , " + str(TotalPower) + " , " +
|
ResultFile.write(str(layoutT) + " , " + str(TotalPower) + " , "
|
||||||
str(MaxPower) + " , " + str(MinPower) + " , " +
|
+ str(MaxPower) + " , " + str(MinPower) + " , "
|
||||||
str(TotalTime) + " , " + str(MaxTime) + " , " +
|
+ str(TotalTime) + " , " + str(MaxTime) + " , "
|
||||||
str(MinTime) + "\n")
|
+ str(MinTime) + "\n")
|
||||||
ResultFile.close()
|
ResultFile.close()
|
||||||
Opener = ResultFile = open(ResultTable, "r")
|
Opener = ResultFile = open(ResultTable, "r")
|
||||||
for line in Opener:
|
for line in Opener:
|
||||||
|
@ -180,5 +180,6 @@ def main():
|
||||||
PowerCollector(OutputDir, Benchmarks, LayoutThreads, Renderer)
|
PowerCollector(OutputDir, Benchmarks, LayoutThreads, Renderer)
|
||||||
PowerParser(OutputDir, LayoutThreads)
|
PowerParser(OutputDir, LayoutThreads)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -75,8 +75,8 @@ class ServoFormatter(base.BaseFormatter):
|
||||||
def text_to_erase_display(self):
|
def text_to_erase_display(self):
|
||||||
if not self.interactive or not self.current_display:
|
if not self.interactive or not self.current_display:
|
||||||
return ""
|
return ""
|
||||||
return ((self.move_up + self.clear_eol) *
|
return ((self.move_up + self.clear_eol)
|
||||||
self.current_display.count('\n'))
|
* self.current_display.count('\n'))
|
||||||
|
|
||||||
def generate_output(self, text=None, new_display=None, unexpected_in_test=None):
|
def generate_output(self, text=None, new_display=None, unexpected_in_test=None):
|
||||||
if not self.interactive:
|
if not self.interactive:
|
||||||
|
|
|
@ -19,6 +19,7 @@ def wpt_path(*args):
|
||||||
def servo_path(*args):
|
def servo_path(*args):
|
||||||
return os.path.join(servo_root, *args)
|
return os.path.join(servo_root, *args)
|
||||||
|
|
||||||
|
|
||||||
paths = {"include_manifest": wpt_path("include.ini"),
|
paths = {"include_manifest": wpt_path("include.ini"),
|
||||||
"config": wpt_path("config.ini"),
|
"config": wpt_path("config.ini"),
|
||||||
"ca-cert-path": wpt_path("web-platform-tests/tools/certs/cacert.pem"),
|
"ca-cert-path": wpt_path("web-platform-tests/tools/certs/cacert.pem"),
|
||||||
|
@ -26,8 +27,8 @@ paths = {"include_manifest": wpt_path("include.ini"),
|
||||||
"host-cert-path": wpt_path("web-platform-tests/tools/certs/web-platform.test.pem")}
|
"host-cert-path": wpt_path("web-platform-tests/tools/certs/web-platform.test.pem")}
|
||||||
# Imports
|
# Imports
|
||||||
sys.path.append(wpt_path("web-platform-tests", "tools"))
|
sys.path.append(wpt_path("web-platform-tests", "tools"))
|
||||||
import localpaths # noqa: flake8
|
import localpaths # noqa: F401,E402
|
||||||
from wptrunner import wptrunner, wptcommandline
|
from wptrunner import wptrunner, wptcommandline # noqa: E402
|
||||||
|
|
||||||
|
|
||||||
def run_tests(**kwargs):
|
def run_tests(**kwargs):
|
||||||
|
@ -106,5 +107,6 @@ def main():
|
||||||
kwargs = vars(parser.parse_args())
|
kwargs = vars(parser.parse_args())
|
||||||
return run_tests(**kwargs)
|
return run_tests(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
sys.exit(0 if main() else 1)
|
sys.exit(0 if main() else 1)
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from wptrunner import wptcommandline
|
from wptrunner import wptcommandline
|
||||||
|
from update import updatecommandline
|
||||||
|
|
||||||
here = os.path.split(__file__)[0]
|
here = os.path.split(__file__)[0]
|
||||||
|
|
||||||
|
@ -12,9 +13,6 @@ here = os.path.split(__file__)[0]
|
||||||
def wpt_path(*args):
|
def wpt_path(*args):
|
||||||
return os.path.join(here, *args)
|
return os.path.join(here, *args)
|
||||||
|
|
||||||
# Imports
|
|
||||||
from update import updatecommandline
|
|
||||||
|
|
||||||
|
|
||||||
def update_tests(**kwargs):
|
def update_tests(**kwargs):
|
||||||
import update
|
import update
|
||||||
|
@ -45,5 +43,6 @@ def main():
|
||||||
kwargs = vars(parser.parse_args())
|
kwargs = vars(parser.parse_args())
|
||||||
return update_tests(**kwargs)
|
return update_tests(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
sys.exit(0 if main() else 1)
|
sys.exit(0 if main() else 1)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue