Index: Source/bindings/templates/methods.cpp |
diff --git a/Source/bindings/templates/methods.cpp b/Source/bindings/templates/methods.cpp |
index 865271c40531c6c912a1829f34c4513f3021fdff..eab54045ecca2361b316a7209c789dbf4901c13a 100644 |
--- a/Source/bindings/templates/methods.cpp |
+++ b/Source/bindings/templates/methods.cpp |
@@ -1,4 +1,4 @@ |
-{% from 'conversions.cpp' import v8_value_to_local_cpp_value %} |
+{% from 'conversions.cpp' import declare_enum_validation_variable, v8_value_to_local_cpp_value %} |
{##############################################################################} |
@@ -196,13 +196,13 @@ if (!{{argument.name}}{% if argument.is_nullable %} && !isUndefinedOrNull(info[{ |
{{throw_type_error(method, '"parameter %s is not of type \'%s\'."' % |
(argument.index + 1, argument.idl_type)) | indent}} |
} |
-{% elif argument.enum_validation_expression %} |
+{% elif argument.enum_values %} |
{# Invalid enum values: http://www.w3.org/TR/WebIDL/#idl-enums #} |
-String string = {{argument.name}}; |
-if (!({{argument.enum_validation_expression}})) { |
+{{declare_enum_validation_variable(argument.enum_values)}} |
+if (!isValidEnum({{argument.name}}, validValues, WTF_ARRAY_LENGTH(validValues))) { |
{{throw_type_error(method, |
- '"parameter %s (\'" + string + "\') is not a valid enum value."' % |
- (argument.index + 1)) | indent}} |
+ '"parameter %s (\'" + toCoreString(info.GetIsolate(), info[%s]) + "\') is not a valid enum value."' % |
+ (argument.index + 1, argument.index)) | indent}} |
} |
{% elif argument.idl_type == 'Promise' %} |
{# We require this for our implementation of promises, though not in spec: |