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 from the Jinja2 template
6 // third_party/blink/renderer/bindings/templates/union_container.h.tmpl
7 // by the script code_generator_v8.py.
8 // DO NOT MODIFY!
9
10 // clang-format off
11 #ifndef THIRD_PARTY_BLINK_RENDERER_BINDINGS_TESTS_RESULTS_CORE_TEST_ENUM_OR_TEST_ENUM_OR_NULL_SEQUENCE_H_
12 #define THIRD_PARTY_BLINK_RENDERER_BINDINGS_TESTS_RESULTS_CORE_TEST_ENUM_OR_TEST_ENUM_OR_NULL_SEQUENCE_H_
13
14 #include "base/optional.h"
15 #include "third_party/blink/renderer/bindings/core/v8/dictionary.h"
16 #include "third_party/blink/renderer/bindings/core/v8/native_value_traits.h"
17 #include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
18 #include "third_party/blink/renderer/core/core_export.h"
19 #include "third_party/blink/renderer/platform/bindings/exception_state.h"
20 #include "third_party/blink/renderer/platform/heap/handle.h"
21
22 namespace blink {
23
24 class CORE_EXPORT TestEnumOrTestEnumOrNullSequence final {
25 DISALLOW_NEW();
26 public:
27 TestEnumOrTestEnumOrNullSequence();
IsNull()28 bool IsNull() const { return type_ == SpecificType::kNone; }
29
IsTestEnum()30 bool IsTestEnum() const { return type_ == SpecificType::kTestEnum; }
31 const String& GetAsTestEnum() const;
32 void SetTestEnum(const String&);
33 static TestEnumOrTestEnumOrNullSequence FromTestEnum(const String&);
34
IsTestEnumOrNullSequence()35 bool IsTestEnumOrNullSequence() const { return type_ == SpecificType::kTestEnumOrNullSequence; }
36 const Vector<String>& GetAsTestEnumOrNullSequence() const;
37 void SetTestEnumOrNullSequence(const Vector<String>&);
38 static TestEnumOrTestEnumOrNullSequence FromTestEnumOrNullSequence(const Vector<String>&);
39
40 TestEnumOrTestEnumOrNullSequence(const TestEnumOrTestEnumOrNullSequence&);
41 ~TestEnumOrTestEnumOrNullSequence();
42 TestEnumOrTestEnumOrNullSequence& operator=(const TestEnumOrTestEnumOrNullSequence&);
43 void Trace(Visitor*) const;
44
45 private:
46 enum class SpecificType {
47 kNone,
48 kTestEnum,
49 kTestEnumOrNullSequence,
50 };
51 SpecificType type_;
52
53 String test_enum_;
54 Vector<String> test_enum_or_null_sequence_;
55
56 friend CORE_EXPORT v8::Local<v8::Value> ToV8(const TestEnumOrTestEnumOrNullSequence&, v8::Local<v8::Object>, v8::Isolate*);
57 };
58
59 class V8TestEnumOrTestEnumOrNullSequence final {
60 public:
61 CORE_EXPORT static void ToImpl(v8::Isolate*, v8::Local<v8::Value>, TestEnumOrTestEnumOrNullSequence&, UnionTypeConversionMode, ExceptionState&);
62 };
63
64 CORE_EXPORT v8::Local<v8::Value> ToV8(const TestEnumOrTestEnumOrNullSequence&, v8::Local<v8::Object>, v8::Isolate*);
65
66 template <class CallbackInfo>
V8SetReturnValue(const CallbackInfo & callbackInfo,TestEnumOrTestEnumOrNullSequence & impl)67 inline void V8SetReturnValue(const CallbackInfo& callbackInfo, TestEnumOrTestEnumOrNullSequence& impl) {
68 V8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(), callbackInfo.GetIsolate()));
69 }
70
71 template <class CallbackInfo>
V8SetReturnValue(const CallbackInfo & callbackInfo,TestEnumOrTestEnumOrNullSequence & impl,v8::Local<v8::Object> creationContext)72 inline void V8SetReturnValue(const CallbackInfo& callbackInfo, TestEnumOrTestEnumOrNullSequence& impl, v8::Local<v8::Object> creationContext) {
73 V8SetReturnValue(callbackInfo, ToV8(impl, creationContext, callbackInfo.GetIsolate()));
74 }
75
76 template <>
77 struct NativeValueTraits<TestEnumOrTestEnumOrNullSequence> : public NativeValueTraitsBase<TestEnumOrTestEnumOrNullSequence> {
78 CORE_EXPORT static TestEnumOrTestEnumOrNullSequence NativeValue(v8::Isolate*, v8::Local<v8::Value>, ExceptionState&);
79 CORE_EXPORT static TestEnumOrTestEnumOrNullSequence NullValue() { return TestEnumOrTestEnumOrNullSequence(); }
80 };
81
82 template <>
83 struct V8TypeOf<TestEnumOrTestEnumOrNullSequence> {
84 typedef V8TestEnumOrTestEnumOrNullSequence Type;
85 };
86
87 } // namespace blink
88
89 // We need to set canInitializeWithMemset=true because HeapVector supports
90 // items that can initialize with memset or have a vtable. It is safe to
91 // set canInitializeWithMemset=true for a union type object in practice.
92 // See https://codereview.chromium.org/1118993002/#msg5 for more details.
93 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::TestEnumOrTestEnumOrNullSequence)
94
95 #endif // THIRD_PARTY_BLINK_RENDERER_BINDINGS_TESTS_RESULTS_CORE_TEST_ENUM_OR_TEST_ENUM_OR_NULL_SEQUENCE_H_
96