Skip to content

Commit

Permalink
Support nullable typed arrays in codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
Xanewok committed Mar 14, 2018
1 parent e025bbb commit 6beb32e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions components/script/dom/bindings/codegen/CodegenRust.py
Expand Up @@ -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

Expand All @@ -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=">")
Expand Down
1 change: 1 addition & 0 deletions components/script/dom/testbinding.rs
Expand Up @@ -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>) {}
Expand Down
1 change: 1 addition & 0 deletions components/script/dom/webidls/TestBinding.webidl
Expand Up @@ -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);
Expand Down

0 comments on commit 6beb32e

Please sign in to comment.