/src/serenity/Userland/Libraries/LibJS/Runtime/WeakContainer.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #include <LibJS/Heap/Heap.h> |
8 | | #include <LibJS/Runtime/WeakContainer.h> |
9 | | |
10 | | namespace JS { |
11 | | |
12 | | WeakContainer::WeakContainer(Heap& heap) |
13 | 0 | : m_heap(heap) |
14 | 0 | { |
15 | 0 | m_heap.did_create_weak_container({}, *this); |
16 | 0 | } |
17 | | |
18 | | WeakContainer::~WeakContainer() |
19 | 0 | { |
20 | 0 | deregister(); |
21 | 0 | } |
22 | | |
23 | | void WeakContainer::deregister() |
24 | 0 | { |
25 | 0 | if (!m_registered) |
26 | 0 | return; |
27 | 0 | m_heap.did_destroy_weak_container({}, *this); |
28 | 0 | m_registered = false; |
29 | 0 | } |
30 | | |
31 | | } |