Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync WebIDL.py with gecko #23748

Merged
merged 2 commits into from Jul 12, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Some generated files are not rendered by default. Learn more.

@@ -17,6 +17,7 @@
from WebIDL import (
BuiltinTypes,
IDLBuiltinType,
IDLDefaultDictionaryValue,
IDLEmptySequenceValue,
IDLInterfaceMember,
IDLNullableType,
@@ -678,13 +679,16 @@ def handleDefault(nullValue):
return None

if isinstance(defaultValue, IDLNullValue):
assert type.nullable() or type.isDictionary()
assert type.nullable()
return nullValue
elif isinstance(defaultValue, IDLDefaultDictionaryValue):
assert type.isDictionary()
return nullValue
elif isinstance(defaultValue, IDLEmptySequenceValue):
assert type.isSequence()
return "Vec::new()"

raise TypeError("Can't handle non-null or non-empty sequence default value here")
raise TypeError("Can't handle non-null, non-empty sequence or non-empty dictionary default value here")

# A helper function for wrapping up the template body for
# possibly-nullable objecty stuff
@@ -747,17 +751,19 @@ def wrapObjectTemplate(templateBody, nullValue, isDefinitelyObject, type,
for memberType in type.unroll().flatMemberTypes
if memberType.isDictionary()
]
if defaultValue and not isinstance(defaultValue, IDLNullValue):
if (defaultValue and
not isinstance(defaultValue, IDLNullValue) and
not isinstance(defaultValue, IDLDefaultDictionaryValue)):
tag = defaultValue.type.tag()
if tag is IDLType.Tags.bool:
default = "%s::Boolean(%s)" % (
union_native_type(type),
"true" if defaultValue.value else "false")
else:
raise("We don't currently support default values that aren't null or boolean")
raise("We don't currently support default values that aren't null, boolean or default dictionary")
elif dictionaries:
if defaultValue:
assert isinstance(defaultValue, IDLNullValue)
assert isinstance(defaultValue, IDLDefaultDictionaryValue)
dictionary, = dictionaries
default = "%s::%s(%s::%s::empty())" % (
union_native_type(type),
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.