1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY!
8 #include "V8TestCallbackInterface.h"
10 #include "bindings/core/v8/ScriptController.h"
11 #include "bindings/core/v8/V8Binding.h"
12 #include "bindings/tests/v8/V8TestInterfaceEmpty.h"
13 #include "bindings/tests/v8/V8TestInterfaceWillBeGarbageCollected.h"
14 #include "core/dom/ExecutionContext.h"
15 #include "wtf/Assertions.h"
16 #include "wtf/GetPtr.h"
17 #include "wtf/RefPtr.h"
21 V8TestCallbackInterface::V8TestCallbackInterface(v8::Handle<v8::Function> callback, ScriptState* scriptState)
22 : ActiveDOMCallback(scriptState->executionContext())
23 , m_scriptState(scriptState)
25 m_callback.set(scriptState->isolate(), callback);
28 V8TestCallbackInterface::~V8TestCallbackInterface()
32 void V8TestCallbackInterface::voidMethod()
34 if (!canInvokeCallback())
37 if (m_scriptState->contextIsEmpty())
40 ScriptState::Scope scope(m_scriptState.get());
41 v8::Handle<v8::Value> *argv = 0;
43 ScriptController::callFunction(m_scriptState->executionContext(), m_callback.newLocal(m_scriptState->isolate()), m_scriptState->context()->Global(), 0, argv, m_scriptState->isolate());
46 bool V8TestCallbackInterface::booleanMethod()
48 if (!canInvokeCallback())
51 if (m_scriptState->contextIsEmpty())
54 ScriptState::Scope scope(m_scriptState.get());
55 v8::Handle<v8::Value> *argv = 0;
57 v8::TryCatch exceptionCatcher;
58 exceptionCatcher.SetVerbose(true);
59 ScriptController::callFunction(m_scriptState->executionContext(), m_callback.newLocal(m_scriptState->isolate()), m_scriptState->context()->Global(), 0, argv, m_scriptState->isolate());
60 return !exceptionCatcher.HasCaught();
63 void V8TestCallbackInterface::voidMethodBooleanArg(bool boolArg)
65 if (!canInvokeCallback())
68 if (m_scriptState->contextIsEmpty())
71 ScriptState::Scope scope(m_scriptState.get());
72 v8::Handle<v8::Value> boolArgHandle = v8Boolean(boolArg, m_scriptState->isolate());
73 if (boolArgHandle.IsEmpty()) {
74 if (!isScriptControllerTerminating())
78 v8::Handle<v8::Value> argv[] = { boolArgHandle };
80 ScriptController::callFunction(m_scriptState->executionContext(), m_callback.newLocal(m_scriptState->isolate()), m_scriptState->context()->Global(), 1, argv, m_scriptState->isolate());
83 void V8TestCallbackInterface::voidMethodSequenceArg(const Vector<RefPtr<TestInterfaceEmpty> >& sequenceArg)
85 if (!canInvokeCallback())
88 if (m_scriptState->contextIsEmpty())
91 ScriptState::Scope scope(m_scriptState.get());
92 v8::Handle<v8::Value> sequenceArgHandle = v8Array(sequenceArg, m_scriptState->context()->Global(), m_scriptState->isolate());
93 if (sequenceArgHandle.IsEmpty()) {
94 if (!isScriptControllerTerminating())
98 v8::Handle<v8::Value> argv[] = { sequenceArgHandle };
100 ScriptController::callFunction(m_scriptState->executionContext(), m_callback.newLocal(m_scriptState->isolate()), m_scriptState->context()->Global(), 1, argv, m_scriptState->isolate());
103 void V8TestCallbackInterface::voidMethodFloatArg(float floatArg)
105 if (!canInvokeCallback())
108 if (m_scriptState->contextIsEmpty())
111 ScriptState::Scope scope(m_scriptState.get());
112 v8::Handle<v8::Value> floatArgHandle = v8::Number::New(m_scriptState->isolate(), floatArg);
113 if (floatArgHandle.IsEmpty()) {
114 if (!isScriptControllerTerminating())
118 v8::Handle<v8::Value> argv[] = { floatArgHandle };
120 ScriptController::callFunction(m_scriptState->executionContext(), m_callback.newLocal(m_scriptState->isolate()), m_scriptState->context()->Global(), 1, argv, m_scriptState->isolate());
123 void V8TestCallbackInterface::voidMethodTestInterfaceEmptyArg(TestInterfaceEmpty* testInterfaceEmptyArg)
125 if (!canInvokeCallback())
128 if (m_scriptState->contextIsEmpty())
131 ScriptState::Scope scope(m_scriptState.get());
132 v8::Handle<v8::Value> testInterfaceEmptyArgHandle = toV8(testInterfaceEmptyArg, m_scriptState->context()->Global(), m_scriptState->isolate());
133 if (testInterfaceEmptyArgHandle.IsEmpty()) {
134 if (!isScriptControllerTerminating())
138 v8::Handle<v8::Value> argv[] = { testInterfaceEmptyArgHandle };
140 ScriptController::callFunction(m_scriptState->executionContext(), m_callback.newLocal(m_scriptState->isolate()), m_scriptState->context()->Global(), 1, argv, m_scriptState->isolate());
143 void V8TestCallbackInterface::voidMethodTestInterfaceEmptyStringArg(TestInterfaceEmpty* testInterfaceEmptyArg, const String& stringArg)
145 if (!canInvokeCallback())
148 if (m_scriptState->contextIsEmpty())
151 ScriptState::Scope scope(m_scriptState.get());
152 v8::Handle<v8::Value> testInterfaceEmptyArgHandle = toV8(testInterfaceEmptyArg, m_scriptState->context()->Global(), m_scriptState->isolate());
153 if (testInterfaceEmptyArgHandle.IsEmpty()) {
154 if (!isScriptControllerTerminating())
158 v8::Handle<v8::Value> stringArgHandle = v8String(m_scriptState->isolate(), stringArg);
159 if (stringArgHandle.IsEmpty()) {
160 if (!isScriptControllerTerminating())
164 v8::Handle<v8::Value> argv[] = { testInterfaceEmptyArgHandle, stringArgHandle };
166 ScriptController::callFunction(m_scriptState->executionContext(), m_callback.newLocal(m_scriptState->isolate()), m_scriptState->context()->Global(), 2, argv, m_scriptState->isolate());
169 void V8TestCallbackInterface::callbackWithThisValueVoidMethodStringArg(ScriptValue thisValue, const String& stringArg)
171 if (!canInvokeCallback())
174 if (m_scriptState->contextIsEmpty())
177 ScriptState::Scope scope(m_scriptState.get());
178 v8::Handle<v8::Value> thisHandle = thisValue.v8Value();
179 if (thisHandle.IsEmpty()) {
180 if (!isScriptControllerTerminating())
184 v8::Handle<v8::Value> stringArgHandle = v8String(m_scriptState->isolate(), stringArg);
185 if (stringArgHandle.IsEmpty()) {
186 if (!isScriptControllerTerminating())
190 v8::Handle<v8::Value> argv[] = { stringArgHandle };
192 ScriptController::callFunction(m_scriptState->executionContext(), m_callback.newLocal(m_scriptState->isolate()), thisHandle, 1, argv, m_scriptState->isolate());
195 void V8TestCallbackInterface::voidMethodWillBeGarbageCollectedSequenceArg(const WillBeHeapVector<RefPtrWillBeMember<TestInterfaceWillBeGarbageCollected> >& sequenceArg)
197 if (!canInvokeCallback())
200 if (m_scriptState->contextIsEmpty())
203 ScriptState::Scope scope(m_scriptState.get());
204 v8::Handle<v8::Value> sequenceArgHandle = v8Array(sequenceArg, m_scriptState->context()->Global(), m_scriptState->isolate());
205 if (sequenceArgHandle.IsEmpty()) {
206 if (!isScriptControllerTerminating())
210 v8::Handle<v8::Value> argv[] = { sequenceArgHandle };
212 ScriptController::callFunction(m_scriptState->executionContext(), m_callback.newLocal(m_scriptState->isolate()), m_scriptState->context()->Global(), 1, argv, m_scriptState->isolate());
215 void V8TestCallbackInterface::voidMethodWillBeGarbageCollectedArrayArg(const WillBeHeapVector<RefPtrWillBeMember<TestInterfaceWillBeGarbageCollected> >& arrayArg)
217 if (!canInvokeCallback())
220 if (m_scriptState->contextIsEmpty())
223 ScriptState::Scope scope(m_scriptState.get());
224 v8::Handle<v8::Value> arrayArgHandle = v8Array(arrayArg, m_scriptState->context()->Global(), m_scriptState->isolate());
225 if (arrayArgHandle.IsEmpty()) {
226 if (!isScriptControllerTerminating())
230 v8::Handle<v8::Value> argv[] = { arrayArgHandle };
232 ScriptController::callFunction(m_scriptState->executionContext(), m_callback.newLocal(m_scriptState->isolate()), m_scriptState->context()->Global(), 1, argv, m_scriptState->isolate());