diff options
author | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2013-09-13 12:51:20 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-19 20:50:05 +0200 |
commit | d441d6f39bb846989d95bcf5caf387b42414718d (patch) | |
tree | e367e64a75991c554930278175d403c072de6bb8 /Source/JavaScriptCore/API/JSCallbackFunction.cpp | |
parent | 0060b2994c07842f4c59de64b5e3e430525c4b90 (diff) | |
download | qtwebkit-d441d6f39bb846989d95bcf5caf387b42414718d.tar.gz |
Import Qt5x2 branch of QtWebkit for Qt 5.2
Importing a new snapshot of webkit.
Change-Id: I2d01ad12cdc8af8cb015387641120a9d7ea5f10c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'Source/JavaScriptCore/API/JSCallbackFunction.cpp')
-rw-r--r-- | Source/JavaScriptCore/API/JSCallbackFunction.cpp | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/Source/JavaScriptCore/API/JSCallbackFunction.cpp b/Source/JavaScriptCore/API/JSCallbackFunction.cpp index aada87bfa..c29b9077c 100644 --- a/Source/JavaScriptCore/API/JSCallbackFunction.cpp +++ b/Source/JavaScriptCore/API/JSCallbackFunction.cpp @@ -29,11 +29,13 @@ #include "APIShims.h" #include "APICast.h" #include "CodeBlock.h" +#include "Error.h" #include "ExceptionHelpers.h" -#include "JSFunction.h" #include "FunctionPrototype.h" -#include <runtime/JSGlobalObject.h> -#include <runtime/JSLock.h> +#include "JSFunction.h" +#include "JSGlobalObject.h" +#include "JSLock.h" +#include "Operations.h" #include <wtf/Vector.h> namespace JSC { @@ -42,28 +44,36 @@ ASSERT_HAS_TRIVIAL_DESTRUCTOR(JSCallbackFunction); const ClassInfo JSCallbackFunction::s_info = { "CallbackFunction", &InternalFunction::s_info, 0, 0, CREATE_METHOD_TABLE(JSCallbackFunction) }; -JSCallbackFunction::JSCallbackFunction(JSGlobalObject* globalObject, JSObjectCallAsFunctionCallback callback) - : InternalFunction(globalObject, globalObject->callbackFunctionStructure()) +JSCallbackFunction::JSCallbackFunction(JSGlobalObject* globalObject, Structure* structure, JSObjectCallAsFunctionCallback callback) + : InternalFunction(globalObject, structure) , m_callback(callback) { } -void JSCallbackFunction::finishCreation(JSGlobalData& globalData, const String& name) +void JSCallbackFunction::finishCreation(VM& vm, const String& name) { - Base::finishCreation(globalData, name); + Base::finishCreation(vm, name); ASSERT(inherits(&s_info)); } +JSCallbackFunction* JSCallbackFunction::create(ExecState* exec, JSGlobalObject* globalObject, JSObjectCallAsFunctionCallback callback, const String& name) +{ + JSCallbackFunction* function = new (NotNull, allocateCell<JSCallbackFunction>(*exec->heap())) JSCallbackFunction(globalObject, globalObject->callbackFunctionStructure(), callback); + function->finishCreation(exec->vm(), name); + return function; +} + EncodedJSValue JSCallbackFunction::call(ExecState* exec) { JSContextRef execRef = toRef(exec); JSObjectRef functionRef = toRef(exec->callee()); JSObjectRef thisObjRef = toRef(exec->hostThisValue().toThisObject(exec)); - int argumentCount = static_cast<int>(exec->argumentCount()); - Vector<JSValueRef, 16> arguments(argumentCount); - for (int i = 0; i < argumentCount; i++) - arguments[i] = toRef(exec, exec->argument(i)); + size_t argumentCount = exec->argumentCount(); + Vector<JSValueRef, 16> arguments; + arguments.reserveInitialCapacity(argumentCount); + for (size_t i = 0; i < argumentCount; ++i) + arguments.uncheckedAppend(toRef(exec, exec->argument(i))); JSValueRef exception = 0; JSValueRef result; |