OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_MAP_SERIALIZATION_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_MAP_SERIALIZATION_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_MAP_SERIALIZATION_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_MAP_SERIALIZATION_H_ |
7 | 7 |
8 #include <type_traits> | 8 #include <type_traits> |
9 | 9 |
10 #include "mojo/public/cpp/bindings/lib/array_internal.h" | 10 #include "mojo/public/cpp/bindings/lib/array_internal.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
61 typename WrapperTraits<S>::DataType>::type, | 61 typename WrapperTraits<S>::DataType>::type, |
62 true, | 62 true, |
63 false> { | 63 false> { |
64 typedef | 64 typedef |
65 typename std::remove_pointer<typename WrapperTraits<S>::DataType>::type | 65 typename std::remove_pointer<typename WrapperTraits<S>::DataType>::type |
66 S_Data; | 66 S_Data; |
67 static size_t GetBaseArraySize(size_t count) { | 67 static size_t GetBaseArraySize(size_t count) { |
68 return count * sizeof(StructPointer<S_Data>); | 68 return count * sizeof(StructPointer<S_Data>); |
69 } | 69 } |
70 static size_t GetItemSize(const S& item) { | 70 static size_t GetItemSize(const S& item) { |
71 return GetSerializedSize_(*UnwrapConstStructPtr<S>::value(item)); | 71 return !item.is_null() |
viettrungluu
2015/12/07 22:03:51
nit: Is S not testable? (I.e., would |return item
vardhan
2015/12/07 22:48:31
Done.
It's testable. I was trying to be more expl
| |
72 ? GetSerializedSize_(*UnwrapConstStructPtr<S>::value(item)) | |
73 : 0; | |
72 } | 74 } |
73 }; | 75 }; |
74 | 76 |
75 template <typename U, typename U_Data> | 77 template <typename U, typename U_Data> |
76 struct MapSerializer<U, U_Data, true, true> { | 78 struct MapSerializer<U, U_Data, true, true> { |
77 static size_t GetBaseArraySize(size_t count) { | 79 static size_t GetBaseArraySize(size_t count) { |
78 return count * sizeof(U_Data); | 80 return count * sizeof(U_Data); |
79 } | 81 } |
80 static size_t GetItemSize(const U& item) { | 82 static size_t GetItemSize(const U& item) { |
81 return GetSerializedSize_(item, true); | 83 return GetSerializedSize_(item, true); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
203 | 205 |
204 *output = Map<MapKey, MapValue>(keys.Pass(), values.Pass()); | 206 *output = Map<MapKey, MapValue>(keys.Pass(), values.Pass()); |
205 } else { | 207 } else { |
206 output->reset(); | 208 output->reset(); |
207 } | 209 } |
208 } | 210 } |
209 | 211 |
210 } // namespace mojo | 212 } // namespace mojo |
211 | 213 |
212 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_MAP_SERIALIZATION_H_ | 214 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_MAP_SERIALIZATION_H_ |
OLD | NEW |