From 1da4a27e790d092368f003ce9f7ef23a06494ac8 Mon Sep 17 00:00:00 2001 From: Haled Odat <8566042+HalidOdat@users.noreply.github.com> Date: Thu, 18 Apr 2024 06:56:02 +0200 Subject: [PATCH] Apply review --- cli/src/debug/string.rs | 26 +++-- .../src/builtins/array/array_iterator.rs | 3 +- core/engine/src/builtins/array/mod.rs | 84 +++++++------- .../src/builtins/async_generator/mod.rs | 18 +-- core/engine/src/builtins/atomics/mod.rs | 26 ++--- core/engine/src/builtins/bigint/mod.rs | 9 +- core/engine/src/builtins/boolean/mod.rs | 5 +- core/engine/src/builtins/dataview/mod.rs | 52 +++++---- core/engine/src/builtins/error/mod.rs | 8 +- core/engine/src/builtins/function/mod.rs | 12 +- core/engine/src/builtins/generator/mod.rs | 8 +- core/engine/src/builtins/intl/collator/mod.rs | 12 +- .../src/builtins/intl/list_format/mod.rs | 14 ++- core/engine/src/builtins/intl/locale/mod.rs | 28 ++--- .../src/builtins/intl/plural_rules/mod.rs | 14 ++- .../src/builtins/intl/segmenter/iterator.rs | 6 +- .../engine/src/builtins/intl/segmenter/mod.rs | 12 +- .../src/builtins/intl/segmenter/segments.rs | 4 +- .../iterable/async_from_sync_iterator.rs | 7 +- core/engine/src/builtins/json/mod.rs | 4 +- core/engine/src/builtins/map/map_iterator.rs | 6 +- core/engine/src/builtins/map/mod.rs | 22 ++-- core/engine/src/builtins/math/mod.rs | 89 +++++++-------- core/engine/src/builtins/number/mod.rs | 44 +++---- .../src/builtins/object/for_in_iterator.rs | 4 +- core/engine/src/builtins/object/mod.rs | 84 ++++++++------ core/engine/src/builtins/promise/mod.rs | 6 +- core/engine/src/builtins/reflect/mod.rs | 28 ++--- core/engine/src/builtins/regexp/mod.rs | 55 ++++++--- .../builtins/regexp/regexp_string_iterator.rs | 5 +- core/engine/src/builtins/set/mod.rs | 18 +-- core/engine/src/builtins/set/set_iterator.rs | 6 +- core/engine/src/builtins/string/mod.rs | 108 +++++++++--------- .../src/builtins/string/string_iterator.rs | 5 +- core/engine/src/builtins/symbol/mod.rs | 41 ++++--- .../src/builtins/temporal/calendar/mod.rs | 57 ++++----- .../src/builtins/temporal/duration/mod.rs | 42 +++---- core/engine/src/builtins/temporal/now.rs | 18 +-- .../src/builtins/temporal/plain_date/mod.rs | 55 +++++---- .../src/builtins/temporal/plain_time/mod.rs | 27 +++-- .../builtins/temporal/plain_year_month/mod.rs | 29 +++-- .../src/builtins/temporal/time_zone/mod.rs | 25 ++-- .../src/builtins/typed_array/builtin.rs | 72 ++++++------ core/engine/src/builtins/weak/weak_ref.rs | 6 +- core/engine/src/builtins/weak_map/mod.rs | 9 +- core/engine/src/builtins/weak_set/mod.rs | 7 +- core/engine/src/class.rs | 4 +- core/engine/src/object/mod.rs | 11 -- examples/src/bin/classes.rs | 6 +- tests/tester/src/exec/js262.rs | 40 +++---- 50 files changed, 685 insertions(+), 596 deletions(-) diff --git a/cli/src/debug/string.rs b/cli/src/debug/string.rs index 2ee9e893cbd..ce064ed2af9 100644 --- a/cli/src/debug/string.rs +++ b/cli/src/debug/string.rs @@ -1,6 +1,6 @@ use boa_engine::{ - js_str, js_string, object::ObjectInitializer, property::Attribute, string::JsStrVariant, - Context, JsNativeError, JsObject, JsResult, JsValue, NativeFunction, + js_string, object::ObjectInitializer, property::Attribute, string::JsStrVariant, Context, + JsNativeError, JsObject, JsResult, JsValue, NativeFunction, }; fn storage(_: &JsValue, args: &[JsValue], _: &mut Context) -> JsResult { @@ -61,8 +61,12 @@ fn summary(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult JsResult JsObject { ObjectInitializer::new(context) - .function(NativeFunction::from_fn_ptr(storage), js_str!("storage"), 1) + .function( + NativeFunction::from_fn_ptr(storage), + js_string!("storage"), + 1, + ) .function( NativeFunction::from_fn_ptr(encoding), - js_str!("encoding"), + js_string!("encoding"), + 1, + ) + .function( + NativeFunction::from_fn_ptr(summary), + js_string!("summary"), 1, ) - .function(NativeFunction::from_fn_ptr(summary), js_str!("summary"), 1) .build() } diff --git a/core/engine/src/builtins/array/array_iterator.rs b/core/engine/src/builtins/array/array_iterator.rs index 9b404209ae9..70393e93406 100644 --- a/core/engine/src/builtins/array/array_iterator.rs +++ b/core/engine/src/builtins/array/array_iterator.rs @@ -12,6 +12,7 @@ use crate::{ }, context::intrinsics::Intrinsics, error::JsNativeError, + js_string, object::JsObject, property::{Attribute, PropertyNameKind}, realm::Realm, @@ -49,7 +50,7 @@ impl IntrinsicObject for ArrayIterator { .iterator_prototypes() .iterator(), ) - .static_method(Self::next, js_str!("next"), 0) + .static_method(Self::next, js_string!("next"), 0) .static_property( JsSymbol::to_string_tag(), js_str!("Array Iterator"), diff --git a/core/engine/src/builtins/array/mod.rs b/core/engine/src/builtins/array/mod.rs index 5e776ecaea1..aa962470408 100644 --- a/core/engine/src/builtins/array/mod.rs +++ b/core/engine/src/builtins/array/mod.rs @@ -110,9 +110,9 @@ impl IntrinsicObject for Array { BuiltInBuilder::from_standard_constructor::(realm) // Static Methods - .static_method(Self::from, js_str!("from"), 1) - .static_method(Self::is_array, js_str!("isArray"), 1) - .static_method(Self::of, js_str!("of"), 0) + .static_method(Self::from, js_string!("from"), 1) + .static_method(Self::is_array, js_string!("isArray"), 1) + .static_method(Self::of, js_string!("of"), 0) .static_accessor( JsSymbol::species(), Some(get_species), @@ -124,49 +124,49 @@ impl IntrinsicObject for Array { 0, Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::PERMANENT, ) - .method(Self::at, js_str!("at"), 1) - .method(Self::concat, js_str!("concat"), 1) - .method(Self::copy_within, js_str!("copyWithin"), 2) - .method(Self::entries, js_str!("entries"), 0) - .method(Self::every, js_str!("every"), 1) - .method(Self::fill, js_str!("fill"), 1) - .method(Self::filter, js_str!("filter"), 1) - .method(Self::find, js_str!("find"), 1) - .method(Self::find_index, js_str!("findIndex"), 1) - .method(Self::find_last, js_str!("findLast"), 1) - .method(Self::find_last_index, js_str!("findLastIndex"), 1) - .method(Self::flat, js_str!("flat"), 0) - .method(Self::flat_map, js_str!("flatMap"), 1) - .method(Self::for_each, js_str!("forEach"), 1) - .method(Self::includes_value, js_str!("includes"), 1) - .method(Self::index_of, js_str!("indexOf"), 1) - .method(Self::join, js_str!("join"), 1) - .method(Self::keys, js_str!("keys"), 0) - .method(Self::last_index_of, js_str!("lastIndexOf"), 1) - .method(Self::map, js_str!("map"), 1) - .method(Self::pop, js_str!("pop"), 0) - .method(Self::push, js_str!("push"), 1) - .method(Self::reduce, js_str!("reduce"), 1) - .method(Self::reduce_right, js_str!("reduceRight"), 1) - .method(Self::reverse, js_str!("reverse"), 0) - .method(Self::shift, js_str!("shift"), 0) - .method(Self::slice, js_str!("slice"), 2) - .method(Self::some, js_str!("some"), 1) - .method(Self::sort, js_str!("sort"), 1) - .method(Self::splice, js_str!("splice"), 2) - .method(Self::to_locale_string, js_str!("toLocaleString"), 0) - .method(Self::to_reversed, js_str!("toReversed"), 0) - .method(Self::to_sorted, js_str!("toSorted"), 1) - .method(Self::to_spliced, js_str!("toSpliced"), 2) - .method(Self::unshift, js_str!("unshift"), 1) - .method(Self::with, js_str!("with"), 2) + .method(Self::at, js_string!("at"), 1) + .method(Self::concat, js_string!("concat"), 1) + .method(Self::copy_within, js_string!("copyWithin"), 2) + .method(Self::entries, js_string!("entries"), 0) + .method(Self::every, js_string!("every"), 1) + .method(Self::fill, js_string!("fill"), 1) + .method(Self::filter, js_string!("filter"), 1) + .method(Self::find, js_string!("find"), 1) + .method(Self::find_index, js_string!("findIndex"), 1) + .method(Self::find_last, js_string!("findLast"), 1) + .method(Self::find_last_index, js_string!("findLastIndex"), 1) + .method(Self::flat, js_string!("flat"), 0) + .method(Self::flat_map, js_string!("flatMap"), 1) + .method(Self::for_each, js_string!("forEach"), 1) + .method(Self::includes_value, js_string!("includes"), 1) + .method(Self::index_of, js_string!("indexOf"), 1) + .method(Self::join, js_string!("join"), 1) + .method(Self::keys, js_string!("keys"), 0) + .method(Self::last_index_of, js_string!("lastIndexOf"), 1) + .method(Self::map, js_string!("map"), 1) + .method(Self::pop, js_string!("pop"), 0) + .method(Self::push, js_string!("push"), 1) + .method(Self::reduce, js_string!("reduce"), 1) + .method(Self::reduce_right, js_string!("reduceRight"), 1) + .method(Self::reverse, js_string!("reverse"), 0) + .method(Self::shift, js_string!("shift"), 0) + .method(Self::slice, js_string!("slice"), 2) + .method(Self::some, js_string!("some"), 1) + .method(Self::sort, js_string!("sort"), 1) + .method(Self::splice, js_string!("splice"), 2) + .method(Self::to_locale_string, js_string!("toLocaleString"), 0) + .method(Self::to_reversed, js_string!("toReversed"), 0) + .method(Self::to_sorted, js_string!("toSorted"), 1) + .method(Self::to_spliced, js_string!("toSpliced"), 2) + .method(Self::unshift, js_string!("unshift"), 1) + .method(Self::with, js_string!("with"), 2) .property( - js_str!("toString"), + js_string!("toString"), to_string_function, Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE, ) .property( - js_str!("values"), + js_string!("values"), values_function.clone(), Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE, ) @@ -1051,7 +1051,7 @@ impl Array { // 1. Let array be ? ToObject(this value). let array = this.to_object(context)?; // 2. Let func be ? Get(array, "join"). - let func = array.get(js_str!("join"), context)?; + let func = array.get(js_string!("join"), context)?; // 3. If IsCallable(func) is false, set func to the intrinsic function %Object.prototype.toString%. // 4. Return ? Call(func, array). if let Some(func) = func.as_callable() { diff --git a/core/engine/src/builtins/async_generator/mod.rs b/core/engine/src/builtins/async_generator/mod.rs index 6e1c651a828..976dab93cfe 100644 --- a/core/engine/src/builtins/async_generator/mod.rs +++ b/core/engine/src/builtins/async_generator/mod.rs @@ -7,11 +7,14 @@ use crate::{ builtins::{ - generator::GeneratorContext, iterable::create_iter_result_object, - promise::if_abrupt_reject_promise, promise::PromiseCapability, Promise, + generator::GeneratorContext, + iterable::create_iter_result_object, + promise::{if_abrupt_reject_promise, PromiseCapability}, + Promise, }, context::intrinsics::Intrinsics, error::JsNativeError, + js_string, native_function::NativeFunction, object::{FunctionObjectBuilder, JsObject, CONSTRUCTOR}, property::Attribute, @@ -23,7 +26,6 @@ use crate::{ Context, JsArgs, JsData, JsError, JsResult, JsString, }; use boa_gc::{Finalize, Trace}; -use boa_macros::js_str; use boa_profiler::Profiler; use std::collections::VecDeque; @@ -80,9 +82,9 @@ impl IntrinsicObject for AsyncGenerator { .iterator_prototypes() .async_iterator(), ) - .static_method(Self::next, js_str!("next"), 1) - .static_method(Self::r#return, js_str!("return"), 1) - .static_method(Self::throw, js_str!("throw"), 1) + .static_method(Self::next, js_string!("next"), 1) + .static_method(Self::r#return, js_string!("return"), 1) + .static_method(Self::throw, js_string!("throw"), 1) .static_property( JsSymbol::to_string_tag(), Self::NAME, @@ -576,7 +578,7 @@ impl AsyncGenerator { generator.clone(), ), ) - .name(js_str!("")) + .name(js_string!("")) .length(1) .build(); @@ -611,7 +613,7 @@ impl AsyncGenerator { generator, ), ) - .name(js_str!("")) + .name(js_string!("")) .length(1) .build(); diff --git a/core/engine/src/builtins/atomics/mod.rs b/core/engine/src/builtins/atomics/mod.rs index 064c395a537..db74e6fbca8 100644 --- a/core/engine/src/builtins/atomics/mod.rs +++ b/core/engine/src/builtins/atomics/mod.rs @@ -15,7 +15,7 @@ mod futex; use std::sync::atomic::Ordering; use crate::{ - builtins::BuiltInObject, context::intrinsics::Intrinsics, object::JsObject, + builtins::BuiltInObject, context::intrinsics::Intrinsics, js_string, object::JsObject, property::Attribute, realm::Realm, string::common::StaticJsStrings, symbol::JsSymbol, sys::time::Duration, value::IntegerOrInfinity, Context, JsArgs, JsNativeError, JsResult, JsString, JsValue, @@ -44,18 +44,18 @@ impl IntrinsicObject for Atomics { Self::NAME, Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE, ) - .static_method(Atomics::add, js_str!("add"), 3) - .static_method(Atomics::bit_and, js_str!("and"), 3) - .static_method(Atomics::compare_exchange, js_str!("compareExchange"), 4) - .static_method(Atomics::swap, js_str!("exchange"), 3) - .static_method(Atomics::is_lock_free, js_str!("isLockFree"), 1) - .static_method(Atomics::load, js_str!("load"), 2) - .static_method(Atomics::bit_or, js_str!("or"), 3) - .static_method(Atomics::store, js_str!("store"), 3) - .static_method(Atomics::sub, js_str!("sub"), 3) - .static_method(Atomics::wait, js_str!("wait"), 4) - .static_method(Atomics::notify, js_str!("notify"), 3) - .static_method(Atomics::bit_xor, js_str!("xor"), 3) + .static_method(Atomics::add, js_string!("add"), 3) + .static_method(Atomics::bit_and, js_string!("and"), 3) + .static_method(Atomics::compare_exchange, js_string!("compareExchange"), 4) + .static_method(Atomics::swap, js_string!("exchange"), 3) + .static_method(Atomics::is_lock_free, js_string!("isLockFree"), 1) + .static_method(Atomics::load, js_string!("load"), 2) + .static_method(Atomics::bit_or, js_string!("or"), 3) + .static_method(Atomics::store, js_string!("store"), 3) + .static_method(Atomics::sub, js_string!("sub"), 3) + .static_method(Atomics::wait, js_string!("wait"), 4) + .static_method(Atomics::notify, js_string!("notify"), 3) + .static_method(Atomics::bit_xor, js_string!("xor"), 3) .build(); } diff --git a/core/engine/src/builtins/bigint/mod.rs b/core/engine/src/builtins/bigint/mod.rs index cde62528781..3dc75356b18 100644 --- a/core/engine/src/builtins/bigint/mod.rs +++ b/core/engine/src/builtins/bigint/mod.rs @@ -25,7 +25,6 @@ use crate::{ value::{IntegerOrInfinity, PreferredType}, Context, JsArgs, JsBigInt, JsResult, JsString, JsValue, }; -use boa_macros::js_str; use boa_profiler::Profiler; use num_bigint::ToBigInt; @@ -43,10 +42,10 @@ impl IntrinsicObject for BigInt { let _timer = Profiler::global().start_event(std::any::type_name::(), "init"); BuiltInBuilder::from_standard_constructor::(realm) - .method(Self::to_string, js_str!("toString"), 0) - .method(Self::value_of, js_str!("valueOf"), 0) - .static_method(Self::as_int_n, js_str!("asIntN"), 2) - .static_method(Self::as_uint_n, js_str!("asUintN"), 2) + .method(Self::to_string, js_string!("toString"), 0) + .method(Self::value_of, js_string!("valueOf"), 0) + .static_method(Self::as_int_n, js_string!("asIntN"), 2) + .static_method(Self::as_uint_n, js_string!("asUintN"), 2) .property( JsSymbol::to_string_tag(), Self::NAME, diff --git a/core/engine/src/builtins/boolean/mod.rs b/core/engine/src/builtins/boolean/mod.rs index 07bc08d77f4..3ae156b44b2 100644 --- a/core/engine/src/builtins/boolean/mod.rs +++ b/core/engine/src/builtins/boolean/mod.rs @@ -22,7 +22,6 @@ use crate::{ string::common::StaticJsStrings, Context, JsResult, JsString, JsValue, }; -use boa_macros::js_str; use boa_profiler::Profiler; use super::{BuiltInBuilder, BuiltInConstructor, IntrinsicObject}; @@ -36,8 +35,8 @@ impl IntrinsicObject for Boolean { let _timer = Profiler::global().start_event(std::any::type_name::(), "init"); BuiltInBuilder::from_standard_constructor::(realm) - .method(Self::to_string, js_str!("toString"), 0) - .method(Self::value_of, js_str!("valueOf"), 0) + .method(Self::to_string, js_string!("toString"), 0) + .method(Self::value_of, js_string!("valueOf"), 0) .build(); } diff --git a/core/engine/src/builtins/dataview/mod.rs b/core/engine/src/builtins/dataview/mod.rs index 99563a94406..7274cc1fd94 100644 --- a/core/engine/src/builtins/dataview/mod.rs +++ b/core/engine/src/builtins/dataview/mod.rs @@ -23,7 +23,6 @@ use crate::{ Context, JsArgs, JsData, JsResult, JsString, }; use boa_gc::{Finalize, Trace}; -use boa_macros::js_str; use bytemuck::{bytes_of, bytes_of_mut}; use super::{ @@ -111,39 +110,44 @@ impl IntrinsicObject for DataView { .build(); BuiltInBuilder::from_standard_constructor::(realm) - .accessor(js_str!("buffer"), Some(get_buffer), None, flag_attributes) .accessor( - js_str!("byteLength"), + js_string!("buffer"), + Some(get_buffer), + None, + flag_attributes, + ) + .accessor( + js_string!("byteLength"), Some(get_byte_length), None, flag_attributes, ) .accessor( - js_str!("byteOffset"), + js_string!("byteOffset"), Some(get_byte_offset), None, flag_attributes, ) - .method(Self::get_big_int64, js_str!("getBigInt64"), 1) - .method(Self::get_big_uint64, js_str!("getBigUint64"), 1) - .method(Self::get_float32, js_str!("getFloat32"), 1) - .method(Self::get_float64, js_str!("getFloat64"), 1) - .method(Self::get_int8, js_str!("getInt8"), 1) - .method(Self::get_int16, js_str!("getInt16"), 1) - .method(Self::get_int32, js_str!("getInt32"), 1) - .method(Self::get_uint8, js_str!("getUint8"), 1) - .method(Self::get_uint16, js_str!("getUint16"), 1) - .method(Self::get_uint32, js_str!("getUint32"), 1) - .method(Self::set_big_int64, js_str!("setBigInt64"), 2) - .method(Self::set_big_uint64, js_str!("setBigUint64"), 2) - .method(Self::set_float32, js_str!("setFloat32"), 2) - .method(Self::set_float64, js_str!("setFloat64"), 2) - .method(Self::set_int8, js_str!("setInt8"), 2) - .method(Self::set_int16, js_str!("setInt16"), 2) - .method(Self::set_int32, js_str!("setInt32"), 2) - .method(Self::set_uint8, js_str!("setUint8"), 2) - .method(Self::set_uint16, js_str!("setUint16"), 2) - .method(Self::set_uint32, js_str!("setUint32"), 2) + .method(Self::get_big_int64, js_string!("getBigInt64"), 1) + .method(Self::get_big_uint64, js_string!("getBigUint64"), 1) + .method(Self::get_float32, js_string!("getFloat32"), 1) + .method(Self::get_float64, js_string!("getFloat64"), 1) + .method(Self::get_int8, js_string!("getInt8"), 1) + .method(Self::get_int16, js_string!("getInt16"), 1) + .method(Self::get_int32, js_string!("getInt32"), 1) + .method(Self::get_uint8, js_string!("getUint8"), 1) + .method(Self::get_uint16, js_string!("getUint16"), 1) + .method(Self::get_uint32, js_string!("getUint32"), 1) + .method(Self::set_big_int64, js_string!("setBigInt64"), 2) + .method(Self::set_big_uint64, js_string!("setBigUint64"), 2) + .method(Self::set_float32, js_string!("setFloat32"), 2) + .method(Self::set_float64, js_string!("setFloat64"), 2) + .method(Self::set_int8, js_string!("setInt8"), 2) + .method(Self::set_int16, js_string!("setInt16"), 2) + .method(Self::set_int32, js_string!("setInt32"), 2) + .method(Self::set_uint8, js_string!("setUint8"), 2) + .method(Self::set_uint16, js_string!("setUint16"), 2) + .method(Self::set_uint32, js_string!("setUint32"), 2) .property( JsSymbol::to_string_tag(), Self::NAME, diff --git a/core/engine/src/builtins/error/mod.rs b/core/engine/src/builtins/error/mod.rs index bd94319c3e4..ed005d0e380 100644 --- a/core/engine/src/builtins/error/mod.rs +++ b/core/engine/src/builtins/error/mod.rs @@ -137,9 +137,9 @@ impl IntrinsicObject for Error { let attribute = Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE; BuiltInBuilder::from_standard_constructor::(realm) - .property(js_str!("name"), Self::NAME, attribute) - .property(js_str!("message"), js_string!(), attribute) - .method(Self::to_string, js_str!("toString"), 0) + .property(js_string!("name"), Self::NAME, attribute) + .property(js_string!("message"), js_string!(), attribute) + .method(Self::to_string, js_string!("toString"), 0) .build(); } @@ -192,7 +192,7 @@ impl BuiltInConstructor for Error { let msg = message.to_string(context)?; // b. Perform CreateNonEnumerableDataPropertyOrThrow(O, "message", msg). - o.create_non_enumerable_data_property_or_throw(js_str!("message"), msg, context); + o.create_non_enumerable_data_property_or_throw(js_string!("message"), msg, context); } // 4. Perform ? InstallErrorCause(O, options). diff --git a/core/engine/src/builtins/function/mod.rs b/core/engine/src/builtins/function/mod.rs index f33641be1e7..70f8d444e1a 100644 --- a/core/engine/src/builtins/function/mod.rs +++ b/core/engine/src/builtins/function/mod.rs @@ -309,19 +309,19 @@ impl IntrinsicObject for BuiltInFunctionObject { let throw_type_error = realm.intrinsics().objects().throw_type_error(); BuiltInBuilder::from_standard_constructor::(realm) - .method(Self::apply, js_str!("apply"), 2) - .method(Self::bind, js_str!("bind"), 1) - .method(Self::call, js_str!("call"), 1) - .method(Self::to_string, js_str!("toString"), 0) + .method(Self::apply, js_string!("apply"), 2) + .method(Self::bind, js_string!("bind"), 1) + .method(Self::call, js_string!("call"), 1) + .method(Self::to_string, js_string!("toString"), 0) .property(JsSymbol::has_instance(), has_instance, Attribute::default()) .accessor( - js_str!("caller"), + js_string!("caller"), Some(throw_type_error.clone()), Some(throw_type_error.clone()), Attribute::CONFIGURABLE, ) .accessor( - js_str!("arguments"), + js_string!("arguments"), Some(throw_type_error.clone()), Some(throw_type_error), Attribute::CONFIGURABLE, diff --git a/core/engine/src/builtins/generator/mod.rs b/core/engine/src/builtins/generator/mod.rs index e349a67746d..3a9d56aa5b6 100644 --- a/core/engine/src/builtins/generator/mod.rs +++ b/core/engine/src/builtins/generator/mod.rs @@ -13,6 +13,7 @@ use crate::{ builtins::iterable::create_iter_result_object, context::intrinsics::Intrinsics, error::JsNativeError, + js_string, object::{JsObject, CONSTRUCTOR}, property::Attribute, realm::Realm, @@ -23,7 +24,6 @@ use crate::{ Context, JsArgs, JsData, JsError, JsResult, JsString, }; use boa_gc::{custom_trace, Finalize, Trace}; -use boa_macros::js_str; use boa_profiler::Profiler; use super::{BuiltInBuilder, IntrinsicObject}; @@ -139,9 +139,9 @@ impl IntrinsicObject for Generator { .iterator_prototypes() .iterator(), ) - .static_method(Self::next, js_str!("next"), 1) - .static_method(Self::r#return, js_str!("return"), 1) - .static_method(Self::throw, js_str!("throw"), 1) + .static_method(Self::next, js_string!("next"), 1) + .static_method(Self::r#return, js_string!("return"), 1) + .static_method(Self::throw, js_string!("throw"), 1) .static_property( JsSymbol::to_string_tag(), Self::NAME, diff --git a/core/engine/src/builtins/intl/collator/mod.rs b/core/engine/src/builtins/intl/collator/mod.rs index 4f9ef56a728..a99aec57a68 100644 --- a/core/engine/src/builtins/intl/collator/mod.rs +++ b/core/engine/src/builtins/intl/collator/mod.rs @@ -158,19 +158,23 @@ impl IntrinsicObject for Collator { .build(); BuiltInBuilder::from_standard_constructor::(realm) - .static_method(Self::supported_locales_of, js_str!("supportedLocalesOf"), 1) + .static_method( + Self::supported_locales_of, + js_string!("supportedLocalesOf"), + 1, + ) .property( JsSymbol::to_string_tag(), - js_str!("Intl.Collator"), + js_string!("Intl.Collator"), Attribute::CONFIGURABLE, ) .accessor( - js_str!("compare"), + js_string!("compare"), Some(compare), None, Attribute::CONFIGURABLE, ) - .method(Self::resolved_options, js_str!("resolvedOptions"), 0) + .method(Self::resolved_options, js_string!("resolvedOptions"), 0) .build(); } diff --git a/core/engine/src/builtins/intl/list_format/mod.rs b/core/engine/src/builtins/intl/list_format/mod.rs index 7c0e04b6ddf..c76889ffaed 100644 --- a/core/engine/src/builtins/intl/list_format/mod.rs +++ b/core/engine/src/builtins/intl/list_format/mod.rs @@ -52,15 +52,19 @@ impl IntrinsicObject for ListFormat { let _timer = Profiler::global().start_event(std::any::type_name::(), "init"); BuiltInBuilder::from_standard_constructor::(realm) - .static_method(Self::supported_locales_of, js_str!("supportedLocalesOf"), 1) + .static_method( + Self::supported_locales_of, + js_string!("supportedLocalesOf"), + 1, + ) .property( JsSymbol::to_string_tag(), - js_str!("Intl.ListFormat"), + js_string!("Intl.ListFormat"), Attribute::CONFIGURABLE, ) - .method(Self::format, js_str!("format"), 1) - .method(Self::format_to_parts, js_str!("formatToParts"), 1) - .method(Self::resolved_options, js_str!("resolvedOptions"), 0) + .method(Self::format, js_string!("format"), 1) + .method(Self::format_to_parts, js_string!("formatToParts"), 1) + .method(Self::resolved_options, js_string!("resolvedOptions"), 0) .build(); } diff --git a/core/engine/src/builtins/intl/locale/mod.rs b/core/engine/src/builtins/intl/locale/mod.rs index b416f4b7103..a70ab770f63 100644 --- a/core/engine/src/builtins/intl/locale/mod.rs +++ b/core/engine/src/builtins/intl/locale/mod.rs @@ -77,68 +77,68 @@ impl IntrinsicObject for Locale { BuiltInBuilder::from_standard_constructor::(realm) .property( JsSymbol::to_string_tag(), - js_str!("Intl.Locale"), + js_string!("Intl.Locale"), Attribute::CONFIGURABLE, ) - .method(Self::maximize, js_str!("maximize"), 0) - .method(Self::minimize, js_str!("minimize"), 0) - .method(Self::to_string, js_str!("toString"), 0) + .method(Self::maximize, js_string!("maximize"), 0) + .method(Self::minimize, js_string!("minimize"), 0) + .method(Self::to_string, js_string!("toString"), 0) .accessor( - js_str!("baseName"), + js_string!("baseName"), Some(base_name), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("calendar"), + js_string!("calendar"), Some(calendar), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("caseFirst"), + js_string!("caseFirst"), Some(case_first), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("collation"), + js_string!("collation"), Some(collation), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("hourCycle"), + js_string!("hourCycle"), Some(hour_cycle), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("numeric"), + js_string!("numeric"), Some(numeric), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("numberingSystem"), + js_string!("numberingSystem"), Some(numbering_system), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("language"), + js_string!("language"), Some(language), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("script"), + js_string!("script"), Some(script), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("region"), + js_string!("region"), Some(region), None, Attribute::CONFIGURABLE, diff --git a/core/engine/src/builtins/intl/plural_rules/mod.rs b/core/engine/src/builtins/intl/plural_rules/mod.rs index 627203377ab..d0dad83b308 100644 --- a/core/engine/src/builtins/intl/plural_rules/mod.rs +++ b/core/engine/src/builtins/intl/plural_rules/mod.rs @@ -53,15 +53,19 @@ impl IntrinsicObject for PluralRules { let _timer = Profiler::global().start_event(std::any::type_name::(), "init"); BuiltInBuilder::from_standard_constructor::(realm) - .static_method(Self::supported_locales_of, js_str!("supportedLocalesOf"), 1) + .static_method( + Self::supported_locales_of, + js_string!("supportedLocalesOf"), + 1, + ) .property( JsSymbol::to_string_tag(), - js_str!("Intl.PluralRules"), + js_string!("Intl.PluralRules"), Attribute::CONFIGURABLE, ) - .method(Self::resolved_options, js_str!("resolvedOptions"), 0) - .method(Self::select, js_str!("select"), 1) - .method(Self::select_range, js_str!("selectRange"), 2) + .method(Self::resolved_options, js_string!("resolvedOptions"), 0) + .method(Self::select, js_string!("select"), 1) + .method(Self::select_range, js_string!("selectRange"), 2) .build(); } diff --git a/core/engine/src/builtins/intl/segmenter/iterator.rs b/core/engine/src/builtins/intl/segmenter/iterator.rs index af440efb8ee..7ed7ef663c2 100644 --- a/core/engine/src/builtins/intl/segmenter/iterator.rs +++ b/core/engine/src/builtins/intl/segmenter/iterator.rs @@ -1,5 +1,4 @@ use boa_gc::{Finalize, Trace}; -use boa_macros::js_str; use boa_profiler::Profiler; use icu_segmenter::{ GraphemeClusterBreakIteratorLatin1, GraphemeClusterBreakIteratorUtf16, @@ -10,6 +9,7 @@ use icu_segmenter::{ use crate::{ builtins::{iterable::create_iter_result_object, BuiltInBuilder, IntrinsicObject}, context::intrinsics::Intrinsics, + js_string, property::Attribute, realm::Realm, Context, JsData, JsNativeError, JsObject, JsResult, JsString, JsSymbol, JsValue, @@ -67,10 +67,10 @@ impl IntrinsicObject for SegmentIterator { BuiltInBuilder::with_intrinsic::(realm) .static_property( JsSymbol::to_string_tag(), - js_str!("Segmenter String Iterator"), + js_string!("Segmenter String Iterator"), Attribute::CONFIGURABLE, ) - .static_method(Self::next, js_str!("next"), 0) + .static_method(Self::next, js_string!("next"), 0) .build(); } diff --git a/core/engine/src/builtins/intl/segmenter/mod.rs b/core/engine/src/builtins/intl/segmenter/mod.rs index 53b10a01130..517e359b688 100644 --- a/core/engine/src/builtins/intl/segmenter/mod.rs +++ b/core/engine/src/builtins/intl/segmenter/mod.rs @@ -89,14 +89,18 @@ impl IntrinsicObject for Segmenter { let _timer = Profiler::global().start_event(std::any::type_name::(), "init"); BuiltInBuilder::from_standard_constructor::(realm) - .static_method(Self::supported_locales_of, js_str!("supportedLocalesOf"), 1) + .static_method( + Self::supported_locales_of, + js_string!("supportedLocalesOf"), + 1, + ) .property( JsSymbol::to_string_tag(), - js_str!("Intl.Segmenter"), + js_string!("Intl.Segmenter"), Attribute::CONFIGURABLE, ) - .method(Self::resolved_options, js_str!("resolvedOptions"), 0) - .method(Self::segment, js_str!("segment"), 1) + .method(Self::resolved_options, js_string!("resolvedOptions"), 0) + .method(Self::segment, js_string!("segment"), 1) .build(); } diff --git a/core/engine/src/builtins/intl/segmenter/segments.rs b/core/engine/src/builtins/intl/segmenter/segments.rs index dc0dc6b3eaa..65487c362d9 100644 --- a/core/engine/src/builtins/intl/segmenter/segments.rs +++ b/core/engine/src/builtins/intl/segmenter/segments.rs @@ -1,11 +1,11 @@ use boa_gc::{Finalize, Trace}; -use boa_macros::js_str; use boa_profiler::Profiler; use itertools::Itertools; use crate::{ builtins::{BuiltInBuilder, IntrinsicObject}, context::intrinsics::Intrinsics, + js_string, realm::Realm, Context, JsArgs, JsData, JsNativeError, JsObject, JsResult, JsString, JsSymbol, JsValue, }; @@ -23,7 +23,7 @@ impl IntrinsicObject for Segments { let _timer = Profiler::global().start_event("%SegmentsPrototype%", "init"); BuiltInBuilder::with_intrinsic::(realm) - .static_method(Self::containing, js_str!("containing"), 1) + .static_method(Self::containing, js_string!("containing"), 1) .static_method(Self::iterator, JsSymbol::iterator(), 0) .build(); } diff --git a/core/engine/src/builtins/iterable/async_from_sync_iterator.rs b/core/engine/src/builtins/iterable/async_from_sync_iterator.rs index 9b90e7323ec..8854bdf00e6 100644 --- a/core/engine/src/builtins/iterable/async_from_sync_iterator.rs +++ b/core/engine/src/builtins/iterable/async_from_sync_iterator.rs @@ -5,6 +5,7 @@ use crate::{ BuiltInBuilder, IntrinsicObject, Promise, }, context::intrinsics::Intrinsics, + js_string, native_function::NativeFunction, object::{FunctionObjectBuilder, JsObject}, realm::Realm, @@ -38,9 +39,9 @@ impl IntrinsicObject for AsyncFromSyncIterator { .iterator_prototypes() .async_iterator(), ) - .static_method(Self::next, js_str!("next"), 1) - .static_method(Self::r#return, js_str!("return"), 1) - .static_method(Self::throw, js_str!("throw"), 1) + .static_method(Self::next, js_string!("next"), 1) + .static_method(Self::r#return, js_string!("return"), 1) + .static_method(Self::throw, js_string!("throw"), 1) .build(); } diff --git a/core/engine/src/builtins/json/mod.rs b/core/engine/src/builtins/json/mod.rs index a200c8f7464..e2e9b24104c 100644 --- a/core/engine/src/builtins/json/mod.rs +++ b/core/engine/src/builtins/json/mod.rs @@ -54,8 +54,8 @@ impl IntrinsicObject for Json { let attribute = Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE; BuiltInBuilder::with_intrinsic::(realm) - .static_method(Self::parse, js_str!("parse"), 2) - .static_method(Self::stringify, js_str!("stringify"), 3) + .static_method(Self::parse, js_string!("parse"), 2) + .static_method(Self::stringify, js_string!("stringify"), 3) .static_property(to_string_tag, Self::NAME, attribute) .build(); } diff --git a/core/engine/src/builtins/map/map_iterator.rs b/core/engine/src/builtins/map/map_iterator.rs index b6d7d3f8e38..5a6a1ed4017 100644 --- a/core/engine/src/builtins/map/map_iterator.rs +++ b/core/engine/src/builtins/map/map_iterator.rs @@ -12,6 +12,7 @@ use crate::{ }, context::intrinsics::Intrinsics, error::JsNativeError, + js_string, object::JsObject, property::{Attribute, PropertyNameKind}, realm::Realm, @@ -19,7 +20,6 @@ use crate::{ Context, JsData, JsResult, }; use boa_gc::{Finalize, Trace}; -use boa_macros::js_str; use boa_profiler::Profiler; /// The Map Iterator object represents an iteration over a map. It implements the iterator protocol. @@ -49,10 +49,10 @@ impl IntrinsicObject for MapIterator { .iterator_prototypes() .iterator(), ) - .static_method(Self::next, js_str!("next"), 0) + .static_method(Self::next, js_string!("next"), 0) .static_property( JsSymbol::to_string_tag(), - js_str!("Map Iterator"), + js_string!("Map Iterator"), Attribute::CONFIGURABLE, ) .build(); diff --git a/core/engine/src/builtins/map/mod.rs b/core/engine/src/builtins/map/mod.rs index 76edde995c8..c5c4edee468 100644 --- a/core/engine/src/builtins/map/mod.rs +++ b/core/engine/src/builtins/map/mod.rs @@ -56,7 +56,7 @@ impl IntrinsicObject for Map { .build(); BuiltInBuilder::from_standard_constructor::(realm) - .static_method(Self::group_by, js_str!("groupBy"), 2) + .static_method(Self::group_by, js_string!("groupBy"), 2) .static_accessor( JsSymbol::species(), Some(get_species), @@ -64,7 +64,7 @@ impl IntrinsicObject for Map { Attribute::CONFIGURABLE, ) .property( - js_str!("entries"), + js_string!("entries"), entries_function.clone(), Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE, ) @@ -78,16 +78,16 @@ impl IntrinsicObject for Map { Self::NAME, Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE, ) - .method(Self::clear, js_str!("clear"), 0) - .method(Self::delete, js_str!("delete"), 1) - .method(Self::for_each, js_str!("forEach"), 1) - .method(Self::get, js_str!("get"), 1) - .method(Self::has, js_str!("has"), 1) - .method(Self::keys, js_str!("keys"), 0) - .method(Self::set, js_str!("set"), 2) - .method(Self::values, js_str!("values"), 0) + .method(Self::clear, js_string!("clear"), 0) + .method(Self::delete, js_string!("delete"), 1) + .method(Self::for_each, js_string!("forEach"), 1) + .method(Self::get, js_string!("get"), 1) + .method(Self::has, js_string!("has"), 1) + .method(Self::keys, js_string!("keys"), 0) + .method(Self::set, js_string!("set"), 2) + .method(Self::values, js_string!("values"), 0) .accessor( - js_str!("size"), + js_string!("size"), Some(get_size), None, Attribute::CONFIGURABLE, diff --git a/core/engine/src/builtins/math/mod.rs b/core/engine/src/builtins/math/mod.rs index 21effd1d33f..13d5748c071 100644 --- a/core/engine/src/builtins/math/mod.rs +++ b/core/engine/src/builtins/math/mod.rs @@ -12,11 +12,10 @@ //! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math use crate::{ - builtins::BuiltInObject, context::intrinsics::Intrinsics, object::JsObject, + builtins::BuiltInObject, context::intrinsics::Intrinsics, js_string, object::JsObject, property::Attribute, realm::Realm, string::common::StaticJsStrings, symbol::JsSymbol, Context, JsArgs, JsResult, JsString, JsValue, }; -use boa_macros::js_str; use boa_profiler::Profiler; use super::{BuiltInBuilder, IntrinsicObject}; @@ -34,53 +33,53 @@ impl IntrinsicObject for Math { let attribute = Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::PERMANENT; BuiltInBuilder::with_intrinsic::(realm) - .static_property(js_str!("E"), std::f64::consts::E, attribute) - .static_property(js_str!("LN10"), std::f64::consts::LN_10, attribute) - .static_property(js_str!("LN2"), std::f64::consts::LN_2, attribute) - .static_property(js_str!("LOG10E"), std::f64::consts::LOG10_E, attribute) - .static_property(js_str!("LOG2E"), std::f64::consts::LOG2_E, attribute) - .static_property(js_str!("PI"), std::f64::consts::PI, attribute) + .static_property(js_string!("E"), std::f64::consts::E, attribute) + .static_property(js_string!("LN10"), std::f64::consts::LN_10, attribute) + .static_property(js_string!("LN2"), std::f64::consts::LN_2, attribute) + .static_property(js_string!("LOG10E"), std::f64::consts::LOG10_E, attribute) + .static_property(js_string!("LOG2E"), std::f64::consts::LOG2_E, attribute) + .static_property(js_string!("PI"), std::f64::consts::PI, attribute) .static_property( - js_str!("SQRT1_2"), + js_string!("SQRT1_2"), std::f64::consts::FRAC_1_SQRT_2, attribute, ) - .static_property(js_str!("SQRT2"), std::f64::consts::SQRT_2, attribute) - .static_method(Self::abs, js_str!("abs"), 1) - .static_method(Self::acos, js_str!("acos"), 1) - .static_method(Self::acosh, js_str!("acosh"), 1) - .static_method(Self::asin, js_str!("asin"), 1) - .static_method(Self::asinh, js_str!("asinh"), 1) - .static_method(Self::atan, js_str!("atan"), 1) - .static_method(Self::atanh, js_str!("atanh"), 1) - .static_method(Self::atan2, js_str!("atan2"), 2) - .static_method(Self::cbrt, js_str!("cbrt"), 1) - .static_method(Self::ceil, js_str!("ceil"), 1) - .static_method(Self::clz32, js_str!("clz32"), 1) - .static_method(Self::cos, js_str!("cos"), 1) - .static_method(Self::cosh, js_str!("cosh"), 1) - .static_method(Self::exp, js_str!("exp"), 1) - .static_method(Self::expm1, js_str!("expm1"), 1) - .static_method(Self::floor, js_str!("floor"), 1) - .static_method(Self::fround, js_str!("fround"), 1) - .static_method(Self::hypot, js_str!("hypot"), 2) - .static_method(Self::imul, js_str!("imul"), 2) - .static_method(Self::log, js_str!("log"), 1) - .static_method(Self::log1p, js_str!("log1p"), 1) - .static_method(Self::log10, js_str!("log10"), 1) - .static_method(Self::log2, js_str!("log2"), 1) - .static_method(Self::max, js_str!("max"), 2) - .static_method(Self::min, js_str!("min"), 2) - .static_method(Self::pow, js_str!("pow"), 2) - .static_method(Self::random, js_str!("random"), 0) - .static_method(Self::round, js_str!("round"), 1) - .static_method(Self::sign, js_str!("sign"), 1) - .static_method(Self::sin, js_str!("sin"), 1) - .static_method(Self::sinh, js_str!("sinh"), 1) - .static_method(Self::sqrt, js_str!("sqrt"), 1) - .static_method(Self::tan, js_str!("tan"), 1) - .static_method(Self::tanh, js_str!("tanh"), 1) - .static_method(Self::trunc, js_str!("trunc"), 1) + .static_property(js_string!("SQRT2"), std::f64::consts::SQRT_2, attribute) + .static_method(Self::abs, js_string!("abs"), 1) + .static_method(Self::acos, js_string!("acos"), 1) + .static_method(Self::acosh, js_string!("acosh"), 1) + .static_method(Self::asin, js_string!("asin"), 1) + .static_method(Self::asinh, js_string!("asinh"), 1) + .static_method(Self::atan, js_string!("atan"), 1) + .static_method(Self::atanh, js_string!("atanh"), 1) + .static_method(Self::atan2, js_string!("atan2"), 2) + .static_method(Self::cbrt, js_string!("cbrt"), 1) + .static_method(Self::ceil, js_string!("ceil"), 1) + .static_method(Self::clz32, js_string!("clz32"), 1) + .static_method(Self::cos, js_string!("cos"), 1) + .static_method(Self::cosh, js_string!("cosh"), 1) + .static_method(Self::exp, js_string!("exp"), 1) + .static_method(Self::expm1, js_string!("expm1"), 1) + .static_method(Self::floor, js_string!("floor"), 1) + .static_method(Self::fround, js_string!("fround"), 1) + .static_method(Self::hypot, js_string!("hypot"), 2) + .static_method(Self::imul, js_string!("imul"), 2) + .static_method(Self::log, js_string!("log"), 1) + .static_method(Self::log1p, js_string!("log1p"), 1) + .static_method(Self::log10, js_string!("log10"), 1) + .static_method(Self::log2, js_string!("log2"), 1) + .static_method(Self::max, js_string!("max"), 2) + .static_method(Self::min, js_string!("min"), 2) + .static_method(Self::pow, js_string!("pow"), 2) + .static_method(Self::random, js_string!("random"), 0) + .static_method(Self::round, js_string!("round"), 1) + .static_method(Self::sign, js_string!("sign"), 1) + .static_method(Self::sin, js_string!("sin"), 1) + .static_method(Self::sinh, js_string!("sinh"), 1) + .static_method(Self::sqrt, js_string!("sqrt"), 1) + .static_method(Self::tan, js_string!("tan"), 1) + .static_method(Self::tanh, js_string!("tanh"), 1) + .static_method(Self::trunc, js_string!("trunc"), 1) .static_property( JsSymbol::to_string_tag(), Self::NAME, diff --git a/core/engine/src/builtins/number/mod.rs b/core/engine/src/builtins/number/mod.rs index 7da79a76605..025c25acf6e 100644 --- a/core/engine/src/builtins/number/mod.rs +++ b/core/engine/src/builtins/number/mod.rs @@ -54,42 +54,46 @@ impl IntrinsicObject for Number { let attribute = Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::PERMANENT; BuiltInBuilder::from_standard_constructor::(realm) - .static_property(js_str!("EPSILON"), f64::EPSILON, attribute) + .static_property(js_string!("EPSILON"), f64::EPSILON, attribute) .static_property( - js_str!("MAX_SAFE_INTEGER"), + js_string!("MAX_SAFE_INTEGER"), Self::MAX_SAFE_INTEGER, attribute, ) .static_property( - js_str!("MIN_SAFE_INTEGER"), + js_string!("MIN_SAFE_INTEGER"), Self::MIN_SAFE_INTEGER, attribute, ) - .static_property(js_str!("MAX_VALUE"), Self::MAX_VALUE, attribute) - .static_property(js_str!("MIN_VALUE"), Self::MIN_VALUE, attribute) - .static_property(js_str!("NEGATIVE_INFINITY"), f64::NEG_INFINITY, attribute) - .static_property(js_str!("POSITIVE_INFINITY"), f64::INFINITY, attribute) - .static_property(js_str!("NaN"), f64::NAN, attribute) + .static_property(js_string!("MAX_VALUE"), Self::MAX_VALUE, attribute) + .static_property(js_string!("MIN_VALUE"), Self::MIN_VALUE, attribute) .static_property( - js_str!("parseInt"), + js_string!("NEGATIVE_INFINITY"), + f64::NEG_INFINITY, + attribute, + ) + .static_property(js_string!("POSITIVE_INFINITY"), f64::INFINITY, attribute) + .static_property(js_string!("NaN"), f64::NAN, attribute) + .static_property( + js_string!("parseInt"), realm.intrinsics().objects().parse_int(), Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE, ) .static_property( - js_str!("parseFloat"), + js_string!("parseFloat"), realm.intrinsics().objects().parse_float(), Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE, ) - .static_method(Self::number_is_finite, js_str!("isFinite"), 1) - .static_method(Self::number_is_nan, js_str!("isNaN"), 1) - .static_method(Self::is_safe_integer, js_str!("isSafeInteger"), 1) - .static_method(Self::number_is_integer, js_str!("isInteger"), 1) - .method(Self::to_exponential, js_str!("toExponential"), 1) - .method(Self::to_fixed, js_str!("toFixed"), 1) - .method(Self::to_locale_string, js_str!("toLocaleString"), 0) - .method(Self::to_precision, js_str!("toPrecision"), 1) - .method(Self::to_string, js_str!("toString"), 1) - .method(Self::value_of, js_str!("valueOf"), 0) + .static_method(Self::number_is_finite, js_string!("isFinite"), 1) + .static_method(Self::number_is_nan, js_string!("isNaN"), 1) + .static_method(Self::is_safe_integer, js_string!("isSafeInteger"), 1) + .static_method(Self::number_is_integer, js_string!("isInteger"), 1) + .method(Self::to_exponential, js_string!("toExponential"), 1) + .method(Self::to_fixed, js_string!("toFixed"), 1) + .method(Self::to_locale_string, js_string!("toLocaleString"), 0) + .method(Self::to_precision, js_string!("toPrecision"), 1) + .method(Self::to_string, js_string!("toString"), 1) + .method(Self::value_of, js_string!("valueOf"), 0) .build(); } diff --git a/core/engine/src/builtins/object/for_in_iterator.rs b/core/engine/src/builtins/object/for_in_iterator.rs index 4afc08ef5c8..cbaf5adf0b7 100644 --- a/core/engine/src/builtins/object/for_in_iterator.rs +++ b/core/engine/src/builtins/object/for_in_iterator.rs @@ -12,13 +12,13 @@ use crate::{ builtins::{iterable::create_iter_result_object, BuiltInBuilder, IntrinsicObject}, context::intrinsics::Intrinsics, error::JsNativeError, + js_string, object::{internal_methods::InternalMethodContext, JsObject}, property::PropertyKey, realm::Realm, Context, JsData, JsResult, JsString, JsValue, }; use boa_gc::{Finalize, Trace}; -use boa_macros::js_str; use boa_profiler::Profiler; use rustc_hash::FxHashSet; use std::collections::VecDeque; @@ -50,7 +50,7 @@ impl IntrinsicObject for ForInIterator { .iterator_prototypes() .iterator(), ) - .static_method(Self::next, js_str!("next"), 0) + .static_method(Self::next, js_string!("next"), 0) .build(); } diff --git a/core/engine/src/builtins/object/mod.rs b/core/engine/src/builtins/object/mod.rs index 501fb30be9d..a0fe6351913 100644 --- a/core/engine/src/builtins/object/mod.rs +++ b/core/engine/src/builtins/object/mod.rs @@ -62,64 +62,80 @@ impl IntrinsicObject for OrdinaryObject { BuiltInBuilder::from_standard_constructor::(realm) .inherits(None) .accessor( - js_str!("__proto__"), + js_string!("__proto__"), Some(legacy_proto_getter), Some(legacy_setter_proto), Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE, ) - .method(Self::has_own_property, js_str!("hasOwnProperty"), 1) + .method(Self::has_own_property, js_string!("hasOwnProperty"), 1) .method( Self::property_is_enumerable, - js_str!("propertyIsEnumerable"), + js_string!("propertyIsEnumerable"), 1, ) - .method(Self::to_string, js_str!("toString"), 0) - .method(Self::to_locale_string, js_str!("toLocaleString"), 0) - .method(Self::value_of, js_str!("valueOf"), 0) - .method(Self::is_prototype_of, js_str!("isPrototypeOf"), 1) - .method(Self::legacy_define_getter, js_str!("__defineGetter__"), 2) - .method(Self::legacy_define_setter, js_str!("__defineSetter__"), 2) - .method(Self::legacy_lookup_getter, js_str!("__lookupGetter__"), 1) - .method(Self::legacy_lookup_setter, js_str!("__lookupSetter__"), 1) - .static_method(Self::create, js_str!("create"), 2) - .static_method(Self::set_prototype_of, js_str!("setPrototypeOf"), 2) - .static_method(Self::get_prototype_of, js_str!("getPrototypeOf"), 1) - .static_method(Self::define_property, js_str!("defineProperty"), 3) - .static_method(Self::define_properties, js_str!("defineProperties"), 2) - .static_method(Self::assign, js_str!("assign"), 2) - .static_method(Self::is, js_str!("is"), 2) - .static_method(Self::keys, js_str!("keys"), 1) - .static_method(Self::values, js_str!("values"), 1) - .static_method(Self::entries, js_str!("entries"), 1) - .static_method(Self::seal, js_str!("seal"), 1) - .static_method(Self::is_sealed, js_str!("isSealed"), 1) - .static_method(Self::freeze, js_str!("freeze"), 1) - .static_method(Self::is_frozen, js_str!("isFrozen"), 1) - .static_method(Self::prevent_extensions, js_str!("preventExtensions"), 1) - .static_method(Self::is_extensible, js_str!("isExtensible"), 1) + .method(Self::to_string, js_string!("toString"), 0) + .method(Self::to_locale_string, js_string!("toLocaleString"), 0) + .method(Self::value_of, js_string!("valueOf"), 0) + .method(Self::is_prototype_of, js_string!("isPrototypeOf"), 1) + .method( + Self::legacy_define_getter, + js_string!("__defineGetter__"), + 2, + ) + .method( + Self::legacy_define_setter, + js_string!("__defineSetter__"), + 2, + ) + .method( + Self::legacy_lookup_getter, + js_string!("__lookupGetter__"), + 1, + ) + .method( + Self::legacy_lookup_setter, + js_string!("__lookupSetter__"), + 1, + ) + .static_method(Self::create, js_string!("create"), 2) + .static_method(Self::set_prototype_of, js_string!("setPrototypeOf"), 2) + .static_method(Self::get_prototype_of, js_string!("getPrototypeOf"), 1) + .static_method(Self::define_property, js_string!("defineProperty"), 3) + .static_method(Self::define_properties, js_string!("defineProperties"), 2) + .static_method(Self::assign, js_string!("assign"), 2) + .static_method(Self::is, js_string!("is"), 2) + .static_method(Self::keys, js_string!("keys"), 1) + .static_method(Self::values, js_string!("values"), 1) + .static_method(Self::entries, js_string!("entries"), 1) + .static_method(Self::seal, js_string!("seal"), 1) + .static_method(Self::is_sealed, js_string!("isSealed"), 1) + .static_method(Self::freeze, js_string!("freeze"), 1) + .static_method(Self::is_frozen, js_string!("isFrozen"), 1) + .static_method(Self::prevent_extensions, js_string!("preventExtensions"), 1) + .static_method(Self::is_extensible, js_string!("isExtensible"), 1) .static_method( Self::get_own_property_descriptor, - js_str!("getOwnPropertyDescriptor"), + js_string!("getOwnPropertyDescriptor"), 2, ) .static_method( Self::get_own_property_descriptors, - js_str!("getOwnPropertyDescriptors"), + js_string!("getOwnPropertyDescriptors"), 1, ) .static_method( Self::get_own_property_names, - js_str!("getOwnPropertyNames"), + js_string!("getOwnPropertyNames"), 1, ) .static_method( Self::get_own_property_symbols, - js_str!("getOwnPropertySymbols"), + js_string!("getOwnPropertySymbols"), 1, ) - .static_method(Self::has_own, js_str!("hasOwn"), 2) - .static_method(Self::from_entries, js_str!("fromEntries"), 1) - .static_method(Self::group_by, js_str!("groupBy"), 2) + .static_method(Self::has_own, js_string!("hasOwn"), 2) + .static_method(Self::from_entries, js_string!("fromEntries"), 1) + .static_method(Self::group_by, js_string!("groupBy"), 2) .build(); } diff --git a/core/engine/src/builtins/promise/mod.rs b/core/engine/src/builtins/promise/mod.rs index fec5c6c4977..8d1b45beb67 100644 --- a/core/engine/src/builtins/promise/mod.rs +++ b/core/engine/src/builtins/promise/mod.rs @@ -355,9 +355,9 @@ impl IntrinsicObject for Promise { None, Attribute::CONFIGURABLE, ) - .method(Self::then, js_str!("then"), 2) - .method(Self::catch, js_str!("catch"), 1) - .method(Self::finally, js_str!("finally"), 1) + .method(Self::then, js_string!("then"), 2) + .method(Self::catch, js_string!("catch"), 1) + .method(Self::finally, js_string!("finally"), 1) // .property( JsSymbol::to_string_tag(), diff --git a/core/engine/src/builtins/reflect/mod.rs b/core/engine/src/builtins/reflect/mod.rs index 8f6c3142959..f4d405adf76 100644 --- a/core/engine/src/builtins/reflect/mod.rs +++ b/core/engine/src/builtins/reflect/mod.rs @@ -15,6 +15,7 @@ use crate::{ builtins::{self, BuiltInObject}, context::intrinsics::Intrinsics, error::JsNativeError, + js_string, object::{internal_methods::InternalMethodContext, JsObject}, property::Attribute, realm::Realm, @@ -22,7 +23,6 @@ use crate::{ symbol::JsSymbol, Context, JsArgs, JsResult, JsString, JsValue, }; -use boa_macros::js_str; use boa_profiler::Profiler; #[cfg(test)] @@ -39,23 +39,23 @@ impl IntrinsicObject for Reflect { let to_string_tag = JsSymbol::to_string_tag(); BuiltInBuilder::with_intrinsic::(realm) - .static_method(Self::apply, js_str!("apply"), 3) - .static_method(Self::construct, js_str!("construct"), 2) - .static_method(Self::define_property, js_str!("defineProperty"), 3) - .static_method(Self::delete_property, js_str!("deleteProperty"), 2) - .static_method(Self::get, js_str!("get"), 2) + .static_method(Self::apply, js_string!("apply"), 3) + .static_method(Self::construct, js_string!("construct"), 2) + .static_method(Self::define_property, js_string!("defineProperty"), 3) + .static_method(Self::delete_property, js_string!("deleteProperty"), 2) + .static_method(Self::get, js_string!("get"), 2) .static_method( Self::get_own_property_descriptor, - js_str!("getOwnPropertyDescriptor"), + js_string!("getOwnPropertyDescriptor"), 2, ) - .static_method(Self::get_prototype_of, js_str!("getPrototypeOf"), 1) - .static_method(Self::has, js_str!("has"), 2) - .static_method(Self::is_extensible, js_str!("isExtensible"), 1) - .static_method(Self::own_keys, js_str!("ownKeys"), 1) - .static_method(Self::prevent_extensions, js_str!("preventExtensions"), 1) - .static_method(Self::set, js_str!("set"), 3) - .static_method(Self::set_prototype_of, js_str!("setPrototypeOf"), 2) + .static_method(Self::get_prototype_of, js_string!("getPrototypeOf"), 1) + .static_method(Self::has, js_string!("has"), 2) + .static_method(Self::is_extensible, js_string!("isExtensible"), 1) + .static_method(Self::own_keys, js_string!("ownKeys"), 1) + .static_method(Self::prevent_extensions, js_string!("preventExtensions"), 1) + .static_method(Self::set, js_string!("set"), 3) + .static_method(Self::set_prototype_of, js_string!("setPrototypeOf"), 2) .static_property( to_string_tag, Self::NAME, diff --git a/core/engine/src/builtins/regexp/mod.rs b/core/engine/src/builtins/regexp/mod.rs index e2ec5979dac..34be1ef9654 100644 --- a/core/engine/src/builtins/regexp/mod.rs +++ b/core/engine/src/builtins/regexp/mod.rs @@ -95,48 +95,73 @@ impl IntrinsicObject for RegExp { None, Attribute::CONFIGURABLE, ) - .property(js_str!("lastIndex"), 0, Attribute::all()) - .method(Self::test, js_str!("test"), 1) - .method(Self::exec, js_str!("exec"), 1) - .method(Self::to_string, js_str!("toString"), 0) + .property(js_string!("lastIndex"), 0, Attribute::all()) + .method(Self::test, js_string!("test"), 1) + .method(Self::exec, js_string!("exec"), 1) + .method(Self::to_string, js_string!("toString"), 0) .method(Self::r#match, JsSymbol::r#match(), 1) .method(Self::match_all, JsSymbol::match_all(), 1) .method(Self::replace, JsSymbol::replace(), 2) .method(Self::search, JsSymbol::search(), 1) .method(Self::split, JsSymbol::split(), 2) .accessor( - js_str!("hasIndices"), + js_string!("hasIndices"), Some(get_has_indices), None, flag_attributes, ) - .accessor(js_str!("global"), Some(get_global), None, flag_attributes) .accessor( - js_str!("ignoreCase"), + js_string!("global"), + Some(get_global), + None, + flag_attributes, + ) + .accessor( + js_string!("ignoreCase"), Some(get_ignore_case), None, flag_attributes, ) .accessor( - js_str!("multiline"), + js_string!("multiline"), Some(get_multiline), None, flag_attributes, ) - .accessor(js_str!("dotAll"), Some(get_dot_all), None, flag_attributes) - .accessor(js_str!("unicode"), Some(get_unicode), None, flag_attributes) .accessor( - js_str!("unicodeSets"), + js_string!("dotAll"), + Some(get_dot_all), + None, + flag_attributes, + ) + .accessor( + js_string!("unicode"), + Some(get_unicode), + None, + flag_attributes, + ) + .accessor( + js_string!("unicodeSets"), Some(get_unicode_sets), None, flag_attributes, ) - .accessor(js_str!("sticky"), Some(get_sticky), None, flag_attributes) - .accessor(js_str!("flags"), Some(get_flags), None, flag_attributes) - .accessor(js_str!("source"), Some(get_source), None, flag_attributes); + .accessor( + js_string!("sticky"), + Some(get_sticky), + None, + flag_attributes, + ) + .accessor(js_string!("flags"), Some(get_flags), None, flag_attributes) + .accessor( + js_string!("source"), + Some(get_source), + None, + flag_attributes, + ); #[cfg(feature = "annex-b")] - let regexp = regexp.method(Self::compile, js_str!("compile"), 2); + let regexp = regexp.method(Self::compile, js_string!("compile"), 2); regexp.build(); } diff --git a/core/engine/src/builtins/regexp/regexp_string_iterator.rs b/core/engine/src/builtins/regexp/regexp_string_iterator.rs index c9597fbd827..2cb8620a8a5 100644 --- a/core/engine/src/builtins/regexp/regexp_string_iterator.rs +++ b/core/engine/src/builtins/regexp/regexp_string_iterator.rs @@ -14,6 +14,7 @@ use crate::{ builtins::{iterable::create_iter_result_object, regexp, BuiltInBuilder, IntrinsicObject}, context::intrinsics::Intrinsics, error::JsNativeError, + js_string, object::JsObject, property::Attribute, realm::Realm, @@ -52,10 +53,10 @@ impl IntrinsicObject for RegExpStringIterator { .iterator_prototypes() .iterator(), ) - .static_method(Self::next, js_str!("next"), 0) + .static_method(Self::next, js_string!("next"), 0) .static_property( JsSymbol::to_string_tag(), - js_str!("RegExp String Iterator"), + js_string!("RegExp String Iterator"), Attribute::CONFIGURABLE, ) .build(); diff --git a/core/engine/src/builtins/set/mod.rs b/core/engine/src/builtins/set/mod.rs index dbc1e60bb1e..a82f8c973fc 100644 --- a/core/engine/src/builtins/set/mod.rs +++ b/core/engine/src/builtins/set/mod.rs @@ -65,25 +65,25 @@ impl IntrinsicObject for Set { None, Attribute::CONFIGURABLE, ) - .method(Self::add, js_str!("add"), 1) - .method(Self::clear, js_str!("clear"), 0) - .method(Self::delete, js_str!("delete"), 1) - .method(Self::entries, js_str!("entries"), 0) - .method(Self::for_each, js_str!("forEach"), 1) - .method(Self::has, js_str!("has"), 1) + .method(Self::add, js_string!("add"), 1) + .method(Self::clear, js_string!("clear"), 0) + .method(Self::delete, js_string!("delete"), 1) + .method(Self::entries, js_string!("entries"), 0) + .method(Self::for_each, js_string!("forEach"), 1) + .method(Self::has, js_string!("has"), 1) .property( - js_str!("keys"), + js_string!("keys"), values_function.clone(), Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE, ) .accessor( - js_str!("size"), + js_string!("size"), Some(size_getter), None, Attribute::CONFIGURABLE, ) .property( - js_str!("values"), + js_string!("values"), values_function.clone(), Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE, ) diff --git a/core/engine/src/builtins/set/set_iterator.rs b/core/engine/src/builtins/set/set_iterator.rs index b982311d321..6926b9fac36 100644 --- a/core/engine/src/builtins/set/set_iterator.rs +++ b/core/engine/src/builtins/set/set_iterator.rs @@ -12,6 +12,7 @@ use crate::{ }, context::intrinsics::Intrinsics, error::JsNativeError, + js_string, object::JsObject, property::{Attribute, PropertyNameKind}, realm::Realm, @@ -19,7 +20,6 @@ use crate::{ Context, JsData, JsResult, }; use boa_gc::{Finalize, Trace}; -use boa_macros::js_str; use boa_profiler::Profiler; /// The Set Iterator object represents an iteration over a set. It implements the iterator protocol. @@ -49,10 +49,10 @@ impl IntrinsicObject for SetIterator { .iterator_prototypes() .iterator(), ) - .static_method(Self::next, js_str!("next"), 0) + .static_method(Self::next, js_string!("next"), 0) .static_property( JsSymbol::to_string_tag(), - js_str!("Set Iterator"), + js_string!("Set Iterator"), Attribute::CONFIGURABLE, ) .build(); diff --git a/core/engine/src/builtins/string/mod.rs b/core/engine/src/builtins/string/mod.rs index 057b5e855a8..a49f08a1866 100644 --- a/core/engine/src/builtins/string/mod.rs +++ b/core/engine/src/builtins/string/mod.rs @@ -116,89 +116,89 @@ impl IntrinsicObject for String { let attribute = Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::PERMANENT; let builder = BuiltInBuilder::from_standard_constructor::(realm) - .property(js_str!("length"), 0, attribute) + .property(js_string!("length"), 0, attribute) .property( - js_str!("trimStart"), + js_string!("trimStart"), trim_start, Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE, ) .property( - js_str!("trimEnd"), + js_string!("trimEnd"), trim_end, Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE, ) - .static_method(Self::raw, js_str!("raw"), 1) - .static_method(Self::from_char_code, js_str!("fromCharCode"), 1) - .static_method(Self::from_code_point, js_str!("fromCodePoint"), 1) - .method(Self::char_at, js_str!("charAt"), 1) - .method(Self::char_code_at, js_str!("charCodeAt"), 1) - .method(Self::code_point_at, js_str!("codePointAt"), 1) - .method(Self::to_string, js_str!("toString"), 0) - .method(Self::concat, js_str!("concat"), 1) - .method(Self::repeat, js_str!("repeat"), 1) - .method(Self::slice, js_str!("slice"), 2) - .method(Self::starts_with, js_str!("startsWith"), 1) - .method(Self::ends_with, js_str!("endsWith"), 1) - .method(Self::includes, js_str!("includes"), 1) - .method(Self::index_of, js_str!("indexOf"), 1) - .method(Self::is_well_formed, js_str!("isWellFormed"), 0) - .method(Self::last_index_of, js_str!("lastIndexOf"), 1) - .method(Self::locale_compare, js_str!("localeCompare"), 1) - .method(Self::r#match, js_str!("match"), 1) - .method(Self::normalize, js_str!("normalize"), 0) - .method(Self::pad_end, js_str!("padEnd"), 1) - .method(Self::pad_start, js_str!("padStart"), 1) - .method(Self::trim, js_str!("trim"), 0) - .method(Self::to_case::, js_str!("toLowerCase"), 0) - .method(Self::to_case::, js_str!("toUpperCase"), 0) - .method(Self::to_well_formed, js_str!("toWellFormed"), 0) + .static_method(Self::raw, js_string!("raw"), 1) + .static_method(Self::from_char_code, js_string!("fromCharCode"), 1) + .static_method(Self::from_code_point, js_string!("fromCodePoint"), 1) + .method(Self::char_at, js_string!("charAt"), 1) + .method(Self::char_code_at, js_string!("charCodeAt"), 1) + .method(Self::code_point_at, js_string!("codePointAt"), 1) + .method(Self::to_string, js_string!("toString"), 0) + .method(Self::concat, js_string!("concat"), 1) + .method(Self::repeat, js_string!("repeat"), 1) + .method(Self::slice, js_string!("slice"), 2) + .method(Self::starts_with, js_string!("startsWith"), 1) + .method(Self::ends_with, js_string!("endsWith"), 1) + .method(Self::includes, js_string!("includes"), 1) + .method(Self::index_of, js_string!("indexOf"), 1) + .method(Self::is_well_formed, js_string!("isWellFormed"), 0) + .method(Self::last_index_of, js_string!("lastIndexOf"), 1) + .method(Self::locale_compare, js_string!("localeCompare"), 1) + .method(Self::r#match, js_string!("match"), 1) + .method(Self::normalize, js_string!("normalize"), 0) + .method(Self::pad_end, js_string!("padEnd"), 1) + .method(Self::pad_start, js_string!("padStart"), 1) + .method(Self::trim, js_string!("trim"), 0) + .method(Self::to_case::, js_string!("toLowerCase"), 0) + .method(Self::to_case::, js_string!("toUpperCase"), 0) + .method(Self::to_well_formed, js_string!("toWellFormed"), 0) .method( Self::to_locale_case::, - js_str!("toLocaleLowerCase"), + js_string!("toLocaleLowerCase"), 0, ) .method( Self::to_locale_case::, - js_str!("toLocaleUpperCase"), + js_string!("toLocaleUpperCase"), 0, ) - .method(Self::substring, js_str!("substring"), 2) - .method(Self::split, js_str!("split"), 2) - .method(Self::value_of, js_str!("valueOf"), 0) - .method(Self::match_all, js_str!("matchAll"), 1) - .method(Self::replace, js_str!("replace"), 2) - .method(Self::replace_all, js_str!("replaceAll"), 2) + .method(Self::substring, js_string!("substring"), 2) + .method(Self::split, js_string!("split"), 2) + .method(Self::value_of, js_string!("valueOf"), 0) + .method(Self::match_all, js_string!("matchAll"), 1) + .method(Self::replace, js_string!("replace"), 2) + .method(Self::replace_all, js_string!("replaceAll"), 2) .method(Self::iterator, JsSymbol::iterator(), 0) - .method(Self::search, js_str!("search"), 1) - .method(Self::at, js_str!("at"), 1); + .method(Self::search, js_string!("search"), 1) + .method(Self::at, js_string!("at"), 1); #[cfg(feature = "annex-b")] let builder = { builder .property( - js_str!("trimLeft"), + js_string!("trimLeft"), trim_left, Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE, ) .property( - js_str!("trimRight"), + js_string!("trimRight"), trim_right, Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE, ) - .method(Self::substr, js_str!("substr"), 2) - .method(Self::anchor, js_str!("anchor"), 1) - .method(Self::big, js_str!("big"), 0) - .method(Self::blink, js_str!("blink"), 0) - .method(Self::bold, js_str!("bold"), 0) - .method(Self::fixed, js_str!("fixed"), 0) - .method(Self::fontcolor, js_str!("fontcolor"), 1) - .method(Self::fontsize, js_str!("fontsize"), 1) - .method(Self::italics, js_str!("italics"), 0) - .method(Self::link, js_str!("link"), 1) - .method(Self::small, js_str!("small"), 0) - .method(Self::strike, js_str!("strike"), 0) - .method(Self::sub, js_str!("sub"), 0) - .method(Self::sup, js_str!("sup"), 0) + .method(Self::substr, js_string!("substr"), 2) + .method(Self::anchor, js_string!("anchor"), 1) + .method(Self::big, js_string!("big"), 0) + .method(Self::blink, js_string!("blink"), 0) + .method(Self::bold, js_string!("bold"), 0) + .method(Self::fixed, js_string!("fixed"), 0) + .method(Self::fontcolor, js_string!("fontcolor"), 1) + .method(Self::fontsize, js_string!("fontsize"), 1) + .method(Self::italics, js_string!("italics"), 0) + .method(Self::link, js_string!("link"), 1) + .method(Self::small, js_string!("small"), 0) + .method(Self::strike, js_string!("strike"), 0) + .method(Self::sub, js_string!("sub"), 0) + .method(Self::sup, js_string!("sup"), 0) }; builder.build(); diff --git a/core/engine/src/builtins/string/string_iterator.rs b/core/engine/src/builtins/string/string_iterator.rs index 101b884fa5a..aeafafff73d 100644 --- a/core/engine/src/builtins/string/string_iterator.rs +++ b/core/engine/src/builtins/string/string_iterator.rs @@ -17,7 +17,6 @@ use crate::{ Context, JsData, JsResult, JsString, JsValue, }; use boa_gc::{Finalize, Trace}; -use boa_macros::js_str; use boa_profiler::Profiler; /// The `StringIterator` object represents an iteration over a string. It implements the iterator protocol. @@ -44,10 +43,10 @@ impl IntrinsicObject for StringIterator { .iterator_prototypes() .iterator(), ) - .static_method(Self::next, js_str!("next"), 0) + .static_method(Self::next, js_string!("next"), 0) .static_property( JsSymbol::to_string_tag(), - js_str!("String Iterator"), + js_string!("String Iterator"), Attribute::CONFIGURABLE, ) .build(); diff --git a/core/engine/src/builtins/symbol/mod.rs b/core/engine/src/builtins/symbol/mod.rs index 9886ce6289c..dd50afb1048 100644 --- a/core/engine/src/builtins/symbol/mod.rs +++ b/core/engine/src/builtins/symbol/mod.rs @@ -33,7 +33,6 @@ use crate::{ value::JsValue, Context, JsArgs, JsResult, JsString, }; -use boa_macros::js_str; use boa_profiler::Profiler; use dashmap::DashMap; use once_cell::sync::Lazy; @@ -124,37 +123,41 @@ impl IntrinsicObject for Symbol { .build(); BuiltInBuilder::from_standard_constructor::(realm) - .static_method(Self::for_, js_str!("for"), 1) - .static_method(Self::key_for, js_str!("keyFor"), 1) - .static_property(js_str!("asyncIterator"), symbol_async_iterator, attribute) - .static_property(js_str!("hasInstance"), symbol_has_instance, attribute) + .static_method(Self::for_, js_string!("for"), 1) + .static_method(Self::key_for, js_string!("keyFor"), 1) .static_property( - js_str!("isConcatSpreadable"), + js_string!("asyncIterator"), + symbol_async_iterator, + attribute, + ) + .static_property(js_string!("hasInstance"), symbol_has_instance, attribute) + .static_property( + js_string!("isConcatSpreadable"), symbol_is_concat_spreadable, attribute, ) - .static_property(js_str!("iterator"), symbol_iterator, attribute) - .static_property(js_str!("match"), symbol_match, attribute) - .static_property(js_str!("matchAll"), symbol_match_all, attribute) - .static_property(js_str!("replace"), symbol_replace, attribute) - .static_property(js_str!("search"), symbol_search, attribute) - .static_property(js_str!("species"), symbol_species, attribute) - .static_property(js_str!("split"), symbol_split, attribute) + .static_property(js_string!("iterator"), symbol_iterator, attribute) + .static_property(js_string!("match"), symbol_match, attribute) + .static_property(js_string!("matchAll"), symbol_match_all, attribute) + .static_property(js_string!("replace"), symbol_replace, attribute) + .static_property(js_string!("search"), symbol_search, attribute) + .static_property(js_string!("species"), symbol_species, attribute) + .static_property(js_string!("split"), symbol_split, attribute) .static_property( - js_str!("toPrimitive"), + js_string!("toPrimitive"), symbol_to_primitive.clone(), attribute, ) .static_property( - js_str!("toStringTag"), + js_string!("toStringTag"), symbol_to_string_tag.clone(), attribute, ) - .static_property(js_str!("unscopables"), symbol_unscopables, attribute) - .method(Self::to_string, js_str!("toString"), 0) - .method(Self::value_of, js_str!("valueOf"), 0) + .static_property(js_string!("unscopables"), symbol_unscopables, attribute) + .method(Self::to_string, js_string!("toString"), 0) + .method(Self::value_of, js_string!("valueOf"), 0) .accessor( - js_str!("description"), + js_string!("description"), Some(get_description), None, Attribute::CONFIGURABLE | Attribute::NON_ENUMERABLE, diff --git a/core/engine/src/builtins/temporal/calendar/mod.rs b/core/engine/src/builtins/temporal/calendar/mod.rs index bf74a3c4529..e479ec9881d 100644 --- a/core/engine/src/builtins/temporal/calendar/mod.rs +++ b/core/engine/src/builtins/temporal/calendar/mod.rs @@ -76,40 +76,45 @@ impl IntrinsicObject for Calendar { Self::NAME, Attribute::CONFIGURABLE, ) - .accessor(js_str!("id"), Some(get_id), None, Attribute::CONFIGURABLE) - .static_method(Self::from, js_str!("from"), 1) - .method(Self::date_from_fields, js_str!("dateFromFields"), 2) + .accessor( + js_string!("id"), + Some(get_id), + None, + Attribute::CONFIGURABLE, + ) + .static_method(Self::from, js_string!("from"), 1) + .method(Self::date_from_fields, js_string!("dateFromFields"), 2) .method( Self::year_month_from_fields, - js_str!("yearMonthFromFields"), + js_string!("yearMonthFromFields"), 2, ) .method( Self::month_day_from_fields, - js_str!("monthDayFromFields"), + js_string!("monthDayFromFields"), 2, ) - .method(Self::date_add, js_str!("dateAdd"), 3) - .method(Self::date_until, js_str!("dateUntil"), 3) - .method(Self::era, js_str!("era"), 1) - .method(Self::era_year, js_str!("eraYear"), 1) - .method(Self::year, js_str!("year"), 1) - .method(Self::month, js_str!("month"), 1) - .method(Self::month_code, js_str!("monthCode"), 1) - .method(Self::day, js_str!("day"), 1) - .method(Self::day_of_week, js_str!("dayOfWeek"), 1) - .method(Self::day_of_year, js_str!("dayOfYear"), 1) - .method(Self::week_of_year, js_str!("weekOfYear"), 1) - .method(Self::year_of_week, js_str!("yearOfWeek"), 1) - .method(Self::days_in_week, js_str!("daysInWeek"), 1) - .method(Self::days_in_month, js_str!("daysInMonth"), 1) - .method(Self::days_in_year, js_str!("daysInYear"), 1) - .method(Self::months_in_year, js_str!("monthsInYear"), 1) - .method(Self::in_leap_year, js_str!("inLeapYear"), 1) - .method(Self::fields, js_str!("fields"), 1) - .method(Self::merge_fields, js_str!("mergeFields"), 2) - .method(Self::get_id, js_str!("toString"), 0) - .method(Self::get_id, js_str!("toJSON"), 0) + .method(Self::date_add, js_string!("dateAdd"), 3) + .method(Self::date_until, js_string!("dateUntil"), 3) + .method(Self::era, js_string!("era"), 1) + .method(Self::era_year, js_string!("eraYear"), 1) + .method(Self::year, js_string!("year"), 1) + .method(Self::month, js_string!("month"), 1) + .method(Self::month_code, js_string!("monthCode"), 1) + .method(Self::day, js_string!("day"), 1) + .method(Self::day_of_week, js_string!("dayOfWeek"), 1) + .method(Self::day_of_year, js_string!("dayOfYear"), 1) + .method(Self::week_of_year, js_string!("weekOfYear"), 1) + .method(Self::year_of_week, js_string!("yearOfWeek"), 1) + .method(Self::days_in_week, js_string!("daysInWeek"), 1) + .method(Self::days_in_month, js_string!("daysInMonth"), 1) + .method(Self::days_in_year, js_string!("daysInYear"), 1) + .method(Self::months_in_year, js_string!("monthsInYear"), 1) + .method(Self::in_leap_year, js_string!("inLeapYear"), 1) + .method(Self::fields, js_string!("fields"), 1) + .method(Self::merge_fields, js_string!("mergeFields"), 2) + .method(Self::get_id, js_string!("toString"), 0) + .method(Self::get_id, js_string!("toJSON"), 0) .build(); } diff --git a/core/engine/src/builtins/temporal/duration/mod.rs b/core/engine/src/builtins/temporal/duration/mod.rs index 8f8a0389675..8e242ae44ae 100644 --- a/core/engine/src/builtins/temporal/duration/mod.rs +++ b/core/engine/src/builtins/temporal/duration/mod.rs @@ -109,86 +109,86 @@ impl IntrinsicObject for Duration { Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE, ) .accessor( - js_str!("years"), + js_string!("years"), Some(get_years), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("months"), + js_string!("months"), Some(get_months), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("weeks"), + js_string!("weeks"), Some(get_weeks), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("days"), + js_string!("days"), Some(get_days), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("hours"), + js_string!("hours"), Some(get_hours), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("minutes"), + js_string!("minutes"), Some(get_minutes), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("seconds"), + js_string!("seconds"), Some(get_seconds), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("milliseconds"), + js_string!("milliseconds"), Some(get_milliseconds), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("microseconds"), + js_string!("microseconds"), Some(get_microseconds), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("nanoseconds"), + js_string!("nanoseconds"), Some(get_nanoseconds), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("sign"), + js_string!("sign"), Some(get_sign), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("blank"), + js_string!("blank"), Some(is_blank), None, Attribute::CONFIGURABLE, ) - .method(Self::with, js_str!("with"), 1) - .method(Self::negated, js_str!("negated"), 0) - .method(Self::abs, js_str!("abs"), 0) - .method(Self::add, js_str!("add"), 2) - .method(Self::subtract, js_str!("subtract"), 2) - .method(Self::round, js_str!("round"), 1) - .method(Self::total, js_str!("total"), 1) - .method(Self::to_string, js_str!("toString"), 1) - .method(Self::to_json, js_str!("toJSON"), 0) + .method(Self::with, js_string!("with"), 1) + .method(Self::negated, js_string!("negated"), 0) + .method(Self::abs, js_string!("abs"), 0) + .method(Self::add, js_string!("add"), 2) + .method(Self::subtract, js_string!("subtract"), 2) + .method(Self::round, js_string!("round"), 1) + .method(Self::total, js_string!("total"), 1) + .method(Self::to_string, js_string!("toString"), 1) + .method(Self::to_json, js_string!("toJSON"), 0) .build(); } diff --git a/core/engine/src/builtins/temporal/now.rs b/core/engine/src/builtins/temporal/now.rs index ec8204ccc74..4e13a3424d8 100644 --- a/core/engine/src/builtins/temporal/now.rs +++ b/core/engine/src/builtins/temporal/now.rs @@ -6,13 +6,13 @@ use crate::{ BuiltInBuilder, BuiltInObject, IntrinsicObject, }, context::intrinsics::Intrinsics, + js_string, property::Attribute, realm::Realm, string::common::StaticJsStrings, sys::time::SystemTime, Context, JsBigInt, JsNativeError, JsObject, JsResult, JsString, JsSymbol, JsValue, }; -use boa_macros::js_str; use boa_profiler::Profiler; use super::{ns_max_instant, ns_min_instant}; @@ -37,14 +37,14 @@ impl IntrinsicObject for Now { Self::NAME, Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE, ) - .static_method(Self::time_zone_id, js_str!("timeZoneId"), 0) - .static_method(Self::instant, js_str!("instant"), 0) - .static_method(Self::plain_date_time, js_str!("plainDateTime"), 2) - .static_method(Self::plain_date_time_iso, js_str!("plainDateTimeISO"), 1) - .static_method(Self::zoned_date_time, js_str!("zonedDateTime"), 2) - .static_method(Self::zoned_date_time_iso, js_str!("zonedDateTimeISO"), 1) - .static_method(Self::plain_date, js_str!("plainDate"), 2) - .static_method(Self::plain_date_iso, js_str!("plainDateISO"), 1) + .static_method(Self::time_zone_id, js_string!("timeZoneId"), 0) + .static_method(Self::instant, js_string!("instant"), 0) + .static_method(Self::plain_date_time, js_string!("plainDateTime"), 2) + .static_method(Self::plain_date_time_iso, js_string!("plainDateTimeISO"), 1) + .static_method(Self::zoned_date_time, js_string!("zonedDateTime"), 2) + .static_method(Self::zoned_date_time_iso, js_string!("zonedDateTimeISO"), 1) + .static_method(Self::plain_date, js_string!("plainDate"), 2) + .static_method(Self::plain_date_iso, js_string!("plainDateISO"), 1) .build(); } diff --git a/core/engine/src/builtins/temporal/plain_date/mod.rs b/core/engine/src/builtins/temporal/plain_date/mod.rs index 01d750c93d3..aac77d7e019 100644 --- a/core/engine/src/builtins/temporal/plain_date/mod.rs +++ b/core/engine/src/builtins/temporal/plain_date/mod.rs @@ -126,95 +126,100 @@ impl IntrinsicObject for PlainDate { Attribute::CONFIGURABLE, ) .accessor( - js_str!("calendarId"), + js_string!("calendarId"), Some(get_calendar_id), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("year"), + js_string!("year"), Some(get_year), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("month"), + js_string!("month"), Some(get_month), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("monthCode"), + js_string!("monthCode"), Some(get_month_code), None, Attribute::CONFIGURABLE, ) - .accessor(js_str!("day"), Some(get_day), None, Attribute::CONFIGURABLE) .accessor( - js_str!("dayOfWeek"), + js_string!("day"), + Some(get_day), + None, + Attribute::CONFIGURABLE, + ) + .accessor( + js_string!("dayOfWeek"), Some(get_day_of_week), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("dayOfYear"), + js_string!("dayOfYear"), Some(get_day_of_year), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("weekOfYear"), + js_string!("weekOfYear"), Some(get_week_of_year), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("yearOfWeek"), + js_string!("yearOfWeek"), Some(get_year_of_week), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("daysInWeek"), + js_string!("daysInWeek"), Some(get_days_in_week), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("daysInMonth"), + js_string!("daysInMonth"), Some(get_days_in_month), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("daysInYear"), + js_string!("daysInYear"), Some(get_days_in_year), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("monthsInYear"), + js_string!("monthsInYear"), Some(get_months_in_year), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("inLeapYear"), + js_string!("inLeapYear"), Some(get_in_leap_year), None, Attribute::CONFIGURABLE, ) - .method(Self::to_plain_year_month, js_str!("toPlainYearMonth"), 0) - .method(Self::to_plain_month_day, js_str!("toPlainMonthDay"), 0) - .method(Self::get_iso_fields, js_str!("getISOFields"), 0) - .method(Self::get_calendar, js_str!("getCalendar"), 0) - .method(Self::add, js_str!("add"), 2) - .method(Self::subtract, js_str!("subtract"), 2) - .method(Self::with, js_str!("with"), 2) - .method(Self::with_calendar, js_str!("withCalendar"), 1) - .method(Self::until, js_str!("until"), 2) - .method(Self::since, js_str!("since"), 2) - .method(Self::equals, js_str!("equals"), 1) + .method(Self::to_plain_year_month, js_string!("toPlainYearMonth"), 0) + .method(Self::to_plain_month_day, js_string!("toPlainMonthDay"), 0) + .method(Self::get_iso_fields, js_string!("getISOFields"), 0) + .method(Self::get_calendar, js_string!("getCalendar"), 0) + .method(Self::add, js_string!("add"), 2) + .method(Self::subtract, js_string!("subtract"), 2) + .method(Self::with, js_string!("with"), 2) + .method(Self::with_calendar, js_string!("withCalendar"), 1) + .method(Self::until, js_string!("until"), 2) + .method(Self::since, js_string!("since"), 2) + .method(Self::equals, js_string!("equals"), 1) .build(); } diff --git a/core/engine/src/builtins/temporal/plain_time/mod.rs b/core/engine/src/builtins/temporal/plain_time/mod.rs index 2a75e410681..846b23cc63c 100644 --- a/core/engine/src/builtins/temporal/plain_time/mod.rs +++ b/core/engine/src/builtins/temporal/plain_time/mod.rs @@ -71,42 +71,47 @@ impl IntrinsicObject for PlainTime { Self::NAME, Attribute::CONFIGURABLE, ) - .accessor(js_str!("hour"), Some(get_hour), None, Attribute::default()) .accessor( - js_str!("minute"), + js_string!("hour"), + Some(get_hour), + None, + Attribute::default(), + ) + .accessor( + js_string!("minute"), Some(get_minute), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("second"), + js_string!("second"), Some(get_second), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("millisecond"), + js_string!("millisecond"), Some(get_millisecond), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("microsecond"), + js_string!("microsecond"), Some(get_microsecond), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("nanosecond"), + js_string!("nanosecond"), Some(get_nanosecond), None, Attribute::CONFIGURABLE, ) - .method(Self::add, js_str!("add"), 1) - .method(Self::subtract, js_str!("subtract"), 1) - .method(Self::round, js_str!("round"), 1) - .method(Self::get_iso_fields, js_str!("getISOFields"), 0) - .method(Self::value_of, js_str!("valueOf"), 0) + .method(Self::add, js_string!("add"), 1) + .method(Self::subtract, js_string!("subtract"), 1) + .method(Self::round, js_string!("round"), 1) + .method(Self::get_iso_fields, js_string!("getISOFields"), 0) + .method(Self::value_of, js_string!("valueOf"), 0) .build(); } diff --git a/core/engine/src/builtins/temporal/plain_year_month/mod.rs b/core/engine/src/builtins/temporal/plain_year_month/mod.rs index bd893347620..c651534b5d4 100644 --- a/core/engine/src/builtins/temporal/plain_year_month/mod.rs +++ b/core/engine/src/builtins/temporal/plain_year_month/mod.rs @@ -11,7 +11,6 @@ use crate::{ Context, JsArgs, JsData, JsNativeError, JsObject, JsResult, JsString, JsSymbol, JsValue, }; use boa_gc::{Finalize, Trace}; -use boa_macros::js_str; use boa_profiler::Profiler; use super::calendar::to_temporal_calendar_slot_value; @@ -99,59 +98,59 @@ impl IntrinsicObject for PlainYearMonth { Attribute::CONFIGURABLE, ) .accessor( - js_str!("calendarId"), + js_string!("calendarId"), Some(get_calendar_id), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("year"), + js_string!("year"), Some(get_year), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("month"), + js_string!("month"), Some(get_month), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("monthCode"), + js_string!("monthCode"), Some(get_month_code), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("daysInMonth"), + js_string!("daysInMonth"), Some(get_days_in_month), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("daysInYear"), + js_string!("daysInYear"), Some(get_days_in_year), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("monthsInYear"), + js_string!("monthsInYear"), Some(get_months_in_year), None, Attribute::CONFIGURABLE, ) .accessor( - js_str!("inLeapYear"), + js_string!("inLeapYear"), Some(get_in_leap_year), None, Attribute::CONFIGURABLE, ) - .method(Self::with, js_str!("with"), 2) - .method(Self::add, js_str!("add"), 2) - .method(Self::subtract, js_str!("subtract"), 2) - .method(Self::until, js_str!("until"), 2) - .method(Self::since, js_str!("since"), 2) - .method(Self::equals, js_str!("equals"), 1) + .method(Self::with, js_string!("with"), 2) + .method(Self::add, js_string!("add"), 2) + .method(Self::subtract, js_string!("subtract"), 2) + .method(Self::until, js_string!("until"), 2) + .method(Self::since, js_string!("since"), 2) + .method(Self::equals, js_string!("equals"), 1) .build(); } diff --git a/core/engine/src/builtins/temporal/time_zone/mod.rs b/core/engine/src/builtins/temporal/time_zone/mod.rs index 747d056bc66..826cf94bb52 100644 --- a/core/engine/src/builtins/temporal/time_zone/mod.rs +++ b/core/engine/src/builtins/temporal/time_zone/mod.rs @@ -15,7 +15,6 @@ use crate::{ Context, JsArgs, JsData, JsNativeError, JsObject, JsResult, JsString, JsSymbol, JsValue, }; use boa_gc::{custom_trace, Finalize, Trace}; -use boa_macros::js_str; use boa_profiler::Profiler; use temporal_rs::components::tz::TimeZoneSlot; @@ -55,33 +54,37 @@ impl IntrinsicObject for TimeZone { BuiltInBuilder::from_standard_constructor::(realm) .method( Self::get_offset_nanoseconds_for, - js_str!("getOffsetNanosecondsFor"), + js_string!("getOffsetNanosecondsFor"), 1, ) .method( Self::get_offset_string_for, - js_str!("getOffsetStringFor"), + js_string!("getOffsetStringFor"), 1, ) .method( Self::get_plain_date_time_for, - js_str!("getPlainDateTimeFor"), + js_string!("getPlainDateTimeFor"), 2, ) - .method(Self::get_instant_for, js_str!("getInstantFor"), 2) + .method(Self::get_instant_for, js_string!("getInstantFor"), 2) .method( Self::get_possible_instants_for, - js_str!("getPossibleInstantFor"), + js_string!("getPossibleInstantFor"), + 1, + ) + .method( + Self::get_next_transition, + js_string!("getNextTransition"), 1, ) - .method(Self::get_next_transition, js_str!("getNextTransition"), 1) .method( Self::get_previous_transition, - js_str!("getPreviousTransition"), + js_string!("getPreviousTransition"), 1, ) - .method(Self::to_string, js_str!("toString"), 0) - .method(Self::to_string, js_str!("toJSON"), 0) + .method(Self::to_string, js_string!("toString"), 0) + .method(Self::to_string, js_string!("toJSON"), 0) .property( JsSymbol::to_string_tag(), Self::NAME, @@ -92,7 +95,7 @@ impl IntrinsicObject for TimeZone { realm.intrinsics().constructors().time_zone().prototype(), Attribute::default(), ) - .accessor(js_str!("id"), Some(get_id), None, Attribute::default()) + .accessor(js_string!("id"), Some(get_id), None, Attribute::default()) .build(); } diff --git a/core/engine/src/builtins/typed_array/builtin.rs b/core/engine/src/builtins/typed_array/builtin.rs index e9b85d4bbf8..36b25648c55 100644 --- a/core/engine/src/builtins/typed_array/builtin.rs +++ b/core/engine/src/builtins/typed_array/builtin.rs @@ -79,19 +79,19 @@ impl IntrinsicObject for BuiltinTypedArray { Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE, ) .accessor( - js_str!("buffer"), + js_string!("buffer"), Some(get_buffer), None, Attribute::CONFIGURABLE | Attribute::NON_ENUMERABLE, ) .accessor( - js_str!("byteLength"), + js_string!("byteLength"), Some(get_byte_length), None, Attribute::CONFIGURABLE | Attribute::NON_ENUMERABLE, ) .accessor( - js_str!("byteOffset"), + js_string!("byteOffset"), Some(get_byte_offset), None, Attribute::CONFIGURABLE | Attribute::NON_ENUMERABLE, @@ -108,47 +108,47 @@ impl IntrinsicObject for BuiltinTypedArray { None, Attribute::CONFIGURABLE | Attribute::NON_ENUMERABLE, ) - .static_method(Self::from, js_str!("from"), 1) - .static_method(Self::of, js_str!("of"), 0) - .method(Self::at, js_str!("at"), 1) - .method(Self::copy_within, js_str!("copyWithin"), 2) - .method(Self::entries, js_str!("entries"), 0) - .method(Self::every, js_str!("every"), 1) - .method(Self::fill, js_str!("fill"), 1) - .method(Self::filter, js_str!("filter"), 1) - .method(Self::find, js_str!("find"), 1) - .method(Self::find_index, js_str!("findIndex"), 1) - .method(Self::find_last, js_str!("findLast"), 1) - .method(Self::find_last_index, js_str!("findLastIndex"), 1) - .method(Self::for_each, js_str!("forEach"), 1) - .method(Self::includes, js_str!("includes"), 1) - .method(Self::index_of, js_str!("indexOf"), 1) - .method(Self::join, js_str!("join"), 1) - .method(Self::keys, js_str!("keys"), 0) - .method(Self::last_index_of, js_str!("lastIndexOf"), 1) - .method(Self::map, js_str!("map"), 1) - .method(Self::reduce, js_str!("reduce"), 1) - .method(Self::reduceright, js_str!("reduceRight"), 1) - .method(Self::reverse, js_str!("reverse"), 0) - .method(Self::set, js_str!("set"), 1) - .method(Self::slice, js_str!("slice"), 2) - .method(Self::some, js_str!("some"), 1) - .method(Self::sort, js_str!("sort"), 1) - .method(Self::subarray, js_str!("subarray"), 2) - .method(Self::to_locale_string, js_str!("toLocaleString"), 0) - .method(Self::to_reversed, js_str!("toReversed"), 0) - .method(Self::to_sorted, js_str!("toSorted"), 1) - .method(Self::with, js_str!("with"), 2) + .static_method(Self::from, js_string!("from"), 1) + .static_method(Self::of, js_string!("of"), 0) + .method(Self::at, js_string!("at"), 1) + .method(Self::copy_within, js_string!("copyWithin"), 2) + .method(Self::entries, js_string!("entries"), 0) + .method(Self::every, js_string!("every"), 1) + .method(Self::fill, js_string!("fill"), 1) + .method(Self::filter, js_string!("filter"), 1) + .method(Self::find, js_string!("find"), 1) + .method(Self::find_index, js_string!("findIndex"), 1) + .method(Self::find_last, js_string!("findLast"), 1) + .method(Self::find_last_index, js_string!("findLastIndex"), 1) + .method(Self::for_each, js_string!("forEach"), 1) + .method(Self::includes, js_string!("includes"), 1) + .method(Self::index_of, js_string!("indexOf"), 1) + .method(Self::join, js_string!("join"), 1) + .method(Self::keys, js_string!("keys"), 0) + .method(Self::last_index_of, js_string!("lastIndexOf"), 1) + .method(Self::map, js_string!("map"), 1) + .method(Self::reduce, js_string!("reduce"), 1) + .method(Self::reduceright, js_string!("reduceRight"), 1) + .method(Self::reverse, js_string!("reverse"), 0) + .method(Self::set, js_string!("set"), 1) + .method(Self::slice, js_string!("slice"), 2) + .method(Self::some, js_string!("some"), 1) + .method(Self::sort, js_string!("sort"), 1) + .method(Self::subarray, js_string!("subarray"), 2) + .method(Self::to_locale_string, js_string!("toLocaleString"), 0) + .method(Self::to_reversed, js_string!("toReversed"), 0) + .method(Self::to_sorted, js_string!("toSorted"), 1) + .method(Self::with, js_string!("with"), 2) // 23.2.3.29 %TypedArray%.prototype.toString ( ) // The initial value of the %TypedArray%.prototype.toString data property is the same // built-in function object as the Array.prototype.toString method defined in 23.1.3.30. .property( - js_str!("toString"), + js_string!("toString"), realm.intrinsics().objects().array_prototype_to_string(), Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE, ) .property( - js_str!("values"), + js_string!("values"), values_function, Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE, ) diff --git a/core/engine/src/builtins/weak/weak_ref.rs b/core/engine/src/builtins/weak/weak_ref.rs index 3b618362b5a..8442e6ac1bc 100644 --- a/core/engine/src/builtins/weak/weak_ref.rs +++ b/core/engine/src/builtins/weak/weak_ref.rs @@ -1,10 +1,10 @@ use boa_gc::{Finalize, Trace, WeakGc}; -use boa_macros::js_str; use boa_profiler::Profiler; use crate::{ builtins::{BuiltInBuilder, BuiltInConstructor, BuiltInObject, IntrinsicObject}, context::intrinsics::{Intrinsics, StandardConstructor, StandardConstructors}, + js_string, object::{internal_methods::get_prototype_from_constructor, ErasedVTableObject, JsObject}, property::Attribute, realm::Realm, @@ -36,10 +36,10 @@ impl IntrinsicObject for WeakRef { BuiltInBuilder::from_standard_constructor::(realm) .property( JsSymbol::to_string_tag(), - js_str!("WeakRef"), + js_string!("WeakRef"), Attribute::CONFIGURABLE, ) - .method(Self::deref, js_str!("deref"), 0) + .method(Self::deref, js_string!("deref"), 0) .build(); } } diff --git a/core/engine/src/builtins/weak_map/mod.rs b/core/engine/src/builtins/weak_map/mod.rs index 94d537c9ce2..01cd63c0a98 100644 --- a/core/engine/src/builtins/weak_map/mod.rs +++ b/core/engine/src/builtins/weak_map/mod.rs @@ -13,6 +13,7 @@ use crate::{ IntrinsicObject, }, context::intrinsics::{Intrinsics, StandardConstructor, StandardConstructors}, + js_string, object::{internal_methods::get_prototype_from_constructor, ErasedVTableObject, JsObject}, property::Attribute, realm::Realm, @@ -42,10 +43,10 @@ impl IntrinsicObject for WeakMap { Self::NAME, Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE, ) - .method(Self::delete, js_str!("delete"), 1) - .method(Self::get, js_str!("get"), 1) - .method(Self::has, js_str!("has"), 1) - .method(Self::set, js_str!("set"), 2) + .method(Self::delete, js_string!("delete"), 1) + .method(Self::get, js_string!("get"), 1) + .method(Self::has, js_string!("has"), 1) + .method(Self::set, js_string!("set"), 2) .build(); } } diff --git a/core/engine/src/builtins/weak_set/mod.rs b/core/engine/src/builtins/weak_set/mod.rs index c2e52029d3d..d90a8257725 100644 --- a/core/engine/src/builtins/weak_set/mod.rs +++ b/core/engine/src/builtins/weak_set/mod.rs @@ -10,6 +10,7 @@ use crate::{ builtins::{BuiltInBuilder, BuiltInConstructor, BuiltInObject, IntrinsicObject}, context::intrinsics::{Intrinsics, StandardConstructor, StandardConstructors}, + js_string, object::{internal_methods::get_prototype_from_constructor, ErasedVTableObject, JsObject}, property::Attribute, realm::Realm, @@ -39,9 +40,9 @@ impl IntrinsicObject for WeakSet { Self::NAME, Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE, ) - .method(Self::add, js_str!("add"), 1) - .method(Self::delete, js_str!("delete"), 1) - .method(Self::has, js_str!("has"), 1) + .method(Self::add, js_string!("add"), 1) + .method(Self::delete, js_string!("delete"), 1) + .method(Self::has, js_string!("has"), 1) .build(); } } diff --git a/core/engine/src/class.rs b/core/engine/src/class.rs index c362c00de37..af0838c583e 100644 --- a/core/engine/src/class.rs +++ b/core/engine/src/class.rs @@ -10,7 +10,7 @@ //! # property::Attribute, //! # class::{Class, ClassBuilder}, //! # Context, JsResult, JsValue, -//! # JsArgs, Source, JsObject, js_str, +//! # JsArgs, Source, JsObject, js_str, js_string, //! # JsNativeError, JsData, //! # }; //! # use boa_gc::{Finalize, Trace}; @@ -64,7 +64,7 @@ //! /// This is where the class object is initialized. //! fn init(class: &mut ClassBuilder) -> JsResult<()> { //! class.method( -//! js_str!("speak"), +//! js_string!("speak"), //! 0, //! NativeFunction::from_fn_ptr(|this, _args, _ctx| { //! if let Some(object) = this.as_object() { diff --git a/core/engine/src/object/mod.rs b/core/engine/src/object/mod.rs index 33231f7f3f0..f2fc7ed64fe 100644 --- a/core/engine/src/object/mod.rs +++ b/core/engine/src/object/mod.rs @@ -465,17 +465,6 @@ pub struct FunctionBinding { pub(crate) name: JsString, } -impl From> for FunctionBinding { - #[inline] - fn from(name: JsStr<'_>) -> Self { - let name: JsString = name.into(); - Self { - binding: name.clone().into(), - name: name.clone(), - } - } -} - impl From for FunctionBinding { #[inline] fn from(name: JsString) -> Self { diff --git a/examples/src/bin/classes.rs b/examples/src/bin/classes.rs index 6254d0c4df8..44da13ce8b2 100644 --- a/examples/src/bin/classes.rs +++ b/examples/src/bin/classes.rs @@ -2,7 +2,7 @@ use boa_engine::{ class::{Class, ClassBuilder}, error::JsNativeError, - js_str, + js_str, js_string, native_function::NativeFunction, property::Attribute, Context, JsArgs, JsData, JsResult, JsString, JsValue, Source, @@ -93,7 +93,7 @@ impl Class for Person { // // This function is added to the `Person` prototype. class.method( - js_str!("sayHello"), + js_string!("sayHello"), 0, NativeFunction::from_fn_ptr(Self::say_hello), ); @@ -103,7 +103,7 @@ impl Class for Person { // // This function is added to the `Person` class. class.static_method( - js_str!("is"), + js_string!("is"), 1, NativeFunction::from_fn_ptr(|_this, args, _ctx| { if let Some(arg) = args.first() { diff --git a/tests/tester/src/exec/js262.rs b/tests/tester/src/exec/js262.rs index 19c785086b4..6e44571f14c 100644 --- a/tests/tester/src/exec/js262.rs +++ b/tests/tester/src/exec/js262.rs @@ -8,7 +8,7 @@ use std::{ use boa_engine::{ builtins::array_buffer::{ArrayBuffer, SharedArrayBuffer}, - js_str, js_string, + js_string, native_function::NativeFunction, object::{builtins::JsSharedArrayBuffer, JsObject, ObjectInitializer}, property::Attribute, @@ -77,27 +77,27 @@ pub(super) fn register_js262(handles: WorkerHandles, context: &mut Context) -> J let js262 = ObjectInitializer::new(context) .function( NativeFunction::from_fn_ptr(create_realm), - js_str!("createRealm"), + js_string!("createRealm"), 0, ) .function( NativeFunction::from_fn_ptr(detach_array_buffer), - js_str!("detachArrayBuffer"), + js_string!("detachArrayBuffer"), 2, ) .function( NativeFunction::from_fn_ptr(eval_script), - js_str!("evalScript"), + js_string!("evalScript"), 1, ) - .function(NativeFunction::from_fn_ptr(gc), js_str!("gc"), 0) + .function(NativeFunction::from_fn_ptr(gc), js_string!("gc"), 0) .property( - js_str!("global"), + js_string!("global"), global_obj, Attribute::WRITABLE | Attribute::CONFIGURABLE, ) .property( - js_str!("agent"), + js_string!("agent"), agent, Attribute::WRITABLE | Attribute::CONFIGURABLE, ) @@ -105,7 +105,7 @@ pub(super) fn register_js262(handles: WorkerHandles, context: &mut Context) -> J context .register_global_property( - js_str!("$262"), + js_string!("$262"), js262.clone(), Attribute::WRITABLE | Attribute::CONFIGURABLE, ) @@ -261,13 +261,13 @@ fn agent_obj(handles: WorkerHandles, context: &mut Context) -> JsObject { }; ObjectInitializer::new(context) - .function(start, js_str!("start"), 1) - .function(broadcast, js_str!("broadcast"), 2) - .function(get_report, js_str!("getReport"), 0) - .function(NativeFunction::from_fn_ptr(sleep), js_str!("sleep"), 1) + .function(start, js_string!("start"), 1) + .function(broadcast, js_string!("broadcast"), 2) + .function(get_report, js_string!("getReport"), 0) + .function(NativeFunction::from_fn_ptr(sleep), js_string!("sleep"), 1) .function( NativeFunction::from_fn_ptr(monotonic_now), - js_str!("monotonicNow"), + js_string!("monotonicNow"), 0, ) .build() @@ -307,26 +307,26 @@ fn register_js262_worker( }; let agent = ObjectInitializer::new(context) - .function(receive_broadcast, js_str!("receiveBroadcast"), 1) - .function(report, js_str!("report"), 1) - .function(NativeFunction::from_fn_ptr(sleep), js_str!("sleep"), 1) + .function(receive_broadcast, js_string!("receiveBroadcast"), 1) + .function(report, js_string!("report"), 1) + .function(NativeFunction::from_fn_ptr(sleep), js_string!("sleep"), 1) // Don't need to signal leaving, the main thread will join with the worker // threads anyways. .function( NativeFunction::from_fn_ptr(|_, _, _| Ok(JsValue::undefined())), - js_str!("leaving"), + js_string!("leaving"), 0, ) .function( NativeFunction::from_fn_ptr(monotonic_now), - js_str!("monotonicNow"), + js_string!("monotonicNow"), 0, ) .build(); let js262 = ObjectInitializer::new(context) .property( - js_str!("agent"), + js_string!("agent"), agent, Attribute::WRITABLE | Attribute::CONFIGURABLE, ) @@ -334,7 +334,7 @@ fn register_js262_worker( context .register_global_property( - js_str!("$262"), + js_string!("$262"), js262, Attribute::WRITABLE | Attribute::CONFIGURABLE, )