• 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 FOUNDATION_ACE_NAPI_NATIVE_ENGINE_IMPL_ARK_NATIVE_VALUE_ARK_NATIVE_OBJECT_H
17 #define FOUNDATION_ACE_NAPI_NATIVE_ENGINE_IMPL_ARK_NATIVE_VALUE_ARK_NATIVE_OBJECT_H
18 
19 #include <mutex>
20 
21 #include "ark_native_value.h"
22 
23 class ArkNativeObject : public ArkNativeValue, public NativeObject {
24 public:
25     explicit ArkNativeObject(ArkNativeEngine* engine);
26     ArkNativeObject(ArkNativeEngine* engine, Local<JSValueRef> value);
27     ~ArkNativeObject() override;
28 
29     bool ConvertToNativeBindingObject(
30         void* engine, DetachCallback detach, AttachCallback attach, void *object, void *hint) override;
31     void* GetInterface(int interfaceId) override;
32     static void* DetachFuncCallback(void* engine, void* object, void* hint, void* detachData);
33     static Local<JSValueRef> AttachFuncCallback(void* engine, void* object, void* hint, void* attachData);
34     void SetNativePointer(void* pointer, NativeFinalize cb, void* hint, NativeReference** reference = nullptr,
35         size_t nativeBindingSize = 0) override;
36     void* GetNativePointer() override;
37     void SetNativeBindingPointer(void* enginePointer, void* objPointer,
38         void* hint, void* detachData, void* attachData) override;
39     void* GetNativeBindingPointer(uint32_t index) override;
40     void AddFinalizer(void* pointer, NativeFinalize cb, void* hint) override;
41     void Freeze() override;
42     void Seal() override;
43     NativeValue* GetPropertyNames() override;
44     NativeValue* GetEnumerablePropertyNames() override;
45 
46     NativeValue* GetPrototype() override;
47 
48     bool DefineProperty(NativePropertyDescriptor propertyDescriptor) override;
49 
50     bool SetProperty(NativeValue* key, NativeValue* value) override;
51     NativeValue* GetProperty(NativeValue* key) override;
52     NativeValue* GetOwnProperty(const char* name) override;
53     bool HasProperty(NativeValue* key) override;
54     bool DeleteProperty(NativeValue* key) override;
55 
56     bool SetProperty(const char* name, NativeValue* value) override;
57     NativeValue* GetProperty(const char* name) override;
58     bool HasProperty(const char* name) override;
59     bool DeleteProperty(const char* name) override;
60 
61     bool SetPrivateProperty(const char* name, NativeValue* value) override;
62     NativeValue* GetPrivateProperty(const char* name) override;
63     bool HasPrivateProperty(const char* name) override;
64     bool DeletePrivateProperty(const char* name) override;
65 
66     NativeValue* GetAllPropertyNames(
67         napi_key_collection_mode keyMode, napi_key_filter keyFilter, napi_key_conversion keyConversion) override;
68     bool AssociateTypeTag(NapiTypeTag* typeTag) override;
69     bool CheckTypeTag(NapiTypeTag* typeTag) override;
70     void SetModuleName(std::string moduleName);
71     std::string GetModuleName();
72 
73     bool SetElement(uint32_t index, NativeValue* value) override;
74     NativeValue* GetElement(uint32_t index) override;
75     bool HasElement(uint32_t index) override;
76     bool DeleteElement(uint32_t index) override;
77 };
78 
79 #endif /* FOUNDATION_ACE_NAPI_NATIVE_ENGINE_IMPL_ARK_NATIVE_VALUE_ARK_NATIVE_OBJECT_H */
80