| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions are | |
| 6 * met: | |
| 7 * | |
| 8 * * Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * * Redistributions in binary form must reproduce the above | |
| 11 * copyright notice, this list of conditions and the following disclaimer | |
| 12 * in the documentation and/or other materials provided with the | |
| 13 * distribution. | |
| 14 * * Neither the name of Google Inc. nor the names of its | |
| 15 * contributors may be used to endorse or promote products derived from | |
| 16 * this software without specific prior written permission. | |
| 17 * | |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 29 */ | |
| 30 | |
| 31 // This file has been auto-generated by code_generator_v8.pm. DO NOT MODIFY! | |
| 32 | |
| 33 #include "config.h" | |
| 34 #include "V8TestCallback.h" | |
| 35 | |
| 36 #include "V8TestInterfaceEmpty.h" | |
| 37 #include "bindings/v8/V8Binding.h" | |
| 38 #include "bindings/v8/V8Callback.h" | |
| 39 #include "core/dom/ExecutionContext.h" | |
| 40 #include "wtf/Assertions.h" | |
| 41 #include "wtf/GetPtr.h" | |
| 42 #include "wtf/RefPtr.h" | |
| 43 namespace WebCore { | |
| 44 | |
| 45 V8TestCallback::V8TestCallback(v8::Handle<v8::Function> callback, ExecutionConte
xt* context) | |
| 46 : ActiveDOMCallback(context) | |
| 47 , m_callback(toIsolate(context), callback) | |
| 48 , m_world(DOMWrapperWorld::current()) | |
| 49 { | |
| 50 } | |
| 51 | |
| 52 V8TestCallback::~V8TestCallback() | |
| 53 { | |
| 54 } | |
| 55 | |
| 56 bool V8TestCallback::callbackWithNoArg() | |
| 57 { | |
| 58 if (!canInvokeCallback()) | |
| 59 return true; | |
| 60 | |
| 61 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | |
| 62 v8::HandleScope handleScope(isolate); | |
| 63 | |
| 64 v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.
get()); | |
| 65 if (v8Context.IsEmpty()) | |
| 66 return true; | |
| 67 | |
| 68 v8::Context::Scope scope(v8Context); | |
| 69 v8::Handle<v8::Value> *argv = 0; | |
| 70 | |
| 71 return invokeCallback(m_callback.newLocal(isolate), 0, argv, executionContex
t(), isolate); | |
| 72 } | |
| 73 | |
| 74 bool V8TestCallback::callbackWithTestInterfaceEmptyArg(TestInterfaceEmpty* class
1Arg) | |
| 75 { | |
| 76 if (!canInvokeCallback()) | |
| 77 return true; | |
| 78 | |
| 79 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | |
| 80 v8::HandleScope handleScope(isolate); | |
| 81 | |
| 82 v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.
get()); | |
| 83 if (v8Context.IsEmpty()) | |
| 84 return true; | |
| 85 | |
| 86 v8::Context::Scope scope(v8Context); | |
| 87 v8::Handle<v8::Value> class1ArgHandle = toV8(class1Arg, v8::Handle<v8::Objec
t>(), isolate); | |
| 88 if (class1ArgHandle.IsEmpty()) { | |
| 89 if (!isScriptControllerTerminating()) | |
| 90 CRASH(); | |
| 91 return true; | |
| 92 } | |
| 93 v8::Handle<v8::Value> argv[] = { class1ArgHandle }; | |
| 94 | |
| 95 return invokeCallback(m_callback.newLocal(isolate), 1, argv, executionContex
t(), isolate); | |
| 96 } | |
| 97 | |
| 98 bool V8TestCallback::callbackWithTestInterfaceEmptyArg(TestInterfaceEmpty* class
2Arg, const String& strArg) | |
| 99 { | |
| 100 if (!canInvokeCallback()) | |
| 101 return true; | |
| 102 | |
| 103 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | |
| 104 v8::HandleScope handleScope(isolate); | |
| 105 | |
| 106 v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.
get()); | |
| 107 if (v8Context.IsEmpty()) | |
| 108 return true; | |
| 109 | |
| 110 v8::Context::Scope scope(v8Context); | |
| 111 v8::Handle<v8::Value> class2ArgHandle = toV8(class2Arg, v8::Handle<v8::Objec
t>(), isolate); | |
| 112 if (class2ArgHandle.IsEmpty()) { | |
| 113 if (!isScriptControllerTerminating()) | |
| 114 CRASH(); | |
| 115 return true; | |
| 116 } | |
| 117 v8::Handle<v8::Value> strArgHandle = v8String(isolate, strArg); | |
| 118 if (strArgHandle.IsEmpty()) { | |
| 119 if (!isScriptControllerTerminating()) | |
| 120 CRASH(); | |
| 121 return true; | |
| 122 } | |
| 123 v8::Handle<v8::Value> argv[] = { class2ArgHandle, strArgHandle }; | |
| 124 | |
| 125 return invokeCallback(m_callback.newLocal(isolate), 2, argv, executionContex
t(), isolate); | |
| 126 } | |
| 127 | |
| 128 bool V8TestCallback::callbackWithBooleanArg(bool boolArg) | |
| 129 { | |
| 130 if (!canInvokeCallback()) | |
| 131 return true; | |
| 132 | |
| 133 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | |
| 134 v8::HandleScope handleScope(isolate); | |
| 135 | |
| 136 v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.
get()); | |
| 137 if (v8Context.IsEmpty()) | |
| 138 return true; | |
| 139 | |
| 140 v8::Context::Scope scope(v8Context); | |
| 141 v8::Handle<v8::Value> boolArgHandle = v8Boolean(boolArg, isolate); | |
| 142 if (boolArgHandle.IsEmpty()) { | |
| 143 if (!isScriptControllerTerminating()) | |
| 144 CRASH(); | |
| 145 return true; | |
| 146 } | |
| 147 v8::Handle<v8::Value> argv[] = { boolArgHandle }; | |
| 148 | |
| 149 return invokeCallback(m_callback.newLocal(isolate), 1, argv, executionContex
t(), isolate); | |
| 150 } | |
| 151 | |
| 152 bool V8TestCallback::callbackWithSequenceArg(const Vector<RefPtr<TestInterfaceEm
pty> >& sequenceArg) | |
| 153 { | |
| 154 if (!canInvokeCallback()) | |
| 155 return true; | |
| 156 | |
| 157 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | |
| 158 v8::HandleScope handleScope(isolate); | |
| 159 | |
| 160 v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.
get()); | |
| 161 if (v8Context.IsEmpty()) | |
| 162 return true; | |
| 163 | |
| 164 v8::Context::Scope scope(v8Context); | |
| 165 v8::Handle<v8::Value> sequenceArgHandle = v8Array(sequenceArg, isolate); | |
| 166 if (sequenceArgHandle.IsEmpty()) { | |
| 167 if (!isScriptControllerTerminating()) | |
| 168 CRASH(); | |
| 169 return true; | |
| 170 } | |
| 171 v8::Handle<v8::Value> argv[] = { sequenceArgHandle }; | |
| 172 | |
| 173 return invokeCallback(m_callback.newLocal(isolate), 1, argv, executionContex
t(), isolate); | |
| 174 } | |
| 175 | |
| 176 bool V8TestCallback::callbackWithFloatArg(float floatArg) | |
| 177 { | |
| 178 if (!canInvokeCallback()) | |
| 179 return true; | |
| 180 | |
| 181 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | |
| 182 v8::HandleScope handleScope(isolate); | |
| 183 | |
| 184 v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.
get()); | |
| 185 if (v8Context.IsEmpty()) | |
| 186 return true; | |
| 187 | |
| 188 v8::Context::Scope scope(v8Context); | |
| 189 v8::Handle<v8::Value> floatArgHandle = v8::Number::New(isolate, floatArg); | |
| 190 if (floatArgHandle.IsEmpty()) { | |
| 191 if (!isScriptControllerTerminating()) | |
| 192 CRASH(); | |
| 193 return true; | |
| 194 } | |
| 195 v8::Handle<v8::Value> argv[] = { floatArgHandle }; | |
| 196 | |
| 197 return invokeCallback(m_callback.newLocal(isolate), 1, argv, executionContex
t(), isolate); | |
| 198 } | |
| 199 | |
| 200 bool V8TestCallback::callbackWithThisArg(ScriptValue thisValue, int arg) | |
| 201 { | |
| 202 if (!canInvokeCallback()) | |
| 203 return true; | |
| 204 | |
| 205 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | |
| 206 v8::HandleScope handleScope(isolate); | |
| 207 | |
| 208 v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.
get()); | |
| 209 if (v8Context.IsEmpty()) | |
| 210 return true; | |
| 211 | |
| 212 v8::Context::Scope scope(v8Context); | |
| 213 v8::Handle<v8::Value> thisHandle = thisValue.v8Value(); | |
| 214 if (thisHandle.IsEmpty()) { | |
| 215 if (!isScriptControllerTerminating()) | |
| 216 CRASH(); | |
| 217 return true; | |
| 218 } | |
| 219 ASSERT(thisHandle->IsObject()); | |
| 220 v8::Handle<v8::Value> argHandle = v8::Integer::New(isolate, arg); | |
| 221 if (argHandle.IsEmpty()) { | |
| 222 if (!isScriptControllerTerminating()) | |
| 223 CRASH(); | |
| 224 return true; | |
| 225 } | |
| 226 v8::Handle<v8::Value> argv[] = { argHandle }; | |
| 227 | |
| 228 return invokeCallback(m_callback.newLocal(isolate), v8::Handle<v8::Object>::
Cast(thisHandle), 1, argv, executionContext(), isolate); | |
| 229 } | |
| 230 | |
| 231 void V8TestCallback::callbackWithVoidReturnValue() | |
| 232 { | |
| 233 if (!canInvokeCallback()) | |
| 234 return; | |
| 235 | |
| 236 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | |
| 237 v8::HandleScope handleScope(isolate); | |
| 238 | |
| 239 v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.
get()); | |
| 240 if (v8Context.IsEmpty()) | |
| 241 return; | |
| 242 | |
| 243 v8::Context::Scope scope(v8Context); | |
| 244 v8::Handle<v8::Value> *argv = 0; | |
| 245 | |
| 246 invokeCallback(m_callback.newLocal(isolate), 0, argv, executionContext(), is
olate); | |
| 247 } | |
| 248 | |
| 249 } // namespace WebCore | |
| OLD | NEW |