OLD | NEW |
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. | 5 // This file has been auto-generated by code_generator_v8.py. |
6 // DO NOT MODIFY! | 6 // DO NOT MODIFY! |
7 | 7 |
8 // This file has been generated from the Jinja2 template in | 8 // This file has been generated from the Jinja2 template in |
9 // third_party/WebKit/Source/bindings/templates/dictionary_v8.cpp.tmpl | 9 // third_party/WebKit/Source/bindings/templates/dictionary_v8.cpp.tmpl |
10 | 10 |
11 // clang-format off | 11 // clang-format off |
12 #include "V8TestDictionaryDerived.h" | 12 #include "V8TestDictionaryDerived.h" |
13 | 13 |
14 #include "bindings/core/v8/ExceptionState.h" | 14 #include "bindings/core/v8/ExceptionState.h" |
15 #include "bindings/core/v8/IDLTypes.h" | 15 #include "bindings/core/v8/IDLTypes.h" |
16 #include "bindings/core/v8/NativeValueTraitsImpl.h" | 16 #include "bindings/core/v8/NativeValueTraitsImpl.h" |
17 #include "bindings/core/v8/V8TestDictionary.h" | 17 #include "bindings/core/v8/V8TestDictionary.h" |
18 | 18 |
19 namespace blink { | 19 namespace blink { |
20 | 20 |
| 21 static const v8::Eternal<v8::Name>* eternalV8TestDictionaryDerivedImplementedAsK
eys(v8::Isolate* isolate) { |
| 22 static const char* const kKeys[] = { |
| 23 "derivedStringMember", |
| 24 "derivedStringMemberWithDefault", |
| 25 "requiredLongMember", |
| 26 "stringOrDoubleSequenceMember", |
| 27 }; |
| 28 return V8PerIsolateData::from(isolate)->findOrCreateEternalNameCache( |
| 29 kKeys, kKeys, WTF_ARRAY_LENGTH(kKeys)); |
| 30 } |
| 31 |
21 void V8TestDictionaryDerivedImplementedAs::toImpl(v8::Isolate* isolate, v8::Loca
l<v8::Value> v8Value, TestDictionaryDerivedImplementedAs& impl, ExceptionState&
exceptionState) { | 32 void V8TestDictionaryDerivedImplementedAs::toImpl(v8::Isolate* isolate, v8::Loca
l<v8::Value> v8Value, TestDictionaryDerivedImplementedAs& impl, ExceptionState&
exceptionState) { |
22 if (isUndefinedOrNull(v8Value)) { | 33 if (isUndefinedOrNull(v8Value)) { |
23 exceptionState.throwTypeError("Missing required member(s): requiredLongMembe
r."); | 34 exceptionState.throwTypeError("Missing required member(s): requiredLongMembe
r."); |
24 return; | 35 return; |
25 } | 36 } |
26 if (!v8Value->IsObject()) { | 37 if (!v8Value->IsObject()) { |
27 exceptionState.throwTypeError("cannot convert to dictionary."); | 38 exceptionState.throwTypeError("cannot convert to dictionary."); |
28 return; | 39 return; |
29 } | 40 } |
30 v8::Local<v8::Object> v8Object = v8Value.As<v8::Object>(); | 41 v8::Local<v8::Object> v8Object = v8Value.As<v8::Object>(); |
31 ALLOW_UNUSED_LOCAL(v8Object); | 42 ALLOW_UNUSED_LOCAL(v8Object); |
32 | 43 |
33 V8TestDictionary::toImpl(isolate, v8Value, impl, exceptionState); | 44 V8TestDictionary::toImpl(isolate, v8Value, impl, exceptionState); |
34 if (exceptionState.hadException()) | 45 if (exceptionState.hadException()) |
35 return; | 46 return; |
36 | 47 |
| 48 const v8::Eternal<v8::Name>* keys = eternalV8TestDictionaryDerivedImplementedA
sKeys(isolate); |
37 v8::TryCatch block(isolate); | 49 v8::TryCatch block(isolate); |
| 50 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
38 v8::Local<v8::Value> derivedStringMemberValue; | 51 v8::Local<v8::Value> derivedStringMemberValue; |
39 if (!v8Object->Get(isolate->GetCurrentContext(), v8AtomicString(isolate, "deri
vedStringMember")).ToLocal(&derivedStringMemberValue)) { | 52 if (!v8Object->Get(context, keys[0].Get(isolate)).ToLocal(&derivedStringMember
Value)) { |
40 exceptionState.rethrowV8Exception(block.Exception()); | 53 exceptionState.rethrowV8Exception(block.Exception()); |
41 return; | 54 return; |
42 } | 55 } |
43 if (derivedStringMemberValue.IsEmpty() || derivedStringMemberValue->IsUndefine
d()) { | 56 if (derivedStringMemberValue.IsEmpty() || derivedStringMemberValue->IsUndefine
d()) { |
44 // Do nothing. | 57 // Do nothing. |
45 } else { | 58 } else { |
46 V8StringResource<> derivedStringMember = derivedStringMemberValue; | 59 V8StringResource<> derivedStringMember = derivedStringMemberValue; |
47 if (!derivedStringMember.prepare(exceptionState)) | 60 if (!derivedStringMember.prepare(exceptionState)) |
48 return; | 61 return; |
49 impl.setDerivedStringMember(derivedStringMember); | 62 impl.setDerivedStringMember(derivedStringMember); |
50 } | 63 } |
51 | 64 |
52 v8::Local<v8::Value> derivedStringMemberWithDefaultValue; | 65 v8::Local<v8::Value> derivedStringMemberWithDefaultValue; |
53 if (!v8Object->Get(isolate->GetCurrentContext(), v8AtomicString(isolate, "deri
vedStringMemberWithDefault")).ToLocal(&derivedStringMemberWithDefaultValue)) { | 66 if (!v8Object->Get(context, keys[1].Get(isolate)).ToLocal(&derivedStringMember
WithDefaultValue)) { |
54 exceptionState.rethrowV8Exception(block.Exception()); | 67 exceptionState.rethrowV8Exception(block.Exception()); |
55 return; | 68 return; |
56 } | 69 } |
57 if (derivedStringMemberWithDefaultValue.IsEmpty() || derivedStringMemberWithDe
faultValue->IsUndefined()) { | 70 if (derivedStringMemberWithDefaultValue.IsEmpty() || derivedStringMemberWithDe
faultValue->IsUndefined()) { |
58 // Do nothing. | 71 // Do nothing. |
59 } else { | 72 } else { |
60 V8StringResource<> derivedStringMemberWithDefault = derivedStringMemberWithD
efaultValue; | 73 V8StringResource<> derivedStringMemberWithDefault = derivedStringMemberWithD
efaultValue; |
61 if (!derivedStringMemberWithDefault.prepare(exceptionState)) | 74 if (!derivedStringMemberWithDefault.prepare(exceptionState)) |
62 return; | 75 return; |
63 impl.setDerivedStringMemberWithDefault(derivedStringMemberWithDefault); | 76 impl.setDerivedStringMemberWithDefault(derivedStringMemberWithDefault); |
64 } | 77 } |
65 | 78 |
66 v8::Local<v8::Value> requiredLongMemberValue; | 79 v8::Local<v8::Value> requiredLongMemberValue; |
67 if (!v8Object->Get(isolate->GetCurrentContext(), v8AtomicString(isolate, "requ
iredLongMember")).ToLocal(&requiredLongMemberValue)) { | 80 if (!v8Object->Get(context, keys[2].Get(isolate)).ToLocal(&requiredLongMemberV
alue)) { |
68 exceptionState.rethrowV8Exception(block.Exception()); | 81 exceptionState.rethrowV8Exception(block.Exception()); |
69 return; | 82 return; |
70 } | 83 } |
71 if (requiredLongMemberValue.IsEmpty() || requiredLongMemberValue->IsUndefined(
)) { | 84 if (requiredLongMemberValue.IsEmpty() || requiredLongMemberValue->IsUndefined(
)) { |
72 exceptionState.throwTypeError("required member requiredLongMember is undefin
ed."); | 85 exceptionState.throwTypeError("required member requiredLongMember is undefin
ed."); |
73 return; | 86 return; |
74 } else { | 87 } else { |
75 int32_t requiredLongMember = NativeValueTraits<IDLLong>::nativeValue(isolate
, requiredLongMemberValue, exceptionState, NormalConversion); | 88 int32_t requiredLongMember = NativeValueTraits<IDLLong>::nativeValue(isolate
, requiredLongMemberValue, exceptionState, NormalConversion); |
76 if (exceptionState.hadException()) | 89 if (exceptionState.hadException()) |
77 return; | 90 return; |
78 impl.setRequiredLongMember(requiredLongMember); | 91 impl.setRequiredLongMember(requiredLongMember); |
79 } | 92 } |
80 | 93 |
81 v8::Local<v8::Value> stringOrDoubleSequenceMemberValue; | 94 v8::Local<v8::Value> stringOrDoubleSequenceMemberValue; |
82 if (!v8Object->Get(isolate->GetCurrentContext(), v8AtomicString(isolate, "stri
ngOrDoubleSequenceMember")).ToLocal(&stringOrDoubleSequenceMemberValue)) { | 95 if (!v8Object->Get(context, keys[3].Get(isolate)).ToLocal(&stringOrDoubleSeque
nceMemberValue)) { |
83 exceptionState.rethrowV8Exception(block.Exception()); | 96 exceptionState.rethrowV8Exception(block.Exception()); |
84 return; | 97 return; |
85 } | 98 } |
86 if (stringOrDoubleSequenceMemberValue.IsEmpty() || stringOrDoubleSequenceMembe
rValue->IsUndefined()) { | 99 if (stringOrDoubleSequenceMemberValue.IsEmpty() || stringOrDoubleSequenceMembe
rValue->IsUndefined()) { |
87 // Do nothing. | 100 // Do nothing. |
88 } else { | 101 } else { |
89 HeapVector<StringOrDouble> stringOrDoubleSequenceMember = toImplArray<HeapVe
ctor<StringOrDouble>>(stringOrDoubleSequenceMemberValue, 0, isolate, exceptionSt
ate); | 102 HeapVector<StringOrDouble> stringOrDoubleSequenceMember = toImplArray<HeapVe
ctor<StringOrDouble>>(stringOrDoubleSequenceMemberValue, 0, isolate, exceptionSt
ate); |
90 if (exceptionState.hadException()) | 103 if (exceptionState.hadException()) |
91 return; | 104 return; |
92 impl.setStringOrDoubleSequenceMember(stringOrDoubleSequenceMember); | 105 impl.setStringOrDoubleSequenceMember(stringOrDoubleSequenceMember); |
93 } | 106 } |
94 } | 107 } |
95 | 108 |
96 v8::Local<v8::Value> TestDictionaryDerivedImplementedAs::toV8Impl(v8::Local<v8::
Object> creationContext, v8::Isolate* isolate) const { | 109 v8::Local<v8::Value> TestDictionaryDerivedImplementedAs::toV8Impl(v8::Local<v8::
Object> creationContext, v8::Isolate* isolate) const { |
97 v8::Local<v8::Object> v8Object = v8::Object::New(isolate); | 110 v8::Local<v8::Object> v8Object = v8::Object::New(isolate); |
98 if (!toV8TestDictionaryDerivedImplementedAs(*this, v8Object, creationContext,
isolate)) | 111 if (!toV8TestDictionaryDerivedImplementedAs(*this, v8Object, creationContext,
isolate)) |
99 return v8::Undefined(isolate); | 112 return v8::Undefined(isolate); |
100 return v8Object; | 113 return v8Object; |
101 } | 114 } |
102 | 115 |
103 bool toV8TestDictionaryDerivedImplementedAs(const TestDictionaryDerivedImplement
edAs& impl, v8::Local<v8::Object> dictionary, v8::Local<v8::Object> creationCont
ext, v8::Isolate* isolate) { | 116 bool toV8TestDictionaryDerivedImplementedAs(const TestDictionaryDerivedImplement
edAs& impl, v8::Local<v8::Object> dictionary, v8::Local<v8::Object> creationCont
ext, v8::Isolate* isolate) { |
104 if (!toV8TestDictionary(impl, dictionary, creationContext, isolate)) | 117 if (!toV8TestDictionary(impl, dictionary, creationContext, isolate)) |
105 return false; | 118 return false; |
106 | 119 |
| 120 const v8::Eternal<v8::Name>* keys = eternalV8TestDictionaryDerivedImplementedA
sKeys(isolate); |
| 121 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
107 v8::Local<v8::Value> derivedStringMemberValue; | 122 v8::Local<v8::Value> derivedStringMemberValue; |
108 bool derivedStringMemberHasValueOrDefault = false; | 123 bool derivedStringMemberHasValueOrDefault = false; |
109 if (impl.hasDerivedStringMember()) { | 124 if (impl.hasDerivedStringMember()) { |
110 derivedStringMemberValue = v8String(isolate, impl.derivedStringMember()); | 125 derivedStringMemberValue = v8String(isolate, impl.derivedStringMember()); |
111 derivedStringMemberHasValueOrDefault = true; | 126 derivedStringMemberHasValueOrDefault = true; |
112 } | 127 } |
113 if (derivedStringMemberHasValueOrDefault && | 128 if (derivedStringMemberHasValueOrDefault && |
114 !v8CallBoolean(dictionary->CreateDataProperty(isolate->GetCurrentContext()
, v8AtomicString(isolate, "derivedStringMember"), derivedStringMemberValue))) { | 129 !v8CallBoolean(dictionary->CreateDataProperty(context, keys[0].Get(isolate
), derivedStringMemberValue))) { |
115 return false; | 130 return false; |
116 } | 131 } |
117 | 132 |
118 v8::Local<v8::Value> derivedStringMemberWithDefaultValue; | 133 v8::Local<v8::Value> derivedStringMemberWithDefaultValue; |
119 bool derivedStringMemberWithDefaultHasValueOrDefault = false; | 134 bool derivedStringMemberWithDefaultHasValueOrDefault = false; |
120 if (impl.hasDerivedStringMemberWithDefault()) { | 135 if (impl.hasDerivedStringMemberWithDefault()) { |
121 derivedStringMemberWithDefaultValue = v8String(isolate, impl.derivedStringMe
mberWithDefault()); | 136 derivedStringMemberWithDefaultValue = v8String(isolate, impl.derivedStringMe
mberWithDefault()); |
122 derivedStringMemberWithDefaultHasValueOrDefault = true; | 137 derivedStringMemberWithDefaultHasValueOrDefault = true; |
123 } else { | 138 } else { |
124 derivedStringMemberWithDefaultValue = v8String(isolate, "default string valu
e"); | 139 derivedStringMemberWithDefaultValue = v8String(isolate, "default string valu
e"); |
125 derivedStringMemberWithDefaultHasValueOrDefault = true; | 140 derivedStringMemberWithDefaultHasValueOrDefault = true; |
126 } | 141 } |
127 if (derivedStringMemberWithDefaultHasValueOrDefault && | 142 if (derivedStringMemberWithDefaultHasValueOrDefault && |
128 !v8CallBoolean(dictionary->CreateDataProperty(isolate->GetCurrentContext()
, v8AtomicString(isolate, "derivedStringMemberWithDefault"), derivedStringMember
WithDefaultValue))) { | 143 !v8CallBoolean(dictionary->CreateDataProperty(context, keys[1].Get(isolate
), derivedStringMemberWithDefaultValue))) { |
129 return false; | 144 return false; |
130 } | 145 } |
131 | 146 |
132 v8::Local<v8::Value> requiredLongMemberValue; | 147 v8::Local<v8::Value> requiredLongMemberValue; |
133 bool requiredLongMemberHasValueOrDefault = false; | 148 bool requiredLongMemberHasValueOrDefault = false; |
134 if (impl.hasRequiredLongMember()) { | 149 if (impl.hasRequiredLongMember()) { |
135 requiredLongMemberValue = v8::Integer::New(isolate, impl.requiredLongMember(
)); | 150 requiredLongMemberValue = v8::Integer::New(isolate, impl.requiredLongMember(
)); |
136 requiredLongMemberHasValueOrDefault = true; | 151 requiredLongMemberHasValueOrDefault = true; |
137 } else { | 152 } else { |
138 NOTREACHED(); | 153 NOTREACHED(); |
139 } | 154 } |
140 if (requiredLongMemberHasValueOrDefault && | 155 if (requiredLongMemberHasValueOrDefault && |
141 !v8CallBoolean(dictionary->CreateDataProperty(isolate->GetCurrentContext()
, v8AtomicString(isolate, "requiredLongMember"), requiredLongMemberValue))) { | 156 !v8CallBoolean(dictionary->CreateDataProperty(context, keys[2].Get(isolate
), requiredLongMemberValue))) { |
142 return false; | 157 return false; |
143 } | 158 } |
144 | 159 |
145 v8::Local<v8::Value> stringOrDoubleSequenceMemberValue; | 160 v8::Local<v8::Value> stringOrDoubleSequenceMemberValue; |
146 bool stringOrDoubleSequenceMemberHasValueOrDefault = false; | 161 bool stringOrDoubleSequenceMemberHasValueOrDefault = false; |
147 if (impl.hasStringOrDoubleSequenceMember()) { | 162 if (impl.hasStringOrDoubleSequenceMember()) { |
148 stringOrDoubleSequenceMemberValue = ToV8(impl.stringOrDoubleSequenceMember()
, creationContext, isolate); | 163 stringOrDoubleSequenceMemberValue = ToV8(impl.stringOrDoubleSequenceMember()
, creationContext, isolate); |
149 stringOrDoubleSequenceMemberHasValueOrDefault = true; | 164 stringOrDoubleSequenceMemberHasValueOrDefault = true; |
150 } | 165 } |
151 if (stringOrDoubleSequenceMemberHasValueOrDefault && | 166 if (stringOrDoubleSequenceMemberHasValueOrDefault && |
152 !v8CallBoolean(dictionary->CreateDataProperty(isolate->GetCurrentContext()
, v8AtomicString(isolate, "stringOrDoubleSequenceMember"), stringOrDoubleSequenc
eMemberValue))) { | 167 !v8CallBoolean(dictionary->CreateDataProperty(context, keys[3].Get(isolate
), stringOrDoubleSequenceMemberValue))) { |
153 return false; | 168 return false; |
154 } | 169 } |
155 | 170 |
156 return true; | 171 return true; |
157 } | 172 } |
158 | 173 |
159 TestDictionaryDerivedImplementedAs NativeValueTraits<TestDictionaryDerivedImplem
entedAs>::nativeValue(v8::Isolate* isolate, v8::Local<v8::Value> value, Exceptio
nState& exceptionState) { | 174 TestDictionaryDerivedImplementedAs NativeValueTraits<TestDictionaryDerivedImplem
entedAs>::nativeValue(v8::Isolate* isolate, v8::Local<v8::Value> value, Exceptio
nState& exceptionState) { |
160 TestDictionaryDerivedImplementedAs impl; | 175 TestDictionaryDerivedImplementedAs impl; |
161 V8TestDictionaryDerivedImplementedAs::toImpl(isolate, value, impl, exceptionSt
ate); | 176 V8TestDictionaryDerivedImplementedAs::toImpl(isolate, value, impl, exceptionSt
ate); |
162 return impl; | 177 return impl; |
163 } | 178 } |
164 | 179 |
165 } // namespace blink | 180 } // namespace blink |
OLD | NEW |