/src/hermes/lib/VM/JSDataView.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/JSDataView.h" |
9 | | |
10 | | #include "hermes/VM/BuildMetadata.h" |
11 | | #include "hermes/VM/Runtime-inline.h" |
12 | | |
13 | | namespace hermes { |
14 | | namespace vm { |
15 | | |
16 | | const ObjectVTable JSDataView::vt{ |
17 | | VTable(CellKind::JSDataViewKind, cellSize<JSDataView>()), |
18 | | JSDataView::_getOwnIndexedRangeImpl, |
19 | | JSDataView::_haveOwnIndexedImpl, |
20 | | JSDataView::_getOwnIndexedPropertyFlagsImpl, |
21 | | JSDataView::_getOwnIndexedImpl, |
22 | | JSDataView::_setOwnIndexedImpl, |
23 | | JSDataView::_deleteOwnIndexedImpl, |
24 | | JSDataView::_checkAllOwnIndexedImpl, |
25 | | }; |
26 | | |
27 | 1 | void JSDataViewBuildMeta(const GCCell *cell, Metadata::Builder &mb) { |
28 | 1 | mb.addJSObjectOverlapSlots(JSObject::numOverlapSlots<JSDataView>()); |
29 | 1 | JSObjectBuildMeta(cell, mb); |
30 | 1 | const auto *self = static_cast<const JSDataView *>(cell); |
31 | 1 | mb.setVTable(&JSDataView::vt); |
32 | 1 | mb.addField("buffer", &self->buffer_); |
33 | 1 | } |
34 | | |
35 | | PseudoHandle<JSDataView> JSDataView::create( |
36 | | Runtime &runtime, |
37 | 0 | Handle<JSObject> prototype) { |
38 | 0 | auto *cell = runtime.makeAFixed<JSDataView>( |
39 | 0 | runtime, |
40 | 0 | prototype, |
41 | 0 | runtime.getHiddenClassForPrototype( |
42 | 0 | *prototype, numOverlapSlots<JSDataView>())); |
43 | 0 | return JSObjectInit::initToPseudoHandle(runtime, cell); |
44 | 0 | } |
45 | | |
46 | | JSDataView::JSDataView( |
47 | | Runtime &runtime, |
48 | | Handle<JSObject> parent, |
49 | | Handle<HiddenClass> clazz) |
50 | 0 | : JSObject(runtime, *parent, *clazz), |
51 | 0 | buffer_(nullptr), |
52 | 0 | offset_(0), |
53 | 0 | length_(0) {} |
54 | | |
55 | | } // namespace vm |
56 | | } // namespace hermes |