OLD | NEW |
---|---|
(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) | |
peria
2016/09/15 01:14:32
[style] redundant space after ','
lkawai
2016/09/16 05:05:50
Done.
| |
14 : m_callback(scriptState->isolate(), callback) | |
15 { | |
16 m_callback.setPhantom(); | |
17 } | |
18 | |
19 DEFINE_TRACE({{v8_class}}) | |
20 { | |
21 } | |
22 | |
23 bool {{v8_class}}::call({{argument_declarations | join(', ')}}) | |
24 { | |
25 {% set return_default = 'return false' %} | |
bashi
2016/09/13 00:35:06
Remove this and simply use 'return false' where {{
lkawai
2016/09/16 05:05:50
Done.
| |
26 if (!scriptState->contextIsValid()) | |
27 {{return_default}}; | |
28 | |
29 if (m_callback.isEmpty()) | |
30 {{return_default}}; | |
31 | |
32 {% for argument in arguments %} | |
33 v8::Local<v8::Value> {{argument.handle}} = {{argument.cpp_value_to_v8_value} }; | |
34 {% endfor %} | |
35 {% if arguments %} | |
36 v8::Local<v8::Value> argv[] = { {{arguments | join(', ', 'handle')}} }; | |
37 {% else %} | |
38 {# Empty array initializers are illegal, and don\'t compile in MSVC. #} | |
39 v8::Local<v8::Value> *argv = 0; | |
peria
2016/09/15 01:14:32
[style] s/0/nullptr/
lkawai
2016/09/16 05:05:50
Done.
| |
40 {% endif %} | |
41 | |
42 v8::Local<v8::Value> currentValue; | |
43 v8::TryCatch exceptionCatcher(scriptState->isolate()); | |
44 exceptionCatcher.SetVerbose(true); | |
45 if (V8ScriptRunner::callFunction(m_callback.newLocal(scriptState->isolate()) , scriptState->getExecutionContext(), scriptState->context()->Global(), {{argume nts | length}}, argv, scriptState->isolate()).ToLocal(¤tValue)) | |
46 { | |
47 {% if rvalue_cpp_type != 'void' %} | |
bashi
2016/09/13 00:35:06
Did you try generating bindings for a callback of
lkawai
2016/09/16 05:05:50
Done.
| |
48 {{v8_value_to_local_cpp_value(v8_value_to_local_cpp_value_dict)}} | |
49 {% endif %} | |
50 returnValue = cppValue; | |
51 return true; | |
52 } | |
53 else { return false; } | |
bashi
2016/09/13 00:35:06
Remove else clause and simply return false.
lkawai
2016/09/16 05:05:50
Done.
| |
54 } | |
55 | |
56 } // namespace blink | |
57 | |
58 {% endfilter %}{# format_blink_cpp_source_code #} | |
OLD | NEW |