OLD | NEW |
(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 #ifndef UnrestrictedDoubleOrString_h |
| 8 #define UnrestrictedDoubleOrString_h |
| 9 |
| 10 #include "bindings/core/v8/Dictionary.h" |
| 11 #include "bindings/core/v8/ExceptionState.h" |
| 12 #include "bindings/core/v8/V8Binding.h" |
| 13 #include "core/CoreExport.h" |
| 14 #include "platform/heap/Handle.h" |
| 15 |
| 16 namespace blink { |
| 17 |
| 18 |
| 19 class CORE_EXPORT UnrestrictedDoubleOrString final { |
| 20 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 21 public: |
| 22 UnrestrictedDoubleOrString(); |
| 23 bool isNull() const { return m_type == SpecificTypeNone; } |
| 24 |
| 25 bool isUnrestrictedDouble() const { return m_type == SpecificTypeUnrestricte
dDouble; } |
| 26 double getAsUnrestrictedDouble() const; |
| 27 void setUnrestrictedDouble(double); |
| 28 static UnrestrictedDoubleOrString fromUnrestrictedDouble(double); |
| 29 |
| 30 bool isString() const { return m_type == SpecificTypeString; } |
| 31 String getAsString() const; |
| 32 void setString(String); |
| 33 static UnrestrictedDoubleOrString fromString(String); |
| 34 |
| 35 UnrestrictedDoubleOrString(const UnrestrictedDoubleOrString&); |
| 36 ~UnrestrictedDoubleOrString(); |
| 37 UnrestrictedDoubleOrString& operator=(const UnrestrictedDoubleOrString&); |
| 38 DECLARE_TRACE(); |
| 39 |
| 40 private: |
| 41 enum SpecificTypes { |
| 42 SpecificTypeNone, |
| 43 SpecificTypeUnrestrictedDouble, |
| 44 SpecificTypeString, |
| 45 }; |
| 46 SpecificTypes m_type; |
| 47 |
| 48 double m_unrestrictedDouble; |
| 49 String m_string; |
| 50 |
| 51 friend CORE_EXPORT v8::Local<v8::Value> toV8(const UnrestrictedDoubleOrStrin
g&, v8::Local<v8::Object>, v8::Isolate*); |
| 52 }; |
| 53 |
| 54 class V8UnrestrictedDoubleOrString final { |
| 55 public: |
| 56 CORE_EXPORT static void toImpl(v8::Isolate*, v8::Local<v8::Value>, Unrestric
tedDoubleOrString&, UnionTypeConversionMode, ExceptionState&); |
| 57 }; |
| 58 |
| 59 CORE_EXPORT v8::Local<v8::Value> toV8(const UnrestrictedDoubleOrString&, v8::Loc
al<v8::Object>, v8::Isolate*); |
| 60 |
| 61 template <class CallbackInfo> |
| 62 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, UnrestrictedDoubl
eOrString& impl) |
| 63 { |
| 64 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInf
o.GetIsolate())); |
| 65 } |
| 66 |
| 67 template <> |
| 68 struct NativeValueTraits<UnrestrictedDoubleOrString> { |
| 69 CORE_EXPORT static UnrestrictedDoubleOrString nativeValue(v8::Isolate*, v8::
Local<v8::Value>, ExceptionState&); |
| 70 }; |
| 71 |
| 72 } // namespace blink |
| 73 |
| 74 // We need to set canInitializeWithMemset=true because HeapVector supports |
| 75 // items that can initialize with memset or have a vtable. It is safe to |
| 76 // set canInitializeWithMemset=true for a union type object in practice. |
| 77 // See https://codereview.chromium.org/1118993002/#msg5 for more details. |
| 78 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::UnrestrictedDoubleOrString); |
| 79 |
| 80 #endif // UnrestrictedDoubleOrString_h |
OLD | NEW |