Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 1 | /* |
| 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) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 24 | #include "V8DOMStringList.h" |
Torne (Richard Coles) | e524955 | 2013-05-15 11:35:13 +0100 | [diff] [blame] | 25 | #include "V8TestObject.h" |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 26 | #include "bindings/v8/V8Binding.h" |
| 27 | #include "bindings/v8/V8Callback.h" |
| 28 | #include "core/dom/ScriptExecutionContext.h" |
Torne (Richard Coles) | 81a5157 | 2013-05-13 16:52:28 +0100 | [diff] [blame] | 29 | #include "wtf/Assertions.h" |
| 30 | #include "wtf/GetPtr.h" |
Torne (Richard Coles) | 81a5157 | 2013-05-13 16:52:28 +0100 | [diff] [blame] | 31 | #include "wtf/RefPtr.h" |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 32 | namespace WebCore { |
| 33 | |
| 34 | V8TestCallback::V8TestCallback(v8::Handle<v8::Object> callback, ScriptExecutionContext* context) |
| 35 | : ActiveDOMCallback(context) |
| 36 | , m_callback(callback) |
| 37 | , m_world(DOMWrapperWorld::current()) |
| 38 | { |
| 39 | } |
| 40 | |
| 41 | V8TestCallback::~V8TestCallback() |
| 42 | { |
| 43 | } |
| 44 | |
| 45 | // Functions |
| 46 | |
| 47 | bool V8TestCallback::callbackWithNoParam() |
| 48 | { |
| 49 | if (!canInvokeCallback()) |
| 50 | return true; |
| 51 | |
Ben Murdoch | 591b958 | 2013-07-10 11:41:44 +0100 | [diff] [blame] | 52 | v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 53 | v8::HandleScope handleScope(isolate); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 54 | |
| 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 Murdoch | 591b958 | 2013-07-10 11:41:44 +0100 | [diff] [blame] | 65 | return !invokeCallback(m_callback.newLocal(isolate), 0, argv, callbackReturnValue, scriptExecutionContext()); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 66 | } |
| 67 | |
Torne (Richard Coles) | e524955 | 2013-05-15 11:35:13 +0100 | [diff] [blame] | 68 | bool V8TestCallback::callbackWithTestObjectParam(TestObj* class1Param) |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 69 | { |
| 70 | if (!canInvokeCallback()) |
| 71 | return true; |
| 72 | |
Ben Murdoch | 591b958 | 2013-07-10 11:41:44 +0100 | [diff] [blame] | 73 | v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 74 | v8::HandleScope handleScope(isolate); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 75 | |
| 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 Murdoch | 591b958 | 2013-07-10 11:41:44 +0100 | [diff] [blame] | 82 | v8::Handle<v8::Value> class1ParamHandle = toV8(class1Param, v8::Handle<v8::Object>(), isolate); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 83 | 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 Murdoch | 591b958 | 2013-07-10 11:41:44 +0100 | [diff] [blame] | 94 | return !invokeCallback(m_callback.newLocal(isolate), 1, argv, callbackReturnValue, scriptExecutionContext()); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 95 | } |
| 96 | |
Torne (Richard Coles) | e524955 | 2013-05-15 11:35:13 +0100 | [diff] [blame] | 97 | bool V8TestCallback::callbackWithTestObjectParam(TestObj* class2Param, const String& strArg) |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 98 | { |
| 99 | if (!canInvokeCallback()) |
| 100 | return true; |
| 101 | |
Ben Murdoch | 591b958 | 2013-07-10 11:41:44 +0100 | [diff] [blame] | 102 | v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 103 | v8::HandleScope handleScope(isolate); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 104 | |
| 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 Murdoch | 591b958 | 2013-07-10 11:41:44 +0100 | [diff] [blame] | 111 | v8::Handle<v8::Value> class2ParamHandle = toV8(class2Param, v8::Handle<v8::Object>(), isolate); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 112 | if (class2ParamHandle.IsEmpty()) { |
| 113 | if (!isScriptControllerTerminating()) |
| 114 | CRASH(); |
| 115 | return true; |
| 116 | } |
Ben Murdoch | 591b958 | 2013-07-10 11:41:44 +0100 | [diff] [blame] | 117 | v8::Handle<v8::Value> strArgHandle = v8String(strArg, isolate); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 118 | 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 Murdoch | 591b958 | 2013-07-10 11:41:44 +0100 | [diff] [blame] | 130 | return !invokeCallback(m_callback.newLocal(isolate), 2, argv, callbackReturnValue, scriptExecutionContext()); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | bool V8TestCallback::callbackWithStringList(RefPtr<DOMStringList> listParam) |
| 134 | { |
| 135 | if (!canInvokeCallback()) |
| 136 | return true; |
| 137 | |
Ben Murdoch | 591b958 | 2013-07-10 11:41:44 +0100 | [diff] [blame] | 138 | v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 139 | v8::HandleScope handleScope(isolate); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 140 | |
| 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 Murdoch | 591b958 | 2013-07-10 11:41:44 +0100 | [diff] [blame] | 147 | v8::Handle<v8::Value> listParamHandle = toV8(listParam, v8::Handle<v8::Object>(), isolate); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 148 | 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 Murdoch | 591b958 | 2013-07-10 11:41:44 +0100 | [diff] [blame] | 159 | return !invokeCallback(m_callback.newLocal(isolate), 1, argv, callbackReturnValue, scriptExecutionContext()); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | bool V8TestCallback::callbackWithBoolean(bool boolParam) |
| 163 | { |
| 164 | if (!canInvokeCallback()) |
| 165 | return true; |
| 166 | |
Ben Murdoch | 591b958 | 2013-07-10 11:41:44 +0100 | [diff] [blame] | 167 | v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 168 | v8::HandleScope handleScope(isolate); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 169 | |
| 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 Murdoch | 591b958 | 2013-07-10 11:41:44 +0100 | [diff] [blame] | 176 | v8::Handle<v8::Value> boolParamHandle = v8Boolean(boolParam, isolate); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 177 | 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 Murdoch | 591b958 | 2013-07-10 11:41:44 +0100 | [diff] [blame] | 188 | return !invokeCallback(m_callback.newLocal(isolate), 1, argv, callbackReturnValue, scriptExecutionContext()); |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 189 | } |
| 190 | |
Torne (Richard Coles) | 521d96e | 2013-06-19 11:58:24 +0100 | [diff] [blame] | 191 | bool V8TestCallback::callbackWithSequence(Vector<RefPtr<TestObj> > sequenceParam) |
| 192 | { |
| 193 | if (!canInvokeCallback()) |
| 194 | return true; |
| 195 | |
Ben Murdoch | 591b958 | 2013-07-10 11:41:44 +0100 | [diff] [blame] | 196 | v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 197 | v8::HandleScope handleScope(isolate); |
Torne (Richard Coles) | 521d96e | 2013-06-19 11:58:24 +0100 | [diff] [blame] | 198 | |
| 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 Murdoch | 591b958 | 2013-07-10 11:41:44 +0100 | [diff] [blame] | 205 | v8::Handle<v8::Value> sequenceParamHandle = v8Array(sequenceParam, isolate); |
Torne (Richard Coles) | 521d96e | 2013-06-19 11:58:24 +0100 | [diff] [blame] | 206 | 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 Murdoch | 591b958 | 2013-07-10 11:41:44 +0100 | [diff] [blame] | 217 | return !invokeCallback(m_callback.newLocal(isolate), 1, argv, callbackReturnValue, scriptExecutionContext()); |
| 218 | } |
| 219 | |
Ben Murdoch | e69819b | 2013-07-17 14:56:49 +0100 | [diff] [blame^] | 220 | bool V8TestCallback::callbackWithThisArg(ScriptValue thisValue, int param) |
Ben Murdoch | 591b958 | 2013-07-10 11:41:44 +0100 | [diff] [blame] | 221 | { |
| 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 Murdoch | 591b958 | 2013-07-10 11:41:44 +0100 | [diff] [blame] | 234 | 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 Murdoch | e69819b | 2013-07-17 14:56:49 +0100 | [diff] [blame^] | 241 | v8::Handle<v8::Value> paramHandle = v8::Integer::New(param, isolate); |
| 242 | if (paramHandle.IsEmpty()) { |
| 243 | if (!isScriptControllerTerminating()) |
| 244 | CRASH(); |
| 245 | return true; |
| 246 | } |
Ben Murdoch | 591b958 | 2013-07-10 11:41:44 +0100 | [diff] [blame] | 247 | |
| 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) | 521d96e | 2013-06-19 11:58:24 +0100 | [diff] [blame] | 254 | } |
| 255 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 256 | } // namespace WebCore |
| 257 | |