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