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

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

Issue 1966933002: Mojo C++ bindings: switch the existing usage of StructTraits to use the new data view interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@26_reader
Patch Set: typeid() is not allowed :/ 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
1 {%- import "struct_macros.tmpl" as struct_macros %} 1 {%- import "struct_macros.tmpl" as struct_macros %}
2 {%- set mojom_type = struct|get_qualified_name_for_kind %} 2 {%- set mojom_type = struct|get_qualified_name_for_kind %}
3 {%- set data_type = struct|get_qualified_name_for_kind(internal=True) %}
4 3
5 // static 4 // static
6 bool StructTraits<{{mojom_type}}, {{mojom_type}}Ptr>::ReadFromDataView( 5 bool StructTraits<{{mojom_type}}, {{mojom_type}}Ptr>::Read(
7 {{mojom_type}}DataView input, 6 {{mojom_type}}DataView input,
8 {{mojom_type}}Ptr* output) { 7 {{mojom_type}}Ptr* output) {
9 bool success = true; 8 bool success = true;
10 if (!input.is_null()) { 9 {{mojom_type}}Ptr result({{mojom_type}}::New());
11 {{mojom_type}}Ptr result({{mojom_type}}::New()); 10 {{struct_macros.deserialize(struct, "input", "result->%s",
12 {{struct_macros.deserialize(struct, "input", "result->%s", 11 "success")|indent(4)}}
13 "success")|indent(4)}} 12 *output = std::move(result);
14 *output = std::move(result);
15 } else {
16 output->reset();
17 }
18 return success; 13 return success;
19 } 14 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698