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

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

Issue 2312093003: Generated bindings for IDL callback functions (Closed)
Patch Set: Did rebase-update 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::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(&currentValue))
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 #}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698