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

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

Issue 740453004: IDL: Basic dictionary inheritance support (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 1 month 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 %}
11 #include "{{filename}}" 11 #include "{{filename}}"
12 {% endfor %} 12 {% endfor %}
13 13
14 namespace blink { 14 namespace blink {
15 15
16 void {{v8_class}}::toImpl(v8::Isolate* isolate, v8::Handle<v8::Value> v8Value, { {cpp_class}}& impl, ExceptionState& exceptionState) 16 void {{v8_class}}::toImpl(v8::Isolate* isolate, v8::Handle<v8::Value> v8Value, { {cpp_class}}& impl, ExceptionState& exceptionState)
17 { 17 {
18 if (isUndefinedOrNull(v8Value)) 18 if (isUndefinedOrNull(v8Value))
19 return; 19 return;
20 if (!v8Value->IsObject()) { 20 if (!v8Value->IsObject()) {
21 exceptionState.throwTypeError("cannot convert to dictionary."); 21 exceptionState.throwTypeError("cannot convert to dictionary.");
22 return; 22 return;
23 } 23 }
24 24
25 {% if parent_v8_class %}
26 {{parent_v8_class}}::toImpl(isolate, v8Value, impl, exceptionState);
27 if (exceptionState.hadException())
28 return;
29
30 {% endif %}
25 // FIXME: Do not use Dictionary and DictionaryHelper 31 // FIXME: Do not use Dictionary and DictionaryHelper
26 // https://crbug.com/321462 32 // https://crbug.com/321462
27 Dictionary dictionary(v8Value, isolate); 33 Dictionary dictionary(v8Value, isolate);
28 // FIXME: Remove this v8::TryCatch once the code is switched from 34 // FIXME: Remove this v8::TryCatch once the code is switched from
29 // Dictionary/DictionaryHelper to something that uses ExceptionState. 35 // Dictionary/DictionaryHelper to something that uses ExceptionState.
30 v8::TryCatch block; 36 v8::TryCatch block;
31 {% for member in members %} 37 {% for member in members %}
32 {{member.cpp_type}} {{member.name}}; 38 {{member.cpp_type}} {{member.name}};
33 if (DictionaryHelper::getWithUndefinedOrNullCheck(dictionary, "{{member.name }}", {{member.name}})) { 39 if (DictionaryHelper::getWithUndefinedOrNullCheck(dictionary, "{{member.name }}", {{member.name}})) {
34 {% if member.enum_validation_expression %} 40 {% if member.enum_validation_expression %}
(...skipping 13 matching lines...) Expand all
48 exceptionState.rethrowV8Exception(block.Exception()); 54 exceptionState.rethrowV8Exception(block.Exception());
49 return; 55 return;
50 } 56 }
51 57
52 {% endfor %} 58 {% endfor %}
53 } 59 }
54 60
55 v8::Handle<v8::Value> toV8({{cpp_class}}& impl, v8::Handle<v8::Object> creationC ontext, v8::Isolate* isolate) 61 v8::Handle<v8::Value> toV8({{cpp_class}}& impl, v8::Handle<v8::Object> creationC ontext, v8::Isolate* isolate)
56 { 62 {
57 v8::Handle<v8::Object> v8Object = v8::Object::New(isolate); 63 v8::Handle<v8::Object> v8Object = v8::Object::New(isolate);
64 {% if parent_v8_class %}
65 toV8{{parent_cpp_class}}(impl, v8Object, creationContext, isolate);
66 {% endif %}
67 toV8{{cpp_class}}(impl, v8Object, creationContext, isolate);
68 return v8Object;
69 }
70
71 void toV8{{cpp_class}}({{cpp_class}}& impl, v8::Handle<v8::Object> dest, v8::Han dle<v8::Object> creationContext, v8::Isolate* isolate)
haraken 2014/11/19 09:11:26 dest => dictionary ?
bashi 2014/11/19 11:04:43 Done.
72 {
58 {% for member in members %} 73 {% for member in members %}
59 if (impl.{{member.has_method_name}}()) { 74 if (impl.{{member.has_method_name}}()) {
60 {% if member.is_object %} 75 {% if member.is_object %}
61 ASSERT(impl.{{member.cpp_name}}().isObject()); 76 ASSERT(impl.{{member.cpp_name}}().isObject());
62 {% endif %} 77 {% endif %}
63 v8Object->Set(v8String(isolate, "{{member.name}}"), {{member.cpp_value_t o_v8_value}}); 78 dest->Set(v8String(isolate, "{{member.name}}"), {{member.cpp_value_to_v8 _value}});
64 {% if member.v8_default_value %} 79 {% if member.v8_default_value %}
65 } else { 80 } else {
66 v8Object->Set(v8String(isolate, "{{member.name}}"), {{member.v8_default_ value}}); 81 dest->Set(v8String(isolate, "{{member.name}}"), {{member.v8_default_valu e}});
67 {% endif %} 82 {% endif %}
68 } 83 }
69 84
70 {% endfor %} 85 {% endfor %}
71 return v8Object;
72 } 86 }
73 87
74 } // namespace blink 88 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698