mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:37:35 +00:00
LibJS+Everywhere: Make PrimitiveString and Utf16String fallible
This makes construction of Utf16String fallible in OOM conditions. The immediate impact is that PrimitiveString must then be fallible as well, as it may either transcode UTF-8 to UTF-16, or create a UTF-16 string from ropes. There are a couple of places where it is very non-trivial to propagate the error further. A FIXME has been added to those locations.
This commit is contained in:
parent
d793262beb
commit
115baa7e32
57 changed files with 306 additions and 295 deletions
|
@ -21,10 +21,10 @@ class Utf16StringImpl : public RefCounted<Utf16StringImpl> {
|
|||
public:
|
||||
~Utf16StringImpl() = default;
|
||||
|
||||
static NonnullRefPtr<Utf16StringImpl> create();
|
||||
static NonnullRefPtr<Utf16StringImpl> create(Utf16Data);
|
||||
static NonnullRefPtr<Utf16StringImpl> create(StringView);
|
||||
static NonnullRefPtr<Utf16StringImpl> create(Utf16View const&);
|
||||
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&);
|
||||
|
||||
Utf16Data const& string() const;
|
||||
Utf16View view() const;
|
||||
|
@ -40,10 +40,10 @@ private:
|
|||
|
||||
class Utf16String {
|
||||
public:
|
||||
Utf16String();
|
||||
explicit Utf16String(Utf16Data);
|
||||
explicit Utf16String(StringView);
|
||||
explicit Utf16String(Utf16View const&);
|
||||
static ThrowCompletionOr<Utf16String> create(VM&);
|
||||
static ThrowCompletionOr<Utf16String> create(VM&, Utf16Data);
|
||||
static ThrowCompletionOr<Utf16String> create(VM&, StringView);
|
||||
static ThrowCompletionOr<Utf16String> create(VM&, Utf16View const&);
|
||||
|
||||
Utf16Data const& string() const;
|
||||
Utf16View view() const;
|
||||
|
@ -57,6 +57,8 @@ public:
|
|||
bool is_empty() const;
|
||||
|
||||
private:
|
||||
explicit Utf16String(NonnullRefPtr<Detail::Utf16StringImpl>);
|
||||
|
||||
NonnullRefPtr<Detail::Utf16StringImpl> m_string;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue