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

Unified Diff: Source/bindings/templates/union.cpp

Issue 854113002: IDL: Enumeration support in union types (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
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 %}
{

Powered by Google App Engine
This is Rietveld 408576698