Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Side by Side Diff: ipc/ipc_message_macros.h

Issue 1532053002: use variadic macros/templates in IPC message implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: simplify Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Defining IPC Messages 5 // Defining IPC Messages
6 // 6 //
7 // Your IPC messages will be defined by macros inside of an XXX_messages.h 7 // Your IPC messages will be defined by macros inside of an XXX_messages.h
8 // header file. Most of the time, the system can automatically generate all 8 // header file. Most of the time, the system can automatically generate all
9 // of messaging mechanism from these definitions, but sometimes some manual 9 // of messaging mechanism from these definitions, but sometimes some manual
10 // coding is required. In these cases, you will also have an XXX_messages.cc 10 // coding is required. In these cases, you will also have an XXX_messages.cc
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 // after including this header, but before using any of the macros below. 189 // after including this header, but before using any of the macros below.
190 // (This needs to be before the include guard.) 190 // (This needs to be before the include guard.)
191 #undef IPC_MESSAGE_EXPORT 191 #undef IPC_MESSAGE_EXPORT
192 #define IPC_MESSAGE_EXPORT 192 #define IPC_MESSAGE_EXPORT
193 193
194 #ifndef IPC_IPC_MESSAGE_MACROS_H_ 194 #ifndef IPC_IPC_MESSAGE_MACROS_H_
195 #define IPC_IPC_MESSAGE_MACROS_H_ 195 #define IPC_IPC_MESSAGE_MACROS_H_
196 196
197 #include <stdint.h> 197 #include <stdint.h>
198 198
199 #include "base/export_template.h"
199 #include "base/profiler/scoped_profile.h" 200 #include "base/profiler/scoped_profile.h"
201 #include "base/tuple.h"
202 #include "ipc/ipc_message_templates.h"
200 #include "ipc/ipc_message_utils.h" 203 #include "ipc/ipc_message_utils.h"
201 #include "ipc/param_traits_macros.h" 204 #include "ipc/param_traits_macros.h"
202 205
203 #if defined(IPC_MESSAGE_IMPL)
204 #include "ipc/ipc_message_utils_impl.h"
205 #endif
206
207 // Convenience macro for defining structs without inheritance. Should not need 206 // Convenience macro for defining structs without inheritance. Should not need
208 // to be subsequently redefined. 207 // to be subsequently redefined.
209 #define IPC_STRUCT_BEGIN(struct_name) \ 208 #define IPC_STRUCT_BEGIN(struct_name) \
210 IPC_STRUCT_BEGIN_WITH_PARENT(struct_name, IPC::NoParams) 209 IPC_STRUCT_BEGIN_WITH_PARENT(struct_name, IPC::NoParams)
211 210
212 // Macros for defining structs. Will be subsequently redefined. 211 // Macros for defining structs. Will be subsequently redefined.
213 #define IPC_STRUCT_BEGIN_WITH_PARENT(struct_name, parent) \ 212 #define IPC_STRUCT_BEGIN_WITH_PARENT(struct_name, parent) \
214 struct struct_name; \ 213 struct struct_name; \
215 IPC_STRUCT_TRAITS_BEGIN(struct_name) \ 214 IPC_STRUCT_TRAITS_BEGIN(struct_name) \
216 IPC_STRUCT_TRAITS_END() \ 215 IPC_STRUCT_TRAITS_END() \
217 struct IPC_MESSAGE_EXPORT struct_name : parent { \ 216 struct IPC_MESSAGE_EXPORT struct_name : parent { \
218 struct_name(); \ 217 struct_name(); \
219 ~struct_name(); 218 ~struct_name();
220 // Optional variadic parameters specify the default value for this struct 219 // Optional variadic parameters specify the default value for this struct
221 // member. They are passed through to the constructor for |type|. 220 // member. They are passed through to the constructor for |type|.
222 #define IPC_STRUCT_MEMBER(type, name, ...) type name; 221 #define IPC_STRUCT_MEMBER(type, name, ...) type name;
223 #define IPC_STRUCT_END() }; 222 #define IPC_STRUCT_END() };
224 223
225 // Message macros collect specific numbers of arguments and funnel them into 224 // Message macros collect specific numbers of arguments and funnel them into
226 // the common message generation macro. These should never be redefined. 225 // the common message generation macro. These should never be redefined.
227 #define IPC_MESSAGE_CONTROL0(msg_class) \
228 IPC_MESSAGE_DECL(EMPTY, CONTROL, msg_class, 0, 0, (), ())
danakj 2015/12/19 00:15:06 We used to have EMPTY in the 0 cases, but we won't
mdempsky 2015/12/19 02:14:48 The EMPTY cases used to be the same as 0-parameter
229 226
230 #define IPC_MESSAGE_CONTROL1(msg_class, type1) \ 227 #define IPC_MESSAGE_CONTROL(msg_class, ...) \
231 IPC_MESSAGE_DECL(ASYNC, CONTROL, msg_class, 1, 0, (type1), ()) 228 IPC_MESSAGE_DECL(msg_class, Async, Control, IPC_TUPLE(__VA_ARGS__), \
229 IPC_TUPLE())
230 #define IPC_MESSAGE_ROUTED(msg_class, ...) \
231 IPC_MESSAGE_DECL(msg_class, Async, Routed, IPC_TUPLE(__VA_ARGS__), \
232 IPC_TUPLE())
232 233
233 #define IPC_MESSAGE_CONTROL2(msg_class, type1, type2) \ 234 #define IPC_SYNC_MESSAGE_CONTROL(msg_class, in, out) \
234 IPC_MESSAGE_DECL(ASYNC, CONTROL, msg_class, 2, 0, (type1, type2), ()) 235 IPC_MESSAGE_DECL(msg_class, Sync, Control, IPC_TUPLE in, IPC_TUPLE out)
danakj 2015/12/19 00:15:06 should these be IPC_TUPLE(in), IPC_TUPLE(out) or i
mdempsky 2015/12/19 02:14:48 The idea is callers write: IPC_SYNC_MESSAGE_CON
236 #define IPC_SYNC_MESSAGE_ROUTED(msg_class, in, out) \
237 IPC_MESSAGE_DECL(msg_class, Sync, Routed, IPC_TUPLE in, IPC_TUPLE out)
235 238
236 #define IPC_MESSAGE_CONTROL3(msg_class, type1, type2, type3) \ 239 #define IPC_TUPLE(...) base::Tuple<__VA_ARGS__>
237 IPC_MESSAGE_DECL(ASYNC, CONTROL, msg_class, 3, 0, (type1, type2, type3), ())
238 240
239 #define IPC_MESSAGE_CONTROL4(msg_class, type1, type2, type3, type4) \ 241 // Macro trick to allow passing arguments with embedded commas (such
240 IPC_MESSAGE_DECL(ASYNC, CONTROL, msg_class, 4, 0, (type1, type2, type3, type4) , ()) 242 // as tuple types) to sub-macros.
243 // TODO(mdempsky): Move to base too?
244 #define IPC_COMMA_GUARD(...) __VA_ARGS__
241 245
242 #define IPC_MESSAGE_CONTROL5(msg_class, type1, type2, type3, type4, type5) \ 246 #define IPC_MESSAGE_DECL(msg_name, sync, kind, in_tuple, out_tuple) \
243 IPC_MESSAGE_DECL(ASYNC, CONTROL, msg_class, 5, 0, (type1, type2, type3, type4, type5), ()) 247 extern IPC_MESSAGE_EXPORT const char msg_name##_Name[]; \
244 248 extern template class EXPORT_TEMPLATE_DECLARE(IPC_MESSAGE_EXPORT) \
245 #define IPC_MESSAGE_ROUTED0(msg_class) \ 249 IPC::Common##sync##Message<IPC_MESSAGE_ID(), msg_name##_Name, in_tuple, \
246 IPC_MESSAGE_DECL(EMPTY, ROUTED, msg_class, 0, 0, (), ()) 250 out_tuple>; \
247 251 extern template class EXPORT_TEMPLATE_DECLARE(IPC_MESSAGE_EXPORT) \
248 #define IPC_MESSAGE_ROUTED1(msg_class, type1) \ 252 IPC::sync##kind##Message<IPC_MESSAGE_ID(), msg_name##_Name, in_tuple, \
249 IPC_MESSAGE_DECL(ASYNC, ROUTED, msg_class, 1, 0, (type1), ()) 253 out_tuple>; \
250 254 using msg_name = IPC::sync##kind##Message<IPC_MESSAGE_ID(), msg_name##_Name, \
251 #define IPC_MESSAGE_ROUTED2(msg_class, type1, type2) \ 255 in_tuple, out_tuple>; \
252 IPC_MESSAGE_DECL(ASYNC, ROUTED, msg_class, 2, 0, (type1, type2), ()) 256 IPC_MESSAGE_EXTRA(msg_name, sync, kind, IPC_COMMA_GUARD(in_tuple), \
253 257 IPC_COMMA_GUARD(out_tuple))
254 #define IPC_MESSAGE_ROUTED3(msg_class, type1, type2, type3) \
255 IPC_MESSAGE_DECL(ASYNC, ROUTED, msg_class, 3, 0, (type1, type2, type3), ())
256
257 #define IPC_MESSAGE_ROUTED4(msg_class, type1, type2, type3, type4) \
258 IPC_MESSAGE_DECL(ASYNC, ROUTED, msg_class, 4, 0, (type1, type2, type3, type4), ())
259
260 #define IPC_MESSAGE_ROUTED5(msg_class, type1, type2, type3, type4, type5) \
261 IPC_MESSAGE_DECL(ASYNC, ROUTED, msg_class, 5, 0, (type1, type2, type3, type4, type5), ())
262
263 #define IPC_SYNC_MESSAGE_CONTROL0_0(msg_class) \
264 IPC_MESSAGE_DECL(SYNC, CONTROL, msg_class, 0, 0, (), ())
265
266 #define IPC_SYNC_MESSAGE_CONTROL0_1(msg_class, type1_out) \
267 IPC_MESSAGE_DECL(SYNC, CONTROL, msg_class, 0, 1, (), (type1_out))
268
269 #define IPC_SYNC_MESSAGE_CONTROL0_2(msg_class, type1_out, type2_out) \
270 IPC_MESSAGE_DECL(SYNC, CONTROL, msg_class, 0, 2, (), (type1_out, type2_out))
271
272 #define IPC_SYNC_MESSAGE_CONTROL0_3(msg_class, type1_out, type2_out, type3_out) \
273 IPC_MESSAGE_DECL(SYNC, CONTROL, msg_class, 0, 3, (), (type1_out, type2_out, ty pe3_out))
274
275 #define IPC_SYNC_MESSAGE_CONTROL0_4(msg_class, type1_out, type2_out, type3_out, type4_out) \
276 IPC_MESSAGE_DECL(SYNC, CONTROL, msg_class, 0, 4, (), (type1_out, type2_out, ty pe3_out, type4_out))
277
278 #define IPC_SYNC_MESSAGE_CONTROL1_0(msg_class, type1_in) \
279 IPC_MESSAGE_DECL(SYNC, CONTROL, msg_class, 1, 0, (type1_in), ())
280
281 #define IPC_SYNC_MESSAGE_CONTROL1_1(msg_class, type1_in, type1_out) \
282 IPC_MESSAGE_DECL(SYNC, CONTROL, msg_class, 1, 1, (type1_in), (type1_out))
283
284 #define IPC_SYNC_MESSAGE_CONTROL1_2(msg_class, type1_in, type1_out, type2_out) \
285 IPC_MESSAGE_DECL(SYNC, CONTROL, msg_class, 1, 2, (type1_in), (type1_out, type2 _out))
286
287 #define IPC_SYNC_MESSAGE_CONTROL1_3(msg_class, type1_in, type1_out, type2_out, t ype3_out) \
288 IPC_MESSAGE_DECL(SYNC, CONTROL, msg_class, 1, 3, (type1_in), (type1_out, type2 _out, type3_out))
289
290 #define IPC_SYNC_MESSAGE_CONTROL1_4(msg_class, type1_in, type1_out, type2_out, t ype3_out, type4_out) \
291 IPC_MESSAGE_DECL(SYNC, CONTROL, msg_class, 1, 4, (type1_in), (type1_out, type2 _out, type3_out, type4_out))
292
293 #define IPC_SYNC_MESSAGE_CONTROL2_0(msg_class, type1_in, type2_in) \
294 IPC_MESSAGE_DECL(SYNC, CONTROL, msg_class, 2, 0, (type1_in, type2_in), ())
295
296 #define IPC_SYNC_MESSAGE_CONTROL2_1(msg_class, type1_in, type2_in, type1_out) \
297 IPC_MESSAGE_DECL(SYNC, CONTROL, msg_class, 2, 1, (type1_in, type2_in), (type1_ out))
298
299 #define IPC_SYNC_MESSAGE_CONTROL2_2(msg_class, type1_in, type2_in, type1_out, ty pe2_out) \
300 IPC_MESSAGE_DECL(SYNC, CONTROL, msg_class, 2, 2, (type1_in, type2_in), (type1_ out, type2_out))
301
302 #define IPC_SYNC_MESSAGE_CONTROL2_3(msg_class, type1_in, type2_in, type1_out, ty pe2_out, type3_out) \
303 IPC_MESSAGE_DECL(SYNC, CONTROL, msg_class, 2, 3, (type1_in, type2_in), (type1_ out, type2_out, type3_out))
304
305 #define IPC_SYNC_MESSAGE_CONTROL2_4(msg_class, type1_in, type2_in, type1_out, ty pe2_out, type3_out, type4_out) \
306 IPC_MESSAGE_DECL(SYNC, CONTROL, msg_class, 2, 4, (type1_in, type2_in), (type1_ out, type2_out, type3_out, type4_out))
307
308 #define IPC_SYNC_MESSAGE_CONTROL3_0(msg_class, type1_in, type2_in, type3_in) \
309 IPC_MESSAGE_DECL(SYNC, CONTROL, msg_class, 3, 0, (type1_in, type2_in, type3_in ), ())
310
311 #define IPC_SYNC_MESSAGE_CONTROL3_1(msg_class, type1_in, type2_in, type3_in, typ e1_out) \
312 IPC_MESSAGE_DECL(SYNC, CONTROL, msg_class, 3, 1, (type1_in, type2_in, type3_in ), (type1_out))
313
314 #define IPC_SYNC_MESSAGE_CONTROL3_2(msg_class, type1_in, type2_in, type3_in, typ e1_out, type2_out) \
315 IPC_MESSAGE_DECL(SYNC, CONTROL, msg_class, 3, 2, (type1_in, type2_in, type3_in ), (type1_out, type2_out))
316
317 #define IPC_SYNC_MESSAGE_CONTROL3_3(msg_class, type1_in, type2_in, type3_in, typ e1_out, type2_out, type3_out) \
318 IPC_MESSAGE_DECL(SYNC, CONTROL, msg_class, 3, 3, (type1_in, type2_in, type3_in ), (type1_out, type2_out, type3_out))
319
320 #define IPC_SYNC_MESSAGE_CONTROL3_4(msg_class, type1_in, type2_in, type3_in, typ e1_out, type2_out, type3_out, type4_out) \
321 IPC_MESSAGE_DECL(SYNC, CONTROL, msg_class, 3, 4, (type1_in, type2_in, type3_in ), (type1_out, type2_out, type3_out, type4_out))
322
323 #define IPC_SYNC_MESSAGE_CONTROL4_0(msg_class, type1_in, type2_in, type3_in, typ e4_in) \
324 IPC_MESSAGE_DECL(SYNC, CONTROL, msg_class, 4, 0, (type1_in, type2_in, type3_in , type4_in), ())
325
326 #define IPC_SYNC_MESSAGE_CONTROL4_1(msg_class, type1_in, type2_in, type3_in, typ e4_in, type1_out) \
327 IPC_MESSAGE_DECL(SYNC, CONTROL, msg_class, 4, 1, (type1_in, type2_in, type3_in , type4_in), (type1_out))
328
329 #define IPC_SYNC_MESSAGE_CONTROL4_2(msg_class, type1_in, type2_in, type3_in, typ e4_in, type1_out, type2_out) \
330 IPC_MESSAGE_DECL(SYNC, CONTROL, msg_class, 4, 2, (type1_in, type2_in, type3_in , type4_in), (type1_out, type2_out))
331
332 #define IPC_SYNC_MESSAGE_CONTROL4_3(msg_class, type1_in, type2_in, type3_in, typ e4_in, type1_out, type2_out, type3_out) \
333 IPC_MESSAGE_DECL(SYNC, CONTROL, msg_class, 4, 3, (type1_in, type2_in, type3_in , type4_in), (type1_out, type2_out, type3_out))
334
335 #define IPC_SYNC_MESSAGE_CONTROL4_4(msg_class, type1_in, type2_in, type3_in, typ e4_in, type1_out, type2_out, type3_out, type4_out) \
336 IPC_MESSAGE_DECL(SYNC, CONTROL, msg_class, 4, 4, (type1_in, type2_in, type3_in , type4_in), (type1_out, type2_out, type3_out, type4_out))
337
338 #define IPC_SYNC_MESSAGE_CONTROL5_0(msg_class, type1_in, type2_in, type3_in, typ e4_in, type5_in) \
339 IPC_MESSAGE_DECL(SYNC, CONTROL, msg_class, 5, 0, (type1_in, type2_in, type3_in , type4_in, type5_in), ())
340
341 #define IPC_SYNC_MESSAGE_CONTROL5_1(msg_class, type1_in, type2_in, type3_in, typ e4_in, type5_in, type1_out) \
342 IPC_MESSAGE_DECL(SYNC, CONTROL, msg_class, 5, 1, (type1_in, type2_in, type3_in , type4_in, type5_in), (type1_out))
343
344 #define IPC_SYNC_MESSAGE_CONTROL5_2(msg_class, type1_in, type2_in, type3_in, typ e4_in, type5_in, type1_out, type2_out) \
345 IPC_MESSAGE_DECL(SYNC, CONTROL, msg_class, 5, 2, (type1_in, type2_in, type3_in , type4_in, type5_in), (type1_out, type2_out))
346
347 #define IPC_SYNC_MESSAGE_CONTROL5_3(msg_class, type1_in, type2_in, type3_in, typ e4_in, type5_in, type1_out, type2_out, type3_out) \
348 IPC_MESSAGE_DECL(SYNC, CONTROL, msg_class, 5, 3, (type1_in, type2_in, type3_in , type4_in, type5_in), (type1_out, type2_out, type3_out))
349
350 #define IPC_SYNC_MESSAGE_ROUTED0_0(msg_class) \
351 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 0, 0, (), ())
352
353 #define IPC_SYNC_MESSAGE_ROUTED0_1(msg_class, type1_out) \
354 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 0, 1, (), (type1_out))
355
356 #define IPC_SYNC_MESSAGE_ROUTED0_2(msg_class, type1_out, type2_out) \
357 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 0, 2, (), (type1_out, type2_out))
358
359 #define IPC_SYNC_MESSAGE_ROUTED0_3(msg_class, type1_out, type2_out, type3_out) \
360 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 0, 3, (), (type1_out, type2_out, typ e3_out))
361
362 #define IPC_SYNC_MESSAGE_ROUTED0_4(msg_class, type1_out, type2_out, type3_out, t ype4_out) \
363 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 0, 4, (), (type1_out, type2_out, typ e3_out, type4_out))
364
365 #define IPC_SYNC_MESSAGE_ROUTED1_0(msg_class, type1_in) \
366 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 1, 0, (type1_in), ())
367
368 #define IPC_SYNC_MESSAGE_ROUTED1_1(msg_class, type1_in, type1_out) \
369 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 1, 1, (type1_in), (type1_out))
370
371 #define IPC_SYNC_MESSAGE_ROUTED1_2(msg_class, type1_in, type1_out, type2_out) \
372 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 1, 2, (type1_in), (type1_out, type2_ out))
373
374 #define IPC_SYNC_MESSAGE_ROUTED1_3(msg_class, type1_in, type1_out, type2_out, ty pe3_out) \
375 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 1, 3, (type1_in), (type1_out, type2_ out, type3_out))
376
377 #define IPC_SYNC_MESSAGE_ROUTED1_4(msg_class, type1_in, type1_out, type2_out, ty pe3_out, type4_out) \
378 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 1, 4, (type1_in), (type1_out, type2_ out, type3_out, type4_out))
379
380 #define IPC_SYNC_MESSAGE_ROUTED2_0(msg_class, type1_in, type2_in) \
381 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 2, 0, (type1_in, type2_in), ())
382
383 #define IPC_SYNC_MESSAGE_ROUTED2_1(msg_class, type1_in, type2_in, type1_out) \
384 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 2, 1, (type1_in, type2_in), (type1_o ut))
385
386 #define IPC_SYNC_MESSAGE_ROUTED2_2(msg_class, type1_in, type2_in, type1_out, typ e2_out) \
387 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 2, 2, (type1_in, type2_in), (type1_o ut, type2_out))
388
389 #define IPC_SYNC_MESSAGE_ROUTED2_3(msg_class, type1_in, type2_in, type1_out, typ e2_out, type3_out) \
390 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 2, 3, (type1_in, type2_in), (type1_o ut, type2_out, type3_out))
391
392 #define IPC_SYNC_MESSAGE_ROUTED2_4(msg_class, type1_in, type2_in, type1_out, typ e2_out, type3_out, type4_out) \
393 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 2, 4, (type1_in, type2_in), (type1_o ut, type2_out, type3_out, type4_out))
394
395 #define IPC_SYNC_MESSAGE_ROUTED3_0(msg_class, type1_in, type2_in, type3_in) \
396 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 3, 0, (type1_in, type2_in, type3_in) , ())
397
398 #define IPC_SYNC_MESSAGE_ROUTED3_1(msg_class, type1_in, type2_in, type3_in, type 1_out) \
399 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 3, 1, (type1_in, type2_in, type3_in) , (type1_out))
400
401 #define IPC_SYNC_MESSAGE_ROUTED3_2(msg_class, type1_in, type2_in, type3_in, type 1_out, type2_out) \
402 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 3, 2, (type1_in, type2_in, type3_in) , (type1_out, type2_out))
403
404 #define IPC_SYNC_MESSAGE_ROUTED3_3(msg_class, type1_in, type2_in, type3_in, type 1_out, type2_out, type3_out) \
405 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 3, 3, (type1_in, type2_in, type3_in) , (type1_out, type2_out, type3_out))
406
407 #define IPC_SYNC_MESSAGE_ROUTED3_4(msg_class, type1_in, type2_in, type3_in, type 1_out, type2_out, type3_out, type4_out) \
408 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 3, 4, (type1_in, type2_in, type3_in) , (type1_out, type2_out, type3_out, type4_out))
409
410 #define IPC_SYNC_MESSAGE_ROUTED4_0(msg_class, type1_in, type2_in, type3_in, type 4_in) \
411 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 4, 0, (type1_in, type2_in, type3_in, type4_in), ())
412
413 #define IPC_SYNC_MESSAGE_ROUTED4_1(msg_class, type1_in, type2_in, type3_in, type 4_in, type1_out) \
414 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 4, 1, (type1_in, type2_in, type3_in, type4_in), (type1_out))
415
416 #define IPC_SYNC_MESSAGE_ROUTED4_2(msg_class, type1_in, type2_in, type3_in, type 4_in, type1_out, type2_out) \
417 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 4, 2, (type1_in, type2_in, type3_in, type4_in), (type1_out, type2_out))
418
419 #define IPC_SYNC_MESSAGE_ROUTED4_3(msg_class, type1_in, type2_in, type3_in, type 4_in, type1_out, type2_out, type3_out) \
420 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 4, 3, (type1_in, type2_in, type3_in, type4_in), (type1_out, type2_out, type3_out))
421
422 #define IPC_SYNC_MESSAGE_ROUTED4_4(msg_class, type1_in, type2_in, type3_in, type 4_in, type1_out, type2_out, type3_out, type4_out) \
423 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 4, 4, (type1_in, type2_in, type3_in, type4_in), (type1_out, type2_out, type3_out, type4_out))
424
425 #define IPC_SYNC_MESSAGE_ROUTED5_0(msg_class, type1_in, type2_in, type3_in, type 4_in, type5_in) \
426 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 5, 0, (type1_in, type2_in, type3_in, type4_in, type5_in), ())
427
428 #define IPC_SYNC_MESSAGE_ROUTED5_1(msg_class, type1_in, type2_in, type3_in, type 4_in, type5_in, type1_out) \
429 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 5, 1, (type1_in, type2_in, type3_in, type4_in, type5_in), (type1_out))
430
431 #define IPC_SYNC_MESSAGE_ROUTED5_2(msg_class, type1_in, type2_in, type3_in, type 4_in, type5_in, type1_out, type2_out) \
432 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 5, 2, (type1_in, type2_in, type3_in, type4_in, type5_in), (type1_out, type2_out))
433
434 #define IPC_SYNC_MESSAGE_ROUTED5_3(msg_class, type1_in, type2_in, type3_in, type 4_in, type5_in, type1_out, type2_out, type3_out) \
435 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 5, 3, (type1_in, type2_in, type3_in, type4_in, type5_in), (type1_out, type2_out, type3_out))
436
437 // The following macros define the common set of methods provided by ASYNC
438 // message classes.
439 // This macro is for all the async IPCs that don't pass an extra parameter using
440 // IPC_BEGIN_MESSAGE_MAP_WITH_PARAM.
441 #define IPC_ASYNC_MESSAGE_METHODS_GENERIC \
442 template<class T, class S, class P, class Method> \
443 static bool Dispatch(const Message* msg, T* obj, S* sender, P* parameter, \
444 Method func) { \
445 Schema::Param p; \
446 if (Read(msg, &p)) { \
447 base::DispatchToMethod(obj, func, p); \
448 return true; \
449 } \
450 return false; \
451 }
452
453 // The following macros are for for async IPCs which have a dispatcher with an
454 // extra parameter specified using IPC_BEGIN_MESSAGE_MAP_WITH_PARAM.
455 #define IPC_ASYNC_MESSAGE_METHODS_1 \
456 IPC_ASYNC_MESSAGE_METHODS_GENERIC \
457 template<class T, class S, class P, typename TA> \
458 static bool Dispatch(const Message* msg, T* obj, S* sender, P* parameter, \
459 void (T::*func)(P*, TA)) { \
460 Schema::Param p; \
461 if (Read(msg, &p)) { \
462 (obj->*func)(parameter, base::get<0>(p)); \
463 return true; \
464 } \
465 return false; \
466 }
467 #define IPC_ASYNC_MESSAGE_METHODS_2 \
468 IPC_ASYNC_MESSAGE_METHODS_GENERIC \
469 template<class T, class S, class P, typename TA, typename TB> \
470 static bool Dispatch(const Message* msg, T* obj, S* sender, P* parameter, \
471 void (T::*func)(P*, TA, TB)) { \
472 Schema::Param p; \
473 if (Read(msg, &p)) { \
474 (obj->*func)(parameter, base::get<0>(p), base::get<1>(p)); \
475 return true; \
476 } \
477 return false; \
478 }
479 #define IPC_ASYNC_MESSAGE_METHODS_3 \
480 IPC_ASYNC_MESSAGE_METHODS_GENERIC \
481 template<class T, class S, class P, typename TA, typename TB, typename TC> \
482 static bool Dispatch(const Message* msg, T* obj, S* sender, P* parameter, \
483 void (T::*func)(P*, TA, TB, TC)) { \
484 Schema::Param p; \
485 if (Read(msg, &p)) { \
486 (obj->*func)(parameter, base::get<0>(p), base::get<1>(p), \
487 base::get<2>(p)); \
488 return true; \
489 } \
490 return false; \
491 }
492 #define IPC_ASYNC_MESSAGE_METHODS_4 \
493 IPC_ASYNC_MESSAGE_METHODS_GENERIC \
494 template<class T, class S, class P, typename TA, typename TB, typename TC, \
495 typename TD> \
496 static bool Dispatch(const Message* msg, T* obj, S* sender, P* parameter, \
497 void (T::*func)(P*, TA, TB, TC, TD)) { \
498 Schema::Param p; \
499 if (Read(msg, &p)) { \
500 (obj->*func)(parameter, base::get<0>(p), base::get<1>(p), \
501 base::get<2>(p), base::get<3>(p)); \
502 return true; \
503 } \
504 return false; \
505 }
506 #define IPC_ASYNC_MESSAGE_METHODS_5 \
507 IPC_ASYNC_MESSAGE_METHODS_GENERIC \
508 template<class T, class S, class P, typename TA, typename TB, typename TC, \
509 typename TD, typename TE> \
510 static bool Dispatch(const Message* msg, T* obj, S* sender, P* parameter, \
511 void (T::*func)(P*, TA, TB, TC, TD, TE)) { \
512 Schema::Param p; \
513 if (Read(msg, &p)) { \
514 (obj->*func)(parameter, base::get<0>(p), base::get<1>(p), \
515 base::get<2>(p), base::get<3>(p), base::get<4>(p)); \
516 return true; \
517 } \
518 return false; \
519 }
520
521 // The following macros define the common set of methods provided by SYNC
522 // message classes.
523 #define IPC_SYNC_MESSAGE_METHODS_GENERIC \
524 template<class T, class S, class P, class Method> \
525 static bool Dispatch(const Message* msg, T* obj, S* sender, P* parameter, \
526 Method func) { \
527 Schema::SendParam send_params; \
528 bool ok = ReadSendParam(msg, &send_params); \
529 return Schema::DispatchWithSendParams(ok, send_params, msg, obj, sender, \
530 func); \
531 } \
532 template<class T, class P, class Method> \
533 static bool DispatchDelayReply(const Message* msg, T* obj, P* parameter, \
534 Method func) { \
535 Schema::SendParam send_params; \
536 bool ok = ReadSendParam(msg, &send_params); \
537 return Schema::DispatchDelayReplyWithSendParams(ok, send_params, msg, \
538 obj, func); \
539 }
540 #define IPC_SYNC_MESSAGE_METHODS_0 \
541 IPC_SYNC_MESSAGE_METHODS_GENERIC
542 #define IPC_SYNC_MESSAGE_METHODS_1 \
543 IPC_SYNC_MESSAGE_METHODS_GENERIC \
544 template<typename TA> \
545 static void WriteReplyParams(Message* reply, TA a) { \
546 Schema::WriteReplyParams(reply, a); \
547 }
548 #define IPC_SYNC_MESSAGE_METHODS_2 \
549 IPC_SYNC_MESSAGE_METHODS_GENERIC \
550 template<typename TA, typename TB> \
551 static void WriteReplyParams(Message* reply, TA a, TB b) { \
552 Schema::WriteReplyParams(reply, a, b); \
553 }
554 #define IPC_SYNC_MESSAGE_METHODS_3 \
555 IPC_SYNC_MESSAGE_METHODS_GENERIC \
556 template<typename TA, typename TB, typename TC> \
557 static void WriteReplyParams(Message* reply, TA a, TB b, TC c) { \
558 Schema::WriteReplyParams(reply, a, b, c); \
559 }
560 #define IPC_SYNC_MESSAGE_METHODS_4 \
561 IPC_SYNC_MESSAGE_METHODS_GENERIC \
562 template<typename TA, typename TB, typename TC, typename TD> \
563 static void WriteReplyParams(Message* reply, TA a, TB b, TC c, TD d) { \
564 Schema::WriteReplyParams(reply, a, b, c, d); \
565 }
566 #define IPC_SYNC_MESSAGE_METHODS_5 \
567 IPC_SYNC_MESSAGE_METHODS_GENERIC \
568 template<typename TA, typename TB, typename TC, typename TD, typename TE> \
569 static void WriteReplyParams(Message* reply, TA a, TB b, TC c, TD d, TE e) { \
570 Schema::WriteReplyParams(reply, a, b, c, d, e); \
571 }
572
573 // Common message macro which dispatches into one of the 6 (sync x kind)
574 // routines. There is a way that these 6 cases can be lumped together,
575 // but the macros get very complicated in that case.
576 // Note: intended be redefined to generate other information.
577 #define IPC_MESSAGE_DECL(sync, kind, msg_class, \
578 in_cnt, out_cnt, in_list, out_list) \
579 IPC_##sync##_##kind##_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \
580 IPC_MESSAGE_EXTRA(sync, kind, msg_class, in_cnt, out_cnt, in_list, out_list)
581
582 #define IPC_EMPTY_CONTROL_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \
583 class IPC_MESSAGE_EXPORT msg_class : public IPC::Message { \
584 public: \
585 typedef IPC::Message Schema; \
586 enum { ID = IPC_MESSAGE_ID() }; \
587 msg_class() : IPC::Message(MSG_ROUTING_CONTROL, ID, PRIORITY_NORMAL) {} \
588 static void Log(std::string* name, const Message* msg, std::string* l); \
589 };
590
591 #define IPC_EMPTY_ROUTED_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \
592 class IPC_MESSAGE_EXPORT msg_class : public IPC::Message { \
593 public: \
594 typedef IPC::Message Schema; \
595 enum { ID = IPC_MESSAGE_ID() }; \
596 msg_class(int32_t routing_id) \
597 : IPC::Message(routing_id, ID, PRIORITY_NORMAL) {} \
598 static void Log(std::string* name, const Message* msg, std::string* l); \
599 };
600
601 #define IPC_ASYNC_CONTROL_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \
602 class IPC_MESSAGE_EXPORT msg_class : public IPC::Message { \
603 public: \
604 typedef IPC::MessageSchema<IPC_TUPLE_IN_##in_cnt in_list> Schema; \
605 typedef Schema::Param Param; \
606 enum { ID = IPC_MESSAGE_ID() }; \
607 msg_class(IPC_TYPE_IN_##in_cnt in_list); \
608 ~msg_class() override; \
609 static bool Read(const Message* msg, Schema::Param* p); \
610 static void Log(std::string* name, const Message* msg, std::string* l); \
611 IPC_ASYNC_MESSAGE_METHODS_##in_cnt \
612 };
613
614 #define IPC_ASYNC_ROUTED_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \
615 class IPC_MESSAGE_EXPORT msg_class : public IPC::Message { \
616 public: \
617 typedef IPC::MessageSchema<IPC_TUPLE_IN_##in_cnt in_list> Schema; \
618 typedef Schema::Param Param; \
619 enum { ID = IPC_MESSAGE_ID() }; \
620 msg_class(int32_t routing_id IPC_COMMA_##in_cnt \
621 IPC_TYPE_IN_##in_cnt in_list); \
622 ~msg_class() override; \
623 static bool Read(const Message* msg, Schema::Param* p); \
624 static void Log(std::string* name, const Message* msg, std::string* l); \
625 IPC_ASYNC_MESSAGE_METHODS_##in_cnt \
626 };
627
628 #define IPC_SYNC_CONTROL_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \
629 class IPC_MESSAGE_EXPORT msg_class : public IPC::SyncMessage { \
630 public: \
631 typedef IPC::SyncMessageSchema<IPC_TUPLE_IN_##in_cnt in_list, \
632 IPC_TUPLE_OUT_##out_cnt out_list> Schema; \
633 typedef Schema::ReplyParam ReplyParam; \
634 typedef Schema::SendParam SendParam; \
635 enum { ID = IPC_MESSAGE_ID() }; \
636 msg_class(IPC_TYPE_IN_##in_cnt in_list \
637 IPC_COMMA_AND_##in_cnt(IPC_COMMA_##out_cnt) \
638 IPC_TYPE_OUT_##out_cnt out_list); \
639 ~msg_class() override; \
640 static bool ReadSendParam(const Message* msg, Schema::SendParam* p); \
641 static bool ReadReplyParam( \
642 const Message* msg, \
643 base::TupleTypes<ReplyParam>::ValueTuple* p); \
644 static void Log(std::string* name, const Message* msg, std::string* l); \
645 IPC_SYNC_MESSAGE_METHODS_##out_cnt \
646 };
647
648 #define IPC_SYNC_ROUTED_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \
649 class IPC_MESSAGE_EXPORT msg_class : public IPC::SyncMessage { \
650 public: \
651 typedef IPC::SyncMessageSchema<IPC_TUPLE_IN_##in_cnt in_list, \
652 IPC_TUPLE_OUT_##out_cnt out_list> Schema; \
653 typedef Schema::ReplyParam ReplyParam; \
654 typedef Schema::SendParam SendParam; \
655 enum { ID = IPC_MESSAGE_ID() }; \
656 msg_class(int32_t routing_id \
657 IPC_COMMA_OR_##in_cnt(IPC_COMMA_##out_cnt) \
658 IPC_TYPE_IN_##in_cnt in_list \
659 IPC_COMMA_AND_##in_cnt(IPC_COMMA_##out_cnt) \
660 IPC_TYPE_OUT_##out_cnt out_list); \
661 ~msg_class() override; \
662 static bool ReadSendParam(const Message* msg, Schema::SendParam* p); \
663 static bool ReadReplyParam( \
664 const Message* msg, \
665 base::TupleTypes<ReplyParam>::ValueTuple* p); \
666 static void Log(std::string* name, const Message* msg, std::string* l); \
667 IPC_SYNC_MESSAGE_METHODS_##out_cnt \
668 };
669 258
670 #if defined(IPC_MESSAGE_IMPL) 259 #if defined(IPC_MESSAGE_IMPL)
671 260
672 // "Implementation" inclusion produces constructors, destructors, and 261 // "Implementation" inclusion produces constructors, destructors, and
673 // logging functions, except for the no-arg special cases, where the 262 // logging functions, except for the no-arg special cases, where the
674 // implementation occurs in the declaration, and there is no special 263 // implementation occurs in the declaration, and there is no special
675 // logging function. 264 // logging function.
676 #define IPC_MESSAGE_EXTRA(sync, kind, msg_class, \ 265 #define IPC_MESSAGE_EXTRA(msg_name, sync, kind, in_tuple, out_tuple) \
677 in_cnt, out_cnt, in_list, out_list) \ 266 const char msg_name##_Name[] = #msg_name; \
678 IPC_##sync##_##kind##_IMPL(msg_class, in_cnt, out_cnt, in_list, out_list) \ 267 template class EXPORT_TEMPLATE_DEFINE(IPC_MESSAGE_EXPORT) \
679 IPC_##sync##_MESSAGE_LOG(msg_class) 268 IPC::Common##sync##Message<IPC_MESSAGE_ID(), msg_name##_Name, in_tuple, \
680 269 out_tuple>; \
681 #define IPC_EMPTY_CONTROL_IMPL(msg_class, in_cnt, out_cnt, in_list, out_list) 270 template class EXPORT_TEMPLATE_DEFINE(IPC_MESSAGE_EXPORT) \
682 #define IPC_EMPTY_ROUTED_IMPL(msg_class, in_cnt, out_cnt, in_list, out_list) 271 IPC::sync##kind##Message<IPC_MESSAGE_ID(), msg_name##_Name, in_tuple, \
683 272 out_tuple>;
684 #define IPC_ASYNC_CONTROL_IMPL(msg_class, in_cnt, out_cnt, in_list, out_list) \
685 msg_class::msg_class(IPC_TYPE_IN_##in_cnt in_list) : \
686 IPC::Message(MSG_ROUTING_CONTROL, ID, PRIORITY_NORMAL) { \
687 Schema::Write(this, IPC_NAME_IN_##in_cnt in_list); \
688 } \
689 msg_class::~msg_class() {} \
690 bool msg_class::Read(const Message* msg, Schema::Param* p) { \
691 return Schema::Read(msg, p); \
692 }
693
694 #define IPC_ASYNC_ROUTED_IMPL(msg_class, in_cnt, out_cnt, in_list, out_list) \
695 msg_class::msg_class(int32_t routing_id IPC_COMMA_##in_cnt \
696 IPC_TYPE_IN_##in_cnt in_list) : \
697 IPC::Message(routing_id, ID, PRIORITY_NORMAL) { \
698 Schema::Write(this, IPC_NAME_IN_##in_cnt in_list); \
699 } \
700 msg_class::~msg_class() {} \
701 bool msg_class::Read(const Message* msg, Schema::Param* p) { \
702 return Schema::Read(msg, p); \
703 }
704
705 #define IPC_SYNC_CONTROL_IMPL(msg_class, in_cnt, out_cnt, in_list, out_list) \
706 msg_class::msg_class(IPC_TYPE_IN_##in_cnt in_list \
707 IPC_COMMA_AND_##in_cnt(IPC_COMMA_##out_cnt) \
708 IPC_TYPE_OUT_##out_cnt out_list) : \
709 IPC::SyncMessage(MSG_ROUTING_CONTROL, ID, PRIORITY_NORMAL, \
710 new IPC::ParamDeserializer<Schema::ReplyParam>( \
711 IPC_NAME_OUT_##out_cnt out_list)) { \
712 Schema::Write(this, IPC_NAME_IN_##in_cnt in_list); \
713 } \
714 msg_class::~msg_class() {} \
715 bool msg_class::ReadSendParam(const Message* msg, Schema::SendParam* p) { \
716 return Schema::ReadSendParam(msg, p); \
717 } \
718 bool msg_class::ReadReplyParam( \
719 const Message* msg, \
720 base::TupleTypes<ReplyParam>::ValueTuple* p) { \
721 return Schema::ReadReplyParam(msg, p); \
722 }
723
724 #define IPC_SYNC_ROUTED_IMPL(msg_class, in_cnt, out_cnt, in_list, out_list) \
725 msg_class::msg_class(int32_t routing_id \
726 IPC_COMMA_OR_##in_cnt(IPC_COMMA_##out_cnt) \
727 IPC_TYPE_IN_##in_cnt in_list \
728 IPC_COMMA_AND_##in_cnt(IPC_COMMA_##out_cnt) \
729 IPC_TYPE_OUT_##out_cnt out_list) : \
730 IPC::SyncMessage(routing_id, ID, PRIORITY_NORMAL, \
731 new IPC::ParamDeserializer<Schema::ReplyParam>( \
732 IPC_NAME_OUT_##out_cnt out_list)) { \
733 Schema::Write(this, IPC_NAME_IN_##in_cnt in_list); \
734 } \
735 msg_class::~msg_class() {} \
736 bool msg_class::ReadSendParam(const Message* msg, Schema::SendParam* p) { \
737 return Schema::ReadSendParam(msg, p); \
738 } \
739 bool msg_class::ReadReplyParam( \
740 const Message* msg, \
741 base::TupleTypes<ReplyParam>::ValueTuple* p) { \
742 return Schema::ReadReplyParam(msg, p); \
743 }
744
745 #define IPC_EMPTY_MESSAGE_LOG(msg_class) \
746 void msg_class::Log(std::string* name, \
747 const Message* msg, \
748 std::string* l) { \
749 if (name) \
750 *name = #msg_class; \
751 }
752
753 #define IPC_ASYNC_MESSAGE_LOG(msg_class) \
754 void msg_class::Log(std::string* name, \
755 const Message* msg, \
756 std::string* l) { \
757 if (name) \
758 *name = #msg_class; \
759 if (!msg || !l) \
760 return; \
761 Schema::Param p; \
762 if (Schema::Read(msg, &p)) \
763 IPC::LogParam(p, l); \
764 }
765
766 #define IPC_SYNC_MESSAGE_LOG(msg_class) \
767 void msg_class::Log(std::string* name, \
768 const Message* msg, \
769 std::string* l) { \
770 if (name) \
771 *name = #msg_class; \
772 if (!msg || !l) \
773 return; \
774 if (msg->is_sync()) { \
775 base::TupleTypes<Schema::SendParam>::ValueTuple p; \
776 if (Schema::ReadSendParam(msg, &p)) \
777 IPC::LogParam(p, l); \
778 AddOutputParamsToLog(msg, l); \
779 } else { \
780 base::TupleTypes<Schema::ReplyParam>::ValueTuple p; \
781 if (Schema::ReadReplyParam(msg, &p)) \
782 IPC::LogParam(p, l); \
783 } \
784 }
785 273
786 #elif defined(IPC_MESSAGE_MACROS_LOG_ENABLED) 274 #elif defined(IPC_MESSAGE_MACROS_LOG_ENABLED)
787 275
788 #ifndef IPC_LOG_TABLE_ADD_ENTRY 276 #ifndef IPC_LOG_TABLE_ADD_ENTRY
789 #error You need to define IPC_LOG_TABLE_ADD_ENTRY(msg_id, logger) 277 #error You need to define IPC_LOG_TABLE_ADD_ENTRY(msg_id, logger)
790 #endif 278 #endif
791 279
792 // "Log table" inclusion produces extra logging registration code. 280 // "Log table" inclusion produces extra logging registration code.
793 #define IPC_MESSAGE_EXTRA(sync, kind, msg_class, \ 281 #define IPC_MESSAGE_EXTRA(msg_name, sync, kind, in_tuple, out_tuple) \
794 in_cnt, out_cnt, in_list, out_list) \ 282 class LoggerRegisterHelper##msg_name { \
795 class LoggerRegisterHelper##msg_class { \ 283 public: \
796 public: \ 284 LoggerRegisterHelper##msg_name() { \
797 LoggerRegisterHelper##msg_class() { \ 285 const uint32_t msg_id = static_cast<uint32_t>(msg_name::ID); \
798 const uint32_t msg_id = static_cast<uint32_t>(msg_class::ID); \ 286 IPC_LOG_TABLE_ADD_ENTRY(msg_id, msg_name::Log); \
799 IPC_LOG_TABLE_ADD_ENTRY(msg_id, msg_class::Log); \ 287 } \
800 } \ 288 }; \
801 }; \ 289 LoggerRegisterHelper##msg_name g_LoggerRegisterHelper##msg_name;
802 LoggerRegisterHelper##msg_class g_LoggerRegisterHelper##msg_class;
803 290
804 #else 291 #else
805 292
806 // Normal inclusion produces nothing extra. 293 // Normal inclusion produces nothing extra.
807 #define IPC_MESSAGE_EXTRA(sync, kind, msg_class, \ 294 #define IPC_MESSAGE_EXTRA(msg_name, sync, kind, in_tuple, out_tuple)
808 in_cnt, out_cnt, in_list, out_list)
809 295
810 #endif // defined(IPC_MESSAGE_IMPL) 296 #endif // defined(IPC_MESSAGE_IMPL)
811
812 // Handle variable sized argument lists. These are usually invoked by token
813 // pasting against the argument counts.
814 #define IPC_TYPE_IN_0()
815 #define IPC_TYPE_IN_1(t1) const t1& arg1
816 #define IPC_TYPE_IN_2(t1, t2) const t1& arg1, const t2& arg2
817 #define IPC_TYPE_IN_3(t1, t2, t3) const t1& arg1, const t2& arg2, cons t t3& arg3
818 #define IPC_TYPE_IN_4(t1, t2, t3, t4) const t1& arg1, const t2& arg2, cons t t3& arg3, const t4& arg4
819 #define IPC_TYPE_IN_5(t1, t2, t3, t4, t5) const t1& arg1, const t2& arg2, cons t t3& arg3, const t4& arg4, const t5& arg5
820
821 #define IPC_TYPE_OUT_0()
822 #define IPC_TYPE_OUT_1(t1) t1* arg6
823 #define IPC_TYPE_OUT_2(t1, t2) t1* arg6, t2* arg7
824 #define IPC_TYPE_OUT_3(t1, t2, t3) t1* arg6, t2* arg7, t3* arg8
825 #define IPC_TYPE_OUT_4(t1, t2, t3, t4) t1* arg6, t2* arg7, t3* arg8, \
826 t4* arg9
827
828 #define IPC_TUPLE_IN_0() base::Tuple<>
829 #define IPC_TUPLE_IN_1(t1) base::Tuple<t1>
830 #define IPC_TUPLE_IN_2(t1, t2) base::Tuple<t1, t2>
831 #define IPC_TUPLE_IN_3(t1, t2, t3) base::Tuple<t1, t2, t3>
832 #define IPC_TUPLE_IN_4(t1, t2, t3, t4) base::Tuple<t1, t2, t3, t4>
833 #define IPC_TUPLE_IN_5(t1, t2, t3, t4, t5) base::Tuple<t1, t2, t3, t4, t5>
834
835 #define IPC_TUPLE_OUT_0() base::Tuple<>
836 #define IPC_TUPLE_OUT_1(t1) base::Tuple<t1&>
837 #define IPC_TUPLE_OUT_2(t1, t2) base::Tuple<t1&, t2&>
838 #define IPC_TUPLE_OUT_3(t1, t2, t3) base::Tuple<t1&, t2&, t3&>
839 #define IPC_TUPLE_OUT_4(t1, t2, t3, t4) base::Tuple<t1&, t2&, t3&, t4&>
840
841 #define IPC_NAME_IN_0() base::MakeTuple()
842 #define IPC_NAME_IN_1(t1) base::MakeRefTuple(arg1)
843 #define IPC_NAME_IN_2(t1, t2) base::MakeRefTuple(arg1, arg2)
844 #define IPC_NAME_IN_3(t1, t2, t3) base::MakeRefTuple(arg1, arg2, arg3)
845 #define IPC_NAME_IN_4(t1, t2, t3, t4) base::MakeRefTuple(arg1, arg2, \
846 arg3, arg4)
847 #define IPC_NAME_IN_5(t1, t2, t3, t4, t5) base::MakeRefTuple(arg1, arg2, \
848 arg3, arg4, arg5)
849
850 #define IPC_NAME_OUT_0() base::MakeTuple()
851 #define IPC_NAME_OUT_1(t1) base::MakeRefTuple(*arg6)
852 #define IPC_NAME_OUT_2(t1, t2) base::MakeRefTuple(*arg6, *arg7)
853 #define IPC_NAME_OUT_3(t1, t2, t3) base::MakeRefTuple(*arg6, *arg7, \
854 *arg8)
855 #define IPC_NAME_OUT_4(t1, t2, t3, t4) base::MakeRefTuple(*arg6, *arg7, \
856 *arg8, *arg9)
857
858 // There are places where the syntax requires a comma if there are input args,
859 // if there are input args and output args, or if there are input args or
860 // output args. These macros allow generation of the comma as needed; invoke
861 // by token pasting against the argument counts.
862 #define IPC_COMMA_0
863 #define IPC_COMMA_1 ,
864 #define IPC_COMMA_2 ,
865 #define IPC_COMMA_3 ,
866 #define IPC_COMMA_4 ,
867 #define IPC_COMMA_5 ,
868
869 #define IPC_COMMA_AND_0(x)
870 #define IPC_COMMA_AND_1(x) x
871 #define IPC_COMMA_AND_2(x) x
872 #define IPC_COMMA_AND_3(x) x
873 #define IPC_COMMA_AND_4(x) x
874 #define IPC_COMMA_AND_5(x) x
875
876 #define IPC_COMMA_OR_0(x) x
877 #define IPC_COMMA_OR_1(x) ,
878 #define IPC_COMMA_OR_2(x) ,
879 #define IPC_COMMA_OR_3(x) ,
880 #define IPC_COMMA_OR_4(x) ,
881 #define IPC_COMMA_OR_5(x) ,
882 297
883 // Message IDs 298 // Message IDs
884 // Note: we currently use __LINE__ to give unique IDs to messages within 299 // Note: we currently use __LINE__ to give unique IDs to messages within
885 // a file. They're globally unique since each file defines its own 300 // a file. They're globally unique since each file defines its own
886 // IPC_MESSAGE_START. 301 // IPC_MESSAGE_START.
887 #define IPC_MESSAGE_ID() ((IPC_MESSAGE_START << 16) + __LINE__) 302 #define IPC_MESSAGE_ID() ((IPC_MESSAGE_START << 16) + __LINE__)
888 #define IPC_MESSAGE_ID_CLASS(id) ((id) >> 16) 303 #define IPC_MESSAGE_ID_CLASS(id) ((id) >> 16)
889 #define IPC_MESSAGE_ID_LINE(id) ((id) & 0xffff) 304 #define IPC_MESSAGE_ID_LINE(id) ((id) & 0xffff)
890 305
891 // Message crackers and handlers. Usage: 306 // Message crackers and handlers. Usage:
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 ipc_message__.type()) 384 ipc_message__.type())
970 385
971 #define IPC_END_MESSAGE_MAP() \ 386 #define IPC_END_MESSAGE_MAP() \
972 } \ 387 } \
973 } 388 }
974 389
975 // This corresponds to an enum value from IPCMessageStart. 390 // This corresponds to an enum value from IPCMessageStart.
976 #define IPC_MESSAGE_CLASS(message) \ 391 #define IPC_MESSAGE_CLASS(message) \
977 IPC_MESSAGE_ID_CLASS(message.type()) 392 IPC_MESSAGE_ID_CLASS(message.type())
978 393
394 // Deprecated legacy macro names.
395 // TODO(mdempsky): Replace uses with generic names.
396
397 #define IPC_MESSAGE_CONTROL0 IPC_MESSAGE_CONTROL
398 #define IPC_MESSAGE_CONTROL1 IPC_MESSAGE_CONTROL
399 #define IPC_MESSAGE_CONTROL2 IPC_MESSAGE_CONTROL
400 #define IPC_MESSAGE_CONTROL3 IPC_MESSAGE_CONTROL
401 #define IPC_MESSAGE_CONTROL4 IPC_MESSAGE_CONTROL
402 #define IPC_MESSAGE_CONTROL5 IPC_MESSAGE_CONTROL
403
404 #define IPC_MESSAGE_ROUTED0 IPC_MESSAGE_ROUTED
405 #define IPC_MESSAGE_ROUTED1 IPC_MESSAGE_ROUTED
406 #define IPC_MESSAGE_ROUTED2 IPC_MESSAGE_ROUTED
407 #define IPC_MESSAGE_ROUTED3 IPC_MESSAGE_ROUTED
408 #define IPC_MESSAGE_ROUTED4 IPC_MESSAGE_ROUTED
409 #define IPC_MESSAGE_ROUTED5 IPC_MESSAGE_ROUTED
410
411 #define IPC_SYNC_MESSAGE_CONTROL0_x(msg_class, ...) \
412 IPC_SYNC_MESSAGE_CONTROL(msg_class, (), (__VA_ARGS__))
413 #define IPC_SYNC_MESSAGE_CONTROL1_x(msg_class, a, ...) \
414 IPC_SYNC_MESSAGE_CONTROL(msg_class, (a), (__VA_ARGS__))
415 #define IPC_SYNC_MESSAGE_CONTROL2_x(msg_class, a, b, ...) \
416 IPC_SYNC_MESSAGE_CONTROL(msg_class, (a, b), (__VA_ARGS__))
417 #define IPC_SYNC_MESSAGE_CONTROL3_x(msg_class, a, b, c, ...) \
418 IPC_SYNC_MESSAGE_CONTROL(msg_class, (a, b, c), (__VA_ARGS__))
419 #define IPC_SYNC_MESSAGE_CONTROL4_x(msg_class, a, b, c, d, ...) \
420 IPC_SYNC_MESSAGE_CONTROL(msg_class, (a, b, c, d), (__VA_ARGS__))
421 #define IPC_SYNC_MESSAGE_CONTROL5_x(msg_class, a, b, c, d, e, ...) \
422 IPC_SYNC_MESSAGE_CONTROL(msg_class, (a, b, c, d, e), (__VA_ARGS__))
423
424 #define IPC_SYNC_MESSAGE_ROUTED0_x(msg_class, ...) \
425 IPC_SYNC_MESSAGE_ROUTED(msg_class, (), (__VA_ARGS__))
426 #define IPC_SYNC_MESSAGE_ROUTED1_x(msg_class, a, ...) \
427 IPC_SYNC_MESSAGE_ROUTED(msg_class, (a), (__VA_ARGS__))
428 #define IPC_SYNC_MESSAGE_ROUTED2_x(msg_class, a, b, ...) \
429 IPC_SYNC_MESSAGE_ROUTED(msg_class, (a, b), (__VA_ARGS__))
430 #define IPC_SYNC_MESSAGE_ROUTED3_x(msg_class, a, b, c, ...) \
431 IPC_SYNC_MESSAGE_ROUTED(msg_class, (a, b, c), (__VA_ARGS__))
432 #define IPC_SYNC_MESSAGE_ROUTED4_x(msg_class, a, b, c, d, ...) \
433 IPC_SYNC_MESSAGE_ROUTED(msg_class, (a, b, c, d), (__VA_ARGS__))
434 #define IPC_SYNC_MESSAGE_ROUTED5_x(msg_class, a, b, c, d, e, ...) \
435 IPC_SYNC_MESSAGE_ROUTED(msg_class, (a, b, c, d, e), (__VA_ARGS__))
436
437 #define IPC_SYNC_MESSAGE_CONTROL0_0 IPC_SYNC_MESSAGE_CONTROL0_x
438 #define IPC_SYNC_MESSAGE_CONTROL0_1 IPC_SYNC_MESSAGE_CONTROL0_x
439 #define IPC_SYNC_MESSAGE_CONTROL0_2 IPC_SYNC_MESSAGE_CONTROL0_x
440 #define IPC_SYNC_MESSAGE_CONTROL0_3 IPC_SYNC_MESSAGE_CONTROL0_x
441 #define IPC_SYNC_MESSAGE_CONTROL0_4 IPC_SYNC_MESSAGE_CONTROL0_x
442 #define IPC_SYNC_MESSAGE_CONTROL0_5 IPC_SYNC_MESSAGE_CONTROL0_x
443 #define IPC_SYNC_MESSAGE_CONTROL1_0 IPC_SYNC_MESSAGE_CONTROL1_x
444 #define IPC_SYNC_MESSAGE_CONTROL1_1 IPC_SYNC_MESSAGE_CONTROL1_x
445 #define IPC_SYNC_MESSAGE_CONTROL1_2 IPC_SYNC_MESSAGE_CONTROL1_x
446 #define IPC_SYNC_MESSAGE_CONTROL1_3 IPC_SYNC_MESSAGE_CONTROL1_x
447 #define IPC_SYNC_MESSAGE_CONTROL1_4 IPC_SYNC_MESSAGE_CONTROL1_x
448 #define IPC_SYNC_MESSAGE_CONTROL1_5 IPC_SYNC_MESSAGE_CONTROL1_x
449 #define IPC_SYNC_MESSAGE_CONTROL2_0 IPC_SYNC_MESSAGE_CONTROL2_x
450 #define IPC_SYNC_MESSAGE_CONTROL2_1 IPC_SYNC_MESSAGE_CONTROL2_x
451 #define IPC_SYNC_MESSAGE_CONTROL2_2 IPC_SYNC_MESSAGE_CONTROL2_x
452 #define IPC_SYNC_MESSAGE_CONTROL2_3 IPC_SYNC_MESSAGE_CONTROL2_x
453 #define IPC_SYNC_MESSAGE_CONTROL2_4 IPC_SYNC_MESSAGE_CONTROL2_x
454 #define IPC_SYNC_MESSAGE_CONTROL2_5 IPC_SYNC_MESSAGE_CONTROL2_x
455 #define IPC_SYNC_MESSAGE_CONTROL3_0 IPC_SYNC_MESSAGE_CONTROL3_x
456 #define IPC_SYNC_MESSAGE_CONTROL3_1 IPC_SYNC_MESSAGE_CONTROL3_x
457 #define IPC_SYNC_MESSAGE_CONTROL3_2 IPC_SYNC_MESSAGE_CONTROL3_x
458 #define IPC_SYNC_MESSAGE_CONTROL3_3 IPC_SYNC_MESSAGE_CONTROL3_x
459 #define IPC_SYNC_MESSAGE_CONTROL3_4 IPC_SYNC_MESSAGE_CONTROL3_x
460 #define IPC_SYNC_MESSAGE_CONTROL3_5 IPC_SYNC_MESSAGE_CONTROL3_x
461 #define IPC_SYNC_MESSAGE_CONTROL4_0 IPC_SYNC_MESSAGE_CONTROL4_x
462 #define IPC_SYNC_MESSAGE_CONTROL4_1 IPC_SYNC_MESSAGE_CONTROL4_x
463 #define IPC_SYNC_MESSAGE_CONTROL4_2 IPC_SYNC_MESSAGE_CONTROL4_x
464 #define IPC_SYNC_MESSAGE_CONTROL4_3 IPC_SYNC_MESSAGE_CONTROL4_x
465 #define IPC_SYNC_MESSAGE_CONTROL4_4 IPC_SYNC_MESSAGE_CONTROL4_x
466 #define IPC_SYNC_MESSAGE_CONTROL4_5 IPC_SYNC_MESSAGE_CONTROL4_x
467 #define IPC_SYNC_MESSAGE_CONTROL5_0 IPC_SYNC_MESSAGE_CONTROL5_x
468 #define IPC_SYNC_MESSAGE_CONTROL5_1 IPC_SYNC_MESSAGE_CONTROL5_x
469 #define IPC_SYNC_MESSAGE_CONTROL5_2 IPC_SYNC_MESSAGE_CONTROL5_x
470 #define IPC_SYNC_MESSAGE_CONTROL5_3 IPC_SYNC_MESSAGE_CONTROL5_x
471 #define IPC_SYNC_MESSAGE_CONTROL5_4 IPC_SYNC_MESSAGE_CONTROL5_x
472 #define IPC_SYNC_MESSAGE_CONTROL5_5 IPC_SYNC_MESSAGE_CONTROL5_x
473
474 #define IPC_SYNC_MESSAGE_ROUTED0_0 IPC_SYNC_MESSAGE_ROUTED0_x
475 #define IPC_SYNC_MESSAGE_ROUTED0_1 IPC_SYNC_MESSAGE_ROUTED0_x
476 #define IPC_SYNC_MESSAGE_ROUTED0_2 IPC_SYNC_MESSAGE_ROUTED0_x
477 #define IPC_SYNC_MESSAGE_ROUTED0_3 IPC_SYNC_MESSAGE_ROUTED0_x
478 #define IPC_SYNC_MESSAGE_ROUTED0_4 IPC_SYNC_MESSAGE_ROUTED0_x
479 #define IPC_SYNC_MESSAGE_ROUTED0_5 IPC_SYNC_MESSAGE_ROUTED0_x
480 #define IPC_SYNC_MESSAGE_ROUTED1_0 IPC_SYNC_MESSAGE_ROUTED1_x
481 #define IPC_SYNC_MESSAGE_ROUTED1_1 IPC_SYNC_MESSAGE_ROUTED1_x
482 #define IPC_SYNC_MESSAGE_ROUTED1_2 IPC_SYNC_MESSAGE_ROUTED1_x
483 #define IPC_SYNC_MESSAGE_ROUTED1_3 IPC_SYNC_MESSAGE_ROUTED1_x
484 #define IPC_SYNC_MESSAGE_ROUTED1_4 IPC_SYNC_MESSAGE_ROUTED1_x
485 #define IPC_SYNC_MESSAGE_ROUTED1_5 IPC_SYNC_MESSAGE_ROUTED1_x
486 #define IPC_SYNC_MESSAGE_ROUTED2_0 IPC_SYNC_MESSAGE_ROUTED2_x
487 #define IPC_SYNC_MESSAGE_ROUTED2_1 IPC_SYNC_MESSAGE_ROUTED2_x
488 #define IPC_SYNC_MESSAGE_ROUTED2_2 IPC_SYNC_MESSAGE_ROUTED2_x
489 #define IPC_SYNC_MESSAGE_ROUTED2_3 IPC_SYNC_MESSAGE_ROUTED2_x
490 #define IPC_SYNC_MESSAGE_ROUTED2_4 IPC_SYNC_MESSAGE_ROUTED2_x
491 #define IPC_SYNC_MESSAGE_ROUTED2_5 IPC_SYNC_MESSAGE_ROUTED2_x
492 #define IPC_SYNC_MESSAGE_ROUTED3_0 IPC_SYNC_MESSAGE_ROUTED3_x
493 #define IPC_SYNC_MESSAGE_ROUTED3_1 IPC_SYNC_MESSAGE_ROUTED3_x
494 #define IPC_SYNC_MESSAGE_ROUTED3_2 IPC_SYNC_MESSAGE_ROUTED3_x
495 #define IPC_SYNC_MESSAGE_ROUTED3_3 IPC_SYNC_MESSAGE_ROUTED3_x
496 #define IPC_SYNC_MESSAGE_ROUTED3_4 IPC_SYNC_MESSAGE_ROUTED3_x
497 #define IPC_SYNC_MESSAGE_ROUTED3_5 IPC_SYNC_MESSAGE_ROUTED3_x
498 #define IPC_SYNC_MESSAGE_ROUTED4_0 IPC_SYNC_MESSAGE_ROUTED4_x
499 #define IPC_SYNC_MESSAGE_ROUTED4_1 IPC_SYNC_MESSAGE_ROUTED4_x
500 #define IPC_SYNC_MESSAGE_ROUTED4_2 IPC_SYNC_MESSAGE_ROUTED4_x
501 #define IPC_SYNC_MESSAGE_ROUTED4_3 IPC_SYNC_MESSAGE_ROUTED4_x
502 #define IPC_SYNC_MESSAGE_ROUTED4_4 IPC_SYNC_MESSAGE_ROUTED4_x
503 #define IPC_SYNC_MESSAGE_ROUTED4_5 IPC_SYNC_MESSAGE_ROUTED4_x
504 #define IPC_SYNC_MESSAGE_ROUTED5_0 IPC_SYNC_MESSAGE_ROUTED5_x
505 #define IPC_SYNC_MESSAGE_ROUTED5_1 IPC_SYNC_MESSAGE_ROUTED5_x
506 #define IPC_SYNC_MESSAGE_ROUTED5_2 IPC_SYNC_MESSAGE_ROUTED5_x
507 #define IPC_SYNC_MESSAGE_ROUTED5_3 IPC_SYNC_MESSAGE_ROUTED5_x
508 #define IPC_SYNC_MESSAGE_ROUTED5_4 IPC_SYNC_MESSAGE_ROUTED5_x
509 #define IPC_SYNC_MESSAGE_ROUTED5_5 IPC_SYNC_MESSAGE_ROUTED5_x
510
979 #endif // IPC_IPC_MESSAGE_MACROS_H_ 511 #endif // IPC_IPC_MESSAGE_MACROS_H_
980 512
981 // Clean up IPC_MESSAGE_START in this unguarded section so that the 513 // Clean up IPC_MESSAGE_START in this unguarded section so that the
982 // XXX_messages.h files need not do so themselves. This makes the 514 // XXX_messages.h files need not do so themselves. This makes the
983 // XXX_messages.h files easier to write. 515 // XXX_messages.h files easier to write.
984 #undef IPC_MESSAGE_START 516 #undef IPC_MESSAGE_START
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698