• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_TOOLING_INSPECTOR_EXTENSION_H
17 #define PANDA_TOOLING_INSPECTOR_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 // NOTE(a.urakov): move to PtLangExt after the refactoring will be done
29 
30 class InspectorExtension {
31 public:
32     using PropertyHandler = std::function<void(const std::string &name, TypedValue value, bool isArrayElement,
33                                                bool isFinal, bool isAccessor)>;
34 
35     InspectorExtension() = default;
36     virtual ~InspectorExtension() = default;
37 
38     NO_COPY_SEMANTIC(InspectorExtension);
39     NO_MOVE_SEMANTIC(InspectorExtension);
40 
41     virtual std::string GetClassName(const ObjectHeader *object) = 0;
42     virtual std::optional<std::string> GetAsString(const ObjectHeader *object) = 0;
43     virtual std::optional<size_t> GetLengthIfArray(const ObjectHeader *object) = 0;
44     virtual void EnumerateProperties(const ObjectHeader *object, const PropertyHandler &handler) = 0;
45     virtual void EnumerateGlobals(const PropertyHandler &handler) = 0;
GetThisParameterName()46     virtual std::string_view GetThisParameterName() const
47     {
48         return "this";
49     }
50 };
51 }  // namespace ark::tooling
52 
53 #endif  // PANDA_TOOLING_INSPECTOR_EXTENSION_H
54