OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/inspector/V8ValueCopier.h" | 5 #include "src/inspector/V8ValueCopier.h" |
6 | 6 |
7 namespace v8_inspector { | 7 namespace v8_inspector { |
8 | 8 |
9 namespace { | 9 namespace { |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 return value; | 23 return value; |
24 if (!value->IsObject()) return v8::MaybeLocal<v8::Value>(); | 24 if (!value->IsObject()) return v8::MaybeLocal<v8::Value>(); |
25 v8::Local<v8::Object> object = value.As<v8::Object>(); | 25 v8::Local<v8::Object> object = value.As<v8::Object>(); |
26 if (object->CreationContext() != m_from) return value; | 26 if (object->CreationContext() != m_from) return value; |
27 | 27 |
28 if (object->IsArray()) { | 28 if (object->IsArray()) { |
29 v8::Local<v8::Array> array = object.As<v8::Array>(); | 29 v8::Local<v8::Array> array = object.As<v8::Array>(); |
30 v8::Local<v8::Array> result = v8::Array::New(m_isolate, array->Length()); | 30 v8::Local<v8::Array> result = v8::Array::New(m_isolate, array->Length()); |
31 if (!result->SetPrototype(m_to, v8::Null(m_isolate)).FromMaybe(false)) | 31 if (!result->SetPrototype(m_to, v8::Null(m_isolate)).FromMaybe(false)) |
32 return v8::MaybeLocal<v8::Value>(); | 32 return v8::MaybeLocal<v8::Value>(); |
33 for (uint32_t i = 0; i < array->Length(); ++i) { | 33 for (size_t i = 0; i < array->Length(); ++i) { |
34 v8::Local<v8::Value> item; | 34 v8::Local<v8::Value> item; |
35 if (!array->Get(m_from, i).ToLocal(&item)) | 35 if (!array->Get(m_from, i).ToLocal(&item)) |
36 return v8::MaybeLocal<v8::Value>(); | 36 return v8::MaybeLocal<v8::Value>(); |
37 v8::Local<v8::Value> copied; | 37 v8::Local<v8::Value> copied; |
38 if (!copy(item, depth + 1).ToLocal(&copied)) | 38 if (!copy(item, depth + 1).ToLocal(&copied)) |
39 return v8::MaybeLocal<v8::Value>(); | 39 return v8::MaybeLocal<v8::Value>(); |
40 if (!createDataProperty(m_to, result, i, copied).FromMaybe(false)) | 40 if (!createDataProperty(m_to, result, i, copied).FromMaybe(false)) |
41 return v8::MaybeLocal<v8::Value>(); | 41 return v8::MaybeLocal<v8::Value>(); |
42 } | 42 } |
43 return result; | 43 return result; |
44 } | 44 } |
45 | 45 |
46 v8::Local<v8::Object> result = v8::Object::New(m_isolate); | 46 v8::Local<v8::Object> result = v8::Object::New(m_isolate); |
47 if (!result->SetPrototype(m_to, v8::Null(m_isolate)).FromMaybe(false)) | 47 if (!result->SetPrototype(m_to, v8::Null(m_isolate)).FromMaybe(false)) |
48 return v8::MaybeLocal<v8::Value>(); | 48 return v8::MaybeLocal<v8::Value>(); |
49 v8::Local<v8::Array> properties; | 49 v8::Local<v8::Array> properties; |
50 if (!object->GetOwnPropertyNames(m_from).ToLocal(&properties)) | 50 if (!object->GetOwnPropertyNames(m_from).ToLocal(&properties)) |
51 return v8::MaybeLocal<v8::Value>(); | 51 return v8::MaybeLocal<v8::Value>(); |
52 for (uint32_t i = 0; i < properties->Length(); ++i) { | 52 for (size_t i = 0; i < properties->Length(); ++i) { |
53 v8::Local<v8::Value> name; | 53 v8::Local<v8::Value> name; |
54 if (!properties->Get(m_from, i).ToLocal(&name) || !name->IsString()) | 54 if (!properties->Get(m_from, i).ToLocal(&name) || !name->IsString()) |
55 return v8::MaybeLocal<v8::Value>(); | 55 return v8::MaybeLocal<v8::Value>(); |
56 v8::Local<v8::Value> property; | 56 v8::Local<v8::Value> property; |
57 if (!object->Get(m_from, name).ToLocal(&property)) | 57 if (!object->Get(m_from, name).ToLocal(&property)) |
58 return v8::MaybeLocal<v8::Value>(); | 58 return v8::MaybeLocal<v8::Value>(); |
59 v8::Local<v8::Value> copied; | 59 v8::Local<v8::Value> copied; |
60 if (!copy(property, depth + 1).ToLocal(&copied)) | 60 if (!copy(property, depth + 1).ToLocal(&copied)) |
61 return v8::MaybeLocal<v8::Value>(); | 61 return v8::MaybeLocal<v8::Value>(); |
62 if (!createDataProperty(m_to, result, v8::Local<v8::String>::Cast(name), | 62 if (!createDataProperty(m_to, result, v8::Local<v8::String>::Cast(name), |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 v8::Local<v8::Array> array, int index, | 101 v8::Local<v8::Array> array, int index, |
102 v8::Local<v8::Value> value) { | 102 v8::Local<v8::Value> value) { |
103 v8::TryCatch tryCatch(context->GetIsolate()); | 103 v8::TryCatch tryCatch(context->GetIsolate()); |
104 v8::Isolate::DisallowJavascriptExecutionScope throwJs( | 104 v8::Isolate::DisallowJavascriptExecutionScope throwJs( |
105 context->GetIsolate(), | 105 context->GetIsolate(), |
106 v8::Isolate::DisallowJavascriptExecutionScope::THROW_ON_FAILURE); | 106 v8::Isolate::DisallowJavascriptExecutionScope::THROW_ON_FAILURE); |
107 return array->CreateDataProperty(context, index, value); | 107 return array->CreateDataProperty(context, index, value); |
108 } | 108 } |
109 | 109 |
110 } // namespace v8_inspector | 110 } // namespace v8_inspector |
OLD | NEW |