[email protected] | 01cca004 | 2012-04-16 19:13:02 | [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_LOG_MACROS_H_ |
| 6 | #define IPC_PARAM_TRAITS_LOG_MACROS_H_ |
[email protected] | d7a5e3e | 2011-03-12 16:28:36 | [diff] [blame] | 7 | #pragma once |
[email protected] | 6476c72c | 2011-02-11 18:46:19 | [diff] [blame] | 8 | |
| 9 | #include <string> |
| 10 | |
| 11 | // Null out all the macros that need nulling. |
| 12 | #include "ipc/ipc_message_null_macros.h" |
| 13 | |
| 14 | // STRUCT declarations cause corresponding STRUCT_TRAITS declarations to occur. |
| 15 | #undef IPC_STRUCT_BEGIN |
[email protected] | 6766b17 | 2011-11-21 18:29:36 | [diff] [blame] | 16 | #undef IPC_STRUCT_BEGIN_WITH_PARENT |
[email protected] | 6476c72c | 2011-02-11 18:46:19 | [diff] [blame] | 17 | #undef IPC_STRUCT_MEMBER |
| 18 | #undef IPC_STRUCT_END |
[email protected] | 6766b17 | 2011-11-21 18:29:36 | [diff] [blame] | 19 | #define IPC_STRUCT_BEGIN_WITH_PARENT(struct_name, parent) \ |
| 20 | IPC_STRUCT_BEGIN(struct_name) |
[email protected] | 6476c72c | 2011-02-11 18:46:19 | [diff] [blame] | 21 | #define IPC_STRUCT_BEGIN(struct_name) IPC_STRUCT_TRAITS_BEGIN(struct_name) |
[email protected] | 01cca004 | 2012-04-16 19:13:02 | [diff] [blame] | 22 | #define IPC_STRUCT_MEMBER(type, name, ...) IPC_STRUCT_TRAITS_MEMBER(name) |
[email protected] | 6476c72c | 2011-02-11 18:46:19 | [diff] [blame] | 23 | #define IPC_STRUCT_END() IPC_STRUCT_TRAITS_END() |
| 24 | |
| 25 | // Set up so next include will generate log methods. |
| 26 | #undef IPC_STRUCT_TRAITS_BEGIN |
| 27 | #undef IPC_STRUCT_TRAITS_MEMBER |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 28 | #undef IPC_STRUCT_TRAITS_PARENT |
[email protected] | 6476c72c | 2011-02-11 18:46:19 | [diff] [blame] | 29 | #undef IPC_STRUCT_TRAITS_END |
| 30 | #define IPC_STRUCT_TRAITS_BEGIN(struct_name) \ |
| 31 | void ParamTraits<struct_name>::Log(const param_type& p, std::string* l) { \ |
| 32 | bool needs_comma = false; \ |
| 33 | l->append("("); |
| 34 | #define IPC_STRUCT_TRAITS_MEMBER(name) \ |
| 35 | if (needs_comma) \ |
| 36 | l->append(", "); \ |
| 37 | LogParam(p.name, l); \ |
| 38 | needs_comma = true; |
[email protected] | 94dc971d | 2011-03-05 19:08:32 | [diff] [blame] | 39 | #define IPC_STRUCT_TRAITS_PARENT(type) \ |
| 40 | if (needs_comma) \ |
| 41 | l->append(", "); \ |
| 42 | ParamTraits<type>::Log(p, l); \ |
| 43 | needs_comma = true; |
[email protected] | 6476c72c | 2011-02-11 18:46:19 | [diff] [blame] | 44 | #define IPC_STRUCT_TRAITS_END() \ |
| 45 | l->append(")"); \ |
| 46 | } |
| 47 | |
| 48 | #undef IPC_ENUM_TRAITS |
| 49 | #define IPC_ENUM_TRAITS(enum_name) \ |
| 50 | void ParamTraits<enum_name>::Log(const param_type& p, std::string* l) { \ |
| 51 | LogParam(static_cast<int>(p), l); \ |
| 52 | } |
| 53 | |
| 54 | #endif // IPC_PARAM_TRAITS_LOG_MACROS_H_ |
| 55 | |