OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 IPC_IPC_MESSAGE_UTILS_H_ | 5 #ifndef IPC_IPC_MESSAGE_UTILS_H_ |
6 #define IPC_IPC_MESSAGE_UTILS_H_ | 6 #define IPC_IPC_MESSAGE_UTILS_H_ |
7 | 7 |
8 #include <limits.h> | 8 #include <limits.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <stdint.h> | 10 #include <stdint.h> |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 std::string params; | 70 std::string params; |
71 }; | 71 }; |
72 | 72 |
73 //----------------------------------------------------------------------------- | 73 //----------------------------------------------------------------------------- |
74 | 74 |
75 // A dummy struct to place first just to allow leading commas for all | 75 // A dummy struct to place first just to allow leading commas for all |
76 // members in the macro-generated constructor initializer lists. | 76 // members in the macro-generated constructor initializer lists. |
77 struct NoParams { | 77 struct NoParams { |
78 }; | 78 }; |
79 | 79 |
| 80 // Specializations are checked by 'IPC checker' part of find-bad-constructs |
| 81 // Clang plugin (see WriteParam() below for the details). |
| 82 template <typename... Ts> |
| 83 struct CheckedTuple { |
| 84 typedef std::tuple<Ts...> Tuple; |
| 85 }; |
| 86 |
80 template <class P> | 87 template <class P> |
81 static inline void GetParamSize(base::PickleSizer* sizer, const P& p) { | 88 static inline void GetParamSize(base::PickleSizer* sizer, const P& p) { |
82 typedef typename SimilarTypeTraits<P>::Type Type; | 89 typedef typename SimilarTypeTraits<P>::Type Type; |
83 ParamTraits<Type>::GetSize(sizer, static_cast<const Type&>(p)); | 90 ParamTraits<Type>::GetSize(sizer, static_cast<const Type&>(p)); |
84 } | 91 } |
85 | 92 |
| 93 // This function is checked by 'IPC checker' part of find-bad-constructs |
| 94 // Clang plugin to make it's not called on the following types: |
| 95 // 1. long / unsigned long (but not typedefs to) |
| 96 // 2. intmax_t, uintmax_t, intptr_t, uintptr_t, wint_t, |
| 97 // size_t, rsize_t, ssize_t, ptrdiff_t, dev_t, off_t, clock_t, |
| 98 // time_t, suseconds_t (including typedefs to) |
| 99 // 3. Any template referencing types above (e.g. std::vector<size_t>) |
86 template <class P> | 100 template <class P> |
87 static inline void WriteParam(base::Pickle* m, const P& p) { | 101 static inline void WriteParam(base::Pickle* m, const P& p) { |
88 typedef typename SimilarTypeTraits<P>::Type Type; | 102 typedef typename SimilarTypeTraits<P>::Type Type; |
89 ParamTraits<Type>::Write(m, static_cast<const Type& >(p)); | 103 ParamTraits<Type>::Write(m, static_cast<const Type& >(p)); |
90 } | 104 } |
91 | 105 |
92 template <class P> | 106 template <class P> |
93 static inline bool WARN_UNUSED_RESULT ReadParam(const base::Pickle* m, | 107 static inline bool WARN_UNUSED_RESULT ReadParam(const base::Pickle* m, |
94 base::PickleIterator* iter, | 108 base::PickleIterator* iter, |
95 P* p) { | 109 P* p) { |
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1085 template <class ReplyParamType> | 1099 template <class ReplyParamType> |
1086 inline void LogReplyParamsToMessage(const ReplyParamType& reply_params, | 1100 inline void LogReplyParamsToMessage(const ReplyParamType& reply_params, |
1087 const Message* msg) {} | 1101 const Message* msg) {} |
1088 | 1102 |
1089 inline void ConnectMessageAndReply(const Message* msg, Message* reply) {} | 1103 inline void ConnectMessageAndReply(const Message* msg, Message* reply) {} |
1090 #endif | 1104 #endif |
1091 | 1105 |
1092 } // namespace IPC | 1106 } // namespace IPC |
1093 | 1107 |
1094 #endif // IPC_IPC_MESSAGE_UTILS_H_ | 1108 #endif // IPC_IPC_MESSAGE_UTILS_H_ |
OLD | NEW |