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

Unified Diff: mojo/public/cpp/bindings/struct_traits.h

Issue 1524703002: [mojo] Support native types with mojom wire format (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bindings-5-pickles
Patch Set: doc Created 5 years 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
« no previous file with comments | « mojo/public/cpp/bindings/BUILD.gn ('k') | mojo/public/cpp/bindings/tests/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/struct_traits.h
diff --git a/mojo/public/cpp/bindings/struct_traits.h b/mojo/public/cpp/bindings/struct_traits.h
new file mode 100644
index 0000000000000000000000000000000000000000..fb7290b20ab7c4effc89177a64250606d6868dca
--- /dev/null
+++ b/mojo/public/cpp/bindings/struct_traits.h
@@ -0,0 +1,35 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_PUBLIC_CPP_BINDINGS_STRUCT_TRAITS_H_
+#define MOJO_PUBLIC_CPP_BINDINGS_STRUCT_TRAITS_H_
+
+namespace mojo {
+
+// This must be specialized for any type |T| to be serialized/deserialized as
+// a mojom struct of type |MojomType|.
+//
+// Each specialization must implement a few things:
+//
+// 1. Static getters for each field in the Mojom type. These should be
+// of the form:
+//
+// static <return type> <field name>(const T&)
+//
+// and should return a serializable form of the named field as extracted
+// from the referenced |T| instance.
+//
+// 2. A static Read method to initialize a new |T| from a MojomType::Reader:
+//
+// static bool Read(MojomType::Reader r, T* out);
Jeffrey Yasskin 2016/01/28 18:01:40 Could you document whether a 'true' or 'false' ret
+//
+// The generated MojomType::Reader type provides a convenient, inexpensive
+// view of a serialized struct's field data.
+//
+template <typename MojomType, typename T>
+struct StructTraits;
+
+} // namespace mojo
+
+#endif // MOJO_PUBLIC_CPP_BINDINGS_STRUCT_TRAITS_H_
« no previous file with comments | « mojo/public/cpp/bindings/BUILD.gn ('k') | mojo/public/cpp/bindings/tests/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698