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>
This commit is contained in:
Josh Matthews 2024-11-05 03:29:08 -05:00 committed by GitHub
parent 537958a3cc
commit 25a0764a37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
38 changed files with 763 additions and 515 deletions

View file

@ -6,8 +6,7 @@ use std::cell::Cell;
use std::rc::Rc;
use dom_struct::dom_struct;
use js::jsval::JSVal;
use js::rust::HandleObject;
use js::rust::{HandleObject, MutableHandleValue};
use crate::dom::bindings::callback::ExceptionHandling;
use crate::dom::bindings::cell::DomRefCell;
@ -137,10 +136,10 @@ impl PerformanceObserverMethods for PerformanceObserver {
}
// https://w3c.github.io/performance-timeline/#supportedentrytypes-attribute
fn SupportedEntryTypes(cx: JSContext, global: &GlobalScope) -> JSVal {
fn SupportedEntryTypes(cx: JSContext, global: &GlobalScope, retval: MutableHandleValue) {
// While this is exposed through a method of PerformanceObserver,
// it is specified as associated with the global scope.
global.supported_performance_entry_types(cx)
global.supported_performance_entry_types(cx, retval)
}
// https://w3c.github.io/performance-timeline/#dom-performanceobserver-observe()