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. DO NOT MODIFY! | 5 // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY! |
6 | 6 |
7 #ifndef UnionTypeModules_h | 7 #ifndef StringOrDouble_h |
8 #define UnionTypeModules_h | 8 #define StringOrDouble_h |
9 | 9 |
10 #include "bindings/core/v8/Dictionary.h" | 10 #include "bindings/core/v8/Dictionary.h" |
11 #include "bindings/core/v8/ExceptionState.h" | 11 #include "bindings/core/v8/ExceptionState.h" |
12 #include "bindings/core/v8/UnionTypesCore.h" | |
13 #include "bindings/core/v8/V8Binding.h" | 12 #include "bindings/core/v8/V8Binding.h" |
14 #include "modules/ModulesExport.h" | 13 #include "core/CoreExport.h" |
15 #include "platform/heap/Handle.h" | 14 #include "platform/heap/Handle.h" |
16 | 15 |
17 namespace blink { | 16 namespace blink { |
18 | 17 |
19 | 18 |
20 class MODULES_EXPORT BooleanOrString final { | 19 class CORE_EXPORT StringOrDouble final { |
21 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 20 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
22 public: | 21 public: |
23 BooleanOrString(); | 22 StringOrDouble(); |
24 bool isNull() const { return m_type == SpecificTypeNone; } | 23 bool isNull() const { return m_type == SpecificTypeNone; } |
25 | 24 |
26 bool isBoolean() const { return m_type == SpecificTypeBoolean; } | |
27 bool getAsBoolean() const; | |
28 void setBoolean(bool); | |
29 static BooleanOrString fromBoolean(bool); | |
30 | |
31 bool isString() const { return m_type == SpecificTypeString; } | 25 bool isString() const { return m_type == SpecificTypeString; } |
32 String getAsString() const; | 26 String getAsString() const; |
33 void setString(String); | 27 void setString(String); |
34 static BooleanOrString fromString(String); | 28 static StringOrDouble fromString(String); |
35 | 29 |
36 BooleanOrString(const BooleanOrString&); | 30 bool isDouble() const { return m_type == SpecificTypeDouble; } |
37 ~BooleanOrString(); | 31 double getAsDouble() const; |
38 BooleanOrString& operator=(const BooleanOrString&); | 32 void setDouble(double); |
| 33 static StringOrDouble fromDouble(double); |
| 34 |
| 35 StringOrDouble(const StringOrDouble&); |
| 36 ~StringOrDouble(); |
| 37 StringOrDouble& operator=(const StringOrDouble&); |
39 DECLARE_TRACE(); | 38 DECLARE_TRACE(); |
40 | 39 |
41 private: | 40 private: |
42 enum SpecificTypes { | 41 enum SpecificTypes { |
43 SpecificTypeNone, | 42 SpecificTypeNone, |
44 SpecificTypeBoolean, | |
45 SpecificTypeString, | 43 SpecificTypeString, |
| 44 SpecificTypeDouble, |
46 }; | 45 }; |
47 SpecificTypes m_type; | 46 SpecificTypes m_type; |
48 | 47 |
49 bool m_boolean; | |
50 String m_string; | 48 String m_string; |
| 49 double m_double; |
51 | 50 |
52 friend MODULES_EXPORT v8::Local<v8::Value> toV8(const BooleanOrString&, v8::
Local<v8::Object>, v8::Isolate*); | 51 friend CORE_EXPORT v8::Local<v8::Value> toV8(const StringOrDouble&, v8::Loca
l<v8::Object>, v8::Isolate*); |
53 }; | 52 }; |
54 | 53 |
55 class V8BooleanOrString final { | 54 class V8StringOrDouble final { |
56 public: | 55 public: |
57 MODULES_EXPORT static void toImpl(v8::Isolate*, v8::Local<v8::Value>, Boolea
nOrString&, UnionTypeConversionMode, ExceptionState&); | 56 CORE_EXPORT static void toImpl(v8::Isolate*, v8::Local<v8::Value>, StringOrD
ouble&, UnionTypeConversionMode, ExceptionState&); |
58 }; | 57 }; |
59 | 58 |
60 MODULES_EXPORT v8::Local<v8::Value> toV8(const BooleanOrString&, v8::Local<v8::O
bject>, v8::Isolate*); | 59 CORE_EXPORT v8::Local<v8::Value> toV8(const StringOrDouble&, v8::Local<v8::Objec
t>, v8::Isolate*); |
61 | 60 |
62 template <class CallbackInfo> | 61 template <class CallbackInfo> |
63 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, BooleanOrString&
impl) | 62 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, StringOrDouble& i
mpl) |
64 { | 63 { |
65 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInf
o.GetIsolate())); | 64 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInf
o.GetIsolate())); |
66 } | 65 } |
67 | 66 |
68 template <> | 67 template <> |
69 struct NativeValueTraits<BooleanOrString> { | 68 struct NativeValueTraits<StringOrDouble> { |
70 MODULES_EXPORT static BooleanOrString nativeValue(v8::Isolate*, v8::Local<v8
::Value>, ExceptionState&); | 69 CORE_EXPORT static StringOrDouble nativeValue(v8::Isolate*, v8::Local<v8::Va
lue>, ExceptionState&); |
71 }; | 70 }; |
72 | 71 |
73 } // namespace blink | 72 } // namespace blink |
74 | 73 |
75 // We need to set canInitializeWithMemset=true because HeapVector supports | 74 // We need to set canInitializeWithMemset=true because HeapVector supports |
76 // items that can initialize with memset or have a vtable. It is safe to | 75 // items that can initialize with memset or have a vtable. It is safe to |
77 // set canInitializeWithMemset=true for a union type object in practice. | 76 // set canInitializeWithMemset=true for a union type object in practice. |
78 // See https://codereview.chromium.org/1118993002/#msg5 for more details. | 77 // See https://codereview.chromium.org/1118993002/#msg5 for more details. |
79 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::BooleanOrString); | 78 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::StringOrDouble); |
80 | 79 |
81 #endif // UnionTypeModules_h | 80 #endif // StringOrDouble_h |
OLD | NEW |