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(SQL_DATABASE)
24
25#include "JSTestCallback.h"
26
27#include "JSDOMStringList.h"
28#include "JSTestNode.h"
29#include "ScriptExecutionContext.h"
30#include "SerializedScriptValue.h"
31#include <runtime/JSLock.h>
32
33using namespace JSC;
34
35namespace WebCore {
36
37JSTestCallback::JSTestCallback(JSObject* callback, JSDOMGlobalObject* globalObject)
38    : TestCallback()
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(m_data));
53#ifndef NDEBUG
54    m_data = 0;
55#endif
56}
57
58
59// Functions
60
61bool JSTestCallback::callbackWithNoParam()
62{
63    if (!canInvokeCallback())
64        return true;
65
66    Ref<JSTestCallback> protect(*this);
67
68    JSLockHolder lock(m_data->globalObject()->vm());
69
70    MarkedArgumentBuffer args;
71
72    bool raisedException = false;
73    m_data->invokeCallback(args, &raisedException);
74    return !raisedException;
75}
76
77bool JSTestCallback::callbackWithArrayParam(RefPtr<Float32Array> arrayParam)
78{
79    if (!canInvokeCallback())
80        return true;
81
82    Ref<JSTestCallback> protect(*this);
83
84    JSLockHolder lock(m_data->globalObject()->vm());
85
86    ExecState* exec = m_data->globalObject()->globalExec();
87    MarkedArgumentBuffer args;
88    args.append(toJS(exec, m_data->globalObject(), arrayParam));
89
90    bool raisedException = false;
91    m_data->invokeCallback(args, &raisedException);
92    return !raisedException;
93}
94
95bool JSTestCallback::callbackWithSerializedScriptValueParam(PassRefPtr<SerializedScriptValue> srzParam, const String& strArg)
96{
97    if (!canInvokeCallback())
98        return true;
99
100    Ref<JSTestCallback> protect(*this);
101
102    JSLockHolder lock(m_data->globalObject()->vm());
103
104    ExecState* exec = m_data->globalObject()->globalExec();
105    MarkedArgumentBuffer args;
106    args.append(srzParam ? srzParam->deserialize(exec, m_data->globalObject(), 0) : jsNull());
107    args.append(jsStringWithCache(exec, strArg));
108
109    bool raisedException = false;
110    m_data->invokeCallback(args, &raisedException);
111    return !raisedException;
112}
113
114bool JSTestCallback::callbackWithStringList(PassRefPtr<DOMStringList> listParam)
115{
116    if (!canInvokeCallback())
117        return true;
118
119    Ref<JSTestCallback> protect(*this);
120
121    JSLockHolder lock(m_data->globalObject()->vm());
122
123    ExecState* exec = m_data->globalObject()->globalExec();
124    MarkedArgumentBuffer args;
125    args.append(toJS(exec, m_data->globalObject(), listParam));
126
127    bool raisedException = false;
128    m_data->invokeCallback(args, &raisedException);
129    return !raisedException;
130}
131
132bool JSTestCallback::callbackWithBoolean(bool boolParam)
133{
134    if (!canInvokeCallback())
135        return true;
136
137    Ref<JSTestCallback> protect(*this);
138
139    JSLockHolder lock(m_data->globalObject()->vm());
140
141    ExecState* exec = m_data->globalObject()->globalExec();
142    MarkedArgumentBuffer args;
143    args.append(jsBoolean(boolParam));
144
145    bool raisedException = false;
146    m_data->invokeCallback(args, &raisedException);
147    return !raisedException;
148}
149
150bool JSTestCallback::callbackRequiresThisToPass(int longParam, TestNode* testNodeParam)
151{
152    if (!canInvokeCallback())
153        return true;
154
155    Ref<JSTestCallback> protect(*this);
156
157    JSLockHolder lock(m_data->globalObject()->vm());
158
159    ExecState* exec = m_data->globalObject()->globalExec();
160    MarkedArgumentBuffer args;
161    args.append(toJS(exec, m_data->globalObject(), longParam));
162    args.append(toJS(exec, m_data->globalObject(), testNodeParam));
163
164    bool raisedException = false;
165    m_data->invokeCallback(args, &raisedException);
166    return !raisedException;
167}
168
169}
170
171#endif // ENABLE(SQL_DATABASE)
172