From 6beb32e28e8652027a28bc8400dbe2d6e78cb286 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Tue, 13 Mar 2018 13:05:04 +0100 Subject: [PATCH] Support nullable typed arrays in codegen --- components/script/dom/bindings/codegen/CodegenRust.py | 5 +++-- components/script/dom/testbinding.rs | 1 + components/script/dom/webidls/TestBinding.webidl | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 3e39bc231d40..6ab7dd8b1d3d 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -882,7 +882,8 @@ def wrapObjectTemplate(templateBody, nullValue, isDefinitelyObject, type, else: unwrapFailureCode = failureCode - typeName = type.name + typeName = type.unroll().name # unroll because it may be nullable + if isMember == "Union": typeName = "Heap" + typeName @@ -902,7 +903,7 @@ def wrapObjectTemplate(templateBody, nullValue, isDefinitelyObject, type, if isMember == "Union": templateBody = "RootedTraceableBox::new(%s)" % templateBody - declType = CGGeneric("typedarray::%s" % type.name) + declType = CGGeneric("typedarray::%s" % typeName) if type.nullable(): templateBody = "Some(%s)" % templateBody declType = CGWrapper(declType, pre="Option<", post=">") diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs index 2f6d578b0c9c..80159a300681 100644 --- a/components/script/dom/testbinding.rs +++ b/components/script/dom/testbinding.rs @@ -492,6 +492,7 @@ impl TestBindingMethods for TestBinding { fn PassNullableInterface(&self, _: Option<&Blob>) {} #[allow(unsafe_code)] unsafe fn PassNullableObject(&self, _: *mut JSContext, _: *mut JSObject) {} + fn PassNullableTypedArray(&self, _: CustomAutoRooterGuard>) { } fn PassNullableUnion(&self, _: Option) {} fn PassNullableUnion2(&self, _: Option) {} fn PassNullableUnion3(&self, _: Option) {} diff --git a/components/script/dom/webidls/TestBinding.webidl b/components/script/dom/webidls/TestBinding.webidl index 7021d7d76352..1a1c86293cb2 100644 --- a/components/script/dom/webidls/TestBinding.webidl +++ b/components/script/dom/webidls/TestBinding.webidl @@ -294,6 +294,7 @@ interface TestBinding { // void passNullableEnum(TestEnum? arg); void passNullableInterface(Blob? arg); void passNullableObject(object? arg); + void passNullableTypedArray(Int8Array? arg); void passNullableUnion((HTMLElement or long)? arg); void passNullableUnion2((Event or DOMString)? data); void passNullableUnion3((DOMString or sequence)? data);