Home | History | Annotate | Download | only in results
      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.
      4 
      5 // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY!
      6 
      7 #include "config.h"
      8 #include "V8TestCallbackInterface.h"
      9 
     10 #include "bindings/tests/v8/V8TestInterfaceEmpty.h"
     11 #include "bindings/tests/v8/V8TestInterfaceWillBeGarbageCollected.h"
     12 #include "bindings/v8/V8Binding.h"
     13 #include "bindings/v8/V8Callback.h"
     14 #include "core/dom/ExecutionContext.h"
     15 #include "wtf/Assertions.h"
     16 #include "wtf/GetPtr.h"
     17 #include "wtf/RefPtr.h"
     18 
     19 namespace WebCore {
     20 
     21 V8TestCallbackInterface::V8TestCallbackInterface(v8::Handle<v8::Function> callback, ScriptState* scriptState)
     22     : ActiveDOMCallback(scriptState->executionContext())
     23     , m_scriptState(scriptState)
     24 {
     25     m_callback.set(scriptState->isolate(), callback);
     26 }
     27 
     28 V8TestCallbackInterface::~V8TestCallbackInterface()
     29 {
     30 }
     31 
     32 void V8TestCallbackInterface::voidMethod()
     33 {
     34     if (!canInvokeCallback())
     35         return;
     36 
     37     v8::Isolate* isolate = m_scriptState->isolate();
     38     if (m_scriptState->contextIsEmpty())
     39         return;
     40 
     41     ScriptState::Scope scope(m_scriptState.get());
     42     v8::Handle<v8::Value> *argv = 0;
     43 
     44     invokeCallback(m_scriptState.get(), m_callback.newLocal(isolate), 0, argv);
     45 }
     46 
     47 bool V8TestCallbackInterface::booleanMethod()
     48 {
     49     if (!canInvokeCallback())
     50         return true;
     51 
     52     v8::Isolate* isolate = m_scriptState->isolate();
     53     if (m_scriptState->contextIsEmpty())
     54         return true;
     55 
     56     ScriptState::Scope scope(m_scriptState.get());
     57     v8::Handle<v8::Value> *argv = 0;
     58 
     59     return invokeCallback(m_scriptState.get(), m_callback.newLocal(isolate), 0, argv);
     60 }
     61 
     62 void V8TestCallbackInterface::voidMethodBooleanArg(bool boolArg)
     63 {
     64     if (!canInvokeCallback())
     65         return;
     66 
     67     v8::Isolate* isolate = m_scriptState->isolate();
     68     if (m_scriptState->contextIsEmpty())
     69         return;
     70 
     71     ScriptState::Scope scope(m_scriptState.get());
     72     v8::Handle<v8::Value> boolArgHandle = v8Boolean(boolArg, isolate);
     73     if (boolArgHandle.IsEmpty()) {
     74         if (!isScriptControllerTerminating())
     75             CRASH();
     76         return;
     77     }
     78     v8::Handle<v8::Value> argv[] = { boolArgHandle };
     79 
     80     invokeCallback(m_scriptState.get(), m_callback.newLocal(isolate), 1, argv);
     81 }
     82 
     83 void V8TestCallbackInterface::voidMethodSequenceArg(const Vector<RefPtr<TestInterfaceEmpty> >& sequenceArg)
     84 {
     85     if (!canInvokeCallback())
     86         return;
     87 
     88     v8::Isolate* isolate = m_scriptState->isolate();
     89     if (m_scriptState->contextIsEmpty())
     90         return;
     91 
     92     ScriptState::Scope scope(m_scriptState.get());
     93     v8::Handle<v8::Value> sequenceArgHandle = v8Array(sequenceArg, m_scriptState->context()->Global(), isolate);
     94     if (sequenceArgHandle.IsEmpty()) {
     95         if (!isScriptControllerTerminating())
     96             CRASH();
     97         return;
     98     }
     99     v8::Handle<v8::Value> argv[] = { sequenceArgHandle };
    100 
    101     invokeCallback(m_scriptState.get(), m_callback.newLocal(isolate), 1, argv);
    102 }
    103 
    104 void V8TestCallbackInterface::voidMethodFloatArg(float floatArg)
    105 {
    106     if (!canInvokeCallback())
    107         return;
    108 
    109     v8::Isolate* isolate = m_scriptState->isolate();
    110     if (m_scriptState->contextIsEmpty())
    111         return;
    112 
    113     ScriptState::Scope scope(m_scriptState.get());
    114     v8::Handle<v8::Value> floatArgHandle = v8::Number::New(isolate, floatArg);
    115     if (floatArgHandle.IsEmpty()) {
    116         if (!isScriptControllerTerminating())
    117             CRASH();
    118         return;
    119     }
    120     v8::Handle<v8::Value> argv[] = { floatArgHandle };
    121 
    122     invokeCallback(m_scriptState.get(), m_callback.newLocal(isolate), 1, argv);
    123 }
    124 
    125 void V8TestCallbackInterface::voidMethodTestInterfaceEmptyArg(TestInterfaceEmpty* testInterfaceEmptyArg)
    126 {
    127     if (!canInvokeCallback())
    128         return;
    129 
    130     v8::Isolate* isolate = m_scriptState->isolate();
    131     if (m_scriptState->contextIsEmpty())
    132         return;
    133 
    134     ScriptState::Scope scope(m_scriptState.get());
    135     v8::Handle<v8::Value> testInterfaceEmptyArgHandle = toV8(testInterfaceEmptyArg, m_scriptState->context()->Global(), isolate);
    136     if (testInterfaceEmptyArgHandle.IsEmpty()) {
    137         if (!isScriptControllerTerminating())
    138             CRASH();
    139         return;
    140     }
    141     v8::Handle<v8::Value> argv[] = { testInterfaceEmptyArgHandle };
    142 
    143     invokeCallback(m_scriptState.get(), m_callback.newLocal(isolate), 1, argv);
    144 }
    145 
    146 void V8TestCallbackInterface::voidMethodTestInterfaceEmptyStringArg(TestInterfaceEmpty* testInterfaceEmptyArg, const String& stringArg)
    147 {
    148     if (!canInvokeCallback())
    149         return;
    150 
    151     v8::Isolate* isolate = m_scriptState->isolate();
    152     if (m_scriptState->contextIsEmpty())
    153         return;
    154 
    155     ScriptState::Scope scope(m_scriptState.get());
    156     v8::Handle<v8::Value> testInterfaceEmptyArgHandle = toV8(testInterfaceEmptyArg, m_scriptState->context()->Global(), isolate);
    157     if (testInterfaceEmptyArgHandle.IsEmpty()) {
    158         if (!isScriptControllerTerminating())
    159             CRASH();
    160         return;
    161     }
    162     v8::Handle<v8::Value> stringArgHandle = v8String(isolate, stringArg);
    163     if (stringArgHandle.IsEmpty()) {
    164         if (!isScriptControllerTerminating())
    165             CRASH();
    166         return;
    167     }
    168     v8::Handle<v8::Value> argv[] = { testInterfaceEmptyArgHandle, stringArgHandle };
    169 
    170     invokeCallback(m_scriptState.get(), m_callback.newLocal(isolate), 2, argv);
    171 }
    172 
    173 void V8TestCallbackInterface::callbackWithThisValueVoidMethodStringArg(ScriptValue thisValue, const String& stringArg)
    174 {
    175     if (!canInvokeCallback())
    176         return;
    177 
    178     v8::Isolate* isolate = m_scriptState->isolate();
    179     if (m_scriptState->contextIsEmpty())
    180         return;
    181 
    182     ScriptState::Scope scope(m_scriptState.get());
    183     v8::Handle<v8::Value> thisHandle = thisValue.v8Value();
    184     if (thisHandle.IsEmpty()) {
    185         if (!isScriptControllerTerminating())
    186             CRASH();
    187         return;
    188     }
    189     v8::Handle<v8::Value> stringArgHandle = v8String(isolate, stringArg);
    190     if (stringArgHandle.IsEmpty()) {
    191         if (!isScriptControllerTerminating())
    192             CRASH();
    193         return;
    194     }
    195     v8::Handle<v8::Value> argv[] = { stringArgHandle };
    196 
    197     invokeCallback(m_scriptState.get(), m_callback.newLocal(isolate), thisHandle, 1, argv);
    198 }
    199 
    200 void V8TestCallbackInterface::voidMethodWillBeGarbageCollectedSequenceArg(const WillBeHeapVector<RefPtrWillBeMember<TestInterfaceWillBeGarbageCollected> >& sequenceArg)
    201 {
    202     if (!canInvokeCallback())
    203         return;
    204 
    205     v8::Isolate* isolate = m_scriptState->isolate();
    206     if (m_scriptState->contextIsEmpty())
    207         return;
    208 
    209     ScriptState::Scope scope(m_scriptState.get());
    210     v8::Handle<v8::Value> sequenceArgHandle = v8Array(sequenceArg, m_scriptState->context()->Global(), isolate);
    211     if (sequenceArgHandle.IsEmpty()) {
    212         if (!isScriptControllerTerminating())
    213             CRASH();
    214         return;
    215     }
    216     v8::Handle<v8::Value> argv[] = { sequenceArgHandle };
    217 
    218     invokeCallback(m_scriptState.get(), m_callback.newLocal(isolate), 1, argv);
    219 }
    220 
    221 void V8TestCallbackInterface::voidMethodWillBeGarbageCollectedArrayArg(const WillBeHeapVector<RefPtrWillBeMember<TestInterfaceWillBeGarbageCollected> >& arrayArg)
    222 {
    223     if (!canInvokeCallback())
    224         return;
    225 
    226     v8::Isolate* isolate = m_scriptState->isolate();
    227     if (m_scriptState->contextIsEmpty())
    228         return;
    229 
    230     ScriptState::Scope scope(m_scriptState.get());
    231     v8::Handle<v8::Value> arrayArgHandle = v8Array(arrayArg, m_scriptState->context()->Global(), isolate);
    232     if (arrayArgHandle.IsEmpty()) {
    233         if (!isScriptControllerTerminating())
    234             CRASH();
    235         return;
    236     }
    237     v8::Handle<v8::Value> argv[] = { arrayArgHandle };
    238 
    239     invokeCallback(m_scriptState.get(), m_callback.newLocal(isolate), 1, argv);
    240 }
    241 
    242 } // namespace WebCore
    243