1 /** 2 * Copyright (c) 2021-2024 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 PANDA_RUNTIME_INCLUDE_TOOLING_PT_LANG_EXTENSION_H 17 #define PANDA_RUNTIME_INCLUDE_TOOLING_PT_LANG_EXTENSION_H 18 19 #include "libpandabase/macros.h" 20 #include "libpandafile/file_items.h" 21 #include "runtime/include/typed_value.h" 22 23 #include <optional> 24 #include <functional> 25 #include <string> 26 27 namespace ark::tooling { 28 class PtLangExt { 29 public: 30 using PropertyHandler = 31 std::function<void(const std::string &name, TypedValue value, bool isFinal, bool isAccessor)>; 32 33 public: 34 PtLangExt() = default; 35 virtual ~PtLangExt() = default; 36 37 NO_COPY_SEMANTIC(PtLangExt); 38 NO_MOVE_SEMANTIC(PtLangExt); 39 40 virtual std::string GetClassName(const ObjectHeader *object) = 0; 41 virtual std::optional<std::string> GetAsString(const ObjectHeader *object) = 0; 42 virtual std::optional<size_t> GetLengthIfArray(const ObjectHeader *object) = 0; 43 virtual void EnumerateProperties(const ObjectHeader *object, const PropertyHandler &handler) = 0; 44 virtual void EnumerateGlobals(const PropertyHandler &handler) = 0; GetThisParameterName()45 virtual std::string_view GetThisParameterName() const 46 { 47 return "this"; 48 } 49 }; 50 } // namespace ark::tooling 51 52 #endif // PANDA_RUNTIME_INCLUDE_TOOLING_PT_LANG_EXTENSION_H 53