| 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_PARAM_TRAITS_MACROS_H_ | 5 #ifndef IPC_PARAM_TRAITS_MACROS_H_ |
| 6 #define IPC_PARAM_TRAITS_MACROS_H_ | 6 #define IPC_PARAM_TRAITS_MACROS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 // Traits generation for structs. | 10 // Traits generation for structs. |
| 11 #define IPC_STRUCT_TRAITS_BEGIN(struct_name) \ | 11 #define IPC_STRUCT_TRAITS_BEGIN(struct_name) \ |
| 12 namespace IPC { \ | 12 namespace IPC { \ |
| 13 template <> \ | 13 template <> \ |
| 14 struct IPC_MESSAGE_EXPORT ParamTraits<struct_name> { \ | 14 struct IPC_MESSAGE_EXPORT ParamTraits<struct_name> { \ |
| 15 typedef struct_name param_type; \ | 15 typedef struct_name param_type; \ |
| 16 static void Write(Message* m, const param_type& p); \ | 16 static void Write(base::Pickle* m, const param_type& p); \ |
| 17 static bool Read(const Message* m, base::PickleIterator* iter, \ | 17 static bool Read(const base::Pickle* m, \ |
| 18 param_type* p); \ | 18 base::PickleIterator* iter, \ |
| 19 static void Log(const param_type& p, std::string* l); \ | 19 param_type* p); \ |
| 20 }; \ | 20 static void Log(const param_type& p, std::string* l); \ |
| 21 }; \ |
| 21 } | 22 } |
| 22 | 23 |
| 23 #define IPC_STRUCT_TRAITS_MEMBER(name) | 24 #define IPC_STRUCT_TRAITS_MEMBER(name) |
| 24 #define IPC_STRUCT_TRAITS_PARENT(type) | 25 #define IPC_STRUCT_TRAITS_PARENT(type) |
| 25 #define IPC_STRUCT_TRAITS_END() | 26 #define IPC_STRUCT_TRAITS_END() |
| 26 | 27 |
| 27 // Convenience macro for defining enumerated type traits for types which are | 28 // Convenience macro for defining enumerated type traits for types which are |
| 28 // not range-checked by the IPC system. The author of the message handlers | 29 // not range-checked by the IPC system. The author of the message handlers |
| 29 // is responsible for all validation. This macro should not need to be | 30 // is responsible for all validation. This macro should not need to be |
| 30 // subsequently redefined. | 31 // subsequently redefined. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 41 // range-checked by the IPC system to be in the range of minvalue..maxvalue | 42 // range-checked by the IPC system to be in the range of minvalue..maxvalue |
| 42 // inclusive. This macro should not need to be subsequently redefined. | 43 // inclusive. This macro should not need to be subsequently redefined. |
| 43 // TODO(tsepez): Cast to std::underlying_type<>::type once that is permitted. | 44 // TODO(tsepez): Cast to std::underlying_type<>::type once that is permitted. |
| 44 #define IPC_ENUM_TRAITS_MIN_MAX_VALUE(type, minvalue, maxvalue) \ | 45 #define IPC_ENUM_TRAITS_MIN_MAX_VALUE(type, minvalue, maxvalue) \ |
| 45 IPC_ENUM_TRAITS_VALIDATE( \ | 46 IPC_ENUM_TRAITS_VALIDATE( \ |
| 46 type, (static_cast<int>(value) >= static_cast<int>(minvalue) && \ | 47 type, (static_cast<int>(value) >= static_cast<int>(minvalue) && \ |
| 47 static_cast<int>(value) <= static_cast<int>(maxvalue))) | 48 static_cast<int>(value) <= static_cast<int>(maxvalue))) |
| 48 | 49 |
| 49 // Traits generation for enums. This macro may be redefined later. | 50 // Traits generation for enums. This macro may be redefined later. |
| 50 #define IPC_ENUM_TRAITS_VALIDATE(enum_name, validation_expression) \ | 51 #define IPC_ENUM_TRAITS_VALIDATE(enum_name, validation_expression) \ |
| 51 namespace IPC { \ | 52 namespace IPC { \ |
| 52 template <> \ | 53 template <> \ |
| 53 struct IPC_MESSAGE_EXPORT ParamTraits<enum_name> { \ | 54 struct IPC_MESSAGE_EXPORT ParamTraits<enum_name> { \ |
| 54 typedef enum_name param_type; \ | 55 typedef enum_name param_type; \ |
| 55 static void Write(Message* m, const param_type& p); \ | 56 static void Write(base::Pickle* m, const param_type& p); \ |
| 56 static bool Read(const Message* m, base::PickleIterator* iter, \ | 57 static bool Read(const base::Pickle* m, \ |
| 57 param_type* p); \ | 58 base::PickleIterator* iter, \ |
| 58 static void Log(const param_type& p, std::string* l); \ | 59 param_type* p); \ |
| 59 }; \ | 60 static void Log(const param_type& p, std::string* l); \ |
| 61 }; \ |
| 60 } | 62 } |
| 61 | 63 |
| 62 #endif // IPC_PARAM_TRAITS_MACROS_H_ | 64 #endif // IPC_PARAM_TRAITS_MACROS_H_ |
| 63 | 65 |
| OLD | NEW |