OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import sys | 6 import sys |
7 import string | 7 import string |
8 import json | 8 import json |
9 | 9 |
10 package = sys.argv[1] | 10 package = sys.argv[1] |
11 output_cc_path = sys.argv[2] | 11 output_cc_path = sys.argv[2] |
12 output_h_path = sys.argv[3] | 12 output_h_path = sys.argv[3] |
13 blink_protocol_path = sys.argv[4] | 13 blink_protocol_path = sys.argv[4] |
14 browser_protocol_path = sys.argv[5] if len(sys.argv) > 5 else None | |
15 | 14 |
16 template_h = string.Template("""\ | 15 template_h = string.Template("""\ |
17 // Copyright 2013 The Chromium Authors. All rights reserved. | 16 // Copyright 2013 The Chromium Authors. All rights reserved. |
18 // Use of this source code is governed by a BSD-style license that can be | 17 // Use of this source code is governed by a BSD-style license that can be |
19 // found in the LICENSE file. | 18 // found in the LICENSE file. |
20 | 19 |
21 #ifndef ${PACKAGE}_BROWSER_DEVTOOLS_DEVTOOLS_PROTOCOL_CONSTANTS_H_ | 20 #ifndef ${PACKAGE}_BROWSER_DEVTOOLS_DEVTOOLS_PROTOCOL_CONSTANTS_H_ |
22 #define ${PACKAGE}_BROWSER_DEVTOOLS_DEVTOOLS_PROTOCOL_CONSTANTS_H_ | 21 #define ${PACKAGE}_BROWSER_DEVTOOLS_DEVTOOLS_PROTOCOL_CONSTANTS_H_ |
23 | 22 |
24 // THIS FILE IS AUTOGENERATED. DO NOT EDIT. | 23 // THIS FILE IS AUTOGENERATED. DO NOT EDIT. |
25 // Generated by | 24 // Generated by |
26 // chrome/browser/devtools/devtools_protocol_constants_generator.py from | 25 // chrome/browser/devtools/devtools_protocol_constants_generator.py from |
27 // gen/blink/core/inspector/protocol.json and | 26 // gen/blink/core/inspector/protocol.json |
28 // content/browser/devtools/browser_protocol.json | |
29 | 27 |
30 #include <string> | 28 #include <string> |
31 | 29 |
32 namespace $package { | 30 namespace $package { |
33 namespace devtools { | 31 namespace devtools { |
34 | 32 |
35 extern const char kProtocolVersion[]; | 33 extern const char kProtocolVersion[]; |
36 | 34 |
37 bool IsSupportedProtocolVersion(const std::string& version); | 35 bool IsSupportedProtocolVersion(const std::string& version); |
38 | 36 |
39 extern const char kResult[]; | 37 extern const char kResult[]; |
40 $contents | 38 $contents |
41 | 39 |
42 } // devtools | 40 } // devtools |
43 } // $package | 41 } // $package |
44 | 42 |
45 #endif // ${PACKAGE}_BROWSER_DEVTOOLS_DEVTOOLS_PROTOCOL_CONSTANTS_H_ | 43 #endif // ${PACKAGE}_BROWSER_DEVTOOLS_DEVTOOLS_PROTOCOL_CONSTANTS_H_ |
46 """) | 44 """) |
47 | 45 |
48 template_cc = string.Template("""\ | 46 template_cc = string.Template("""\ |
49 // Copyright 2013 The Chromium Authors. All rights reserved. | 47 // Copyright 2013 The Chromium Authors. All rights reserved. |
50 // Use of this source code is governed by a BSD-style license that can be | 48 // Use of this source code is governed by a BSD-style license that can be |
51 // found in the LICENSE file. | 49 // found in the LICENSE file. |
52 | 50 |
53 // THIS FILE IS AUTOGENERATED. DO NOT EDIT. | 51 // THIS FILE IS AUTOGENERATED. DO NOT EDIT. |
54 // Generated by | 52 // Generated by |
55 // chrome/browser/devtools/devtools_protocol_constants_generator.py from | 53 // chrome/browser/devtools/devtools_protocol_constants_generator.py from |
56 // gen/blink/core/inspector/protocol.json and | 54 // gen/blink/core/inspector/protocol.json |
57 // content/browser/devtools/browser_protocol.json | |
58 | 55 |
59 #include "base/strings/string_number_conversions.h" | 56 #include "base/strings/string_number_conversions.h" |
60 #include "base/strings/string_split.h" | 57 #include "base/strings/string_split.h" |
61 #include "base/strings/string_util.h" | 58 #include "base/strings/string_util.h" |
62 #include "$package/browser/devtools/devtools_protocol_constants.h" | 59 #include "$package/browser/devtools/devtools_protocol_constants.h" |
63 | 60 |
64 namespace $package { | 61 namespace $package { |
65 namespace devtools { | 62 namespace devtools { |
66 | 63 |
67 const char kProtocolVersion[] = "$major.$minor"; | 64 const char kProtocolVersion[] = "$major.$minor"; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 "contents": contents, | 148 "contents": contents, |
152 "package": package | 149 "package": package |
153 })) | 150 })) |
154 | 151 |
155 blink_protocol_data = open(blink_protocol_path).read() | 152 blink_protocol_data = open(blink_protocol_path).read() |
156 blink_protocol = json.loads(blink_protocol_data) | 153 blink_protocol = json.loads(blink_protocol_data) |
157 blink_version = blink_protocol["version"] | 154 blink_version = blink_protocol["version"] |
158 | 155 |
159 domains = blink_protocol["domains"] | 156 domains = blink_protocol["domains"] |
160 | 157 |
161 if browser_protocol_path: | |
162 browser_protocol_data = open(browser_protocol_path).read() | |
163 browser_protocol = json.loads(browser_protocol_data) | |
164 domains = domains + browser_protocol["domains"] | |
165 | |
166 namespace_tree = {} | 158 namespace_tree = {} |
167 | 159 |
168 for domain in domains: | 160 for domain in domains: |
169 domain_value = {} | 161 domain_value = {} |
170 domain_namespace_name = Capitalize(domain["domain"]) | 162 domain_namespace_name = Capitalize(domain["domain"]) |
171 if "commands" in domain: | 163 if "commands" in domain: |
172 for command in domain["commands"]: | 164 for command in domain["commands"]: |
173 if (IsHandledInBrowser(command)): | 165 if (IsHandledInBrowser(command)): |
174 domain_value[command["name"]] = CreateNamespace(domain["domain"], | 166 domain_value[command["name"]] = CreateNamespace(domain["domain"], |
175 command, ["parameters", "returns"], ["kParam", "kResponse"], | 167 command, ["parameters", "returns"], ["kParam", "kResponse"], |
(...skipping 27 matching lines...) Expand all Loading... |
203 sys.exit(1) | 195 sys.exit(1) |
204 | 196 |
205 for (namespace_name, namespace) in namespace_tree.items(): | 197 for (namespace_name, namespace) in namespace_tree.items(): |
206 namespace["kName"] = namespace_name | 198 namespace["kName"] = namespace_name |
207 | 199 |
208 with open(output_cc_path, "w") as f: | 200 with open(output_cc_path, "w") as f: |
209 CreateBody(namespace_tree, blink_version, f) | 201 CreateBody(namespace_tree, blink_version, f) |
210 | 202 |
211 with open(output_h_path, "w") as f: | 203 with open(output_h_path, "w") as f: |
212 CreateHeader(namespace_tree, f) | 204 CreateHeader(namespace_tree, f) |
OLD | NEW |