aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py7
-rw-r--r--components/script/dom/bindings/conversions.rs9
-rw-r--r--components/script/dom/testbinding.rs10
-rw-r--r--components/script/dom/webidls/TestBinding.webidl4
4 files changed, 25 insertions, 5 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index 56144485ab6..4468bb13b6b 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -433,7 +433,7 @@ class CGMethodCall(CGThing):
# XXXbz Now we're supposed to check for distinguishingArg being
# an array or a platform object that supports indexed
# properties... skip that last for now. It's a bit of a pain.
- pickFirstSignature("%s.get().isObject() && IsArrayLike(cx, &%s.get().toObject())" %
+ pickFirstSignature("%s.get().is_object() && is_array_like(cx, %s)" %
(distinguishingArg, distinguishingArg),
lambda s:
(s[1][distinguishingIndex].type.isArray() or
@@ -442,7 +442,7 @@ class CGMethodCall(CGThing):
# Check for Date objects
# XXXbz Do we need to worry about security wrappers around the Date?
- pickFirstSignature("%s.get().isObject() && JS_ObjectIsDate(cx, &%s.get().toObject())" %
+ pickFirstSignature("%s.get().is_object() && JS_ObjectIsDate(cx, &%s.get().to_object())" %
(distinguishingArg, distinguishingArg),
lambda s: (s[1][distinguishingIndex].type.isDate() or
s[1][distinguishingIndex].type.isObject()))
@@ -5438,7 +5438,8 @@ class CGBindingRoot(CGThing):
'dom::bindings::callback::{CallbackContainer,CallbackInterface,CallbackFunction}',
'dom::bindings::callback::{CallSetup,ExceptionHandling}',
'dom::bindings::callback::wrap_call_this_object',
- 'dom::bindings::conversions::{ConversionBehavior, DOM_OBJECT_SLOT, IDLInterface}',
+ 'dom::bindings::conversions::{ConversionBehavior, DOM_OBJECT_SLOT}',
+ 'dom::bindings::conversions::{IDLInterface, is_array_like}',
'dom::bindings::conversions::{FromJSValConvertible, StringificationBehavior}',
'dom::bindings::conversions::{ToJSValConvertible, jsid_to_str, native_from_handlevalue}',
'dom::bindings::conversions::{native_from_object, private_from_object, root_from_object}',
diff --git a/components/script/dom/bindings/conversions.rs b/components/script/dom/bindings/conversions.rs
index 3bf389a6596..6db0d08af4d 100644
--- a/components/script/dom/bindings/conversions.rs
+++ b/components/script/dom/bindings/conversions.rs
@@ -47,7 +47,7 @@ use js::jsapi::{HandleId, HandleObject, HandleValue, JS_GetClass};
use js::jsapi::{JSClass, JSContext, JSObject, MutableHandleValue};
use js::jsapi::{JS_GetLatin1StringCharsAndLength, JS_GetReservedSlot};
use js::jsapi::{JS_GetObjectAsArrayBufferView, JS_GetArrayBufferViewType};
-use js::jsapi::{JS_GetTwoByteStringCharsAndLength, JS_NewStringCopyN};
+use js::jsapi::{JS_GetTwoByteStringCharsAndLength, JS_IsArrayObject, JS_NewStringCopyN};
use js::jsapi::{JS_StringHasLatin1Chars, JS_WrapValue};
use js::jsapi::{Type};
use js::jsval::{ObjectValue, StringValue};
@@ -458,3 +458,10 @@ pub fn array_buffer_view_to_vec_checked<T: ArrayBufferViewContents>(abv: *mut JS
array_buffer_view_data_checked(abv).map(|data| data.to_vec())
}
}
+
+/// Returns whether `value` is an array-like object.
+/// Note: Currently only Arrays are supported.
+/// TODO: Expand this to support sequences and other array-like objects
+pub unsafe fn is_array_like(cx: *mut JSContext, value: HandleValue) -> bool {
+ JS_IsArrayObject(cx, value)
+}
diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs
index 1b7b838f831..ae63c1f6e20 100644
--- a/components/script/dom/testbinding.rs
+++ b/components/script/dom/testbinding.rs
@@ -51,6 +51,16 @@ impl TestBinding {
pub fn Constructor(global: GlobalRef) -> Fallible<Root<TestBinding>> {
Ok(TestBinding::new(global))
}
+
+ #[allow(unused_variables)]
+ pub fn Constructor_(global: GlobalRef, nums: Vec<f64>) -> Fallible<Root<TestBinding>> {
+ Ok(TestBinding::new(global))
+ }
+
+ #[allow(unused_variables)]
+ pub fn Constructor__(global: GlobalRef, num: f64) -> Fallible<Root<TestBinding>> {
+ Ok(TestBinding::new(global))
+ }
}
impl TestBindingMethods for TestBinding {
diff --git a/components/script/dom/webidls/TestBinding.webidl b/components/script/dom/webidls/TestBinding.webidl
index fd1358da4d8..269114dbf80 100644
--- a/components/script/dom/webidls/TestBinding.webidl
+++ b/components/script/dom/webidls/TestBinding.webidl
@@ -69,7 +69,9 @@ dictionary TestDictionaryDefaults {
object? nullableObjectValue = null;
};
-[Constructor]
+[Constructor,
+ Constructor(sequence<unrestricted double> numberSequence),
+ Constructor(unrestricted double num)]
interface TestBinding {
attribute boolean booleanAttribute;
attribute byte byteAttribute;