1/*
2 * Copyright (c) 2023 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_LAZY_CALLBACK_H
17#define ECMASCRIPT_BUILTINS_BUILTINS_LAZY_CALLBACK_H
18
19#include "ecmascript/global_env.h"
20#include "ecmascript/js_function.h"
21#include "ecmascript/js_handle.h"
22#include "ecmascript/js_tagged_value.h"
23#include "ecmascript/js_thread.h"
24#include "ecmascript/object_factory.h"
25
26// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
27#define ITERATE_TYPED_ARRAY(V) \
28    V(Int8Array)               \
29    V(Uint8Array)              \
30    V(Uint8ClampedArray)       \
31    V(Int16Array)              \
32    V(Uint16Array)             \
33    V(Int32Array)              \
34    V(Uint32Array)             \
35    V(Float32Array)            \
36    V(Float64Array)            \
37    V(BigInt64Array)           \
38    V(BigUint64Array)
39
40#define ITERATE_INTL(V)       \
41    V(Locale)                 \
42    V(DateTimeFormat)         \
43    V(NumberFormat)           \
44    V(RelativeTimeFormat)     \
45    V(Collator)               \
46    V(PluralRules)            \
47    V(DisplayNames)           \
48    V(Segmenter)              \
49    V(Segments)               \
50    V(ListFormat)             \
51
52namespace panda::ecmascript::builtins {
53class BuiltinsLazyCallback {
54public:
55    static JSTaggedValue Date(JSThread *thread, const JSHandle<JSObject> &obj);
56    static JSTaggedValue Set(JSThread *thread, const JSHandle<JSObject> &obj);
57    static JSTaggedValue Map(JSThread *thread, const JSHandle<JSObject> &obj);
58    static JSTaggedValue WeakMap(JSThread *thread, const JSHandle<JSObject> &obj);
59    static JSTaggedValue WeakSet(JSThread *thread, const JSHandle<JSObject> &obj);
60    static JSTaggedValue WeakRef(JSThread *thread, const JSHandle<JSObject> &obj);
61    static JSTaggedValue FinalizationRegistry(JSThread *thread, const JSHandle<JSObject> &obj);
62    static JSTaggedValue TypedArray(JSThread *thread, const JSHandle<JSObject> &obj);
63    static JSTaggedValue Int8Array(JSThread *thread, const JSHandle<JSObject> &obj);
64    static JSTaggedValue Uint8Array(JSThread *thread, const JSHandle<JSObject> &obj);
65    static JSTaggedValue Uint8ClampedArray(JSThread *thread, const JSHandle<JSObject> &obj);
66    static JSTaggedValue Int16Array(JSThread *thread, const JSHandle<JSObject> &obj);
67    static JSTaggedValue Uint16Array(JSThread *thread, const JSHandle<JSObject> &obj);
68    static JSTaggedValue Int32Array(JSThread *thread, const JSHandle<JSObject> &obj);
69    static JSTaggedValue Uint32Array(JSThread *thread, const JSHandle<JSObject> &obj);
70    static JSTaggedValue Float32Array(JSThread *thread, const JSHandle<JSObject> &obj);
71    static JSTaggedValue Float64Array(JSThread *thread, const JSHandle<JSObject> &obj);
72    static JSTaggedValue BigInt64Array(JSThread *thread, const JSHandle<JSObject> &obj);
73    static JSTaggedValue BigUint64Array(JSThread *thread, const JSHandle<JSObject> &obj);
74    static JSTaggedValue ArrayBuffer(JSThread *thread, const JSHandle<JSObject> &obj);
75    static JSTaggedValue DataView(JSThread *thread, const JSHandle<JSObject> &obj);
76    static JSTaggedValue SharedArrayBuffer(JSThread *thread, const JSHandle<JSObject> &obj);
77#ifdef ARK_SUPPORT_INTL
78    static JSTaggedValue Locale(JSThread *thread, const JSHandle<JSObject> &obj);
79    static JSTaggedValue DateTimeFormat(JSThread *thread, const JSHandle<JSObject> &obj);
80    static JSTaggedValue NumberFormat(JSThread *thread, const JSHandle<JSObject> &obj);
81    static JSTaggedValue RelativeTimeFormat(JSThread *thread, const JSHandle<JSObject> &obj);
82    static JSTaggedValue Collator(JSThread *thread, const JSHandle<JSObject> &obj);
83    static JSTaggedValue PluralRules(JSThread *thread, const JSHandle<JSObject> &obj);
84    static JSTaggedValue DisplayNames(JSThread *thread, const JSHandle<JSObject> &obj);
85    static JSTaggedValue Segmenter(JSThread *thread, const JSHandle<JSObject> &obj);
86    static JSTaggedValue Segments(JSThread *thread, const JSHandle<JSObject> &obj);
87    static JSTaggedValue ListFormat(JSThread *thread, const JSHandle<JSObject> &obj);
88#endif
89
90private:
91    static void ResetLazyInternalAttr(JSThread *thread, const JSHandle<JSObject> &object, const char *key);
92};
93}   // namespace panda::ecmascript::builtins
94#endif  // ECMASCRIPT_BUILTINS_BUILTINS_LAZY_CALLBACK_H