1 /* 2 * Copyright (c) 2025 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_CROSS_VM_DYNAMIC_OBJECT_ACCESSOR_H 17 #define ECMASCRIPT_CROSS_VM_DYNAMIC_OBJECT_ACCESSOR_H 18 19 #include "common_interfaces/objects/base_object.h" 20 #include "common_interfaces/objects/base_object_accessor.h" 21 22 namespace panda::ecmascript { 23 using common::ThreadHolder; 24 using common::BaseObject; 25 26 class DynamicObjectAccessor : public common::DynamicObjectAccessorInterface { 27 public: 28 static void Initialize(); 29 30 bool HasProperty(ThreadHolder *thread, const BaseObject *obj, 31 const char *name) const override; 32 33 JSTaggedValue GetProperty(ThreadHolder *thread, const BaseObject *obj, 34 const char *name) const override; 35 36 bool SetProperty(ThreadHolder *thread, BaseObject *obj, 37 const char *name, JSTaggedValue value) override; 38 39 bool HasElementByIdx(ThreadHolder *thread, 40 const BaseObject *obj, 41 const uint32_t index) const override; 42 43 JSTaggedValue GetElementByIdx(ThreadHolder *thread, 44 const BaseObject *obj, 45 const uint32_t index) const override; 46 47 bool SetElementByIdx(ThreadHolder *thread, BaseObject *obj, 48 const uint32_t index, JSTaggedValue value) override; 49 50 private: 51 static DynamicObjectAccessor dynObjectAccessor_; 52 }; 53 } // namespace panda::ecmascript 54 #endif // ECMASCRIPT_CROSS_VM_DYNAMIC_OBJECT_ACCESSOR_H 55