Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: src/api.cc

Issue 2307603002: Throw exceptions for errors in v8::ValueSerializer. (Closed)
Patch Set: fix comment Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/v8.h ('k') | src/messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/api.h" 5 #include "src/api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #ifdef V8_USE_ADDRESS_SANITIZER 8 #ifdef V8_USE_ADDRESS_SANITIZER
9 #include <sanitizer/asan_interface.h> 9 #include <sanitizer/asan_interface.h>
10 #endif // V8_USE_ADDRESS_SANITIZER 10 #endif // V8_USE_ADDRESS_SANITIZER
(...skipping 2820 matching lines...) Expand 10 before | Expand all | Expand 10 after
2831 Local<String> result; 2831 Local<String> result;
2832 has_pending_exception = 2832 has_pending_exception =
2833 !ToLocal<String>(i::Object::ToString(isolate, maybe), &result); 2833 !ToLocal<String>(i::Object::ToString(isolate, maybe), &result);
2834 RETURN_ON_FAILED_EXECUTION(String); 2834 RETURN_ON_FAILED_EXECUTION(String);
2835 RETURN_ESCAPED(result); 2835 RETURN_ESCAPED(result);
2836 } 2836 }
2837 2837
2838 // --- V a l u e S e r i a l i z a t i o n --- 2838 // --- V a l u e S e r i a l i z a t i o n ---
2839 2839
2840 struct ValueSerializer::PrivateData { 2840 struct ValueSerializer::PrivateData {
2841 explicit PrivateData(i::Isolate* i) : isolate(i), serializer(i) {} 2841 explicit PrivateData(i::Isolate* i, ValueSerializer::Delegate* delegate)
2842 : isolate(i), serializer(i, delegate) {}
2842 i::Isolate* isolate; 2843 i::Isolate* isolate;
2843 i::ValueSerializer serializer; 2844 i::ValueSerializer serializer;
2844 }; 2845 };
2845 2846
2846 ValueSerializer::ValueSerializer(Isolate* isolate) 2847 ValueSerializer::ValueSerializer(Isolate* isolate)
2847 : private_(new PrivateData(reinterpret_cast<i::Isolate*>(isolate))) {} 2848 : ValueSerializer(isolate, nullptr) {}
2849
2850 ValueSerializer::ValueSerializer(Isolate* isolate, Delegate* delegate)
2851 : private_(
2852 new PrivateData(reinterpret_cast<i::Isolate*>(isolate), delegate)) {}
2848 2853
2849 ValueSerializer::~ValueSerializer() { delete private_; } 2854 ValueSerializer::~ValueSerializer() { delete private_; }
2850 2855
2851 void ValueSerializer::WriteHeader() { private_->serializer.WriteHeader(); } 2856 void ValueSerializer::WriteHeader() { private_->serializer.WriteHeader(); }
2852 2857
2853 Maybe<bool> ValueSerializer::WriteValue(Local<Context> context, 2858 Maybe<bool> ValueSerializer::WriteValue(Local<Context> context,
2854 Local<Value> value) { 2859 Local<Value> value) {
2855 PREPARE_FOR_EXECUTION_PRIMITIVE(context, ValueSerializer, WriteValue, bool); 2860 PREPARE_FOR_EXECUTION_PRIMITIVE(context, ValueSerializer, WriteValue, bool);
2856 i::Handle<i::Object> object = Utils::OpenHandle(*value); 2861 i::Handle<i::Object> object = Utils::OpenHandle(*value);
2857 Maybe<bool> result = private_->serializer.WriteObject(object); 2862 Maybe<bool> result = private_->serializer.WriteObject(object);
(...skipping 6348 matching lines...) Expand 10 before | Expand all | Expand 10 after
9206 Address callback_address = 9211 Address callback_address =
9207 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 9212 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
9208 VMState<EXTERNAL> state(isolate); 9213 VMState<EXTERNAL> state(isolate);
9209 ExternalCallbackScope call_scope(isolate, callback_address); 9214 ExternalCallbackScope call_scope(isolate, callback_address);
9210 callback(info); 9215 callback(info);
9211 } 9216 }
9212 9217
9213 9218
9214 } // namespace internal 9219 } // namespace internal
9215 } // namespace v8 9220 } // namespace v8
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698