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

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

Issue 2312093003: Generated bindings for IDL callback functions (Closed)
Patch Set: Edited template 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, v8::Local<v8::Objec t> owner, ScriptState* scriptState)
14 : ActiveDOMCallback(scriptState->getExecutionContext())
15 , m_callback(scriptState->isolate(), callback)
16 , m_scriptState(scriptState)
17 {
18 V8PrivateProperty::get{{cpp_class}}(scriptState->isolate()).set(scriptState- >context(), owner, callback);
19 m_callback.setPhantom();
20 }
21
22 {{v8_class}}::~{{v8_class}}()
23 {
24 }
25
26 DEFINE_TRACE({{v8_class}})
27 {
28 {{v8_class}}::trace(visitor);
29 ActiveDOMCallback::trace(visitor);
30 }
31
32 bool {{v8_class}}::call({{argument_declarations | join(', ')}})
33 {
34 {% set return_default = 'return false' %}
35 if (!canInvokeCallback())
36 {{return_default}};
37
38 if (!m_scriptState->contextIsValid())
39 {{return_default}};
40
41 ScriptState::Scope scope(m_scriptState.get());
42
43 if (m_callback.isEmpty())
44 {{return_default}};
45
46 {% for argument in arguments %}
47 v8::Local<v8::Value> {{argument.handle}} = {{argument.cpp_value_to_v8_value} };
48 {% endfor %}
49 {% if arguments %}
50 v8::Local<v8::Value> argv[] = { {{arguments | join(', ', 'handle')}} };
51 {% else %}
52 {# Empty array initializers are illegal, and don\'t compile in MSVC. #}
53 v8::Local<v8::Value> *argv = 0;
54 {% endif %}
55
56 v8::Local<v8::Value> currentValue;
57 v8::TryCatch exceptionCatcher(m_scriptState->isolate());
58 exceptionCatcher.SetVerbose(true);
59 if (V8ScriptRunner::callFunction(m_callback.newLocal(m_scriptState->isolate( )), m_scriptState->getExecutionContext(), m_scriptState->context()->Global(), {{ arguments | length}}, argv, m_scriptState->isolate()).ToLocal(&currentValue))
60 {
61 {{v8_value_to_local_cpp_value(v8_value_to_local_cpp_value_dict)}}
62 returnValue = cppValue;
63 return true;
64 }
65 else { return false; }
66 }
67
68 {{rvalue_cpp_type}} {{v8_class}}::getValue()
69 {
70 return returnValue;
71 }
72
73 } // namespace blink
74
75 {% endfilter %}{# format_blink_cpp_source_code #}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698