OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 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_IPC_PARAM_TRAITS_LOG_MACROS_H_ |
| 6 #define IPC_IPC_PARAM_TRAITS_LOG_MACROS_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 // Enable IPC include guard convention multiple-inclusion semantics. |
| 11 #undef IPC_MESSAGE_REINCLUDE |
| 12 #define IPC_MESSAGE_REINCLUDE 1 |
| 13 |
| 14 // Null out all the macros that need nulling. |
| 15 #include "ipc/ipc_message_null_macros.h" |
| 16 |
| 17 // STRUCT declarations cause corresponding STRUCT_TRAITS declarations to occur. |
| 18 #undef IPC_STRUCT_BEGIN |
| 19 #undef IPC_STRUCT_MEMBER |
| 20 #undef IPC_STRUCT_END |
| 21 #define IPC_STRUCT_BEGIN(struct_name) IPC_STRUCT_TRAITS_BEGIN(struct_name) |
| 22 #define IPC_STRUCT_MEMBER(type, name) IPC_STRUCT_TRAITS_MEMBER(name) |
| 23 #define IPC_STRUCT_END(struct_name) IPC_STRUCT_TRAITS_END(struct_name) |
| 24 |
| 25 // ENUM declarations cause corresponding ENUM_TRAITS declartions to occur. |
| 26 #undef IPC_ENUM_BEGIN |
| 27 #undef IPC_ENUM_VALUE |
| 28 #undef IPC_ENUM_VALUE |
| 29 #undef IPC_ENUM_END |
| 30 #define IPC_ENUM_BEGIN(enum_name) IPC_ENUM_TRAITS_BEGIN(enum_name) |
| 31 #define IPC_ENUM_VALUE(enum_name) IPC_ENUM_TRAITS_VALUE(enum_name) |
| 32 #define IPC_ENUM_END(enum_name) IPC_ENUM_TRAITS_END(enum_name) |
| 33 |
| 34 // Set up so next include will generate log methods. |
| 35 #undef IPC_STRUCT_TRAITS_BEGIN |
| 36 #undef IPC_STRUCT_TRAITS_MEMBER |
| 37 #undef IPC_STRUCT_TRAITS_END |
| 38 #define IPC_STRUCT_TRAITS_BEGIN(struct_name) \ |
| 39 void ParamTraits<struct_name>::Log(const param_type& p, std::string* l) { \ |
| 40 bool needs_comma = false; \ |
| 41 l->append("("); |
| 42 #define IPC_STRUCT_TRAITS_MEMBER(name) \ |
| 43 if (needs_comma) \ |
| 44 l->append(", "); \ |
| 45 LogParam(p.name, l); \ |
| 46 needs_comma = true; |
| 47 #define IPC_STRUCT_TRAITS_END(struct_name) l->append(")"); } |
| 48 |
| 49 #undef IPC_ENUM_TRAITS_BEGIN |
| 50 #undef IPC_ENUM_TRAITS_VALUE |
| 51 #undef IPC_ENUM_TRAITS_END |
| 52 #define IPC_ENUM_TRAITS_BEGIN(enum_name) \ |
| 53 void ParamTraits<enum_name>::Log(const param_type& p, std::string* l) { \ |
| 54 std::string state; \ |
| 55 switch (p) { |
| 56 #define IPC_ENUM_TRAITS_VALUE(name) \ |
| 57 case name: \ |
| 58 state = #name; \ |
| 59 break; |
| 60 #define IPC_ENUM_TRAITS_END(enum_name) \ |
| 61 default: \ |
| 62 state = "INVALID " #enum_name; \ |
| 63 break; \ |
| 64 } \ |
| 65 LogParam(state, l); \ |
| 66 } |
| 67 |
| 68 #endif // IPC_IPC_PARAM_TRAITS_LOG_MACROS_H_ |
| 69 |
OLD | NEW |