Reset the background of title label when selected by arrow keys.
[chromium-blink-merge.git] / ipc / param_traits_macros.h
blobf4248df1116867b836f74a037f888ee1596a2efa
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
3 // found in the LICENSE file.
5 #ifndef IPC_PARAM_TRAITS_MACROS_H_
6 #define IPC_PARAM_TRAITS_MACROS_H_
8 #include <string>
10 // Traits generation for structs.
11 #define IPC_STRUCT_TRAITS_BEGIN(struct_name) \
12 namespace IPC { \
13 template <> \
14 struct IPC_MESSAGE_EXPORT ParamTraits<struct_name> { \
15 typedef struct_name param_type; \
16 static void Write(Message* m, const param_type& p); \
17 static bool Read(const Message* m, PickleIterator* iter, param_type* p); \
18 static void Log(const param_type& p, std::string* l); \
19 }; \
22 #define IPC_STRUCT_TRAITS_MEMBER(name)
23 #define IPC_STRUCT_TRAITS_PARENT(type)
24 #define IPC_STRUCT_TRAITS_END()
26 // Convenience macro for defining enumerated type traits for types which are
27 // not range-checked by the IPC system. The author of the message handlers
28 // is responsible for all validation. This macro should not need to be
29 // subsequently redefined.
30 #define IPC_ENUM_TRAITS(type) \
31 IPC_ENUM_TRAITS_VALIDATE(type, true)
33 // Convenience macro for defining enumerated type traits for types which are
34 // range-checked by the IPC system to be in the range of 0..maxvalue inclusive.
35 // This macro should not need to be subsequently redefined.
36 #define IPC_ENUM_TRAITS_MAX_VALUE(type, maxvalue) \
37 IPC_ENUM_TRAITS_MIN_MAX_VALUE(type, 0, maxvalue)
39 // Convenience macro for defining enumerated type traits for types which are
40 // range-checked by the IPC system to be in the range of minvalue..maxvalue
41 // inclusive. This macro should not need to be subsequently redefined.
42 // TODO(tsepez): Cast to std::underlying_type<>::type once that is permitted.
43 #define IPC_ENUM_TRAITS_MIN_MAX_VALUE(type, minvalue, maxvalue) \
44 IPC_ENUM_TRAITS_VALIDATE( \
45 type, (static_cast<int>(value) >= static_cast<int>(minvalue) && \
46 static_cast<int>(value) <= static_cast<int>(maxvalue)))
48 // Traits generation for enums. This macro may be redefined later.
49 #define IPC_ENUM_TRAITS_VALIDATE(enum_name, validation_expression) \
50 namespace IPC { \
51 template <> \
52 struct IPC_MESSAGE_EXPORT ParamTraits<enum_name> { \
53 typedef enum_name param_type; \
54 static void Write(Message* m, const param_type& p); \
55 static bool Read(const Message* m, PickleIterator* iter, param_type* p); \
56 static void Log(const param_type& p, std::string* l); \
57 }; \
60 #endif // IPC_PARAM_TRAITS_MACROS_H_