summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortsepez@chromium.org <tsepez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-11 18:46:19 +0000
committertsepez@chromium.org <tsepez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-11 18:46:19 +0000
commit6476c72c1c90f470a4f395ae83a3adc4d866b7ab (patch)
tree53b0a26ecb2bd2da474190eba393d189cdb4648a
parent5d29a5ce7ec414c2e1fcc29e44aa1fd0f0766b9c (diff)
downloadchromium_src-6476c72c1c90f470a4f395ae83a3adc4d866b7ab.zip
chromium_src-6476c72c1c90f470a4f395ae83a3adc4d866b7ab.tar.gz
chromium_src-6476c72c1c90f470a4f395ae83a3adc4d866b7ab.tar.bz2
Make the implementation .cc files go away, instead have the authors give us a header only.
Review URL: http://codereview.chromium.org/6410007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74637 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/chrome_common.gypi1
-rw-r--r--chrome/common/common_message_generator.cc33
-rw-r--r--chrome/common/common_message_generator.h28
-rw-r--r--ipc/ipc.gypi6
-rw-r--r--ipc/ipc_message_macros.h178
-rw-r--r--ipc/ipc_message_null_macros.h167
-rw-r--r--ipc/ipc_message_utils.h6
-rw-r--r--ipc/param_traits_log_macros.h45
-rw-r--r--ipc/param_traits_macros.h38
-rw-r--r--ipc/param_traits_read_macros.h42
-rw-r--r--ipc/param_traits_write_macros.h35
-rw-r--r--ipc/struct_constructor_macros.h20
-rw-r--r--ipc/struct_destructor_macros.h16
13 files changed, 598 insertions, 17 deletions
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index 0557c4e..7112f9f 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -46,6 +46,7 @@
'common/chrome_counters.h',
'common/chrome_version_info.cc',
'common/chrome_version_info.h',
+ 'common/common_message_generator.cc',
'common/common_param_traits.cc',
'common/common_param_traits.h',
'common/content_restriction.h',
diff --git a/chrome/common/common_message_generator.cc b/chrome/common/common_message_generator.cc
new file mode 100644
index 0000000..e349e3b
--- /dev/null
+++ b/chrome/common/common_message_generator.cc
@@ -0,0 +1,33 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Get basic type definitions.
+#define IPC_MESSAGE_IMPL
+#include "chrome/common/common_message_generator.h"
+#include "chrome/common/common_param_traits.h"
+
+// Generate constructors.
+#include "ipc/struct_constructor_macros.h"
+#include "chrome/common/common_message_generator.h"
+
+// Generate destructors.
+#include "ipc/struct_destructor_macros.h"
+#include "chrome/common/common_message_generator.h"
+
+namespace IPC {
+
+// Generate param traits write methods.
+#include "ipc/param_traits_write_macros.h"
+#include "chrome/common/common_message_generator.h"
+
+// Generate param traits read methods.
+#include "ipc/param_traits_read_macros.h"
+#include "chrome/common/common_message_generator.h"
+
+// Generate param traits log methods.
+#include "ipc/param_traits_log_macros.h"
+#include "chrome/common/common_message_generator.h"
+
+} // namespace IPC
+
diff --git a/chrome/common/common_message_generator.h b/chrome/common/common_message_generator.h
new file mode 100644
index 0000000..61e5c04
--- /dev/null
+++ b/chrome/common/common_message_generator.h
@@ -0,0 +1,28 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Multiply-included file, hence no include guard.
+
+#if 0 // This feature is not yet enabled for these files.
+
+#include "chrome/common/autofill_messages.h"
+#include "chrome/common/automation_messages.h"
+#include "chrome/common/database_messages.h"
+#include "chrome/common/devtools_messages.h"
+#include "chrome/common/dom_storage_messages.h"
+#include "chrome/common/file_utilities_messages.h"
+#include "chrome/common/gpu_messages.h"
+#include "chrome/common/indexed_db_messages.h"
+#include "chrome/common/mime_registry_messages.h"
+#include "chrome/common/nacl_messages.h"
+#include "chrome/common/pepper_file_messages.h"
+#include "chrome/common/pepper_messages.h"
+#include "chrome/common/plugin_messages.h"
+#include "chrome/common/render_messages.h"
+#include "chrome/common/service_messages.h"
+#include "chrome/common/speech_input_messages.h"
+#include "chrome/common/utility_messages.h"
+#include "chrome/common/worker_messages.h"
+
+#endif
diff --git a/ipc/ipc.gypi b/ipc/ipc.gypi
index acc1670..485d3d9 100644
--- a/ipc/ipc.gypi
+++ b/ipc/ipc.gypi
@@ -40,6 +40,12 @@
'ipc_sync_message.h',
'ipc_sync_message_filter.cc',
'ipc_sync_message_filter.h',
+ 'param_traits_log_macros.h',
+ 'param_traits_macros.h',
+ 'param_traits_read_macros.h',
+ 'param_traits_write_macros.h',
+ 'struct_constructor_macros.h',
+ 'struct_destructor_macros.h',
],
'include_dirs': [
'..',
diff --git a/ipc/ipc_message_macros.h b/ipc/ipc_message_macros.h
index af2901a..c8cdf38 100644
--- a/ipc/ipc_message_macros.h
+++ b/ipc/ipc_message_macros.h
@@ -1,18 +1,143 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// This header is meant to be included in multiple passes, hence no traditional
-// header guard.
+// Defining IPC Messages
//
-// In your XXX_messages_internal.h file, before defining any messages do:
-// #define IPC_MESSAGE_START XMsgStart
-// XMstStart value is from the IPCMessageStart enum in ipc_message_utils.h, and
-// needs to be unique for each different file.
-// In your XXX_messages.cc file, after all the includes for param types:
+// Your IPC messages will be defined by macros inside of an XXX_messages.h
+// header file. Most of the time, the system can automatically generate all
+// of messaging mechanism from these definitions, but sometimes some manual
+// coding is required. In these cases, you will also have an XXX_messages.cc
+// implemation file as well.
+//
+// The senders of your messages will include your XXX_messages.h file to
+// get the full set of definitions they need to send your messages.
+//
+// Each XXX_messages.h file must be registered with the IPC system. This
+// requires adding two things:
+// - An XXXMsgStart value to the IPCMessageStart enum in ipc_message_utils.h
+// - An inclusion of XXX_messages.h file in a message generator .h file
+//
+// The XXXMsgStart value is an enumeration that ensures uniqueness for
+// each different message file. Later, you will use this inside your
+// XXX_messages.h file before invoking message declatation macros:
+// #define IPC_MESSAGE_START XXXMsgStart
+// ( ... your macro invocations go here ... )
+//
+// Message Generator Files
+//
+// 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.
+//
+// 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
+// the following code:
+// // Get basic type definitions.
+// #define IPC_MESSAGE_IMPL
+// #include "path/to/YYY_message_generator.h"
+// // Generate constructors.
+// #include "ipc/struct_constructor_macros.h"
+// #include "path/to/YYY_message_generator.h"
+// // 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"
+// #include "path/to/YYY_message_generator.h"
+// // Generate param traits read methods.
+// #include "ipc/param_traits_read_macros.h"
+// #include "path/to/YYY_message_generator.h"
+// // Generate param traits log methods.
+// #include "ipc/param_traits_log_macros.h"
+// #include "path/to/YYY_message_generator.h"
+// } // namespace IPC
+//
+// In cases where manual generation is required, in your XXX_messages.cc
+// file, put the following after all the includes for param types:
// #define IPC_MESSAGE_IMPL
-// #include "X_messages.h"
+// #include "XXX_messages.h"
+// (... implementation of traits not auto-generated ...)
+//
+// Multiple Inclusion
+//
+// The XXX_messages.h file will be multiply-included by the
+// YYY_message_generator.cc file, so your XXX_messages file can't be
+// guarded in the usual manner. Ideally, there will be no need for any
+// inclusion guard, since the XXX_messages.h file should consist soley
+// of inclusions of other headers (which are self-guarding) and IPC
+// macros (which are multiply evaluating).
+//
+// Note that there is no #pragma once either; doing so would mark the whole
+// file as being singly-included. Since your XXX_messages.h file is only
+// partially-guarded, care must be taken to ensure that it is only included
+// by other .cc files (and the YYY_message_generator.h file). Including an
+// XXX_messages.h file in some other .h file may result in duplicate
+// declarations and a compilation failure.
+//
+// Type Declarations
+//
+// It is generally a bad idea to have type definitions in a XXX_messages.h
+// file; most likely the typedef will then be used in the message, as opposed
+// to the struct iself. Later, an IPC message dispatcher wil need to call
+// a function taking that type, and that function is declared in some other
+// header. Thus, in order to get the type definition, the other header
+// would have to include the XXX_messages.h file, violating the rule above
+// about not including XXX_messages.h file in other .h files.
+//
+// One approach here is to move these type definitions to another (guarded)
+// .h file and include this second .h in your XXX_messages.h file. This
+// is still less than ideal, because the dispatched function would have to
+// redeclare the typedef or include this second header. This may be
+// reasonable in a few cases.
+//
+// Failing all of the above, then you will want to bracket the smallest
+// possible section of your XXX_messages.h file containing these types
+// with an include guard macro. Be aware that providing an incomplete
+// class type declaration to avoid pulling in a long chain of headers is
+// acceptable when your XXX_messages.h header is being included by the
+// message sending caller's code, but not when the YYY_message_generator.c
+// is building the messages. In addtion, due to the multiple inclusion
+// restriction, these type ought to be guarded. Follow a convention like:
+// #ifndef SOME_GUARD_MACRO
+// #define SOME_GUARD_MACRO
+// class some_class; // One incomplete class declaration
+// class_some_other_class; // Another incomplete class declaration
+// #endif // SOME_GUARD_MACRO
+// #ifdef IPC_MESSAGE_IMPL
+// #inlcude "path/to/some_class.h" // Full class declaration
+// #inlcude "path/to/some_other_class.h" // Full class declaration
+// #endif // IPC_MESSAGE_IMPL
+// (.. IPC macros using some_class and some_other_class ...)
//
+// Macro Invocations
+//
+// You will use IPC message macro invocations for three things:
+// - New struct definitions for IPC
+// - Registering existing struct and enum definitions with IPC
+// - Defining the messages themselves
+//
+// New structs are defined with IPC_STRUCT_BEGIN(), IPC_STRUCT_MEMBER(),
+// IPC_STRUCT_END() family of macros. These cause the XXX_messages.h
+// to proclaim equivalent struct declarations for use by callers, as well
+// as later registering the type with the message generation. Note that
+// IPC_STRUCT_MEMBER() is only permitted inside matching calls to
+// IPC_STRUCT_BEGIN() / IPC_STRUCT_END().
+//
+// Externally-defined structs are registered with IPC_STRUCT_TRAITS_BEGIN(),
+// IPC_STRUCT_TRAITS_MEMBER(), and IPC_STRUCT_TRAITS_END() macros. These
+// cause registration of the types with message generation only. Note that
+// IPC_STRUCT_TRAITS_MEMBER() is only permitted inside matching calls
+// to IPC_STRUCT_TRAITS_BEGIN() / IPC_STRUCT_TRAITS_END().
+//
+// Enum types are registered with a single IPC_ENUM_TRAITS() macro. There
+// is no need to enumerate each value to the IPC mechanism.
+//
+// Once the types have been declared / registered, message definitions follow.
// "Sync" messages are just synchronous calls, the Send() call doesn't return
// until a reply comes back. Input parameters are first (const TYPE&), and
// To declare a sync message, use the IPC_SYNC_ macros. The numbers at the
@@ -21,7 +146,6 @@
// The receiver's handler function will be
// void OnSyncMessageName(const type1& in1, type2* out1, type3* out2)
//
-//
// A caller can also send a synchronous message, while the receiver can respond
// at a later time. This is transparent from the sender's side. The receiver
// needs to use a different handler that takes in a IPC::Message* as the output
@@ -38,11 +162,12 @@
// ViewHostMsg_SyncMessageName::WriteReplyParams(reply_msg, out1, out2);
// Send(reply_msg);
-#include "ipc/ipc_message_utils.h"
+#ifndef IPC_IPC_MESSAGE_MACROS_H_
+#define IPC_IPC_MESSAGE_MACROS_H_
+// Can use #pragma once all XXX_messages.h files clean up IPC_MESSAGE_START
-// In case a file includes several X_messages.h files, we don't want to get
-// errors because each X_messages_internal.h file will define this.
-#undef IPC_MESSAGE_START
+#include "ipc/ipc_message_utils.h"
+#include "ipc/param_traits_macros.h"
#if defined(IPC_MESSAGE_IMPL)
#include "ipc/ipc_message_impl_macros.h"
@@ -60,7 +185,7 @@ typedef void (*LogFunction)(std::string* name,
typedef base::hash_map<uint32, LogFunction > LogFunctionMap;
LogFunctionMap g_log_function_mapping;
-#endif
+#endif // IPC_LOG_TABLE_CREATED
#define IPC_MESSAGE_LOG(msg_class) \
@@ -280,7 +405,7 @@ LogFunctionMap g_log_function_mapping;
#define IPC_SYNC_MESSAGE_ROUTED5_4_EXTRA(msg_class, type1_in, type2_in, type3_in, type4_in, type5_in, type1_out, type2_out, type3_out, type4_out) \
IPC_MESSAGE_LOG(msg_class)
-#else
+#else // defined(IPC_MESSAGE_MACROS_LOG_ENABLED)
#define IPC_MESSAGE_CONTROL0_EXTRA(msg_class)
#define IPC_MESSAGE_CONTROL1_EXTRA(msg_class, type1)
@@ -352,7 +477,18 @@ LogFunctionMap g_log_function_mapping;
#define IPC_SYNC_MESSAGE_ROUTED5_3_EXTRA(msg_class, type1_in, type2_in, type3_in, type4_in, type5_in, type1_out, type2_out, type3_out)
#define IPC_SYNC_MESSAGE_ROUTED5_4_EXTRA(msg_class, type1_in, type2_in, type3_in, type4_in, type5_in, type1_out, type2_out, type4_out)
-#endif
+#endif // defined(IPC_MESSAGE_MACROS_LOG_ENABLED)
+
+// Macros for defining structs. May be subsequently redefined.
+#define IPC_STRUCT_BEGIN(struct_name) \
+ struct struct_name; \
+ IPC_STRUCT_TRAITS_BEGIN(struct_name) \
+ IPC_STRUCT_TRAITS_END() \
+ struct struct_name : IPC::NoParams { \
+ struct_name(); \
+ ~struct_name();
+#define IPC_STRUCT_MEMBER(type, name) type name;
+#define IPC_STRUCT_END() };
// 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.
@@ -1243,3 +1379,11 @@ LogFunctionMap g_log_function_mapping;
// This corresponds to an enum value from IPCMessageStart.
#define IPC_MESSAGE_CLASS(message) \
message.type() >> 16
+
+#endif // IPC_IPC_MESSAGE_MACROS_H_
+
+// Clean up IPC_MESSAGE_START in this unguarded section so that the
+// XXX_messages.h files need not do so themselves. This makes the
+// XXX_messages.h files easier to write.
+#undef IPC_MESSAGE_START
+
diff --git a/ipc/ipc_message_null_macros.h b/ipc/ipc_message_null_macros.h
new file mode 100644
index 0000000..2c33172
--- /dev/null
+++ b/ipc/ipc_message_null_macros.h
@@ -0,0 +1,167 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// No include guard, may be included multiple times.
+
+// NULL out all the macros that need NULLing, so that multiple includes of
+// the XXXX_messages_internal.h files will not generate noise.
+#undef IPC_STRUCT_BEGIN
+#undef IPC_STRUCT_MEMBER
+#undef IPC_STRUCT_END
+#undef IPC_STRUCT_TRAITS_BEGIN
+#undef IPC_STRUCT_TRAITS_MEMBER
+#undef IPC_STRUCT_TRAITS_END
+#undef IPC_ENUM_TRAITS
+#undef IPC_MESSAGE_CONTROL0
+#undef IPC_MESSAGE_CONTROL1
+#undef IPC_MESSAGE_CONTROL2
+#undef IPC_MESSAGE_CONTROL3
+#undef IPC_MESSAGE_CONTROL4
+#undef IPC_MESSAGE_CONTROL5
+#undef IPC_MESSAGE_ROUTED0
+#undef IPC_MESSAGE_ROUTED1
+#undef IPC_MESSAGE_ROUTED2
+#undef IPC_MESSAGE_ROUTED3
+#undef IPC_MESSAGE_ROUTED4
+#undef IPC_MESSAGE_ROUTED5
+#undef IPC_SYNC_MESSAGE_CONTROL0_0
+#undef IPC_SYNC_MESSAGE_CONTROL0_1
+#undef IPC_SYNC_MESSAGE_CONTROL0_2
+#undef IPC_SYNC_MESSAGE_CONTROL0_3
+#undef IPC_SYNC_MESSAGE_CONTROL0_4
+#undef IPC_SYNC_MESSAGE_CONTROL1_0
+#undef IPC_SYNC_MESSAGE_CONTROL1_1
+#undef IPC_SYNC_MESSAGE_CONTROL1_2
+#undef IPC_SYNC_MESSAGE_CONTROL1_3
+#undef IPC_SYNC_MESSAGE_CONTROL1_4
+#undef IPC_SYNC_MESSAGE_CONTROL2_0
+#undef IPC_SYNC_MESSAGE_CONTROL2_1
+#undef IPC_SYNC_MESSAGE_CONTROL2_2
+#undef IPC_SYNC_MESSAGE_CONTROL2_3
+#undef IPC_SYNC_MESSAGE_CONTROL2_4
+#undef IPC_SYNC_MESSAGE_CONTROL3_0
+#undef IPC_SYNC_MESSAGE_CONTROL3_1
+#undef IPC_SYNC_MESSAGE_CONTROL3_2
+#undef IPC_SYNC_MESSAGE_CONTROL3_3
+#undef IPC_SYNC_MESSAGE_CONTROL3_4
+#undef IPC_SYNC_MESSAGE_CONTROL4_0
+#undef IPC_SYNC_MESSAGE_CONTROL4_1
+#undef IPC_SYNC_MESSAGE_CONTROL4_2
+#undef IPC_SYNC_MESSAGE_CONTROL4_3
+#undef IPC_SYNC_MESSAGE_CONTROL4_4
+#undef IPC_SYNC_MESSAGE_CONTROL5_0
+#undef IPC_SYNC_MESSAGE_CONTROL5_1
+#undef IPC_SYNC_MESSAGE_CONTROL5_2
+#undef IPC_SYNC_MESSAGE_CONTROL5_3
+#undef IPC_SYNC_MESSAGE_CONTROL5_4
+#undef IPC_SYNC_MESSAGE_ROUTED0_0
+#undef IPC_SYNC_MESSAGE_ROUTED0_1
+#undef IPC_SYNC_MESSAGE_ROUTED0_2
+#undef IPC_SYNC_MESSAGE_ROUTED0_3
+#undef IPC_SYNC_MESSAGE_ROUTED0_4
+#undef IPC_SYNC_MESSAGE_ROUTED1_0
+#undef IPC_SYNC_MESSAGE_ROUTED1_1
+#undef IPC_SYNC_MESSAGE_ROUTED1_2
+#undef IPC_SYNC_MESSAGE_ROUTED1_3
+#undef IPC_SYNC_MESSAGE_ROUTED1_4
+#undef IPC_SYNC_MESSAGE_ROUTED2_0
+#undef IPC_SYNC_MESSAGE_ROUTED2_1
+#undef IPC_SYNC_MESSAGE_ROUTED2_2
+#undef IPC_SYNC_MESSAGE_ROUTED2_3
+#undef IPC_SYNC_MESSAGE_ROUTED2_4
+#undef IPC_SYNC_MESSAGE_ROUTED3_0
+#undef IPC_SYNC_MESSAGE_ROUTED3_1
+#undef IPC_SYNC_MESSAGE_ROUTED3_2
+#undef IPC_SYNC_MESSAGE_ROUTED3_3
+#undef IPC_SYNC_MESSAGE_ROUTED3_4
+#undef IPC_SYNC_MESSAGE_ROUTED4_0
+#undef IPC_SYNC_MESSAGE_ROUTED4_1
+#undef IPC_SYNC_MESSAGE_ROUTED4_2
+#undef IPC_SYNC_MESSAGE_ROUTED4_3
+#undef IPC_SYNC_MESSAGE_ROUTED4_4
+#undef IPC_SYNC_MESSAGE_ROUTED5_0
+#undef IPC_SYNC_MESSAGE_ROUTED5_1
+#undef IPC_SYNC_MESSAGE_ROUTED5_2
+#undef IPC_SYNC_MESSAGE_ROUTED5_3
+#undef IPC_SYNC_MESSAGE_ROUTED5_4
+
+#define IPC_STRUCT_BEGIN(struct_name)
+#define IPC_STRUCT_MEMBER(type, name)
+#define IPC_STRUCT_END()
+#define IPC_STRUCT_TRAITS_BEGIN(struct_name)
+#define IPC_STRUCT_TRAITS_MEMBER(name)
+#define IPC_STRUCT_TRAITS_END()
+#define IPC_ENUM_TRAITS(enum_name)
+#define IPC_MESSAGE_CONTROL0(msg_class)
+#define IPC_MESSAGE_CONTROL1(msg_class, type1)
+#define IPC_MESSAGE_CONTROL2(msg_class, type1, type2)
+#define IPC_MESSAGE_CONTROL3(msg_class, type1, type2, type3)
+#define IPC_MESSAGE_CONTROL4(msg_class, type1, type2, type3, type4)
+#define IPC_MESSAGE_CONTROL5(msg_class, type1, type2, type3, type4, type5)
+#define IPC_MESSAGE_ROUTED0(msg_class)
+#define IPC_MESSAGE_ROUTED1(msg_class, type1)
+#define IPC_MESSAGE_ROUTED2(msg_class, type1, type2)
+#define IPC_MESSAGE_ROUTED3(msg_class, type1, type2, type3)
+#define IPC_MESSAGE_ROUTED4(msg_class, type1, type2, type3, type4)
+#define IPC_MESSAGE_ROUTED5(msg_class, type1, type2, type3, type4, type5)
+#define IPC_SYNC_MESSAGE_CONTROL0_0(msg_class)
+#define IPC_SYNC_MESSAGE_CONTROL0_1(msg_class, type1_out)
+#define IPC_SYNC_MESSAGE_CONTROL0_2(msg_class, type1_out, type2_out)
+#define IPC_SYNC_MESSAGE_CONTROL0_3(msg_class, type1_out, type2_out, type3_out)
+#define IPC_SYNC_MESSAGE_CONTROL0_4(msg_class, type1_out, type2_out, type3_out, type4_out)
+#define IPC_SYNC_MESSAGE_CONTROL1_0(msg_class, type1_in)
+#define IPC_SYNC_MESSAGE_CONTROL1_1(msg_class, type1_in, type1_out)
+#define IPC_SYNC_MESSAGE_CONTROL1_2(msg_class, type1_in, type1_out, type2_out)
+#define IPC_SYNC_MESSAGE_CONTROL1_3(msg_class, type1_in, type1_out, type2_out, type3_out)
+#define IPC_SYNC_MESSAGE_CONTROL1_4(msg_class, type1_in, type1_out, type2_out, type3_out, type4_out)
+#define IPC_SYNC_MESSAGE_CONTROL2_0(msg_class, type1_in, type2_in)
+#define IPC_SYNC_MESSAGE_CONTROL2_1(msg_class, type1_in, type2_in, type1_out)
+#define IPC_SYNC_MESSAGE_CONTROL2_2(msg_class, type1_in, type2_in, type1_out, type2_out)
+#define IPC_SYNC_MESSAGE_CONTROL2_3(msg_class, type1_in, type2_in, type1_out, type2_out, type3_out)
+#define IPC_SYNC_MESSAGE_CONTROL2_4(msg_class, type1_in, type2_in, type1_out, type2_out, type3_out, type4_out)
+#define IPC_SYNC_MESSAGE_CONTROL3_0(msg_class, type1_in, type2_in, type3_in)
+#define IPC_SYNC_MESSAGE_CONTROL3_1(msg_class, type1_in, type2_in, type3_in, type1_out)
+#define IPC_SYNC_MESSAGE_CONTROL3_2(msg_class, type1_in, type2_in, type3_in, type1_out, type2_out)
+#define IPC_SYNC_MESSAGE_CONTROL3_3(msg_class, type1_in, type2_in, type3_in, type1_out, type2_out, type3_out)
+#define IPC_SYNC_MESSAGE_CONTROL3_4(msg_class, type1_in, type2_in, type3_in, type1_out, type2_out, type3_out, type4_out)
+#define IPC_SYNC_MESSAGE_CONTROL4_0(msg_class, type1_in, type2_in, type3_in, type4_in)
+#define IPC_SYNC_MESSAGE_CONTROL4_1(msg_class, type1_in, type2_in, type3_in, type4_in, type1_out)
+#define IPC_SYNC_MESSAGE_CONTROL4_2(msg_class, type1_in, type2_in, type3_in, type4_in, type1_out, type2_out)
+#define IPC_SYNC_MESSAGE_CONTROL4_3(msg_class, type1_in, type2_in, type3_in, type4_in, type1_out, type2_out, type3_out)
+#define IPC_SYNC_MESSAGE_CONTROL4_4(msg_class, type1_in, type2_in, type3_in, type4_in, type1_out, type2_out, type3_out, type4_out)
+#define IPC_SYNC_MESSAGE_CONTROL5_0(msg_class, type1_in, type2_in, type3_in, type4_in, type5_in)
+#define IPC_SYNC_MESSAGE_CONTROL5_1(msg_class, type1_in, type2_in, type3_in, type4_in, type5_in, type1_out)
+#define IPC_SYNC_MESSAGE_CONTROL5_2(msg_class, type1_in, type2_in, type3_in, type4_in, type5_in, type1_out, type2_out)
+#define IPC_SYNC_MESSAGE_CONTROL5_3(msg_class, type1_in, type2_in, type3_in, type4_in, type5_in, type1_out, type2_out, type3_out)
+#define IPC_SYNC_MESSAGE_CONTROL5_4(msg_class, type1_in, type2_in, type3_in, type4_in, type5_in, type1_out, type2_out, type3_out, type4_out)
+#define IPC_SYNC_MESSAGE_ROUTED0_0(msg_class)
+#define IPC_SYNC_MESSAGE_ROUTED0_1(msg_class, type1_out)
+#define IPC_SYNC_MESSAGE_ROUTED0_2(msg_class, type1_out, type2_out)
+#define IPC_SYNC_MESSAGE_ROUTED0_3(msg_class, type1_out, type2_out, type3_out)
+#define IPC_SYNC_MESSAGE_ROUTED0_4(msg_class, type1_out, type2_out, type3_out, type4_out)
+#define IPC_SYNC_MESSAGE_ROUTED1_0(msg_class, type1_in)
+#define IPC_SYNC_MESSAGE_ROUTED1_1(msg_class, type1_in, type1_out)
+#define IPC_SYNC_MESSAGE_ROUTED1_2(msg_class, type1_in, type1_out, type2_out)
+#define IPC_SYNC_MESSAGE_ROUTED1_3(msg_class, type1_in, type1_out, type2_out, type3_out)
+#define IPC_SYNC_MESSAGE_ROUTED1_4(msg_class, type1_in, type1_out, type2_out, type3_out, type4_out)
+#define IPC_SYNC_MESSAGE_ROUTED2_0(msg_class, type1_in, type2_in)
+#define IPC_SYNC_MESSAGE_ROUTED2_1(msg_class, type1_in, type2_in, type1_out)
+#define IPC_SYNC_MESSAGE_ROUTED2_2(msg_class, type1_in, type2_in, type1_out, type2_out)
+#define IPC_SYNC_MESSAGE_ROUTED2_3(msg_class, type1_in, type2_in, type1_out, type2_out, type3_out)
+#define IPC_SYNC_MESSAGE_ROUTED2_4(msg_class, type1_in, type2_in, type1_out, type2_out, type3_out, type4_out)
+#define IPC_SYNC_MESSAGE_ROUTED3_0(msg_class, type1_in, type2_in, type3_in)
+#define IPC_SYNC_MESSAGE_ROUTED3_1(msg_class, type1_in, type2_in, type3_in, type1_out)
+#define IPC_SYNC_MESSAGE_ROUTED3_2(msg_class, type1_in, type2_in, type3_in, type1_out, type2_out)
+#define IPC_SYNC_MESSAGE_ROUTED3_3(msg_class, type1_in, type2_in, type3_in, type1_out, type2_out, type3_out)
+#define IPC_SYNC_MESSAGE_ROUTED3_4(msg_class, type1_in, type2_in, type3_in, type1_out, type2_out, type3_out, type4_out)
+#define IPC_SYNC_MESSAGE_ROUTED4_0(msg_class, type1_in, type2_in, type3_in, type4_in)
+#define IPC_SYNC_MESSAGE_ROUTED4_1(msg_class, type1_in, type2_in, type3_in, type4_in, type1_out)
+#define IPC_SYNC_MESSAGE_ROUTED4_2(msg_class, type1_in, type2_in, type3_in, type4_in, type1_out, type2_out)
+#define IPC_SYNC_MESSAGE_ROUTED4_3(msg_class, type1_in, type2_in, type3_in, type4_in, type1_out, type2_out, type3_out)
+#define IPC_SYNC_MESSAGE_ROUTED4_4(msg_class, type1_in, type2_in, type3_in, type4_in, type1_out, type2_out, type3_out, type4_out)
+#define IPC_SYNC_MESSAGE_ROUTED5_0(msg_class, type1_in, type2_in, type3_in, type4_in, type5_in)
+#define IPC_SYNC_MESSAGE_ROUTED5_1(msg_class, type1_in, type2_in, type3_in, type4_in, type5_in, type1_out)
+#define IPC_SYNC_MESSAGE_ROUTED5_2(msg_class, type1_in, type2_in, type3_in, type4_in, type5_in, type1_out, type2_out)
+#define IPC_SYNC_MESSAGE_ROUTED5_3(msg_class, type1_in, type2_in, type3_in, type4_in, type5_in, type1_out, type2_out, type3_out)
+#define IPC_SYNC_MESSAGE_ROUTED5_4(msg_class, type1_in, type2_in, type3_in, type4_in, type5_in, type1_out, type2_out, type3_out, type4_out)
diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h
index 2b0fcef..75231d8 100644
--- a/ipc/ipc_message_utils.h
+++ b/ipc/ipc_message_utils.h
@@ -121,6 +121,12 @@ class MessageIterator {
};
//-----------------------------------------------------------------------------
+// A dummy struct to place first just to allow leading commas for all
+// members in the macro-generated constructor initializer lists.
+struct NoParams {
+};
+
+//-----------------------------------------------------------------------------
// ParamTraits specializations, etc.
template <class P>
diff --git a/ipc/param_traits_log_macros.h b/ipc/param_traits_log_macros.h
new file mode 100644
index 0000000..40f8ec4
--- /dev/null
+++ b/ipc/param_traits_log_macros.h
@@ -0,0 +1,45 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IPC_PARAM_TRAITS_LOG_MACROS_H_
+#define IPC_PARAM_TRAITS_LOG_MACROS_H_
+
+#include <string>
+
+// Null out all the macros that need nulling.
+#include "ipc/ipc_message_null_macros.h"
+
+// STRUCT declarations cause corresponding STRUCT_TRAITS declarations to occur.
+#undef IPC_STRUCT_BEGIN
+#undef IPC_STRUCT_MEMBER
+#undef IPC_STRUCT_END
+#define IPC_STRUCT_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()
+
+// Set up so next include will generate log methods.
+#undef IPC_STRUCT_TRAITS_BEGIN
+#undef IPC_STRUCT_TRAITS_MEMBER
+#undef IPC_STRUCT_TRAITS_END
+#define IPC_STRUCT_TRAITS_BEGIN(struct_name) \
+ void ParamTraits<struct_name>::Log(const param_type& p, std::string* l) { \
+ bool needs_comma = false; \
+ l->append("(");
+#define IPC_STRUCT_TRAITS_MEMBER(name) \
+ if (needs_comma) \
+ l->append(", "); \
+ LogParam(p.name, l); \
+ needs_comma = true;
+#define IPC_STRUCT_TRAITS_END() \
+ l->append(")"); \
+ }
+
+#undef IPC_ENUM_TRAITS
+#define IPC_ENUM_TRAITS(enum_name) \
+ void ParamTraits<enum_name>::Log(const param_type& p, std::string* l) { \
+ LogParam(static_cast<int>(p), l); \
+ }
+
+#endif // IPC_PARAM_TRAITS_LOG_MACROS_H_
+
diff --git a/ipc/param_traits_macros.h b/ipc/param_traits_macros.h
new file mode 100644
index 0000000..f22376a5
--- /dev/null
+++ b/ipc/param_traits_macros.h
@@ -0,0 +1,38 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IPC_PARAM_TRAITS_MACROS_H_
+#define IPC_PARAM_TRAITS_MACROS_H_
+
+#include <string>
+
+// Traits generation for structs.
+#define IPC_STRUCT_TRAITS_BEGIN(struct_name) \
+ namespace IPC { \
+ template <> \
+ struct ParamTraits<struct_name> { \
+ typedef struct_name param_type; \
+ static void Write(Message* m, const param_type& p); \
+ static bool Read(const Message* m, void** iter, param_type* p); \
+ static void Log(const param_type& p, std::string* l); \
+ }; \
+ }
+
+#define IPC_STRUCT_TRAITS_MEMBER(name)
+#define IPC_STRUCT_TRAITS_END()
+
+// Traits generation for enums.
+#define IPC_ENUM_TRAITS(enum_name) \
+ namespace IPC { \
+ template <> \
+ struct ParamTraits<enum_name> { \
+ typedef enum_name param_type; \
+ static void Write(Message* m, const param_type& p); \
+ static bool Read(const Message* m, void** iter, param_type* p); \
+ static void Log(const param_type& p, std::string* l); \
+ }; \
+ }
+
+#endif // IPC_PARAM_TRAITS_MACROS_H_
+
diff --git a/ipc/param_traits_read_macros.h b/ipc/param_traits_read_macros.h
new file mode 100644
index 0000000..a4fc2f9
--- /dev/null
+++ b/ipc/param_traits_read_macros.h
@@ -0,0 +1,42 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IPC_PARAM_TRAITS_READ_MACROS_H_
+#define IPC_PARAM_TRAITS_READ_MACROS_H_
+
+// Null out all the macros that need nulling.
+#include "ipc/ipc_message_null_macros.h"
+
+// STRUCT declarations cause corresponding STRUCT_TRAITS declarations to occur.
+#undef IPC_STRUCT_BEGIN
+#undef IPC_STRUCT_MEMBER
+#undef IPC_STRUCT_END
+#define IPC_STRUCT_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()
+
+// Set up so next include will generate read methods.
+#undef IPC_STRUCT_TRAITS_BEGIN
+#undef IPC_STRUCT_TRAITS_MEMBER
+#undef IPC_STRUCT_TRAITS_END
+#define IPC_STRUCT_TRAITS_BEGIN(struct_name) \
+ bool ParamTraits<struct_name>:: \
+ Read(const Message* m, void** iter, param_type* p) { \
+ return
+#define IPC_STRUCT_TRAITS_MEMBER(name) ReadParam(m, iter, &p->name) &&
+#define IPC_STRUCT_TRAITS_END() 1; }
+
+#undef IPC_ENUM_TRAITS
+#define IPC_ENUM_TRAITS(enum_name) \
+ bool ParamTraits<enum_name>:: \
+ Read(const Message* m, void** iter, param_type* p) { \
+ int type; \
+ if (!m->ReadInt(iter, &type)) \
+ return false; \
+ *p = static_cast<param_type>(type); \
+ return true; \
+ }
+
+#endif // IPC_PARAM_TRAITS_READ_MACROS_H_
+
diff --git a/ipc/param_traits_write_macros.h b/ipc/param_traits_write_macros.h
new file mode 100644
index 0000000..84e63f7
--- /dev/null
+++ b/ipc/param_traits_write_macros.h
@@ -0,0 +1,35 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IPC_PARAM_TRAITS_WRITE_MACROS_H_
+#define IPC_PARAM_TRAITS_WRITE_MACROS_H_
+
+// Null out all the macros that need nulling.
+#include "ipc/ipc_message_null_macros.h"
+
+// STRUCT declarations cause corresponding STRUCT_TRAITS declarations to occur.
+#undef IPC_STRUCT_BEGIN
+#undef IPC_STRUCT_MEMBER
+#undef IPC_STRUCT_END
+#define IPC_STRUCT_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()
+
+// Set up so next include will generate write methods.
+#undef IPC_STRUCT_TRAITS_BEGIN
+#undef IPC_STRUCT_TRAITS_MEMBER
+#undef IPC_STRUCT_TRAITS_END
+#define IPC_STRUCT_TRAITS_BEGIN(struct_name) \
+ void ParamTraits<struct_name>::Write(Message* m, const param_type& p) {
+#define IPC_STRUCT_TRAITS_MEMBER(name) WriteParam(m, p.name);
+#define IPC_STRUCT_TRAITS_END() }
+
+#undef IPC_ENUM_TRAITS
+#define IPC_ENUM_TRAITS(enum_name) \
+ void ParamTraits<enum_name>::Write(Message* m, const param_type& p) { \
+ m->WriteInt(static_cast<int>(p)); \
+ }
+
+#endif // IPC_PARAM_TRAITS_WRITE_MACROS_H_
+
diff --git a/ipc/struct_constructor_macros.h b/ipc/struct_constructor_macros.h
new file mode 100644
index 0000000..67bfcfb
--- /dev/null
+++ b/ipc/struct_constructor_macros.h
@@ -0,0 +1,20 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IPC_STRUCT_CONSTRUCTOR_MACROS_H_
+#define IPC_STRUCT_CONSTRUCTOR_MACROS_H_
+
+// Null out all the macros that need nulling.
+#include "ipc/ipc_message_null_macros.h"
+
+// Set up so next include will generate constructors.
+#undef IPC_STRUCT_BEGIN
+#undef IPC_STRUCT_MEMBER
+#undef IPC_STRUCT_END
+#define IPC_STRUCT_BEGIN(struct_name) struct_name::struct_name() : NoParams()
+#define IPC_STRUCT_MEMBER(type, name) , name()
+#define IPC_STRUCT_END() {}
+
+#endif // IPC_STRUCT_CONSTRUCTOR_MACROS_H_
+
diff --git a/ipc/struct_destructor_macros.h b/ipc/struct_destructor_macros.h
new file mode 100644
index 0000000..bf3dc95
--- /dev/null
+++ b/ipc/struct_destructor_macros.h
@@ -0,0 +1,16 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IPC_STRUCT_DESTRUCTOR_MACROS_H_
+#define IPC_STRUCT_DESTRUCTOR_MACROS_H_
+
+// Null out all the macros that need nulling.
+#include "ipc/ipc_message_null_macros.h"
+
+// Set up so next include will generate destructors.
+#undef IPC_STRUCT_BEGIN
+#define IPC_STRUCT_BEGIN(struct_name) struct_name::~struct_name() {}
+
+#endif // IPC_STRUCT_DESTRUCTOR_MACROS_H_
+