diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2011-10-27 13:40:00 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-01-05 12:18:11 +0100 |
commit | dd34832c519d86f1f7d157d872a87f8ed56de6c8 (patch) | |
tree | 9a66fc51cb19559ffc1e92060c4a54dfa6abd05e /src/3rdparty/v8/src/api.cc | |
parent | b126a7c96ba8a0ae4bd91fd504a4b36a1034c199 (diff) |
[V8] Add custom object compare callback
A global custom object comparison callback can be set with:
V8::SetUserObjectComparisonCallbackFunction()
When two JSObjects are compared (== or !=), if either one has
the MarkAsUseUserObjectComparison() bit set, the custom comparison
callback is invoked to do the actual comparison.
This is useful when you have "value" objects that you want to
compare as equal, even though they are actually different JS object
instances.
Change-Id: Ic7512e8342c071793393e5ad3fcb6fb241f7cc80
Diffstat (limited to 'src/3rdparty/v8/src/api.cc')
-rw-r--r-- | src/3rdparty/v8/src/api.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/3rdparty/v8/src/api.cc b/src/3rdparty/v8/src/api.cc index 54df40d..974d702 100644 --- a/src/3rdparty/v8/src/api.cc +++ b/src/3rdparty/v8/src/api.cc @@ -1464,6 +1464,17 @@ void ObjectTemplate::SetHasExternalResource(bool value) } +void ObjectTemplate::MarkAsUseUserObjectComparison() +{ + i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); + if (IsDeadCheck(isolate, "v8::ObjectTemplate::MarkAsUseUserObjectComparison()")) { + return; + } + ENTER_V8(isolate); + EnsureConstructor(this); + Utils::OpenHandle(this)->set_use_user_object_comparison(i::Smi::FromInt(1)); +} + // --- S c r i p t D a t a --- @@ -5113,6 +5124,17 @@ void V8::SetFailedAccessCheckCallbackFunction( isolate->SetFailedAccessCheckCallback(callback); } + +void V8::SetUserObjectComparisonCallbackFunction( + UserObjectComparisonCallback callback) { + i::Isolate* isolate = i::Isolate::Current(); + if (IsDeadCheck(isolate, "v8::V8::SetUserObjectComparisonCallbackFunction()")) { + return; + } + isolate->SetUserObjectComparisonCallback(callback); +} + + void V8::AddObjectGroup(Persistent<Value>* objects, size_t length, RetainedObjectInfo* info) { |