LibJS+LibWeb: Convert string view PrimitiveString instances to String

First, this adds an overload of PrimitiveString::create for StringView.
This overload will throw an OOM completion if creating a String fails.
This is not only a bit more convenient, but it also ensures at compile
time that all PrimitiveString::create(string_view) invocations will be
handled as String and OOM-aware.

Next, this wraps all invocations to PrimitiveString::create(string_view)
with MUST_OR_THROW_OOM.

A small PrimitiveString::create(DeprecatedFlyString) overload also had
to be added to disambiguate between the StringView and DeprecatedString
overloads.
This commit is contained in:
Timothy Flynn 2023-02-09 09:00:14 -05:00 committed by Linus Groh
commit c3abb1396c
Notes: sideshowbarker 2024-07-17 23:02:37 +09:00
69 changed files with 223 additions and 186 deletions

View file

@ -26,7 +26,9 @@ public:
[[nodiscard]] static NonnullGCPtr<PrimitiveString> create(VM&, Utf16String);
[[nodiscard]] static NonnullGCPtr<PrimitiveString> create(VM&, String);
[[nodiscard]] static NonnullGCPtr<PrimitiveString> create(VM&, DeprecatedString);
[[nodiscard]] static NonnullGCPtr<PrimitiveString> create(VM&, DeprecatedFlyString const&);
[[nodiscard]] static NonnullGCPtr<PrimitiveString> create(VM&, PrimitiveString&, PrimitiveString&);
static ThrowCompletionOr<NonnullGCPtr<PrimitiveString>> create(VM&, StringView);
virtual ~PrimitiveString();