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

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

Issue 656073002: IDL: Use ALLOW_ONLY_INLINE_ALLOCATION() in dictionaries (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 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/dictionary_v8.h ('k') | Source/bindings/templates/methods.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 void {{v8_class}}::toImpl(v8::Isolate* isolate, v8::Handle<v8::Value> v8Value, { {cpp_class}}& impl, ExceptionState& exceptionState)
17 { 17 {
18 ASSERT(isUndefinedOrNull(v8Value) || v8Value->IsObject()); 18 if (isUndefinedOrNull(v8Value))
19 return;
20 if (!v8Value->IsObject()) {
21 exceptionState.throwTypeError("cannot convert to dictionary.");
22 return;
23 }
19 24
20 {{cpp_class}}* impl = {{cpp_class}}::create();
21 // FIXME: Do not use Dictionary and DictionaryHelper 25 // FIXME: Do not use Dictionary and DictionaryHelper
22 // https://crbug.com/321462 26 // https://crbug.com/321462
23 Dictionary dictionary(v8Value, isolate); 27 Dictionary dictionary(v8Value, isolate);
24 // FIXME: Remove this v8::TryCatch once the code is switched from 28 // FIXME: Remove this v8::TryCatch once the code is switched from
25 // Dictionary/DictionaryHelper to something that uses ExceptionState. 29 // Dictionary/DictionaryHelper to something that uses ExceptionState.
26 v8::TryCatch block; 30 v8::TryCatch block;
27 {% for member in members %} 31 {% for member in members %}
28 {{member.cpp_type}} {{member.name}}; 32 {{member.cpp_type}} {{member.name}};
29 if (DictionaryHelper::getWithUndefinedOrNullCheck(dictionary, "{{member.name }}", {{member.name}})) { 33 if (DictionaryHelper::getWithUndefinedOrNullCheck(dictionary, "{{member.name }}", {{member.name}})) {
30 {% if member.enum_validation_expression %} 34 {% if member.enum_validation_expression %}
31 String string = {{member.name}}; 35 String string = {{member.name}};
32 if (!({{member.enum_validation_expression}})) { 36 if (!({{member.enum_validation_expression}})) {
33 exceptionState.throwTypeError("member {{member.name}} ('" + string + "') is not a valid enum value."); 37 exceptionState.throwTypeError("member {{member.name}} ('" + string + "') is not a valid enum value.");
34 return 0; 38 return;
35 } 39 }
36 {% elif member.is_object %} 40 {% elif member.is_object %}
37 if (!{{member.name}}.isObject()) { 41 if (!{{member.name}}.isObject()) {
38 exceptionState.throwTypeError("member {{member.name}} is not an obje ct."); 42 exceptionState.throwTypeError("member {{member.name}} is not an obje ct.");
39 return 0; 43 return;
40 } 44 }
41 {% endif %} 45 {% endif %}
42 impl->{{member.setter_name}}({{member.name}}); 46 impl.{{member.setter_name}}({{member.name}});
43 } else if (block.HasCaught()) { 47 } else if (block.HasCaught()) {
44 exceptionState.rethrowV8Exception(block.Exception()); 48 exceptionState.rethrowV8Exception(block.Exception());
45 return 0; 49 return;
46 } 50 }
51
47 {% endfor %} 52 {% endfor %}
48 return impl;
49 } 53 }
50 54
51 v8::Handle<v8::Value> toV8({{cpp_class}}* impl, v8::Handle<v8::Object> creationC ontext, v8::Isolate* isolate) 55 v8::Handle<v8::Value> toV8({{cpp_class}}& impl, v8::Handle<v8::Object> creationC ontext, v8::Isolate* isolate)
52 { 56 {
53 v8::Handle<v8::Object> v8Object = v8::Object::New(isolate); 57 v8::Handle<v8::Object> v8Object = v8::Object::New(isolate);
54 {% for member in members %} 58 {% for member in members %}
55 if (impl->{{member.has_method_name}}()) { 59 if (impl.{{member.has_method_name}}()) {
56 {% if member.is_object %} 60 {% if member.is_object %}
57 ASSERT(impl->{{member.cpp_name}}().isObject()); 61 ASSERT(impl.{{member.cpp_name}}().isObject());
58 {% endif %} 62 {% endif %}
59 v8Object->Set(v8String(isolate, "{{member.name}}"), {{member.cpp_value_t o_v8_value}}); 63 v8Object->Set(v8String(isolate, "{{member.name}}"), {{member.cpp_value_t o_v8_value}});
60 {% if member.v8_default_value %} 64 {% if member.v8_default_value %}
61 } else { 65 } else {
62 v8Object->Set(v8String(isolate, "{{member.name}}"), {{member.v8_default_ value}}); 66 v8Object->Set(v8String(isolate, "{{member.name}}"), {{member.v8_default_ value}});
63 {% endif %} 67 {% endif %}
64 } 68 }
69
65 {% endfor %} 70 {% endfor %}
66 return v8Object; 71 return v8Object;
67 } 72 }
68 73
69 } // namespace blink 74 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/templates/dictionary_v8.h ('k') | Source/bindings/templates/methods.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698