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 #include "{{v8_class}}.h" |
| 6 |
| 7 {% for filename in cpp_includes %} |
| 8 #include "{{filename}}" |
| 9 {% endfor %} |
| 10 |
| 11 namespace blink { |
| 12 |
| 13 {{v8_class}}::{{v8_class}}(v8::Local<v8::Function> callback, ScriptState* scrip
tState) |
| 14 : m_callback(scriptState->isolate(), callback) |
| 15 , m_scriptState(scriptState) |
| 16 { |
| 17 m_callback.setPhantom(); |
| 18 } |
| 19 |
| 20 DEFINE_TRACE({{v8_class}}) |
| 21 { |
| 22 } |
| 23 |
| 24 bool {{v8_class}}::call({{argument_declarations | join(', ')}}) |
| 25 { |
| 26 {% set return_default = 'return false' %} |
| 27 if (!m_scriptState->contextIsValid()) |
| 28 {{return_default}}; |
| 29 |
| 30 ScriptState::Scope scope(m_scriptState.get()); |
| 31 |
| 32 if (m_callback.isEmpty()) |
| 33 {{return_default}}; |
| 34 |
| 35 {% for argument in arguments %} |
| 36 v8::Local<v8::Value> {{argument.handle}} = {{argument.cpp_value_to_v8_value}
}; |
| 37 {% endfor %} |
| 38 {% if arguments %} |
| 39 v8::Local<v8::Value> argv[] = { {{arguments | join(', ', 'handle')}} }; |
| 40 {% else %} |
| 41 {# Empty array initializers are illegal, and don\'t compile in MSVC. #} |
| 42 v8::Local<v8::Value> *argv = 0; |
| 43 {% endif %} |
| 44 |
| 45 v8::Local<v8::Value> currentValue; |
| 46 v8::TryCatch exceptionCatcher(m_scriptState->isolate()); |
| 47 exceptionCatcher.SetVerbose(true); |
| 48 if (V8ScriptRunner::callFunction(m_callback.newLocal(m_scriptState->isolate(
)), m_scriptState->getExecutionContext(), m_scriptState->context()->Global(), {{
arguments | length}}, argv, m_scriptState->isolate()).ToLocal(¤tValue)) |
| 49 { |
| 50 {% if rvalue_cpp_type != 'void' %} |
| 51 {{v8_value_to_local_cpp_value(v8_value_to_local_cpp_value_dict)}} |
| 52 {% endif %} |
| 53 returnValue = cppValue; |
| 54 return true; |
| 55 } |
| 56 else { return false; } |
| 57 } |
| 58 |
| 59 {% if rvalue_cpp_type != 'void' %} |
| 60 {{rvalue_cpp_type}} {{v8_class}}::getValue() |
| 61 { |
| 62 return returnValue; |
| 63 } |
| 64 {% endif %} |
| 65 |
| 66 } // namespace blink |
| 67 |
| 68 {% endfilter %}{# format_blink_cpp_source_code #} |
OLD | NEW |