From b4e35c5dd65e3c7e0fd37cd56de29272995b8cd0 Mon Sep 17 00:00:00 2001 From: Calli Date: Mon, 3 Oct 2022 13:21:15 +0200 Subject: [PATCH 1/4] Separate JsObjectType implementors to their own module --- boa_engine/src/lib.rs | 2 +- boa_engine/src/object/jsmap.rs | 34 +++++++++++++-------------- boa_engine/src/object/jsset.rs | 2 +- boa_engine/src/object/mod.rs | 28 +++++++++++++++------- boa_examples/src/bin/closures.rs | 2 +- boa_examples/src/bin/jsarray.rs | 2 +- boa_examples/src/bin/jsarraybuffer.rs | 2 +- boa_examples/src/bin/jsmap.rs | 2 +- boa_examples/src/bin/jsset.rs | 2 +- boa_examples/src/bin/jstypedarray.rs | 2 +- boa_tester/src/exec/js262.rs | 2 +- 11 files changed, 45 insertions(+), 35 deletions(-) diff --git a/boa_engine/src/lib.rs b/boa_engine/src/lib.rs index 9e6e3ea26ce..fda4f95a1ee 100644 --- a/boa_engine/src/lib.rs +++ b/boa_engine/src/lib.rs @@ -96,7 +96,7 @@ mod tests; /// A convenience module that re-exports the most commonly-used Boa APIs pub mod prelude { - pub use crate::{object::JsObject, Context, JsBigInt, JsResult, JsString, JsValue}; + pub use crate::{object::js_objects::JsObject, Context, JsBigInt, JsResult, JsString, JsValue}; } use std::result::Result as StdResult; diff --git a/boa_engine/src/object/jsmap.rs b/boa_engine/src/object/jsmap.rs index 885929c708d..b84aedc07b5 100644 --- a/boa_engine/src/object/jsmap.rs +++ b/boa_engine/src/object/jsmap.rs @@ -16,7 +16,7 @@ use std::ops::Deref; /// Create a `JsMap` and set a new entry /// ``` /// # use boa_engine::{ -/// # object::JsMap, +/// # object::js_objects::JsMap, /// # Context, JsValue, /// # }; /// @@ -37,7 +37,7 @@ use std::ops::Deref; /// Create a `JsMap` from a `JsArray` /// ``` /// # use boa_engine::{ -/// # object::{JsArray, JsMap}, +/// # object::js_objects::{JsArray, JsMap}, /// # Context, JsValue, /// # }; /// @@ -46,7 +46,7 @@ use std::ops::Deref; /// /// // Create an array of two `[key, value]` pairs /// let js_array = JsArray::new(context); -/// +/// /// // Create a `[key, value]` pair of JsValues /// let vec_one: Vec = vec![JsValue::new("first-key"), JsValue::new("first-value")]; /// @@ -72,7 +72,7 @@ impl JsMap { /// /// ``` /// # use boa_engine::{ - /// # object::JsMap, + /// # object::js_objects::JsMap, /// # Context, JsValue, /// # }; /// @@ -94,7 +94,7 @@ impl JsMap { /// # Examples /// ``` /// # use boa_engine::{ - /// # object::{JsArray, JsMap}, + /// # object::js_objects::{JsArray, JsMap}, /// # Context, JsResult, JsValue, /// # }; /// @@ -103,7 +103,7 @@ impl JsMap { /// /// // Create an array of two `[key, value]` pairs /// let js_array = JsArray::new(context); - /// + /// /// // Create a `[key, value]` pair of JsValues and add it to the `JsArray` as a `JsArray` /// let vec_one: Vec = vec![JsValue::new("first-key"), JsValue::new("first-value")]; /// js_array.push(JsArray::from_iter(vec_one, context), context).unwrap(); @@ -136,7 +136,7 @@ impl JsMap { /// ``` /// # use boa_engine::{ /// # builtins::map::ordered_map::OrderedMap, - /// # object::{JsObject, ObjectData, JsMap}, + /// # object::{js_objects::{JsObject, JsMap}, ObjectData}, /// # Context, JsValue, /// # }; /// @@ -147,7 +147,7 @@ impl JsMap { /// context.intrinsics().constructors().map().prototype(), /// ObjectData::map(OrderedMap::new()) /// ); - /// + /// /// // Create `JsMap` object with incoming object. /// let js_map = JsMap::from_object(some_object, context).unwrap(); /// @@ -156,7 +156,7 @@ impl JsMap { /// Invalid Example - returns a `TypeError` with the message "object is not a Map" /// ``` /// # use boa_engine::{ - /// # object::{JsObject, JsArray, JsMap}, + /// # object::js_objects::{JsObject, JsArray, JsMap}, /// # Context, JsResult, JsValue, /// # }; /// @@ -166,7 +166,7 @@ impl JsMap { /// /// // Some object is an Array object, not a map object /// assert!(JsMap::from_object(some_object.into(), context).is_err()); - /// + /// /// ``` #[inline] pub fn from_object(object: JsObject, context: &mut Context) -> JsResult { @@ -210,7 +210,7 @@ impl JsMap { /// /// ``` /// # use boa_engine::{ - /// # object::JsMap, + /// # object::js_objects::JsMap, /// # Context, JsValue, /// # }; /// @@ -223,7 +223,7 @@ impl JsMap { /// /// assert_eq!(js_map.get("foo", context).unwrap(), "bar".into()); /// assert_eq!(js_map.get(2, context).unwrap(), 4.into()) - /// + /// /// ``` #[inline] pub fn set(&self, key: K, value: V, context: &mut Context) -> JsResult @@ -244,7 +244,7 @@ impl JsMap { /// /// ``` /// # use boa_engine::{ - /// # object::JsMap, + /// # object::js_objects::JsMap, /// # Context, JsValue, /// # }; /// @@ -270,7 +270,7 @@ impl JsMap { /// /// ``` /// # use boa_engine::{ - /// # object::JsMap, + /// # object::js_objects::JsMap, /// # Context, JsValue, /// # }; /// @@ -300,7 +300,7 @@ impl JsMap { /// /// ``` /// # use boa_engine::{ - /// # object::JsMap, + /// # object::js_objects::JsMap, /// # Context, JsValue, /// # }; /// @@ -327,7 +327,7 @@ impl JsMap { /// /// ``` /// # use boa_engine::{ - /// # object::JsMap, + /// # object::js_objects::JsMap, /// # Context, JsValue, /// # }; /// @@ -353,7 +353,7 @@ impl JsMap { /// /// ``` /// # use boa_engine::{ - /// # object::JsMap, + /// # object::js_objects::JsMap, /// # Context, JsValue, /// # }; /// diff --git a/boa_engine/src/object/jsset.rs b/boa_engine/src/object/jsset.rs index 4f521a66376..ce2e35b17cf 100644 --- a/boa_engine/src/object/jsset.rs +++ b/boa_engine/src/object/jsset.rs @@ -8,7 +8,7 @@ use crate::{ Context, JsResult, JsValue, }; -// This is an wrapper for `JsSet` +/// JavaScript `Set` rust object. #[derive(Debug, Clone, Trace, Finalize)] pub struct JsSet { inner: JsObject, diff --git a/boa_engine/src/object/mod.rs b/boa_engine/src/object/mod.rs index 86491ab9fb9..553d55227b6 100644 --- a/boa_engine/src/object/mod.rs +++ b/boa_engine/src/object/mod.rs @@ -1,6 +1,8 @@ -//! This module implements the Rust representation of a JavaScript object. +//! This module implements the Rust representation of a JavaScript object, see [js_objects] for implementors. +//! +//! This module also provides helper objects for working with JavaScript objects. -pub use jsobject::{JsObject, RecursionLimiter, Ref, RefMut}; +pub use jsobject::{RecursionLimiter, Ref, RefMut}; pub use operations::IntegrityLevel; pub use property_map::*; @@ -76,15 +78,23 @@ mod jstypedarray; mod operations; mod property_map; -pub use jsarray::*; -pub use jsarraybuffer::*; -pub use jsfunction::*; -pub use jsmap::*; +pub mod js_objects { + //! Contains all the Rust representations of JavaScript objects. + + pub use super::jsarray::*; + pub use super::jsarraybuffer::*; + pub use super::jsfunction::*; + pub use super::jsmap::*; + pub use super::jsobject::JsObject; + pub use super::jsproxy::{JsProxy, JsRevocableProxy}; + pub use super::jsset::*; + pub use super::jstypedarray::*; +} +pub(crate) use js_objects::*; + pub use jsmap_iterator::*; -pub use jsproxy::*; -pub use jsset::*; +pub use jsproxy::JsProxyBuilder; pub use jsset_iterator::*; -pub use jstypedarray::*; pub(crate) trait JsObjectType: Into + Into + Deref diff --git a/boa_examples/src/bin/closures.rs b/boa_examples/src/bin/closures.rs index 2c453e40702..7138134fb7c 100644 --- a/boa_examples/src/bin/closures.rs +++ b/boa_examples/src/bin/closures.rs @@ -2,7 +2,7 @@ // inside Rust and call them from Javascript. use boa_engine::{ - object::{FunctionBuilder, JsObject}, + object::{FunctionBuilder, js_objects::JsObject}, property::{Attribute, PropertyDescriptor}, Context, JsString, JsValue, }; diff --git a/boa_examples/src/bin/jsarray.rs b/boa_examples/src/bin/jsarray.rs index 2b369e109dc..27f29603007 100644 --- a/boa_examples/src/bin/jsarray.rs +++ b/boa_examples/src/bin/jsarray.rs @@ -1,7 +1,7 @@ // This example shows how to manipulate a Javascript array using Rust code. use boa_engine::{ - object::{FunctionBuilder, JsArray}, + object::{FunctionBuilder, js_objects::JsArray}, Context, JsResult, JsValue, }; diff --git a/boa_examples/src/bin/jsarraybuffer.rs b/boa_examples/src/bin/jsarraybuffer.rs index 4f6773b27a1..001927d244b 100644 --- a/boa_examples/src/bin/jsarraybuffer.rs +++ b/boa_examples/src/bin/jsarraybuffer.rs @@ -1,7 +1,7 @@ // This example shows how to manipulate a Javascript array using Rust code. use boa_engine::{ - object::{JsArrayBuffer, JsUint32Array, JsUint8Array}, + object::{js_objects::JsArrayBuffer, js_objects::JsUint32Array, js_objects::JsUint8Array}, property::Attribute, Context, JsResult, JsValue, }; diff --git a/boa_examples/src/bin/jsmap.rs b/boa_examples/src/bin/jsmap.rs index df18bebb7dc..c7a104f2431 100644 --- a/boa_examples/src/bin/jsmap.rs +++ b/boa_examples/src/bin/jsmap.rs @@ -1,5 +1,5 @@ use boa_engine::{ - object::{JsArray, JsMap}, + object::{js_objects::JsArray, js_objects::JsMap}, Context, JsResult, JsValue, }; diff --git a/boa_examples/src/bin/jsset.rs b/boa_examples/src/bin/jsset.rs index 1300320dc25..9c100b4f56f 100644 --- a/boa_examples/src/bin/jsset.rs +++ b/boa_examples/src/bin/jsset.rs @@ -1,6 +1,6 @@ // This example shows how to manipulate a Javascript Set using Rust code. #![allow(clippy::bool_assert_comparison)] -use boa_engine::{object::JsSet, Context, JsValue}; +use boa_engine::{object::js_objects::JsSet, Context, JsValue}; fn main() -> Result<(), JsValue> { // New `Context` for a new Javascript executor. diff --git a/boa_examples/src/bin/jstypedarray.rs b/boa_examples/src/bin/jstypedarray.rs index e10b788e5fb..6aa0a2ac5c3 100644 --- a/boa_examples/src/bin/jstypedarray.rs +++ b/boa_examples/src/bin/jstypedarray.rs @@ -1,7 +1,7 @@ // This example shows how to manipulate a Javascript array using Rust code. use boa_engine::{ - object::{FunctionBuilder, JsUint8Array}, + object::{js_objects::JsUint8Array, FunctionBuilder}, property::Attribute, Context, JsResult, JsValue, }; diff --git a/boa_tester/src/exec/js262.rs b/boa_tester/src/exec/js262.rs index f6ad73dd210..99b05effd52 100644 --- a/boa_tester/src/exec/js262.rs +++ b/boa_tester/src/exec/js262.rs @@ -1,6 +1,6 @@ use boa_engine::{ builtins::JsArgs, - object::{JsObject, ObjectInitializer}, + object::{js_objects::JsObject, ObjectInitializer}, property::Attribute, Context, JsResult, JsValue, }; From 2794c7c418ccdd732004a74c383086f05fb85046 Mon Sep 17 00:00:00 2001 From: Calli Date: Mon, 3 Oct 2022 13:26:27 +0200 Subject: [PATCH 2/4] rename js_objects to js_object in line with object module --- boa_engine/src/lib.rs | 2 +- boa_engine/src/object/jsmap.rs | 24 ++++++++++++------------ boa_engine/src/object/mod.rs | 6 +++--- boa_examples/src/bin/closures.rs | 2 +- boa_examples/src/bin/jsarray.rs | 2 +- boa_examples/src/bin/jsarraybuffer.rs | 2 +- boa_examples/src/bin/jsmap.rs | 2 +- boa_examples/src/bin/jsset.rs | 2 +- boa_examples/src/bin/jstypedarray.rs | 2 +- boa_tester/src/exec/js262.rs | 2 +- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/boa_engine/src/lib.rs b/boa_engine/src/lib.rs index fda4f95a1ee..a6d3ce758c5 100644 --- a/boa_engine/src/lib.rs +++ b/boa_engine/src/lib.rs @@ -96,7 +96,7 @@ mod tests; /// A convenience module that re-exports the most commonly-used Boa APIs pub mod prelude { - pub use crate::{object::js_objects::JsObject, Context, JsBigInt, JsResult, JsString, JsValue}; + pub use crate::{object::js_object::JsObject, Context, JsBigInt, JsResult, JsString, JsValue}; } use std::result::Result as StdResult; diff --git a/boa_engine/src/object/jsmap.rs b/boa_engine/src/object/jsmap.rs index b84aedc07b5..2a3c35589d1 100644 --- a/boa_engine/src/object/jsmap.rs +++ b/boa_engine/src/object/jsmap.rs @@ -16,7 +16,7 @@ use std::ops::Deref; /// Create a `JsMap` and set a new entry /// ``` /// # use boa_engine::{ -/// # object::js_objects::JsMap, +/// # object::js_object::JsMap, /// # Context, JsValue, /// # }; /// @@ -37,7 +37,7 @@ use std::ops::Deref; /// Create a `JsMap` from a `JsArray` /// ``` /// # use boa_engine::{ -/// # object::js_objects::{JsArray, JsMap}, +/// # object::js_object::{JsArray, JsMap}, /// # Context, JsValue, /// # }; /// @@ -72,7 +72,7 @@ impl JsMap { /// /// ``` /// # use boa_engine::{ - /// # object::js_objects::JsMap, + /// # object::js_object::JsMap, /// # Context, JsValue, /// # }; /// @@ -94,7 +94,7 @@ impl JsMap { /// # Examples /// ``` /// # use boa_engine::{ - /// # object::js_objects::{JsArray, JsMap}, + /// # object::js_object::{JsArray, JsMap}, /// # Context, JsResult, JsValue, /// # }; /// @@ -136,7 +136,7 @@ impl JsMap { /// ``` /// # use boa_engine::{ /// # builtins::map::ordered_map::OrderedMap, - /// # object::{js_objects::{JsObject, JsMap}, ObjectData}, + /// # object::{js_object::{JsObject, JsMap}, ObjectData}, /// # Context, JsValue, /// # }; /// @@ -156,7 +156,7 @@ impl JsMap { /// Invalid Example - returns a `TypeError` with the message "object is not a Map" /// ``` /// # use boa_engine::{ - /// # object::js_objects::{JsObject, JsArray, JsMap}, + /// # object::js_object::{JsObject, JsArray, JsMap}, /// # Context, JsResult, JsValue, /// # }; /// @@ -210,7 +210,7 @@ impl JsMap { /// /// ``` /// # use boa_engine::{ - /// # object::js_objects::JsMap, + /// # object::js_object::JsMap, /// # Context, JsValue, /// # }; /// @@ -244,7 +244,7 @@ impl JsMap { /// /// ``` /// # use boa_engine::{ - /// # object::js_objects::JsMap, + /// # object::js_object::JsMap, /// # Context, JsValue, /// # }; /// @@ -270,7 +270,7 @@ impl JsMap { /// /// ``` /// # use boa_engine::{ - /// # object::js_objects::JsMap, + /// # object::js_object::JsMap, /// # Context, JsValue, /// # }; /// @@ -300,7 +300,7 @@ impl JsMap { /// /// ``` /// # use boa_engine::{ - /// # object::js_objects::JsMap, + /// # object::js_object::JsMap, /// # Context, JsValue, /// # }; /// @@ -327,7 +327,7 @@ impl JsMap { /// /// ``` /// # use boa_engine::{ - /// # object::js_objects::JsMap, + /// # object::js_object::JsMap, /// # Context, JsValue, /// # }; /// @@ -353,7 +353,7 @@ impl JsMap { /// /// ``` /// # use boa_engine::{ - /// # object::js_objects::JsMap, + /// # object::js_object::JsMap, /// # Context, JsValue, /// # }; /// diff --git a/boa_engine/src/object/mod.rs b/boa_engine/src/object/mod.rs index 553d55227b6..f1e0e4d3a05 100644 --- a/boa_engine/src/object/mod.rs +++ b/boa_engine/src/object/mod.rs @@ -1,4 +1,4 @@ -//! This module implements the Rust representation of a JavaScript object, see [js_objects] for implementors. +//! This module implements the Rust representation of a JavaScript object, see [js_object] for implementors. //! //! This module also provides helper objects for working with JavaScript objects. @@ -78,7 +78,7 @@ mod jstypedarray; mod operations; mod property_map; -pub mod js_objects { +pub mod js_object { //! Contains all the Rust representations of JavaScript objects. pub use super::jsarray::*; @@ -90,7 +90,7 @@ pub mod js_objects { pub use super::jsset::*; pub use super::jstypedarray::*; } -pub(crate) use js_objects::*; +pub(crate) use js_object::*; pub use jsmap_iterator::*; pub use jsproxy::JsProxyBuilder; diff --git a/boa_examples/src/bin/closures.rs b/boa_examples/src/bin/closures.rs index 7138134fb7c..ab1bfa7b98d 100644 --- a/boa_examples/src/bin/closures.rs +++ b/boa_examples/src/bin/closures.rs @@ -2,7 +2,7 @@ // inside Rust and call them from Javascript. use boa_engine::{ - object::{FunctionBuilder, js_objects::JsObject}, + object::{js_object::JsObject, FunctionBuilder}, property::{Attribute, PropertyDescriptor}, Context, JsString, JsValue, }; diff --git a/boa_examples/src/bin/jsarray.rs b/boa_examples/src/bin/jsarray.rs index 27f29603007..af07e55c8e5 100644 --- a/boa_examples/src/bin/jsarray.rs +++ b/boa_examples/src/bin/jsarray.rs @@ -1,7 +1,7 @@ // This example shows how to manipulate a Javascript array using Rust code. use boa_engine::{ - object::{FunctionBuilder, js_objects::JsArray}, + object::{js_object::JsArray, FunctionBuilder}, Context, JsResult, JsValue, }; diff --git a/boa_examples/src/bin/jsarraybuffer.rs b/boa_examples/src/bin/jsarraybuffer.rs index 001927d244b..806260c7eea 100644 --- a/boa_examples/src/bin/jsarraybuffer.rs +++ b/boa_examples/src/bin/jsarraybuffer.rs @@ -1,7 +1,7 @@ // This example shows how to manipulate a Javascript array using Rust code. use boa_engine::{ - object::{js_objects::JsArrayBuffer, js_objects::JsUint32Array, js_objects::JsUint8Array}, + object::{js_object::JsArrayBuffer, js_object::JsUint32Array, js_object::JsUint8Array}, property::Attribute, Context, JsResult, JsValue, }; diff --git a/boa_examples/src/bin/jsmap.rs b/boa_examples/src/bin/jsmap.rs index c7a104f2431..809301cd3a6 100644 --- a/boa_examples/src/bin/jsmap.rs +++ b/boa_examples/src/bin/jsmap.rs @@ -1,5 +1,5 @@ use boa_engine::{ - object::{js_objects::JsArray, js_objects::JsMap}, + object::{js_object::JsArray, js_object::JsMap}, Context, JsResult, JsValue, }; diff --git a/boa_examples/src/bin/jsset.rs b/boa_examples/src/bin/jsset.rs index 9c100b4f56f..a8abc7aa1a8 100644 --- a/boa_examples/src/bin/jsset.rs +++ b/boa_examples/src/bin/jsset.rs @@ -1,6 +1,6 @@ // This example shows how to manipulate a Javascript Set using Rust code. #![allow(clippy::bool_assert_comparison)] -use boa_engine::{object::js_objects::JsSet, Context, JsValue}; +use boa_engine::{object::js_object::JsSet, Context, JsValue}; fn main() -> Result<(), JsValue> { // New `Context` for a new Javascript executor. diff --git a/boa_examples/src/bin/jstypedarray.rs b/boa_examples/src/bin/jstypedarray.rs index 6aa0a2ac5c3..578f762ab7d 100644 --- a/boa_examples/src/bin/jstypedarray.rs +++ b/boa_examples/src/bin/jstypedarray.rs @@ -1,7 +1,7 @@ // This example shows how to manipulate a Javascript array using Rust code. use boa_engine::{ - object::{js_objects::JsUint8Array, FunctionBuilder}, + object::{js_object::JsUint8Array, FunctionBuilder}, property::Attribute, Context, JsResult, JsValue, }; diff --git a/boa_tester/src/exec/js262.rs b/boa_tester/src/exec/js262.rs index 99b05effd52..4071968d994 100644 --- a/boa_tester/src/exec/js262.rs +++ b/boa_tester/src/exec/js262.rs @@ -1,6 +1,6 @@ use boa_engine::{ builtins::JsArgs, - object::{js_objects::JsObject, ObjectInitializer}, + object::{js_object::JsObject, ObjectInitializer}, property::Attribute, Context, JsResult, JsValue, }; From a045735c07ab8a070ad030e4cedf866757a261d0 Mon Sep 17 00:00:00 2001 From: Calli Date: Mon, 3 Oct 2022 14:32:38 +0200 Subject: [PATCH 3/4] fixed import errors after merge from main --- boa_engine/src/object/jsdataview.rs | 2 +- boa_engine/src/object/mod.rs | 3 ++- boa_examples/src/bin/jsarraybuffer.rs | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/boa_engine/src/object/jsdataview.rs b/boa_engine/src/object/jsdataview.rs index 2a321ce8f44..c0aa551c180 100644 --- a/boa_engine/src/object/jsdataview.rs +++ b/boa_engine/src/object/jsdataview.rs @@ -17,7 +17,7 @@ use std::ops::Deref; /// # Examples /// ``` /// # use boa_engine::{ -/// # object::{JsArrayBuffer, JsDataView}, +/// # object::js_object::{JsArrayBuffer, JsDataView}, /// # Context, JsValue /// # }; /// diff --git a/boa_engine/src/object/mod.rs b/boa_engine/src/object/mod.rs index 7a4435e47bb..e536a57b262 100644 --- a/boa_engine/src/object/mod.rs +++ b/boa_engine/src/object/mod.rs @@ -84,12 +84,13 @@ pub mod js_object { pub use super::jsarray::*; pub use super::jsarraybuffer::*; + pub use super::jsdataview::*; pub use super::jsfunction::*; pub use super::jsmap::*; pub use super::jsobject::JsObject; pub use super::jsproxy::{JsProxy, JsRevocableProxy}; + pub use super::jsset::*; pub use super::jstypedarray::*; - pub use super::jsdataview::*; } pub(crate) use js_object::*; diff --git a/boa_examples/src/bin/jsarraybuffer.rs b/boa_examples/src/bin/jsarraybuffer.rs index fd5e148f4a4..17eb3dd132d 100644 --- a/boa_examples/src/bin/jsarraybuffer.rs +++ b/boa_examples/src/bin/jsarraybuffer.rs @@ -1,7 +1,7 @@ // This example shows how to manipulate a Javascript array using Rust code. use boa_engine::{ - object::js_object::{JsArrayBuffer, JsDataView, JsUint32Array, js_object::JsUint8Array}, + object::js_object::{JsArrayBuffer, JsDataView, JsUint32Array, JsUint8Array}, property::Attribute, Context, JsResult, JsValue, }; From 0e7924812220164bb437b474e97157343f050b8d Mon Sep 17 00:00:00 2001 From: Calli Date: Sat, 8 Oct 2022 15:12:10 +0200 Subject: [PATCH 4/4] Implemented requested changes --- boa_engine/src/lib.rs | 2 +- .../src/object/{ => builtins}/jsarray.rs | 0 .../object/{ => builtins}/jsarraybuffer.rs | 0 .../src/object/{ => builtins}/jsdataview.rs | 2 +- .../src/object/{ => builtins}/jsfunction.rs | 0 boa_engine/src/object/{ => builtins}/jsmap.rs | 24 ++++++------- .../object/{ => builtins}/jsmap_iterator.rs | 0 .../src/object/{ => builtins}/jsproxy.rs | 3 +- boa_engine/src/object/{ => builtins}/jsset.rs | 0 .../object/{ => builtins}/jsset_iterator.rs | 0 .../src/object/{ => builtins}/jstypedarray.rs | 0 boa_engine/src/object/builtins/mod.rs | 23 +++++++++++++ boa_engine/src/object/mod.rs | 34 ++++--------------- boa_examples/src/bin/closures.rs | 2 +- boa_examples/src/bin/jsarray.rs | 2 +- boa_examples/src/bin/jsarraybuffer.rs | 2 +- boa_examples/src/bin/jsmap.rs | 2 +- boa_examples/src/bin/jsset.rs | 2 +- boa_examples/src/bin/jstypedarray.rs | 2 +- boa_tester/src/exec/js262.rs | 2 +- 20 files changed, 52 insertions(+), 50 deletions(-) rename boa_engine/src/object/{ => builtins}/jsarray.rs (100%) rename boa_engine/src/object/{ => builtins}/jsarraybuffer.rs (100%) rename boa_engine/src/object/{ => builtins}/jsdataview.rs (99%) rename boa_engine/src/object/{ => builtins}/jsfunction.rs (100%) rename boa_engine/src/object/{ => builtins}/jsmap.rs (95%) rename boa_engine/src/object/{ => builtins}/jsmap_iterator.rs (100%) rename boa_engine/src/object/{ => builtins}/jsproxy.rs (99%) rename boa_engine/src/object/{ => builtins}/jsset.rs (100%) rename boa_engine/src/object/{ => builtins}/jsset_iterator.rs (100%) rename boa_engine/src/object/{ => builtins}/jstypedarray.rs (100%) create mode 100644 boa_engine/src/object/builtins/mod.rs diff --git a/boa_engine/src/lib.rs b/boa_engine/src/lib.rs index a6d3ce758c5..9e6e3ea26ce 100644 --- a/boa_engine/src/lib.rs +++ b/boa_engine/src/lib.rs @@ -96,7 +96,7 @@ mod tests; /// A convenience module that re-exports the most commonly-used Boa APIs pub mod prelude { - pub use crate::{object::js_object::JsObject, Context, JsBigInt, JsResult, JsString, JsValue}; + pub use crate::{object::JsObject, Context, JsBigInt, JsResult, JsString, JsValue}; } use std::result::Result as StdResult; diff --git a/boa_engine/src/object/jsarray.rs b/boa_engine/src/object/builtins/jsarray.rs similarity index 100% rename from boa_engine/src/object/jsarray.rs rename to boa_engine/src/object/builtins/jsarray.rs diff --git a/boa_engine/src/object/jsarraybuffer.rs b/boa_engine/src/object/builtins/jsarraybuffer.rs similarity index 100% rename from boa_engine/src/object/jsarraybuffer.rs rename to boa_engine/src/object/builtins/jsarraybuffer.rs diff --git a/boa_engine/src/object/jsdataview.rs b/boa_engine/src/object/builtins/jsdataview.rs similarity index 99% rename from boa_engine/src/object/jsdataview.rs rename to boa_engine/src/object/builtins/jsdataview.rs index c0aa551c180..2f15fa3db82 100644 --- a/boa_engine/src/object/jsdataview.rs +++ b/boa_engine/src/object/builtins/jsdataview.rs @@ -17,7 +17,7 @@ use std::ops::Deref; /// # Examples /// ``` /// # use boa_engine::{ -/// # object::js_object::{JsArrayBuffer, JsDataView}, +/// # object::builtins::{JsArrayBuffer, JsDataView}, /// # Context, JsValue /// # }; /// diff --git a/boa_engine/src/object/jsfunction.rs b/boa_engine/src/object/builtins/jsfunction.rs similarity index 100% rename from boa_engine/src/object/jsfunction.rs rename to boa_engine/src/object/builtins/jsfunction.rs diff --git a/boa_engine/src/object/jsmap.rs b/boa_engine/src/object/builtins/jsmap.rs similarity index 95% rename from boa_engine/src/object/jsmap.rs rename to boa_engine/src/object/builtins/jsmap.rs index 2a3c35589d1..a689c87659e 100644 --- a/boa_engine/src/object/jsmap.rs +++ b/boa_engine/src/object/builtins/jsmap.rs @@ -16,7 +16,7 @@ use std::ops::Deref; /// Create a `JsMap` and set a new entry /// ``` /// # use boa_engine::{ -/// # object::js_object::JsMap, +/// # object::builtins::JsMap, /// # Context, JsValue, /// # }; /// @@ -37,7 +37,7 @@ use std::ops::Deref; /// Create a `JsMap` from a `JsArray` /// ``` /// # use boa_engine::{ -/// # object::js_object::{JsArray, JsMap}, +/// # object::builtins::{JsArray, JsMap}, /// # Context, JsValue, /// # }; /// @@ -72,7 +72,7 @@ impl JsMap { /// /// ``` /// # use boa_engine::{ - /// # object::js_object::JsMap, + /// # object::builtins::JsMap, /// # Context, JsValue, /// # }; /// @@ -94,7 +94,7 @@ impl JsMap { /// # Examples /// ``` /// # use boa_engine::{ - /// # object::js_object::{JsArray, JsMap}, + /// # object::builtins::{JsArray, JsMap}, /// # Context, JsResult, JsValue, /// # }; /// @@ -136,7 +136,7 @@ impl JsMap { /// ``` /// # use boa_engine::{ /// # builtins::map::ordered_map::OrderedMap, - /// # object::{js_object::{JsObject, JsMap}, ObjectData}, + /// # object::{builtins::JsMap, JsObject, ObjectData}, /// # Context, JsValue, /// # }; /// @@ -156,7 +156,7 @@ impl JsMap { /// Invalid Example - returns a `TypeError` with the message "object is not a Map" /// ``` /// # use boa_engine::{ - /// # object::js_object::{JsObject, JsArray, JsMap}, + /// # object::{JsObject, builtins::{JsArray, JsMap}}, /// # Context, JsResult, JsValue, /// # }; /// @@ -210,7 +210,7 @@ impl JsMap { /// /// ``` /// # use boa_engine::{ - /// # object::js_object::JsMap, + /// # object::builtins::JsMap, /// # Context, JsValue, /// # }; /// @@ -244,7 +244,7 @@ impl JsMap { /// /// ``` /// # use boa_engine::{ - /// # object::js_object::JsMap, + /// # object::builtins::JsMap, /// # Context, JsValue, /// # }; /// @@ -270,7 +270,7 @@ impl JsMap { /// /// ``` /// # use boa_engine::{ - /// # object::js_object::JsMap, + /// # object::builtins::JsMap, /// # Context, JsValue, /// # }; /// @@ -300,7 +300,7 @@ impl JsMap { /// /// ``` /// # use boa_engine::{ - /// # object::js_object::JsMap, + /// # object::builtins::JsMap, /// # Context, JsValue, /// # }; /// @@ -327,7 +327,7 @@ impl JsMap { /// /// ``` /// # use boa_engine::{ - /// # object::js_object::JsMap, + /// # object::builtins::JsMap, /// # Context, JsValue, /// # }; /// @@ -353,7 +353,7 @@ impl JsMap { /// /// ``` /// # use boa_engine::{ - /// # object::js_object::JsMap, + /// # object::builtins::JsMap, /// # Context, JsValue, /// # }; /// diff --git a/boa_engine/src/object/jsmap_iterator.rs b/boa_engine/src/object/builtins/jsmap_iterator.rs similarity index 100% rename from boa_engine/src/object/jsmap_iterator.rs rename to boa_engine/src/object/builtins/jsmap_iterator.rs diff --git a/boa_engine/src/object/jsproxy.rs b/boa_engine/src/object/builtins/jsproxy.rs similarity index 99% rename from boa_engine/src/object/jsproxy.rs rename to boa_engine/src/object/builtins/jsproxy.rs index ad9a65867d6..760d68e7208 100644 --- a/boa_engine/src/object/jsproxy.rs +++ b/boa_engine/src/object/builtins/jsproxy.rs @@ -2,10 +2,11 @@ use boa_gc::{Finalize, Trace}; use crate::{ builtins::{function::NativeFunctionSignature, Proxy}, + object::{FunctionBuilder, JsObject, JsObjectType, ObjectData}, Context, JsResult, JsValue, }; -use super::{FunctionBuilder, JsFunction, JsObject, JsObjectType, ObjectData}; +use super::JsFunction; /// JavaScript [`Proxy`][proxy] rust object. /// diff --git a/boa_engine/src/object/jsset.rs b/boa_engine/src/object/builtins/jsset.rs similarity index 100% rename from boa_engine/src/object/jsset.rs rename to boa_engine/src/object/builtins/jsset.rs diff --git a/boa_engine/src/object/jsset_iterator.rs b/boa_engine/src/object/builtins/jsset_iterator.rs similarity index 100% rename from boa_engine/src/object/jsset_iterator.rs rename to boa_engine/src/object/builtins/jsset_iterator.rs diff --git a/boa_engine/src/object/jstypedarray.rs b/boa_engine/src/object/builtins/jstypedarray.rs similarity index 100% rename from boa_engine/src/object/jstypedarray.rs rename to boa_engine/src/object/builtins/jstypedarray.rs diff --git a/boa_engine/src/object/builtins/mod.rs b/boa_engine/src/object/builtins/mod.rs new file mode 100644 index 00000000000..5c1b24b3d2b --- /dev/null +++ b/boa_engine/src/object/builtins/mod.rs @@ -0,0 +1,23 @@ +//! Contains all the Rust representations of JavaScript objects. + +mod jsarray; +mod jsarraybuffer; +mod jsdataview; +mod jsfunction; +mod jsmap; +mod jsmap_iterator; +pub(crate) mod jsproxy; +mod jsset; +mod jsset_iterator; +mod jstypedarray; + +pub use jsarray::*; +pub use jsarraybuffer::*; +pub use jsdataview::*; +pub use jsfunction::*; +pub use jsmap::*; +pub use jsmap_iterator::*; +pub use jsproxy::{JsProxy, JsRevocableProxy}; +pub use jsset::*; +pub use jsset_iterator::*; +pub use jstypedarray::*; diff --git a/boa_engine/src/object/mod.rs b/boa_engine/src/object/mod.rs index e536a57b262..05357100284 100644 --- a/boa_engine/src/object/mod.rs +++ b/boa_engine/src/object/mod.rs @@ -1,4 +1,4 @@ -//! This module implements the Rust representation of a JavaScript object, see [js_object] for implementors. +//! This module implements the Rust representation of a JavaScript object, see object::[builtins] for implementors. //! //! This module also provides helper objects for working with JavaScript objects. @@ -65,38 +65,16 @@ use std::{ mod tests; pub(crate) mod internal_methods; -mod jsarray; -mod jsarraybuffer; -mod jsdataview; -mod jsfunction; -mod jsmap; -mod jsmap_iterator; + +pub mod builtins; mod jsobject; -mod jsproxy; -mod jsset; -mod jsset_iterator; -mod jstypedarray; mod operations; mod property_map; -pub mod js_object { - //! Contains all the Rust representations of JavaScript objects. - - pub use super::jsarray::*; - pub use super::jsarraybuffer::*; - pub use super::jsdataview::*; - pub use super::jsfunction::*; - pub use super::jsmap::*; - pub use super::jsobject::JsObject; - pub use super::jsproxy::{JsProxy, JsRevocableProxy}; - pub use super::jsset::*; - pub use super::jstypedarray::*; -} -pub(crate) use js_object::*; +pub(crate) use builtins::*; -pub use jsmap_iterator::*; -pub use jsproxy::JsProxyBuilder; -pub use jsset_iterator::*; +pub use builtins::jsproxy::JsProxyBuilder; +pub use jsobject::*; pub(crate) trait JsObjectType: Into + Into + Deref diff --git a/boa_examples/src/bin/closures.rs b/boa_examples/src/bin/closures.rs index ab1bfa7b98d..2c453e40702 100644 --- a/boa_examples/src/bin/closures.rs +++ b/boa_examples/src/bin/closures.rs @@ -2,7 +2,7 @@ // inside Rust and call them from Javascript. use boa_engine::{ - object::{js_object::JsObject, FunctionBuilder}, + object::{FunctionBuilder, JsObject}, property::{Attribute, PropertyDescriptor}, Context, JsString, JsValue, }; diff --git a/boa_examples/src/bin/jsarray.rs b/boa_examples/src/bin/jsarray.rs index af07e55c8e5..1159a57dbd2 100644 --- a/boa_examples/src/bin/jsarray.rs +++ b/boa_examples/src/bin/jsarray.rs @@ -1,7 +1,7 @@ // This example shows how to manipulate a Javascript array using Rust code. use boa_engine::{ - object::{js_object::JsArray, FunctionBuilder}, + object::{builtins::JsArray, FunctionBuilder}, Context, JsResult, JsValue, }; diff --git a/boa_examples/src/bin/jsarraybuffer.rs b/boa_examples/src/bin/jsarraybuffer.rs index 17eb3dd132d..f0c0d8306ee 100644 --- a/boa_examples/src/bin/jsarraybuffer.rs +++ b/boa_examples/src/bin/jsarraybuffer.rs @@ -1,7 +1,7 @@ // This example shows how to manipulate a Javascript array using Rust code. use boa_engine::{ - object::js_object::{JsArrayBuffer, JsDataView, JsUint32Array, JsUint8Array}, + object::builtins::{JsArrayBuffer, JsDataView, JsUint32Array, JsUint8Array}, property::Attribute, Context, JsResult, JsValue, }; diff --git a/boa_examples/src/bin/jsmap.rs b/boa_examples/src/bin/jsmap.rs index 809301cd3a6..928d8c66722 100644 --- a/boa_examples/src/bin/jsmap.rs +++ b/boa_examples/src/bin/jsmap.rs @@ -1,5 +1,5 @@ use boa_engine::{ - object::{js_object::JsArray, js_object::JsMap}, + object::{builtins::JsArray, builtins::JsMap}, Context, JsResult, JsValue, }; diff --git a/boa_examples/src/bin/jsset.rs b/boa_examples/src/bin/jsset.rs index a8abc7aa1a8..b9cc0f424bb 100644 --- a/boa_examples/src/bin/jsset.rs +++ b/boa_examples/src/bin/jsset.rs @@ -1,6 +1,6 @@ // This example shows how to manipulate a Javascript Set using Rust code. #![allow(clippy::bool_assert_comparison)] -use boa_engine::{object::js_object::JsSet, Context, JsValue}; +use boa_engine::{object::builtins::JsSet, Context, JsValue}; fn main() -> Result<(), JsValue> { // New `Context` for a new Javascript executor. diff --git a/boa_examples/src/bin/jstypedarray.rs b/boa_examples/src/bin/jstypedarray.rs index 578f762ab7d..cf9f1cdfb09 100644 --- a/boa_examples/src/bin/jstypedarray.rs +++ b/boa_examples/src/bin/jstypedarray.rs @@ -1,7 +1,7 @@ // This example shows how to manipulate a Javascript array using Rust code. use boa_engine::{ - object::{js_object::JsUint8Array, FunctionBuilder}, + object::{builtins::JsUint8Array, FunctionBuilder}, property::Attribute, Context, JsResult, JsValue, }; diff --git a/boa_tester/src/exec/js262.rs b/boa_tester/src/exec/js262.rs index 4071968d994..f6ad73dd210 100644 --- a/boa_tester/src/exec/js262.rs +++ b/boa_tester/src/exec/js262.rs @@ -1,6 +1,6 @@ use boa_engine::{ builtins::JsArgs, - object::{js_object::JsObject, ObjectInitializer}, + object::{JsObject, ObjectInitializer}, property::Attribute, Context, JsResult, JsValue, };