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

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

Issue 1057453002: bindings: Throw TypeError when required dictionary member is undefined (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 8 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
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 %}
(...skipping 28 matching lines...) Expand all
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 {% if member.is_required %}
50 exceptionState.throwTypeError("required member {{member.name}} is undefi ned.");
51 return;
52 {% else %}
49 // Do nothing. 53 // Do nothing.
54 {% endif %}
50 {% if member.is_nullable %} 55 {% if member.is_nullable %}
51 } else if ({{member.name}}Value->IsNull()) { 56 } else if ({{member.name}}Value->IsNull()) {
52 impl.{{member.null_setter_name}}(); 57 impl.{{member.null_setter_name}}();
53 {% endif %} 58 {% endif %}
54 } else { 59 } else {
55 {% if member.deprecate_as %} 60 {% if member.deprecate_as %}
56 UseCounter::countDeprecationIfNotPrivateScript(isolate, callingExecution Context(isolate), UseCounter::{{member.deprecate_as}}); 61 UseCounter::countDeprecationIfNotPrivateScript(isolate, callingExecution Context(isolate), UseCounter::{{member.deprecate_as}});
57 {% endif %} 62 {% endif %}
58 {{v8_value_to_local_cpp_value(member) | indent(8)}} 63 {{v8_value_to_local_cpp_value(member) | indent(8)}}
59 {% if member.is_interface_type %} 64 {% if member.is_interface_type %}
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 { 99 {
95 {% for member in members %} 100 {% for member in members %}
96 if (impl.{{member.has_method_name}}()) { 101 if (impl.{{member.has_method_name}}()) {
97 {% if member.is_object %} 102 {% if member.is_object %}
98 ASSERT(impl.{{member.cpp_name}}().isObject()); 103 ASSERT(impl.{{member.cpp_name}}().isObject());
99 {% endif %} 104 {% endif %}
100 dictionary->Set(v8String(isolate, "{{member.name}}"), {{member.cpp_value _to_v8_value}}); 105 dictionary->Set(v8String(isolate, "{{member.name}}"), {{member.cpp_value _to_v8_value}});
101 {% if member.v8_default_value %} 106 {% if member.v8_default_value %}
102 } else { 107 } else {
103 dictionary->Set(v8String(isolate, "{{member.name}}"), {{member.v8_defaul t_value}}); 108 dictionary->Set(v8String(isolate, "{{member.name}}"), {{member.v8_defaul t_value}});
109 {% elif member.is_required %}
110 } else {
111 ASSERT_NOT_REACHED();
104 {% endif %} 112 {% endif %}
105 } 113 }
106 114
107 {% endfor %} 115 {% endfor %}
108 } 116 }
109 117
110 {{cpp_class}} NativeValueTraits<{{cpp_class}}>::nativeValue(v8::Isolate* isolate , v8::Local<v8::Value> value, ExceptionState& exceptionState) 118 {{cpp_class}} NativeValueTraits<{{cpp_class}}>::nativeValue(v8::Isolate* isolate , v8::Local<v8::Value> value, ExceptionState& exceptionState)
111 { 119 {
112 {{cpp_class}} impl; 120 {{cpp_class}} impl;
113 {{v8_class}}::toImpl(isolate, value, impl, exceptionState); 121 {{v8_class}}::toImpl(isolate, value, impl, exceptionState);
114 return impl; 122 return impl;
115 } 123 }
116 124
117 } // namespace blink 125 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/scripts/v8_dictionary.py ('k') | Source/bindings/tests/idls/core/TestDictionaryDerived.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698