• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef ECMASCRIPT_BUILTINS_BUILTINS_DATAVIEW_H
17 #define ECMASCRIPT_BUILTINS_BUILTINS_DATAVIEW_H
18 
19 #include "ecmascript/base/builtins_base.h"
20 #include "ecmascript/js_dataview.h"
21 
22 namespace panda::ecmascript::builtins {
23 using DataViewType = ecmascript::DataViewType;
24 class BuiltinsDataView : public base::BuiltinsBase {
25 public:
26     // 24.2.2.1 DataView (buffer [ , byteOffset [ , byteLength ] ] )
27     static JSTaggedValue DataViewConstructor(EcmaRuntimeCallInfo *argv);
28     // 24.2.4.1 get DataView.prototype.buffer
29     static JSTaggedValue GetBuffer(EcmaRuntimeCallInfo *argv);
30     // 24.2.4.2 get DataView.prototype.byteLength
31     static JSTaggedValue GetByteLength(EcmaRuntimeCallInfo *argv);
32     // 24.2.4.3 get DataView.prototype.byteOffset
33     static JSTaggedValue GetOffset(EcmaRuntimeCallInfo *argv);
34     // 24.2.4.5 DataView.prototype.getFloat32 ( byteOffset [ , littleEndian ] )
35     static JSTaggedValue GetFloat32(EcmaRuntimeCallInfo *argv);
36     // 24.2.4.6 DataView.prototype.getFloat64 ( byteOffset [ , littleEndian ] )
37     static JSTaggedValue GetFloat64(EcmaRuntimeCallInfo *argv);
38     // 24.2.4.7 DataView.prototype.getInt8 ( byteOffset )
39     static JSTaggedValue GetInt8(EcmaRuntimeCallInfo *argv);
40     // 24.2.4.8 DataView.prototype.getInt16 ( byteOffset [ , littleEndian ] )
41     static JSTaggedValue GetInt16(EcmaRuntimeCallInfo *argv);
42     // 24.2.4.9 DataView.prototype.getInt32 ( byteOffset [ , littleEndian ] )
43     static JSTaggedValue GetInt32(EcmaRuntimeCallInfo *argv);
44     // 24.2.4.10 DataView.prototype.getUint8 ( byteOffset )
45     static JSTaggedValue GetUint8(EcmaRuntimeCallInfo *argv);
46     // 24.2.4.11 DataView.prototype.getUint16 ( byteOffset [ , littleEndian ] )
47     static JSTaggedValue GetUint16(EcmaRuntimeCallInfo *argv);
48     // 24.2.4.12 DataView.prototype.getUint32 ( byteOffset [ , littleEndian ] )
49     static JSTaggedValue GetUint32(EcmaRuntimeCallInfo *argv);
50     // 25.3.4.5 DataView.prototype.getBigInt64 ( byteOffset [ , littleEndian ] )
51     static JSTaggedValue GetBigInt64(EcmaRuntimeCallInfo *argv);
52     // 25.3.4.6 DataView.prototype.getBigUint64 ( byteOffset [ , littleEndian ] )
53     static JSTaggedValue GetBigUint64(EcmaRuntimeCallInfo *argv);
54     // 24.2.4.13 DataView.prototype.setFloat32 ( byteOffset, value [ , littleEndian ] )
55     static JSTaggedValue SetFloat32(EcmaRuntimeCallInfo *argv);
56     // 24.2.4.14 DataView.prototype.setFloat64 ( byteOffset, value [ , littleEndian ] )
57     static JSTaggedValue SetFloat64(EcmaRuntimeCallInfo *argv);
58     // 24.2.4.15 DataView.prototype.setInt8 ( byteOffset, value )
59     static JSTaggedValue SetInt8(EcmaRuntimeCallInfo *argv);
60     // 24.2.4.16 DataView.prototype.setInt16 ( byteOffset, value [ , littleEndian ] )
61     static JSTaggedValue SetInt16(EcmaRuntimeCallInfo *argv);
62     // 24.2.4.17 DataView.prototype.setInt32 ( byteOffset, value [ , littleEndian ] )
63     static JSTaggedValue SetInt32(EcmaRuntimeCallInfo *argv);
64     // 24.2.4.18 DataView.prototype.setUint8 ( byteOffset, value )
65     static JSTaggedValue SetUint8(EcmaRuntimeCallInfo *argv);
66     // 24.2.4.19 DataView.prototype.setUint16( byteOffset, value [ , littleEndian ] )
67     static JSTaggedValue SetUint16(EcmaRuntimeCallInfo *argv);
68     // 24.2.4.20 DataView.prototype.setUint32 ( byteOffset, value [ , littleEndian ] )
69     static JSTaggedValue SetUint32(EcmaRuntimeCallInfo *argv);
70     // 25.3.4.15 DataView.prototype.setBigInt64 ( byteOffset, value [ , littleEndian ] )
71     static JSTaggedValue SetBigInt64(EcmaRuntimeCallInfo *argv);
72     // 25.3.4.16 DataView.prototype.setBigUint64 ( byteOffset, value [ , littleEndian ] )
73     static JSTaggedValue SetBigUint64(EcmaRuntimeCallInfo *argv);
74 
75 private:
76     // 24.2.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type )
77     static JSTaggedValue GetViewValue(JSThread *thread, const JSHandle<JSTaggedValue> &view,
78                                       const JSHandle<JSTaggedValue> &requestIndex,
79                                       const JSHandle<JSTaggedValue> &littleEndian,
80                                       DataViewType type);
81     static JSTaggedValue SetViewValue(JSThread *thread, const JSHandle<JSTaggedValue> &view,
82                                       const JSHandle<JSTaggedValue> &requestIndex,
83                                       const JSHandle<JSTaggedValue> &littleEndian,
84                                       DataViewType type, const JSHandle<JSTaggedValue> &value);
85 
86     static JSTaggedValue GetTypedValue(EcmaRuntimeCallInfo *argv, DataViewType type);
87     static JSTaggedValue SetTypedValue(EcmaRuntimeCallInfo *argv, DataViewType type);
88 };
89 }  // namespace panda::ecmascript::builtins
90 
91 #endif  // ECMASCRIPT_BUILTINS_BUILTINS_DATAVIEW_H
92