mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-05 06:32:30 +02:00
LibJS: Add DisposableStack{, Prototype, Constructor}
Since the async parts of the spec are not stage 3 at this point we don't add AsyncDisposableStack.
This commit is contained in:
Notes:
sideshowbarker
2024-07-17 11:06:06 +09:00
Author: https://github.com/davidot Commit: https://github.com/SerenityOS/serenity/commit/6255ca4a42 Pull-request: https://github.com/SerenityOS/serenity/pull/16630 Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/linusg ✅
40
Userland/Libraries/LibJS/Runtime/DisposableStack.h
Normal file
40
Userland/Libraries/LibJS/Runtime/DisposableStack.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2022, David Tuin <davidot@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibJS/Runtime/AbstractOperations.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
|
||||
namespace JS {
|
||||
|
||||
class DisposableStack final : public Object {
|
||||
JS_OBJECT(DisposableStack, Object);
|
||||
|
||||
public:
|
||||
virtual ~DisposableStack() override = default;
|
||||
|
||||
enum class DisposableState {
|
||||
Pending,
|
||||
Disposed
|
||||
};
|
||||
|
||||
[[nodiscard]] DisposableState disposable_state() const { return m_state; }
|
||||
[[nodiscard]] Vector<DisposableResource> const& disposable_resource_stack() const { return m_disposable_resource_stack; }
|
||||
[[nodiscard]] Vector<DisposableResource>& disposable_resource_stack() { return m_disposable_resource_stack; }
|
||||
|
||||
void set_disposed() { m_state = DisposableState::Disposed; }
|
||||
|
||||
private:
|
||||
DisposableStack(Vector<DisposableResource> stack, Object& prototype);
|
||||
|
||||
virtual void visit_edges(Visitor& visitor) override;
|
||||
|
||||
Vector<DisposableResource> m_disposable_resource_stack;
|
||||
DisposableState m_state { DisposableState::Pending };
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user