blob: b2d1f2ea17ad1267b78321d3fa8efe190dd2c46c [file] [log] [blame]
[email protected]6476c72c2011-02-11 18:46:191// 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_PARAM_TRAITS_LOG_MACROS_H_
6#define IPC_PARAM_TRAITS_LOG_MACROS_H_
[email protected]d7a5e3e2011-03-12 16:28:367#pragma once
[email protected]6476c72c2011-02-11 18:46:198
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]6766b172011-11-21 18:29:3616#undef IPC_STRUCT_BEGIN_WITH_PARENT
[email protected]6476c72c2011-02-11 18:46:1917#undef IPC_STRUCT_MEMBER
18#undef IPC_STRUCT_END
[email protected]6766b172011-11-21 18:29:3619#define IPC_STRUCT_BEGIN_WITH_PARENT(struct_name, parent) \
20 IPC_STRUCT_BEGIN(struct_name)
[email protected]6476c72c2011-02-11 18:46:1921#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() 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]94dc971d2011-03-05 19:08:3228#undef IPC_STRUCT_TRAITS_PARENT
[email protected]6476c72c2011-02-11 18:46:1929#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]94dc971d2011-03-05 19:08:3239#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]6476c72c2011-02-11 18:46:1944#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