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_LONG_SEQUENCE_OR_EVENT_H_
12 #define THIRD_PARTY_BLINK_RENDERER_BINDINGS_TESTS_RESULTS_CORE_LONG_SEQUENCE_OR_EVENT_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 Event;
25 
26 class CORE_EXPORT LongSequenceOrEvent final {
27   DISALLOW_NEW();
28  public:
29   LongSequenceOrEvent();
IsNull()30   bool IsNull() const { return type_ == SpecificType::kNone; }
31 
IsEvent()32   bool IsEvent() const { return type_ == SpecificType::kEvent; }
33   Event* GetAsEvent() const;
34   void SetEvent(Event*);
35   static LongSequenceOrEvent FromEvent(Event*);
36 
IsLongSequence()37   bool IsLongSequence() const { return type_ == SpecificType::kLongSequence; }
38   const Vector<int32_t>& GetAsLongSequence() const;
39   void SetLongSequence(const Vector<int32_t>&);
40   static LongSequenceOrEvent FromLongSequence(const Vector<int32_t>&);
41 
42   LongSequenceOrEvent(const LongSequenceOrEvent&);
43   ~LongSequenceOrEvent();
44   LongSequenceOrEvent& operator=(const LongSequenceOrEvent&);
45   void Trace(Visitor*) const;
46 
47  private:
48   enum class SpecificType {
49     kNone,
50     kEvent,
51     kLongSequence,
52   };
53   SpecificType type_;
54 
55   Member<Event> event_;
56   Vector<int32_t> long_sequence_;
57 
58   friend CORE_EXPORT v8::Local<v8::Value> ToV8(const LongSequenceOrEvent&, v8::Local<v8::Object>, v8::Isolate*);
59 };
60 
61 class V8LongSequenceOrEvent final {
62  public:
63   CORE_EXPORT static void ToImpl(v8::Isolate*, v8::Local<v8::Value>, LongSequenceOrEvent&, UnionTypeConversionMode, ExceptionState&);
64 };
65 
66 CORE_EXPORT v8::Local<v8::Value> ToV8(const LongSequenceOrEvent&, v8::Local<v8::Object>, v8::Isolate*);
67 
68 template <class CallbackInfo>
V8SetReturnValue(const CallbackInfo & callbackInfo,LongSequenceOrEvent & impl)69 inline void V8SetReturnValue(const CallbackInfo& callbackInfo, LongSequenceOrEvent& impl) {
70   V8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(), callbackInfo.GetIsolate()));
71 }
72 
73 template <class CallbackInfo>
V8SetReturnValue(const CallbackInfo & callbackInfo,LongSequenceOrEvent & impl,v8::Local<v8::Object> creationContext)74 inline void V8SetReturnValue(const CallbackInfo& callbackInfo, LongSequenceOrEvent& impl, v8::Local<v8::Object> creationContext) {
75   V8SetReturnValue(callbackInfo, ToV8(impl, creationContext, callbackInfo.GetIsolate()));
76 }
77 
78 template <>
79 struct NativeValueTraits<LongSequenceOrEvent> : public NativeValueTraitsBase<LongSequenceOrEvent> {
80   CORE_EXPORT static LongSequenceOrEvent NativeValue(v8::Isolate*, v8::Local<v8::Value>, ExceptionState&);
81   CORE_EXPORT static LongSequenceOrEvent NullValue() { return LongSequenceOrEvent(); }
82 };
83 
84 template <>
85 struct V8TypeOf<LongSequenceOrEvent> {
86   typedef V8LongSequenceOrEvent Type;
87 };
88 
89 }  // namespace blink
90 
91 // We need to set canInitializeWithMemset=true because HeapVector supports
92 // items that can initialize with memset or have a vtable. It is safe to
93 // set canInitializeWithMemset=true for a union type object in practice.
94 // See https://codereview.chromium.org/1118993002/#msg5 for more details.
95 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::LongSequenceOrEvent)
96 
97 #endif  // THIRD_PARTY_BLINK_RENDERER_BINDINGS_TESTS_RESULTS_CORE_LONG_SEQUENCE_OR_EVENT_H_
98