1 {% include
'copyright_block.txt' %}
3 {% filter
conditional(conditional_string
) %}
4 #include "{{v8_class}}.h"
6 {% for filename in cpp_includes
%}
7 #include "{{filename}}"
12 {{v8_class
}}::{{v8_class
}}(v8::Local
<v8::Function
> callback
, ScriptState
* scriptState
)
13 : ActiveDOMCallback(scriptState
->executionContext())
14 , m_scriptState(scriptState
)
16 m_callback
.set(scriptState
->isolate(), callback
);
19 {{v8_class
}}::~{{v8_class
}}()
23 DEFINE_TRACE({{v8_class
}})
25 {{cpp_class
}}::trace(visitor
);
26 ActiveDOMCallback::trace(visitor
);
29 {% for method in methods
if not method
.is_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 if (!m_scriptState
->contextIsValid())
40 ScriptState::Scope
scope(m_scriptState
.get());
41 {% if method
.call_with_this_handle
%}
42 v8::Local
<v8::Value
> thisHandle
= thisValue
.v8Value();
43 if (thisHandle
.IsEmpty()) {
44 if (!isScriptControllerTerminating())
49 {% for argument in method
.arguments
%}
50 v8::Local
<v8::Value
> {{argument
.handle
}} = {{argument
.cpp_value_to_v8_value
}};
51 if ({{argument
.handle
}}.IsEmpty()) {
52 if (!isScriptControllerTerminating())
57 {% if method
.arguments
%}
58 v8::Local
<v8::Value
> argv
[] = { {{method
.arguments
| join(', ', 'handle')}} };
60 {# Empty array initializers are illegal, and don't compile in MSVC. #}
61 v8::Local<v8::Value> *argv = 0;
64 {% set this_handle_parameter = 'thisHandle, ' if method.call_with_this_handle else 'v8::Undefined(m_scriptState->isolate()), ' %}
65 {% if method.idl_type == 'boolean' %}
66 v8::TryCatch exceptionCatcher;
67 exceptionCatcher.SetVerbose(true);
68 ScriptController::callFunction(m_scriptState->executionContext(), m_callback.newLocal(m_scriptState->isolate()), {{this_handle_parameter}}{{method.arguments | length}}, argv, m_scriptState->isolate());
69 return !exceptionCatcher.HasCaught();
71 ScriptController::callFunction(m_scriptState->executionContext(), m_callback.newLocal(m_scriptState->isolate()), {{this_handle_parameter}}{{method.arguments | length}}, argv, m_scriptState->isolate());