diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2011-10-27 13:40:00 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-26 08:56:32 +0200 |
commit | e9eec54513cc7cf8850f5832565075c2c9339cee (patch) | |
tree | d8e2b625be45102d43c38ace9234441b0f33f4a4 /src/3rdparty/v8/src/api.cc | |
parent | cb81e0bca99bbd90a3f22277727ff31b38152805 (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: Icd3419349874ee845684fff8455862da73f5ff2d
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
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 d11b98e..4c39e7a 100644 --- a/src/3rdparty/v8/src/api.cc +++ b/src/3rdparty/v8/src/api.cc @@ -1493,6 +1493,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 --- @@ -5364,6 +5375,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) { |