1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 07:37:46 +00:00

LibJS: Make Utf16String & related APIs infallible

Work towards #20449.
This commit is contained in:
Andreas Kling 2023-08-08 18:54:20 +02:00
parent 9708b86d65
commit 7849950383
15 changed files with 82 additions and 88 deletions

View file

@ -21,10 +21,10 @@ class Utf16StringImpl : public RefCounted<Utf16StringImpl> {
public:
~Utf16StringImpl() = default;
static ThrowCompletionOr<NonnullRefPtr<Utf16StringImpl>> create(VM&);
static ThrowCompletionOr<NonnullRefPtr<Utf16StringImpl>> create(VM&, Utf16Data);
static ThrowCompletionOr<NonnullRefPtr<Utf16StringImpl>> create(VM&, StringView);
static ThrowCompletionOr<NonnullRefPtr<Utf16StringImpl>> create(VM&, Utf16View const&);
[[nodiscard]] static NonnullRefPtr<Utf16StringImpl> create();
[[nodiscard]] static NonnullRefPtr<Utf16StringImpl> create(Utf16Data);
[[nodiscard]] static NonnullRefPtr<Utf16StringImpl> create(StringView);
[[nodiscard]] static NonnullRefPtr<Utf16StringImpl> create(Utf16View const&);
Utf16Data const& string() const;
Utf16View view() const;
@ -40,18 +40,18 @@ private:
class Utf16String {
public:
static ThrowCompletionOr<Utf16String> create(VM&);
static ThrowCompletionOr<Utf16String> create(VM&, Utf16Data);
static ThrowCompletionOr<Utf16String> create(VM&, StringView);
static ThrowCompletionOr<Utf16String> create(VM&, Utf16View const&);
[[nodiscard]] static Utf16String create();
[[nodiscard]] static Utf16String create(Utf16Data);
[[nodiscard]] static Utf16String create(StringView);
[[nodiscard]] static Utf16String create(Utf16View const&);
Utf16Data const& string() const;
Utf16View view() const;
Utf16View substring_view(size_t code_unit_offset, size_t code_unit_length) const;
Utf16View substring_view(size_t code_unit_offset) const;
ThrowCompletionOr<String> to_utf8(VM&) const;
ThrowCompletionOr<DeprecatedString> to_deprecated_string(VM&) const;
[[nodiscard]] String to_utf8() const;
[[nodiscard]] DeprecatedString to_deprecated_string() const;
u16 code_unit_at(size_t index) const;
size_t length_in_code_units() const;