Skip to content

Commit

Permalink
Trying to clean Rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
lameferret committed Jul 6, 2022
1 parent 7aa86c1 commit 694a4e7
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 95 deletions.
13 changes: 0 additions & 13 deletions boa_engine/src/builtins/set/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,22 +164,13 @@ impl Set {
Ok(set.into())
}

<<<<<<< HEAD
/// Utility for constructing `Set` objects.
pub(crate) fn set_create(prototype: Option<JsObject>, context: &mut Context) -> JsObject {
=======
/// Utility for constructing `Set` Objects.
pub(crate) fn set_create(
prototype: Option<JsObject>,
context: &mut Context,
) -> JsResult<JsObject> {
>>>>>>> 5b5551f2b6 (Safe wrapper for `JsSet`)
let prototype = match prototype {
Some(prototype) => prototype,
None => context.intrinsics().constructors().set().prototype(),
};

<<<<<<< HEAD
JsObject::from_proto_and_data(prototype, ObjectData::set(OrderedSet::new()))
}

Expand All @@ -197,10 +188,6 @@ impl Set {
}

set
=======
let set = JsObject::from_proto_and_data(prototype, ObjectData::set(OrderedSet::new()));
Ok(set)
>>>>>>> 5b5551f2b6 (Safe wrapper for `JsSet`)
}

/// `get Set [ @@species ]`
Expand Down
56 changes: 0 additions & 56 deletions boa_engine/src/object/jsset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,7 @@ use boa_gc::{Finalize, Trace};

use crate::{
builtins::Set,
<<<<<<< HEAD
<<<<<<< HEAD
object::{JsFunction, JsObject, JsObjectType, JsSetIterator},
=======
object::{JsObject, JsObjectType},
>>>>>>> 5b5551f2b6 (Safe wrapper for `JsSet`)
=======
object::{JsFunction, JsObject, JsObjectType, JsSetIterator},
>>>>>>> 5adeddf912 (Add `entries()`, `values()`, `keys()`, and `JsSetIterator` wrapper)
Context, JsResult, JsValue,
};

Expand All @@ -29,12 +21,7 @@ impl JsSet {
/// similar to Rust initialization.
#[inline]
pub fn new(context: &mut Context) -> Self {
<<<<<<< HEAD
let inner = Set::set_create(None, context);
=======
let inner = Set::set_create(None, context)
.expect("creating an empty set with the default prototype must not fail");
>>>>>>> 5b5551f2b6 (Safe wrapper for `JsSet`)

Self { inner }
}
Expand All @@ -47,7 +34,6 @@ impl JsSet {
Set::get_size(&self.inner.clone().into(), context)
}

<<<<<<< HEAD
/// Appends value to the Set object.
/// Returns the Set object with added value.
///
Expand All @@ -74,43 +60,16 @@ impl JsSet {
///
/// Same as JavaScript's `set.clear()`.
#[inline]
=======
/// Add an element to `Set` and returns `Set` with value appended to the end.
///
/// Same as JavaScript's `set.add(value)`.
#[inline]
pub fn add<T>(&self, value: T, context: &mut Context) -> JsResult<Self>
where
T: Into<JsValue>,
{
let object = Set::add(&self.inner.clone().into(), &[value.into()], context)?
.as_object()
.cloned()
.expect("Set.prototype.add should always return `Set` object.");

Self::from_object(object, context)
}

/// Removes all the elements for the `Set` and returns `Undefined`.
///
/// Same as JavaScript's `set.clear()`.
>>>>>>> 5b5551f2b6 (Safe wrapper for `JsSet`)
pub fn clear(&self, context: &mut Context) -> JsResult<JsValue> {
Set::clear(&self.inner.clone().into(), &[JsValue::Null], context)
}

<<<<<<< HEAD
/// Removes the element associated to the value.
/// Returns a boolean asserting whether an element was
/// successfully removed or not.
///
/// Same as JavaScript's `set.delete(value)`.
#[inline]
=======
/// Removes given value from the `Set` and returns `Bool`.
///
/// Same as JavaScript's `set.delete(value)`.
>>>>>>> 5b5551f2b6 (Safe wrapper for `JsSet`)
pub fn delete<T>(&self, value: T, context: &mut Context) -> JsResult<bool>
where
T: Into<JsValue>,
Expand All @@ -121,17 +80,11 @@ impl JsSet {
}
}

<<<<<<< HEAD
/// Returns a boolean asserting whether an element is present
/// with the given value in the Set object or not.
///
/// Same as JavaScript's `set.has(value)`.
#[inline]
=======
/// Checks if given value is in the `Set` and returns `Bool`.
///
/// Same as JavaScript's `set.has(value)`.
>>>>>>> 5b5551f2b6 (Safe wrapper for `JsSet`)
pub fn has<T>(&self, value: T, context: &mut Context) -> JsResult<bool>
where
T: Into<JsValue>,
Expand All @@ -142,10 +95,6 @@ impl JsSet {
}
}

<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> 5adeddf912 (Add `entries()`, `values()`, `keys()`, and `JsSetIterator` wrapper)
/// Returns a new iterator object that yields the values
/// for each element in the Set object in insertion order.
///
Expand Down Expand Up @@ -190,8 +139,6 @@ impl JsSet {
)
}

=======
>>>>>>> 5b5551f2b6 (Safe wrapper for `JsSet`)
/// Utility: Creates `JsSet` from `JsObject`, if not a Set throw `TypeError`.
#[inline]
pub fn from_object(object: JsObject, context: &mut Context) -> JsResult<Self> {
Expand All @@ -201,7 +148,6 @@ impl JsSet {
context.throw_error("Object is not a Set")
}
}
<<<<<<< HEAD

/// Utility: Creates a `JsSet` from a `<IntoIterator<Item = JsValue>` convertible object.
#[inline]
Expand All @@ -212,8 +158,6 @@ impl JsSet {
let inner = Set::create_set_from_list(elements, context);
Self { inner }
}
=======
>>>>>>> 5b5551f2b6 (Safe wrapper for `JsSet`)
}

impl From<JsSet> for JsObject {
Expand Down
14 changes: 0 additions & 14 deletions boa_engine/src/object/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,7 @@ mod jsmap_iterator;
mod jsobject;
mod jsproxy;
mod jsset;
<<<<<<< HEAD
<<<<<<< HEAD
mod jsset_iterator;
=======
>>>>>>> 5b5551f2b6 (Safe wrapper for `JsSet`)
=======
mod jsset_iterator;
>>>>>>> 5adeddf912 (Add `entries()`, `values()`, `keys()`, and `JsSetIterator` wrapper)
mod jstypedarray;
mod operations;
mod property_map;
Expand All @@ -86,14 +79,7 @@ pub use jsmap::*;
pub use jsmap_iterator::*;
pub use jsproxy::*;
pub use jsset::*;
<<<<<<< HEAD
<<<<<<< HEAD
pub use jsset_iterator::*;
=======
>>>>>>> 5b5551f2b6 (Safe wrapper for `JsSet`)
=======
pub use jsset_iterator::*;
>>>>>>> 5adeddf912 (Add `entries()`, `values()`, `keys()`, and `JsSetIterator` wrapper)
pub use jstypedarray::*;

pub(crate) trait JsObjectType:
Expand Down
12 changes: 0 additions & 12 deletions boa_examples/src/bin/jsset.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
<<<<<<< HEAD
// This example shows how to manipulate a Javascript Set using Rust code.
#![allow(clippy::bool_assert_comparison)]
=======
// This example shows how to manipulate a Javascript set using Rust code.

>>>>>>> 5b5551f2b6 (Safe wrapper for `JsSet`)
use boa_engine::{object::JsSet, Context, JsValue};

fn main() -> Result<(), JsValue> {
Expand All @@ -26,11 +21,7 @@ fn main() -> Result<(), JsValue> {
set.add("two", context)?;
set.add("three", context)?;

<<<<<<< HEAD
assert!(set.has("one", context)?);
=======
assert_eq!(set.has("one", context)?, true);
>>>>>>> 5b5551f2b6 (Safe wrapper for `JsSet`)
assert_eq!(set.has("One", context)?, false);

set.delete("two", context)?;
Expand All @@ -43,7 +34,6 @@ fn main() -> Result<(), JsValue> {
assert_eq!(set.has("three", context)?, false);
assert_eq!(set.size(context)?, 0);

<<<<<<< HEAD
// Add a slice into a set;
set.add_items(
&[JsValue::new(1), JsValue::new(2), JsValue::new(3)],
Expand All @@ -58,8 +48,6 @@ fn main() -> Result<(), JsValue> {
assert_eq!(slice_set.size(context)?, 3);

set.clear(context)?;
=======
>>>>>>> 5b5551f2b6 (Safe wrapper for `JsSet`)

Ok(())
}

0 comments on commit 694a4e7

Please sign in to comment.