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

Side by Side Diff: third_party/WebKit/Source/devtools/scripts/build/generate_protocol_externs.py

Issue 2863433002: DevTools: Make domains promisified by default (Closed)
Patch Set: Created 3 years, 7 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 | « no previous file | 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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2011 Google Inc. All rights reserved. 2 # Copyright (c) 2011 Google Inc. All rights reserved.
3 # 3 #
4 # Redistribution and use in source and binary forms, with or without 4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are 5 # modification, are permitted provided that the following conditions are
6 # met: 6 # met:
7 # 7 #
8 # * Redistributions of source code must retain the above copyright 8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer. 9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above 10 # * Redistributions in binary form must reproduce the above
(...skipping 28 matching lines...) Expand all
39 "string": "string", 39 "string": "string",
40 "integer": "number", 40 "integer": "number",
41 "number": "number", 41 "number": "number",
42 "boolean": "boolean", 42 "boolean": "boolean",
43 "array": "!Array<*>", 43 "array": "!Array<*>",
44 "object": "!Object", 44 "object": "!Object",
45 } 45 }
46 46
47 ref_types = {} 47 ref_types = {}
48 48
49 PROMISIFIED_DOMAINS = frozenset([ 49 NON_PROMISIFIED_DOMAINS = frozenset([
50 "HeapProfiler", 50 "Accessibility",
51 "Profiler", 51 "Animation",
52 "ApplicationCache",
53 "CacheStorage",
54 "CSS",
55 "Debugger",
56 "DOM",
57 "DOMDebugger",
58 "IndexedDB",
59 "LayerTree",
60 "Network",
61 "Page",
62 "Runtime",
63 "Target",
52 ]) 64 ])
53 65
54 66
55 def full_qualified_type_id(domain_name, type_id): 67 def full_qualified_type_id(domain_name, type_id):
56 if type_id.find(".") == -1: 68 if type_id.find(".") == -1:
57 return "%s.%s" % (domain_name, type_id) 69 return "%s.%s" % (domain_name, type_id)
58 return type_id 70 return type_id
59 71
60 72
61 def fix_camel_case(name): 73 def fix_camel_case(name):
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 127
116 for domain in domains: 128 for domain in domains:
117 domain_name = domain["domain"] 129 domain_name = domain["domain"]
118 if "types" in domain: 130 if "types" in domain:
119 for type in domain["types"]: 131 for type in domain["types"]:
120 type_id = full_qualified_type_id(domain_name, type["id"]) 132 type_id = full_qualified_type_id(domain_name, type["id"])
121 ref_types[type_id] = "Protocol.%s.%s" % (domain_name, type["id"] ) 133 ref_types[type_id] = "Protocol.%s.%s" % (domain_name, type["id"] )
122 134
123 for domain in domains: 135 for domain in domains:
124 domain_name = domain["domain"] 136 domain_name = domain["domain"]
125 is_promisified = domain_name in PROMISIFIED_DOMAINS 137 is_promisified = domain_name not in NON_PROMISIFIED_DOMAINS
126 138
127 output_file.write("Protocol.%s = {};\n" % domain_name) 139 output_file.write("Protocol.%s = {};\n" % domain_name)
128 output_file.write("\n\n/**\n * @constructor\n*/\n") 140 output_file.write("\n\n/**\n * @constructor\n*/\n")
129 output_file.write("Protocol.%sAgent = function(){};\n" % domain_name) 141 output_file.write("Protocol.%sAgent = function(){};\n" % domain_name)
130 142
131 if "commands" in domain: 143 if "commands" in domain:
132 for command in domain["commands"]: 144 for command in domain["commands"]:
133 output_file.write("\n/**\n") 145 output_file.write("\n/**\n")
134 params = [] 146 params = []
135 in_param_to_type = {} 147 in_param_to_type = {}
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 import sys 284 import sys
273 import os.path 285 import os.path
274 program_name = os.path.basename(__file__) 286 program_name = os.path.basename(__file__)
275 if len(sys.argv) < 5 or sys.argv[1] != "-o": 287 if len(sys.argv) < 5 or sys.argv[1] != "-o":
276 sys.stderr.write("Usage: %s -o OUTPUT_FILE INPUT_FILE_1 INPUT_FILE_2\n" % program_name) 288 sys.stderr.write("Usage: %s -o OUTPUT_FILE INPUT_FILE_1 INPUT_FILE_2\n" % program_name)
277 exit(1) 289 exit(1)
278 output_path = sys.argv[2] 290 output_path = sys.argv[2]
279 input_path_1 = sys.argv[3] 291 input_path_1 = sys.argv[3]
280 input_path_2 = sys.argv[4] 292 input_path_2 = sys.argv[4]
281 generate_protocol_externs(output_path, input_path_1, input_path_2) 293 generate_protocol_externs(output_path, input_path_1, input_path_2)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698