/src/hermes/lib/VM/NativeState.cpp
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) Meta Platforms, Inc. and affiliates. |
3 | | * |
4 | | * This source code is licensed under the MIT license found in the |
5 | | * LICENSE file in the root directory of this source tree. |
6 | | */ |
7 | | |
8 | | #include "hermes/VM/NativeState.h" |
9 | | |
10 | | #include "hermes/VM/Runtime.h" |
11 | | |
12 | | namespace hermes { |
13 | | namespace vm { |
14 | | |
15 | | const VTable NativeState::vt{ |
16 | | CellKind::NativeStateKind, |
17 | | cellSize<NativeState>(), |
18 | | _finalizeImpl, |
19 | | }; |
20 | | |
21 | 1 | void NativeStateBuildMeta(const GCCell *cell, Metadata::Builder &mb) { |
22 | 1 | mb.setVTable(&NativeState::vt); |
23 | 1 | } |
24 | | |
25 | | /* static */ |
26 | | NativeState *NativeState::create( |
27 | | Runtime &runtime, |
28 | | void *context, |
29 | 0 | FinalizeNativeStatePtr finalizePtr) { |
30 | 0 | return runtime.makeAFixed<NativeState, HasFinalizer::Yes>( |
31 | 0 | context, finalizePtr); |
32 | 0 | } |
33 | | |
34 | 0 | void NativeState::_finalizeImpl(GCCell *cell, GC &gc) { |
35 | 0 | auto *self = vmcast<NativeState>(cell); |
36 | 0 | self->finalizePtr_(gc, self); |
37 | 0 | } |
38 | | |
39 | | } // namespace vm |
40 | | } // namespace hermes |