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

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

Issue 2748353003: [Bindings] Remove redundant ToObject invocation in dictionary toImpl. (Closed)
Patch Set: cast directly after check Created 3 years, 9 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/tests/results/core/V8TestDictionary.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 {% filter format_blink_cpp_source_code %} 1 {% filter format_blink_cpp_source_code %}
2 2
3 {% from 'utilities.cpp.tmpl' import declare_enum_validation_variable %} 3 {% from 'utilities.cpp.tmpl' import declare_enum_validation_variable %}
4 {% include 'copyright_block.txt' %} 4 {% include 'copyright_block.txt' %}
5 #include "{{v8_original_class}}.h" 5 #include "{{v8_original_class}}.h"
6 6
7 {% for filename in cpp_includes if filename != '%s.h' % v8_class %} 7 {% for filename in cpp_includes if filename != '%s.h' % v8_class %}
8 #include "{{filename}}" 8 #include "{{filename}}"
9 {% endfor %} 9 {% endfor %}
10 10
11 namespace blink { 11 namespace blink {
12 12
13 {% from 'utilities.cpp.tmpl' import v8_value_to_local_cpp_value %} 13 {% from 'utilities.cpp.tmpl' import v8_value_to_local_cpp_value %}
14 void {{v8_class}}::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, {{ cpp_class}}& impl, ExceptionState& exceptionState) { 14 void {{v8_class}}::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, {{ cpp_class}}& impl, ExceptionState& exceptionState) {
15 if (isUndefinedOrNull(v8Value)) { 15 if (isUndefinedOrNull(v8Value)) {
16 {% if required_member_names %} 16 {% if required_member_names %}
17 exceptionState.throwTypeError("Missing required member(s): {{required_member _names|join(', ')}}."); 17 exceptionState.throwTypeError("Missing required member(s): {{required_member _names|join(', ')}}.");
18 {% endif %} 18 {% endif %}
19 return; 19 return;
20 } 20 }
21 if (!v8Value->IsObject()) { 21 if (!v8Value->IsObject()) {
22 {% if use_permissive_dictionary_conversion %} 22 {% if use_permissive_dictionary_conversion %}
23 // Do nothing. 23 // Do nothing.
24 return; 24 return;
25 {% else %} 25 {% else %}
26 exceptionState.throwTypeError("cannot convert to dictionary."); 26 exceptionState.throwTypeError("cannot convert to dictionary.");
27 return; 27 return;
28 {% endif %} 28 {% endif %}
29 } 29 }
30 v8::Local<v8::Object> v8Object = v8Value.As<v8::Object>();
31 (void)v8Object;
Yuki 2017/03/17 06:07:33 nit: You can use ALLOW_UNUSED_LOCAL, just FYI.
jbroman 2017/03/17 14:50:26 I'd thought that wtf had something and couldn't fi
30 32
31 {% if parent_v8_class %} 33 {% if parent_v8_class %}
32 {{parent_v8_class}}::toImpl(isolate, v8Value, impl, exceptionState); 34 {{parent_v8_class}}::toImpl(isolate, v8Value, impl, exceptionState);
33 if (exceptionState.hadException()) 35 if (exceptionState.hadException())
34 return; 36 return;
35 37
36 {% endif %} 38 {% endif %}
37 {# Declare local variables only when the dictionary has members to avoid unuse d variable warnings. #} 39 {# Declare local variables only when the dictionary has members to avoid unuse d variable warnings. #}
38 {% if members %} 40 {% if members %}
39 v8::TryCatch block(isolate); 41 v8::TryCatch block(isolate);
40 v8::Local<v8::Object> v8Object;
41 if (!v8Call(v8Value->ToObject(isolate->GetCurrentContext()), v8Object, block)) {
42 exceptionState.rethrowV8Exception(block.Exception());
43 return;
44 }
45 {% endif %} 42 {% endif %}
46 {% for member in members %} 43 {% for member in members %}
47 {% filter runtime_enabled(member.runtime_enabled_feature_name) %} 44 {% filter runtime_enabled(member.runtime_enabled_feature_name) %}
48 v8::Local<v8::Value> {{member.name}}Value; 45 v8::Local<v8::Value> {{member.name}}Value;
49 if (!v8Object->Get(isolate->GetCurrentContext(), v8AtomicString(isolate, "{{me mber.name}}")).ToLocal(&{{member.name}}Value)) { 46 if (!v8Object->Get(isolate->GetCurrentContext(), v8AtomicString(isolate, "{{me mber.name}}")).ToLocal(&{{member.name}}Value)) {
50 exceptionState.rethrowV8Exception(block.Exception()); 47 exceptionState.rethrowV8Exception(block.Exception());
51 return; 48 return;
52 } 49 }
53 if ({{member.name}}Value.IsEmpty() || {{member.name}}Value->IsUndefined()) { 50 if ({{member.name}}Value.IsEmpty() || {{member.name}}Value->IsUndefined()) {
54 {% if member.is_required %} 51 {% if member.is_required %}
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 126
130 {{cpp_class}} NativeValueTraits<{{cpp_class}}>::nativeValue(v8::Isolate* isolate , v8::Local<v8::Value> value, ExceptionState& exceptionState) { 127 {{cpp_class}} NativeValueTraits<{{cpp_class}}>::nativeValue(v8::Isolate* isolate , v8::Local<v8::Value> value, ExceptionState& exceptionState) {
131 {{cpp_class}} impl; 128 {{cpp_class}} impl;
132 {{v8_class}}::toImpl(isolate, value, impl, exceptionState); 129 {{v8_class}}::toImpl(isolate, value, impl, exceptionState);
133 return impl; 130 return impl;
134 } 131 }
135 132
136 } // namespace blink 133 } // namespace blink
137 134
138 {% endfilter %}{# format_blink_cpp_source_code #} 135 {% endfilter %}{# format_blink_cpp_source_code #}
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/tests/results/core/V8TestDictionary.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698