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

Side by Side Diff: third_party/WebKit/Source/bindings/tests/results/core/TestInterfaceOrTestInterfaceEmpty.cpp

Issue 1961883002: Generate separate files for union type containers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
(Empty)
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
3 // found in the LICENSE file.
4
5 // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY!
6
7 #include "TestInterfaceOrTestInterfaceEmpty.h"
8
9 #include "bindings/core/v8/ToV8.h"
10 #include "bindings/core/v8/V8TestInterface.h"
11 #include "bindings/core/v8/V8TestInterfaceEmpty.h"
12 #include "bindings/tests/idls/core/TestImplements2.h"
13 #include "bindings/tests/idls/core/TestImplements3Implementation.h"
14 #include "bindings/tests/idls/core/TestPartialInterface.h"
15 #include "bindings/tests/idls/core/TestPartialInterfaceImplementation.h"
16
17 namespace blink {
18
19 TestInterfaceOrTestInterfaceEmpty::TestInterfaceOrTestInterfaceEmpty()
20 : m_type(SpecificTypeNone)
21 {
22 }
23
24 TestInterfaceImplementation* TestInterfaceOrTestInterfaceEmpty::getAsTestInterfa ce() const
25 {
26 ASSERT(isTestInterface());
27 return m_testInterface;
28 }
29
30 void TestInterfaceOrTestInterfaceEmpty::setTestInterface(TestInterfaceImplementa tion* value)
31 {
32 ASSERT(isNull());
33 m_testInterface = value;
34 m_type = SpecificTypeTestInterface;
35 }
36
37 TestInterfaceOrTestInterfaceEmpty TestInterfaceOrTestInterfaceEmpty::fromTestInt erface(TestInterfaceImplementation* value)
38 {
39 TestInterfaceOrTestInterfaceEmpty container;
40 container.setTestInterface(value);
41 return container;
42 }
43
44 TestInterfaceEmpty* TestInterfaceOrTestInterfaceEmpty::getAsTestInterfaceEmpty() const
45 {
46 ASSERT(isTestInterfaceEmpty());
47 return m_testInterfaceEmpty;
48 }
49
50 void TestInterfaceOrTestInterfaceEmpty::setTestInterfaceEmpty(TestInterfaceEmpty * value)
51 {
52 ASSERT(isNull());
53 m_testInterfaceEmpty = value;
54 m_type = SpecificTypeTestInterfaceEmpty;
55 }
56
57 TestInterfaceOrTestInterfaceEmpty TestInterfaceOrTestInterfaceEmpty::fromTestInt erfaceEmpty(TestInterfaceEmpty* value)
58 {
59 TestInterfaceOrTestInterfaceEmpty container;
60 container.setTestInterfaceEmpty(value);
61 return container;
62 }
63
64 TestInterfaceOrTestInterfaceEmpty::TestInterfaceOrTestInterfaceEmpty(const TestI nterfaceOrTestInterfaceEmpty&) = default;
65 TestInterfaceOrTestInterfaceEmpty::~TestInterfaceOrTestInterfaceEmpty() = defaul t;
66 TestInterfaceOrTestInterfaceEmpty& TestInterfaceOrTestInterfaceEmpty::operator=( const TestInterfaceOrTestInterfaceEmpty&) = default;
67
68 DEFINE_TRACE(TestInterfaceOrTestInterfaceEmpty)
69 {
70 visitor->trace(m_testInterface);
71 visitor->trace(m_testInterfaceEmpty);
72 }
73
74 void V8TestInterfaceOrTestInterfaceEmpty::toImpl(v8::Isolate* isolate, v8::Local <v8::Value> v8Value, TestInterfaceOrTestInterfaceEmpty& impl, UnionTypeConversio nMode conversionMode, ExceptionState& exceptionState)
75 {
76 if (v8Value.IsEmpty())
77 return;
78
79 if (conversionMode == UnionTypeConversionMode::Nullable && isUndefinedOrNull (v8Value))
80 return;
81
82 if (V8TestInterface::hasInstance(v8Value, isolate)) {
83 TestInterfaceImplementation* cppValue = V8TestInterface::toImpl(v8::Loca l<v8::Object>::Cast(v8Value));
84 impl.setTestInterface(cppValue);
85 return;
86 }
87
88 if (V8TestInterfaceEmpty::hasInstance(v8Value, isolate)) {
89 TestInterfaceEmpty* cppValue = V8TestInterfaceEmpty::toImpl(v8::Local<v8 ::Object>::Cast(v8Value));
90 impl.setTestInterfaceEmpty(cppValue);
91 return;
92 }
93
94 exceptionState.throwTypeError("The provided value is not of type '(TestInter face or TestInterfaceEmpty)'");
95 }
96
97 v8::Local<v8::Value> toV8(const TestInterfaceOrTestInterfaceEmpty& impl, v8::Loc al<v8::Object> creationContext, v8::Isolate* isolate)
98 {
99 switch (impl.m_type) {
100 case TestInterfaceOrTestInterfaceEmpty::SpecificTypeNone:
101 return v8::Null(isolate);
102 case TestInterfaceOrTestInterfaceEmpty::SpecificTypeTestInterface:
103 return toV8(impl.getAsTestInterface(), creationContext, isolate);
104 case TestInterfaceOrTestInterfaceEmpty::SpecificTypeTestInterfaceEmpty:
105 return toV8(impl.getAsTestInterfaceEmpty(), creationContext, isolate);
106 default:
107 ASSERT_NOT_REACHED();
108 }
109 return v8::Local<v8::Value>();
110 }
111
112 TestInterfaceOrTestInterfaceEmpty NativeValueTraits<TestInterfaceOrTestInterface Empty>::nativeValue(v8::Isolate* isolate, v8::Local<v8::Value> value, ExceptionS tate& exceptionState)
113 {
114 TestInterfaceOrTestInterfaceEmpty impl;
115 V8TestInterfaceOrTestInterfaceEmpty::toImpl(isolate, value, impl, UnionTypeC onversionMode::NotNullable, exceptionState);
116 return impl;
117 }
118
119 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698