X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/b37bf2e156556c589aea3e1f58a377f2b1189665..ed1e77d3adeb83d26fd1dfb16dd84cabdcefd250:/API/JSCallbackConstructor.cpp?ds=inline diff --git a/API/JSCallbackConstructor.cpp b/API/JSCallbackConstructor.cpp index 46c1823..65e66dc 100644 --- a/API/JSCallbackConstructor.cpp +++ b/API/JSCallbackConstructor.cpp @@ -1,6 +1,5 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* - * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2006, 2007, 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 @@ -11,10 +10,10 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -27,20 +26,30 @@ #include "config.h" #include "JSCallbackConstructor.h" +#include "APICallbackFunction.h" #include "APICast.h" -#include -#include +#include "Error.h" +#include "JSGlobalObject.h" +#include "JSLock.h" +#include "ObjectPrototype.h" +#include "JSCInlines.h" #include -namespace KJS { +namespace JSC { -const ClassInfo JSCallbackConstructor::info = { "CallbackConstructor", 0, 0}; +const ClassInfo JSCallbackConstructor::s_info = { "CallbackConstructor", &Base::s_info, 0, CREATE_METHOD_TABLE(JSCallbackConstructor) }; -JSCallbackConstructor::JSCallbackConstructor(ExecState* exec, JSClassRef jsClass, JSObjectCallAsConstructorCallback callback) - : JSObject(exec->lexicalGlobalObject()->objectPrototype()) +JSCallbackConstructor::JSCallbackConstructor(JSGlobalObject* globalObject, Structure* structure, JSClassRef jsClass, JSObjectCallAsConstructorCallback callback) + : JSDestructibleObject(globalObject->vm(), structure) , m_class(jsClass) , m_callback(callback) { +} + +void JSCallbackConstructor::finishCreation(JSGlobalObject* globalObject, JSClassRef jsClass) +{ + Base::finishCreation(globalObject->vm()); + ASSERT(inherits(info())); if (m_class) JSClassRetain(jsClass); } @@ -51,32 +60,15 @@ JSCallbackConstructor::~JSCallbackConstructor() JSClassRelease(m_class); } -bool JSCallbackConstructor::implementsHasInstance() const +void JSCallbackConstructor::destroy(JSCell* cell) { - return true; + static_cast(cell)->JSCallbackConstructor::~JSCallbackConstructor(); } -bool JSCallbackConstructor::implementsConstruct() const +ConstructType JSCallbackConstructor::getConstructData(JSCell*, ConstructData& constructData) { - return true; -} - -JSObject* JSCallbackConstructor::construct(ExecState* exec, const List &args) -{ - JSContextRef ctx = toRef(exec); - JSObjectRef thisRef = toRef(this); - - if (m_callback) { - int argumentCount = static_cast(args.size()); - Vector arguments(argumentCount); - for (int i = 0; i < argumentCount; i++) - arguments[i] = toRef(args[i]); - - JSLock::DropAllLocks dropAllLocks; - return toJS(m_callback(ctx, thisRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot()))); - } - - return toJS(JSObjectMake(ctx, m_class, 0)); + constructData.native.function = APICallbackFunction::construct; + return ConstructTypeHost; } -} // namespace KJS +} // namespace JSC