Chromium Code Reviews| 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 |