Line data Source code
1 : // Copyright 2018 the V8 project authors. All rights reserved.
2 : // Use of this source code is governed by a BSD-style license that can be
3 : // found in the LICENSE file.
4 :
5 : #ifndef V8_INSPECTOR_VALUE_MIRROR_H_
6 : #define V8_INSPECTOR_VALUE_MIRROR_H_
7 :
8 : #include <memory>
9 :
10 : #include "src/base/macros.h"
11 : #include "src/inspector/protocol/Protocol.h"
12 : #include "src/inspector/protocol/Runtime.h"
13 : #include "src/inspector/string-16.h"
14 :
15 : #include "include/v8-inspector.h"
16 : #include "include/v8.h"
17 :
18 : namespace v8_inspector {
19 :
20 : class ValueMirror;
21 : enum class WrapMode;
22 :
23 330 : struct PrivatePropertyMirror {
24 : String16 name;
25 : std::unique_ptr<ValueMirror> value;
26 : };
27 :
28 8150 : struct InternalPropertyMirror {
29 : String16 name;
30 : std::unique_ptr<ValueMirror> value;
31 : };
32 :
33 48207273 : struct PropertyMirror {
34 : String16 name;
35 : bool writable;
36 : bool configurable;
37 : bool enumerable;
38 : bool isOwn;
39 : bool isIndex;
40 : std::unique_ptr<ValueMirror> value;
41 : std::unique_ptr<ValueMirror> getter;
42 : std::unique_ptr<ValueMirror> setter;
43 : std::unique_ptr<ValueMirror> symbol;
44 : std::unique_ptr<ValueMirror> exception;
45 : };
46 :
47 7292058 : class ValueMirror {
48 : public:
49 : virtual ~ValueMirror();
50 :
51 : static std::unique_ptr<ValueMirror> create(v8::Local<v8::Context> context,
52 : v8::Local<v8::Value> value);
53 : virtual protocol::Response buildRemoteObject(
54 : v8::Local<v8::Context> context, WrapMode mode,
55 : std::unique_ptr<protocol::Runtime::RemoteObject>* result) const = 0;
56 0 : virtual void buildPropertyPreview(
57 : v8::Local<v8::Context> context, const String16& name,
58 0 : std::unique_ptr<protocol::Runtime::PropertyPreview>*) const {}
59 55 : virtual void buildObjectPreview(
60 : v8::Local<v8::Context> context, bool generatePreviewForTable,
61 : int* nameLimit, int* indexLimit,
62 55 : std::unique_ptr<protocol::Runtime::ObjectPreview>*) const {}
63 0 : virtual void buildEntryPreview(
64 : v8::Local<v8::Context> context, int* nameLimit, int* indexLimit,
65 0 : std::unique_ptr<protocol::Runtime::ObjectPreview>*) const {}
66 : virtual v8::Local<v8::Value> v8Value() const = 0;
67 :
68 79268 : class PropertyAccumulator {
69 : public:
70 79268 : virtual ~PropertyAccumulator() = default;
71 : virtual bool Add(PropertyMirror mirror) = 0;
72 : };
73 : static bool getProperties(v8::Local<v8::Context> context,
74 : v8::Local<v8::Object> object, bool ownProperties,
75 : bool accessorPropertiesOnly,
76 : PropertyAccumulator* accumulator);
77 : static void getInternalProperties(
78 : v8::Local<v8::Context> context, v8::Local<v8::Object> object,
79 : std::vector<InternalPropertyMirror>* mirrors);
80 : static std::vector<PrivatePropertyMirror> getPrivateProperties(
81 : v8::Local<v8::Context> context, v8::Local<v8::Object> object);
82 : };
83 : } // namespace v8_inspector
84 :
85 : #endif // V8_INSPECTOR_VALUE_MIRROR_H_
|