OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 int global_length = global_listeners.length(); | 125 int global_length = global_listeners.length(); |
126 if (global_length == 0) { | 126 if (global_length == 0) { |
127 DefaultMessageReport(loc, message); | 127 DefaultMessageReport(loc, message); |
128 if (isolate->has_scheduled_exception()) { | 128 if (isolate->has_scheduled_exception()) { |
129 isolate->clear_scheduled_exception(); | 129 isolate->clear_scheduled_exception(); |
130 } | 130 } |
131 } else { | 131 } else { |
132 for (int i = 0; i < global_length; i++) { | 132 for (int i = 0; i < global_length; i++) { |
133 HandleScope scope; | 133 HandleScope scope; |
134 if (global_listeners.get(i)->IsUndefined()) continue; | 134 if (global_listeners.get(i)->IsUndefined()) continue; |
135 Handle<Foreign> callback_obj(Foreign::cast(global_listeners.get(i))); | 135 v8::NeanderObject listener(JSObject::cast(global_listeners.get(i))); |
| 136 Handle<Foreign> callback_obj(Foreign::cast(listener.get(0))); |
136 v8::MessageCallback callback = | 137 v8::MessageCallback callback = |
137 FUNCTION_CAST<v8::MessageCallback>(callback_obj->foreign_address()); | 138 FUNCTION_CAST<v8::MessageCallback>(callback_obj->foreign_address()); |
| 139 Handle<Object> callback_data(listener.get(1)); |
138 { | 140 { |
139 // Do not allow exceptions to propagate. | 141 // Do not allow exceptions to propagate. |
140 v8::TryCatch try_catch; | 142 v8::TryCatch try_catch; |
141 callback(api_message_obj, api_exception_obj); | 143 callback(api_message_obj, callback_data->IsUndefined() |
| 144 ? api_exception_obj |
| 145 : v8::Utils::ToLocal(callback_data)); |
142 } | 146 } |
143 if (isolate->has_scheduled_exception()) { | 147 if (isolate->has_scheduled_exception()) { |
144 isolate->clear_scheduled_exception(); | 148 isolate->clear_scheduled_exception(); |
145 } | 149 } |
146 } | 150 } |
147 } | 151 } |
148 } | 152 } |
149 | 153 |
150 | 154 |
151 Handle<String> MessageHandler::GetMessage(Handle<Object> data) { | 155 Handle<String> MessageHandler::GetMessage(Handle<Object> data) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 187 |
184 | 188 |
185 SmartArrayPointer<char> MessageHandler::GetLocalizedMessage( | 189 SmartArrayPointer<char> MessageHandler::GetLocalizedMessage( |
186 Handle<Object> data) { | 190 Handle<Object> data) { |
187 HandleScope scope; | 191 HandleScope scope; |
188 return GetMessage(data)->ToCString(DISALLOW_NULLS); | 192 return GetMessage(data)->ToCString(DISALLOW_NULLS); |
189 } | 193 } |
190 | 194 |
191 | 195 |
192 } } // namespace v8::internal | 196 } } // namespace v8::internal |
OLD | NEW |