diff options
author | Josh Matthews <josh@joshmatthews.net> | 2024-11-05 03:29:08 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-05 08:29:08 +0000 |
commit | 25a0764a37a585d032ca352923b24995f8cbf1a0 (patch) | |
tree | 1805edc4fc79396de9150f8bc063888926d53d3b /components/script/dom/testbinding.rs | |
parent | 537958a3ccb57502c558e4da0963307fd7481a14 (diff) | |
download | servo-25a0764a37a585d032ca352923b24995f8cbf1a0.tar.gz servo-25a0764a37a585d032ca352923b24995f8cbf1a0.zip |
Use out parameter for generated methods returning JSVal (#34087)
* Make generated bindings that return a WebIDL `any` value use out parameters.
Returning raw JSVal values makes it easier to create GC hazards in code
that calls these methods. Accepting a MutableHandle argument instead
ensures that the values are rooted by the caller.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Update mozjs.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Fix clippy warnings.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
---------
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Diffstat (limited to 'components/script/dom/testbinding.rs')
-rw-r--r-- | components/script/dom/testbinding.rs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs index 2c91ce7fac5..1fc70eac60d 100644 --- a/components/script/dom/testbinding.rs +++ b/components/script/dom/testbinding.rs @@ -11,8 +11,8 @@ use std::time::Duration; use dom_struct::dom_struct; use js::jsapi::{Heap, JSObject, JS_NewPlainObject}; -use js::jsval::{JSVal, NullValue}; -use js::rust::{CustomAutoRooterGuard, HandleObject, HandleValue}; +use js::jsval::JSVal; +use js::rust::{CustomAutoRooterGuard, HandleObject, HandleValue, MutableHandleValue}; use js::typedarray::{self, Uint8ClampedArray}; use script_traits::serializable::BlobImpl; use servo_config::prefs; @@ -229,9 +229,7 @@ impl TestBindingMethods for TestBinding { create_buffer_source(cx, &data, array.handle_mut()) .expect("Creating ClampedU8 array should never fail") } - fn AnyAttribute(&self, _: SafeJSContext) -> JSVal { - NullValue() - } + fn AnyAttribute(&self, _: SafeJSContext, _: MutableHandleValue) {} fn SetAnyAttribute(&self, _: SafeJSContext, _: HandleValue) {} #[allow(unsafe_code)] fn ObjectAttribute(&self, cx: SafeJSContext) -> NonNull<JSObject> { @@ -426,9 +424,7 @@ impl TestBindingMethods for TestBinding { can_gc, ) } - fn ReceiveAny(&self, _: SafeJSContext) -> JSVal { - NullValue() - } + fn ReceiveAny(&self, _: SafeJSContext, _: MutableHandleValue) {} fn ReceiveObject(&self, cx: SafeJSContext) -> NonNull<JSObject> { self.ObjectAttribute(cx) } |