aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script
diff options
context:
space:
mode:
authorMs2ger <ms2ger@gmail.com>2014-06-07 17:38:35 +0200
committerMs2ger <ms2ger@gmail.com>2014-06-07 17:38:35 +0200
commitef0ccd3e1539165935795c12d1480c766f26b3a9 (patch)
treefb92b03fe61dcf98ef9a1af477df6e46c73fd712 /src/components/script
parent4786c30bce3e9f3cd9805a1b9590d87e69652659 (diff)
downloadservo-ef0ccd3e1539165935795c12d1480c766f26b3a9.tar.gz
servo-ef0ccd3e1539165935795c12d1480c766f26b3a9.zip
Add support for undefined default values for 'any'.
This also updates TestBinding to take into account the automatic default for optional 'any' arguments and dictionary members.
Diffstat (limited to 'src/components/script')
-rw-r--r--src/components/script/dom/bindings/codegen/CodegenRust.py14
-rw-r--r--src/components/script/dom/testbinding.rs2
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>>) {}