diff options
author | Kent Hansen <kent.hansen@nokia.com> | 2011-08-16 10:50:00 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-08-29 10:16:01 +0200 |
commit | 9830cb8e5992a352ec6508491ab52e8f2a9da877 (patch) | |
tree | 9baa3969878a1e070c56c9a3a67143c2d96ee5d6 /src/v8/0012-Add-IsCallable-method-for-Object-in-the-API.patch | |
parent | 13b3545e833f6175f686c9776e1510db3f3f11eb (diff) |
Add QtV8 library to QtBase
This adds Aaron's copy of V8 to src/3rdparty/v8 (as a
git submodule), and builds it as a "normal" Qt library
(without any dependencies on Qt itself).
The library can be added to a project with
QT += v8-private
V8 API headers are available as private includes, e.g.
#include <private/v8.h>
The API is private because we're exposing a third-party
API directly, and we don't want to (and cannot) make
source or binary compatibility guarantees for it.
Since we want the V8 public API headers to be private
headers in Qt, syncqt and sync.profile were extended to
understand a new configuration option, the
@allmoduleheadersprivate array, that tells syncqt whether
all the library headers should be treated as private even
though they don't follow the _p.h Qt convention.
The V8 project files, patches and autotests are copied
from the QtDeclarative repository. The next step after
this commit is to remove QtDeclarative's copy of V8 and
link with QtV8 instead.
Task-number: QTBUG-20963
Change-Id: Ib8820362cdbc8fa662a5e97db841656cf38d1b62
Reviewed-on: http://codereview.qt.nokia.com/3092
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/v8/0012-Add-IsCallable-method-for-Object-in-the-API.patch')
-rw-r--r-- | src/v8/0012-Add-IsCallable-method-for-Object-in-the-API.patch | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/src/v8/0012-Add-IsCallable-method-for-Object-in-the-API.patch b/src/v8/0012-Add-IsCallable-method-for-Object-in-the-API.patch new file mode 100644 index 0000000000..77589c8af3 --- /dev/null +++ b/src/v8/0012-Add-IsCallable-method-for-Object-in-the-API.patch @@ -0,0 +1,116 @@ +From 472c04c9e7a64e8734c76d2cf97a7cc5b773b788 Mon Sep 17 00:00:00 2001 +From: ager@chromium.org <ager@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00> +Date: Mon, 9 May 2011 15:24:48 +0000 +Subject: [PATCH 12/13] Add IsCallable method for Object in the API + +Patch by Peter Varga. + +BUG=none +TEST=cctest/test-api/CallableObject + +Review URL: http://codereview.chromium.org/6964005 + +git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@7828 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 +--- + include/v8.h | 7 +++++++ + src/api.cc | 11 +++++++++++ + test/cctest/test-api.cc | 43 +++++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 61 insertions(+), 0 deletions(-) + +diff --git a/include/v8.h b/include/v8.h +index 08b0ec2..4194d4a 100644 +--- a/include/v8.h ++++ b/include/v8.h +@@ -1763,6 +1763,13 @@ class Object : public Value { + V8EXPORT int GetIndexedPropertiesExternalArrayDataLength(); + + /** ++ * Checks whether a callback is set by the ++ * ObjectTemplate::SetCallAsFunctionHandler method. ++ * When an Object is callable this method returns true. ++ */ ++ V8EXPORT bool IsCallable(); ++ ++ /** + * Call an Object as a function if a callback is set by the + * ObjectTemplate::SetCallAsFunctionHandler method. + */ +diff --git a/src/api.cc b/src/api.cc +index bd435eb..a5a637f 100644 +--- a/src/api.cc ++++ b/src/api.cc +@@ -3265,6 +3265,17 @@ int v8::Object::GetIndexedPropertiesExternalArrayDataLength() { + } + + ++bool v8::Object::IsCallable() { ++ i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); ++ ON_BAILOUT(isolate, "v8::Object::IsCallable()", return false); ++ ENTER_V8(isolate); ++ i::HandleScope scope(isolate); ++ i::Handle<i::JSObject> obj = Utils::OpenHandle(this); ++ if (obj->IsJSFunction()) return true; ++ return i::Execution::GetFunctionDelegate(obj)->IsJSFunction(); ++} ++ ++ + Local<v8::Value> Object::CallAsFunction(v8::Handle<v8::Object> recv, int argc, + v8::Handle<v8::Value> argv[]) { + i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); +diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc +index 1334f63..45db5a1 100644 +--- a/test/cctest/test-api.cc ++++ b/test/cctest/test-api.cc +@@ -7263,6 +7263,49 @@ THREADED_TEST(CallAsFunction) { + } + + ++// Check whether a non-function object is callable. ++THREADED_TEST(CallableObject) { ++ v8::HandleScope scope; ++ LocalContext context; ++ ++ { Local<ObjectTemplate> instance_template = ObjectTemplate::New(); ++ instance_template->SetCallAsFunctionHandler(call_as_function); ++ Local<Object> instance = instance_template->NewInstance(); ++ v8::TryCatch try_catch; ++ ++ CHECK(instance->IsCallable()); ++ CHECK(!try_catch.HasCaught()); ++ } ++ ++ { Local<ObjectTemplate> instance_template = ObjectTemplate::New(); ++ Local<Object> instance = instance_template->NewInstance(); ++ v8::TryCatch try_catch; ++ ++ CHECK(!instance->IsCallable()); ++ CHECK(!try_catch.HasCaught()); ++ } ++ ++ { Local<FunctionTemplate> function_template = ++ FunctionTemplate::New(call_as_function); ++ Local<Function> function = function_template->GetFunction(); ++ Local<Object> instance = function; ++ v8::TryCatch try_catch; ++ ++ CHECK(instance->IsCallable()); ++ CHECK(!try_catch.HasCaught()); ++ } ++ ++ { Local<FunctionTemplate> function_template = FunctionTemplate::New(); ++ Local<Function> function = function_template->GetFunction(); ++ Local<Object> instance = function; ++ v8::TryCatch try_catch; ++ ++ CHECK(instance->IsCallable()); ++ CHECK(!try_catch.HasCaught()); ++ } ++} ++ ++ + static int CountHandles() { + return v8::HandleScope::NumberOfHandles(); + } +-- +1.7.2.3 + |