Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(590)

Side by Side Diff: third_party/WebKit/Source/bindings/templates/callback_function.cpp

Issue 2350813005: bindings: Support sequence in callback function arguments (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 {% from 'utilities.cpp' import v8_value_to_local_cpp_value %} 1 {% from 'utilities.cpp' import v8_value_to_local_cpp_value %}
2 {% filter format_blink_cpp_source_code %} 2 {% filter format_blink_cpp_source_code %}
3 3
4 {% include 'copyright_block.txt' %} 4 {% include 'copyright_block.txt' %}
5 5
6 #include "{{v8_class}}.h" 6 #include "{{v8_class}}.h"
7 7
8 {% for filename in cpp_includes %} 8 {% for filename in cpp_includes %}
9 #include "{{filename}}" 9 #include "{{filename}}"
10 {% endfor %} 10 {% endfor %}
(...skipping 11 matching lines...) Expand all
22 { 22 {
23 } 23 }
24 24
25 bool {{v8_class}}::call({{argument_declarations | join(', ')}}) 25 bool {{v8_class}}::call({{argument_declarations | join(', ')}})
26 { 26 {
27 if (!scriptState->contextIsValid()) 27 if (!scriptState->contextIsValid())
28 return false; 28 return false;
29 29
30 if (m_callback.isEmpty()) 30 if (m_callback.isEmpty())
31 return false; 31 return false;
32
32 ScriptState::Scope scope(scriptState); 33 ScriptState::Scope scope(scriptState);
34 ExceptionState exceptionState(scriptState->isolate(), ExceptionState::Execut ionContext, "{{cpp_class}}");
bashi 2016/09/21 02:00:21 Always declare exceptionState for simplicity. Ano
peria 2016/09/21 02:21:36 +1 to declare it here.
haraken 2016/09/21 02:25:12 What is an expected behavior when an exception is
bashi 2016/09/21 05:01:45 Hmm, glanced at existing hand-written callbacks an
Yuki 2016/09/21 07:59:37 Yes, I think that's the expected design. Always ki
33 35
34 {% for argument in arguments %} 36 {% for argument in arguments %}
35 v8::Local<v8::Value> {{argument.argument_name}} = {{argument.cpp_value_to_v8 _value}}; 37 v8::Local<v8::Value> {{argument.argument_name}} = {{argument.cpp_value_to_v8 _value}};
36 {% endfor %} 38 {% endfor %}
37 {% if arguments %} 39 {% if arguments %}
38 v8::Local<v8::Value> argv[] = { {{arguments | join(', ', 'argument_name')}} }; 40 v8::Local<v8::Value> argv[] = { {{arguments | join(', ', 'argument_name')}} };
39 {% else %} 41 {% else %}
40 {# Empty array initializers are illegal, and don\'t compile in MSVC. #} 42 {# Empty array initializers are illegal, and don\'t compile in MSVC. #}
41 v8::Local<v8::Value> *argv = nullptr; 43 v8::Local<v8::Value> *argv = nullptr;
42 {% endif %} 44 {% endif %}
43 45
44 v8::Local<v8::Value> v8ReturnValue; 46 v8::Local<v8::Value> v8ReturnValue;
45 v8::TryCatch exceptionCatcher(scriptState->isolate()); 47 v8::TryCatch exceptionCatcher(scriptState->isolate());
46 exceptionCatcher.SetVerbose(true); 48 exceptionCatcher.SetVerbose(true);
47 49
48 if (V8ScriptRunner::callFunction(m_callback.newLocal(scriptState->isolate()) , scriptState->getExecutionContext(), scriptState->context()->Global(), {{argume nts | length}}, argv, scriptState->isolate()).ToLocal(&v8ReturnValue)) 50 if (V8ScriptRunner::callFunction(m_callback.newLocal(scriptState->isolate()) , scriptState->getExecutionContext(), scriptState->context()->Global(), {{argume nts | length}}, argv, scriptState->isolate()).ToLocal(&v8ReturnValue))
49 { 51 {
50 {% if return_value %} 52 {% if return_value %}
51 {{v8_value_to_local_cpp_value(return_value) | indent(8)}} 53 {{v8_value_to_local_cpp_value(return_value) | indent(8)}}
52 returnValue = cppValue; 54 returnValue = cppValue;
53 {% endif %} 55 {% endif %}
54 return true; 56 return true;
55 } 57 }
56 return false; 58 return false;
57 } 59 }
58 60
59 } // namespace blink 61 } // namespace blink
60 62
61 {% endfilter %}{# format_blink_cpp_source_code #} 63 {% endfilter %}{# format_blink_cpp_source_code #}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698