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

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

Issue 1057453002: bindings: Throw TypeError when required dictionary member is undefined (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
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
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 "V8TestDictionaryDerived.h" 8 #include "V8TestDictionaryDerived.h"
9 9
10 #include "bindings/core/v8/ExceptionState.h" 10 #include "bindings/core/v8/ExceptionState.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } 48 }
49 if (derivedStringMemberWithDefaultValue.IsEmpty() || derivedStringMemberWith DefaultValue->IsUndefined()) { 49 if (derivedStringMemberWithDefaultValue.IsEmpty() || derivedStringMemberWith DefaultValue->IsUndefined()) {
50 // Do nothing. 50 // Do nothing.
51 } else { 51 } else {
52 V8StringResource<> derivedStringMemberWithDefault = derivedStringMemberW ithDefaultValue; 52 V8StringResource<> derivedStringMemberWithDefault = derivedStringMemberW ithDefaultValue;
53 if (!derivedStringMemberWithDefault.prepare(exceptionState)) 53 if (!derivedStringMemberWithDefault.prepare(exceptionState))
54 return; 54 return;
55 impl.setDerivedStringMemberWithDefault(derivedStringMemberWithDefault); 55 impl.setDerivedStringMemberWithDefault(derivedStringMemberWithDefault);
56 } 56 }
57 57
58 v8::Local<v8::Value> requiredLongMemberValue = v8Object->Get(v8String(isolat e, "requiredLongMember"));
59 if (block.HasCaught()) {
60 exceptionState.rethrowV8Exception(block.Exception());
61 return;
62 }
63 if (requiredLongMemberValue.IsEmpty() || requiredLongMemberValue->IsUndefine d()) {
64 exceptionState.throwTypeError("required member requiredLongMember is und efined.");
65 return;
66 } else {
67 int requiredLongMember = toInt32(isolate, requiredLongMemberValue, Norma lConversion, exceptionState);
68 if (exceptionState.hadException())
69 return;
70 impl.setRequiredLongMember(requiredLongMember);
71 }
72
58 } 73 }
59 74
60 v8::Local<v8::Value> toV8(const TestDictionaryDerivedImplementedAs& impl, v8::Lo cal<v8::Object> creationContext, v8::Isolate* isolate) 75 v8::Local<v8::Value> toV8(const TestDictionaryDerivedImplementedAs& impl, v8::Lo cal<v8::Object> creationContext, v8::Isolate* isolate)
61 { 76 {
62 v8::Local<v8::Object> v8Object = v8::Object::New(isolate); 77 v8::Local<v8::Object> v8Object = v8::Object::New(isolate);
63 toV8TestDictionary(impl, v8Object, creationContext, isolate); 78 toV8TestDictionary(impl, v8Object, creationContext, isolate);
64 toV8TestDictionaryDerivedImplementedAs(impl, v8Object, creationContext, isol ate); 79 toV8TestDictionaryDerivedImplementedAs(impl, v8Object, creationContext, isol ate);
65 return v8Object; 80 return v8Object;
66 } 81 }
67 82
68 void toV8TestDictionaryDerivedImplementedAs(const TestDictionaryDerivedImplement edAs& impl, v8::Local<v8::Object> dictionary, v8::Local<v8::Object> creationCont ext, v8::Isolate* isolate) 83 void toV8TestDictionaryDerivedImplementedAs(const TestDictionaryDerivedImplement edAs& impl, v8::Local<v8::Object> dictionary, v8::Local<v8::Object> creationCont ext, v8::Isolate* isolate)
69 { 84 {
70 if (impl.hasDerivedStringMember()) { 85 if (impl.hasDerivedStringMember()) {
71 dictionary->Set(v8String(isolate, "derivedStringMember"), v8String(isola te, impl.derivedStringMember())); 86 dictionary->Set(v8String(isolate, "derivedStringMember"), v8String(isola te, impl.derivedStringMember()));
72 } 87 }
73 88
74 if (impl.hasDerivedStringMemberWithDefault()) { 89 if (impl.hasDerivedStringMemberWithDefault()) {
75 dictionary->Set(v8String(isolate, "derivedStringMemberWithDefault"), v8S tring(isolate, impl.derivedStringMemberWithDefault())); 90 dictionary->Set(v8String(isolate, "derivedStringMemberWithDefault"), v8S tring(isolate, impl.derivedStringMemberWithDefault()));
76 } else { 91 } else {
77 dictionary->Set(v8String(isolate, "derivedStringMemberWithDefault"), v8S tring(isolate, String("default string value"))); 92 dictionary->Set(v8String(isolate, "derivedStringMemberWithDefault"), v8S tring(isolate, String("default string value")));
78 } 93 }
79 94
95 if (impl.hasRequiredLongMember()) {
96 dictionary->Set(v8String(isolate, "requiredLongMember"), v8::Integer::Ne w(isolate, impl.requiredLongMember()));
97 } else {
98 ASSERT_NOT_REACHED();
99 }
100
80 } 101 }
81 102
82 TestDictionaryDerivedImplementedAs NativeValueTraits<TestDictionaryDerivedImplem entedAs>::nativeValue(v8::Isolate* isolate, v8::Local<v8::Value> value, Exceptio nState& exceptionState) 103 TestDictionaryDerivedImplementedAs NativeValueTraits<TestDictionaryDerivedImplem entedAs>::nativeValue(v8::Isolate* isolate, v8::Local<v8::Value> value, Exceptio nState& exceptionState)
83 { 104 {
84 TestDictionaryDerivedImplementedAs impl; 105 TestDictionaryDerivedImplementedAs impl;
85 V8TestDictionaryDerivedImplementedAs::toImpl(isolate, value, impl, exception State); 106 V8TestDictionaryDerivedImplementedAs::toImpl(isolate, value, impl, exception State);
86 return impl; 107 return impl;
87 } 108 }
88 109
89 } // namespace blink 110 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/tests/results/core/TestDictionaryDerivedImplementedAs.h ('k') | Source/core/testing/DictionaryTest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698