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

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

Issue 2014403002: Mojo C++ bindings: custom type mapping of map (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « mojo/public/cpp/bindings/lib/serialization_forward.h ('k') | mojo/public/cpp/bindings/map.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_SERIALIZATION_UTIL_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_UTIL_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_UTIL_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_UTIL_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 return f(std::forward<InputUserType>(input), context); 220 return f(std::forward<InputUserType>(input), context);
221 } 221 }
222 222
223 template <typename ReturnType, typename ParamType, typename InputUserType> 223 template <typename ReturnType, typename ParamType, typename InputUserType>
224 ReturnType CallWithContext(ReturnType (*f)(ParamType), 224 ReturnType CallWithContext(ReturnType (*f)(ParamType),
225 InputUserType&& input, 225 InputUserType&& input,
226 void* context) { 226 void* context) {
227 return f(std::forward<InputUserType>(input)); 227 return f(std::forward<InputUserType>(input));
228 } 228 }
229 229
230 template <typename T, typename MaybeConstUserType>
231 struct HasGetDataMethod {
232 template <typename U>
233 static char Test(decltype(U::GetData(std::declval<MaybeConstUserType&>()))*);
234 template <typename U>
235 static int Test(...);
236 static const bool value = sizeof(Test<T>(0)) == sizeof(char);
237
238 private:
239 EnsureTypeIsComplete<T> check_t_;
240 };
241
242 template <
243 typename Traits,
244 typename MaybeConstUserType,
245 typename std::enable_if<
246 HasGetDataMethod<Traits, MaybeConstUserType>::value>::type* = nullptr>
247 decltype(Traits::GetData(std::declval<MaybeConstUserType&>()))
248 CallGetDataIfExists(MaybeConstUserType& input) {
249 return Traits::GetData(input);
250 }
251
252 template <
253 typename Traits,
254 typename MaybeConstUserType,
255 typename std::enable_if<
256 !HasGetDataMethod<Traits, MaybeConstUserType>::value>::type* = nullptr>
257 void* CallGetDataIfExists(MaybeConstUserType& input) {
258 return nullptr;
259 }
260
230 } // namespace internal 261 } // namespace internal
231 } // namespace mojo 262 } // namespace mojo
232 263
233 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_UTIL_H_ 264 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_UTIL_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/serialization_forward.h ('k') | mojo/public/cpp/bindings/map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698