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