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

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

Issue 953123003: IDL: Put generated union type containers in separate files (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 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 2015 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 "bindings/core/v8/ArrayBufferOrArrayBufferViewOrDictionary.cpp"
8 #include "bindings/core/v8/UnionTypesCore.h" 8 #include "bindings/core/v8/BooleanOrStringOrUnrestrictedDouble.cpp"
9 9 #include "bindings/core/v8/DoubleOrString.cpp"
10 #include "bindings/core/v8/Dictionary.h" 10 #include "bindings/core/v8/NodeOrNodeList.cpp"
11 #include "bindings/core/v8/UnionTypesCore.h" 11 #include "bindings/core/v8/StringOrArrayBufferOrArrayBufferView.cpp"
12 #include "bindings/core/v8/V8ArrayBuffer.h" 12 #include "bindings/core/v8/StringOrDouble.cpp"
13 #include "bindings/core/v8/V8ArrayBufferView.h" 13 #include "bindings/core/v8/StringOrStringSequence.cpp"
14 #include "bindings/core/v8/V8Node.h" 14 #include "bindings/core/v8/TestEnumOrDouble.cpp"
15 #include "bindings/core/v8/V8NodeList.h" 15 #include "bindings/core/v8/TestInterface2OrUint8Array.cpp"
16 #include "bindings/core/v8/V8TestDictionary.h" 16 #include "bindings/core/v8/TestInterfaceGarbageCollectedOrString.cpp"
17 #include "bindings/core/v8/V8TestInterface.h" 17 #include "bindings/core/v8/TestInterfaceOrLong.cpp"
18 #include "bindings/core/v8/V8TestInterface2.h" 18 #include "bindings/core/v8/TestInterfaceOrTestInterfaceEmpty.cpp"
19 #include "bindings/core/v8/V8TestInterfaceEmpty.h" 19 #include "bindings/core/v8/TestInterfaceWillBeGarbageCollectedOrTestDictionary.c pp"
20 #include "bindings/core/v8/V8TestInterfaceGarbageCollected.h" 20 #include "bindings/core/v8/UnrestrictedDoubleOrString.cpp"
21 #include "bindings/core/v8/V8TestInterfaceWillBeGarbageCollected.h"
22 #include "bindings/core/v8/V8Uint8Array.h"
23 #include "bindings/tests/idls/core/TestImplements2.h"
24 #include "bindings/tests/idls/core/TestImplements3Implementation.h"
25 #include "bindings/tests/idls/core/TestPartialInterface.h"
26 #include "bindings/tests/idls/core/TestPartialInterfaceImplementation.h"
27 #include "core/dom/NameNodeList.h"
28 #include "core/dom/NodeList.h"
29 #include "core/dom/StaticNodeList.h"
30 #include "core/html/LabelsNodeList.h"
31
32 namespace blink {
33
34 ArrayBufferOrArrayBufferViewOrDictionary::ArrayBufferOrArrayBufferViewOrDictiona ry()
35 : m_type(SpecificTypeNone)
36 {
37 }
38
39 PassRefPtr<TestArrayBuffer> ArrayBufferOrArrayBufferViewOrDictionary::getAsArray Buffer() const
40 {
41 ASSERT(isArrayBuffer());
42 return m_arrayBuffer;
43 }
44
45 void ArrayBufferOrArrayBufferViewOrDictionary::setArrayBuffer(PassRefPtr<TestArr ayBuffer> value)
46 {
47 ASSERT(isNull());
48 m_arrayBuffer = value;
49 m_type = SpecificTypeArrayBuffer;
50 }
51
52 ArrayBufferOrArrayBufferViewOrDictionary ArrayBufferOrArrayBufferViewOrDictionar y::fromArrayBuffer(PassRefPtr<TestArrayBuffer> value)
53 {
54 ArrayBufferOrArrayBufferViewOrDictionary container;
55 container.setArrayBuffer(value);
56 return container;
57 }
58
59 PassRefPtr<TestArrayBufferView> ArrayBufferOrArrayBufferViewOrDictionary::getAsA rrayBufferView() const
60 {
61 ASSERT(isArrayBufferView());
62 return m_arrayBufferView;
63 }
64
65 void ArrayBufferOrArrayBufferViewOrDictionary::setArrayBufferView(PassRefPtr<Tes tArrayBufferView> value)
66 {
67 ASSERT(isNull());
68 m_arrayBufferView = value;
69 m_type = SpecificTypeArrayBufferView;
70 }
71
72 ArrayBufferOrArrayBufferViewOrDictionary ArrayBufferOrArrayBufferViewOrDictionar y::fromArrayBufferView(PassRefPtr<TestArrayBufferView> value)
73 {
74 ArrayBufferOrArrayBufferViewOrDictionary container;
75 container.setArrayBufferView(value);
76 return container;
77 }
78
79 Dictionary ArrayBufferOrArrayBufferViewOrDictionary::getAsDictionary() const
80 {
81 ASSERT(isDictionary());
82 return m_dictionary;
83 }
84
85 void ArrayBufferOrArrayBufferViewOrDictionary::setDictionary(Dictionary value)
86 {
87 ASSERT(isNull());
88 m_dictionary = value;
89 m_type = SpecificTypeDictionary;
90 }
91
92 ArrayBufferOrArrayBufferViewOrDictionary ArrayBufferOrArrayBufferViewOrDictionar y::fromDictionary(Dictionary value)
93 {
94 ArrayBufferOrArrayBufferViewOrDictionary container;
95 container.setDictionary(value);
96 return container;
97 }
98
99 void V8ArrayBufferOrArrayBufferViewOrDictionary::toImpl(v8::Isolate* isolate, v8 ::Local<v8::Value> v8Value, ArrayBufferOrArrayBufferViewOrDictionary& impl, Exce ptionState& exceptionState)
100 {
101 if (v8Value.IsEmpty())
102 return;
103
104 if (V8ArrayBuffer::hasInstance(v8Value, isolate)) {
105 RefPtr<TestArrayBuffer> cppValue = V8ArrayBuffer::toImpl(v8::Local<v8::O bject>::Cast(v8Value));
106 impl.setArrayBuffer(cppValue);
107 return;
108 }
109
110 if (V8ArrayBufferView::hasInstance(v8Value, isolate)) {
111 RefPtr<TestArrayBufferView> cppValue = V8ArrayBufferView::toImpl(v8::Loc al<v8::Object>::Cast(v8Value));
112 impl.setArrayBufferView(cppValue);
113 return;
114 }
115
116 if (isUndefinedOrNull(v8Value) || v8Value->IsObject()) {
117 TONATIVE_VOID_EXCEPTIONSTATE(Dictionary, cppValue, Dictionary(v8Value, i solate, exceptionState), exceptionState);
118 impl.setDictionary(cppValue);
119 return;
120 }
121
122 exceptionState.throwTypeError("The provided value is not of type '(ArrayBuff er or ArrayBufferView or Dictionary)'");
123 }
124
125 v8::Local<v8::Value> toV8(const ArrayBufferOrArrayBufferViewOrDictionary& impl, v8::Local<v8::Object> creationContext, v8::Isolate* isolate)
126 {
127 switch (impl.m_type) {
128 case ArrayBufferOrArrayBufferViewOrDictionary::SpecificTypeNone:
129 return v8::Null(isolate);
130 case ArrayBufferOrArrayBufferViewOrDictionary::SpecificTypeArrayBuffer:
131 return toV8(impl.getAsArrayBuffer(), creationContext, isolate);
132 case ArrayBufferOrArrayBufferViewOrDictionary::SpecificTypeArrayBufferView:
133 return toV8(impl.getAsArrayBufferView(), creationContext, isolate);
134 case ArrayBufferOrArrayBufferViewOrDictionary::SpecificTypeDictionary:
135 return impl.getAsDictionary().v8Value();
136 default:
137 ASSERT_NOT_REACHED();
138 }
139 return v8::Local<v8::Value>();
140 }
141
142 ArrayBufferOrArrayBufferViewOrDictionary NativeValueTraits<ArrayBufferOrArrayBuf ferViewOrDictionary>::nativeValue(const v8::Local<v8::Value>& value, v8::Isolate * isolate, ExceptionState& exceptionState)
143 {
144 ArrayBufferOrArrayBufferViewOrDictionary impl;
145 V8ArrayBufferOrArrayBufferViewOrDictionary::toImpl(isolate, value, impl, exc eptionState);
146 return impl;
147 }
148
149 BooleanOrStringOrUnrestrictedDouble::BooleanOrStringOrUnrestrictedDouble()
150 : m_type(SpecificTypeNone)
151 {
152 }
153
154 bool BooleanOrStringOrUnrestrictedDouble::getAsBoolean() const
155 {
156 ASSERT(isBoolean());
157 return m_boolean;
158 }
159
160 void BooleanOrStringOrUnrestrictedDouble::setBoolean(bool value)
161 {
162 ASSERT(isNull());
163 m_boolean = value;
164 m_type = SpecificTypeBoolean;
165 }
166
167 BooleanOrStringOrUnrestrictedDouble BooleanOrStringOrUnrestrictedDouble::fromBoo lean(bool value)
168 {
169 BooleanOrStringOrUnrestrictedDouble container;
170 container.setBoolean(value);
171 return container;
172 }
173
174 String BooleanOrStringOrUnrestrictedDouble::getAsString() const
175 {
176 ASSERT(isString());
177 return m_string;
178 }
179
180 void BooleanOrStringOrUnrestrictedDouble::setString(String value)
181 {
182 ASSERT(isNull());
183 m_string = value;
184 m_type = SpecificTypeString;
185 }
186
187 BooleanOrStringOrUnrestrictedDouble BooleanOrStringOrUnrestrictedDouble::fromStr ing(String value)
188 {
189 BooleanOrStringOrUnrestrictedDouble container;
190 container.setString(value);
191 return container;
192 }
193
194 double BooleanOrStringOrUnrestrictedDouble::getAsUnrestrictedDouble() const
195 {
196 ASSERT(isUnrestrictedDouble());
197 return m_unrestrictedDouble;
198 }
199
200 void BooleanOrStringOrUnrestrictedDouble::setUnrestrictedDouble(double value)
201 {
202 ASSERT(isNull());
203 m_unrestrictedDouble = value;
204 m_type = SpecificTypeUnrestrictedDouble;
205 }
206
207 BooleanOrStringOrUnrestrictedDouble BooleanOrStringOrUnrestrictedDouble::fromUnr estrictedDouble(double value)
208 {
209 BooleanOrStringOrUnrestrictedDouble container;
210 container.setUnrestrictedDouble(value);
211 return container;
212 }
213
214 void V8BooleanOrStringOrUnrestrictedDouble::toImpl(v8::Isolate* isolate, v8::Loc al<v8::Value> v8Value, BooleanOrStringOrUnrestrictedDouble& impl, ExceptionState & exceptionState)
215 {
216 if (v8Value.IsEmpty())
217 return;
218
219 if (v8Value->IsBoolean()) {
220 impl.setBoolean(v8Value->ToBoolean()->Value());
221 return;
222 }
223
224 if (v8Value->IsNumber()) {
225 TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toDouble(v8Value, excepti onState), exceptionState);
226 impl.setUnrestrictedDouble(cppValue);
227 return;
228 }
229
230 {
231 TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exce ptionState);
232 impl.setString(cppValue);
233 return;
234 }
235
236 }
237
238 v8::Local<v8::Value> toV8(const BooleanOrStringOrUnrestrictedDouble& impl, v8::L ocal<v8::Object> creationContext, v8::Isolate* isolate)
239 {
240 switch (impl.m_type) {
241 case BooleanOrStringOrUnrestrictedDouble::SpecificTypeNone:
242 return v8::Null(isolate);
243 case BooleanOrStringOrUnrestrictedDouble::SpecificTypeBoolean:
244 return v8Boolean(impl.getAsBoolean(), isolate);
245 case BooleanOrStringOrUnrestrictedDouble::SpecificTypeString:
246 return v8String(isolate, impl.getAsString());
247 case BooleanOrStringOrUnrestrictedDouble::SpecificTypeUnrestrictedDouble:
248 return v8::Number::New(isolate, impl.getAsUnrestrictedDouble());
249 default:
250 ASSERT_NOT_REACHED();
251 }
252 return v8::Local<v8::Value>();
253 }
254
255 BooleanOrStringOrUnrestrictedDouble NativeValueTraits<BooleanOrStringOrUnrestric tedDouble>::nativeValue(const v8::Local<v8::Value>& value, v8::Isolate* isolate, ExceptionState& exceptionState)
256 {
257 BooleanOrStringOrUnrestrictedDouble impl;
258 V8BooleanOrStringOrUnrestrictedDouble::toImpl(isolate, value, impl, exceptio nState);
259 return impl;
260 }
261
262 DoubleOrString::DoubleOrString()
263 : m_type(SpecificTypeNone)
264 {
265 }
266
267 double DoubleOrString::getAsDouble() const
268 {
269 ASSERT(isDouble());
270 return m_double;
271 }
272
273 void DoubleOrString::setDouble(double value)
274 {
275 ASSERT(isNull());
276 m_double = value;
277 m_type = SpecificTypeDouble;
278 }
279
280 DoubleOrString DoubleOrString::fromDouble(double value)
281 {
282 DoubleOrString container;
283 container.setDouble(value);
284 return container;
285 }
286
287 String DoubleOrString::getAsString() const
288 {
289 ASSERT(isString());
290 return m_string;
291 }
292
293 void DoubleOrString::setString(String value)
294 {
295 ASSERT(isNull());
296 m_string = value;
297 m_type = SpecificTypeString;
298 }
299
300 DoubleOrString DoubleOrString::fromString(String value)
301 {
302 DoubleOrString container;
303 container.setString(value);
304 return container;
305 }
306
307 void V8DoubleOrString::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value , DoubleOrString& impl, ExceptionState& exceptionState)
308 {
309 if (v8Value.IsEmpty())
310 return;
311
312 if (v8Value->IsNumber()) {
313 TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toRestrictedDouble(v8Valu e, exceptionState), exceptionState);
314 impl.setDouble(cppValue);
315 return;
316 }
317
318 {
319 TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exce ptionState);
320 impl.setString(cppValue);
321 return;
322 }
323
324 }
325
326 v8::Local<v8::Value> toV8(const DoubleOrString& impl, v8::Local<v8::Object> crea tionContext, v8::Isolate* isolate)
327 {
328 switch (impl.m_type) {
329 case DoubleOrString::SpecificTypeNone:
330 return v8::Null(isolate);
331 case DoubleOrString::SpecificTypeDouble:
332 return v8::Number::New(isolate, impl.getAsDouble());
333 case DoubleOrString::SpecificTypeString:
334 return v8String(isolate, impl.getAsString());
335 default:
336 ASSERT_NOT_REACHED();
337 }
338 return v8::Local<v8::Value>();
339 }
340
341 DoubleOrString NativeValueTraits<DoubleOrString>::nativeValue(const v8::Local<v8 ::Value>& value, v8::Isolate* isolate, ExceptionState& exceptionState)
342 {
343 DoubleOrString impl;
344 V8DoubleOrString::toImpl(isolate, value, impl, exceptionState);
345 return impl;
346 }
347
348 NodeOrNodeList::NodeOrNodeList()
349 : m_type(SpecificTypeNone)
350 {
351 }
352
353 PassRefPtrWillBeRawPtr<Node> NodeOrNodeList::getAsNode() const
354 {
355 ASSERT(isNode());
356 return m_node;
357 }
358
359 void NodeOrNodeList::setNode(PassRefPtrWillBeRawPtr<Node> value)
360 {
361 ASSERT(isNull());
362 m_node = value;
363 m_type = SpecificTypeNode;
364 }
365
366 NodeOrNodeList NodeOrNodeList::fromNode(PassRefPtrWillBeRawPtr<Node> value)
367 {
368 NodeOrNodeList container;
369 container.setNode(value);
370 return container;
371 }
372
373 PassRefPtrWillBeRawPtr<NodeList> NodeOrNodeList::getAsNodeList() const
374 {
375 ASSERT(isNodeList());
376 return m_nodeList;
377 }
378
379 void NodeOrNodeList::setNodeList(PassRefPtrWillBeRawPtr<NodeList> value)
380 {
381 ASSERT(isNull());
382 m_nodeList = value;
383 m_type = SpecificTypeNodeList;
384 }
385
386 NodeOrNodeList NodeOrNodeList::fromNodeList(PassRefPtrWillBeRawPtr<NodeList> val ue)
387 {
388 NodeOrNodeList container;
389 container.setNodeList(value);
390 return container;
391 }
392
393 DEFINE_TRACE(NodeOrNodeList)
394 {
395 visitor->trace(m_node);
396 visitor->trace(m_nodeList);
397 }
398
399 void V8NodeOrNodeList::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value , NodeOrNodeList& impl, ExceptionState& exceptionState)
400 {
401 if (v8Value.IsEmpty())
402 return;
403
404 if (V8Node::hasInstance(v8Value, isolate)) {
405 RefPtrWillBeRawPtr<Node> cppValue = V8Node::toImpl(v8::Local<v8::Object> ::Cast(v8Value));
406 impl.setNode(cppValue);
407 return;
408 }
409
410 if (V8NodeList::hasInstance(v8Value, isolate)) {
411 RefPtrWillBeRawPtr<NodeList> cppValue = V8NodeList::toImpl(v8::Local<v8: :Object>::Cast(v8Value));
412 impl.setNodeList(cppValue);
413 return;
414 }
415
416 exceptionState.throwTypeError("The provided value is not of type '(Node or N odeList)'");
417 }
418
419 v8::Local<v8::Value> toV8(const NodeOrNodeList& impl, v8::Local<v8::Object> crea tionContext, v8::Isolate* isolate)
420 {
421 switch (impl.m_type) {
422 case NodeOrNodeList::SpecificTypeNone:
423 return v8::Null(isolate);
424 case NodeOrNodeList::SpecificTypeNode:
425 return toV8(impl.getAsNode(), creationContext, isolate);
426 case NodeOrNodeList::SpecificTypeNodeList:
427 return toV8(impl.getAsNodeList(), creationContext, isolate);
428 default:
429 ASSERT_NOT_REACHED();
430 }
431 return v8::Local<v8::Value>();
432 }
433
434 NodeOrNodeList NativeValueTraits<NodeOrNodeList>::nativeValue(const v8::Local<v8 ::Value>& value, v8::Isolate* isolate, ExceptionState& exceptionState)
435 {
436 NodeOrNodeList impl;
437 V8NodeOrNodeList::toImpl(isolate, value, impl, exceptionState);
438 return impl;
439 }
440
441 StringOrArrayBufferOrArrayBufferView::StringOrArrayBufferOrArrayBufferView()
442 : m_type(SpecificTypeNone)
443 {
444 }
445
446 String StringOrArrayBufferOrArrayBufferView::getAsString() const
447 {
448 ASSERT(isString());
449 return m_string;
450 }
451
452 void StringOrArrayBufferOrArrayBufferView::setString(String value)
453 {
454 ASSERT(isNull());
455 m_string = value;
456 m_type = SpecificTypeString;
457 }
458
459 StringOrArrayBufferOrArrayBufferView StringOrArrayBufferOrArrayBufferView::fromS tring(String value)
460 {
461 StringOrArrayBufferOrArrayBufferView container;
462 container.setString(value);
463 return container;
464 }
465
466 PassRefPtr<TestArrayBuffer> StringOrArrayBufferOrArrayBufferView::getAsArrayBuff er() const
467 {
468 ASSERT(isArrayBuffer());
469 return m_arrayBuffer;
470 }
471
472 void StringOrArrayBufferOrArrayBufferView::setArrayBuffer(PassRefPtr<TestArrayBu ffer> value)
473 {
474 ASSERT(isNull());
475 m_arrayBuffer = value;
476 m_type = SpecificTypeArrayBuffer;
477 }
478
479 StringOrArrayBufferOrArrayBufferView StringOrArrayBufferOrArrayBufferView::fromA rrayBuffer(PassRefPtr<TestArrayBuffer> value)
480 {
481 StringOrArrayBufferOrArrayBufferView container;
482 container.setArrayBuffer(value);
483 return container;
484 }
485
486 PassRefPtr<TestArrayBufferView> StringOrArrayBufferOrArrayBufferView::getAsArray BufferView() const
487 {
488 ASSERT(isArrayBufferView());
489 return m_arrayBufferView;
490 }
491
492 void StringOrArrayBufferOrArrayBufferView::setArrayBufferView(PassRefPtr<TestArr ayBufferView> value)
493 {
494 ASSERT(isNull());
495 m_arrayBufferView = value;
496 m_type = SpecificTypeArrayBufferView;
497 }
498
499 StringOrArrayBufferOrArrayBufferView StringOrArrayBufferOrArrayBufferView::fromA rrayBufferView(PassRefPtr<TestArrayBufferView> value)
500 {
501 StringOrArrayBufferOrArrayBufferView container;
502 container.setArrayBufferView(value);
503 return container;
504 }
505
506 void V8StringOrArrayBufferOrArrayBufferView::toImpl(v8::Isolate* isolate, v8::Lo cal<v8::Value> v8Value, StringOrArrayBufferOrArrayBufferView& impl, ExceptionSta te& exceptionState)
507 {
508 if (v8Value.IsEmpty())
509 return;
510
511 if (V8ArrayBuffer::hasInstance(v8Value, isolate)) {
512 RefPtr<TestArrayBuffer> cppValue = V8ArrayBuffer::toImpl(v8::Local<v8::O bject>::Cast(v8Value));
513 impl.setArrayBuffer(cppValue);
514 return;
515 }
516
517 if (V8ArrayBufferView::hasInstance(v8Value, isolate)) {
518 RefPtr<TestArrayBufferView> cppValue = V8ArrayBufferView::toImpl(v8::Loc al<v8::Object>::Cast(v8Value));
519 impl.setArrayBufferView(cppValue);
520 return;
521 }
522
523 {
524 TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exce ptionState);
525 impl.setString(cppValue);
526 return;
527 }
528
529 }
530
531 v8::Local<v8::Value> toV8(const StringOrArrayBufferOrArrayBufferView& impl, v8:: Local<v8::Object> creationContext, v8::Isolate* isolate)
532 {
533 switch (impl.m_type) {
534 case StringOrArrayBufferOrArrayBufferView::SpecificTypeNone:
535 return v8::Null(isolate);
536 case StringOrArrayBufferOrArrayBufferView::SpecificTypeString:
537 return v8String(isolate, impl.getAsString());
538 case StringOrArrayBufferOrArrayBufferView::SpecificTypeArrayBuffer:
539 return toV8(impl.getAsArrayBuffer(), creationContext, isolate);
540 case StringOrArrayBufferOrArrayBufferView::SpecificTypeArrayBufferView:
541 return toV8(impl.getAsArrayBufferView(), creationContext, isolate);
542 default:
543 ASSERT_NOT_REACHED();
544 }
545 return v8::Local<v8::Value>();
546 }
547
548 StringOrArrayBufferOrArrayBufferView NativeValueTraits<StringOrArrayBufferOrArra yBufferView>::nativeValue(const v8::Local<v8::Value>& value, v8::Isolate* isolat e, ExceptionState& exceptionState)
549 {
550 StringOrArrayBufferOrArrayBufferView impl;
551 V8StringOrArrayBufferOrArrayBufferView::toImpl(isolate, value, impl, excepti onState);
552 return impl;
553 }
554
555 StringOrDouble::StringOrDouble()
556 : m_type(SpecificTypeNone)
557 {
558 }
559
560 String StringOrDouble::getAsString() const
561 {
562 ASSERT(isString());
563 return m_string;
564 }
565
566 void StringOrDouble::setString(String value)
567 {
568 ASSERT(isNull());
569 m_string = value;
570 m_type = SpecificTypeString;
571 }
572
573 StringOrDouble StringOrDouble::fromString(String value)
574 {
575 StringOrDouble container;
576 container.setString(value);
577 return container;
578 }
579
580 double StringOrDouble::getAsDouble() const
581 {
582 ASSERT(isDouble());
583 return m_double;
584 }
585
586 void StringOrDouble::setDouble(double value)
587 {
588 ASSERT(isNull());
589 m_double = value;
590 m_type = SpecificTypeDouble;
591 }
592
593 StringOrDouble StringOrDouble::fromDouble(double value)
594 {
595 StringOrDouble container;
596 container.setDouble(value);
597 return container;
598 }
599
600 void V8StringOrDouble::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value , StringOrDouble& impl, ExceptionState& exceptionState)
601 {
602 if (v8Value.IsEmpty())
603 return;
604
605 if (v8Value->IsNumber()) {
606 TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toRestrictedDouble(v8Valu e, exceptionState), exceptionState);
607 impl.setDouble(cppValue);
608 return;
609 }
610
611 {
612 TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exce ptionState);
613 impl.setString(cppValue);
614 return;
615 }
616
617 }
618
619 v8::Local<v8::Value> toV8(const StringOrDouble& impl, v8::Local<v8::Object> crea tionContext, v8::Isolate* isolate)
620 {
621 switch (impl.m_type) {
622 case StringOrDouble::SpecificTypeNone:
623 return v8::Null(isolate);
624 case StringOrDouble::SpecificTypeString:
625 return v8String(isolate, impl.getAsString());
626 case StringOrDouble::SpecificTypeDouble:
627 return v8::Number::New(isolate, impl.getAsDouble());
628 default:
629 ASSERT_NOT_REACHED();
630 }
631 return v8::Local<v8::Value>();
632 }
633
634 StringOrDouble NativeValueTraits<StringOrDouble>::nativeValue(const v8::Local<v8 ::Value>& value, v8::Isolate* isolate, ExceptionState& exceptionState)
635 {
636 StringOrDouble impl;
637 V8StringOrDouble::toImpl(isolate, value, impl, exceptionState);
638 return impl;
639 }
640
641 StringOrStringSequence::StringOrStringSequence()
642 : m_type(SpecificTypeNone)
643 {
644 }
645
646 String StringOrStringSequence::getAsString() const
647 {
648 ASSERT(isString());
649 return m_string;
650 }
651
652 void StringOrStringSequence::setString(String value)
653 {
654 ASSERT(isNull());
655 m_string = value;
656 m_type = SpecificTypeString;
657 }
658
659 StringOrStringSequence StringOrStringSequence::fromString(String value)
660 {
661 StringOrStringSequence container;
662 container.setString(value);
663 return container;
664 }
665
666 const Vector<String>& StringOrStringSequence::getAsStringSequence() const
667 {
668 ASSERT(isStringSequence());
669 return m_stringSequence;
670 }
671
672 void StringOrStringSequence::setStringSequence(const Vector<String>& value)
673 {
674 ASSERT(isNull());
675 m_stringSequence = value;
676 m_type = SpecificTypeStringSequence;
677 }
678
679 StringOrStringSequence StringOrStringSequence::fromStringSequence(const Vector<S tring>& value)
680 {
681 StringOrStringSequence container;
682 container.setStringSequence(value);
683 return container;
684 }
685
686 void V8StringOrStringSequence::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, StringOrStringSequence& impl, ExceptionState& exceptionState)
687 {
688 if (v8Value.IsEmpty())
689 return;
690
691 if (v8Value->IsArray()) {
692 TONATIVE_VOID_EXCEPTIONSTATE(Vector<String>, cppValue, toImplArray<Strin g>(v8Value, 0, isolate, exceptionState), exceptionState);
693 impl.setStringSequence(cppValue);
694 return;
695 }
696
697 {
698 TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exce ptionState);
699 impl.setString(cppValue);
700 return;
701 }
702
703 }
704
705 v8::Local<v8::Value> toV8(const StringOrStringSequence& impl, v8::Local<v8::Obje ct> creationContext, v8::Isolate* isolate)
706 {
707 switch (impl.m_type) {
708 case StringOrStringSequence::SpecificTypeNone:
709 return v8::Null(isolate);
710 case StringOrStringSequence::SpecificTypeString:
711 return v8String(isolate, impl.getAsString());
712 case StringOrStringSequence::SpecificTypeStringSequence:
713 return toV8(impl.getAsStringSequence(), creationContext, isolate);
714 default:
715 ASSERT_NOT_REACHED();
716 }
717 return v8::Local<v8::Value>();
718 }
719
720 StringOrStringSequence NativeValueTraits<StringOrStringSequence>::nativeValue(co nst v8::Local<v8::Value>& value, v8::Isolate* isolate, ExceptionState& exception State)
721 {
722 StringOrStringSequence impl;
723 V8StringOrStringSequence::toImpl(isolate, value, impl, exceptionState);
724 return impl;
725 }
726
727 TestEnumOrDouble::TestEnumOrDouble()
728 : m_type(SpecificTypeNone)
729 {
730 }
731
732 String TestEnumOrDouble::getAsTestEnum() const
733 {
734 ASSERT(isTestEnum());
735 return m_testEnum;
736 }
737
738 void TestEnumOrDouble::setTestEnum(String value)
739 {
740 ASSERT(isNull());
741 String string = value;
742 if (!(string == "" || string == "EnumValue1" || string == "EnumValue2" || st ring == "EnumValue3")) {
743 ASSERT_NOT_REACHED();
744 return;
745 }
746 m_testEnum = value;
747 m_type = SpecificTypeTestEnum;
748 }
749
750 TestEnumOrDouble TestEnumOrDouble::fromTestEnum(String value)
751 {
752 TestEnumOrDouble container;
753 container.setTestEnum(value);
754 return container;
755 }
756
757 double TestEnumOrDouble::getAsDouble() const
758 {
759 ASSERT(isDouble());
760 return m_double;
761 }
762
763 void TestEnumOrDouble::setDouble(double value)
764 {
765 ASSERT(isNull());
766 m_double = value;
767 m_type = SpecificTypeDouble;
768 }
769
770 TestEnumOrDouble TestEnumOrDouble::fromDouble(double value)
771 {
772 TestEnumOrDouble container;
773 container.setDouble(value);
774 return container;
775 }
776
777 void V8TestEnumOrDouble::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Val ue, TestEnumOrDouble& impl, ExceptionState& exceptionState)
778 {
779 if (v8Value.IsEmpty())
780 return;
781
782 if (v8Value->IsNumber()) {
783 TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toRestrictedDouble(v8Valu e, exceptionState), exceptionState);
784 impl.setDouble(cppValue);
785 return;
786 }
787
788 {
789 TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exce ptionState);
790 String string = cppValue;
791 if (!(string == "" || string == "EnumValue1" || string == "EnumValue2" | | string == "EnumValue3")) {
792 exceptionState.throwTypeError("'" + string + "' is not a valid enum value.");
793 return;
794 }
795 impl.setTestEnum(cppValue);
796 return;
797 }
798
799 }
800
801 v8::Local<v8::Value> toV8(const TestEnumOrDouble& impl, v8::Local<v8::Object> cr eationContext, v8::Isolate* isolate)
802 {
803 switch (impl.m_type) {
804 case TestEnumOrDouble::SpecificTypeNone:
805 return v8::Null(isolate);
806 case TestEnumOrDouble::SpecificTypeTestEnum:
807 return v8String(isolate, impl.getAsTestEnum());
808 case TestEnumOrDouble::SpecificTypeDouble:
809 return v8::Number::New(isolate, impl.getAsDouble());
810 default:
811 ASSERT_NOT_REACHED();
812 }
813 return v8::Local<v8::Value>();
814 }
815
816 TestEnumOrDouble NativeValueTraits<TestEnumOrDouble>::nativeValue(const v8::Loca l<v8::Value>& value, v8::Isolate* isolate, ExceptionState& exceptionState)
817 {
818 TestEnumOrDouble impl;
819 V8TestEnumOrDouble::toImpl(isolate, value, impl, exceptionState);
820 return impl;
821 }
822
823 TestInterface2OrUint8Array::TestInterface2OrUint8Array()
824 : m_type(SpecificTypeNone)
825 {
826 }
827
828 PassRefPtr<TestInterface2> TestInterface2OrUint8Array::getAsTestInterface2() con st
829 {
830 ASSERT(isTestInterface2());
831 return m_testInterface2;
832 }
833
834 void TestInterface2OrUint8Array::setTestInterface2(PassRefPtr<TestInterface2> va lue)
835 {
836 ASSERT(isNull());
837 m_testInterface2 = value;
838 m_type = SpecificTypeTestInterface2;
839 }
840
841 TestInterface2OrUint8Array TestInterface2OrUint8Array::fromTestInterface2(PassRe fPtr<TestInterface2> value)
842 {
843 TestInterface2OrUint8Array container;
844 container.setTestInterface2(value);
845 return container;
846 }
847
848 PassRefPtr<DOMUint8Array> TestInterface2OrUint8Array::getAsUint8Array() const
849 {
850 ASSERT(isUint8Array());
851 return m_uint8Array;
852 }
853
854 void TestInterface2OrUint8Array::setUint8Array(PassRefPtr<DOMUint8Array> value)
855 {
856 ASSERT(isNull());
857 m_uint8Array = value;
858 m_type = SpecificTypeUint8Array;
859 }
860
861 TestInterface2OrUint8Array TestInterface2OrUint8Array::fromUint8Array(PassRefPtr <DOMUint8Array> value)
862 {
863 TestInterface2OrUint8Array container;
864 container.setUint8Array(value);
865 return container;
866 }
867
868 void V8TestInterface2OrUint8Array::toImpl(v8::Isolate* isolate, v8::Local<v8::Va lue> v8Value, TestInterface2OrUint8Array& impl, ExceptionState& exceptionState)
869 {
870 if (v8Value.IsEmpty())
871 return;
872
873 if (V8TestInterface2::hasInstance(v8Value, isolate)) {
874 RefPtr<TestInterface2> cppValue = V8TestInterface2::toImpl(v8::Local<v8: :Object>::Cast(v8Value));
875 impl.setTestInterface2(cppValue);
876 return;
877 }
878
879 if (V8Uint8Array::hasInstance(v8Value, isolate)) {
880 RefPtr<DOMUint8Array> cppValue = V8Uint8Array::toImpl(v8::Local<v8::Obje ct>::Cast(v8Value));
881 impl.setUint8Array(cppValue);
882 return;
883 }
884
885 exceptionState.throwTypeError("The provided value is not of type '(TestInter face2 or Uint8Array)'");
886 }
887
888 v8::Local<v8::Value> toV8(const TestInterface2OrUint8Array& impl, v8::Local<v8:: Object> creationContext, v8::Isolate* isolate)
889 {
890 switch (impl.m_type) {
891 case TestInterface2OrUint8Array::SpecificTypeNone:
892 return v8::Null(isolate);
893 case TestInterface2OrUint8Array::SpecificTypeTestInterface2:
894 return toV8(impl.getAsTestInterface2(), creationContext, isolate);
895 case TestInterface2OrUint8Array::SpecificTypeUint8Array:
896 return toV8(impl.getAsUint8Array(), creationContext, isolate);
897 default:
898 ASSERT_NOT_REACHED();
899 }
900 return v8::Local<v8::Value>();
901 }
902
903 TestInterface2OrUint8Array NativeValueTraits<TestInterface2OrUint8Array>::native Value(const v8::Local<v8::Value>& value, v8::Isolate* isolate, ExceptionState& e xceptionState)
904 {
905 TestInterface2OrUint8Array impl;
906 V8TestInterface2OrUint8Array::toImpl(isolate, value, impl, exceptionState);
907 return impl;
908 }
909
910 TestInterfaceGarbageCollectedOrString::TestInterfaceGarbageCollectedOrString()
911 : m_type(SpecificTypeNone)
912 {
913 }
914
915 TestInterfaceGarbageCollected* TestInterfaceGarbageCollectedOrString::getAsTestI nterfaceGarbageCollected() const
916 {
917 ASSERT(isTestInterfaceGarbageCollected());
918 return m_testInterfaceGarbageCollected;
919 }
920
921 void TestInterfaceGarbageCollectedOrString::setTestInterfaceGarbageCollected(Tes tInterfaceGarbageCollected* value)
922 {
923 ASSERT(isNull());
924 m_testInterfaceGarbageCollected = value;
925 m_type = SpecificTypeTestInterfaceGarbageCollected;
926 }
927
928 TestInterfaceGarbageCollectedOrString TestInterfaceGarbageCollectedOrString::fro mTestInterfaceGarbageCollected(TestInterfaceGarbageCollected* value)
929 {
930 TestInterfaceGarbageCollectedOrString container;
931 container.setTestInterfaceGarbageCollected(value);
932 return container;
933 }
934
935 String TestInterfaceGarbageCollectedOrString::getAsString() const
936 {
937 ASSERT(isString());
938 return m_string;
939 }
940
941 void TestInterfaceGarbageCollectedOrString::setString(String value)
942 {
943 ASSERT(isNull());
944 m_string = value;
945 m_type = SpecificTypeString;
946 }
947
948 TestInterfaceGarbageCollectedOrString TestInterfaceGarbageCollectedOrString::fro mString(String value)
949 {
950 TestInterfaceGarbageCollectedOrString container;
951 container.setString(value);
952 return container;
953 }
954
955 DEFINE_TRACE(TestInterfaceGarbageCollectedOrString)
956 {
957 visitor->trace(m_testInterfaceGarbageCollected);
958 }
959
960 void V8TestInterfaceGarbageCollectedOrString::toImpl(v8::Isolate* isolate, v8::L ocal<v8::Value> v8Value, TestInterfaceGarbageCollectedOrString& impl, ExceptionS tate& exceptionState)
961 {
962 if (v8Value.IsEmpty())
963 return;
964
965 if (V8TestInterfaceGarbageCollected::hasInstance(v8Value, isolate)) {
966 RawPtr<TestInterfaceGarbageCollected> cppValue = V8TestInterfaceGarbageC ollected::toImpl(v8::Local<v8::Object>::Cast(v8Value));
967 impl.setTestInterfaceGarbageCollected(cppValue);
968 return;
969 }
970
971 {
972 TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exce ptionState);
973 impl.setString(cppValue);
974 return;
975 }
976
977 }
978
979 v8::Local<v8::Value> toV8(const TestInterfaceGarbageCollectedOrString& impl, v8: :Local<v8::Object> creationContext, v8::Isolate* isolate)
980 {
981 switch (impl.m_type) {
982 case TestInterfaceGarbageCollectedOrString::SpecificTypeNone:
983 return v8::Null(isolate);
984 case TestInterfaceGarbageCollectedOrString::SpecificTypeTestInterfaceGarbage Collected:
985 return toV8(impl.getAsTestInterfaceGarbageCollected(), creationContext, isolate);
986 case TestInterfaceGarbageCollectedOrString::SpecificTypeString:
987 return v8String(isolate, impl.getAsString());
988 default:
989 ASSERT_NOT_REACHED();
990 }
991 return v8::Local<v8::Value>();
992 }
993
994 TestInterfaceGarbageCollectedOrString NativeValueTraits<TestInterfaceGarbageColl ectedOrString>::nativeValue(const v8::Local<v8::Value>& value, v8::Isolate* isol ate, ExceptionState& exceptionState)
995 {
996 TestInterfaceGarbageCollectedOrString impl;
997 V8TestInterfaceGarbageCollectedOrString::toImpl(isolate, value, impl, except ionState);
998 return impl;
999 }
1000
1001 TestInterfaceOrLong::TestInterfaceOrLong()
1002 : m_type(SpecificTypeNone)
1003 {
1004 }
1005
1006 PassRefPtr<TestInterfaceImplementation> TestInterfaceOrLong::getAsTestInterface( ) const
1007 {
1008 ASSERT(isTestInterface());
1009 return m_testInterface;
1010 }
1011
1012 void TestInterfaceOrLong::setTestInterface(PassRefPtr<TestInterfaceImplementatio n> value)
1013 {
1014 ASSERT(isNull());
1015 m_testInterface = value;
1016 m_type = SpecificTypeTestInterface;
1017 }
1018
1019 TestInterfaceOrLong TestInterfaceOrLong::fromTestInterface(PassRefPtr<TestInterf aceImplementation> value)
1020 {
1021 TestInterfaceOrLong container;
1022 container.setTestInterface(value);
1023 return container;
1024 }
1025
1026 int TestInterfaceOrLong::getAsLong() const
1027 {
1028 ASSERT(isLong());
1029 return m_long;
1030 }
1031
1032 void TestInterfaceOrLong::setLong(int value)
1033 {
1034 ASSERT(isNull());
1035 m_long = value;
1036 m_type = SpecificTypeLong;
1037 }
1038
1039 TestInterfaceOrLong TestInterfaceOrLong::fromLong(int value)
1040 {
1041 TestInterfaceOrLong container;
1042 container.setLong(value);
1043 return container;
1044 }
1045
1046 void V8TestInterfaceOrLong::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8 Value, TestInterfaceOrLong& impl, ExceptionState& exceptionState)
1047 {
1048 if (v8Value.IsEmpty())
1049 return;
1050
1051 if (V8TestInterface::hasInstance(v8Value, isolate)) {
1052 RefPtr<TestInterfaceImplementation> cppValue = V8TestInterface::toImpl(v 8::Local<v8::Object>::Cast(v8Value));
1053 impl.setTestInterface(cppValue);
1054 return;
1055 }
1056
1057 if (v8Value->IsNumber()) {
1058 TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionSt ate), exceptionState);
1059 impl.setLong(cppValue);
1060 return;
1061 }
1062
1063 {
1064 TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionSt ate), exceptionState);
1065 impl.setLong(cppValue);
1066 return;
1067 }
1068
1069 }
1070
1071 v8::Local<v8::Value> toV8(const TestInterfaceOrLong& impl, v8::Local<v8::Object> creationContext, v8::Isolate* isolate)
1072 {
1073 switch (impl.m_type) {
1074 case TestInterfaceOrLong::SpecificTypeNone:
1075 return v8::Null(isolate);
1076 case TestInterfaceOrLong::SpecificTypeTestInterface:
1077 return toV8(impl.getAsTestInterface(), creationContext, isolate);
1078 case TestInterfaceOrLong::SpecificTypeLong:
1079 return v8::Integer::New(isolate, impl.getAsLong());
1080 default:
1081 ASSERT_NOT_REACHED();
1082 }
1083 return v8::Local<v8::Value>();
1084 }
1085
1086 TestInterfaceOrLong NativeValueTraits<TestInterfaceOrLong>::nativeValue(const v8 ::Local<v8::Value>& value, v8::Isolate* isolate, ExceptionState& exceptionState)
1087 {
1088 TestInterfaceOrLong impl;
1089 V8TestInterfaceOrLong::toImpl(isolate, value, impl, exceptionState);
1090 return impl;
1091 }
1092
1093 TestInterfaceOrTestInterfaceEmpty::TestInterfaceOrTestInterfaceEmpty()
1094 : m_type(SpecificTypeNone)
1095 {
1096 }
1097
1098 PassRefPtr<TestInterfaceImplementation> TestInterfaceOrTestInterfaceEmpty::getAs TestInterface() const
1099 {
1100 ASSERT(isTestInterface());
1101 return m_testInterface;
1102 }
1103
1104 void TestInterfaceOrTestInterfaceEmpty::setTestInterface(PassRefPtr<TestInterfac eImplementation> value)
1105 {
1106 ASSERT(isNull());
1107 m_testInterface = value;
1108 m_type = SpecificTypeTestInterface;
1109 }
1110
1111 TestInterfaceOrTestInterfaceEmpty TestInterfaceOrTestInterfaceEmpty::fromTestInt erface(PassRefPtr<TestInterfaceImplementation> value)
1112 {
1113 TestInterfaceOrTestInterfaceEmpty container;
1114 container.setTestInterface(value);
1115 return container;
1116 }
1117
1118 PassRefPtr<TestInterfaceEmpty> TestInterfaceOrTestInterfaceEmpty::getAsTestInter faceEmpty() const
1119 {
1120 ASSERT(isTestInterfaceEmpty());
1121 return m_testInterfaceEmpty;
1122 }
1123
1124 void TestInterfaceOrTestInterfaceEmpty::setTestInterfaceEmpty(PassRefPtr<TestInt erfaceEmpty> value)
1125 {
1126 ASSERT(isNull());
1127 m_testInterfaceEmpty = value;
1128 m_type = SpecificTypeTestInterfaceEmpty;
1129 }
1130
1131 TestInterfaceOrTestInterfaceEmpty TestInterfaceOrTestInterfaceEmpty::fromTestInt erfaceEmpty(PassRefPtr<TestInterfaceEmpty> value)
1132 {
1133 TestInterfaceOrTestInterfaceEmpty container;
1134 container.setTestInterfaceEmpty(value);
1135 return container;
1136 }
1137
1138 void V8TestInterfaceOrTestInterfaceEmpty::toImpl(v8::Isolate* isolate, v8::Local <v8::Value> v8Value, TestInterfaceOrTestInterfaceEmpty& impl, ExceptionState& ex ceptionState)
1139 {
1140 if (v8Value.IsEmpty())
1141 return;
1142
1143 if (V8TestInterface::hasInstance(v8Value, isolate)) {
1144 RefPtr<TestInterfaceImplementation> cppValue = V8TestInterface::toImpl(v 8::Local<v8::Object>::Cast(v8Value));
1145 impl.setTestInterface(cppValue);
1146 return;
1147 }
1148
1149 if (V8TestInterfaceEmpty::hasInstance(v8Value, isolate)) {
1150 RefPtr<TestInterfaceEmpty> cppValue = V8TestInterfaceEmpty::toImpl(v8::L ocal<v8::Object>::Cast(v8Value));
1151 impl.setTestInterfaceEmpty(cppValue);
1152 return;
1153 }
1154
1155 exceptionState.throwTypeError("The provided value is not of type '(TestInter face or TestInterfaceEmpty)'");
1156 }
1157
1158 v8::Local<v8::Value> toV8(const TestInterfaceOrTestInterfaceEmpty& impl, v8::Loc al<v8::Object> creationContext, v8::Isolate* isolate)
1159 {
1160 switch (impl.m_type) {
1161 case TestInterfaceOrTestInterfaceEmpty::SpecificTypeNone:
1162 return v8::Null(isolate);
1163 case TestInterfaceOrTestInterfaceEmpty::SpecificTypeTestInterface:
1164 return toV8(impl.getAsTestInterface(), creationContext, isolate);
1165 case TestInterfaceOrTestInterfaceEmpty::SpecificTypeTestInterfaceEmpty:
1166 return toV8(impl.getAsTestInterfaceEmpty(), creationContext, isolate);
1167 default:
1168 ASSERT_NOT_REACHED();
1169 }
1170 return v8::Local<v8::Value>();
1171 }
1172
1173 TestInterfaceOrTestInterfaceEmpty NativeValueTraits<TestInterfaceOrTestInterface Empty>::nativeValue(const v8::Local<v8::Value>& value, v8::Isolate* isolate, Exc eptionState& exceptionState)
1174 {
1175 TestInterfaceOrTestInterfaceEmpty impl;
1176 V8TestInterfaceOrTestInterfaceEmpty::toImpl(isolate, value, impl, exceptionS tate);
1177 return impl;
1178 }
1179
1180 TestInterfaceWillBeGarbageCollectedOrTestDictionary::TestInterfaceWillBeGarbageC ollectedOrTestDictionary()
1181 : m_type(SpecificTypeNone)
1182 {
1183 }
1184
1185 PassRefPtrWillBeRawPtr<TestInterfaceWillBeGarbageCollected> TestInterfaceWillBeG arbageCollectedOrTestDictionary::getAsTestInterfaceWillBeGarbageCollected() cons t
1186 {
1187 ASSERT(isTestInterfaceWillBeGarbageCollected());
1188 return m_testInterfaceWillBeGarbageCollected;
1189 }
1190
1191 void TestInterfaceWillBeGarbageCollectedOrTestDictionary::setTestInterfaceWillBe GarbageCollected(PassRefPtrWillBeRawPtr<TestInterfaceWillBeGarbageCollected> val ue)
1192 {
1193 ASSERT(isNull());
1194 m_testInterfaceWillBeGarbageCollected = value;
1195 m_type = SpecificTypeTestInterfaceWillBeGarbageCollected;
1196 }
1197
1198 TestInterfaceWillBeGarbageCollectedOrTestDictionary TestInterfaceWillBeGarbageCo llectedOrTestDictionary::fromTestInterfaceWillBeGarbageCollected(PassRefPtrWillB eRawPtr<TestInterfaceWillBeGarbageCollected> value)
1199 {
1200 TestInterfaceWillBeGarbageCollectedOrTestDictionary container;
1201 container.setTestInterfaceWillBeGarbageCollected(value);
1202 return container;
1203 }
1204
1205 TestDictionary TestInterfaceWillBeGarbageCollectedOrTestDictionary::getAsTestDic tionary() const
1206 {
1207 ASSERT(isTestDictionary());
1208 return m_testDictionary;
1209 }
1210
1211 void TestInterfaceWillBeGarbageCollectedOrTestDictionary::setTestDictionary(Test Dictionary value)
1212 {
1213 ASSERT(isNull());
1214 m_testDictionary = value;
1215 m_type = SpecificTypeTestDictionary;
1216 }
1217
1218 TestInterfaceWillBeGarbageCollectedOrTestDictionary TestInterfaceWillBeGarbageCo llectedOrTestDictionary::fromTestDictionary(TestDictionary value)
1219 {
1220 TestInterfaceWillBeGarbageCollectedOrTestDictionary container;
1221 container.setTestDictionary(value);
1222 return container;
1223 }
1224
1225 DEFINE_TRACE(TestInterfaceWillBeGarbageCollectedOrTestDictionary)
1226 {
1227 visitor->trace(m_testInterfaceWillBeGarbageCollected);
1228 visitor->trace(m_testDictionary);
1229 }
1230
1231 void V8TestInterfaceWillBeGarbageCollectedOrTestDictionary::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, TestInterfaceWillBeGarbageCollectedOrTest Dictionary& impl, ExceptionState& exceptionState)
1232 {
1233 if (v8Value.IsEmpty())
1234 return;
1235
1236 if (V8TestInterfaceWillBeGarbageCollected::hasInstance(v8Value, isolate)) {
1237 RefPtrWillBeRawPtr<TestInterfaceWillBeGarbageCollected> cppValue = V8Tes tInterfaceWillBeGarbageCollected::toImpl(v8::Local<v8::Object>::Cast(v8Value));
1238 impl.setTestInterfaceWillBeGarbageCollected(cppValue);
1239 return;
1240 }
1241
1242 if (isUndefinedOrNull(v8Value) || v8Value->IsObject()) {
1243 TestDictionary cppValue;
1244 TONATIVE_VOID_EXCEPTIONSTATE_ARGINTERNAL(V8TestDictionary::toImpl(isolat e, v8Value, cppValue, exceptionState), exceptionState);
1245 impl.setTestDictionary(cppValue);
1246 return;
1247 }
1248
1249 exceptionState.throwTypeError("The provided value is not of type '(TestInter faceWillBeGarbageCollected or TestDictionary)'");
1250 }
1251
1252 v8::Local<v8::Value> toV8(const TestInterfaceWillBeGarbageCollectedOrTestDiction ary& impl, v8::Local<v8::Object> creationContext, v8::Isolate* isolate)
1253 {
1254 switch (impl.m_type) {
1255 case TestInterfaceWillBeGarbageCollectedOrTestDictionary::SpecificTypeNone:
1256 return v8::Null(isolate);
1257 case TestInterfaceWillBeGarbageCollectedOrTestDictionary::SpecificTypeTestIn terfaceWillBeGarbageCollected:
1258 return toV8(impl.getAsTestInterfaceWillBeGarbageCollected(), creationCon text, isolate);
1259 case TestInterfaceWillBeGarbageCollectedOrTestDictionary::SpecificTypeTestDi ctionary:
1260 return toV8(impl.getAsTestDictionary(), creationContext, isolate);
1261 default:
1262 ASSERT_NOT_REACHED();
1263 }
1264 return v8::Local<v8::Value>();
1265 }
1266
1267 TestInterfaceWillBeGarbageCollectedOrTestDictionary NativeValueTraits<TestInterf aceWillBeGarbageCollectedOrTestDictionary>::nativeValue(const v8::Local<v8::Valu e>& value, v8::Isolate* isolate, ExceptionState& exceptionState)
1268 {
1269 TestInterfaceWillBeGarbageCollectedOrTestDictionary impl;
1270 V8TestInterfaceWillBeGarbageCollectedOrTestDictionary::toImpl(isolate, value , impl, exceptionState);
1271 return impl;
1272 }
1273
1274 UnrestrictedDoubleOrString::UnrestrictedDoubleOrString()
1275 : m_type(SpecificTypeNone)
1276 {
1277 }
1278
1279 double UnrestrictedDoubleOrString::getAsUnrestrictedDouble() const
1280 {
1281 ASSERT(isUnrestrictedDouble());
1282 return m_unrestrictedDouble;
1283 }
1284
1285 void UnrestrictedDoubleOrString::setUnrestrictedDouble(double value)
1286 {
1287 ASSERT(isNull());
1288 m_unrestrictedDouble = value;
1289 m_type = SpecificTypeUnrestrictedDouble;
1290 }
1291
1292 UnrestrictedDoubleOrString UnrestrictedDoubleOrString::fromUnrestrictedDouble(do uble value)
1293 {
1294 UnrestrictedDoubleOrString container;
1295 container.setUnrestrictedDouble(value);
1296 return container;
1297 }
1298
1299 String UnrestrictedDoubleOrString::getAsString() const
1300 {
1301 ASSERT(isString());
1302 return m_string;
1303 }
1304
1305 void UnrestrictedDoubleOrString::setString(String value)
1306 {
1307 ASSERT(isNull());
1308 m_string = value;
1309 m_type = SpecificTypeString;
1310 }
1311
1312 UnrestrictedDoubleOrString UnrestrictedDoubleOrString::fromString(String value)
1313 {
1314 UnrestrictedDoubleOrString container;
1315 container.setString(value);
1316 return container;
1317 }
1318
1319 void V8UnrestrictedDoubleOrString::toImpl(v8::Isolate* isolate, v8::Local<v8::Va lue> v8Value, UnrestrictedDoubleOrString& impl, ExceptionState& exceptionState)
1320 {
1321 if (v8Value.IsEmpty())
1322 return;
1323
1324 if (v8Value->IsNumber()) {
1325 TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toDouble(v8Value, excepti onState), exceptionState);
1326 impl.setUnrestrictedDouble(cppValue);
1327 return;
1328 }
1329
1330 {
1331 TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exce ptionState);
1332 impl.setString(cppValue);
1333 return;
1334 }
1335
1336 }
1337
1338 v8::Local<v8::Value> toV8(const UnrestrictedDoubleOrString& impl, v8::Local<v8:: Object> creationContext, v8::Isolate* isolate)
1339 {
1340 switch (impl.m_type) {
1341 case UnrestrictedDoubleOrString::SpecificTypeNone:
1342 return v8::Null(isolate);
1343 case UnrestrictedDoubleOrString::SpecificTypeUnrestrictedDouble:
1344 return v8::Number::New(isolate, impl.getAsUnrestrictedDouble());
1345 case UnrestrictedDoubleOrString::SpecificTypeString:
1346 return v8String(isolate, impl.getAsString());
1347 default:
1348 ASSERT_NOT_REACHED();
1349 }
1350 return v8::Local<v8::Value>();
1351 }
1352
1353 UnrestrictedDoubleOrString NativeValueTraits<UnrestrictedDoubleOrString>::native Value(const v8::Local<v8::Value>& value, v8::Isolate* isolate, ExceptionState& e xceptionState)
1354 {
1355 UnrestrictedDoubleOrString impl;
1356 V8UnrestrictedDoubleOrString::toImpl(isolate, value, impl, exceptionState);
1357 return impl;
1358 }
1359
1360 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/tests/results/core/UnionTypesCore.h ('k') | Source/bindings/tests/results/core/UnrestrictedDoubleOrString.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698