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

Side by Side Diff: tools/ipc_fuzzer/message_tools/message_list.cc

Issue 1532053002: use variadic macros/templates in IPC message implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move for real Created 4 years, 10 months 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
« no previous file with comments | « tools/ipc_fuzzer/message_lib/message_names.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include <stddef.h> 5 #include <stddef.h>
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iostream> 8 #include <iostream>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 13
14 // Include once to get the type definitions 14 // Include once to get the type definitions
15 #include "tools/ipc_fuzzer/message_lib/all_messages.h" 15 #include "tools/ipc_fuzzer/message_lib/all_messages.h"
16 16
17 struct msginfo { 17 struct msginfo {
18 const char* name; 18 const char* name;
19 const char* file; 19 const char* file;
20 int id; 20 int id;
21 int in_count;
22 int out_count;
23 21
24 bool operator< (const msginfo& other) const { 22 bool operator< (const msginfo& other) const {
25 return id < other.id; 23 return id < other.id;
26 } 24 }
27 }; 25 };
28 26
29 // Redefine macros to generate table 27 // Redefine macros to generate table
30 #include "tools/ipc_fuzzer/message_lib/all_message_null_macros.h" 28 #include "tools/ipc_fuzzer/message_lib/all_message_null_macros.h"
31 #undef IPC_MESSAGE_DECL 29 #undef IPC_MESSAGE_DECL
32 #define IPC_MESSAGE_DECL(kind, type, name, in, out, ilist, olist) \ 30 #define IPC_MESSAGE_DECL(name, ...) {#name, __FILE__, IPC_MESSAGE_ID()},
33 { #name, __FILE__, IPC_MESSAGE_ID(), in, out },
34 31
35 static msginfo msgtable[] = { 32 static msginfo msgtable[] = {
36 #include "tools/ipc_fuzzer/message_lib/all_messages.h" 33 #include "tools/ipc_fuzzer/message_lib/all_messages.h"
37 }; 34 };
38 #define MSGTABLE_SIZE (sizeof(msgtable)/sizeof(msgtable[0])) 35 #define MSGTABLE_SIZE (sizeof(msgtable)/sizeof(msgtable[0]))
39 static_assert(MSGTABLE_SIZE, "check your headers for an extra semicolon"); 36 static_assert(MSGTABLE_SIZE, "check your headers for an extra semicolon");
40 37
41 static bool check_msgtable() { 38 static bool check_msgtable() {
42 bool result = true; 39 bool result = true;
43 int previous_class_id = 0; 40 int previous_class_id = 0;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 if (show_comma) { 133 if (show_comma) {
137 if (!first) 134 if (!first)
138 std::cout << ","; 135 std::cout << ",";
139 first = false; 136 first = false;
140 std::cout << msgtable[i].id; 137 std::cout << msgtable[i].id;
141 } else { 138 } else {
142 if (show_ids) 139 if (show_ids)
143 std::cout << msgtable[i].id << " " << 140 std::cout << msgtable[i].id << " " <<
144 IPC_MESSAGE_ID_CLASS(msgtable[i].id) << "," << 141 IPC_MESSAGE_ID_CLASS(msgtable[i].id) << "," <<
145 IPC_MESSAGE_ID_LINE(msgtable[i].id) << " "; 142 IPC_MESSAGE_ID_LINE(msgtable[i].id) << " ";
146 std::cout << msgtable[i].name; 143 std::cout << msgtable[i].name << "\n";
147 if (show_args) {
148 std::cout << "(" << msgtable[i].in_count << " IN, " <<
149 msgtable[i].out_count << " OUT)";
150 }
151 std::cout << "\n";
152 } 144 }
153 } 145 }
154 } 146 }
155 if (show_comma) 147 if (show_comma)
156 std::cout << "\n"; 148 std::cout << "\n";
157 } 149 }
158 150
159 int main(int argc, char **argv) { 151 int main(int argc, char **argv) {
160 bool show_args = false; 152 bool show_args = false;
161 bool show_ids = false; 153 bool show_ids = false;
(...skipping 23 matching lines...) Expand all
185 } 177 }
186 178
187 std::sort(msgtable, msgtable + MSGTABLE_SIZE); 179 std::sort(msgtable, msgtable + MSGTABLE_SIZE);
188 180
189 if (!skip_check && check_msgtable() == false) 181 if (!skip_check && check_msgtable() == false)
190 return 1; 182 return 1;
191 183
192 dump_msgtable(show_args, show_ids, show_comma, filter); 184 dump_msgtable(show_args, show_ids, show_comma, filter);
193 return 0; 185 return 0;
194 } 186 }
195
OLDNEW
« no previous file with comments | « tools/ipc_fuzzer/message_lib/message_names.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698