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>) {} fn PassOptionalUnion(&self, _: Option) {} fn PassOptionalUnion2(&self, _: Option) {} - fn PassOptionalAny(&self, _: *mut JSContext, _: Option) {} + fn PassOptionalAny(&self, _: *mut JSContext, _: JSVal) {} fn PassOptionalNullableBoolean(&self, _: Option>) {} fn PassOptionalNullableByte(&self, _: Option>) {}