Skip to content

Commit

Permalink
LibWeb: Add builtin Float16Array type and remove related FIXME
Browse files Browse the repository at this point in the history
(cherry picked from commit 9ee7d4d90a0f029e154c796c51650096143446e4)
  • Loading branch information
rmg-x authored and nico committed Nov 18, 2024
1 parent 14818c5 commit 151947c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ static bool is_javascript_builtin(Type const& type)
// might simply need to add another type here.
static constexpr Array types = {
"ArrayBuffer"sv,
"Float16Array"sv,
"Float32Array"sv,
"Float64Array"sv,
"Uint8Array"sv,
Expand Down Expand Up @@ -1258,7 +1259,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
// 1. If types includes a typed array type whose name is the value of V’s [[TypedArrayName]] internal slot, then return the result of converting V to that type.
// 2. If types includes object, then return the IDL value that is a reference to the object V.
auto has_typed_array_name = any_of(types, [](auto const& type) {
return type->name().is_one_of("Int8Array"sv, "Int16Array"sv, "Int32Array"sv, "Uint8Array"sv, "Uint16Array"sv, "Uint32Array"sv, "Uint8ClampedArray"sv, "BigInt64Array"sv, "BigUint64Array", "Float32Array"sv, "Float64Array"sv);
return type->name().is_one_of("Int8Array"sv, "Int16Array"sv, "Int32Array"sv, "Uint8Array"sv, "Uint16Array"sv, "Uint32Array"sv, "Uint8ClampedArray"sv, "BigInt64Array"sv, "BigUint64Array", "Float16Array"sv, "Float32Array"sv, "Float64Array"sv);
});

if (has_typed_array_name || includes_object) {
Expand Down
1 change: 1 addition & 0 deletions Tests/LibWeb/Text/expected/all-window-properties.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ FileList
FileReader
FileSystemEntry
FinalizationRegistry
Float16Array
Float32Array
Float64Array
FocusEvent
Expand Down
1 change: 0 additions & 1 deletion Userland/Libraries/LibWeb/Crypto/Crypto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ WebIDL::ExceptionOr<JS::Handle<WebIDL::ArrayBufferView>> Crypto::get_random_valu
return WebIDL::TypeMismatchError::create(realm(), "array must be one of Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, or BigUint64Array"_fly_string);

auto const& typed_array = *array->bufferable_object().get<JS::NonnullGCPtr<JS::TypedArrayBase>>();
// Still need to exclude Float32Array, and potential future siblings like Float16Array:
if (!typed_array.element_name().is_one_of("Int8Array", "Uint8Array", "Uint8ClampedArray", "Int16Array", "Uint16Array", "Int32Array", "Uint32Array", "BigInt64Array", "BigUint64Array"))
return WebIDL::TypeMismatchError::create(realm(), "array must be one of Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, or BigUint64Array"_string);

Expand Down

0 comments on commit 151947c

Please sign in to comment.