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

Side by Side Diff: mojo/public/cpp/bindings/lib/map_serialization.h

Issue 1833033003: C++ Bindings: Remove 'inline' arg from generated union serialization functions. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 9 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 unified diff | Download patch
OLDNEW
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 item ? GetSerializedSize_(*UnwrapConstStructPtr<S>::value(item)) : 0; 71 return item ? GetSerializedSize_(*UnwrapConstStructPtr<S>::value(item)) : 0;
72 } 72 }
73 }; 73 };
74 74
75 template <typename U, typename U_Data> 75 template <typename U, typename U_Data>
76 struct MapSerializer<U, U_Data, true, true> { 76 struct MapSerializer<U, U_Data, true, true> {
77 static size_t GetBaseArraySize(size_t count) { 77 static size_t GetBaseArraySize(size_t count) {
78 return count * sizeof(U_Data); 78 // GetSerializedSize_ (called in GetItemSize()) will account for
79 // sizeof(U_Data), so prevent double counting by having this count be 0.
80 return 0;
79 } 81 }
80 static size_t GetItemSize(const U& item) { 82 static size_t GetItemSize(const U& item) { return GetSerializedSize_(item); }
81 return GetSerializedSize_(item, true);
82 }
83 }; 83 };
84 84
85 template <> 85 template <>
86 struct MapSerializer<String, String_Data*, false, false> { 86 struct MapSerializer<String, String_Data*, false, false> {
87 static size_t GetBaseArraySize(size_t count) { 87 static size_t GetBaseArraySize(size_t count) {
88 return count * sizeof(StringPointer); 88 return count * sizeof(StringPointer);
89 } 89 }
90 static size_t GetItemSize(const String& item) { 90 static size_t GetItemSize(const String& item) {
91 return GetSerializedSize_(item); 91 return GetSerializedSize_(item);
92 } 92 }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 203
204 *output = Map<MapKey, MapValue>(keys.Pass(), values.Pass()); 204 *output = Map<MapKey, MapValue>(keys.Pass(), values.Pass());
205 } else { 205 } else {
206 output->reset(); 206 output->reset();
207 } 207 }
208 } 208 }
209 209
210 } // namespace mojo 210 } // namespace mojo
211 211
212 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_MAP_SERIALIZATION_H_ 212 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_MAP_SERIALIZATION_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/array_serialization.h ('k') | mojo/public/cpp/bindings/tests/union_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698