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