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

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

Issue 2312093003: Generated bindings for IDL callback functions (Closed)
Patch Set: Addressed comments 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
(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::Isolate* isolate, v8::Local<v8::Function> callbac k)
14 : m_callback(isolate, callback)
15 {
16 DCHECK(!m_callback.isEmpty());
17 m_callback.setPhantom();
18 }
19
20 DEFINE_TRACE({{v8_class}})
21 {
22 }
23
24 bool {{v8_class}}::call({{argument_declarations | join(', ')}})
25 {
26 if (!scriptState->contextIsValid())
27 return false;
28
29 ScriptState::Scope scope(scriptState);
30 if (m_callback.isEmpty())
31 return false;
32
33 {% for argument in arguments %}
34 v8::Local<v8::Value> {{argument.handle_name}} = {{argument.cpp_value_to_v8_v alue}};
35 {% endfor %}
36 {% if arguments %}
37 v8::Local<v8::Value> argv[] = { {{arguments | join(', ', 'handle_name')}} };
38 {% else %}
39 {# Empty array initializers are illegal, and don\'t compile in MSVC. #}
40 v8::Local<v8::Value> *argv = nullptr;
41 {% endif %}
42
43 v8::Local<v8::Value> currentValue;
44 v8::TryCatch exceptionCatcher(scriptState->isolate());
45 exceptionCatcher.SetVerbose(true);
46 if (V8ScriptRunner::callFunction(m_callback.newLocal(scriptState->isolate()) , scriptState->getExecutionContext(), scriptState->context()->Global(), {{argume nts | length}}, argv, scriptState->isolate()).ToLocal(&currentValue))
47 {
48 {% if return_cpp_type != 'void*&' %}
49 {{v8_value_to_local_cpp_value(return_cpp_value)}}
50 returnValue = cppValue;
51 {% endif %}
52 return true;
53 }
54 return false;
55 }
56
57 } // namespace blink
58
59 {% endfilter %}{# format_blink_cpp_source_code #}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698