| Index: third_party/WebKit/Source/bindings/templates/callback_function.cpp
|
| diff --git a/third_party/WebKit/Source/bindings/templates/callback_function.cpp b/third_party/WebKit/Source/bindings/templates/callback_function.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..d68757efdf4a5877783bc0a5a042d83f9ff85f5c
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/bindings/templates/callback_function.cpp
|
| @@ -0,0 +1,75 @@
|
| +{% from 'utilities.cpp' import v8_value_to_local_cpp_value %}
|
| +{% filter format_blink_cpp_source_code %}
|
| +
|
| +{% include 'copyright_block.txt' %}
|
| +#include "{{v8_class}}.h"
|
| +
|
| +{% for filename in cpp_includes %}
|
| +#include "{{filename}}"
|
| +{% endfor %}
|
| +
|
| +namespace blink {
|
| +
|
| +{{v8_class}}::{{v8_class}}(v8::Local<v8::Function> callback, v8::Local<v8::Object> owner, ScriptState* scriptState)
|
| + : ActiveDOMCallback(scriptState->getExecutionContext())
|
| + , m_callback(scriptState->isolate(), callback)
|
| + , m_scriptState(scriptState)
|
| +{
|
| + V8PrivateProperty::get{{cpp_class}}(scriptState->isolate()).set(scriptState->context(), owner, callback);
|
| + m_callback.setPhantom();
|
| +}
|
| +
|
| +{{v8_class}}::~{{v8_class}}()
|
| +{
|
| +}
|
| +
|
| +DEFINE_TRACE({{v8_class}})
|
| +{
|
| + {{v8_class}}::trace(visitor);
|
| + ActiveDOMCallback::trace(visitor);
|
| +}
|
| +
|
| +bool {{v8_class}}::call({{argument_declarations | join(', ')}})
|
| +{
|
| + {% set return_default = 'return false' %}
|
| + if (!canInvokeCallback())
|
| + {{return_default}};
|
| +
|
| + if (!m_scriptState->contextIsValid())
|
| + {{return_default}};
|
| +
|
| + ScriptState::Scope scope(m_scriptState.get());
|
| +
|
| + if (m_callback.isEmpty())
|
| + {{return_default}};
|
| +
|
| + {% for argument in arguments %}
|
| + v8::Local<v8::Value> {{argument.handle}} = {{argument.cpp_value_to_v8_value}};
|
| + {% endfor %}
|
| + {% if arguments %}
|
| + v8::Local<v8::Value> argv[] = { {{arguments | join(', ', 'handle')}} };
|
| + {% else %}
|
| + {# Empty array initializers are illegal, and don\'t compile in MSVC. #}
|
| + v8::Local<v8::Value> *argv = 0;
|
| + {% endif %}
|
| +
|
| + v8::Local<v8::Value> currentValue;
|
| + v8::TryCatch exceptionCatcher(m_scriptState->isolate());
|
| + exceptionCatcher.SetVerbose(true);
|
| + if (V8ScriptRunner::callFunction(m_callback.newLocal(m_scriptState->isolate()), m_scriptState->getExecutionContext(), m_scriptState->context()->Global(), {{arguments | length}}, argv, m_scriptState->isolate()).ToLocal(¤tValue))
|
| + {
|
| + {{v8_value_to_local_cpp_value(v8_value_to_local_cpp_value_dict)}}
|
| + returnValue = cppValue;
|
| + return true;
|
| + }
|
| + else { return false; }
|
| +}
|
| +
|
| +{{rvalue_cpp_type}} {{v8_class}}::getValue()
|
| +{
|
| + return returnValue;
|
| +}
|
| +
|
| +} // namespace blink
|
| +
|
| +{% endfilter %}{# format_blink_cpp_source_code #}
|
|
|