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

Side by Side Diff: mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_template_definition.tmpl

Issue 2686763002: [Mojo Video Capture] Split OnIncomingCapturedVideoFrame() to OnNewBuffer() and OnFrameReadyInBuffer( (Closed)
Patch Set: rebase Created 3 years, 10 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
1 template <typename UnionPtrType> 1 template <typename UnionPtrType>
2 {{union.name}}Ptr {{union.name}}::Clone() const { 2 {{union.name}}Ptr {{union.name}}::Clone() const {
3 // Use UnionPtrType to prevent the compiler from trying to compile this 3 // Use UnionPtrType to prevent the compiler from trying to compile this
4 // without being asked. 4 // without being asked.
5 UnionPtrType rv(New()); 5 UnionPtrType rv(New());
6 switch (tag_) { 6 switch (tag_) {
7 {%- for field in union.fields %} 7 {%- for field in union.fields %}
8 case Tag::{{field.name|upper}}: 8 case Tag::{{field.name|upper}}:
9 {%- if field.kind|is_object_kind or 9 {%- if field.kind|is_object_kind or
10 field.kind|is_any_handle_or_interface_kind %} 10 field.kind|is_any_handle_or_interface_kind %}
11 rv->set_{{field.name}}(mojo::internal::Clone(*data_.{{field.name}})); 11 rv->set_{{field.name}}(mojo::Clone(*data_.{{field.name}}));
12 {%- else %} 12 {%- else %}
13 rv->set_{{field.name}}(mojo::internal::Clone(data_.{{field.name}})); 13 rv->set_{{field.name}}(mojo::Clone(data_.{{field.name}}));
14 {%- endif %} 14 {%- endif %}
15 break; 15 break;
16 {%- endfor %} 16 {%- endfor %}
17 }; 17 };
18 return rv; 18 return rv;
19 } 19 }
20 20
21 template <typename T, 21 template <typename T,
22 typename std::enable_if<std::is_same< 22 typename std::enable_if<std::is_same<
23 T, {{union.name}}>::value>::type*> 23 T, {{union.name}}>::value>::type*>
24 bool {{union.name}}::Equals(const T& other) const { 24 bool {{union.name}}::Equals(const T& other) const {
25 if (tag_ != other.which()) 25 if (tag_ != other.which())
26 return false; 26 return false;
27 27
28 switch (tag_) { 28 switch (tag_) {
29 {%- for field in union.fields %} 29 {%- for field in union.fields %}
30 case Tag::{{field.name|upper}}: 30 case Tag::{{field.name|upper}}:
31 {%- if field.kind|is_object_kind or 31 {%- if field.kind|is_object_kind or
32 field.kind|is_any_handle_or_interface_kind %} 32 field.kind|is_any_handle_or_interface_kind %}
33 return mojo::internal::Equals(*(data_.{{field.name}}), *(other.data_.{{fie ld.name}})); 33 return mojo::internal::Equals(*(data_.{{field.name}}), *(other.data_.{{fie ld.name}}));
34 {%- else %} 34 {%- else %}
35 return mojo::internal::Equals(data_.{{field.name}}, other.data_.{{field.na me}}); 35 return mojo::internal::Equals(data_.{{field.name}}, other.data_.{{field.na me}});
36 {%- endif %} 36 {%- endif %}
37 {%- endfor %} 37 {%- endfor %}
38 }; 38 };
39 39
40 return false; 40 return false;
41 } 41 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698