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

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

Issue 2446213002: [Bindings] [Reformat] Reformat template files (Closed)
Patch Set: Rebase (Split out Callbackfunctions) Created 4 years, 1 month 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 {% filter format_blink_cpp_source_code %} 1 {% filter format_blink_cpp_source_code %}
2 2
3 {% include 'copyright_block.txt' %} 3 {% include 'copyright_block.txt' %}
4 #include "{{v8_class}}.h" 4 #include "{{v8_class}}.h"
5 5
6 {% for filename in cpp_includes %} 6 {% for filename in cpp_includes %}
7 #include "{{filename}}" 7 #include "{{filename}}"
8 {% endfor %} 8 {% endfor %}
9 9
10 namespace blink { 10 namespace blink {
11 11
12 {{v8_class}}::{{v8_class}}(v8::Local<v8::Function> callback, ScriptState* script State) 12 {{v8_class}}::{{v8_class}}(v8::Local<v8::Function> callback, ScriptState* script State)
13 : ActiveDOMCallback(scriptState->getExecutionContext()) 13 : ActiveDOMCallback(scriptState->getExecutionContext())
14 , m_scriptState(scriptState) 14 , m_scriptState(scriptState) {
15 { 15 m_callback.set(scriptState->isolate(), callback);
16 m_callback.set(scriptState->isolate(), callback);
17 } 16 }
18 17
19 {{v8_class}}::~{{v8_class}}() 18 {{v8_class}}::~{{v8_class}}() {}
20 {
21 }
22 19
23 DEFINE_TRACE({{v8_class}}) 20 DEFINE_TRACE({{v8_class}}) {
24 { 21 {{cpp_class}}::trace(visitor);
25 {{cpp_class}}::trace(visitor); 22 ActiveDOMCallback::trace(visitor);
26 ActiveDOMCallback::trace(visitor);
27 } 23 }
28 24
29 {% for method in methods if not method.is_custom %} 25 {% for method in methods if not method.is_custom %}
30 {{method.cpp_type}} {{v8_class}}::{{method.name}}({{method.argument_declarations | join(', ')}}) 26 {{method.cpp_type}} {{v8_class}}::{{method.name}}({{method.argument_declarations | join(', ')}}) {
31 { 27 {% set return_default = 'return true'
32 {% set return_default = 'return true' 28 if method.idl_type == 'boolean' else 'return' %}{# void #}
33 if method.idl_type == 'boolean' else 'return' %}{# void #} 29 if (!canInvokeCallback())
34 if (!canInvokeCallback()) 30 {{return_default}};
35 {{return_default}};
36 31
37 if (!m_scriptState->contextIsValid()) 32 if (!m_scriptState->contextIsValid())
38 {{return_default}}; 33 {{return_default}};
39 34
40 ScriptState::Scope scope(m_scriptState.get()); 35 ScriptState::Scope scope(m_scriptState.get());
41 {% if method.call_with_this_handle %} 36 {% if method.call_with_this_handle %}
42 v8::Local<v8::Value> thisHandle = thisValue.v8Value(); 37 v8::Local<v8::Value> thisHandle = thisValue.v8Value();
43 {% endif %} 38 {% endif %}
44 {% for argument in method.arguments %} 39 {% for argument in method.arguments %}
45 v8::Local<v8::Value> {{argument.handle}} = {{argument.cpp_value_to_v8_value} }; 40 v8::Local<v8::Value> {{argument.handle}} = {{argument.cpp_value_to_v8_value}};
46 {% endfor %} 41 {% endfor %}
47 {% if method.arguments %} 42 {% if method.arguments %}
48 v8::Local<v8::Value> argv[] = { {{method.arguments | join(', ', 'handle')}} }; 43 v8::Local<v8::Value> argv[] = { {{method.arguments | join(', ', 'handle')}} };
49 {% else %} 44 {% else %}
50 {# Empty array initializers are illegal, and don\'t compile in MSVC. #} 45 {# Empty array initializers are illegal, and don\'t compile in MSVC. #}
51 v8::Local<v8::Value> *argv = 0; 46 v8::Local<v8::Value> *argv = 0;
52 {% endif %} 47 {% endif %}
53 48
54 {% set this_handle_parameter = 'thisHandle, ' if method.call_with_this_handl e else 'v8::Undefined(m_scriptState->isolate()), ' %} 49 {% set this_handle_parameter = 'thisHandle, ' if method.call_with_this_handle else 'v8::Undefined(m_scriptState->isolate()), ' %}
55 {% if method.idl_type == 'boolean' %} 50 {% if method.idl_type == 'boolean' %}
56 v8::TryCatch exceptionCatcher(m_scriptState->isolate()); 51 v8::TryCatch exceptionCatcher(m_scriptState->isolate());
57 exceptionCatcher.SetVerbose(true); 52 exceptionCatcher.SetVerbose(true);
58 V8ScriptRunner::callFunction(m_callback.newLocal(m_scriptState->isolate()), m_scriptState->getExecutionContext(), {{this_handle_parameter}}{{method.argument s | length}}, argv, m_scriptState->isolate()); 53 V8ScriptRunner::callFunction(m_callback.newLocal(m_scriptState->isolate()), m_ scriptState->getExecutionContext(), {{this_handle_parameter}}{{method.arguments | length}}, argv, m_scriptState->isolate());
59 return !exceptionCatcher.HasCaught(); 54 return !exceptionCatcher.HasCaught();
60 {% else %}{# void #} 55 {% else %}{# void #}
61 V8ScriptRunner::callFunction(m_callback.newLocal(m_scriptState->isolate()), m_scriptState->getExecutionContext(), {{this_handle_parameter}}{{method.argument s | length}}, argv, m_scriptState->isolate()); 56 V8ScriptRunner::callFunction(m_callback.newLocal(m_scriptState->isolate()), m_ scriptState->getExecutionContext(), {{this_handle_parameter}}{{method.arguments | length}}, argv, m_scriptState->isolate());
62 {% endif %} 57 {% endif %}
63 } 58 }
64 59
65 {% endfor %} 60 {% endfor %}
66 } // namespace blink 61 } // namespace blink
67 62
68 {% endfilter %}{# format_blink_cpp_source_code #} 63 {% endfilter %}{# format_blink_cpp_source_code #}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698