Browse Source

Intl.ListFormat

optimization/static-shapes
Haled Odat 1 year ago
parent
commit
12cadd13f0
  1. 8
      boa_builtins/build.rs
  2. 24
      boa_engine/src/builtins/intl/list_format/mod.rs

8
boa_builtins/build.rs

@ -1154,6 +1154,14 @@ fn main() -> io::Result<()> {
.accessor(utf16!("script"), Attribute::CONFIGURABLE)
.accessor(utf16!("region"), Attribute::CONFIGURABLE)
.build(file)?;
BuiltInBuilderConstructor::new(&context, "INTL_LIST_FORMAT")
.static_method(utf16!("supportedLocalesOf"))
.property(WellKnown::ToStringTag, Attribute::CONFIGURABLE)
.method(utf16!("format"))
.method(utf16!("formatToParts"))
.method(utf16!("resolvedOptions"))
.build(file)?;
}
context.build(file)?;

24
boa_engine/src/builtins/intl/list_format/mod.rs

@ -9,10 +9,8 @@ use crate::{
builtins::{Array, BuiltInBuilder, BuiltInConstructor, BuiltInObject, IntrinsicObject},
context::intrinsics::{Intrinsics, StandardConstructor, StandardConstructors},
object::{internal_methods::get_prototype_from_constructor, JsObject, ObjectData},
property::Attribute,
realm::Realm,
string::utf16,
symbol::JsSymbol,
Context, JsArgs, JsNativeError, JsResult, JsString, JsValue,
};
@ -52,17 +50,17 @@ impl IntrinsicObject for ListFormat {
fn init(realm: &Realm) {
let _timer = Profiler::global().start_event(Self::NAME, "init");
BuiltInBuilder::from_standard_constructor::<Self>(realm)
.static_method(Self::supported_locales_of, "supportedLocalesOf", 1)
.property(
JsSymbol::to_string_tag(),
"Intl.ListFormat",
Attribute::CONFIGURABLE,
)
.method(Self::format, "format", 1)
.method(Self::format_to_parts, "formatToParts", 1)
.method(Self::resolved_options, "resolvedOptions", 0)
.build();
BuiltInBuilder::from_standard_constructor_static_shape::<Self>(
realm,
&boa_builtins::INTL_LIST_FORMAT_CONSTRUCTOR_STATIC_SHAPE,
&boa_builtins::INTL_LIST_FORMAT_PROTOTYPE_STATIC_SHAPE,
)
.static_method(Self::supported_locales_of, 1)
.property("Intl.ListFormat")
.method(Self::format, 1)
.method(Self::format_to_parts, 1)
.method(Self::resolved_options, 0)
.build();
}
fn get(intrinsics: &Intrinsics) -> JsObject {

Loading…
Cancel
Save