diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py index 52e1529f968..6acd0225e25 100644 --- a/src/components/script/dom/bindings/codegen/CodegenRust.py +++ b/src/components/script/dom/bindings/codegen/CodegenRust.py @@ -1089,9 +1089,6 @@ def getWrapTemplateForType(type, descriptorProvider, result, successCode, return (setValue("(%s).to_jsval(cx)" % result), True) if type.isEnum(): - if type.nullable(): - raise TypeError("We don't support nullable enumerated return types " - "yet") return (setValue("(%s).to_jsval(cx)" % result), True) if type.isCallback(): @@ -1188,9 +1185,10 @@ def getRetvalDeclarationForType(returnType, descriptorProvider): result = CGWrapper(result, pre="Option<", post=">") return result if returnType.isEnum(): + result = CGGeneric(returnType.unroll().inner.identifier.name) if returnType.nullable(): - raise TypeError("We don't support nullable enum return values") - return CGGeneric(returnType.inner.identifier.name) + result = CGWrapper(result, pre="Option<", post=">") + return result if returnType.isGeckoInterface(): descriptor = descriptorProvider.getDescriptor( returnType.unroll().inner.identifier.name) diff --git a/src/components/script/dom/testbinding.rs b/src/components/script/dom/testbinding.rs index 7f05fd5f183..c391c44b181 100644 --- a/src/components/script/dom/testbinding.rs +++ b/src/components/script/dom/testbinding.rs @@ -74,6 +74,7 @@ impl TestBinding { pub fn SetDoubleAttributeNullable(&self, _: Option) {} pub fn GetStringAttributeNullable(&self) -> Option { Some(~"") } pub fn SetStringAttributeNullable(&self, _: Option) {} + pub fn GetEnumAttributeNullable(&self) -> Option { Some(_empty) } pub fn GetInterfaceAttributeNullable(&self) -> Option> { Some(Blob::new(&self.window)) } pub fn SetInterfaceAttributeNullable(&self, _: Option>) {} diff --git a/src/components/script/dom/webidls/TestBinding.webidl b/src/components/script/dom/webidls/TestBinding.webidl index 04545269dca..4cc2fac87f9 100644 --- a/src/components/script/dom/webidls/TestBinding.webidl +++ b/src/components/script/dom/webidls/TestBinding.webidl @@ -33,6 +33,7 @@ interface TestBinding { attribute float? floatAttributeNullable; attribute double? doubleAttributeNullable; attribute DOMString? stringAttributeNullable; + readonly attribute TestEnum? enumAttributeNullable; attribute Blob? interfaceAttributeNullable; void passOptionalBoolean(optional boolean arg);