aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Matuszewski <Xanewok@gmail.com>2018-03-13 13:05:04 +0100
committerIgor Matuszewski <Xanewok@gmail.com>2018-03-14 18:43:27 +0100
commit6beb32e28e8652027a28bc8400dbe2d6e78cb286 (patch)
treebb9292dc7b7779b8ca4c28a02562b7f1420b772d
parente025bbb07964eb64317d9a6d63d4a55ba79cd8ae (diff)
downloadservo-6beb32e28e8652027a28bc8400dbe2d6e78cb286.tar.gz
servo-6beb32e28e8652027a28bc8400dbe2d6e78cb286.zip
Support nullable typed arrays in codegen
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py5
-rw-r--r--components/script/dom/testbinding.rs1
-rw-r--r--components/script/dom/webidls/TestBinding.webidl1
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 3e39bc231d4..6ab7dd8b1d3 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -882,7 +882,8 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
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 getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
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 2f6d578b0c9..80159a30068 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<Option<typedarray::Int8Array>>) { }
fn PassNullableUnion(&self, _: Option<HTMLElementOrLong>) {}
fn PassNullableUnion2(&self, _: Option<EventOrString>) {}
fn PassNullableUnion3(&self, _: Option<StringOrLongSequence>) {}
diff --git a/components/script/dom/webidls/TestBinding.webidl b/components/script/dom/webidls/TestBinding.webidl
index 7021d7d7635..1a1c86293cb 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<long>)? data);