Chromium Code Reviews| Index: Source/bindings/templates/union.cpp |
| diff --git a/Source/bindings/templates/union.cpp b/Source/bindings/templates/union.cpp |
| index cf306ce0eb2fe6794e2f940648ea2cc8e628ffbe..4fc6be8fd0e3f27a5ad36dc4606b0194f01c5209 100644 |
| --- a/Source/bindings/templates/union.cpp |
| +++ b/Source/bindings/templates/union.cpp |
| @@ -36,6 +36,13 @@ namespace blink { |
| void {{container.cpp_class}}::set{{member.type_name}}({{member.rvalue_cpp_type}} value) |
| { |
| ASSERT(isNull()); |
| + {% if member.enum_validation_expression %} |
| + String string = value; |
| + if (!({{member.enum_validation_expression}})) { |
| + ASSERT_NOT_REACHED(); |
| + return; |
| + } |
| + {% endif %} |
| m_{{member.cpp_name}} = value; |
| m_type = {{member.specific_type_enum}}; |
| } |
| @@ -128,6 +135,19 @@ void V8{{container.cpp_class}}::toImpl(v8::Isolate* isolate, v8::Local<v8::Value |
| return; |
| } |
| + {# 16.1 Enum #} |
|
Jens Widell
2015/01/16 09:53:51
If we treat an enum as a string type, this block c
bashi
2015/01/16 10:11:58
Right. Will do when we decide to treat an enum as
|
| + {% elif container.enum_type %} |
| + { |
| + {{container.enum_type.v8_value_to_local_cpp_value}}; |
| + String string = cppValue; |
| + if (!({{container.enum_type.enum_validation_expression}})) { |
| + exceptionState.throwTypeError("'" + string + "' is not a valid enum value."); |
| + return; |
| + } |
| + impl.set{{container.enum_type.type_name}}(cppValue); |
| + return; |
| + } |
| + |
| {# 17. Number (fallback) #} |
| {% elif container.numeric_type %} |
| { |