| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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/messages.h" | 5 #include "src/messages.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "src/api.h" | 9 #include "src/api.h" |
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 116 |
| 117 if (!maybe_stringified.ToHandle(&stringified)) { | 117 if (!maybe_stringified.ToHandle(&stringified)) { |
| 118 stringified = isolate->factory()->NewStringFromAsciiChecked("exception"); | 118 stringified = isolate->factory()->NewStringFromAsciiChecked("exception"); |
| 119 } | 119 } |
| 120 message->set_argument(*stringified); | 120 message->set_argument(*stringified); |
| 121 } | 121 } |
| 122 | 122 |
| 123 v8::Local<v8::Message> api_message_obj = v8::Utils::MessageToLocal(message); | 123 v8::Local<v8::Message> api_message_obj = v8::Utils::MessageToLocal(message); |
| 124 v8::Local<v8::Value> api_exception_obj = v8::Utils::ToLocal(exception); | 124 v8::Local<v8::Value> api_exception_obj = v8::Utils::ToLocal(exception); |
| 125 | 125 |
| 126 v8::NeanderArray global_listeners(isolate->factory()->message_listeners()); | 126 Handle<TemplateList> global_listeners = |
| 127 int global_length = global_listeners.length(); | 127 isolate->factory()->message_listeners(); |
| 128 int global_length = global_listeners->length(); |
| 128 if (global_length == 0) { | 129 if (global_length == 0) { |
| 129 DefaultMessageReport(isolate, loc, message); | 130 DefaultMessageReport(isolate, loc, message); |
| 130 if (isolate->has_scheduled_exception()) { | 131 if (isolate->has_scheduled_exception()) { |
| 131 isolate->clear_scheduled_exception(); | 132 isolate->clear_scheduled_exception(); |
| 132 } | 133 } |
| 133 } else { | 134 } else { |
| 134 for (int i = 0; i < global_length; i++) { | 135 for (int i = 0; i < global_length; i++) { |
| 135 HandleScope scope(isolate); | 136 HandleScope scope(isolate); |
| 136 if (global_listeners.get(i)->IsUndefined(isolate)) continue; | 137 if (global_listeners->get(i)->IsUndefined(isolate)) continue; |
| 137 v8::NeanderObject listener(JSObject::cast(global_listeners.get(i))); | 138 v8::NeanderObject listener(JSObject::cast(global_listeners->get(i))); |
| 138 Handle<Foreign> callback_obj(Foreign::cast(listener.get(0))); | 139 Handle<Foreign> callback_obj(Foreign::cast(listener.get(0))); |
| 139 v8::MessageCallback callback = | 140 v8::MessageCallback callback = |
| 140 FUNCTION_CAST<v8::MessageCallback>(callback_obj->foreign_address()); | 141 FUNCTION_CAST<v8::MessageCallback>(callback_obj->foreign_address()); |
| 141 Handle<Object> callback_data(listener.get(1), isolate); | 142 Handle<Object> callback_data(listener.get(1), isolate); |
| 142 { | 143 { |
| 143 // Do not allow exceptions to propagate. | 144 // Do not allow exceptions to propagate. |
| 144 v8::TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate)); | 145 v8::TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate)); |
| 145 callback(api_message_obj, callback_data->IsUndefined(isolate) | 146 callback(api_message_obj, callback_data->IsUndefined(isolate) |
| 146 ? api_exception_obj | 147 ? api_exception_obj |
| 147 : v8::Utils::ToLocal(callback_data)); | 148 : v8::Utils::ToLocal(callback_data)); |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 // Capture a simple stack trace for the stack property. | 517 // Capture a simple stack trace for the stack property. |
| 517 RETURN_ON_EXCEPTION(isolate, | 518 RETURN_ON_EXCEPTION(isolate, |
| 518 isolate->CaptureAndSetSimpleStackTrace(err, mode, caller), | 519 isolate->CaptureAndSetSimpleStackTrace(err, mode, caller), |
| 519 Object); | 520 Object); |
| 520 | 521 |
| 521 return err; | 522 return err; |
| 522 } | 523 } |
| 523 | 524 |
| 524 } // namespace internal | 525 } // namespace internal |
| 525 } // namespace v8 | 526 } // namespace v8 |
| OLD | NEW |