mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
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:
parent
537958a3cc
commit
25a0764a37
38 changed files with 763 additions and 515 deletions
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
use js::jsval::JSVal;
|
||||
use js::rust::MutableHandleValue;
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::WorkerNavigatorBinding::WorkerNavigatorMethods;
|
||||
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
|
||||
|
@ -97,8 +97,8 @@ impl WorkerNavigatorMethods for WorkerNavigator {
|
|||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-navigator-languages
|
||||
#[allow(unsafe_code)]
|
||||
fn Languages(&self, cx: JSContext) -> JSVal {
|
||||
to_frozen_array(&[self.Language()], cx)
|
||||
fn Languages(&self, cx: JSContext, retval: MutableHandleValue) {
|
||||
to_frozen_array(&[self.Language()], cx, retval)
|
||||
}
|
||||
|
||||
// https://w3c.github.io/permissions/#navigator-and-workernavigator-extension
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue