OLD | NEW |
(Empty) | |
| 1 {% from 'utilities.cpp' import v8_value_to_local_cpp_value %} |
| 2 {% filter format_blink_cpp_source_code %} |
| 3 |
| 4 {% include 'copyright_block.txt' %} |
| 5 |
| 6 #include "{{v8_class}}.h" |
| 7 |
| 8 {% for filename in cpp_includes %} |
| 9 #include "{{filename}}" |
| 10 {% endfor %} |
| 11 |
| 12 namespace blink { |
| 13 |
| 14 {{v8_class}}::{{v8_class}}(v8::Isolate* isolate, v8::Local<v8::Function> callbac
k) |
| 15 : m_callback(isolate, callback) |
| 16 { |
| 17 DCHECK(!m_callback.isEmpty()); |
| 18 m_callback.setPhantom(); |
| 19 } |
| 20 |
| 21 DEFINE_TRACE({{v8_class}}) |
| 22 { |
| 23 } |
| 24 |
| 25 bool {{v8_class}}::call({{argument_declarations | join(', ')}}) |
| 26 { |
| 27 if (!scriptState->contextIsValid()) |
| 28 return false; |
| 29 |
| 30 if (m_callback.isEmpty()) |
| 31 return false; |
| 32 ScriptState::Scope scope(scriptState); |
| 33 |
| 34 {% for argument in arguments %} |
| 35 v8::Local<v8::Value> {{argument.argument_name}} = {{argument.cpp_value_to_v8
_value}}; |
| 36 {% endfor %} |
| 37 {% if arguments %} |
| 38 v8::Local<v8::Value> argv[] = { {{arguments | join(', ', 'argument_name')}}
}; |
| 39 {% else %} |
| 40 {# Empty array initializers are illegal, and don\'t compile in MSVC. #} |
| 41 v8::Local<v8::Value> *argv = nullptr; |
| 42 {% endif %} |
| 43 |
| 44 v8::Local<v8::Value> v8ReturnValue; |
| 45 v8::TryCatch exceptionCatcher(scriptState->isolate()); |
| 46 exceptionCatcher.SetVerbose(true); |
| 47 |
| 48 if (V8ScriptRunner::callFunction(m_callback.newLocal(scriptState->isolate())
, scriptState->getExecutionContext(), scriptState->context()->Global(), {{argume
nts | length}}, argv, scriptState->isolate()).ToLocal(&v8ReturnValue)) |
| 49 { |
| 50 {% if return_value %} |
| 51 {{v8_value_to_local_cpp_value(return_value) | indent(8)}} |
| 52 returnValue = cppValue; |
| 53 {% endif %} |
| 54 return true; |
| 55 } |
| 56 return false; |
| 57 } |
| 58 |
| 59 } // namespace blink |
| 60 |
| 61 {% endfilter %}{# format_blink_cpp_source_code #} |
OLD | NEW |