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

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

Issue 556273003: In generated dictionary toImpl(), throw all exceptions via ExceptionState (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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
« no previous file with comments | « no previous file | 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 // 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_class}}.h" 8 #include "{{v8_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 {{cpp_class}}* {{v8_class}}::toImpl(v8::Isolate* isolate, v8::Handle<v8::Value> v8Value, ExceptionState& exceptionState) 16 {{cpp_class}}* {{v8_class}}::toImpl(v8::Isolate* isolate, v8::Handle<v8::Value> v8Value, ExceptionState& exceptionState)
17 { 17 {
18 {{cpp_class}}* impl = {{cpp_class}}::create(); 18 {{cpp_class}}* impl = {{cpp_class}}::create();
19 // FIXME: Do not use Dictionary and DictionaryHelper 19 // FIXME: Do not use Dictionary and DictionaryHelper
20 // https://crbug.com/321462 20 // https://crbug.com/321462
21 Dictionary dictionary(v8Value, isolate); 21 Dictionary dictionary(v8Value, isolate);
22 v8::TryCatch block;
bashi 2014/09/10 14:12:51 Could you leave a FIXME comment so that I won't mi
Jens Widell 2014/09/10 14:26:46 Done.
22 {% for member in members %} 23 {% for member in members %}
23 {{member.cpp_type}} {{member.name}}; 24 {{member.cpp_type}} {{member.name}};
24 if (DictionaryHelper::getWithUndefinedOrNullCheck(dictionary, "{{member.name }}", {{member.name}})) { 25 if (DictionaryHelper::getWithUndefinedOrNullCheck(dictionary, "{{member.name }}", {{member.name}})) {
25 {% if member.enum_validation_expression %} 26 {% if member.enum_validation_expression %}
26 String string = {{member.name}}; 27 String string = {{member.name}};
27 if (!({{member.enum_validation_expression}})) { 28 if (!({{member.enum_validation_expression}})) {
28 exceptionState.throwTypeError("member {{member.name}} ('" + string + "') is not a valid enum value."); 29 exceptionState.throwTypeError("member {{member.name}} ('" + string + "') is not a valid enum value.");
29 return 0; 30 return 0;
30 } 31 }
31 {% endif %} 32 {% endif %}
32 impl->{{member.setter_name}}({{member.name}}); 33 impl->{{member.setter_name}}({{member.name}});
34 } else if (block.HasCaught()) {
35 exceptionState.rethrowV8Exception(block.Exception());
36 return 0;
33 } 37 }
34 {% endfor %} 38 {% endfor %}
35 return impl; 39 return impl;
36 } 40 }
37 41
38 v8::Handle<v8::Value> toV8({{cpp_class}}* impl, v8::Handle<v8::Object> creationC ontext, v8::Isolate* isolate) 42 v8::Handle<v8::Value> toV8({{cpp_class}}* impl, v8::Handle<v8::Object> creationC ontext, v8::Isolate* isolate)
39 { 43 {
40 v8::Handle<v8::Object> v8Object = v8::Object::New(isolate); 44 v8::Handle<v8::Object> v8Object = v8::Object::New(isolate);
41 {% for member in members %} 45 {% for member in members %}
42 if (impl->{{member.has_method_name}}()) 46 if (impl->{{member.has_method_name}}())
43 v8Object->Set(v8String(isolate, "{{member.name}}"), {{member.cpp_value_t o_v8_value}}); 47 v8Object->Set(v8String(isolate, "{{member.name}}"), {{member.cpp_value_t o_v8_value}});
44 {% if member.v8_default_value %} 48 {% if member.v8_default_value %}
45 else 49 else
46 v8Object->Set(v8String(isolate, "{{member.name}}"), {{member.v8_default_ value}}); 50 v8Object->Set(v8String(isolate, "{{member.name}}"), {{member.v8_default_ value}});
47 {% endif %} 51 {% endif %}
48 {% endfor %} 52 {% endfor %}
49 return v8Object; 53 return v8Object;
50 } 54 }
51 55
52 } // namespace blink 56 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/tests/results/core/V8TestDictionary.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698