Index: Source/bindings/tests/results/core/V8TestInterface.cpp |
diff --git a/Source/bindings/tests/results/core/V8TestInterface.cpp b/Source/bindings/tests/results/core/V8TestInterface.cpp |
index d67f1284b627985b322d248fab9dfb21ade96031..5e610ab29176952ce935d5bf57ffbb5d7f196083 100644 |
--- a/Source/bindings/tests/results/core/V8TestInterface.cpp |
+++ b/Source/bindings/tests/results/core/V8TestInterface.cpp |
@@ -281,9 +281,14 @@ static void testEnumAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const |
V8StringResource<> cppValue = v8Value; |
if (!cppValue.prepare()) |
return; |
- String string = cppValue; |
- if (!(string == "" || string == "EnumValue1" || string == "EnumValue2" || string == "EnumValue3")) { |
- currentExecutionContext(info.GetIsolate())->addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel, "The provided value '" + string + "' is not a valid value of type 'TestEnum'.")); |
+ static const char* validValues[] = { |
+ "", |
+ "EnumValue1", |
+ "EnumValue2", |
+ "EnumValue3", |
+ }; |
+ if (!isValidEnum(cppValue, validValues, WTF_ARRAY_LENGTH(validValues))) { |
+ currentExecutionContext(info.GetIsolate())->addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel, "The provided value '" + toCoreString(info.GetIsolate(), v8Value) + "' is not a valid value of type 'TestEnum'.")); |
haraken
2015/04/01 00:29:45
Ditto. Can we use cppValue instead of toCoreString
bashi
2015/04/01 00:50:57
Ditto. An attribute can be a vector.
|
return; |
} |
impl->setTestEnumAttribute(cppValue); |
@@ -963,9 +968,12 @@ static void partialPartialEnumTypeAttributeAttributeSetter(v8::Local<v8::Value> |
V8StringResource<> cppValue = v8Value; |
if (!cppValue.prepare()) |
return; |
- String string = cppValue; |
- if (!(string == "foo" || string == "bar")) { |
- currentExecutionContext(info.GetIsolate())->addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel, "The provided value '" + string + "' is not a valid value of type 'PartialEnumType'.")); |
+ static const char* validValues[] = { |
+ "foo", |
+ "bar", |
+ }; |
+ if (!isValidEnum(cppValue, validValues, WTF_ARRAY_LENGTH(validValues))) { |
+ currentExecutionContext(info.GetIsolate())->addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel, "The provided value '" + toCoreString(info.GetIsolate(), v8Value) + "' is not a valid value of type 'PartialEnumType'.")); |
return; |
} |
TestPartialInterface::setPartialPartialEnumTypeAttribute(*impl, cppValue); |
@@ -1179,9 +1187,14 @@ static void voidMethodTestEnumArgMethod(const v8::FunctionCallbackInfo<v8::Value |
testEnumArg = info[0]; |
if (!testEnumArg.prepare()) |
return; |
- String string = testEnumArg; |
- if (!(string == "" || string == "EnumValue1" || string == "EnumValue2" || string == "EnumValue3")) { |
- V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::failedToExecute("voidMethodTestEnumArg", "TestInterface", "parameter 1 ('" + string + "') is not a valid enum value.")); |
+ static const char* validValues[] = { |
+ "", |
+ "EnumValue1", |
+ "EnumValue2", |
+ "EnumValue3", |
+ }; |
+ if (!isValidEnum(testEnumArg, validValues, WTF_ARRAY_LENGTH(validValues))) { |
+ V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::failedToExecute("voidMethodTestEnumArg", "TestInterface", "parameter 1 ('" + toCoreString(info.GetIsolate(), info[0]) + "') is not a valid enum value.")); |
return; |
} |
} |