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 virtual ~QuickJSNativeObject(); 26 27 virtual void* GetInterface(int interfaceId) override; 28 29 virtual void SetNativePointer(void* pointer, NativeFinalize cb, void* hint) override; 30 31 virtual void AddFinalizer(void* pointer, NativeFinalize cb, void* hint) override; 32 virtual void* GetNativePointer() override; 33 34 virtual NativeValue* GetPropertyNames() override; 35 36 virtual NativeValue* GetPrototype() override; 37 38 virtual bool DefineProperty(NativePropertyDescriptor propertyDescriptor) override; 39 40 virtual bool SetProperty(NativeValue* key, NativeValue* value) override; 41 virtual NativeValue* GetProperty(NativeValue* key) override; 42 virtual bool HasProperty(NativeValue* key) override; 43 virtual bool DeleteProperty(NativeValue* key) override; 44 45 virtual bool SetProperty(const char* name, NativeValue* value) override; 46 virtual NativeValue* GetProperty(const char* name) override; 47 virtual bool HasProperty(const char* name) override; 48 virtual bool DeleteProperty(const char* name) override; 49 50 virtual bool SetPrivateProperty(const char* name, NativeValue* value) override; 51 virtual NativeValue* GetPrivateProperty(const char* name) override; 52 virtual bool HasPrivateProperty(const char* name) override; 53 virtual bool DeletePrivateProperty(const char* name) override; 54 55 virtual NativeValue* GetAllPropertyNames( 56 napi_key_collection_mode keyMode, napi_key_filter keyFilter, napi_key_conversion keyConversion) override; 57 58 virtual bool AssociateTypeTag(NapiTypeTag* typeTag) override; 59 virtual bool CheckTypeTag(NapiTypeTag* typeTag) override; 60 virtual void Freeze() override; 61 virtual void Seal() override; 62 }; 63 64 #endif /* FOUNDATION_ACE_NAPI_NATIVE_ENGINE_IMPL_QUICKJS_NATIVE_VALUE_QUICKJS_NATIVE_OBJECT_H */ 65