| 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) %} | |
| 17 {% endmacro %} | |
| 18 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) |
| 19 { | 17 { |
| 20 if (isUndefinedOrNull(v8Value)) | 18 if (isUndefinedOrNull(v8Value)) |
| 21 return; | 19 return; |
| 22 if (!v8Value->IsObject()) { | 20 if (!v8Value->IsObject()) { |
| 23 exceptionState.throwTypeError("cannot convert to dictionary."); | 21 exceptionState.throwTypeError("cannot convert to dictionary."); |
| 24 return; | 22 return; |
| 25 } | 23 } |
| 26 | 24 |
| 27 {% if parent_v8_class %} | 25 {% if parent_v8_class %} |
| 28 {{parent_v8_class}}::toImpl(isolate, v8Value, impl, exceptionState); | 26 {{parent_v8_class}}::toImpl(isolate, v8Value, impl, exceptionState); |
| 29 if (exceptionState.hadException()) | 27 if (exceptionState.hadException()) |
| 30 return; | 28 return; |
| 31 | 29 |
| 32 {% endif %} | 30 {% endif %} |
| 33 v8::Local<v8::Object> v8Object = v8Value->ToObject(isolate); | 31 v8::Local<v8::Object> v8Object = v8Value->ToObject(isolate); |
| 34 v8::TryCatch block; | 32 v8::TryCatch block; |
| 35 {% for member in members %} | 33 {% for member in members %} |
| 36 v8::Local<v8::Value> {{member.name}}Value = v8Object->Get(v8String(isolate,
"{{member.name}}")); | 34 v8::Local<v8::Value> {{member.name}}Value = v8Object->Get(v8String(isolate,
"{{member.name}}")); |
| 37 if (block.HasCaught()) { | 35 if (!{{member.name}}Value.IsEmpty() && !isUndefinedOrNull({{member.name}}Val
ue)) { |
| 38 exceptionState.rethrowV8Exception(block.Exception()); | 36 {% if member.use_output_parameter_for_result %} |
| 39 return; | 37 {{member.cpp_type}} {{member.name}}; |
| 40 } | |
| 41 if ({{member.name}}Value.IsEmpty() || {{member.name}}Value->IsUndefined()) { | |
| 42 // Do nothing. | |
| 43 {% if member.is_nullable %} | |
| 44 } else if ({{member.name}}Value->IsNull()) { | |
| 45 impl.{{member.null_setter_name}}(); | |
| 46 {% endif %} | 38 {% endif %} |
| 47 } else { | |
| 48 {% if member.use_output_parameter_for_result %} | |
| 49 {{member.cpp_type}} {{member.name}}; | |
| 50 {% endif %} | |
| 51 {{member.v8_value_to_local_cpp_value}}; | 39 {{member.v8_value_to_local_cpp_value}}; |
| 52 {% if member.enum_validation_expression %} | 40 {% if member.enum_validation_expression %} |
| 53 String string = {{member.name}}; | 41 String string = {{member.name}}; |
| 54 if (!({{member.enum_validation_expression}})) { | 42 if (!({{member.enum_validation_expression}})) { |
| 55 exceptionState.throwTypeError("member {{member.name}} ('" + string +
"') is not a valid enum value."); | 43 exceptionState.throwTypeError("member {{member.name}} ('" + string +
"') is not a valid enum value."); |
| 56 return; | 44 return; |
| 57 } | 45 } |
| 58 {% elif member.is_object %} | 46 {% elif member.is_object %} |
| 59 if (!{{member.name}}.isObject()) { | 47 if (!{{member.name}}.isObject()) { |
| 60 exceptionState.throwTypeError("member {{member.name}} is not an obje
ct."); | 48 exceptionState.throwTypeError("member {{member.name}} is not an obje
ct."); |
| 61 return; | 49 return; |
| 62 } | 50 } |
| 63 {% endif %} | 51 {% endif %} |
| 64 impl.{{member.setter_name}}({{member.name}}); | 52 impl.{{member.setter_name}}({{member.name}}); |
| 53 } else if (block.HasCaught()) { |
| 54 exceptionState.rethrowV8Exception(block.Exception()); |
| 55 return; |
| 65 } | 56 } |
| 66 | 57 |
| 67 {% endfor %} | 58 {% endfor %} |
| 68 } | 59 } |
| 69 | 60 |
| 70 v8::Handle<v8::Value> toV8(const {{cpp_class}}& impl, v8::Handle<v8::Object> cre
ationContext, v8::Isolate* isolate) | 61 v8::Handle<v8::Value> toV8(const {{cpp_class}}& impl, v8::Handle<v8::Object> cre
ationContext, v8::Isolate* isolate) |
| 71 { | 62 { |
| 72 v8::Handle<v8::Object> v8Object = v8::Object::New(isolate); | 63 v8::Handle<v8::Object> v8Object = v8::Object::New(isolate); |
| 73 {% if parent_v8_class %} | 64 {% if parent_v8_class %} |
| 74 toV8{{parent_cpp_class}}(impl, v8Object, creationContext, isolate); | 65 toV8{{parent_cpp_class}}(impl, v8Object, creationContext, isolate); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 101 } | 92 } |
| 102 | 93 |
| 103 {{cpp_class}} NativeValueTraits<{{cpp_class}}>::nativeValue(const v8::Handle<v8:
:Value>& value, v8::Isolate* isolate, ExceptionState& exceptionState) | 94 {{cpp_class}} NativeValueTraits<{{cpp_class}}>::nativeValue(const v8::Handle<v8:
:Value>& value, v8::Isolate* isolate, ExceptionState& exceptionState) |
| 104 { | 95 { |
| 105 {{cpp_class}} impl; | 96 {{cpp_class}} impl; |
| 106 {{v8_class}}::toImpl(isolate, value, impl, exceptionState); | 97 {{v8_class}}::toImpl(isolate, value, impl, exceptionState); |
| 107 return impl; | 98 return impl; |
| 108 } | 99 } |
| 109 | 100 |
| 110 } // namespace blink | 101 } // namespace blink |
| OLD | NEW |