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

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

Issue 871443002: IDL: Further improve indexed/named property setter type checking (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 unified diff | Download patch
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 #include "V8TestInterface2.h" 8 #include "V8TestInterface2.h"
9 9
10 #include "bindings/core/v8/ExceptionState.h" 10 #include "bindings/core/v8/ExceptionState.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 static void setItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 66 static void setItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
67 { 67 {
68 ExceptionState exceptionState(ExceptionState::ExecutionContext, "setItem", " TestInterface2", info.Holder(), info.GetIsolate()); 68 ExceptionState exceptionState(ExceptionState::ExecutionContext, "setItem", " TestInterface2", info.Holder(), info.GetIsolate());
69 if (UNLIKELY(info.Length() < 2)) { 69 if (UNLIKELY(info.Length() < 2)) {
70 setMinimumArityTypeError(exceptionState, 2, info.Length()); 70 setMinimumArityTypeError(exceptionState, 2, info.Length());
71 exceptionState.throwIfNeeded(); 71 exceptionState.throwIfNeeded();
72 return; 72 return;
73 } 73 }
74 TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); 74 TestInterface2* impl = V8TestInterface2::toImpl(info.Holder());
75 unsigned index; 75 unsigned index;
76 V8StringResource<> value; 76 TestInterfaceEmpty* value;
77 { 77 {
78 TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(index, toUInt32(info[0], exception State), exceptionState); 78 TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(index, toUInt32(info[0], exception State), exceptionState);
79 TOSTRING_VOID_INTERNAL(value, info[1]); 79 value = V8TestInterfaceEmpty::toImplWithTypeCheck(info.GetIsolate(), inf o[1]);
80 if (!value) {
81 exceptionState.throwTypeError("parameter 2 is not of type 'TestInter faceEmpty'.");
82 exceptionState.throwIfNeeded();
83 return;
84 }
80 } 85 }
81 String result = impl->setItem(index, value, exceptionState); 86 RefPtr<TestInterfaceEmpty> result = impl->setItem(index, value, exceptionSta te);
82 if (exceptionState.hadException()) { 87 if (exceptionState.hadException()) {
83 exceptionState.throwIfNeeded(); 88 exceptionState.throwIfNeeded();
84 return; 89 return;
85 } 90 }
86 v8SetReturnValueString(info, result, info.GetIsolate()); 91 v8SetReturnValue(info, result.release());
87 } 92 }
88 93
89 static void setItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& inf o) 94 static void setItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& inf o)
90 { 95 {
91 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 96 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
92 TestInterface2V8Internal::setItemMethod(info); 97 TestInterface2V8Internal::setItemMethod(info);
93 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 98 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
94 } 99 }
95 100
96 static void deleteItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 101 static void deleteItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 static void setNamedItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 157 static void setNamedItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
153 { 158 {
154 ExceptionState exceptionState(ExceptionState::ExecutionContext, "setNamedIte m", "TestInterface2", info.Holder(), info.GetIsolate()); 159 ExceptionState exceptionState(ExceptionState::ExecutionContext, "setNamedIte m", "TestInterface2", info.Holder(), info.GetIsolate());
155 if (UNLIKELY(info.Length() < 2)) { 160 if (UNLIKELY(info.Length() < 2)) {
156 setMinimumArityTypeError(exceptionState, 2, info.Length()); 161 setMinimumArityTypeError(exceptionState, 2, info.Length());
157 exceptionState.throwIfNeeded(); 162 exceptionState.throwIfNeeded();
158 return; 163 return;
159 } 164 }
160 TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); 165 TestInterface2* impl = V8TestInterface2::toImpl(info.Holder());
161 V8StringResource<> name; 166 V8StringResource<> name;
162 V8StringResource<> value; 167 TestInterfaceEmpty* value;
163 { 168 {
164 TOSTRING_VOID_INTERNAL(name, info[0]); 169 TOSTRING_VOID_INTERNAL(name, info[0]);
165 TOSTRING_VOID_INTERNAL(value, info[1]); 170 value = V8TestInterfaceEmpty::toImplWithTypeCheck(info.GetIsolate(), inf o[1]);
171 if (!value && !isUndefinedOrNull(info[1])) {
172 exceptionState.throwTypeError("parameter 2 is not of type 'TestInter faceEmpty'.");
173 exceptionState.throwIfNeeded();
174 return;
175 }
166 } 176 }
167 String result = impl->setNamedItem(name, value, exceptionState); 177 RefPtr<TestInterfaceEmpty> result = impl->setNamedItem(name, value, exceptio nState);
168 if (exceptionState.hadException()) { 178 if (exceptionState.hadException()) {
169 exceptionState.throwIfNeeded(); 179 exceptionState.throwIfNeeded();
170 return; 180 return;
171 } 181 }
172 v8SetReturnValueString(info, result, info.GetIsolate()); 182 v8SetReturnValue(info, result.release());
173 } 183 }
174 184
175 static void setNamedItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value> & info) 185 static void setNamedItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value> & info)
176 { 186 {
177 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 187 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
178 TestInterface2V8Internal::setNamedItemMethod(info); 188 TestInterface2V8Internal::setNamedItemMethod(info);
179 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 189 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
180 } 190 }
181 191
182 static void deleteNamedItemMethod(const v8::FunctionCallbackInfo<v8::Value>& inf o) 192 static void deleteNamedItemMethod(const v8::FunctionCallbackInfo<v8::Value>& inf o)
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 static void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCall backInfo<v8::Value>& info) 286 static void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCall backInfo<v8::Value>& info)
277 { 287 {
278 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMIndexedProperty"); 288 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMIndexedProperty");
279 TestInterface2V8Internal::indexedPropertyGetter(index, info); 289 TestInterface2V8Internal::indexedPropertyGetter(index, info);
280 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 290 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
281 } 291 }
282 292
283 static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) 293 static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
284 { 294 {
285 TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); 295 TestInterface2* impl = V8TestInterface2::toImpl(info.Holder());
286 TOSTRING_VOID(V8StringResource<>, propertyValue, v8Value); 296 TestInterfaceEmpty* propertyValue = V8TestInterfaceEmpty::toImplWithTypeChec k(info.GetIsolate(), v8Value);
287 ExceptionState exceptionState(ExceptionState::IndexedSetterContext, "TestInt erface2", info.Holder(), info.GetIsolate()); 297 ExceptionState exceptionState(ExceptionState::IndexedSetterContext, "TestInt erface2", info.Holder(), info.GetIsolate());
298 if (!propertyValue) {
299 exceptionState.throwTypeError("The provided value is not of type 'TestIn terfaceEmpty'.");
300 exceptionState.throwIfNeeded();
301 return;
302 }
288 bool result = impl->setItem(index, propertyValue, exceptionState); 303 bool result = impl->setItem(index, propertyValue, exceptionState);
289 if (exceptionState.throwIfNeeded()) 304 if (exceptionState.throwIfNeeded())
290 return; 305 return;
291 if (!result) 306 if (!result)
292 return; 307 return;
293 v8SetReturnValue(info, v8Value); 308 v8SetReturnValue(info, v8Value);
294 } 309 }
295 310
296 static void indexedPropertySetterCallback(uint32_t index, v8::Local<v8::Value> v 8Value, const v8::PropertyCallbackInfo<v8::Value>& info) 311 static void indexedPropertySetterCallback(uint32_t index, v8::Local<v8::Value> v 8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
297 { 312 {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 auto nameString = name.As<v8::String>(); 369 auto nameString = name.As<v8::String>();
355 if (info.Holder()->HasRealNamedProperty(nameString)) 370 if (info.Holder()->HasRealNamedProperty(nameString))
356 return; 371 return;
357 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(nameString).IsEmpty ()) 372 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(nameString).IsEmpty ())
358 return; 373 return;
359 374
360 v8::String::Utf8Value namedProperty(nameString); 375 v8::String::Utf8Value namedProperty(nameString);
361 ExceptionState exceptionState(ExceptionState::SetterContext, *namedProperty, "TestInterface2", info.Holder(), info.GetIsolate()); 376 ExceptionState exceptionState(ExceptionState::SetterContext, *namedProperty, "TestInterface2", info.Holder(), info.GetIsolate());
362 TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); 377 TestInterface2* impl = V8TestInterface2::toImpl(info.Holder());
363 TOSTRING_VOID(V8StringResource<>, propertyName, nameString); 378 TOSTRING_VOID(V8StringResource<>, propertyName, nameString);
364 TOSTRING_VOID(V8StringResource<>, propertyValue, v8Value); 379 TestInterfaceEmpty* propertyValue = V8TestInterfaceEmpty::toImplWithTypeChec k(info.GetIsolate(), v8Value);
380 if (!propertyValue && !isUndefinedOrNull(v8Value)) {
381 exceptionState.throwTypeError("The provided value is not of type 'TestIn terfaceEmpty'.");
382 exceptionState.throwIfNeeded();
383 return;
384 }
365 bool result = impl->setNamedItem(propertyName, propertyValue, exceptionState ); 385 bool result = impl->setNamedItem(propertyName, propertyValue, exceptionState );
366 if (exceptionState.throwIfNeeded()) 386 if (exceptionState.throwIfNeeded())
367 return; 387 return;
368 if (!result) 388 if (!result)
369 return; 389 return;
370 v8SetReturnValue(info, v8Value); 390 v8SetReturnValue(info, v8Value);
371 } 391 }
372 392
373 static void namedPropertySetterCallback(v8::Local<v8::Name> name, v8::Local<v8:: Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) 393 static void namedPropertySetterCallback(v8::Local<v8::Name> name, v8::Local<v8:: Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
374 { 394 {
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 { 557 {
538 scriptWrappable->toImpl<TestInterface2>()->ref(); 558 scriptWrappable->toImpl<TestInterface2>()->ref();
539 } 559 }
540 560
541 void V8TestInterface2::derefObject(ScriptWrappable* scriptWrappable) 561 void V8TestInterface2::derefObject(ScriptWrappable* scriptWrappable)
542 { 562 {
543 scriptWrappable->toImpl<TestInterface2>()->deref(); 563 scriptWrappable->toImpl<TestInterface2>()->deref();
544 } 564 }
545 565
546 } // namespace blink 566 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/tests/idls/core/TestInterface2.idl ('k') | Source/bindings/tests/results/core/V8TestSpecialOperations.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698