diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py index 3950b522877..20cbe1080ef 100644 --- a/src/components/script/dom/bindings/codegen/CodegenRust.py +++ b/src/components/script/dom/bindings/codegen/CodegenRust.py @@ -1601,9 +1601,9 @@ if %(resultStr)s.is_null() { if type.nullable(): (recTemplate, recInfal) = getWrapTemplateForType(type.inner, descriptorProvider, - "%s.Value()" % result, successCode, + "%s.unwrap()" % result, successCode, isCreator, exceptionCode) - return ("if (%s.IsNull()) {\n" % result + + return ("if (%s.is_none()) {\n" % result + CGIndenter(CGGeneric(setValue("JSVAL_NULL"))).define() + "\n" + "}\n" + recTemplate, recInfal) @@ -1667,7 +1667,7 @@ def getRetvalDeclarationForType(returnType, descriptorProvider): if returnType.isPrimitive() and returnType.tag() in builtinNames: result = CGGeneric(builtinNames[returnType.tag()]) if returnType.nullable(): - result = CGWrapper(result, pre="Nullable<", post=">") + result = CGWrapper(result, pre="Option<", post=">") return result, False if returnType.isString(): result = CGGeneric("DOMString") diff --git a/src/components/script/dom/testbinding.rs b/src/components/script/dom/testbinding.rs index 361710ad17f..4aceb57bec2 100644 --- a/src/components/script/dom/testbinding.rs +++ b/src/components/script/dom/testbinding.rs @@ -32,6 +32,29 @@ impl TestBinding { pub fn SetFloatAttribute(&self, _: f32) {} pub fn DoubleAttribute(&self) -> f64 { 0. } pub fn SetDoubleAttribute(&self, _: f64) {} + + pub fn GetBooleanAttributeNullable(&self) -> Option { Some(false) } + pub fn SetBooleanAttributeNullable(&self, _: Option) {} + pub fn GetByteAttributeNullable(&self) -> Option { Some(0) } + pub fn SetByteAttributeNullable(&self, _: Option) {} + pub fn GetOctetAttributeNullable(&self) -> Option { Some(0) } + pub fn SetOctetAttributeNullable(&self, _: Option) {} + pub fn GetShortAttributeNullable(&self) -> Option { Some(0) } + pub fn SetShortAttributeNullable(&self, _: Option) {} + pub fn GetUnsignedShortAttributeNullable(&self) -> Option { Some(0) } + pub fn SetUnsignedShortAttributeNullable(&self, _: Option) {} + pub fn GetLongAttributeNullable(&self) -> Option { Some(0) } + pub fn SetLongAttributeNullable(&self, _: Option) {} + pub fn GetUnsignedLongAttributeNullable(&self) -> Option { Some(0) } + pub fn SetUnsignedLongAttributeNullable(&self, _: Option) {} + pub fn GetLongLongAttributeNullable(&self) -> Option { Some(0) } + pub fn SetLongLongAttributeNullable(&self, _: Option) {} + pub fn GetUnsignedLongLongAttributeNullable(&self) -> Option { Some(0) } + pub fn SetUnsignedLongLongAttributeNullable(&self, _: Option) {} + pub fn GetFloatAttributeNullable(&self) -> Option { Some(0.) } + pub fn SetFloatAttributeNullable(&self, _: Option) {} + pub fn GetDoubleAttributeNullable(&self) -> Option { Some(0.) } + pub fn SetDoubleAttributeNullable(&self, _: Option) {} } impl Reflectable for TestBinding { diff --git a/src/components/script/dom/webidls/TestBinding.webidl b/src/components/script/dom/webidls/TestBinding.webidl index 34dd569e8ee..8086a2bead9 100644 --- a/src/components/script/dom/webidls/TestBinding.webidl +++ b/src/components/script/dom/webidls/TestBinding.webidl @@ -14,4 +14,16 @@ interface TestBinding { attribute unsigned long long unsignedLongLongAttribute; attribute float floatAttribute; attribute double doubleAttribute; + + attribute boolean? booleanAttributeNullable; + attribute byte? byteAttributeNullable; + attribute octet? octetAttributeNullable; + attribute short? shortAttributeNullable; + attribute unsigned short? unsignedShortAttributeNullable; + attribute long? longAttributeNullable; + attribute unsigned long? unsignedLongAttributeNullable; + attribute long long? longLongAttributeNullable; + attribute unsigned long long? unsignedLongLongAttributeNullable; + attribute float? floatAttributeNullable; + attribute double? doubleAttributeNullable; };