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

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

Issue 590443002: IDL: object type support for IDL dictionary (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
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 %}
(...skipping 15 matching lines...) Expand all
26 v8::TryCatch block; 26 v8::TryCatch block;
27 {% for member in members %} 27 {% for member in members %}
28 {{member.cpp_type}} {{member.name}}; 28 {{member.cpp_type}} {{member.name}};
29 if (DictionaryHelper::getWithUndefinedOrNullCheck(dictionary, "{{member.name }}", {{member.name}})) { 29 if (DictionaryHelper::getWithUndefinedOrNullCheck(dictionary, "{{member.name }}", {{member.name}})) {
30 {% if member.enum_validation_expression %} 30 {% if member.enum_validation_expression %}
31 String string = {{member.name}}; 31 String string = {{member.name}};
32 if (!({{member.enum_validation_expression}})) { 32 if (!({{member.enum_validation_expression}})) {
33 exceptionState.throwTypeError("member {{member.name}} ('" + string + "') is not a valid enum value."); 33 exceptionState.throwTypeError("member {{member.name}} ('" + string + "') is not a valid enum value.");
34 return 0; 34 return 0;
35 } 35 }
36 {% elif member.is_object %}
37 if (!{{member.name}}.isObject()) {
38 exceptionState.throwTypeError("member {{member.name}} is not an obje ct.");
39 return 0;
40 }
36 {% endif %} 41 {% endif %}
37 impl->{{member.setter_name}}({{member.name}}); 42 impl->{{member.setter_name}}({{member.name}});
38 } else if (block.HasCaught()) { 43 } else if (block.HasCaught()) {
39 exceptionState.rethrowV8Exception(block.Exception()); 44 exceptionState.rethrowV8Exception(block.Exception());
40 return 0; 45 return 0;
41 } 46 }
42 {% endfor %} 47 {% endfor %}
43 return impl; 48 return impl;
44 } 49 }
45 50
46 v8::Handle<v8::Value> toV8({{cpp_class}}* impl, v8::Handle<v8::Object> creationC ontext, v8::Isolate* isolate) 51 v8::Handle<v8::Value> toV8({{cpp_class}}* impl, v8::Handle<v8::Object> creationC ontext, v8::Isolate* isolate)
47 { 52 {
48 v8::Handle<v8::Object> v8Object = v8::Object::New(isolate); 53 v8::Handle<v8::Object> v8Object = v8::Object::New(isolate);
49 {% for member in members %} 54 {% for member in members %}
50 if (impl->{{member.has_method_name}}()) 55 if (impl->{{member.has_method_name}}()) {
56 {% if member.is_object %}
57 ASSERT(impl->{{member.name}}().isObject());
58 {% endif %}
51 v8Object->Set(v8String(isolate, "{{member.name}}"), {{member.cpp_value_t o_v8_value}}); 59 v8Object->Set(v8String(isolate, "{{member.name}}"), {{member.cpp_value_t o_v8_value}});
52 {% if member.v8_default_value %} 60 {% if member.v8_default_value %}
53 else 61 } else {
54 v8Object->Set(v8String(isolate, "{{member.name}}"), {{member.v8_default_ value}}); 62 v8Object->Set(v8String(isolate, "{{member.name}}"), {{member.v8_default_ value}});
63 }
Jens Widell 2014/09/24 05:23:05 Replace this and following 3 lines with {% endif
bashi 2014/09/24 05:28:55 Done.
64 {% else %}
65 }
55 {% endif %} 66 {% endif %}
56 {% endfor %} 67 {% endfor %}
57 return v8Object; 68 return v8Object;
58 } 69 }
59 70
60 } // namespace blink 71 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698