| OLD | NEW | 
|   1 {% filter format_blink_cpp_source_code %} |   1 {% filter format_blink_cpp_source_code %} | 
|   2  |   2  | 
|   3 {% include 'copyright_block.txt' %} |   3 {% include 'copyright_block.txt' %} | 
|   4 #ifndef {{cpp_class}}_h |   4 #ifndef {{cpp_class}}_h | 
|   5 #define {{cpp_class}}_h |   5 #define {{cpp_class}}_h | 
|   6  |   6  | 
|   7 {% for filename in header_includes %} |   7 {% for filename in header_includes %} | 
|   8 #include "{{filename}}" |   8 #include "{{filename}}" | 
|   9 {% endfor %} |   9 {% endfor %} | 
|  10  |  10  | 
|  11 namespace blink { |  11 namespace blink { | 
|  12  |  12  | 
|  13 {% for decl in header_forward_decls %} |  13 {% for decl in header_forward_decls %} | 
|  14 class {{decl}}; |  14 class {{decl}}; | 
|  15 {% endfor %} |  15 {% endfor %} | 
|  16  |  16  | 
|  17 class {{exported}}{{cpp_class}} final { |  17 class {{exported}}{{cpp_class}} final { | 
|  18     DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |  18   DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 
|  19 public: |  19  public: | 
|  20     {{cpp_class}}(); |  20   {{cpp_class}}(); | 
|  21     bool isNull() const { return m_type == SpecificTypeNone; } |  21   bool isNull() const { return m_type == SpecificTypeNone; } | 
|  22  |  22  | 
 |  23   {% for member in members %} | 
 |  24   bool is{{member.type_name}}() const { return m_type == {{member.specific_type_
    enum}}; } | 
 |  25   {{member.rvalue_cpp_type}} getAs{{member.type_name}}() const; | 
 |  26   void set{{member.type_name}}({{member.rvalue_cpp_type}}); | 
 |  27   static {{cpp_class}} from{{member.type_name}}({{member.rvalue_cpp_type}}); | 
 |  28  | 
 |  29   {% endfor %} | 
 |  30   {{cpp_class}}(const {{cpp_class}}&); | 
 |  31   ~{{cpp_class}}(); | 
 |  32   {{cpp_class}}& operator=(const {{cpp_class}}&); | 
 |  33   DECLARE_TRACE(); | 
 |  34  | 
 |  35  private: | 
 |  36   enum SpecificTypes { | 
 |  37     SpecificTypeNone, | 
|  23     {% for member in members %} |  38     {% for member in members %} | 
|  24     bool is{{member.type_name}}() const { return m_type == {{member.specific_typ
    e_enum}}; } |  39     {{member.specific_type_enum}}, | 
|  25     {{member.rvalue_cpp_type}} getAs{{member.type_name}}() const; |  40     {% endfor %} | 
|  26     void set{{member.type_name}}({{member.rvalue_cpp_type}}); |  41   }; | 
|  27     static {{cpp_class}} from{{member.type_name}}({{member.rvalue_cpp_type}}); |  42   SpecificTypes m_type; | 
|  28  |  43  | 
|  29     {% endfor %} |  44   {% for member in members %} | 
|  30     {{cpp_class}}(const {{cpp_class}}&); |  45   {{member.cpp_type}} m_{{member.cpp_name}}; | 
|  31     ~{{cpp_class}}(); |  46   {% endfor %} | 
|  32     {{cpp_class}}& operator=(const {{cpp_class}}&); |  | 
|  33     DECLARE_TRACE(); |  | 
|  34  |  47  | 
|  35 private: |  48   friend {{exported}}v8::Local<v8::Value> toV8(const {{cpp_class}}&, v8::Local<v
    8::Object>, v8::Isolate*); | 
|  36     enum SpecificTypes { |  | 
|  37         SpecificTypeNone, |  | 
|  38         {% for member in members %} |  | 
|  39         {{member.specific_type_enum}}, |  | 
|  40         {% endfor %} |  | 
|  41     }; |  | 
|  42     SpecificTypes m_type; |  | 
|  43  |  | 
|  44     {% for member in members %} |  | 
|  45     {{member.cpp_type}} m_{{member.cpp_name}}; |  | 
|  46     {% endfor %} |  | 
|  47  |  | 
|  48     friend {{exported}}v8::Local<v8::Value> toV8(const {{cpp_class}}&, v8::Local
    <v8::Object>, v8::Isolate*); |  | 
|  49 }; |  49 }; | 
|  50  |  50  | 
|  51 class {{v8_class}} final { |  51 class {{v8_class}} final { | 
|  52 public: |  52  public: | 
|  53     {{exported}}static void toImpl(v8::Isolate*, v8::Local<v8::Value>, {{cpp_cla
    ss}}&, UnionTypeConversionMode, ExceptionState&); |  53   {{exported}}static void toImpl(v8::Isolate*, v8::Local<v8::Value>, {{cpp_class
    }}&, UnionTypeConversionMode, ExceptionState&); | 
|  54 }; |  54 }; | 
|  55  |  55  | 
|  56 {{exported}}v8::Local<v8::Value> toV8(const {{cpp_class}}&, v8::Local<v8::Object
    >, v8::Isolate*); |  56 {{exported}}v8::Local<v8::Value> toV8(const {{cpp_class}}&, v8::Local<v8::Object
    >, v8::Isolate*); | 
|  57  |  57  | 
|  58 template <class CallbackInfo> |  58 template <class CallbackInfo> | 
|  59 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, {{cpp_class}}& im
    pl) |  59 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, {{cpp_class}}& im
    pl) { | 
|  60 { |  60   v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInfo.
    GetIsolate())); | 
|  61     v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInf
    o.GetIsolate())); |  | 
|  62 } |  61 } | 
|  63  |  62  | 
|  64 template <> |  63 template <> | 
|  65 struct NativeValueTraits<{{cpp_class}}> { |  64 struct NativeValueTraits<{{cpp_class}}> { | 
|  66     {{exported}}static {{cpp_class}} nativeValue(v8::Isolate*, v8::Local<v8::Val
    ue>, ExceptionState&); |  65   {{exported}}static {{cpp_class}} nativeValue(v8::Isolate*, v8::Local<v8::Value
    >, ExceptionState&); | 
|  67 }; |  66 }; | 
|  68  |  67  | 
|  69 } // namespace blink |  68 }  // namespace blink | 
|  70  |  69  | 
|  71 // We need to set canInitializeWithMemset=true because HeapVector supports |  70 // We need to set canInitializeWithMemset=true because HeapVector supports | 
|  72 // items that can initialize with memset or have a vtable. It is safe to |  71 // items that can initialize with memset or have a vtable. It is safe to | 
|  73 // set canInitializeWithMemset=true for a union type object in practice. |  72 // set canInitializeWithMemset=true for a union type object in practice. | 
|  74 // See https://codereview.chromium.org/1118993002/#msg5 for more details. |  73 // See https://codereview.chromium.org/1118993002/#msg5 for more details. | 
|  75 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::{{cpp_class}}); |  74 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::{{cpp_class}}); | 
|  76  |  75  | 
|  77 #endif // {{cpp_class}}_h |  76 #endif  // {{cpp_class}}_h | 
|  78  |  77  | 
|  79 {% endfilter %}{# format_blink_cpp_source_code #} |  78 {% endfilter %}{# format_blink_cpp_source_code #} | 
| OLD | NEW |