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

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

Issue 1618963006: Mojo C++ bindings: support enum validation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 size_t GetSerializedSize_(const {{struct.name}}Ptr& input); 1 size_t GetSerializedSize_(const {{struct.name}}Ptr& input);
2 void Serialize_({{struct.name}}Ptr input, mojo::internal::Buffer* buffer, 2 void Serialize_({{struct.name}}Ptr input, mojo::internal::Buffer* buffer,
3 internal::{{struct.name}}_Data** output); 3 internal::{{struct.name}}_Data** output);
4 bool Deserialize_(internal::{{struct.name}}_Data* input, 4 bool Deserialize_(internal::{{struct.name}}_Data* input,
5 {{struct.name}}Ptr* output, 5 {{struct.name}}Ptr* output,
6 mojo::internal::SerializationContext* context); 6 mojo::internal::SerializationContext* context);
7 7
8 {%- if not variant %} 8 {%- if not variant %}
9 9
10 {# NOTE: Generated Reader instances are intentionally cheap to copy and devoid 10 {# NOTE: Generated Reader instances are intentionally cheap to copy and devoid
(...skipping 15 matching lines...) Expand all
26 {%- elif kind|is_any_handle_kind %} 26 {%- elif kind|is_any_handle_kind %}
27 // TODO(rockot): Support reading handles. ({{name}}() omitted) 27 // TODO(rockot): Support reading handles. ({{name}}() omitted)
28 {%- elif kind|is_interface_kind %} 28 {%- elif kind|is_interface_kind %}
29 // TODO(rockot): Support reading interfaces. ({{name}}() omitted) 29 // TODO(rockot): Support reading interfaces. ({{name}}() omitted)
30 {%- elif kind|is_interface_request_kind %} 30 {%- elif kind|is_interface_request_kind %}
31 // TODO(rockot): Support reading interface requests. ({{name}}() omitted) 31 // TODO(rockot): Support reading interface requests. ({{name}}() omitted)
32 {%- elif kind|is_associated_kind %} 32 {%- elif kind|is_associated_kind %}
33 // TODO(rockot): Support reading associated kinds. ({{name}}() omitted) 33 // TODO(rockot): Support reading associated kinds. ({{name}}() omitted)
34 {%- elif kind|is_enum_kind %} 34 {%- elif kind|is_enum_kind %}
35 {{kind|cpp_result_type}} {{name}}() const { 35 {{kind|cpp_result_type}} {{name}}() const {
36 return static_cast<{{kind|cpp_result_type}}>(data_->{{name}}); 36 return static_cast<{{kind|cpp_result_type}}>(data_->{{name}}.value);
37 } 37 }
38 {%- else %} 38 {%- else %}
39 {{kind|cpp_result_type}} {{name}}() const { return data_->{{name}}; } 39 {{kind|cpp_result_type}} {{name}}() const { return data_->{{name}}; }
40 {%- endif %} 40 {%- endif %}
41 {%- endfor %} 41 {%- endfor %}
42 42
43 private: 43 private:
44 internal::{{struct.name}}_Data* data_; 44 internal::{{struct.name}}_Data* data_;
45 mojo::internal::SerializationContext* context_; 45 mojo::internal::SerializationContext* context_;
46 }; 46 };
(...skipping 27 matching lines...) Expand all
74 74
75 static bool Deserialize(internal::{{struct.name}}_Data* input, 75 static bool Deserialize(internal::{{struct.name}}_Data* input,
76 NativeType* output, 76 NativeType* output,
77 mojo::internal::SerializationContext* context) { 77 mojo::internal::SerializationContext* context) {
78 return mojo::StructTraits<{{struct.name}}, NativeType>::Read( 78 return mojo::StructTraits<{{struct.name}}, NativeType>::Read(
79 {{struct.name}}_Reader(input, context), output); 79 {{struct.name}}_Reader(input, context), output);
80 } 80 }
81 }; 81 };
82 82
83 {%- endif %} {# not variant #} 83 {%- endif %} {# not variant #}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698