Chromium Code Reviews| Index: ipc/param_traits_read_macros.h |
| diff --git a/ipc/param_traits_read_macros.h b/ipc/param_traits_read_macros.h |
| index 3fc0ad1f0f05ff4151ff2bcc6ab5dcdcb7cdcfb9..978256ca8420d133b3b3932b1f3ca445282371c3 100644 |
| --- a/ipc/param_traits_read_macros.h |
| +++ b/ipc/param_traits_read_macros.h |
| @@ -9,13 +9,11 @@ |
| #include "ipc/ipc_message_null_macros.h" |
| // STRUCT declarations cause corresponding STRUCT_TRAITS declarations to occur. |
| -#undef IPC_STRUCT_BEGIN |
| #undef IPC_STRUCT_BEGIN_WITH_PARENT |
| #undef IPC_STRUCT_MEMBER |
| #undef IPC_STRUCT_END |
| #define IPC_STRUCT_BEGIN_WITH_PARENT(struct_name, parent) \ |
| - IPC_STRUCT_BEGIN(struct_name) |
| -#define IPC_STRUCT_BEGIN(struct_name) IPC_STRUCT_TRAITS_BEGIN(struct_name) |
| + IPC_STRUCT_TRAITS_BEGIN(struct_name) |
| #define IPC_STRUCT_MEMBER(type, name, ...) IPC_STRUCT_TRAITS_MEMBER(name) |
| #define IPC_STRUCT_END() IPC_STRUCT_TRAITS_END() |
| @@ -32,14 +30,16 @@ |
| #define IPC_STRUCT_TRAITS_PARENT(type) ParamTraits<type>::Read(m, iter, p) && |
| #define IPC_STRUCT_TRAITS_END() 1; } |
| -#undef IPC_ENUM_TRAITS |
| -#define IPC_ENUM_TRAITS(enum_name) \ |
| +#undef IPC_ENUM_TRAITS_VALIDATE |
| +#define IPC_ENUM_TRAITS_VALIDATE(enum_name, validation_expression) \ |
| bool ParamTraits<enum_name>:: \ |
| Read(const Message* m, PickleIterator* iter, param_type* p) { \ |
| - int type; \ |
| - if (!m->ReadInt(iter, &type)) \ |
| + int value; \ |
| + if (!m->ReadInt(iter, &value)) \ |
| return false; \ |
| - *p = static_cast<param_type>(type); \ |
| + if (!validation_expression) \ |
|
darin (slow to review)
2013/06/03 17:52:53
nit: you might consider writing this as "!(validat
Tom Sepez
2013/06/03 18:33:00
Indeed. thanks.
|
| + return false; \ |
| + *p = static_cast<param_type>(value); \ |
| return true; \ |
| } |