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

Side by Side Diff: Source/bindings/templates/dictionary_v8.cpp

Issue 946973005: IDL: Drop value conversion (V8 -> C++) macros from generated code (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: address comments Created 5 years, 10 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 | « Source/bindings/templates/conversions.cpp ('k') | Source/bindings/templates/interface.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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file has been auto-generated by {{code_generator}}. DO NOT MODIFY! 5 // This file has been auto-generated by {{code_generator}}. DO NOT MODIFY!
6 6
7 #include "config.h" 7 #include "config.h"
8 #include "{{v8_original_class}}.h" 8 #include "{{v8_original_class}}.h"
9 9
10 {% for filename in cpp_includes if filename != '%s.h' % v8_class %} 10 {% for filename in cpp_includes if filename != '%s.h' % v8_class %}
11 #include "{{filename}}" 11 #include "{{filename}}"
12 {% endfor %} 12 {% endfor %}
13 13
14 namespace blink { 14 namespace blink {
15 15
16 {% macro convert_and_set_member(member) %} 16 {% from 'conversions.cpp' import v8_value_to_local_cpp_value %}
17 {% endmacro %}
18 void {{v8_class}}::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, {{ cpp_class}}& impl, ExceptionState& exceptionState) 17 void {{v8_class}}::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, {{ cpp_class}}& impl, ExceptionState& exceptionState)
19 { 18 {
20 if (isUndefinedOrNull(v8Value)) 19 if (isUndefinedOrNull(v8Value))
21 return; 20 return;
22 if (!v8Value->IsObject()) { 21 if (!v8Value->IsObject()) {
23 {% if use_permissive_dictionary_conversion %} 22 {% if use_permissive_dictionary_conversion %}
24 // Do nothing. 23 // Do nothing.
24 return;
25 {% else %} 25 {% else %}
26 exceptionState.throwTypeError("cannot convert to dictionary."); 26 exceptionState.throwTypeError("cannot convert to dictionary.");
27 return;
27 {% endif %} 28 {% endif %}
28 return;
29 } 29 }
30 30
31 {% if parent_v8_class %} 31 {% if parent_v8_class %}
32 {{parent_v8_class}}::toImpl(isolate, v8Value, impl, exceptionState); 32 {{parent_v8_class}}::toImpl(isolate, v8Value, impl, exceptionState);
33 if (exceptionState.hadException()) 33 if (exceptionState.hadException())
34 return; 34 return;
35 35
36 {% endif %} 36 {% endif %}
37 {# Declare local variables only when the dictionary has members to avoid unu sed variable warnings. #} 37 {# Declare local variables only when the dictionary has members to avoid unu sed variable warnings. #}
38 {% if members %} 38 {% if members %}
39 v8::Local<v8::Object> v8Object = v8Value->ToObject(isolate); 39 v8::Local<v8::Object> v8Object = v8Value->ToObject(isolate);
40 v8::TryCatch block; 40 v8::TryCatch block;
41 {% endif %} 41 {% endif %}
42 {% for member in members %} 42 {% for member in members %}
43 v8::Local<v8::Value> {{member.name}}Value = v8Object->Get(v8String(isolate, "{{member.name}}")); 43 v8::Local<v8::Value> {{member.name}}Value = v8Object->Get(v8String(isolate, "{{member.name}}"));
44 if (block.HasCaught()) { 44 if (block.HasCaught()) {
45 exceptionState.rethrowV8Exception(block.Exception()); 45 exceptionState.rethrowV8Exception(block.Exception());
46 return; 46 return;
47 } 47 }
48 if ({{member.name}}Value.IsEmpty() || {{member.name}}Value->IsUndefined()) { 48 if ({{member.name}}Value.IsEmpty() || {{member.name}}Value->IsUndefined()) {
49 // Do nothing. 49 // Do nothing.
50 {% if member.is_nullable %} 50 {% if member.is_nullable %}
51 } else if ({{member.name}}Value->IsNull()) { 51 } else if ({{member.name}}Value->IsNull()) {
52 impl.{{member.null_setter_name}}(); 52 impl.{{member.null_setter_name}}();
53 {% endif %} 53 {% endif %}
54 } else { 54 } else {
55 {% if member.deprecate_as %} 55 {% if member.deprecate_as %}
56 UseCounter::countDeprecationIfNotPrivateScript(isolate, callingExecution Context(isolate), UseCounter::{{member.deprecate_as}}); 56 UseCounter::countDeprecationIfNotPrivateScript(isolate, callingExecution Context(isolate), UseCounter::{{member.deprecate_as}});
57 {% endif %} 57 {% endif %}
58 {% if member.use_output_parameter_for_result %} 58 {{v8_value_to_local_cpp_value(member) | indent(8)}}
59 {{member.cpp_type}} {{member.name}};
60 {% endif %}
61 {{member.v8_value_to_local_cpp_value}};
62 {% if member.is_interface_type %} 59 {% if member.is_interface_type %}
63 if (!{{member.name}} && !{{member.name}}Value->IsNull()) { 60 if (!{{member.name}} && !{{member.name}}Value->IsNull()) {
64 exceptionState.throwTypeError("member {{member.name}} is not of type {{member.idl_type}}."); 61 exceptionState.throwTypeError("member {{member.name}} is not of type {{member.idl_type}}.");
65 return; 62 return;
66 } 63 }
67 {% endif %} 64 {% endif %}
68 {% if member.enum_validation_expression %} 65 {% if member.enum_validation_expression %}
69 String string = {{member.name}}; 66 String string = {{member.name}};
70 if (!({{member.enum_validation_expression}})) { 67 if (!({{member.enum_validation_expression}})) {
71 exceptionState.throwTypeError("member {{member.name}} ('" + string + "') is not a valid enum value."); 68 exceptionState.throwTypeError("member {{member.name}} ('" + string + "') is not a valid enum value.");
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } 108 }
112 109
113 {{cpp_class}} NativeValueTraits<{{cpp_class}}>::nativeValue(const v8::Local<v8:: Value>& value, v8::Isolate* isolate, ExceptionState& exceptionState) 110 {{cpp_class}} NativeValueTraits<{{cpp_class}}>::nativeValue(const v8::Local<v8:: Value>& value, v8::Isolate* isolate, ExceptionState& exceptionState)
114 { 111 {
115 {{cpp_class}} impl; 112 {{cpp_class}} impl;
116 {{v8_class}}::toImpl(isolate, value, impl, exceptionState); 113 {{v8_class}}::toImpl(isolate, value, impl, exceptionState);
117 return impl; 114 return impl;
118 } 115 }
119 116
120 } // namespace blink 117 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/templates/conversions.cpp ('k') | Source/bindings/templates/interface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698