From da8cbf77be667a235693a14a6097e507bc427046 Mon Sep 17 00:00:00 2001 From: HalidOdat Date: Fri, 1 Apr 2022 16:39:31 +0200 Subject: [PATCH] Expose raw builtin functions --- .../src/builtins/array/array_iterator.rs | 2 +- boa_engine/src/builtins/array/mod.rs | 178 ++++-------------- boa_engine/src/builtins/array_buffer/mod.rs | 14 +- boa_engine/src/builtins/bigint/mod.rs | 26 +-- boa_engine/src/builtins/boolean/mod.rs | 16 +- boa_engine/src/builtins/dataview/mod.rs | 80 +++----- boa_engine/src/builtins/date/mod.rs | 8 +- boa_engine/src/builtins/error/aggregate.rs | 4 +- boa_engine/src/builtins/error/eval.rs | 4 +- boa_engine/src/builtins/error/mod.rs | 24 +-- boa_engine/src/builtins/error/range.rs | 4 +- boa_engine/src/builtins/error/reference.rs | 4 +- boa_engine/src/builtins/error/syntax.rs | 4 +- boa_engine/src/builtins/error/type.rs | 4 +- boa_engine/src/builtins/error/uri.rs | 4 +- boa_engine/src/builtins/function/mod.rs | 16 +- boa_engine/src/builtins/generator/mod.rs | 24 +-- .../src/builtins/generator_function/mod.rs | 2 +- boa_engine/src/builtins/json/mod.rs | 10 +- boa_engine/src/builtins/map/mod.rs | 58 ++---- boa_engine/src/builtins/math/mod.rs | 76 ++++---- boa_engine/src/builtins/mod.rs | 40 ++-- boa_engine/src/builtins/number/mod.rs | 60 ++---- boa_engine/src/builtins/object/mod.rs | 2 +- boa_engine/src/builtins/proxy/mod.rs | 4 +- boa_engine/src/builtins/reflect/mod.rs | 36 ++-- boa_engine/src/builtins/regexp/mod.rs | 90 ++------- boa_engine/src/builtins/set/mod.rs | 42 +---- boa_engine/src/builtins/string/mod.rs | 168 ++++------------- boa_engine/src/builtins/symbol/mod.rs | 32 +--- boa_engine/src/builtins/typed_array/mod.rs | 82 ++++---- test262 | 2 +- 32 files changed, 349 insertions(+), 771 deletions(-) diff --git a/boa_engine/src/builtins/array/array_iterator.rs b/boa_engine/src/builtins/array/array_iterator.rs index 2820337b1e9..1444091f301 100644 --- a/boa_engine/src/builtins/array/array_iterator.rs +++ b/boa_engine/src/builtins/array/array_iterator.rs @@ -66,7 +66,7 @@ impl ArrayIterator { /// - [ECMA reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next - pub(crate) fn next(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + pub fn next(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { let mut array_iterator = this.as_object().map(JsObject::borrow_mut); let array_iterator = array_iterator .as_mut() diff --git a/boa_engine/src/builtins/array/mod.rs b/boa_engine/src/builtins/array/mod.rs index bb8a9547c9f..33bb89a27ae 100644 --- a/boa_engine/src/builtins/array/mod.rs +++ b/boa_engine/src/builtins/array/mod.rs @@ -36,7 +36,7 @@ use std::cmp::{max, min, Ordering}; /// JavaScript `Array` built-in implementation. #[derive(Debug, Clone, Copy)] -pub(crate) struct Array; +pub struct Array; impl BuiltIn for Array { const NAME: &'static str = "Array"; @@ -126,7 +126,7 @@ impl BuiltIn for Array { impl Array { const LENGTH: usize = 1; - fn constructor( + pub fn constructor( new_target: &JsValue, args: &[JsValue], context: &mut Context, @@ -308,7 +308,7 @@ impl Array { /// [spec]: https://tc39.es/ecma262/#sec-get-array-@@species /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/@@species #[allow(clippy::unnecessary_wraps)] - fn get_species(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { + pub fn get_species(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Return the this value. Ok(this.clone()) } @@ -381,11 +381,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.from /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from - pub(crate) fn from( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn from(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let items = args.get_or_undefined(0); let mapfn = args.get_or_undefined(1); let this_arg = args.get_or_undefined(2); @@ -543,11 +539,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.isarray /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray - pub(crate) fn is_array( - _: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn is_array(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Return ? IsArray(arg). args.get_or_undefined(0).is_array(context).map(Into::into) } @@ -563,7 +555,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.of /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of - pub(crate) fn of(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn of(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let len be the number of elements in items. // 2. Let lenNumber be 𝔽(len). let len = args.len(); @@ -613,7 +605,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.at /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at - pub(crate) fn at(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn at(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { //1. let O be ? ToObject(this value) let obj = this.to_object(context)?; //2. let len be ? LengthOfArrayLike(O) @@ -650,11 +642,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.concat /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat - pub(crate) fn concat( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn concat(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? ToObject(this value). let obj = this.to_object(context)?; // 2. Let A be ? ArraySpeciesCreate(O, 0). @@ -729,11 +717,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.push /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push - pub(crate) fn push( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn push(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; // 2. Let len be ? LengthOfArrayLike(O). @@ -769,7 +753,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.pop /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop - pub(crate) fn pop(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + pub fn pop(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; // 2. Let len be ? LengthOfArrayLike(O). @@ -808,11 +792,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.foreach /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach - pub(crate) fn for_each( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn for_each(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; // 2. Let len be ? LengthOfArrayLike(O). @@ -854,11 +834,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.join /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join - pub(crate) fn join( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn join(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; // 2. Let len be ? LengthOfArrayLike(O). @@ -910,11 +886,7 @@ impl Array { /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.tostring /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString #[allow(clippy::wrong_self_convention)] - pub(crate) fn to_string( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn to_string(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let array be ? ToObject(this value). let array = this.to_object(context)?; // 2. Let func be ? Get(array, "join"). @@ -940,11 +912,7 @@ impl Array { /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.reverse /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse #[allow(clippy::else_if_without_else)] - pub(crate) fn reverse( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn reverse(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; // 2. Let len be ? LengthOfArrayLike(O). @@ -1021,7 +989,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.shift /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift - pub(crate) fn shift(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + pub fn shift(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; // 2. Let len be ? LengthOfArrayLike(O). @@ -1078,11 +1046,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.unshift /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift - pub(crate) fn unshift( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn unshift(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; // 2. Let len be ? LengthOfArrayLike(O). @@ -1149,11 +1113,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.every /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every - pub(crate) fn every( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn every(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; // 2. Let len be ? LengthOfArrayLike(O). @@ -1201,11 +1161,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.map /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map - pub(crate) fn map( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn map(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; // 2. Let len be ? LengthOfArrayLike(O). @@ -1250,11 +1206,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.indexof /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf - pub(crate) fn index_of( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn index_of(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -1337,7 +1289,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.lastindexof /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf - pub(crate) fn last_index_of( + pub fn last_index_of( this: &JsValue, args: &[JsValue], context: &mut Context, @@ -1407,11 +1359,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.find /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find - pub(crate) fn find( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn find(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -1464,7 +1412,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.findindex /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex - pub(crate) fn find_index( + pub fn find_index( this: &JsValue, args: &[JsValue], context: &mut Context, @@ -1515,11 +1463,7 @@ impl Array { /// - [ECMAScript proposal][spec] /// /// [spec]: https://tc39.es/proposal-array-find-from-last/#sec-array.prototype.findlast - pub(crate) fn find_last( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn find_last(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -1567,7 +1511,7 @@ impl Array { /// - [ECMAScript proposal][spec] /// /// [spec]: https://tc39.es/proposal-array-find-from-last/#sec-array.prototype.findlastindex - pub(crate) fn find_last_index( + pub fn find_last_index( this: &JsValue, args: &[JsValue], context: &mut Context, @@ -1616,11 +1560,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.flat /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat - pub(crate) fn flat( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn flat(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ToObject(this value) let o = this.to_object(context)?; @@ -1672,11 +1612,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.flatMap /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap - pub(crate) fn flat_map( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn flat_map(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ToObject(this value) let o = this.to_object(context)?; @@ -1831,11 +1767,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.fill /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill - pub(crate) fn fill( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn fill(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -1879,7 +1811,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.includes /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes - pub(crate) fn includes_value( + pub fn includes_value( this: &JsValue, args: &[JsValue], context: &mut Context, @@ -1956,11 +1888,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.slice /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice - pub(crate) fn slice( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn slice(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -2018,11 +1946,7 @@ impl Array { /// Splices an array by following /// The deleteCount elements of the array starting at integer index start are replaced by the elements of items. /// An Array object containing the deleted elements (if any) is returned. - pub(crate) fn splice( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn splice(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; // 2. Let len be ? LengthOfArrayLike(O). @@ -2201,11 +2125,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.filter /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter - pub(crate) fn filter( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn filter(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -2267,11 +2187,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.some /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some - pub(crate) fn some( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn some(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; // 2. Let len be ? LengthOfArrayLike(O). @@ -2319,11 +2235,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.sort /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort - pub(crate) fn sort( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn sort(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. If comparefn is not undefined and IsCallable(comparefn) is false, throw a TypeError exception. let comparefn = match args.get_or_undefined(0) { JsValue::Object(ref obj) if obj.is_callable() => Some(obj), @@ -2450,11 +2362,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.reduce /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce - pub(crate) fn reduce( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn reduce(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -2545,7 +2453,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.reduceright /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight - pub(crate) fn reduce_right( + pub fn reduce_right( this: &JsValue, args: &[JsValue], context: &mut Context, @@ -2640,7 +2548,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.copywithin /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin - pub(crate) fn copy_within( + pub fn copy_within( this: &JsValue, args: &[JsValue], context: &mut Context, @@ -2730,11 +2638,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.values /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/values - pub(crate) fn values( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn values(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -2756,7 +2660,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.keys /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/values - pub(crate) fn keys(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + pub fn keys(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -2778,11 +2682,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.entries /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/values - pub(crate) fn entries( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn entries(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; diff --git a/boa_engine/src/builtins/array_buffer/mod.rs b/boa_engine/src/builtins/array_buffer/mod.rs index d05e7b82400..3e65f8d5a6d 100644 --- a/boa_engine/src/builtins/array_buffer/mod.rs +++ b/boa_engine/src/builtins/array_buffer/mod.rs @@ -78,7 +78,7 @@ impl ArrayBuffer { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-arraybuffer-length - fn constructor( + pub fn constructor( new_target: &JsValue, args: &[JsValue], context: &mut Context, @@ -103,7 +103,7 @@ impl ArrayBuffer { /// /// [spec]: https://tc39.es/ecma262/#sec-get-arraybuffer-@@species #[allow(clippy::unnecessary_wraps)] - fn get_species(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { + pub fn get_species(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Return the this value. Ok(this.clone()) } @@ -115,7 +115,7 @@ impl ArrayBuffer { /// /// [spec]: https://tc39.es/ecma262/#sec-arraybuffer.isview #[allow(clippy::unnecessary_wraps)] - fn is_view(_: &JsValue, args: &[JsValue], _context: &mut Context) -> JsResult { + pub fn is_view(_: &JsValue, args: &[JsValue], _context: &mut Context) -> JsResult { // 1. If Type(arg) is not Object, return false. // 2. If arg has a [[ViewedArrayBuffer]] internal slot, return true. // 3. Return false. @@ -133,7 +133,11 @@ impl ArrayBuffer { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-get-arraybuffer.prototype.bytelength - fn byte_length(this: &JsValue, _args: &[JsValue], context: &mut Context) -> JsResult { + pub fn byte_length( + this: &JsValue, + _args: &[JsValue], + context: &mut Context, + ) -> JsResult { // 1. Let O be the this value. // 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]). let obj = if let Some(obj) = this.as_object() { @@ -167,7 +171,7 @@ impl ArrayBuffer { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-arraybuffer.prototype.slice - fn slice(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn slice(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]). let obj = if let Some(obj) = this.as_object() { diff --git a/boa_engine/src/builtins/bigint/mod.rs b/boa_engine/src/builtins/bigint/mod.rs index b5bd14a4e50..d0aa624e85b 100644 --- a/boa_engine/src/builtins/bigint/mod.rs +++ b/boa_engine/src/builtins/bigint/mod.rs @@ -77,7 +77,7 @@ impl BigInt { /// /// [spec]: https://tc39.es/ecma262/#sec-bigint-objects /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/BigInt - fn constructor(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn constructor(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let value = args.get_or_undefined(0); // 2. Let prim be ? ToPrimitive(value, number). @@ -148,11 +148,7 @@ impl BigInt { /// [spec]: https://tc39.es/ecma262/#sec-bigint.prototype.tostring /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/toString #[allow(clippy::wrong_self_convention)] - pub(crate) fn to_string( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn to_string(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let x be ? thisBigIntValue(this value). let x = Self::this_bigint_value(this, context)?; @@ -200,11 +196,7 @@ impl BigInt { /// /// [spec]: https://tc39.es/ecma262/#sec-bigint.prototype.valueof /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/valueOf - pub(crate) fn value_of( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn value_of(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { Ok(JsValue::new(Self::this_bigint_value(this, context)?)) } @@ -215,11 +207,7 @@ impl BigInt { /// [spec]: https://tc39.es/ecma262/#sec-bigint.asintn /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/asIntN #[allow(clippy::wrong_self_convention)] - pub(crate) fn as_int_n( - _: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn as_int_n(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let (modulo, bits) = Self::calculate_as_uint_n(args, context)?; if bits > 0 @@ -246,11 +234,7 @@ impl BigInt { /// [spec]: https://tc39.es/ecma262/#sec-bigint.asuintn /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/asUintN #[allow(clippy::wrong_self_convention)] - pub(crate) fn as_uint_n( - _: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn as_uint_n(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let (modulo, _) = Self::calculate_as_uint_n(args, context)?; Ok(JsValue::new(modulo)) diff --git a/boa_engine/src/builtins/boolean/mod.rs b/boa_engine/src/builtins/boolean/mod.rs index 4377cbd8dab..027c36d8e59 100644 --- a/boa_engine/src/builtins/boolean/mod.rs +++ b/boa_engine/src/builtins/boolean/mod.rs @@ -25,7 +25,7 @@ use tap::{Conv, Pipe}; /// Boolean implementation. #[derive(Debug, Clone, Copy)] -pub(crate) struct Boolean; +pub struct Boolean; impl BuiltIn for Boolean { /// The name of the object. @@ -56,7 +56,7 @@ impl Boolean { /// `[[Construct]]` Create a new boolean object /// /// `[[Call]]` Creates a new boolean primitive - pub(crate) fn constructor( + pub fn constructor( new_target: &JsValue, args: &[JsValue], context: &mut Context, @@ -95,11 +95,7 @@ impl Boolean { /// [spec]: https://tc39.es/ecma262/#sec-boolean-object /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean/toString #[allow(clippy::wrong_self_convention)] - pub(crate) fn to_string( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn to_string(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { let boolean = Self::this_boolean_value(this, context)?; Ok(JsValue::new(boolean.to_string())) } @@ -113,11 +109,7 @@ impl Boolean { /// [spec]: https://tc39.es/ecma262/#sec-boolean.prototype.valueof /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean/valueOf #[inline] - pub(crate) fn value_of( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn value_of(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { Ok(JsValue::new(Self::this_boolean_value(this, context)?)) } } diff --git a/boa_engine/src/builtins/dataview/mod.rs b/boa_engine/src/builtins/dataview/mod.rs index 0bb9b2497c7..d0aedb9dd92 100644 --- a/boa_engine/src/builtins/dataview/mod.rs +++ b/boa_engine/src/builtins/dataview/mod.rs @@ -93,7 +93,7 @@ impl DataView { /// /// [spec]: https://tc39.es/ecma262/#sec-dataview-buffer-byteoffset-bytelength /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/DataView - pub(crate) fn constructor( + pub fn constructor( new_target: &JsValue, args: &[JsValue], context: &mut Context, @@ -187,7 +187,7 @@ impl DataView { /// /// [spec]: https://tc39.es/ecma262/#sec-get-dataview.prototype.buffer /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/buffer - pub(crate) fn get_buffer( + pub fn get_buffer( this: &JsValue, _args: &[JsValue], context: &mut Context, @@ -216,7 +216,7 @@ impl DataView { /// /// [spec]: https://tc39.es/ecma262/#sec-get-dataview.prototype.bytelength /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/byteLength - pub(crate) fn get_byte_length( + pub fn get_byte_length( this: &JsValue, _args: &[JsValue], context: &mut Context, @@ -255,7 +255,7 @@ impl DataView { /// /// [spec]: https://tc39.es/ecma262/#sec-get-dataview.prototype.byteoffset /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/byteOffset - pub(crate) fn get_byte_offset( + pub fn get_byte_offset( this: &JsValue, _args: &[JsValue], context: &mut Context, @@ -362,7 +362,7 @@ impl DataView { /// /// [spec]: https://tc39.es/ecma262/#sec-dataview.prototype.getbigint64 /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getBigInt64 - pub(crate) fn get_big_int64( + pub fn get_big_int64( this: &JsValue, args: &[JsValue], context: &mut Context, @@ -391,7 +391,7 @@ impl DataView { /// /// [spec]: https://tc39.es/ecma262/#sec-dataview.prototype.getbiguint64 /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getBigUint64 - pub(crate) fn get_big_uint64( + pub fn get_big_uint64( this: &JsValue, args: &[JsValue], context: &mut Context, @@ -420,7 +420,7 @@ impl DataView { /// /// [spec]: https://tc39.es/ecma262/#sec-dataview.prototype.getfloat32 /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat32 - pub(crate) fn get_float32( + pub fn get_float32( this: &JsValue, args: &[JsValue], context: &mut Context, @@ -449,7 +449,7 @@ impl DataView { /// /// [spec]: https://tc39.es/ecma262/#sec-dataview.prototype.getfloat64 /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat64 - pub(crate) fn get_float64( + pub fn get_float64( this: &JsValue, args: &[JsValue], context: &mut Context, @@ -478,11 +478,7 @@ impl DataView { /// /// [spec]: https://tc39.es/ecma262/#sec-dataview.prototype.getint8 /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt8 - pub(crate) fn get_int8( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn get_int8(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let byte_offset = args.get_or_undefined(0); let is_little_endian = args.get_or_undefined(1); // 1. Let v be the this value. @@ -507,11 +503,7 @@ impl DataView { /// /// [spec]: https://tc39.es/ecma262/#sec-dataview.prototype.getint16 /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt16 - pub(crate) fn get_int16( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn get_int16(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let byte_offset = args.get_or_undefined(0); let is_little_endian = args.get_or_undefined(1); // 1. Let v be the this value. @@ -536,11 +528,7 @@ impl DataView { /// /// [spec]: https://tc39.es/ecma262/#sec-dataview.prototype.getint32 /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt32 - pub(crate) fn get_int32( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn get_int32(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let byte_offset = args.get_or_undefined(0); let is_little_endian = args.get_or_undefined(1); // 1. Let v be the this value. @@ -565,11 +553,7 @@ impl DataView { /// /// [spec]: https://tc39.es/ecma262/#sec-dataview.prototype.getuint8 /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint8 - pub(crate) fn get_uint8( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn get_uint8(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let byte_offset = args.get_or_undefined(0); let is_little_endian = args.get_or_undefined(1); // 1. Let v be the this value. @@ -594,7 +578,7 @@ impl DataView { /// /// [spec]: https://tc39.es/ecma262/#sec-dataview.prototype.getuint16 /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint16 - pub(crate) fn get_uint16( + pub fn get_uint16( this: &JsValue, args: &[JsValue], context: &mut Context, @@ -623,7 +607,7 @@ impl DataView { /// /// [spec]: https://tc39.es/ecma262/#sec-dataview.prototype.getuint32 /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint32 - pub(crate) fn get_uint32( + pub fn get_uint32( this: &JsValue, args: &[JsValue], context: &mut Context, @@ -730,7 +714,7 @@ impl DataView { /// /// [spec]: https://tc39.es/ecma262/#sec-dataview.prototype.setbigint64 /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setBigInt64 - pub(crate) fn set_big_int64( + pub fn set_big_int64( this: &JsValue, args: &[JsValue], context: &mut Context, @@ -761,7 +745,7 @@ impl DataView { /// /// [spec]: https://tc39.es/ecma262/#sec-dataview.prototype.setbiguint64 /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setBigUint64 - pub(crate) fn set_big_uint64( + pub fn set_big_uint64( this: &JsValue, args: &[JsValue], context: &mut Context, @@ -792,7 +776,7 @@ impl DataView { /// /// [spec]: https://tc39.es/ecma262/#sec-dataview.prototype.setfloat32 /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat32 - pub(crate) fn set_float32( + pub fn set_float32( this: &JsValue, args: &[JsValue], context: &mut Context, @@ -823,7 +807,7 @@ impl DataView { /// /// [spec]: https://tc39.es/ecma262/#sec-dataview.prototype.setfloat64 /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat64 - pub(crate) fn set_float64( + pub fn set_float64( this: &JsValue, args: &[JsValue], context: &mut Context, @@ -854,11 +838,7 @@ impl DataView { /// /// [spec]: https://tc39.es/ecma262/#sec-dataview.prototype.setint8 /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt8 - pub(crate) fn set_int8( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn set_int8(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let byte_offset = args.get_or_undefined(0); let value = args.get_or_undefined(1); let is_little_endian = args.get_or_undefined(2); @@ -885,11 +865,7 @@ impl DataView { /// /// [spec]: https://tc39.es/ecma262/#sec-dataview.prototype.setint16 /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt16 - pub(crate) fn set_int16( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn set_int16(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let byte_offset = args.get_or_undefined(0); let value = args.get_or_undefined(1); let is_little_endian = args.get_or_undefined(2); @@ -916,11 +892,7 @@ impl DataView { /// /// [spec]: https://tc39.es/ecma262/#sec-dataview.prototype.setint32 /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt32 - pub(crate) fn set_int32( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn set_int32(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let byte_offset = args.get_or_undefined(0); let value = args.get_or_undefined(1); let is_little_endian = args.get_or_undefined(2); @@ -947,11 +919,7 @@ impl DataView { /// /// [spec]: https://tc39.es/ecma262/#sec-dataview.prototype.setuint8 /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint8 - pub(crate) fn set_uint8( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn set_uint8(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let byte_offset = args.get_or_undefined(0); let value = args.get_or_undefined(1); let is_little_endian = args.get_or_undefined(2); @@ -978,7 +946,7 @@ impl DataView { /// /// [spec]: https://tc39.es/ecma262/#sec-dataview.prototype.setuint16 /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint16 - pub(crate) fn set_uint16( + pub fn set_uint16( this: &JsValue, args: &[JsValue], context: &mut Context, @@ -1009,7 +977,7 @@ impl DataView { /// /// [spec]: https://tc39.es/ecma262/#sec-dataview.prototype.setuint32 /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint32 - pub(crate) fn set_uint32( + pub fn set_uint32( this: &JsValue, args: &[JsValue], context: &mut Context, diff --git a/boa_engine/src/builtins/date/mod.rs b/boa_engine/src/builtins/date/mod.rs index 9460229aa0f..7910ce29bd3 100644 --- a/boa_engine/src/builtins/date/mod.rs +++ b/boa_engine/src/builtins/date/mod.rs @@ -328,7 +328,7 @@ impl Date { /// /// [spec]: https://tc39.es/ecma262/#sec-date-constructor /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date - pub(crate) fn constructor( + pub fn constructor( new_target: &JsValue, args: &[JsValue], context: &mut Context, @@ -500,7 +500,7 @@ impl Date { /// [spec]: https://tc39.es/ecma262/#sec-date.prototype-@@toprimitive /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/@@toPrimitive #[allow(clippy::wrong_self_convention)] - pub(crate) fn to_primitive( + pub fn to_primitive( this: &JsValue, args: &[JsValue], context: &mut Context, @@ -1820,7 +1820,7 @@ impl Date { /// [spec]: https://tc39.es/ecma262/#sec-date.now /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now #[allow(clippy::unnecessary_wraps)] - pub(crate) fn now(_: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { + pub fn now(_: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Ok(JsValue::new(Utc::now().timestamp_millis() as f64)) } @@ -1836,7 +1836,7 @@ impl Date { /// /// [spec]: https://tc39.es/ecma262/#sec-date.parse /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse - pub(crate) fn parse(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn parse(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // This method is implementation-defined and discouraged, so we just require the same format as the string // constructor. diff --git a/boa_engine/src/builtins/error/aggregate.rs b/boa_engine/src/builtins/error/aggregate.rs index 5c384177c1d..4eea5962343 100644 --- a/boa_engine/src/builtins/error/aggregate.rs +++ b/boa_engine/src/builtins/error/aggregate.rs @@ -22,7 +22,7 @@ use tap::{Conv, Pipe}; use super::Error; #[derive(Debug, Clone, Copy)] -pub(crate) struct AggregateError; +pub struct AggregateError; impl BuiltIn for AggregateError { const NAME: &'static str = "AggregateError"; @@ -61,7 +61,7 @@ impl AggregateError { pub(crate) const LENGTH: usize = 2; /// Create a new aggregate error object. - pub(crate) fn constructor( + pub fn constructor( new_target: &JsValue, args: &[JsValue], context: &mut Context, diff --git a/boa_engine/src/builtins/error/eval.rs b/boa_engine/src/builtins/error/eval.rs index 4cade0f1856..598d99281ce 100644 --- a/boa_engine/src/builtins/error/eval.rs +++ b/boa_engine/src/builtins/error/eval.rs @@ -27,7 +27,7 @@ use super::Error; /// JavaScript `EvalError` impleentation. #[derive(Debug, Clone, Copy)] -pub(crate) struct EvalError; +pub struct EvalError; impl BuiltIn for EvalError { const NAME: &'static str = "EvalError"; @@ -61,7 +61,7 @@ impl EvalError { pub(crate) const LENGTH: usize = 1; /// Create a new error object. - pub(crate) fn constructor( + pub fn constructor( new_target: &JsValue, args: &[JsValue], context: &mut Context, diff --git a/boa_engine/src/builtins/error/mod.rs b/boa_engine/src/builtins/error/mod.rs index c68d1854446..e973b7a92d1 100644 --- a/boa_engine/src/builtins/error/mod.rs +++ b/boa_engine/src/builtins/error/mod.rs @@ -33,19 +33,19 @@ pub(crate) mod uri; #[cfg(test)] mod tests; -pub(crate) use self::aggregate::AggregateError; -pub(crate) use self::eval::EvalError; -pub(crate) use self::r#type::TypeError; -pub(crate) use self::range::RangeError; -pub(crate) use self::reference::ReferenceError; -pub(crate) use self::syntax::SyntaxError; -pub(crate) use self::uri::UriError; +pub use self::aggregate::AggregateError; +pub use self::eval::EvalError; +pub use self::r#type::TypeError; +pub use self::range::RangeError; +pub use self::reference::ReferenceError; +pub use self::syntax::SyntaxError; +pub use self::uri::UriError; use super::JsArgs; /// Built-in `Error` object. #[derive(Debug, Clone, Copy)] -pub(crate) struct Error; +pub struct Error; impl BuiltIn for Error { const NAME: &'static str = "Error"; @@ -97,7 +97,7 @@ impl Error { /// `Error( message [ , options ] )` /// /// Create a new error object. - pub(crate) fn constructor( + pub fn constructor( new_target: &JsValue, args: &[JsValue], context: &mut Context, @@ -137,11 +137,7 @@ impl Error { /// [spec]: https://tc39.es/ecma262/#sec-error.prototype.tostring /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/toString #[allow(clippy::wrong_self_convention)] - pub(crate) fn to_string( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn to_string(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. let o = if let Some(o) = this.as_object() { o diff --git a/boa_engine/src/builtins/error/range.rs b/boa_engine/src/builtins/error/range.rs index 1fa1258b0a8..b7bb5853831 100644 --- a/boa_engine/src/builtins/error/range.rs +++ b/boa_engine/src/builtins/error/range.rs @@ -25,7 +25,7 @@ use super::Error; /// JavaScript `RangeError` implementation. #[derive(Debug, Clone, Copy)] -pub(crate) struct RangeError; +pub struct RangeError; impl BuiltIn for RangeError { const NAME: &'static str = "RangeError"; @@ -59,7 +59,7 @@ impl RangeError { pub(crate) const LENGTH: usize = 1; /// Create a new error object. - pub(crate) fn constructor( + pub fn constructor( new_target: &JsValue, args: &[JsValue], context: &mut Context, diff --git a/boa_engine/src/builtins/error/reference.rs b/boa_engine/src/builtins/error/reference.rs index e130678b955..79c8053a9e3 100644 --- a/boa_engine/src/builtins/error/reference.rs +++ b/boa_engine/src/builtins/error/reference.rs @@ -24,7 +24,7 @@ use tap::{Conv, Pipe}; use super::Error; #[derive(Debug, Clone, Copy)] -pub(crate) struct ReferenceError; +pub struct ReferenceError; impl BuiltIn for ReferenceError { const NAME: &'static str = "ReferenceError"; @@ -62,7 +62,7 @@ impl ReferenceError { pub(crate) const LENGTH: usize = 1; /// Create a new error object. - pub(crate) fn constructor( + pub fn constructor( new_target: &JsValue, args: &[JsValue], context: &mut Context, diff --git a/boa_engine/src/builtins/error/syntax.rs b/boa_engine/src/builtins/error/syntax.rs index d0d2a33bcda..1c73b566f7c 100644 --- a/boa_engine/src/builtins/error/syntax.rs +++ b/boa_engine/src/builtins/error/syntax.rs @@ -27,7 +27,7 @@ use super::Error; /// JavaScript `SyntaxError` impleentation. #[derive(Debug, Clone, Copy)] -pub(crate) struct SyntaxError; +pub struct SyntaxError; impl BuiltIn for SyntaxError { const NAME: &'static str = "SyntaxError"; @@ -61,7 +61,7 @@ impl SyntaxError { pub(crate) const LENGTH: usize = 1; /// Create a new error object. - pub(crate) fn constructor( + pub fn constructor( new_target: &JsValue, args: &[JsValue], context: &mut Context, diff --git a/boa_engine/src/builtins/error/type.rs b/boa_engine/src/builtins/error/type.rs index 0d1faad759c..a9e3c418280 100644 --- a/boa_engine/src/builtins/error/type.rs +++ b/boa_engine/src/builtins/error/type.rs @@ -31,7 +31,7 @@ use super::Error; /// JavaScript `TypeError` implementation. #[derive(Debug, Clone, Copy)] -pub(crate) struct TypeError; +pub struct TypeError; impl BuiltIn for TypeError { const NAME: &'static str = "TypeError"; @@ -65,7 +65,7 @@ impl TypeError { pub(crate) const LENGTH: usize = 1; /// Create a new error object. - pub(crate) fn constructor( + pub fn constructor( new_target: &JsValue, args: &[JsValue], context: &mut Context, diff --git a/boa_engine/src/builtins/error/uri.rs b/boa_engine/src/builtins/error/uri.rs index f00866d2a7b..c77238c7fcd 100644 --- a/boa_engine/src/builtins/error/uri.rs +++ b/boa_engine/src/builtins/error/uri.rs @@ -26,7 +26,7 @@ use super::Error; /// JavaScript `URIError` impleentation. #[derive(Debug, Clone, Copy)] -pub(crate) struct UriError; +pub struct UriError; impl BuiltIn for UriError { const NAME: &'static str = "URIError"; @@ -60,7 +60,7 @@ impl UriError { pub(crate) const LENGTH: usize = 1; /// Create a new error object. - pub(crate) fn constructor( + pub fn constructor( new_target: &JsValue, args: &[JsValue], context: &mut Context, diff --git a/boa_engine/src/builtins/function/mod.rs b/boa_engine/src/builtins/function/mod.rs index cc4af912b79..de6cba9c412 100644 --- a/boa_engine/src/builtins/function/mod.rs +++ b/boa_engine/src/builtins/function/mod.rs @@ -267,7 +267,7 @@ pub struct BuiltInFunctionObject; impl BuiltInFunctionObject { pub const LENGTH: usize = 1; - fn constructor( + pub fn constructor( new_target: &JsValue, _: &[JsValue], context: &mut Context, @@ -297,7 +297,7 @@ impl BuiltInFunctionObject { /// /// [spec]: https://tc39.es/ecma262/#sec-function.prototype.apply /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply - fn apply(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn apply(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let func be the this value. // 2. If IsCallable(func) is false, throw a TypeError exception. let func = this.as_callable().ok_or_else(|| { @@ -337,7 +337,7 @@ impl BuiltInFunctionObject { /// /// [spec]: https://tc39.es/ecma262/#sec-function.prototype.bind /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_objects/Function/bind - fn bind(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn bind(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let Target be the this value. // 2. If IsCallable(Target) is false, throw a TypeError exception. let target = this.as_callable().ok_or_else(|| { @@ -418,7 +418,7 @@ impl BuiltInFunctionObject { /// /// [spec]: https://tc39.es/ecma262/#sec-function.prototype.call /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call - fn call(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn call(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let func be the this value. // 2. If IsCallable(func) is false, throw a TypeError exception. let func = this.as_callable().ok_or_else(|| { @@ -434,7 +434,7 @@ impl BuiltInFunctionObject { } #[allow(clippy::wrong_self_convention)] - fn to_string(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + pub fn to_string(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { let object = this.as_object().map(JsObject::borrow); let function = object .as_deref() @@ -482,7 +482,11 @@ impl BuiltInFunctionObject { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-function.prototype-@@hasinstance - fn has_instance(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn has_instance( + this: &JsValue, + args: &[JsValue], + context: &mut Context, + ) -> JsResult { // 1. Let F be the this value. // 2. Return ? OrdinaryHasInstance(F, V). Ok(JsValue::ordinary_has_instance(this, args.get_or_undefined(0), context)?.into()) diff --git a/boa_engine/src/builtins/generator/mod.rs b/boa_engine/src/builtins/generator/mod.rs index 358890dac77..5933fedf613 100644 --- a/boa_engine/src/builtins/generator/mod.rs +++ b/boa_engine/src/builtins/generator/mod.rs @@ -112,11 +112,7 @@ impl Generator { pub(crate) const LENGTH: usize = 0; #[allow(clippy::unnecessary_wraps)] - pub(crate) fn constructor( - _: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn constructor(_: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { let prototype = context.intrinsics().constructors().generator().prototype(); let this = JsObject::from_proto_and_data( @@ -141,11 +137,7 @@ impl Generator { /// /// [spec]: https://tc39.es/ecma262/#sec-generator.prototype.next /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/next - pub(crate) fn next( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn next(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Return ? GeneratorResume(this value, value, empty). match this.as_object() { Some(obj) if obj.is_generator() => { @@ -165,11 +157,7 @@ impl Generator { /// /// [spec]: https://tc39.es/ecma262/#sec-generator.prototype.return /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/return - pub(crate) fn r#return( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn r#return(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let g be the this value. // 2. Let C be Completion { [[Type]]: return, [[Value]]: value, [[Target]]: empty }. // 3. Return ? GeneratorResumeAbrupt(g, C, empty). @@ -187,11 +175,7 @@ impl Generator { /// /// [spec]: https://tc39.es/ecma262/#sec-generator.prototype.throw /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/throw - pub(crate) fn throw( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn throw(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let g be the this value. // 2. Let C be ThrowCompletion(exception). // 3. Return ? GeneratorResumeAbrupt(g, C, empty). diff --git a/boa_engine/src/builtins/generator_function/mod.rs b/boa_engine/src/builtins/generator_function/mod.rs index 19d761c5f8d..faf19e6476c 100644 --- a/boa_engine/src/builtins/generator_function/mod.rs +++ b/boa_engine/src/builtins/generator_function/mod.rs @@ -109,7 +109,7 @@ impl BuiltIn for GeneratorFunction { } impl GeneratorFunction { - pub(crate) fn constructor( + pub fn constructor( new_target: &JsValue, _: &[JsValue], context: &mut Context, diff --git a/boa_engine/src/builtins/json/mod.rs b/boa_engine/src/builtins/json/mod.rs index e51e10110cf..c6db6e3a701 100644 --- a/boa_engine/src/builtins/json/mod.rs +++ b/boa_engine/src/builtins/json/mod.rs @@ -34,7 +34,7 @@ mod tests; /// JavaScript `JSON` global object. #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub(crate) struct Json; +pub struct Json; impl BuiltIn for Json { const NAME: &'static str = "JSON"; @@ -68,7 +68,7 @@ impl Json { /// /// [spec]: https://tc39.es/ecma262/#sec-json.parse /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse - pub(crate) fn parse(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn parse(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let jsonString be ? ToString(text). let json_string = args .get(0) @@ -209,11 +209,7 @@ impl Json { /// /// [spec]: https://tc39.es/ecma262/#sec-json.stringify /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify - pub(crate) fn stringify( - _: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn stringify(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let stack be a new empty List. let stack = Vec::new(); diff --git a/boa_engine/src/builtins/map/mod.rs b/boa_engine/src/builtins/map/mod.rs index 673d7f9b386..e0af19f9f76 100644 --- a/boa_engine/src/builtins/map/mod.rs +++ b/boa_engine/src/builtins/map/mod.rs @@ -35,7 +35,7 @@ pub mod ordered_map; mod tests; #[derive(Debug, Clone)] -pub(crate) struct Map(OrderedMap); +pub struct Map(OrderedMap); impl BuiltIn for Map { const NAME: &'static str = "Map"; @@ -116,7 +116,7 @@ impl Map { /// /// [spec]: https://tc39.es/ecma262/#sec-map-iterable /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/Map - pub(crate) fn constructor( + pub fn constructor( new_target: &JsValue, args: &[JsValue], context: &mut Context, @@ -157,7 +157,7 @@ impl Map { /// [spec]: https://tc39.es/ecma262/#sec-get-map-@@species /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/@@species #[allow(clippy::unnecessary_wraps)] - fn get_species(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { + pub fn get_species(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Return the this value. Ok(this.clone()) } @@ -172,11 +172,7 @@ impl Map { /// /// [spec]: https://www.ecma-international.org/ecma-262/11.0/index.html#sec-map.prototype.entries /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/entries - pub(crate) fn entries( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn entries(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let M be the this value. // 2. Return ? CreateMapIterator(M, key+value). MapIterator::create_map_iterator(this, PropertyNameKind::KeyAndValue, context) @@ -192,7 +188,7 @@ impl Map { /// /// [spec]: https://tc39.es/ecma262/#sec-map.prototype.keys /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/keys - pub(crate) fn keys(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + pub fn keys(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let M be the this value. // 2. Return ? CreateMapIterator(M, key). MapIterator::create_map_iterator(this, PropertyNameKind::Key, context) @@ -208,11 +204,7 @@ impl Map { /// /// [spec]: https://tc39.es/ecma262/#sec-map.prototype.set /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/set - pub(crate) fn set( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn set(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let key = args.get_or_undefined(0); let value = args.get_or_undefined(1); @@ -257,11 +249,7 @@ impl Map { /// /// [spec]: https://tc39.es/ecma262/#sec-get-map.prototype.size /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/size - pub(crate) fn get_size( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn get_size(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let M be the this value. if let Some(object) = this.as_object() { // 2. Perform ? RequireInternalSlot(M, [[MapData]]). @@ -288,11 +276,7 @@ impl Map { /// /// [spec]: https://tc39.es/ecma262/#sec-map.prototype.delete /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/delete - pub(crate) fn delete( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn delete(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let key = args.get_or_undefined(0); // 1. Let M be the this value. @@ -321,11 +305,7 @@ impl Map { /// /// [spec]: https://tc39.es/ecma262/#sec-map.prototype.get /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get - pub(crate) fn get( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn get(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { const JS_ZERO: &JsValue = &JsValue::Rational(0f64); let key = args.get_or_undefined(0); @@ -365,7 +345,7 @@ impl Map { /// /// [spec]: https://tc39.es/ecma262/#sec-map.prototype.clear /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/clear - pub(crate) fn clear(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + pub fn clear(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let M be the this value. // 2. Perform ? RequireInternalSlot(M, [[MapData]]). if let Some(object) = this.as_object() { @@ -393,11 +373,7 @@ impl Map { /// /// [spec]: https://tc39.es/ecma262/#sec-map.prototype.has /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has - pub(crate) fn has( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn has(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { const JS_ZERO: &JsValue = &JsValue::Rational(0f64); let key = args.get_or_undefined(0); @@ -437,11 +413,7 @@ impl Map { /// /// [spec]: https://tc39.es/ecma262/#sec-map.prototype.foreach /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach - pub(crate) fn for_each( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn for_each(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let M be the this value. // 2. Perform ? RequireInternalSlot(M, [[MapData]]). let map = this @@ -508,11 +480,7 @@ impl Map { /// /// [spec]: https://tc39.es/ecma262/#sec-map.prototype.values /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/values - pub(crate) fn values( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn values(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let M be the this value. // 2. Return ? CreateMapIterator(M, value). MapIterator::create_map_iterator(this, PropertyNameKind::Value, context) diff --git a/boa_engine/src/builtins/math/mod.rs b/boa_engine/src/builtins/math/mod.rs index f3b919cd752..30c262113ea 100644 --- a/boa_engine/src/builtins/math/mod.rs +++ b/boa_engine/src/builtins/math/mod.rs @@ -24,7 +24,7 @@ mod tests; /// Javascript `Math` object. #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub(crate) struct Math; +pub struct Math; impl BuiltIn for Math { const NAME: &'static str = "Math"; @@ -98,7 +98,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.abs /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs - pub(crate) fn abs(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn abs(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -120,7 +120,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.acos /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acos - pub(crate) fn acos(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn acos(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -140,7 +140,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.acosh /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acosh - pub(crate) fn acosh(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn acosh(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -161,7 +161,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.asin /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asin - pub(crate) fn asin(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn asin(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -181,7 +181,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.asinh /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asinh - pub(crate) fn asinh(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn asinh(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -200,7 +200,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.atan /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan - pub(crate) fn atan(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn atan(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -221,7 +221,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.atanh /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atanh - pub(crate) fn atanh(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn atanh(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -243,7 +243,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.atan2 /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan2 - pub(crate) fn atan2(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn atan2(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let ny be ? ToNumber(y). let y = args.get_or_undefined(0).to_number(context)?; @@ -286,7 +286,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.cbrt /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cbrt - pub(crate) fn cbrt(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn cbrt(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -305,7 +305,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.ceil /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil - pub(crate) fn ceil(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn ceil(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -326,7 +326,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.clz32 /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32 - pub(crate) fn clz32(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn clz32(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToUint32(x). @@ -345,7 +345,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.cos /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cos - pub(crate) fn cos(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn cos(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -365,7 +365,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.cosh /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cosh - pub(crate) fn cosh(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn cosh(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -386,7 +386,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.exp /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/exp - pub(crate) fn exp(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn exp(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -409,7 +409,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.expm1 /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/expm1 - pub(crate) fn expm1(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn expm1(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -429,7 +429,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.floor /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor - pub(crate) fn floor(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn floor(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -450,11 +450,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.fround /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround - pub(crate) fn fround( - _: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn fround(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let n be ? ToNumber(x). let x = args.get_or_undefined(0).to_number(context)?; @@ -474,7 +470,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.hypot /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/hypot - pub(crate) fn hypot(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn hypot(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let coerced be a new empty List. // 2. For each element arg of args, do // a. Let n be ? ToNumber(arg). @@ -504,7 +500,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.imul /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul - pub(crate) fn imul(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn imul(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let a be ℝ(? ToUint32(x)). let x = args.get_or_undefined(0).to_u32(context)?; @@ -524,7 +520,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.log /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log - pub(crate) fn log(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn log(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -546,7 +542,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.log1p /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log1p - pub(crate) fn log1p(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn log1p(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -567,7 +563,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.log10 /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log10 - pub(crate) fn log10(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn log10(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -589,7 +585,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.log2 /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log2 - pub(crate) fn log2(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn log2(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -611,7 +607,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.max /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max - pub(crate) fn max(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn max(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let coerced be a new empty List. // 2. For each element arg of args, do // b. Append n to coerced. @@ -649,7 +645,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.min /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min - pub(crate) fn min(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn min(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let coerced be a new empty List. // 2. For each element arg of args, do // b. Append n to coerced. @@ -688,7 +684,7 @@ impl Math { /// [spec]: https://tc39.es/ecma262/#sec-math.pow /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow #[allow(clippy::float_cmp)] - pub(crate) fn pow(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn pow(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Set base to ? ToNumber(base). let x = args.get_or_undefined(0).to_number(context)?; @@ -713,7 +709,7 @@ impl Math { /// [spec]: https://tc39.es/ecma262/#sec-math.random /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random #[allow(clippy::unnecessary_wraps)] - pub(crate) fn random(_: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { + pub fn random(_: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // NOTE: Each Math.random function created for distinct realms must produce a distinct sequence of values from successive calls. Ok(rand::random::().into()) } @@ -727,7 +723,7 @@ impl Math { /// [spec]: https://tc39.es/ecma262/#sec-math.round /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round #[allow(clippy::float_cmp)] - pub(crate) fn round(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn round(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let num = args .get_or_undefined(0) //1. Let n be ? ToNumber(x). @@ -753,7 +749,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.sign /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign - pub(crate) fn sign(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn sign(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let n be ? ToNumber(x). let n = args.get_or_undefined(0).to_number(context)?; @@ -774,7 +770,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.sin /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sin - pub(crate) fn sin(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn sin(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -794,7 +790,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.sinh /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sinh - pub(crate) fn sinh(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn sinh(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -813,7 +809,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.sqrt /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sqrt - pub(crate) fn sqrt(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn sqrt(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -833,7 +829,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.tan /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tan - pub(crate) fn tan(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn tan(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -853,7 +849,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.tanh /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tanh - pub(crate) fn tanh(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn tanh(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -874,7 +870,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.trunc /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc - pub(crate) fn trunc(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn trunc(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). diff --git a/boa_engine/src/builtins/mod.rs b/boa_engine/src/builtins/mod.rs index ddf02edf2d4..ef065753543 100644 --- a/boa_engine/src/builtins/mod.rs +++ b/boa_engine/src/builtins/mod.rs @@ -1,4 +1,9 @@ //! Builtins live here, such as Object, String, Math, etc. +//! +//! This module exposes some raw builtin functions. +//! +//! ## NOTE: +//! Because these are internal functions, they may be subject to change. pub mod array; pub mod array_buffer; @@ -32,7 +37,19 @@ pub mod typed_array; pub mod undefined; pub(crate) use self::{ - array::{array_iterator::ArrayIterator, Array}, + array::array_iterator::ArrayIterator, global_this::GlobalThis, infinity::Infinity, intl::Intl, + map::map_iterator::MapIterator, nan::NaN, object::for_in_iterator::ForInIterator, + set::set_iterator::SetIterator, undefined::Undefined, +}; + +use crate::{ + property::{Attribute, PropertyDescriptor}, + Context, JsValue, +}; + +pub use self::{ + array::Array, + array_buffer::ArrayBuffer, bigint::BigInt, boolean::Boolean, dataview::DataView, @@ -42,38 +59,23 @@ pub(crate) use self::{ UriError, }, function::BuiltInFunctionObject, - global_this::GlobalThis, - infinity::Infinity, - intl::Intl, + generator::Generator, + generator_function::GeneratorFunction, json::Json, - map::map_iterator::MapIterator, map::Map, math::Math, - nan::NaN, number::Number, - object::for_in_iterator::ForInIterator, object::Object as BuiltInObjectObject, proxy::Proxy, reflect::Reflect, regexp::RegExp, - set::set_iterator::SetIterator, set::Set, string::String, symbol::Symbol, typed_array::{ BigInt64Array, BigUint64Array, Float32Array, Float64Array, Int16Array, Int32Array, - Int8Array, Uint16Array, Uint32Array, Uint8Array, Uint8ClampedArray, + Int8Array, TypedArray, Uint16Array, Uint32Array, Uint8Array, Uint8ClampedArray, }, - undefined::Undefined, -}; - -use crate::{ - builtins::{ - array_buffer::ArrayBuffer, generator::Generator, generator_function::GeneratorFunction, - typed_array::TypedArray, - }, - property::{Attribute, PropertyDescriptor}, - Context, JsValue, }; /// Trait representing a global built-in object such as `Math`, `Object` or diff --git a/boa_engine/src/builtins/number/mod.rs b/boa_engine/src/builtins/number/mod.rs index dcbf38cf722..f7ee8c193d2 100644 --- a/boa_engine/src/builtins/number/mod.rs +++ b/boa_engine/src/builtins/number/mod.rs @@ -39,7 +39,7 @@ const BUF_SIZE: usize = 2200; /// `Number` implementation. #[derive(Debug, Clone, Copy)] -pub(crate) struct Number; +pub struct Number; impl BuiltIn for Number { const NAME: &'static str = "Number"; @@ -167,7 +167,7 @@ impl Number { pub(crate) const MIN_VALUE: f64 = f64::MIN_POSITIVE; /// `Number( value )` - pub(crate) fn constructor( + pub fn constructor( new_target: &JsValue, args: &[JsValue], context: &mut Context, @@ -212,7 +212,7 @@ impl Number { /// [spec]: https://tc39.es/ecma262/#sec-number.prototype.toexponential /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential #[allow(clippy::wrong_self_convention)] - pub(crate) fn to_exponential( + pub fn to_exponential( this: &JsValue, args: &[JsValue], context: &mut Context, @@ -256,11 +256,7 @@ impl Number { /// [spec]: https://tc39.es/ecma262/#sec-number.prototype.tofixed /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed #[allow(clippy::wrong_self_convention)] - pub(crate) fn to_fixed( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn to_fixed(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let this_num be ? thisNumberValue(this value). let this_num = Self::this_number_value(this, context)?; @@ -304,7 +300,7 @@ impl Number { /// [spec]: https://tc39.es/ecma262/#sec-number.prototype.tolocalestring /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString #[allow(clippy::wrong_self_convention)] - pub(crate) fn to_locale_string( + pub fn to_locale_string( this: &JsValue, _: &[JsValue], context: &mut Context, @@ -414,7 +410,7 @@ impl Number { /// [spec]: https://tc39.es/ecma262/#sec-number.prototype.toprecision /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision #[allow(clippy::wrong_self_convention)] - pub(crate) fn to_precision( + pub fn to_precision( this: &JsValue, args: &[JsValue], context: &mut Context, @@ -666,11 +662,7 @@ impl Number { /// [spec]: https://tc39.es/ecma262/#sec-number.prototype.tostring /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString #[allow(clippy::wrong_self_convention)] - pub(crate) fn to_string( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn to_string(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let x be ? thisNumberValue(this value). let x = Self::this_number_value(this, context)?; @@ -729,11 +721,7 @@ impl Number { /// /// [spec]: https://tc39.es/ecma262/#sec-number.prototype.valueof /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/valueOf - pub(crate) fn value_of( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn value_of(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { Ok(JsValue::new(Self::this_number_value(this, context)?)) } @@ -751,11 +739,7 @@ impl Number { /// /// [spec]: https://tc39.es/ecma262/#sec-parseint-string-radix /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt - pub(crate) fn parse_int( - _: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn parse_int(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { if let (Some(val), radix) = (args.get(0), args.get_or_undefined(1)) { // 1. Let inputString be ? ToString(string). let input_string = val.to_string(context)?; @@ -878,11 +862,7 @@ impl Number { /// /// [spec]: https://tc39.es/ecma262/#sec-parsefloat-string /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat - pub(crate) fn parse_float( - _: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn parse_float(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { if let Some(val) = args.get(0) { let input_string = val.to_string(context)?; let s = input_string.trim_start_matches(is_trimmable_whitespace); @@ -931,7 +911,7 @@ impl Number { /// /// [spec]: https://tc39.es/ecma262/#sec-isfinite-number /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isFinite - pub(crate) fn global_is_finite( + pub fn global_is_finite( _: &JsValue, args: &[JsValue], context: &mut Context, @@ -958,7 +938,7 @@ impl Number { /// /// [spec]: https://tc39.es/ecma262/#sec-isnan-number /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isNaN - pub(crate) fn global_is_nan( + pub fn global_is_nan( _: &JsValue, args: &[JsValue], context: &mut Context, @@ -986,7 +966,7 @@ impl Number { /// [spec]: https://tc39.es/ecma262/#sec-number.isfinite /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite #[allow(clippy::unnecessary_wraps)] - pub(crate) fn number_is_finite( + pub fn number_is_finite( _: &JsValue, args: &[JsValue], _ctx: &mut Context, @@ -1013,7 +993,7 @@ impl Number { /// [spec]: https://tc39.es/ecma262/#sec-number.isinteger /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger #[allow(clippy::unnecessary_wraps)] - pub(crate) fn number_is_integer( + pub fn number_is_integer( _: &JsValue, args: &[JsValue], _ctx: &mut Context, @@ -1036,11 +1016,7 @@ impl Number { /// [spec]: https://tc39.es/ecma262/#sec-isnan-number /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN #[allow(clippy::unnecessary_wraps)] - pub(crate) fn number_is_nan( - _: &JsValue, - args: &[JsValue], - _ctx: &mut Context, - ) -> JsResult { + pub fn number_is_nan(_: &JsValue, args: &[JsValue], _ctx: &mut Context) -> JsResult { Ok(JsValue::new( if let Some(&JsValue::Rational(number)) = args.get(0) { number.is_nan() @@ -1065,11 +1041,7 @@ impl Number { /// [spec]: https://tc39.es/ecma262/#sec-isnan-number /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN #[allow(clippy::unnecessary_wraps)] - pub(crate) fn is_safe_integer( - _: &JsValue, - args: &[JsValue], - _ctx: &mut Context, - ) -> JsResult { + pub fn is_safe_integer(_: &JsValue, args: &[JsValue], _ctx: &mut Context) -> JsResult { Ok(JsValue::new(match args.get(0) { Some(JsValue::Integer(_)) => true, Some(JsValue::Rational(number)) if Self::is_float_integer(*number) => { diff --git a/boa_engine/src/builtins/object/mod.rs b/boa_engine/src/builtins/object/mod.rs index 6bdb4b6a158..e657ec4b6b7 100644 --- a/boa_engine/src/builtins/object/mod.rs +++ b/boa_engine/src/builtins/object/mod.rs @@ -96,7 +96,7 @@ impl BuiltIn for Object { impl Object { const LENGTH: usize = 1; - fn constructor( + pub fn constructor( new_target: &JsValue, args: &[JsValue], context: &mut Context, diff --git a/boa_engine/src/builtins/proxy/mod.rs b/boa_engine/src/builtins/proxy/mod.rs index 5f580f74bfd..995901040b2 100644 --- a/boa_engine/src/builtins/proxy/mod.rs +++ b/boa_engine/src/builtins/proxy/mod.rs @@ -71,7 +71,7 @@ impl Proxy { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-proxy-target-handler - pub(crate) fn constructor( + pub fn constructor( new_target: &JsValue, args: &[JsValue], context: &mut Context, @@ -129,7 +129,7 @@ impl Proxy { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-proxy.revocable - fn revocable(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn revocable(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let p be ? ProxyCreate(target, handler). let p = Self::create(args.get_or_undefined(0), args.get_or_undefined(1), context)?; diff --git a/boa_engine/src/builtins/reflect/mod.rs b/boa_engine/src/builtins/reflect/mod.rs index 0adad88ba67..10388f7529b 100644 --- a/boa_engine/src/builtins/reflect/mod.rs +++ b/boa_engine/src/builtins/reflect/mod.rs @@ -26,7 +26,7 @@ mod tests; /// Javascript `Reflect` object. #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub(crate) struct Reflect; +pub struct Reflect; impl BuiltIn for Reflect { const NAME: &'static str = "Reflect"; @@ -74,7 +74,7 @@ impl Reflect { /// /// [spec]: https://tc39.es/ecma262/#sec-reflect.apply /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/apply - pub(crate) fn apply(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn apply(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let target = args .get(0) .and_then(JsValue::as_object) @@ -97,11 +97,7 @@ impl Reflect { /// /// [spec]: https://tc39.es/ecma262/#sec-reflect.construct /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct - pub(crate) fn construct( - _: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn construct(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let target = args .get(0) .and_then(JsValue::as_object) @@ -133,7 +129,7 @@ impl Reflect { /// /// [spec]: https://tc39.es/ecma262/#sec-reflect.defineProperty /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/defineProperty - pub(crate) fn define_property( + pub fn define_property( _: &JsValue, args: &[JsValue], context: &mut Context, @@ -162,7 +158,7 @@ impl Reflect { /// /// [spec]: https://tc39.es/ecma262/#sec-reflect.deleteproperty /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/deleteProperty - pub(crate) fn delete_property( + pub fn delete_property( _: &JsValue, args: &[JsValue], context: &mut Context, @@ -184,7 +180,7 @@ impl Reflect { /// /// [spec]: https://tc39.es/ecma262/#sec-reflect.get /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/get - pub(crate) fn get(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn get(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. If Type(target) is not Object, throw a TypeError exception. let target = args .get(0) @@ -211,7 +207,7 @@ impl Reflect { /// /// [spec]: https://tc39.es/ecma262/#sec-reflect.getownpropertydescriptor /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getOwnPropertyDescriptor - pub(crate) fn get_own_property_descriptor( + pub fn get_own_property_descriptor( _: &JsValue, args: &[JsValue], context: &mut Context, @@ -237,7 +233,7 @@ impl Reflect { /// /// [spec]: https://tc39.es/ecma262/#sec-reflect.getprototypeof /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getPrototypeOf - pub(crate) fn get_prototype_of( + pub fn get_prototype_of( _: &JsValue, args: &[JsValue], context: &mut Context, @@ -259,7 +255,7 @@ impl Reflect { /// /// [spec]: https://tc39.es/ecma262/#sec-reflect.has /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has - pub(crate) fn has(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn has(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let target = args .get(0) .and_then(JsValue::as_object) @@ -279,7 +275,7 @@ impl Reflect { /// /// [spec]: https://tc39.es/ecma262/#sec-reflect.isextensible /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/isExtensible - pub(crate) fn is_extensible( + pub fn is_extensible( _: &JsValue, args: &[JsValue], context: &mut Context, @@ -299,11 +295,7 @@ impl Reflect { /// /// [spec]: https://tc39.es/ecma262/#sec-reflect.ownkeys /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/ownKeys - pub(crate) fn own_keys( - _: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn own_keys(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let target = args .get(0) .and_then(JsValue::as_object) @@ -326,7 +318,7 @@ impl Reflect { /// /// [spec]: https://tc39.es/ecma262/#sec-reflect.preventextensions /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/preventExtensions - pub(crate) fn prevent_extensions( + pub fn prevent_extensions( _: &JsValue, args: &[JsValue], context: &mut Context, @@ -347,7 +339,7 @@ impl Reflect { /// /// [spec]: https://tc39.es/ecma262/#sec-reflect.set /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set - pub(crate) fn set(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn set(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let target = args .get(0) .and_then(JsValue::as_object) @@ -372,7 +364,7 @@ impl Reflect { /// /// [spec]: https://tc39.es/ecma262/#sec-reflect.setprototypeof /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/setPrototypeOf - pub(crate) fn set_prototype_of( + pub fn set_prototype_of( _: &JsValue, args: &[JsValue], context: &mut Context, diff --git a/boa_engine/src/builtins/regexp/mod.rs b/boa_engine/src/builtins/regexp/mod.rs index b39d66a8a9b..0c589c6414b 100644 --- a/boa_engine/src/builtins/regexp/mod.rs +++ b/boa_engine/src/builtins/regexp/mod.rs @@ -165,7 +165,7 @@ impl RegExp { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-regexp-pattern-flags - pub(crate) fn constructor( + pub fn constructor( new_target: &JsValue, args: &[JsValue], context: &mut Context, @@ -376,11 +376,7 @@ impl RegExp { /// /// [spec]: https://tc39.es/ecma262/#sec-get-regexp.prototype.global /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/global - pub(crate) fn get_global( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn get_global(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { Self::regexp_has_flag(this, b'g', context) } @@ -394,7 +390,7 @@ impl RegExp { /// /// [spec]: https://tc39.es/ecma262/#sec-get-regexp.prototype.ignorecase /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/ignoreCase - pub(crate) fn get_ignore_case( + pub fn get_ignore_case( this: &JsValue, _: &[JsValue], context: &mut Context, @@ -412,7 +408,7 @@ impl RegExp { /// /// [spec]: https://tc39.es/ecma262/#sec-get-regexp.prototype.multiline /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/multiline - pub(crate) fn get_multiline( + pub fn get_multiline( this: &JsValue, _: &[JsValue], context: &mut Context, @@ -430,11 +426,7 @@ impl RegExp { /// /// [spec]: https://tc39.es/ecma262/#sec-get-regexp.prototype.dotAll /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/dotAll - pub(crate) fn get_dot_all( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn get_dot_all(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { Self::regexp_has_flag(this, b's', context) } @@ -449,11 +441,7 @@ impl RegExp { /// /// [spec]: https://tc39.es/ecma262/#sec-get-regexp.prototype.unicode /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode - pub(crate) fn get_unicode( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn get_unicode(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { Self::regexp_has_flag(this, b'u', context) } @@ -468,11 +456,7 @@ impl RegExp { /// /// [spec]: https://tc39.es/ecma262/#sec-get-regexp.prototype.sticky /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/sticky - pub(crate) fn get_sticky( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn get_sticky(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { Self::regexp_has_flag(this, b'y', context) } @@ -487,11 +471,7 @@ impl RegExp { /// [spec]: https://tc39.es/ecma262/#sec-get-regexp.prototype.flags /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/flags /// [flags]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Advanced_searching_with_flags_2 - pub(crate) fn get_flags( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn get_flags(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let R be the this value. // 2. If Type(R) is not Object, throw a TypeError exception. if let Some(object) = this.as_object() { @@ -549,11 +529,7 @@ impl RegExp { /// /// [spec]: https://tc39.es/ecma262/#sec-get-regexp.prototype.source /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/source - pub(crate) fn get_source( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn get_source(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let R be the this value. // 2. If Type(R) is not Object, throw a TypeError exception. if let Some(object) = this.as_object() { @@ -628,11 +604,7 @@ impl RegExp { /// /// [spec]: https://tc39.es/ecma262/#sec-regexp.prototype.test /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test - pub(crate) fn test( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn test(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let R be the this value. // 2. If Type(R) is not Object, throw a TypeError exception. let this = this.as_object().ok_or_else(|| { @@ -670,11 +642,7 @@ impl RegExp { /// /// [spec]: https://tc39.es/ecma262/#sec-regexp.prototype.exec /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec - pub(crate) fn exec( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn exec(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let R be the this value. // 2. Perform ? RequireInternalSlot(R, [[RegExpMatcher]]). let obj = this @@ -972,11 +940,7 @@ impl RegExp { /// /// [spec]: https://tc39.es/ecma262/#sec-regexp.prototype-@@match /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@match - pub(crate) fn r#match( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn r#match(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let rx be the this value. // 2. If Type(rx) is not Object, throw a TypeError exception. let rx = if let Some(rx) = this.as_object() { @@ -1074,11 +1038,7 @@ impl RegExp { /// [spec]: https://tc39.es/ecma262/#sec-regexp.prototype.tostring /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/toString #[allow(clippy::wrong_self_convention)] - pub(crate) fn to_string( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn to_string(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { let (body, flags) = if let Some(object) = this.as_object() { let object = object.borrow(); let regex = object.as_regexp().ok_or_else(|| { @@ -1107,11 +1067,7 @@ impl RegExp { /// /// [spec]: https://tc39.es/ecma262/#sec-regexp-prototype-matchall /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@matchAll - pub(crate) fn match_all( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn match_all(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let R be the this value. // 2. If Type(R) is not Object, throw a TypeError exception. let regexp = this.as_object().ok_or_else(|| { @@ -1175,11 +1131,7 @@ impl RegExp { /// /// [spec]: https://tc39.es/ecma262/#sec-regexp.prototype-@@replace /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@replace - pub(crate) fn replace( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn replace(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let rx be the this value. // 2. If Type(rx) is not Object, throw a TypeError exception. let rx = if let Some(rx) = this.as_object() { @@ -1419,11 +1371,7 @@ impl RegExp { /// /// [spec]: https://tc39.es/ecma262/#sec-regexp.prototype-@@search /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@search - pub(crate) fn search( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn search(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let rx be the this value. // 2. If Type(rx) is not Object, throw a TypeError exception. let rx = if let Some(rx) = this.as_object() { @@ -1481,11 +1429,7 @@ impl RegExp { /// /// [spec]: https://tc39.es/ecma262/#sec-regexp.prototype-@@split /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@split - pub(crate) fn split( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn split(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let rx be the this value. // 2. If Type(rx) is not Object, throw a TypeError exception. let rx = if let Some(rx) = this.as_object() { diff --git a/boa_engine/src/builtins/set/mod.rs b/boa_engine/src/builtins/set/mod.rs index 1ff23fb706d..45b68866d7d 100644 --- a/boa_engine/src/builtins/set/mod.rs +++ b/boa_engine/src/builtins/set/mod.rs @@ -32,7 +32,7 @@ pub mod set_iterator; mod tests; #[derive(Debug, Clone)] -pub(crate) struct Set(OrderedSet); +pub struct Set(OrderedSet); impl BuiltIn for Set { const NAME: &'static str = "Set"; @@ -110,7 +110,7 @@ impl Set { pub(crate) const LENGTH: usize = 0; /// Create a new set - pub(crate) fn constructor( + pub fn constructor( new_target: &JsValue, args: &[JsValue], context: &mut Context, @@ -190,11 +190,7 @@ impl Set { /// /// [spec]: https://tc39.es/ecma262/#sec-set.prototype.add /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/add - pub(crate) fn add( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn add(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let value = args.get_or_undefined(0); if let Some(object) = this.as_object() { @@ -224,7 +220,7 @@ impl Set { /// /// [spec]: https://tc39.es/ecma262/#sec-set.prototype.clear /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/clear - pub(crate) fn clear(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + pub fn clear(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { if let Some(object) = this.as_object() { if object.borrow().is_set() { this.set_data(ObjectData::set(OrderedSet::new())); @@ -248,11 +244,7 @@ impl Set { /// /// [spec]: https://tc39.es/ecma262/#sec-set.prototype.delete /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/delete - pub(crate) fn delete( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn delete(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let value = args.get_or_undefined(0); let res = if let Some(object) = this.as_object() { @@ -278,11 +270,7 @@ impl Set { /// /// [spec]: https://tc39.es/ecma262/#sec-set.prototype.entries /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/entries - pub(crate) fn entries( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn entries(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { if let Some(object) = this.as_object() { let object = object.borrow(); if !object.is_set() { @@ -312,11 +300,7 @@ impl Set { /// /// [spec]: https://tc39.es/ecma262/#sec-set.prototype.foreach /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/foreach - pub(crate) fn for_each( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn for_each(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { if args.is_empty() { return Err(JsValue::new("Missing argument for Set.prototype.forEach")); } @@ -363,11 +347,7 @@ impl Set { /// /// [spec]: https://tc39.es/ecma262/#sec-map.prototype.has /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has - pub(crate) fn has( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn has(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let value = args.get_or_undefined(0); this.as_object() @@ -389,11 +369,7 @@ impl Set { /// /// [spec]: https://tc39.es/ecma262/#sec-set.prototype.values /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/values - pub(crate) fn values( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn values(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { if let Some(object) = this.as_object() { let object = object.borrow(); if !object.is_set() { diff --git a/boa_engine/src/builtins/string/mod.rs b/boa_engine/src/builtins/string/mod.rs index 60bfdd8f9f5..28482c46137 100644 --- a/boa_engine/src/builtins/string/mod.rs +++ b/boa_engine/src/builtins/string/mod.rs @@ -96,7 +96,7 @@ pub(crate) fn is_trailing_surrogate(value: u16) -> bool { /// JavaScript `String` implementation. #[derive(Debug, Clone, Copy)] -pub(crate) struct String; +pub struct String; impl BuiltIn for String { const NAME: &'static str = "String"; @@ -169,7 +169,7 @@ impl String { /// `String( value )` /// /// - pub(crate) fn constructor( + pub fn constructor( new_target: &JsValue, args: &[JsValue], context: &mut Context, @@ -264,7 +264,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.fromcodepoint /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint - pub(crate) fn from_code_point( + pub fn from_code_point( _: &JsValue, args: &[JsValue], context: &mut Context, @@ -305,7 +305,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.raw /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw - pub(crate) fn raw(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn raw(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let substitutions = args.get(1..).unwrap_or_default(); // 1. Let numberOfSubstitutions be the number of elements in substitutions. @@ -376,7 +376,7 @@ impl String { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/multipage/text-processing.html#sec-string.fromcharcode - pub(crate) fn from_char_code( + pub fn from_char_code( _: &JsValue, args: &[JsValue], context: &mut Context, @@ -406,11 +406,7 @@ impl String { /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.tostring #[allow(clippy::wrong_self_convention)] #[inline] - pub(crate) fn to_string( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn to_string(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Return ? thisStringValue(this value). Ok(Self::this_string_value(this, context)?.into()) } @@ -431,11 +427,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.charat /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charAt - pub(crate) fn char_at( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn char_at(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let this = this.require_object_coercible(context)?; @@ -476,7 +468,7 @@ impl String { /// /// [spec]: https://tc39.es/proposal-relative-indexing-method/#sec-string.prototype.at /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/at - pub(crate) fn at(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn at(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let this = this.require_object_coercible(context)?; @@ -523,7 +515,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.codepointat /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt - pub(crate) fn code_point_at( + pub fn code_point_at( this: &JsValue, args: &[JsValue], context: &mut Context, @@ -565,7 +557,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.charcodeat /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt - pub(crate) fn char_code_at( + pub fn char_code_at( this: &JsValue, args: &[JsValue], context: &mut Context, @@ -612,11 +604,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.concat /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat - pub(crate) fn concat( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn concat(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let this = this.require_object_coercible(context)?; @@ -646,11 +634,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.repeat /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat - pub(crate) fn repeat( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn repeat(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let this = this.require_object_coercible(context)?; @@ -697,11 +681,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.slice /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice - pub(crate) fn slice( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn slice(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let this = this.require_object_coercible(context)?; @@ -765,7 +745,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.startswith /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith - pub(crate) fn starts_with( + pub fn starts_with( this: &JsValue, args: &[JsValue], context: &mut Context, @@ -836,11 +816,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.endswith /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith - pub(crate) fn ends_with( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn ends_with(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let this = this.require_object_coercible(context)?; @@ -906,11 +882,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.includes /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes - pub(crate) fn includes( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn includes(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let this = this.require_object_coercible(context)?; @@ -958,11 +930,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.replace /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace - pub(crate) fn replace( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn replace(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). this.require_object_coercible(context)?; @@ -1074,7 +1042,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.replaceall /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace - pub(crate) fn replace_all( + pub fn replace_all( this: &JsValue, args: &[JsValue], context: &mut Context, @@ -1246,11 +1214,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.indexof /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf - pub(crate) fn index_of( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn index_of(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let this = this.require_object_coercible(context)?; @@ -1290,7 +1254,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.lastindexof /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf - pub(crate) fn last_index_of( + pub fn last_index_of( this: &JsValue, args: &[JsValue], context: &mut Context, @@ -1356,11 +1320,7 @@ impl String { /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.match /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match /// [regex]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions - pub(crate) fn r#match( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn r#match(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let o = this.require_object_coercible(context)?; @@ -1473,11 +1433,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.padend /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd - pub(crate) fn pad_end( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn pad_end(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let this = this.require_object_coercible(context)?; @@ -1500,11 +1456,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.padstart /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart - pub(crate) fn pad_start( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn pad_start(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let this = this.require_object_coercible(context)?; @@ -1527,7 +1479,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.trim /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim - pub(crate) fn trim(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + pub fn trim(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { let object = this.require_object_coercible(context)?; let string = object.to_string(context)?; Ok(JsValue::new(string.trim_matches(is_trimmable_whitespace))) @@ -1545,11 +1497,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.trimstart /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimStart - pub(crate) fn trim_start( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn trim_start(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { let this = this.require_object_coercible(context)?; let string = this.to_string(context)?; Ok(JsValue::new( @@ -1569,11 +1517,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.trimend /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimEnd - pub(crate) fn trim_end( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn trim_end(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { let this = this.require_object_coercible(context)?; let string = this.to_string(context)?; Ok(JsValue::new( @@ -1592,11 +1536,7 @@ impl String { /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.tolowercase /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase #[allow(clippy::wrong_self_convention)] - pub(crate) fn to_lowercase( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn to_lowercase(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let this = this.require_object_coercible(context)?; @@ -1624,11 +1564,7 @@ impl String { /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.toUppercase /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase #[allow(clippy::wrong_self_convention)] - pub(crate) fn to_uppercase( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn to_uppercase(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // This function behaves in exactly the same way as `String.prototype.toLowerCase`, except that the String is // mapped using the toUppercase algorithm of the Unicode Default Case Conversion. @@ -1658,11 +1594,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.substring /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring - pub(crate) fn substring( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn substring(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let this = this.require_object_coercible(context)?; @@ -1714,11 +1646,7 @@ impl String { /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.substr /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr /// - pub(crate) fn substr( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn substr(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let this = this.require_object_coercible(context)?; @@ -1780,11 +1708,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.split /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split - pub(crate) fn split( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn split(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let this = this.require_object_coercible(context)?; @@ -1931,11 +1855,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.value_of /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/valueOf - pub(crate) fn value_of( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn value_of(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Return ? thisStringValue(this value). Self::this_string_value(this, context).map(JsValue::from) } @@ -1952,11 +1872,7 @@ impl String { /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/matchAll /// [regex]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions /// [cg]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Groups_and_Ranges - pub(crate) fn match_all( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn match_all(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let o = this.require_object_coercible(context)?; @@ -2007,11 +1923,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.normalize /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize - pub(crate) fn normalize( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn normalize(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let this = this.require_object_coercible(context)?; @@ -2056,11 +1968,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.search /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/search - pub(crate) fn search( - this: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn search(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let o = this.require_object_coercible(context)?; @@ -2086,11 +1994,7 @@ impl String { rx.invoke(WellKnownSymbols::search(), &[JsValue::new(string)], context) } - pub(crate) fn iterator( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn iterator(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { StringIterator::create_string_iterator(this.clone(), context) } } diff --git a/boa_engine/src/builtins/symbol/mod.rs b/boa_engine/src/builtins/symbol/mod.rs index df98d652c1a..911d4fa3850 100644 --- a/boa_engine/src/builtins/symbol/mod.rs +++ b/boa_engine/src/builtins/symbol/mod.rs @@ -112,7 +112,7 @@ impl BuiltIn for Symbol { ) .name(Self::NAME) .length(Self::LENGTH) - .static_method(Self::for_, "for", 1) + .static_method(Self::r#for, "for", 1) .static_method(Self::key_for, "keyFor", 1) .static_property("asyncIterator", symbol_async_iterator, attribute) .static_property("hasInstance", symbol_has_instance, attribute) @@ -168,7 +168,7 @@ impl Symbol { /// /// [spec]: https://tc39.es/ecma262/#sec-symbol-description /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/Symbol - pub(crate) fn constructor( + pub fn constructor( new_target: &JsValue, args: &[JsValue], context: &mut Context, @@ -202,11 +202,7 @@ impl Symbol { /// [spec]: https://tc39.es/ecma262/#sec-symbol.prototype.tostring /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toString #[allow(clippy::wrong_self_convention)] - pub(crate) fn to_string( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn to_string(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let sym be ? thisSymbolValue(this value). let symbol = Self::this_symbol_value(this, context)?; @@ -224,11 +220,7 @@ impl Symbol { /// /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/valueOf /// [spec]: https://tc39.es/ecma262/#sec-symbol.prototype.valueof - pub(crate) fn value_of( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn value_of(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Return ? thisSymbolValue(this value). let symbol = Self::this_symbol_value(this, context)?; Ok(JsValue::Symbol(symbol)) @@ -244,7 +236,7 @@ impl Symbol { /// /// [spec]: https://tc39.es/ecma262/#sec-symbol.prototype.description /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/description - pub(crate) fn get_description( + pub fn get_description( this: &JsValue, _: &[JsValue], context: &mut Context, @@ -265,7 +257,7 @@ impl Symbol { /// /// [spec]: https://tc39.es/ecma262/#sec-symbol.prototype.for /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/for - pub(crate) fn for_(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn r#for(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let stringKey be ? ToString(key). let string_key = args .get(0) @@ -295,11 +287,7 @@ impl Symbol { /// /// [spec]: https://tc39.es/ecma262/#sec-symbol.prototype.keyfor /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/keyFor - pub(crate) fn key_for( - _: &JsValue, - args: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn key_for(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let sym = args.get_or_undefined(0); // 1. If Type(sym) is not Symbol, throw a TypeError exception. if let Some(sym) = sym.as_symbol() { @@ -329,11 +317,7 @@ impl Symbol { /// /// [spec]: https://tc39.es/ecma262/multipage/#sec-symbol.prototype-@@toprimitive /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/@@toPrimitive - pub(crate) fn to_primitive( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + pub fn to_primitive(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { let sym = Self::this_symbol_value(this, context)?; // 1. Return ? thisSymbolValue(this value). Ok(sym.into()) diff --git a/boa_engine/src/builtins/typed_array/mod.rs b/boa_engine/src/builtins/typed_array/mod.rs index d7ea9c48957..9e8987d10e7 100644 --- a/boa_engine/src/builtins/typed_array/mod.rs +++ b/boa_engine/src/builtins/typed_array/mod.rs @@ -114,7 +114,7 @@ macro_rules! typed_array { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-typedarray - fn constructor( + pub fn constructor( new_target: &JsValue, args: &[JsValue], context: &mut Context, @@ -242,7 +242,7 @@ macro_rules! typed_array { /// /// #[derive(Debug, Clone, Copy)] -pub(crate) struct TypedArray; +pub struct TypedArray; impl BuiltIn for TypedArray { const NAME: &'static str = "TypedArray"; @@ -380,7 +380,7 @@ impl TypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray% - fn constructor( + pub fn constructor( _new_target: &JsValue, _args: &[JsValue], context: &mut Context, @@ -395,7 +395,7 @@ impl TypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray%.from - fn from(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn from(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let C be the this value. // 2. If IsConstructor(C) is false, throw a TypeError exception. let constructor = match this.as_object() { @@ -503,7 +503,7 @@ impl TypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray%.of - fn of(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn of(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let len be the number of elements in items. // 2. Let C be the this value. @@ -538,7 +538,7 @@ impl TypedArray { /// /// [spec]: https://tc39.es/ecma262/#sec-get-%typedarray%-@@species #[allow(clippy::unnecessary_wraps)] - fn get_species(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { + pub fn get_species(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Return the this value. Ok(this.clone()) } @@ -549,7 +549,7 @@ impl TypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray%.prototype.at - fn at(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn at(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). let obj = this @@ -597,7 +597,7 @@ impl TypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-get-%typedarray%.prototype.buffer - fn buffer(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + pub fn buffer(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]). // 3. Assert: O has a [[ViewedArrayBuffer]] internal slot. @@ -622,7 +622,7 @@ impl TypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-get-%typedarray%.prototype.bytelength - fn byte_length(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + pub fn byte_length(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]). // 3. Assert: O has a [[ViewedArrayBuffer]] internal slot. @@ -651,7 +651,7 @@ impl TypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-get-%typedarray%.prototype.byteoffset - fn byte_offset(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + pub fn byte_offset(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]). // 3. Assert: O has a [[ViewedArrayBuffer]] internal slot. @@ -680,7 +680,11 @@ impl TypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray%.prototype.copywithin - fn copy_within(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn copy_within( + this: &JsValue, + args: &[JsValue], + context: &mut Context, + ) -> JsResult { // 1. Let O be the this value. let obj = this .as_object() @@ -849,7 +853,7 @@ impl TypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray%.prototype.entries - fn entries(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + pub fn entries(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). let o = this @@ -877,7 +881,7 @@ impl TypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray%.prototype.every - fn every(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn every(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). let obj = this @@ -936,7 +940,7 @@ impl TypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray%.prototype.fill - fn fill(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn fill(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). let obj = this @@ -1016,7 +1020,7 @@ impl TypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray%.prototype.filter - fn filter(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn filter(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). let obj = this @@ -1097,7 +1101,7 @@ impl TypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray%.prototype.find - fn find(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn find(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). let obj = this @@ -1155,7 +1159,7 @@ impl TypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray%.prototype.findindex - fn findindex(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn findindex(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). let obj = this @@ -1212,7 +1216,7 @@ impl TypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray%.prototype.foreach - fn foreach(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn foreach(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). let obj = this @@ -1264,7 +1268,7 @@ impl TypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray%.prototype.includes - fn includes(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn includes(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). let obj = this @@ -1337,7 +1341,7 @@ impl TypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray%.prototype.indexof - fn index_of(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn index_of(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). let obj = this @@ -1419,7 +1423,7 @@ impl TypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray%.prototype.join - fn join(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn join(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). let obj = this @@ -1476,7 +1480,7 @@ impl TypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray%.prototype.keys - fn keys(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + pub fn keys(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). let o = this @@ -1504,7 +1508,11 @@ impl TypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray%.prototype.lastindexof - fn last_index_of(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn last_index_of( + this: &JsValue, + args: &[JsValue], + context: &mut Context, + ) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). let obj = this @@ -1578,7 +1586,7 @@ impl TypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-get-%typedarray%.prototype.length - fn length(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + pub fn length(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]). // 3. Assert: O has [[ViewedArrayBuffer]] and [[ArrayLength]] internal slots. @@ -1607,7 +1615,7 @@ impl TypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray%.prototype.map - fn map(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn map(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). let obj = this @@ -1665,7 +1673,7 @@ impl TypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray%.prototype.reduce - fn reduce(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn reduce(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). let obj = this @@ -1742,7 +1750,11 @@ impl TypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray%.prototype.reduceright - fn reduceright(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn reduceright( + this: &JsValue, + args: &[JsValue], + context: &mut Context, + ) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). let obj = this @@ -1822,7 +1834,7 @@ impl TypedArray { /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray%.prototype.reverse #[allow(clippy::float_cmp)] - fn reverse(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + pub fn reverse(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). let obj = this @@ -1877,7 +1889,7 @@ impl TypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray%.prototype.set - fn set(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn set(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let target be the this value. // 2. Perform ? RequireInternalSlot(target, [[TypedArrayName]]). // 3. Assert: target has a [[ViewedArrayBuffer]] internal slot. @@ -2255,7 +2267,7 @@ impl TypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray%.prototype.slice - fn slice(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn slice(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). let obj = this @@ -2420,7 +2432,7 @@ impl TypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray%.prototype.some - fn some(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn some(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). let obj = this @@ -2478,7 +2490,7 @@ impl TypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray%.prototype.sort - fn sort(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn sort(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. If comparefn is not undefined and IsCallable(comparefn) is false, throw a TypeError exception. let compare_fn = match args.get(0) { None | Some(JsValue::Undefined) => None, @@ -2686,7 +2698,7 @@ impl TypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray%.prototype.subarray - fn subarray(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { + pub fn subarray(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]). // 3. Assert: O has a [[ViewedArrayBuffer]] internal slot. @@ -2771,7 +2783,7 @@ impl TypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray%.prototype.values - fn values(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + pub fn values(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). let o = this @@ -2800,7 +2812,7 @@ impl TypedArray { /// /// [spec]: https://tc39.es/ecma262/#sec-get-%typedarray%.prototype-@@tostringtag #[allow(clippy::unnecessary_wraps)] - fn to_string_tag(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { + pub fn to_string_tag(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. If Type(O) is not Object, return undefined. // 3. If O does not have a [[TypedArrayName]] internal slot, return undefined. diff --git a/test262 b/test262 index f7fb969cc49..0bccacda693 160000 --- a/test262 +++ b/test262 @@ -1 +1 @@ -Subproject commit f7fb969cc4934bbc5aa29a378d59325eaa84f475 +Subproject commit 0bccacda693ada2cd1736d35eb912b27291ac6ff