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

Side by Side Diff: Source/bindings/tests/results/core/V8TestInterface.cpp

Issue 1047993002: bindings: Add validation for enum Sequence or Array (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_v8.py. DO NOT MODIFY! 5 // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY!
6 6
7 #include "config.h" 7 #include "config.h"
8 #if ENABLE(CONDITION) 8 #if ENABLE(CONDITION)
9 #include "V8TestInterface.h" 9 #include "V8TestInterface.h"
10 10
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 274 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
275 } 275 }
276 276
277 static void testEnumAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 277 static void testEnumAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
278 { 278 {
279 v8::Local<v8::Object> holder = info.Holder(); 279 v8::Local<v8::Object> holder = info.Holder();
280 TestInterfaceImplementation* impl = V8TestInterface::toImpl(holder); 280 TestInterfaceImplementation* impl = V8TestInterface::toImpl(holder);
281 V8StringResource<> cppValue = v8Value; 281 V8StringResource<> cppValue = v8Value;
282 if (!cppValue.prepare()) 282 if (!cppValue.prepare())
283 return; 283 return;
284 String string = cppValue; 284 static const char* validValues[] = {
285 if (!(string == "" || string == "EnumValue1" || string == "EnumValue2" || st ring == "EnumValue3")) { 285 "",
286 currentExecutionContext(info.GetIsolate())->addConsoleMessage(ConsoleMes sage::create(JSMessageSource, WarningMessageLevel, "The provided value '" + stri ng + "' is not a valid value of type 'TestEnum'.")); 286 "EnumValue1",
287 "EnumValue2",
288 "EnumValue3",
289 };
290 if (!isValidEnum(cppValue, validValues, WTF_ARRAY_LENGTH(validValues))) {
291 currentExecutionContext(info.GetIsolate())->addConsoleMessage(ConsoleMes sage::create(JSMessageSource, WarningMessageLevel, "The provided value '" + toCo reString(info.GetIsolate(), v8Value) + "' is not a valid value of type 'TestEnum '."));
287 return; 292 return;
288 } 293 }
289 impl->setTestEnumAttribute(cppValue); 294 impl->setTestEnumAttribute(cppValue);
290 } 295 }
291 296
292 static void testEnumAttributeAttributeSetterCallback(v8::Local<v8::Name>, v8::Lo cal<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 297 static void testEnumAttributeAttributeSetterCallback(v8::Local<v8::Name>, v8::Lo cal<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
293 { 298 {
294 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); 299 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
295 TestInterfaceImplementationV8Internal::testEnumAttributeAttributeSetter(v8Va lue, info); 300 TestInterfaceImplementationV8Internal::testEnumAttributeAttributeSetter(v8Va lue, info);
296 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 301 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 #endif // ENABLE(PARTIAL_CONDITION) 961 #endif // ENABLE(PARTIAL_CONDITION)
957 962
958 #if ENABLE(PARTIAL_CONDITION) 963 #if ENABLE(PARTIAL_CONDITION)
959 static void partialPartialEnumTypeAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 964 static void partialPartialEnumTypeAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
960 { 965 {
961 v8::Local<v8::Object> holder = info.Holder(); 966 v8::Local<v8::Object> holder = info.Holder();
962 TestInterfaceImplementation* impl = V8TestInterface::toImpl(holder); 967 TestInterfaceImplementation* impl = V8TestInterface::toImpl(holder);
963 V8StringResource<> cppValue = v8Value; 968 V8StringResource<> cppValue = v8Value;
964 if (!cppValue.prepare()) 969 if (!cppValue.prepare())
965 return; 970 return;
966 String string = cppValue; 971 static const char* validValues[] = {
967 if (!(string == "foo" || string == "bar")) { 972 "foo",
968 currentExecutionContext(info.GetIsolate())->addConsoleMessage(ConsoleMes sage::create(JSMessageSource, WarningMessageLevel, "The provided value '" + stri ng + "' is not a valid value of type 'PartialEnumType'.")); 973 "bar",
974 };
975 if (!isValidEnum(cppValue, validValues, WTF_ARRAY_LENGTH(validValues))) {
976 currentExecutionContext(info.GetIsolate())->addConsoleMessage(ConsoleMes sage::create(JSMessageSource, WarningMessageLevel, "The provided value '" + toCo reString(info.GetIsolate(), v8Value) + "' is not a valid value of type 'PartialE numType'."));
969 return; 977 return;
970 } 978 }
971 TestPartialInterface::setPartialPartialEnumTypeAttribute(*impl, cppValue); 979 TestPartialInterface::setPartialPartialEnumTypeAttribute(*impl, cppValue);
972 } 980 }
973 #endif // ENABLE(PARTIAL_CONDITION) 981 #endif // ENABLE(PARTIAL_CONDITION)
974 982
975 #if ENABLE(PARTIAL_CONDITION) 983 #if ENABLE(PARTIAL_CONDITION)
976 static void partialPartialEnumTypeAttributeAttributeSetterCallback(v8::Local<v8: :Name>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info ) 984 static void partialPartialEnumTypeAttributeAttributeSetterCallback(v8::Local<v8: :Name>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info )
977 { 985 {
978 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); 986 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 if (UNLIKELY(info.Length() < 1)) { 1180 if (UNLIKELY(info.Length() < 1)) {
1173 V8ThrowException::throwException(createMinimumArityTypeErrorForMethod(in fo.GetIsolate(), "voidMethodTestEnumArg", "TestInterface", 1, info.Length()), in fo.GetIsolate()); 1181 V8ThrowException::throwException(createMinimumArityTypeErrorForMethod(in fo.GetIsolate(), "voidMethodTestEnumArg", "TestInterface", 1, info.Length()), in fo.GetIsolate());
1174 return; 1182 return;
1175 } 1183 }
1176 TestInterfaceImplementation* impl = V8TestInterface::toImpl(info.Holder()); 1184 TestInterfaceImplementation* impl = V8TestInterface::toImpl(info.Holder());
1177 V8StringResource<> testEnumArg; 1185 V8StringResource<> testEnumArg;
1178 { 1186 {
1179 testEnumArg = info[0]; 1187 testEnumArg = info[0];
1180 if (!testEnumArg.prepare()) 1188 if (!testEnumArg.prepare())
1181 return; 1189 return;
1182 String string = testEnumArg; 1190 static const char* validValues[] = {
1183 if (!(string == "" || string == "EnumValue1" || string == "EnumValue2" | | string == "EnumValue3")) { 1191 "",
1184 V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessage s::failedToExecute("voidMethodTestEnumArg", "TestInterface", "parameter 1 ('" + string + "') is not a valid enum value.")); 1192 "EnumValue1",
1193 "EnumValue2",
1194 "EnumValue3",
1195 };
1196 if (!isValidEnum(testEnumArg, validValues, WTF_ARRAY_LENGTH(validValues) )) {
1197 V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessage s::failedToExecute("voidMethodTestEnumArg", "TestInterface", "parameter 1 ('" + toCoreString(info.GetIsolate(), info[0]) + "') is not a valid enum value."));
1185 return; 1198 return;
1186 } 1199 }
1187 } 1200 }
1188 impl->voidMethodTestEnumArg(testEnumArg); 1201 impl->voidMethodTestEnumArg(testEnumArg);
1189 } 1202 }
1190 1203
1191 static void voidMethodTestEnumArgMethodCallback(const v8::FunctionCallbackInfo<v 8::Value>& info) 1204 static void voidMethodTestEnumArgMethodCallback(const v8::FunctionCallbackInfo<v 8::Value>& info)
1192 { 1205 {
1193 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 1206 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
1194 TestInterfaceImplementationV8Internal::voidMethodTestEnumArgMethod(info); 1207 TestInterfaceImplementationV8Internal::voidMethodTestEnumArgMethod(info);
(...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after
2559 void V8TestInterface::registerPartial2VoidMethodMethodForPartialInterface(void ( *method)(const v8::FunctionCallbackInfo<v8::Value>&)) 2572 void V8TestInterface::registerPartial2VoidMethodMethodForPartialInterface(void ( *method)(const v8::FunctionCallbackInfo<v8::Value>&))
2560 { 2573 {
2561 TestInterfaceImplementationV8Internal::partial2VoidMethodMethodForPartialInt erface = method; 2574 TestInterfaceImplementationV8Internal::partial2VoidMethodMethodForPartialInt erface = method;
2562 } 2575 }
2563 void V8TestInterface::registerPartial2StaticVoidMethodMethodForPartialInterface( void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) 2576 void V8TestInterface::registerPartial2StaticVoidMethodMethodForPartialInterface( void (*method)(const v8::FunctionCallbackInfo<v8::Value>&))
2564 { 2577 {
2565 TestInterfaceImplementationV8Internal::partial2StaticVoidMethodMethodForPart ialInterface = method; 2578 TestInterfaceImplementationV8Internal::partial2StaticVoidMethodMethodForPart ialInterface = method;
2566 } 2579 }
2567 } // namespace blink 2580 } // namespace blink
2568 #endif // ENABLE(CONDITION) 2581 #endif // ENABLE(CONDITION)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698