mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Use ToJSValConvertible to convert nullable enums to JSVal.
This commit is contained in:
parent
ccaa46e4a3
commit
a52cffebeb
3 changed files with 5 additions and 5 deletions
|
@ -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)
|
||||
|
|
|
@ -74,6 +74,7 @@ impl TestBinding {
|
|||
pub fn SetDoubleAttributeNullable(&self, _: Option<f64>) {}
|
||||
pub fn GetStringAttributeNullable(&self) -> Option<DOMString> { Some(~"") }
|
||||
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 SetInterfaceAttributeNullable(&self, _: Option<JS<Blob>>) {}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue