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