blob: c582447391ae77c24173114d45910cae9f764b3c [file] [log] [blame]
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +01001/*
2 This file is part of the Blink open source project.
3 This file has been auto-generated by CodeGeneratorV8.pm. 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., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21#include "config.h"
22#include "V8TestCallback.h"
23
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010024#include "V8DOMStringList.h"
Torne (Richard Coles)e5249552013-05-15 11:35:13 +010025#include "V8TestObject.h"
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010026#include "bindings/v8/V8Binding.h"
27#include "bindings/v8/V8Callback.h"
28#include "core/dom/ScriptExecutionContext.h"
Torne (Richard Coles)81a51572013-05-13 16:52:28 +010029#include "wtf/Assertions.h"
30#include "wtf/GetPtr.h"
Torne (Richard Coles)81a51572013-05-13 16:52:28 +010031#include "wtf/RefPtr.h"
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010032namespace WebCore {
33
34V8TestCallback::V8TestCallback(v8::Handle<v8::Object> callback, ScriptExecutionContext* context)
35 : ActiveDOMCallback(context)
36 , m_callback(callback)
37 , m_world(DOMWrapperWorld::current())
38{
39}
40
41V8TestCallback::~V8TestCallback()
42{
43}
44
45// Functions
46
47bool V8TestCallback::callbackWithNoParam()
48{
49 if (!canInvokeCallback())
50 return true;
51
Ben Murdoch591b9582013-07-10 11:41:44 +010052 v8::Isolate* isolate = v8::Isolate::GetCurrent();
53 v8::HandleScope handleScope(isolate);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010054
55 v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_world.get());
56 if (v8Context.IsEmpty())
57 return true;
58
59 v8::Context::Scope scope(v8Context);
60
61
62 v8::Handle<v8::Value> *argv = 0;
63
64 bool callbackReturnValue = false;
Ben Murdoch591b9582013-07-10 11:41:44 +010065 return !invokeCallback(m_callback.newLocal(isolate), 0, argv, callbackReturnValue, scriptExecutionContext());
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010066}
67
Torne (Richard Coles)e5249552013-05-15 11:35:13 +010068bool V8TestCallback::callbackWithTestObjectParam(TestObj* class1Param)
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010069{
70 if (!canInvokeCallback())
71 return true;
72
Ben Murdoch591b9582013-07-10 11:41:44 +010073 v8::Isolate* isolate = v8::Isolate::GetCurrent();
74 v8::HandleScope handleScope(isolate);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010075
76 v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_world.get());
77 if (v8Context.IsEmpty())
78 return true;
79
80 v8::Context::Scope scope(v8Context);
81
Ben Murdoch591b9582013-07-10 11:41:44 +010082 v8::Handle<v8::Value> class1ParamHandle = toV8(class1Param, v8::Handle<v8::Object>(), isolate);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010083 if (class1ParamHandle.IsEmpty()) {
84 if (!isScriptControllerTerminating())
85 CRASH();
86 return true;
87 }
88
89 v8::Handle<v8::Value> argv[] = {
90 class1ParamHandle
91 };
92
93 bool callbackReturnValue = false;
Ben Murdoch591b9582013-07-10 11:41:44 +010094 return !invokeCallback(m_callback.newLocal(isolate), 1, argv, callbackReturnValue, scriptExecutionContext());
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010095}
96
Torne (Richard Coles)e5249552013-05-15 11:35:13 +010097bool V8TestCallback::callbackWithTestObjectParam(TestObj* class2Param, const String& strArg)
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010098{
99 if (!canInvokeCallback())
100 return true;
101
Ben Murdoch591b9582013-07-10 11:41:44 +0100102 v8::Isolate* isolate = v8::Isolate::GetCurrent();
103 v8::HandleScope handleScope(isolate);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100104
105 v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_world.get());
106 if (v8Context.IsEmpty())
107 return true;
108
109 v8::Context::Scope scope(v8Context);
110
Ben Murdoch591b9582013-07-10 11:41:44 +0100111 v8::Handle<v8::Value> class2ParamHandle = toV8(class2Param, v8::Handle<v8::Object>(), isolate);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100112 if (class2ParamHandle.IsEmpty()) {
113 if (!isScriptControllerTerminating())
114 CRASH();
115 return true;
116 }
Ben Murdoch591b9582013-07-10 11:41:44 +0100117 v8::Handle<v8::Value> strArgHandle = v8String(strArg, isolate);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100118 if (strArgHandle.IsEmpty()) {
119 if (!isScriptControllerTerminating())
120 CRASH();
121 return true;
122 }
123
124 v8::Handle<v8::Value> argv[] = {
125 class2ParamHandle,
126 strArgHandle
127 };
128
129 bool callbackReturnValue = false;
Ben Murdoch591b9582013-07-10 11:41:44 +0100130 return !invokeCallback(m_callback.newLocal(isolate), 2, argv, callbackReturnValue, scriptExecutionContext());
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100131}
132
133bool V8TestCallback::callbackWithStringList(RefPtr<DOMStringList> listParam)
134{
135 if (!canInvokeCallback())
136 return true;
137
Ben Murdoch591b9582013-07-10 11:41:44 +0100138 v8::Isolate* isolate = v8::Isolate::GetCurrent();
139 v8::HandleScope handleScope(isolate);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100140
141 v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_world.get());
142 if (v8Context.IsEmpty())
143 return true;
144
145 v8::Context::Scope scope(v8Context);
146
Ben Murdoch591b9582013-07-10 11:41:44 +0100147 v8::Handle<v8::Value> listParamHandle = toV8(listParam, v8::Handle<v8::Object>(), isolate);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100148 if (listParamHandle.IsEmpty()) {
149 if (!isScriptControllerTerminating())
150 CRASH();
151 return true;
152 }
153
154 v8::Handle<v8::Value> argv[] = {
155 listParamHandle
156 };
157
158 bool callbackReturnValue = false;
Ben Murdoch591b9582013-07-10 11:41:44 +0100159 return !invokeCallback(m_callback.newLocal(isolate), 1, argv, callbackReturnValue, scriptExecutionContext());
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100160}
161
162bool V8TestCallback::callbackWithBoolean(bool boolParam)
163{
164 if (!canInvokeCallback())
165 return true;
166
Ben Murdoch591b9582013-07-10 11:41:44 +0100167 v8::Isolate* isolate = v8::Isolate::GetCurrent();
168 v8::HandleScope handleScope(isolate);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100169
170 v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_world.get());
171 if (v8Context.IsEmpty())
172 return true;
173
174 v8::Context::Scope scope(v8Context);
175
Ben Murdoch591b9582013-07-10 11:41:44 +0100176 v8::Handle<v8::Value> boolParamHandle = v8Boolean(boolParam, isolate);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100177 if (boolParamHandle.IsEmpty()) {
178 if (!isScriptControllerTerminating())
179 CRASH();
180 return true;
181 }
182
183 v8::Handle<v8::Value> argv[] = {
184 boolParamHandle
185 };
186
187 bool callbackReturnValue = false;
Ben Murdoch591b9582013-07-10 11:41:44 +0100188 return !invokeCallback(m_callback.newLocal(isolate), 1, argv, callbackReturnValue, scriptExecutionContext());
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100189}
190
Torne (Richard Coles)521d96e2013-06-19 11:58:24 +0100191bool V8TestCallback::callbackWithSequence(Vector<RefPtr<TestObj> > sequenceParam)
192{
193 if (!canInvokeCallback())
194 return true;
195
Ben Murdoch591b9582013-07-10 11:41:44 +0100196 v8::Isolate* isolate = v8::Isolate::GetCurrent();
197 v8::HandleScope handleScope(isolate);
Torne (Richard Coles)521d96e2013-06-19 11:58:24 +0100198
199 v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_world.get());
200 if (v8Context.IsEmpty())
201 return true;
202
203 v8::Context::Scope scope(v8Context);
204
Ben Murdoch591b9582013-07-10 11:41:44 +0100205 v8::Handle<v8::Value> sequenceParamHandle = v8Array(sequenceParam, isolate);
Torne (Richard Coles)521d96e2013-06-19 11:58:24 +0100206 if (sequenceParamHandle.IsEmpty()) {
207 if (!isScriptControllerTerminating())
208 CRASH();
209 return true;
210 }
211
212 v8::Handle<v8::Value> argv[] = {
213 sequenceParamHandle
214 };
215
216 bool callbackReturnValue = false;
Ben Murdoch591b9582013-07-10 11:41:44 +0100217 return !invokeCallback(m_callback.newLocal(isolate), 1, argv, callbackReturnValue, scriptExecutionContext());
218}
219
Ben Murdoche69819b2013-07-17 14:56:49 +0100220bool V8TestCallback::callbackWithThisArg(ScriptValue thisValue, int param)
Ben Murdoch591b9582013-07-10 11:41:44 +0100221{
222 if (!canInvokeCallback())
223 return true;
224
225 v8::Isolate* isolate = v8::Isolate::GetCurrent();
226 v8::HandleScope handleScope(isolate);
227
228 v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_world.get());
229 if (v8Context.IsEmpty())
230 return true;
231
232 v8::Context::Scope scope(v8Context);
233
Ben Murdoch591b9582013-07-10 11:41:44 +0100234 v8::Handle<v8::Value> thisHandle = thisValue.v8Value();
235 if (thisHandle.IsEmpty()) {
236 if (!isScriptControllerTerminating())
237 CRASH();
238 return true;
239 }
240 ASSERT(thisHandle->isObject());
Ben Murdoche69819b2013-07-17 14:56:49 +0100241 v8::Handle<v8::Value> paramHandle = v8::Integer::New(param, isolate);
242 if (paramHandle.IsEmpty()) {
243 if (!isScriptControllerTerminating())
244 CRASH();
245 return true;
246 }
Ben Murdoch591b9582013-07-10 11:41:44 +0100247
248 v8::Handle<v8::Value> argv[] = {
249 paramHandle
250 };
251
252 bool callbackReturnValue = false;
253 return !invokeCallback(m_callback.newLocal(isolate), v8::Handle<v8::Object>::Cast(thisHandle), 1, argv, callbackReturnValue, scriptExecutionContext());
Torne (Richard Coles)521d96e2013-06-19 11:58:24 +0100254}
255
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100256} // namespace WebCore
257