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

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

Issue 2392713002: mojo: Mark DataView readers as WARN_UNUSED_RESULT. (Closed)
Patch Set: Fix attribute placement to appease gcc Created 4 years, 2 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
« no previous file with comments | « mojo/public/tools/bindings/generators/cpp_templates/struct_data_view_declaration.tmpl ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 class {{union.name}}DataView { 1 class {{union.name}}DataView {
2 public: 2 public:
3 using Tag = internal::{{union.name}}_Data::{{union.name}}_Tag; 3 using Tag = internal::{{union.name}}_Data::{{union.name}}_Tag;
4 4
5 {{union.name}}DataView() {} 5 {{union.name}}DataView() {}
6 6
7 {{union.name}}DataView( 7 {{union.name}}DataView(
8 internal::{{union.name}}_Data* data, 8 internal::{{union.name}}_Data* data,
9 mojo::internal::SerializationContext* context) 9 mojo::internal::SerializationContext* context)
10 {%- if union|requires_context_for_data_view %} 10 {%- if union|requires_context_for_data_view %}
(...skipping 13 matching lines...) Expand all
24 {%- for field in union.fields %} 24 {%- for field in union.fields %}
25 {%- set kind = field.kind %} 25 {%- set kind = field.kind %}
26 {%- set name = field.name %} 26 {%- set name = field.name %}
27 bool is_{{name}}() const { return data_->tag == Tag::{{name|upper}}; } 27 bool is_{{name}}() const { return data_->tag == Tag::{{name|upper}}; }
28 28
29 {%- if kind|is_object_kind %} 29 {%- if kind|is_object_kind %}
30 inline void Get{{name|under_to_camel}}DataView( 30 inline void Get{{name|under_to_camel}}DataView(
31 {{kind|cpp_data_view_type}}* output); 31 {{kind|cpp_data_view_type}}* output);
32 32
33 template <typename UserType> 33 template <typename UserType>
34 bool Read{{name|under_to_camel}}(UserType* output) { 34 WARN_UNUSED_RESULT bool Read{{name|under_to_camel}}(UserType* output) {
35 DCHECK(is_{{name}}()); 35 DCHECK(is_{{name}}());
36 return mojo::internal::Deserialize<{{kind|unmapped_type_for_serializer}}>( 36 return mojo::internal::Deserialize<{{kind|unmapped_type_for_serializer}}>(
37 data_->data.f_{{name}}.Get(), output, context_); 37 data_->data.f_{{name}}.Get(), output, context_);
38 } 38 }
39 39
40 {%- elif kind|is_enum_kind %} 40 {%- elif kind|is_enum_kind %}
41 template <typename UserType> 41 template <typename UserType>
42 bool Read{{name|under_to_camel}}(UserType* output) const { 42 WARN_UNUSED_RESULT bool Read{{name|under_to_camel}}(UserType* output) const {
43 DCHECK(is_{{name}}()); 43 DCHECK(is_{{name}}());
44 return mojo::internal::Deserialize<{{kind|unmapped_type_for_serializer}}>( 44 return mojo::internal::Deserialize<{{kind|unmapped_type_for_serializer}}>(
45 data_->data.f_{{name}}, output); 45 data_->data.f_{{name}}, output);
46 } 46 }
47 47
48 {{kind|cpp_data_view_type}} {{name}}() const { 48 {{kind|cpp_data_view_type}} {{name}}() const {
49 DCHECK(is_{{name}}()); 49 DCHECK(is_{{name}}());
50 return static_cast<{{kind|cpp_data_view_type}}>( 50 return static_cast<{{kind|cpp_data_view_type}}>(
51 data_->data.f_{{name}}); 51 data_->data.f_{{name}});
52 } 52 }
(...skipping 30 matching lines...) Expand all
83 {%- endif %} 83 {%- endif %}
84 {%- endfor %} 84 {%- endfor %}
85 85
86 private: 86 private:
87 internal::{{union.name}}_Data* data_ = nullptr; 87 internal::{{union.name}}_Data* data_ = nullptr;
88 {%- if union|requires_context_for_data_view %} 88 {%- if union|requires_context_for_data_view %}
89 mojo::internal::SerializationContext* context_ = nullptr; 89 mojo::internal::SerializationContext* context_ = nullptr;
90 {%- endif %} 90 {%- endif %}
91 }; 91 };
92 92
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/generators/cpp_templates/struct_data_view_declaration.tmpl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698