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

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

Issue 1978003002: Mojo C++ bindings: add detailed comments for String/Array/StructTraits. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@29_wtf_vector
Patch Set: 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
« no previous file with comments | « no previous file | mojo/public/cpp/bindings/array_traits_standard.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/array_traits.h
diff --git a/mojo/public/cpp/bindings/array_traits.h b/mojo/public/cpp/bindings/array_traits.h
index 10fc073ac9696318b62c1b7778921db557b8d206..86b24a8c177b5fa3260e8b66ae835e229d267b6a 100644
--- a/mojo/public/cpp/bindings/array_traits.h
+++ b/mojo/public/cpp/bindings/array_traits.h
@@ -7,12 +7,33 @@
namespace mojo {
-// This must be specialized for any UserType to be serialized/deserialized as
+// This must be specialized for any type |T| to be serialized/deserialized as
// a mojom array.
//
-// TODO(yzshen): This is work in progress. Add better documentation once the
-// interface becomes more stable.
-template <typename UserType>
+// Usually you would like to do a partial specialization for an array/vector
+// template. Imagine you want to specialize it for CustomArray<>, you need to
+// implement:
+//
+// template <typename T>
+// struct ArrayTraits<CustomArray<T>> {
+// using Element = T;
+//
+// // This two methods are optional. Please see comments in struct_traits.h
Ken Rockot(use gerrit already) 2016/05/13 20:40:46 nit: These two methods
yzshen1 2016/05/13 20:47:43 Thanks! Done.
+// static bool IsNull(const CustomArray<T>& input);
+// static void SetToNull(CustomArray<T>* output);
+//
+// static size_t GetSize(const CustomArray<T>& input);
+//
+// static T* GetData(CustomArray<T>& input);
+// static const T* GetData(const CustomArray<T>& input);
+//
+// static T& GetAt(CustomArray<T>& input, size_t index);
+// static const T& GetAt(const CustomArray<T>& input, size_t index);
+//
+// static void Resize(CustomArray<T>& input, size_t size);
+// };
+//
+template <typename T>
struct ArrayTraits;
} // namespace mojo
« no previous file with comments | « no previous file | mojo/public/cpp/bindings/array_traits_standard.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698