diff options
author | tsepez@chromium.org <tsepez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-12 16:28:36 +0000 |
---|---|---|
committer | tsepez@chromium.org <tsepez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-12 16:28:36 +0000 |
commit | d7a5e3e4302a31eca7e7bbc8fb61b5ec0fa9d5d9 (patch) | |
tree | aae51f588dc045640036558410f6e3e8746434ed /ipc/ipc_message_macros.h | |
parent | 6033af3b77d7c40fcdb1c80ac77d4e49ba8236c3 (diff) | |
download | chromium_src-d7a5e3e4302a31eca7e7bbc8fb61b5ec0fa9d5d9.zip chromium_src-d7a5e3e4302a31eca7e7bbc8fb61b5ec0fa9d5d9.tar.gz chromium_src-d7a5e3e4302a31eca7e7bbc8fb61b5ec0fa9d5d9.tar.bz2 |
Change common_message_generator code block.
Makes namespace IPC {} more tightly wrapped around the inclusion of
the genertor header file.
Updates comments in ipc_message_macros to indicate this new style of block.
Makes message ID generation into a macro so can be re-used in forthcoming
ipclist CL. Simplfies the NULL macros.
Adds #pragma once to param traits, because we can.
Review URL: http://codereview.chromium.org/6683014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77943 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc/ipc_message_macros.h')
-rw-r--r-- | ipc/ipc_message_macros.h | 44 |
1 files changed, 27 insertions, 17 deletions
diff --git a/ipc/ipc_message_macros.h b/ipc/ipc_message_macros.h index a41cadf..bdc5acc 100644 --- a/ipc/ipc_message_macros.h +++ b/ipc/ipc_message_macros.h @@ -29,9 +29,9 @@ // A message generator .h header file pulls in all other message-declaring // headers for a given component. It is included by a message generator // .cc file, which is where all the generated code will wind up. Typically, -// you will use an existing generator (e.g. common_message_generator.cc and -// common_message_generator.h in /chrome/common), but there are circumstances -// where you may add a new one. +// you will use an existing generator (e.g. common_message_generator.cc +// in /chrome/common), but there are circumstances where you may add a +// new one. // // In the rare cicrucmstances where you can't re-use an existing file, // your YYY_message_generator.cc file for a component YYY would contain @@ -45,15 +45,19 @@ // // Generate destructors. // #include "ipc/struct_destructor_macros.h" // #include "path/to/YYY_message_generator.h" -// namespace IPC { // // Generate param traits write methods. // #include "ipc/param_traits_write_macros.h" +// namespace IPC { // #include "path/to/YYY_message_generator.h" +// } // namespace IPC // // Generate param traits read methods. // #include "ipc/param_traits_read_macros.h" +// namespace IPC { // #include "path/to/YYY_message_generator.h" +// } // namespace IPC // // Generate param traits log methods. // #include "ipc/param_traits_log_macros.h" +// namespace IPC { // #include "path/to/YYY_message_generator.h" // } // namespace IPC // @@ -186,7 +190,7 @@ #define IPC_STRUCT_END() }; // Message macros collect specific numbers of arguments and funnel them into -// the common message generation macro. +// the common message generation macro. These should never be redefined. #define IPC_MESSAGE_CONTROL0(msg_class) \ IPC_MESSAGE_DECL(EMPTY, CONTROL, msg_class, 0, 0, (), ()) @@ -406,11 +410,7 @@ // Common message macro which dispatches into one of the 6 (sync x kind) // routines. There is a way that these 6 cases can be lumped together, // but the macros get very complicated in that case. -// Note: we currently use __LINE__ to give unique IDs to messages within -// a file. They're globally unique since each file defines its own -// IPC_MESSAGE_START. Ideally, we wouldn't use line numbers (a possibility -// is to instead use the __COUNTER__ macro, but it needs gcc 4.3 and xcode -// doesn't use it yet). +// Note: intended be redefined to generate other information. #define IPC_MESSAGE_DECL(sync, kind, msg_class, \ in_cnt, out_cnt, in_list, out_list) \ IPC_##sync##_##kind##_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \ @@ -419,14 +419,14 @@ #define IPC_EMPTY_CONTROL_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \ class msg_class : public IPC::Message { \ public: \ - enum { ID = (IPC_MESSAGE_START << 16) + __LINE__ }; \ + enum { ID = IPC_MESSAGE_ID() }; \ msg_class() : IPC::Message(MSG_ROUTING_CONTROL, ID, PRIORITY_NORMAL) {} \ }; #define IPC_EMPTY_ROUTED_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \ class msg_class : public IPC::Message { \ public: \ - enum { ID = (IPC_MESSAGE_START << 16) + __LINE__ }; \ + enum { ID = IPC_MESSAGE_ID() }; \ msg_class(int32 routing_id) \ : IPC::Message(routing_id, ID, PRIORITY_NORMAL) {} \ }; @@ -435,7 +435,7 @@ class msg_class : \ public IPC::MessageWithTuple<IPC_TUPLE_IN_##in_cnt in_list> { \ public: \ - enum { ID = (IPC_MESSAGE_START << 16) + __LINE__ }; \ + enum { ID = IPC_MESSAGE_ID() }; \ msg_class(IPC_TYPE_IN_##in_cnt in_list); \ ~msg_class(); \ static void Log(std::string* name, const Message* msg, std::string* l); \ @@ -445,7 +445,7 @@ class msg_class : \ public IPC::MessageWithTuple<IPC_TUPLE_IN_##in_cnt in_list> { \ public: \ - enum { ID = (IPC_MESSAGE_START << 16) + __LINE__ }; \ + enum { ID = IPC_MESSAGE_ID() }; \ msg_class(int32 routing_id IPC_COMMA_##in_cnt \ IPC_TYPE_IN_##in_cnt in_list); \ ~msg_class(); \ @@ -457,7 +457,7 @@ public IPC::MessageWithReply<IPC_TUPLE_IN_##in_cnt in_list, \ IPC_TUPLE_OUT_##out_cnt out_list> { \ public: \ - enum { ID = (IPC_MESSAGE_START << 16) + __LINE__ }; \ + enum { ID = IPC_MESSAGE_ID() }; \ msg_class(IPC_TYPE_IN_##in_cnt in_list \ IPC_COMMA_AND_##in_cnt(IPC_COMMA_##out_cnt) \ IPC_TYPE_OUT_##out_cnt out_list); \ @@ -470,7 +470,7 @@ public IPC::MessageWithReply<IPC_TUPLE_IN_##in_cnt in_list, \ IPC_TUPLE_OUT_##out_cnt out_list> { \ public: \ - enum { ID = (IPC_MESSAGE_START << 16) + __LINE__ }; \ + enum { ID = IPC_MESSAGE_ID() }; \ msg_class(int32 routing_id \ IPC_COMMA_OR_##in_cnt(IPC_COMMA_##out_cnt) \ IPC_TYPE_IN_##in_cnt in_list \ @@ -671,6 +671,16 @@ LogFunctionMap g_log_function_mapping; #define IPC_COMMA_OR_4(x) , #define IPC_COMMA_OR_5(x) , +// Message IDs +// Note: we currently use __LINE__ to give unique IDs to messages within +// a file. They're globally unique since each file defines its own +// IPC_MESSAGE_START. Ideally, we wouldn't use line numbers (a possibility +// is to instead use the __COUNTER__ macro, but it needs gcc 4.3 and xcode +// doesn't use it yet). +#define IPC_MESSAGE_ID() ((IPC_MESSAGE_START << 16) + __LINE__) +#define IPC_MESSAGE_ID_CLASS(id) ((id) >> 16) +#define IPC_MESSAGE_ID_LINE(id) ((id) & 0xffff) + // Message crackers and handlers. // Prefer to use the IPC_BEGIN_MESSAGE_MAP_EX to the older macros since they // allow you to detect when a message could not be de-serialized. Usage: @@ -754,7 +764,7 @@ LogFunctionMap g_log_function_mapping; // This corresponds to an enum value from IPCMessageStart. #define IPC_MESSAGE_CLASS(message) \ - message.type() >> 16 + IPC_MESSAGE_ID_CLASS(message.type()) #endif // IPC_IPC_MESSAGE_MACROS_H_ |