Use ToJSValConvertible to convert nullable enums to JSVal.

This commit is contained in:
Ms2ger 2014-04-06 19:51:12 +02:00
parent ccaa46e4a3
commit a52cffebeb
3 changed files with 5 additions and 5 deletions

View file

@ -1089,9 +1089,6 @@ def getWrapTemplateForType(type, descriptorProvider, result, successCode,
return (setValue("(%s).to_jsval(cx)" % result), True) return (setValue("(%s).to_jsval(cx)" % result), True)
if type.isEnum(): 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) return (setValue("(%s).to_jsval(cx)" % result), True)
if type.isCallback(): if type.isCallback():
@ -1188,9 +1185,10 @@ def getRetvalDeclarationForType(returnType, descriptorProvider):
result = CGWrapper(result, pre="Option<", post=">") result = CGWrapper(result, pre="Option<", post=">")
return result return result
if returnType.isEnum(): if returnType.isEnum():
result = CGGeneric(returnType.unroll().inner.identifier.name)
if returnType.nullable(): if returnType.nullable():
raise TypeError("We don't support nullable enum return values") result = CGWrapper(result, pre="Option<", post=">")
return CGGeneric(returnType.inner.identifier.name) return result
if returnType.isGeckoInterface(): if returnType.isGeckoInterface():
descriptor = descriptorProvider.getDescriptor( descriptor = descriptorProvider.getDescriptor(
returnType.unroll().inner.identifier.name) returnType.unroll().inner.identifier.name)

View file

@ -74,6 +74,7 @@ impl TestBinding {
pub fn SetDoubleAttributeNullable(&self, _: Option<f64>) {} pub fn SetDoubleAttributeNullable(&self, _: Option<f64>) {}
pub fn GetStringAttributeNullable(&self) -> Option<DOMString> { Some(~"") } pub fn GetStringAttributeNullable(&self) -> Option<DOMString> { Some(~"") }
pub fn SetStringAttributeNullable(&self, _: Option<DOMString>) {} pub fn SetStringAttributeNullable(&self, _: Option<DOMString>) {}
pub fn GetEnumAttributeNullable(&self) -> Option<TestEnum> { Some(_empty) }
pub fn GetInterfaceAttributeNullable(&self) -> Option<JS<Blob>> { Some(Blob::new(&self.window)) } pub fn GetInterfaceAttributeNullable(&self) -> Option<JS<Blob>> { Some(Blob::new(&self.window)) }
pub fn SetInterfaceAttributeNullable(&self, _: Option<JS<Blob>>) {} pub fn SetInterfaceAttributeNullable(&self, _: Option<JS<Blob>>) {}

View file

@ -33,6 +33,7 @@ interface TestBinding {
attribute float? floatAttributeNullable; attribute float? floatAttributeNullable;
attribute double? doubleAttributeNullable; attribute double? doubleAttributeNullable;
attribute DOMString? stringAttributeNullable; attribute DOMString? stringAttributeNullable;
readonly attribute TestEnum? enumAttributeNullable;
attribute Blob? interfaceAttributeNullable; attribute Blob? interfaceAttributeNullable;
void passOptionalBoolean(optional boolean arg); void passOptionalBoolean(optional boolean arg);