Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: third_party/WebKit/Source/bindings/templates/union_container.h

Issue 1974143002: Revert of Generate separate files for union type containers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 {% include 'copyright_block.txt' %}
2 #ifndef {{cpp_class}}_h
3 #define {{cpp_class}}_h
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 class {{exported}}{{cpp_class}} final {
16 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
17 public:
18 {{cpp_class}}();
19 bool isNull() const { return m_type == SpecificTypeNone; }
20
21 {% for member in members %}
22 bool is{{member.type_name}}() const { return m_type == {{member.specific_typ e_enum}}; }
23 {{member.rvalue_cpp_type}} getAs{{member.type_name}}() const;
24 void set{{member.type_name}}({{member.rvalue_cpp_type}});
25 static {{cpp_class}} from{{member.type_name}}({{member.rvalue_cpp_type}});
26
27 {% endfor %}
28 {{cpp_class}}(const {{cpp_class}}&);
29 ~{{cpp_class}}();
30 {{cpp_class}}& operator=(const {{cpp_class}}&);
31 DECLARE_TRACE();
32
33 private:
34 enum SpecificTypes {
35 SpecificTypeNone,
36 {% for member in members %}
37 {{member.specific_type_enum}},
38 {% endfor %}
39 };
40 SpecificTypes m_type;
41
42 {% for member in members %}
43 {{member.cpp_type}} m_{{member.cpp_name}};
44 {% endfor %}
45
46 friend {{exported}}v8::Local<v8::Value> toV8(const {{cpp_class}}&, v8::Local <v8::Object>, v8::Isolate*);
47 };
48
49 class {{v8_class}} final {
50 public:
51 {{exported}}static void toImpl(v8::Isolate*, v8::Local<v8::Value>, {{cpp_cla ss}}&, UnionTypeConversionMode, ExceptionState&);
52 };
53
54 {{exported}}v8::Local<v8::Value> toV8(const {{cpp_class}}&, v8::Local<v8::Object >, v8::Isolate*);
55
56 template <class CallbackInfo>
57 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, {{cpp_class}}& im pl)
58 {
59 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInf o.GetIsolate()));
60 }
61
62 template <>
63 struct NativeValueTraits<{{cpp_class}}> {
64 {{exported}}static {{cpp_class}} nativeValue(v8::Isolate*, v8::Local<v8::Val ue>, ExceptionState&);
65 };
66
67 } // namespace blink
68
69 // We need to set canInitializeWithMemset=true because HeapVector supports
70 // items that can initialize with memset or have a vtable. It is safe to
71 // set canInitializeWithMemset=true for a union type object in practice.
72 // See https://codereview.chromium.org/1118993002/#msg5 for more details.
73 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::{{cpp_class}});
74
75 #endif // {{cpp_class}}_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698