Auto merge of #26718 - jdm:codegen-sequence, r=Manishearth

Improve precision of sequence types for WebIDL codegen.

Unlike #26699, this doesn't attempt to improve any of the resulting types and only maintains the status quo.

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] There are tests for these changes
This commit is contained in:
bors-servo 2020-05-29 22:10:21 -04:00 committed by GitHub
commit 1a61937031
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -677,7 +677,7 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
if type.isSequence() or type.isRecord(): if type.isSequence() or type.isRecord():
innerInfo = getJSToNativeConversionInfo(innerContainerType(type), innerInfo = getJSToNativeConversionInfo(innerContainerType(type),
descriptorProvider, descriptorProvider,
isMember=isMember, isMember="Sequence",
isAutoRooted=isAutoRooted) isAutoRooted=isAutoRooted)
declType = wrapInNativeContainerType(type, innerInfo.declType) declType = wrapInNativeContainerType(type, innerInfo.declType)
config = getConversionConfigForType(type, isEnforceRange, isClamp, treatNullAs) config = getConversionConfigForType(type, isEnforceRange, isClamp, treatNullAs)
@ -1075,7 +1075,7 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
assert not isEnforceRange and not isClamp assert not isEnforceRange and not isClamp
assert isMember != "Union" assert isMember != "Union"
if isMember == "Dictionary" or isAutoRooted: if isMember in ("Dictionary", "Sequence") or isAutoRooted:
templateBody = "${val}.get()" templateBody = "${val}.get()"
if defaultValue is None: if defaultValue is None:
@ -1087,7 +1087,7 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
else: else:
raise TypeError("Can't handle non-null, non-undefined default value here") raise TypeError("Can't handle non-null, non-undefined default value here")
if isMember == "Dictionary": if not isAutoRooted:
templateBody = "RootedTraceableBox::from_box(Heap::boxed(%s))" % templateBody templateBody = "RootedTraceableBox::from_box(Heap::boxed(%s))" % templateBody
if default is not None: if default is not None:
default = "RootedTraceableBox::from_box(Heap::boxed(%s))" % default default = "RootedTraceableBox::from_box(Heap::boxed(%s))" % default
@ -1117,7 +1117,7 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
templateBody = "${val}.get().to_object()" templateBody = "${val}.get().to_object()"
default = "ptr::null_mut()" default = "ptr::null_mut()"
if isMember in ("Dictionary", "Union"): if isMember in ("Dictionary", "Union", "Sequence") and not isAutoRooted:
templateBody = "RootedTraceableBox::from_box(Heap::boxed(%s))" % templateBody templateBody = "RootedTraceableBox::from_box(Heap::boxed(%s))" % templateBody
default = "RootedTraceableBox::new(Heap::default())" default = "RootedTraceableBox::new(Heap::default())"
declType = CGGeneric("RootedTraceableBox<Heap<*mut JSObject>>") declType = CGGeneric("RootedTraceableBox<Heap<*mut JSObject>>")