1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 23:38:12 +00:00

LibJS+Everywhere: Allow Cell::initialize overrides to throw OOM errors

Note that as of this commit, there aren't any such throwers, and the
call site in Heap::allocate will drop exceptions on the floor. This
commit only serves to change the declaration of the overrides, make sure
they return an empty value, and to propagate OOM errors frm their base
initialize invocations.
This commit is contained in:
Timothy Flynn 2023-01-28 12:33:35 -05:00 committed by Linus Groh
parent 1c1b902a6a
commit 2692db8699
694 changed files with 1774 additions and 1065 deletions

View file

@ -132,10 +132,12 @@ Blob::Blob(JS::Realm& realm, ByteBuffer byte_buffer)
Blob::~Blob() = default;
void Blob::initialize(JS::Realm& realm)
JS::ThrowCompletionOr<void> Blob::initialize(JS::Realm& realm)
{
Base::initialize(realm);
MUST_OR_THROW_OOM(Base::initialize(realm));
set_prototype(&Bindings::ensure_web_prototype<Bindings::BlobPrototype>(realm, "Blob"));
return {};
}
// https://w3c.github.io/FileAPI/#ref-for-dom-blob-blob

View file

@ -53,7 +53,7 @@ protected:
Blob(JS::Realm&, ByteBuffer, DeprecatedString type);
Blob(JS::Realm&, ByteBuffer);
virtual void initialize(JS::Realm&) override;
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
private:
explicit Blob(JS::Realm&);

View file

@ -18,10 +18,12 @@ File::File(JS::Realm& realm, ByteBuffer byte_buffer, DeprecatedString file_name,
{
}
void File::initialize(JS::Realm& realm)
JS::ThrowCompletionOr<void> File::initialize(JS::Realm& realm)
{
Base::initialize(realm);
MUST_OR_THROW_OOM(Base::initialize(realm));
set_prototype(&Bindings::ensure_web_prototype<Bindings::FilePrototype>(realm, "File"));
return {};
}
File::~File() = default;

View file

@ -31,7 +31,7 @@ public:
private:
File(JS::Realm&, ByteBuffer, DeprecatedString file_name, DeprecatedString type, i64 last_modified);
virtual void initialize(JS::Realm&) override;
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
DeprecatedString m_name;
i64 m_last_modified { 0 };

View file

@ -24,10 +24,12 @@ FileList::FileList(JS::Realm& realm, Vector<JS::NonnullGCPtr<File>>&& files)
FileList::~FileList() = default;
void FileList::initialize(JS::Realm& realm)
JS::ThrowCompletionOr<void> FileList::initialize(JS::Realm& realm)
{
Base::initialize(realm);
MUST_OR_THROW_OOM(Base::initialize(realm));
set_prototype(&Bindings::ensure_web_prototype<Bindings::FileListPrototype>(realm, "FileList"));
return {};
}
// https://w3c.github.io/FileAPI/#dfn-item

View file

@ -35,7 +35,7 @@ public:
private:
FileList(JS::Realm&, Vector<JS::NonnullGCPtr<File>>&&);
virtual void initialize(JS::Realm&) override;
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
Vector<JS::NonnullGCPtr<File>> m_files;