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

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
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))
haraken 2014/10/15 14:38:28 Can we drop the v8Value->IsObject() check?
bashi 2014/10/17 00:50:05 Ah, maybe we can't. Even though the binding layer
19 return;
20 ASSERT(v8Value->IsObject());
19 21
20 {{cpp_class}}* impl = {{cpp_class}}::create();
21 // FIXME: Do not use Dictionary and DictionaryHelper 22 // FIXME: Do not use Dictionary and DictionaryHelper
22 // https://crbug.com/321462 23 // https://crbug.com/321462
23 Dictionary dictionary(v8Value, isolate); 24 Dictionary dictionary(v8Value, isolate);
24 // FIXME: Remove this v8::TryCatch once the code is switched from 25 // FIXME: Remove this v8::TryCatch once the code is switched from
25 // Dictionary/DictionaryHelper to something that uses ExceptionState. 26 // Dictionary/DictionaryHelper to something that uses ExceptionState.
26 v8::TryCatch block; 27 v8::TryCatch block;
27 {% for member in members %} 28 {% for member in members %}
28 {{member.cpp_type}} {{member.name}}; 29 {{member.cpp_type}} {{member.name}};
29 if (DictionaryHelper::getWithUndefinedOrNullCheck(dictionary, "{{member.name }}", {{member.name}})) { 30 if (DictionaryHelper::getWithUndefinedOrNullCheck(dictionary, "{{member.name }}", {{member.name}})) {
30 {% if member.enum_validation_expression %} 31 {% if member.enum_validation_expression %}
31 String string = {{member.name}}; 32 String string = {{member.name}};
32 if (!({{member.enum_validation_expression}})) { 33 if (!({{member.enum_validation_expression}})) {
33 exceptionState.throwTypeError("member {{member.name}} ('" + string + "') is not a valid enum value."); 34 exceptionState.throwTypeError("member {{member.name}} ('" + string + "') is not a valid enum value.");
34 return 0; 35 return;
35 } 36 }
36 {% elif member.is_object %} 37 {% elif member.is_object %}
37 if (!{{member.name}}.isObject()) { 38 if (!{{member.name}}.isObject()) {
38 exceptionState.throwTypeError("member {{member.name}} is not an obje ct."); 39 exceptionState.throwTypeError("member {{member.name}} is not an obje ct.");
39 return 0; 40 return;
40 } 41 }
41 {% endif %} 42 {% endif %}
42 impl->{{member.setter_name}}({{member.name}}); 43 impl.{{member.setter_name}}({{member.name}});
43 } else if (block.HasCaught()) { 44 } else if (block.HasCaught()) {
44 exceptionState.rethrowV8Exception(block.Exception()); 45 exceptionState.rethrowV8Exception(block.Exception());
45 return 0; 46 return;
46 } 47 }
48
47 {% endfor %} 49 {% endfor %}
48 return impl;
49 } 50 }
50 51
51 v8::Handle<v8::Value> toV8({{cpp_class}}* impl, v8::Handle<v8::Object> creationC ontext, v8::Isolate* isolate) 52 v8::Handle<v8::Value> toV8({{cpp_class}}& impl, v8::Handle<v8::Object> creationC ontext, v8::Isolate* isolate)
52 { 53 {
53 v8::Handle<v8::Object> v8Object = v8::Object::New(isolate); 54 v8::Handle<v8::Object> v8Object = v8::Object::New(isolate);
54 {% for member in members %} 55 {% for member in members %}
55 if (impl->{{member.has_method_name}}()) { 56 if (impl.{{member.has_method_name}}()) {
56 {% if member.is_object %} 57 {% if member.is_object %}
57 ASSERT(impl->{{member.cpp_name}}().isObject()); 58 ASSERT(impl.{{member.cpp_name}}().isObject());
58 {% endif %} 59 {% endif %}
59 v8Object->Set(v8String(isolate, "{{member.name}}"), {{member.cpp_value_t o_v8_value}}); 60 v8Object->Set(v8String(isolate, "{{member.name}}"), {{member.cpp_value_t o_v8_value}});
60 {% if member.v8_default_value %} 61 {% if member.v8_default_value %}
61 } else { 62 } else {
62 v8Object->Set(v8String(isolate, "{{member.name}}"), {{member.v8_default_ value}}); 63 v8Object->Set(v8String(isolate, "{{member.name}}"), {{member.v8_default_ value}});
63 {% endif %} 64 {% endif %}
64 } 65 }
66
65 {% endfor %} 67 {% endfor %}
66 return v8Object; 68 return v8Object;
67 } 69 }
68 70
69 } // namespace blink 71 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698