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

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

Issue 2329463004: ABANDONED CL: Changes needed to make things compile after running rewrite_to_chrome_style tool. (Closed)
Patch Set: Rebasing the fixes... Created 3 years, 10 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.tmpl' import v8_value_to_local_cpp_value %} 1 {% from 'utilities.cpp.tmpl' 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 "{{cpp_class}}.h" 6 #include "{{cpp_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 %}
11 11
12 namespace blink { 12 namespace blink {
13 13
14 // static 14 // static
15 {{cpp_class}}* {{cpp_class}}::create(ScriptState* scriptState, v8::Local<v8::Val ue> callback){ 15 {{cpp_class}}* {{cpp_class}}::Create(ScriptState* scriptState, v8::Local<v8::Val ue> callback){
16 if (isUndefinedOrNull(callback)) 16 if (IsUndefinedOrNull(callback))
17 return nullptr; 17 return nullptr;
18 return new {{cpp_class}}(scriptState, v8::Local<v8::Function>::Cast(callback)) ; 18 return new {{cpp_class}}(scriptState, v8::Local<v8::Function>::Cast(callback)) ;
19 } 19 }
20 20
21 {{cpp_class}}::{{cpp_class}}(ScriptState* scriptState, v8::Local<v8::Function> c allback) 21 {{cpp_class}}::{{cpp_class}}(ScriptState* scriptState, v8::Local<v8::Function> c allback)
22 : m_scriptState(scriptState), 22 : m_scriptState(scriptState),
23 m_callback(scriptState->isolate(), this, callback) { 23 m_callback(scriptState->GetIsolate(), this, callback) {
24 DCHECK(!m_callback.isEmpty()); 24 DCHECK(!m_callback.IsEmpty());
25 } 25 }
26 26
27 DEFINE_TRACE({{cpp_class}}) {} 27 DEFINE_TRACE({{cpp_class}}) {}
28 28
29 DEFINE_TRACE_WRAPPERS({{cpp_class}}) { 29 DEFINE_TRACE_WRAPPERS({{cpp_class}}) {
30 visitor->traceWrappers(m_callback.cast<v8::Value>()); 30 visitor->TraceWrappers(m_callback.Cast<v8::Value>());
31 } 31 }
32 32
33 bool {{cpp_class}}::call({{argument_declarations | join(', ')}}) { 33 bool {{cpp_class}}::call({{argument_declarations | join(', ')}}) {
34 if (!m_scriptState->contextIsValid()) 34 if (!m_scriptState->ContextIsValid())
35 return false; 35 return false;
36 36
37 ExecutionContext* context = m_scriptState->getExecutionContext(); 37 ExecutionContext* context = m_scriptState->GetExecutionContext();
38 DCHECK(context); 38 DCHECK(context);
39 if (context->isContextSuspended() || context->isContextDestroyed()) 39 if (context->IsContextSuspended() || context->IsContextDestroyed())
40 return false; 40 return false;
41 41
42 if (m_callback.isEmpty()) 42 if (m_callback.IsEmpty())
43 return false; 43 return false;
44 44
45 // TODO(bashi): Make sure that using DummyExceptionStateForTesting is OK. 45 // TODO(bashi): Make sure that using DummyExceptionStateForTesting is OK.
46 // crbug.com/653769 46 // crbug.com/653769
47 DummyExceptionStateForTesting exceptionState; 47 DummyExceptionStateForTesting exceptionState;
48 ScriptState::Scope scope(m_scriptState.get()); 48 ScriptState::Scope scope(m_scriptState.Get());
49 49
50 {% for argument in arguments %} 50 {% for argument in arguments %}
51 v8::Local<v8::Value> {{argument.argument_name}} = {{argument.cpp_value_to_v8_v alue}}; 51 v8::Local<v8::Value> {{argument.argument_name}} = {{argument.cpp_value_to_v8_v alue}};
52 {% endfor %} 52 {% endfor %}
53 53
54 v8::Local<v8::Value> thisValue = ToV8(scriptWrappable, m_scriptState->context( )->Global(), m_scriptState->isolate()); 54 v8::Local<v8::Value> thisValue = ToV8(scriptWrappable, m_scriptState->GetConte xt()->Global(), m_scriptState->GetIsolate());
55 55
56 {% if arguments %} 56 {% if arguments %}
57 v8::Local<v8::Value> argv[] = { {{arguments | join(', ', 'argument_name')}} }; 57 v8::Local<v8::Value> argv[] = { {{arguments | join(', ', 'argument_name')}} };
58 {% else %} 58 {% else %}
59 {# Empty array initializers are illegal, and don\'t compile in MSVC. #} 59 {# Empty array initializers are illegal, and don\'t compile in MSVC. #}
60 v8::Local<v8::Value> *argv = nullptr; 60 v8::Local<v8::Value> *argv = nullptr;
61 {% endif %} 61 {% endif %}
62 62
63 v8::Local<v8::Value> v8ReturnValue; 63 v8::Local<v8::Value> v8ReturnValue;
64 v8::TryCatch exceptionCatcher(m_scriptState->isolate()); 64 v8::TryCatch exceptionCatcher(m_scriptState->GetIsolate());
65 exceptionCatcher.SetVerbose(true); 65 exceptionCatcher.SetVerbose(true);
66 66
67 if (V8ScriptRunner::callFunction(m_callback.newLocal(m_scriptState->isolate()) , m_scriptState->getExecutionContext(), thisValue, {{arguments | length}}, argv, m_scriptState->isolate()).ToLocal(&v8ReturnValue)) { 67 if (V8ScriptRunner::CallFunction(m_callback.NewLocal(m_scriptState->GetIsolate ()), m_scriptState->GetExecutionContext(), thisValue, {{arguments | length}}, ar gv, m_scriptState->GetIsolate()).ToLocal(&v8ReturnValue)) {
68 {% if return_value %} 68 {% if return_value %}
69 {{v8_value_to_local_cpp_value(return_value) | indent(8)}} 69 {{v8_value_to_local_cpp_value(return_value) | indent(8)}}
70 returnValue = cppValue; 70 returnValue = cppValue;
71 {% endif %} 71 {% endif %}
72 return true; 72 return true;
73 } 73 }
74 return false; 74 return false;
75 } 75 }
76 76
77 } // namespace blink 77 } // namespace blink
78 78
79 {% endfilter %}{# format_blink_cpp_source_code #} 79 {% endfilter %}{# format_blink_cpp_source_code #}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698