1/* 2 This file is part of the WebKit open source project. 3 This file has been generated by generate-bindings.pl. DO NOT MODIFY! 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Library General Public 7 License as published by the Free Software Foundation; either 8 version 2 of the License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Library General Public License for more details. 14 15 You should have received a copy of the GNU Library General Public License 16 along with this library; see the file COPYING.LIB. If not, write to 17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 Boston, MA 02110-1301, USA. 19*/ 20 21#include "config.h" 22 23#if ENABLE(DATABASE) 24 25#include "JSTestCallback.h" 26 27#include "JSClass1.h" 28#include "JSClass2.h" 29#include "JSDOMStringList.h" 30#include "ScriptExecutionContext.h" 31#include <runtime/JSLock.h> 32#include <wtf/MainThread.h> 33 34using namespace JSC; 35 36namespace WebCore { 37 38JSTestCallback::JSTestCallback(JSObject* callback, JSDOMGlobalObject* globalObject) 39 : ActiveDOMCallback(globalObject->scriptExecutionContext()) 40 , m_data(new JSCallbackData(callback, globalObject)) 41{ 42} 43 44JSTestCallback::~JSTestCallback() 45{ 46 ScriptExecutionContext* context = scriptExecutionContext(); 47 // When the context is destroyed, all tasks with a reference to a callback 48 // should be deleted. So if the context is 0, we are on the context thread. 49 if (!context || context->isContextThread()) 50 delete m_data; 51 else 52 context->postTask(DeleteCallbackDataTask::create(m_data)); 53#ifndef NDEBUG 54 m_data = 0; 55#endif 56} 57 58// Functions 59 60bool JSTestCallback::callbackWithNoParam() 61{ 62 if (!canInvokeCallback()) 63 return true; 64 65 RefPtr<JSTestCallback> protect(this); 66 67 JSLock lock(SilenceAssertionsOnly); 68 69 ExecState* exec = m_data->globalObject()->globalExec(); 70 MarkedArgumentBuffer args; 71 72 bool raisedException = false; 73 m_data->invokeCallback(args, &raisedException); 74 return !raisedException; 75} 76 77bool JSTestCallback::callbackWithClass1Param(Class1* class1Param) 78{ 79 if (!canInvokeCallback()) 80 return true; 81 82 RefPtr<JSTestCallback> protect(this); 83 84 JSLock lock(SilenceAssertionsOnly); 85 86 ExecState* exec = m_data->globalObject()->globalExec(); 87 MarkedArgumentBuffer args; 88 args.append(toJS(exec, class1Param)); 89 90 bool raisedException = false; 91 m_data->invokeCallback(args, &raisedException); 92 return !raisedException; 93} 94 95bool JSTestCallback::callbackWithClass2Param(Class2* class2Param, const String& strArg) 96{ 97 if (!canInvokeCallback()) 98 return true; 99 100 RefPtr<JSTestCallback> protect(this); 101 102 JSLock lock(SilenceAssertionsOnly); 103 104 ExecState* exec = m_data->globalObject()->globalExec(); 105 MarkedArgumentBuffer args; 106 args.append(toJS(exec, class2Param)); 107 args.append(jsString(exec, strArg)); 108 109 bool raisedException = false; 110 m_data->invokeCallback(args, &raisedException); 111 return !raisedException; 112} 113 114bool JSTestCallback::callbackWithStringList(DOMStringList* listParam) 115{ 116 if (!canInvokeCallback()) 117 return true; 118 119 RefPtr<JSTestCallback> protect(this); 120 121 JSLock lock(SilenceAssertionsOnly); 122 123 ExecState* exec = m_data->globalObject()->globalExec(); 124 MarkedArgumentBuffer args; 125 args.append(toJS(exec, listParam)); 126 127 bool raisedException = false; 128 m_data->invokeCallback(args, &raisedException); 129 return !raisedException; 130} 131 132} 133 134#endif // ENABLE(DATABASE) 135