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