Index: ipc/ipc_message_macros.h |
=================================================================== |
--- ipc/ipc_message_macros.h (revision 77874) |
+++ ipc/ipc_message_macros.h (working copy) |
@@ -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 @@ |
#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 @@ |
// 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_ |