Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index d3d472d79947cd208684db88d98cc633a551f48c..51e1bf06fdaca153558971b067fab8d5ba26ee8c 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -5320,14 +5320,18 @@ void V8::IgnoreOutOfMemoryException() { |
} |
-bool V8::AddMessageListener(MessageCallback that) { |
+bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) { |
i::Isolate* isolate = i::Isolate::Current(); |
EnsureInitializedForIsolate(isolate, "v8::V8::AddMessageListener()"); |
ON_BAILOUT(isolate, "v8::V8::AddMessageListener()", return false); |
ENTER_V8(isolate); |
i::HandleScope scope(isolate); |
NeanderArray listeners(isolate->factory()->message_listeners()); |
- listeners.add(isolate->factory()->NewForeign(FUNCTION_ADDR(that))); |
+ NeanderObject obj(2); |
+ obj.set(0, *isolate->factory()->NewForeign(FUNCTION_ADDR(that))); |
+ obj.set(1, data.IsEmpty() ? isolate->heap()->undefined_value() |
+ : *Utils::OpenHandle(*data)); |
+ listeners.add(obj.value()); |
return true; |
} |
@@ -5342,7 +5346,8 @@ void V8::RemoveMessageListeners(MessageCallback that) { |
for (int i = 0; i < listeners.length(); i++) { |
if (listeners.get(i)->IsUndefined()) continue; // skip deleted ones |
- i::Handle<i::Foreign> callback_obj(i::Foreign::cast(listeners.get(i))); |
+ NeanderObject listener(i::JSObject::cast(listeners.get(i))); |
+ i::Handle<i::Foreign> callback_obj(i::Foreign::cast(listener.get(0))); |
if (callback_obj->foreign_address() == FUNCTION_ADDR(that)) { |
listeners.set(i, isolate->heap()->undefined_value()); |
} |