diff options
Diffstat (limited to 'src/components/script/dom')
-rw-r--r-- | src/components/script/dom/bindings/codegen/CodegenRust.py | 14 | ||||
-rw-r--r-- | src/components/script/dom/testbinding.rs | 2 |
2 files changed, 13 insertions, 3 deletions
diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py index 14d558958dc..40c9e3b87ba 100644 --- a/src/components/script/dom/bindings/codegen/CodegenRust.py +++ b/src/components/script/dom/bindings/codegen/CodegenRust.py @@ -518,7 +518,7 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None, if not isinstance(defaultValue, IDLNullValue): raise TypeError("Can't handle non-null default value here") - assert type.nullable() or type.isAny() or type.isDictionary() + assert type.nullable() or type.isDictionary() return nullValue # A helper function for wrapping up the template body for @@ -752,7 +752,17 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None, assert not isEnforceRange and not isClamp declType = CGGeneric("JSVal") - return handleOptional("${val}", declType, handleDefaultNull("NullValue()")) + + if defaultValue is None: + default = None + elif isinstance(defaultValue, IDLNullValue): + default = "NullValue()" + elif isinstance(defaultValue, IDLUndefinedValue): + default = "UndefinedValue()" + else: + raise TypeError("Can't handle non-null, non-undefined default value here") + + return handleOptional("${val}", declType, default) if type.isObject(): raise TypeError("Can't handle object arguments yet") diff --git a/src/components/script/dom/testbinding.rs b/src/components/script/dom/testbinding.rs index 852b7443418..984c67ee3e0 100644 --- a/src/components/script/dom/testbinding.rs +++ b/src/components/script/dom/testbinding.rs @@ -180,7 +180,7 @@ pub trait TestBindingMethods { fn PassOptionalInterface(&self, _: Option<JSRef<Blob>>) {} fn PassOptionalUnion(&self, _: Option<HTMLElementOrLong>) {} fn PassOptionalUnion2(&self, _: Option<EventOrString>) {} - fn PassOptionalAny(&self, _: *mut JSContext, _: Option<JSVal>) {} + fn PassOptionalAny(&self, _: *mut JSContext, _: JSVal) {} fn PassOptionalNullableBoolean(&self, _: Option<Option<bool>>) {} fn PassOptionalNullableByte(&self, _: Option<Option<i8>>) {} |