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}}. DO NOT MODIFY!
8 {% filter conditional(conditional_string) %}
9 #include "{{v8_class}}.h"
11 {% for filename in cpp_includes %}
12 #include "{{filename}}"
17 {{v8_class}}::{{v8_class}}(v8::Handle<v8::Function> callback, ExecutionContext* context)
18 : ActiveDOMCallback(context)
20 v8::Isolate* isolate = toIsolate(context);
21 m_callback.set(isolate, callback);
22 m_scriptState = ScriptState::current(isolate);
25 {{v8_class}}::~{{v8_class}}()
29 {% for method in methods if not method.custom %}
30 {{method.cpp_type}} {{v8_class}}::{{method.name}}({{method.argument_declarations | join(', ')}})
32 {% set return_default = 'return true'
33 if method.idl_type == 'boolean' else 'return' %}{# void #}
34 if (!canInvokeCallback())
37 v8::Isolate* isolate = m_scriptState->isolate();
38 if (m_scriptState->contextIsEmpty())
41 ScriptState::Scope scope(m_scriptState.get());
42 {% if method.call_with_this_handle %}
43 v8::Handle<v8::Value> thisHandle = thisValue.v8Value();
44 if (thisHandle.IsEmpty()) {
45 if (!isScriptControllerTerminating())
49 ASSERT(thisHandle->IsObject());
51 {% for argument in method.arguments %}
52 v8::Handle<v8::Value> {{argument.handle}} = {{argument.cpp_value_to_v8_value}};
53 if ({{argument.handle}}.IsEmpty()) {
54 if (!isScriptControllerTerminating())
59 {% if method.arguments %}
60 v8::Handle<v8::Value> argv[] = { {{method.arguments | join(', ', 'handle')}} };
62 v8::Handle<v8::Value> *argv = 0;
65 {% set this_handle_parameter = 'v8::Handle<v8::Object>::Cast(thisHandle), ' if method.call_with_this_handle else '' %}
66 {% if method.idl_type == 'boolean' %}
67 return invokeCallback(m_callback.newLocal(isolate), {{this_handle_parameter}}{{method.arguments | length}}, argv, executionContext(), isolate);
69 invokeCallback(m_callback.newLocal(isolate), {{this_handle_parameter}}{{method.arguments | length}}, argv, executionContext(), isolate);
74 } // namespace WebCore