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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/tools/bindings/generators/cpp_templates/struct_serialization_definition.tmpl
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/struct_serialization_definition.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/struct_serialization_definition.tmpl
index e8e92460cd67b41997d02a291f39b2b6df60a53e..7421abcd787e0b370a25296e67053ca7ffdaf5a0 100644
--- a/mojo/public/tools/bindings/generators/cpp_templates/struct_serialization_definition.tmpl
+++ b/mojo/public/tools/bindings/generators/cpp_templates/struct_serialization_definition.tmpl
@@ -1,19 +1,14 @@
{%- import "struct_macros.tmpl" as struct_macros %}
{%- set mojom_type = struct|get_qualified_name_for_kind %}
-{%- set data_type = struct|get_qualified_name_for_kind(internal=True) %}
// static
-bool StructTraits<{{mojom_type}}, {{mojom_type}}Ptr>::ReadFromDataView(
+bool StructTraits<{{mojom_type}}, {{mojom_type}}Ptr>::Read(
{{mojom_type}}DataView input,
{{mojom_type}}Ptr* output) {
bool success = true;
- if (!input.is_null()) {
- {{mojom_type}}Ptr result({{mojom_type}}::New());
- {{struct_macros.deserialize(struct, "input", "result->%s",
- "success")|indent(4)}}
- *output = std::move(result);
- } else {
- output->reset();
- }
+ {{mojom_type}}Ptr result({{mojom_type}}::New());
+ {{struct_macros.deserialize(struct, "input", "result->%s",
+ "success")|indent(4)}}
+ *output = std::move(result);
return success;
}

Powered by Google App Engine
This is Rietveld 408576698