1 /** 2 * Copyright (c) 2022-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_TOOLING_INSPECTOR_DEFAULT_INSPECTOR_EXTENSION_H 17 #define PANDA_RUNTIME_TOOLING_INSPECTOR_DEFAULT_INSPECTOR_EXTENSION_H 18 19 #include "runtime/include/tooling/inspector_extension.h" 20 21 namespace ark::tooling { 22 class StaticDefaultInspectorExtension : public InspectorExtension { 23 public: StaticDefaultInspectorExtension(panda_file::SourceLang lang)24 explicit StaticDefaultInspectorExtension(panda_file::SourceLang lang) : lang_(lang) {} 25 ~StaticDefaultInspectorExtension() override = default; 26 27 NO_COPY_SEMANTIC(StaticDefaultInspectorExtension); 28 NO_MOVE_SEMANTIC(StaticDefaultInspectorExtension); 29 30 std::string GetClassName(const ObjectHeader *object) override; 31 std::optional<std::string> GetAsString(const ObjectHeader *object) override; 32 std::optional<size_t> GetLengthIfArray(const ObjectHeader *object) override; 33 void EnumerateProperties(const ObjectHeader *object, const PropertyHandler &handler) override; 34 void EnumerateGlobals(const PropertyHandler &handler) override; 35 36 private: 37 panda_file::SourceLang lang_; 38 }; 39 40 class DynamicDefaultInspectorExtension : public InspectorExtension { 41 public: 42 DynamicDefaultInspectorExtension() = default; 43 ~DynamicDefaultInspectorExtension() override = default; 44 45 NO_COPY_SEMANTIC(DynamicDefaultInspectorExtension); 46 NO_MOVE_SEMANTIC(DynamicDefaultInspectorExtension); 47 48 std::string GetClassName(const ObjectHeader *object) override; 49 std::optional<std::string> GetAsString(const ObjectHeader *object) override; 50 std::optional<size_t> GetLengthIfArray(const ObjectHeader *object) override; 51 void EnumerateProperties( 52 const ObjectHeader *object, 53 const std::function<void(const std::string &, TypedValue, bool, bool, bool)> &handler) override; EnumerateGlobals(const PropertyHandler & handler)54 void EnumerateGlobals([[maybe_unused]] const PropertyHandler &handler) override {} 55 }; 56 } // namespace ark::tooling 57 58 #endif // PANDA_RUNTIME_TOOLING_INSPECTOR_DEFAULT_INSPECTOR_EXTENSION_H 59