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