X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/b37bf2e156556c589aea3e1f58a377f2b1189665..9bcd318d5fa2a38139c9651d263a06c797529333:/API/JSCallbackFunction.cpp diff --git a/API/JSCallbackFunction.cpp b/API/JSCallbackFunction.cpp index fb3937d..86a2ebc 100644 --- a/API/JSCallbackFunction.cpp +++ b/API/JSCallbackFunction.cpp @@ -1,6 +1,5 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* - * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -29,40 +28,43 @@ #include "JSCallbackFunction.h" #include "APICast.h" -#include "function.h" -#include "function_object.h" -#include +#include "JSFunction.h" +#include "FunctionPrototype.h" +#include +#include #include -namespace KJS { +namespace JSC { -const ClassInfo JSCallbackFunction::info = { "CallbackFunction", &InternalFunctionImp::info, 0}; +ASSERT_CLASS_FITS_IN_CELL(JSCallbackFunction); + +const ClassInfo JSCallbackFunction::info = { "CallbackFunction", &InternalFunction::info, 0, 0 }; JSCallbackFunction::JSCallbackFunction(ExecState* exec, JSObjectCallAsFunctionCallback callback, const Identifier& name) - : InternalFunctionImp(exec->lexicalGlobalObject()->functionPrototype(), name) + : InternalFunction(&exec->globalData(), exec->lexicalGlobalObject()->callbackFunctionStructure(), name) , m_callback(callback) { } -// InternalFunctionImp mish-mashes constructor and function behavior -- we should -// refactor the code so this override isn't necessary -bool JSCallbackFunction::implementsHasInstance() const { - return false; -} - -JSValue* JSCallbackFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List &args) +JSValuePtr JSCallbackFunction::call(ExecState* exec, JSObject* functionObject, JSValuePtr thisValue, const ArgList& args) { JSContextRef execRef = toRef(exec); - JSObjectRef thisRef = toRef(this); - JSObjectRef thisObjRef = toRef(thisObj); + JSObjectRef functionRef = toRef(functionObject); + JSObjectRef thisObjRef = toRef(thisValue.toThisObject(exec)); int argumentCount = static_cast(args.size()); Vector arguments(argumentCount); for (int i = 0; i < argumentCount; i++) - arguments[i] = toRef(args[i]); + arguments[i] = toRef(args.at(exec, i)); - JSLock::DropAllLocks dropAllLocks; - return toJS(m_callback(execRef, thisRef, thisObjRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot()))); + JSLock::DropAllLocks dropAllLocks(exec); + return toJS(static_cast(functionObject)->m_callback(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot()))); +} + +CallType JSCallbackFunction::getCallData(CallData& callData) +{ + callData.native.function = call; + return CallTypeHost; } -} // namespace KJS +} // namespace JSC