OLD | NEW |
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_original_class}}.h" | 8 #include "{{v8_original_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 {% macro convert_and_set_member(member) %} | 16 {% macro convert_and_set_member(member) %} |
17 {% endmacro %} | 17 {% endmacro %} |
18 void {{v8_class}}::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, {{
cpp_class}}& impl, ExceptionState& exceptionState) | 18 bool {{v8_class}}::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, {{
cpp_class}}& impl, ExceptionState& exceptionState) |
19 { | 19 { |
20 if (isUndefinedOrNull(v8Value)) | 20 if (isUndefinedOrNull(v8Value)) |
21 return; | 21 return true; |
22 if (!v8Value->IsObject()) { | 22 if (!v8Value->IsObject()) { |
23 {% if use_permissive_dictionary_conversion %} | 23 {% if use_permissive_dictionary_conversion %} |
24 // Do nothing. | 24 // Do nothing. |
| 25 return true; |
25 {% else %} | 26 {% else %} |
26 exceptionState.throwTypeError("cannot convert to dictionary."); | 27 exceptionState.throwTypeError("cannot convert to dictionary."); |
| 28 return false; |
27 {% endif %} | 29 {% endif %} |
28 return; | |
29 } | 30 } |
30 | 31 |
31 {% if parent_v8_class %} | 32 {% if parent_v8_class %} |
32 {{parent_v8_class}}::toImpl(isolate, v8Value, impl, exceptionState); | 33 if (!{{parent_v8_class}}::toImpl(isolate, v8Value, impl, exceptionState)) |
33 if (exceptionState.hadException()) | 34 return false; |
34 return; | |
35 | 35 |
36 {% endif %} | 36 {% endif %} |
37 {# Declare local variables only when the dictionary has members to avoid unu
sed variable warnings. #} | 37 {# Declare local variables only when the dictionary has members to avoid unu
sed variable warnings. #} |
38 {% if members %} | 38 {% if members %} |
39 v8::Local<v8::Object> v8Object = v8Value->ToObject(isolate); | 39 v8::Local<v8::Object> v8Object = v8Value->ToObject(isolate); |
40 v8::TryCatch block; | 40 v8::TryCatch block; |
41 {% endif %} | 41 {% endif %} |
42 {% for member in members %} | 42 {% for member in members %} |
43 v8::Local<v8::Value> {{member.name}}Value = v8Object->Get(v8String(isolate,
"{{member.name}}")); | 43 v8::Local<v8::Value> {{member.name}}Value = v8Object->Get(v8String(isolate,
"{{member.name}}")); |
44 if (block.HasCaught()) { | 44 if (block.HasCaught()) { |
45 exceptionState.rethrowV8Exception(block.Exception()); | 45 exceptionState.rethrowV8Exception(block.Exception()); |
46 return; | 46 return false; |
47 } | 47 } |
48 if ({{member.name}}Value.IsEmpty() || {{member.name}}Value->IsUndefined()) { | 48 if ({{member.name}}Value.IsEmpty() || {{member.name}}Value->IsUndefined()) { |
49 // Do nothing. | 49 // Do nothing. |
50 {% if member.is_nullable %} | 50 {% if member.is_nullable %} |
51 } else if ({{member.name}}Value->IsNull()) { | 51 } else if ({{member.name}}Value->IsNull()) { |
52 impl.{{member.null_setter_name}}(); | 52 impl.{{member.null_setter_name}}(); |
53 {% endif %} | 53 {% endif %} |
54 } else { | 54 } else { |
55 {% if member.deprecate_as %} | 55 {% if member.deprecate_as %} |
56 UseCounter::countDeprecationIfNotPrivateScript(isolate, callingExecution
Context(isolate), UseCounter::{{member.deprecate_as}}); | 56 UseCounter::countDeprecationIfNotPrivateScript(isolate, callingExecution
Context(isolate), UseCounter::{{member.deprecate_as}}); |
57 {% endif %} | 57 {% endif %} |
58 {% if member.use_output_parameter_for_result %} | |
59 {{member.cpp_type}} {{member.name}}; | |
60 {% endif %} | |
61 {{member.v8_value_to_local_cpp_value}}; | 58 {{member.v8_value_to_local_cpp_value}}; |
62 {% if member.is_interface_type %} | 59 {% if member.is_interface_type %} |
63 if (!{{member.name}} && !{{member.name}}Value->IsNull()) { | 60 if (!{{member.name}} && !{{member.name}}Value->IsNull()) { |
64 exceptionState.throwTypeError("member {{member.name}} is not of type
{{member.idl_type}}."); | 61 exceptionState.throwTypeError("member {{member.name}} is not of type
{{member.idl_type}}."); |
65 return; | 62 return false; |
66 } | 63 } |
67 {% endif %} | 64 {% endif %} |
68 {% if member.enum_validation_expression %} | 65 {% if member.enum_validation_expression %} |
69 String string = {{member.name}}; | 66 String string = {{member.name}}; |
70 if (!({{member.enum_validation_expression}})) { | 67 if (!({{member.enum_validation_expression}})) { |
71 exceptionState.throwTypeError("member {{member.name}} ('" + string +
"') is not a valid enum value."); | 68 exceptionState.throwTypeError("member {{member.name}} ('" + string +
"') is not a valid enum value."); |
72 return; | 69 return false; |
73 } | 70 } |
74 {% elif member.is_object %} | 71 {% elif member.is_object %} |
75 if (!{{member.name}}.isObject()) { | 72 if (!{{member.name}}.isObject()) { |
76 exceptionState.throwTypeError("member {{member.name}} is not an obje
ct."); | 73 exceptionState.throwTypeError("member {{member.name}} is not an obje
ct."); |
77 return; | 74 return false; |
78 } | 75 } |
79 {% endif %} | 76 {% endif %} |
80 impl.{{member.setter_name}}({{member.name}}); | 77 impl.{{member.setter_name}}({{member.name}}); |
81 } | 78 } |
82 | 79 |
83 {% endfor %} | 80 {% endfor %} |
| 81 return true; |
84 } | 82 } |
85 | 83 |
86 v8::Local<v8::Value> toV8(const {{cpp_class}}& impl, v8::Local<v8::Object> creat
ionContext, v8::Isolate* isolate) | 84 v8::Local<v8::Value> toV8(const {{cpp_class}}& impl, v8::Local<v8::Object> creat
ionContext, v8::Isolate* isolate) |
87 { | 85 { |
88 v8::Local<v8::Object> v8Object = v8::Object::New(isolate); | 86 v8::Local<v8::Object> v8Object = v8::Object::New(isolate); |
89 {% if parent_v8_class %} | 87 {% if parent_v8_class %} |
90 toV8{{parent_cpp_class}}(impl, v8Object, creationContext, isolate); | 88 toV8{{parent_cpp_class}}(impl, v8Object, creationContext, isolate); |
91 {% endif %} | 89 {% endif %} |
92 toV8{{cpp_class}}(impl, v8Object, creationContext, isolate); | 90 toV8{{cpp_class}}(impl, v8Object, creationContext, isolate); |
93 return v8Object; | 91 return v8Object; |
(...skipping 17 matching lines...) Expand all Loading... |
111 } | 109 } |
112 | 110 |
113 {{cpp_class}} NativeValueTraits<{{cpp_class}}>::nativeValue(const v8::Local<v8::
Value>& value, v8::Isolate* isolate, ExceptionState& exceptionState) | 111 {{cpp_class}} NativeValueTraits<{{cpp_class}}>::nativeValue(const v8::Local<v8::
Value>& value, v8::Isolate* isolate, ExceptionState& exceptionState) |
114 { | 112 { |
115 {{cpp_class}} impl; | 113 {{cpp_class}} impl; |
116 {{v8_class}}::toImpl(isolate, value, impl, exceptionState); | 114 {{v8_class}}::toImpl(isolate, value, impl, exceptionState); |
117 return impl; | 115 return impl; |
118 } | 116 } |
119 | 117 |
120 } // namespace blink | 118 } // namespace blink |
OLD | NEW |