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

Add support for attributes on types in WebIDL #22958

Merged
merged 2 commits into from Mar 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 9 additions & 17 deletions components/script/dom/bindings/codegen/CodegenRust.py
Expand Up @@ -573,9 +573,6 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
isAutoRooted=False,
invalidEnumValueFatal=True,
defaultValue=None,
treatNullAs="Default",
isEnforceRange=False,
isClamp=False,
exceptionCode=None,
allowTreatNonObjectAsNull=False,
isCallbackReturnValue=False,
Expand Down Expand Up @@ -603,12 +600,6 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,

If defaultValue is not None, it's the IDL default value for this conversion

If isEnforceRange is true, we're converting an integer and throwing if the
value is out of range.

If isClamp is true, we're converting an integer and clamping if the
value is out of range.

If allowTreatNonObjectAsNull is true, then [TreatNonObjectAsNull]
extended attributes on nullable callback functions will be honored.

Expand All @@ -631,6 +622,13 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
# We should not have a defaultValue if we know we're an object
assert not isDefinitelyObject or defaultValue is None

isEnforceRange = type.enforceRange
isClamp = type.clamp
if type.treatNullAsEmpty:
treatNullAs = "EmptyString"
else:
treatNullAs = "Default"

# If exceptionCode is not set, we'll just rethrow the exception we got.
# Note that we can't just set failureCode to exceptionCode, because setting
# failureCode will prevent pending exceptions from being set in cases when
Expand Down Expand Up @@ -1301,9 +1299,6 @@ def __init__(self, argument, index, args, argc, descriptorProvider,
descriptorProvider,
invalidEnumValueFatal=invalidEnumValueFatal,
defaultValue=argument.defaultValue,
treatNullAs=argument.treatNullAs,
isEnforceRange=argument.enforceRange,
isClamp=argument.clamp,
isMember="Variadic" if argument.variadic else False,
isAutoRooted=type_needs_auto_root(argument.type),
allowTreatNonObjectAsNull=argument.allowTreatNonCallableAsNull())
Expand Down Expand Up @@ -3508,9 +3503,6 @@ def __init__(self, type, interfaceMember, allowTreatNonObjectAsNull=False):
self.variadic = False
self.defaultValue = None
self._allowTreatNonObjectAsNull = allowTreatNonObjectAsNull
self.treatNullAs = interfaceMember.treatNullAs
self.enforceRange = False
self.clamp = False

def allowTreatNonCallableAsNull(self):
return self._allowTreatNonObjectAsNull
Expand Down Expand Up @@ -4874,7 +4866,7 @@ def __init__(self, descriptor, operation):
# arguments[0] is the index or name of the item that we're setting.
argument = arguments[1]
info = getJSToNativeConversionInfo(
argument.type, descriptor, treatNullAs=argument.treatNullAs,
argument.type, descriptor,
exceptionCode="return false;")
template = info.template
declType = info.declType
Expand Down Expand Up @@ -6886,7 +6878,7 @@ def __init__(self, descriptor):

class FakeMember():
def __init__(self):
self.treatNullAs = "Default"
pass

def isStatic(self):
return False
Expand Down