mirror of
https://github.com/servo/servo.git
synced 2025-06-24 17:14:33 +01:00
Use handleOptional for interface conversion.
This commit is contained in:
parent
7c3480de60
commit
54d2e8e235
3 changed files with 4 additions and 4 deletions
|
@ -628,14 +628,14 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
|
|||
"(${val}).to_object()"))
|
||||
|
||||
declType = CGGeneric(descriptor.nativeType)
|
||||
if type.nullable() or isOptional:
|
||||
if type.nullable():
|
||||
templateBody = "Some(%s)" % templateBody
|
||||
declType = CGWrapper(declType, pre="Option<", post=">")
|
||||
|
||||
templateBody = wrapObjectTemplate(templateBody, isDefinitelyObject,
|
||||
type, failureCode)
|
||||
|
||||
return (templateBody, declType, isOptional, "None" if isOptional else None)
|
||||
return handleOptional(templateBody, declType, isOptional)
|
||||
|
||||
if type.isSpiderMonkeyInterface():
|
||||
raise TypeError("Can't handle SpiderMonkey interface arguments yet")
|
||||
|
|
|
@ -145,7 +145,7 @@ impl TestBinding {
|
|||
pub fn PassOptionalNullableDouble(&self, _: Option<Option<f64>>) {}
|
||||
pub fn PassOptionalNullableString(&self, _: Option<Option<DOMString>>) {}
|
||||
// pub fn PassOptionalNullableEnum(&self, _: Option<Option<TestEnum>>) {}
|
||||
// pub fn PassOptionalNullableInterface(&self, _: Option<Option<JS<Blob>>>) {}
|
||||
pub fn PassOptionalNullableInterface(&self, _: Option<Option<JS<Blob>>>) {}
|
||||
pub fn PassOptionalNullableUnion(&self, _: Option<Option<HTMLElementOrLong>>) {}
|
||||
|
||||
pub fn PassOptionalBooleanWithDefault(&self, _: bool) {}
|
||||
|
|
|
@ -150,7 +150,7 @@ interface TestBinding {
|
|||
void passOptionalNullableDouble(optional double? arg);
|
||||
void passOptionalNullableString(optional DOMString? arg);
|
||||
// void passOptionalNullableEnum(optional TestEnum? arg);
|
||||
// void passOptionalNullableInterface(optional Blob? arg);
|
||||
void passOptionalNullableInterface(optional Blob? arg);
|
||||
void passOptionalNullableUnion(optional (HTMLElement or long)? arg);
|
||||
|
||||
void passOptionalBooleanWithDefault(optional boolean arg = false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue