[email protected] | ce208f87 | 2012-03-07 20:42:56 | [diff] [blame^] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 6476c72c | 2011-02-11 18:46:19 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #ifndef IPC_PARAM_TRAITS_MACROS_H_ | ||||
6 | #define IPC_PARAM_TRAITS_MACROS_H_ | ||||
7 | |||||
8 | #include <string> | ||||
9 | |||||
10 | // Traits generation for structs. | ||||
11 | #define IPC_STRUCT_TRAITS_BEGIN(struct_name) \ | ||||
12 | namespace IPC { \ | ||||
13 | template <> \ | ||||
[email protected] | 03ff5e5 | 2011-09-30 00:28:14 | [diff] [blame] | 14 | struct IPC_MESSAGE_EXPORT ParamTraits<struct_name> { \ |
[email protected] | 6476c72c | 2011-02-11 18:46:19 | [diff] [blame] | 15 | typedef struct_name param_type; \ |
16 | static void Write(Message* m, const param_type& p); \ | ||||
[email protected] | ce208f87 | 2012-03-07 20:42:56 | [diff] [blame^] | 17 | static bool Read(const Message* m, PickleIterator* iter, param_type* p); \ |
[email protected] | 6476c72c | 2011-02-11 18:46:19 | [diff] [blame] | 18 | static void Log(const param_type& p, std::string* l); \ |
19 | }; \ | ||||
20 | } | ||||
21 | |||||
22 | #define IPC_STRUCT_TRAITS_MEMBER(name) | ||||
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 23 | #define IPC_STRUCT_TRAITS_PARENT(type) |
[email protected] | 6476c72c | 2011-02-11 18:46:19 | [diff] [blame] | 24 | #define IPC_STRUCT_TRAITS_END() |
25 | |||||
26 | // Traits generation for enums. | ||||
27 | #define IPC_ENUM_TRAITS(enum_name) \ | ||||
28 | namespace IPC { \ | ||||
29 | template <> \ | ||||
[email protected] | 269f86d | 2011-12-07 02:43:47 | [diff] [blame] | 30 | struct IPC_MESSAGE_EXPORT ParamTraits<enum_name> { \ |
[email protected] | 6476c72c | 2011-02-11 18:46:19 | [diff] [blame] | 31 | typedef enum_name param_type; \ |
32 | static void Write(Message* m, const param_type& p); \ | ||||
[email protected] | ce208f87 | 2012-03-07 20:42:56 | [diff] [blame^] | 33 | static bool Read(const Message* m, PickleIterator* iter, param_type* p); \ |
[email protected] | 6476c72c | 2011-02-11 18:46:19 | [diff] [blame] | 34 | static void Log(const param_type& p, std::string* l); \ |
35 | }; \ | ||||
36 | } | ||||
37 | |||||
38 | #endif // IPC_PARAM_TRAITS_MACROS_H_ | ||||
39 |