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

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

Issue 2600323002: DevTools: extract protocol module (Closed)
Patch Set: move inspector backend commands.js Created 3 years, 11 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
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 # Copyright (c) 2012 Intel Corporation. All rights reserved. 3 # Copyright (c) 2012 Intel Corporation. All rights reserved.
4 # 4 #
5 # Redistribution and use in source and binary forms, with or without 5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are 6 # modification, are permitted provided that the following conditions are
7 # met: 7 # met:
8 # 8 #
9 # * Redistributions of source code must retain the above copyright 9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer. 10 # notice, this list of conditions and the following disclaimer.
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 Generator.process_command(json_command, domain_name) 216 Generator.process_command(json_command, domain_name)
217 217
218 Generator.backend_js_domain_initializer_list.append("\n") 218 Generator.backend_js_domain_initializer_list.append("\n")
219 219
220 @staticmethod 220 @staticmethod
221 def process_enum(json_enum, enum_name): 221 def process_enum(json_enum, enum_name):
222 enum_members = [] 222 enum_members = []
223 for member in json_enum["enum"]: 223 for member in json_enum["enum"]:
224 enum_members.append("%s: \"%s\"" % (fix_camel_case(member), member)) 224 enum_members.append("%s: \"%s\"" % (fix_camel_case(member), member))
225 225
226 Generator.backend_js_domain_initializer_list.append("InspectorBackend.re gisterEnum(\"%s\", {%s});\n" % ( 226 Generator.backend_js_domain_initializer_list.append("Protocol.inspectorB ackend.registerEnum(\"%s\", {%s});\n" % (
227 enum_name, ", ".join(enum_members))) 227 enum_name, ", ".join(enum_members)))
228 228
229 @staticmethod 229 @staticmethod
230 def process_event(json_event, domain_name): 230 def process_event(json_event, domain_name):
231 event_name = json_event["name"] 231 event_name = json_event["name"]
232 232
233 json_parameters = json_event.get("parameters") 233 json_parameters = json_event.get("parameters")
234 234
235 backend_js_event_param_list = [] 235 backend_js_event_param_list = []
236 if json_parameters: 236 if json_parameters:
237 for parameter in json_parameters: 237 for parameter in json_parameters:
238 parameter_name = parameter["name"] 238 parameter_name = parameter["name"]
239 backend_js_event_param_list.append("\"%s\"" % parameter_name) 239 backend_js_event_param_list.append("\"%s\"" % parameter_name)
240 240
241 Generator.backend_js_domain_initializer_list.append("InspectorBackend.re gisterEvent(\"%s.%s\", [%s]);\n" % ( 241 Generator.backend_js_domain_initializer_list.append("Protocol.inspectorB ackend.registerEvent(\"%s.%s\", [%s]);\n" % (
242 domain_name, event_name, ", ".join(backend_js_event_param_list))) 242 domain_name, event_name, ", ".join(backend_js_event_param_list)))
243 243
244 @staticmethod 244 @staticmethod
245 def process_command(json_command, domain_name): 245 def process_command(json_command, domain_name):
246 json_command_name = json_command["name"] 246 json_command_name = json_command["name"]
247 247
248 js_parameters_text = "" 248 js_parameters_text = ""
249 if "parameters" in json_command: 249 if "parameters" in json_command:
250 json_params = json_command["parameters"] 250 json_params = json_command["parameters"]
251 js_param_list = [] 251 js_param_list = []
(...skipping 20 matching lines...) Expand all
272 for json_return in json_command["returns"]: 272 for json_return in json_command["returns"]:
273 json_return_name = json_return["name"] 273 json_return_name = json_return["name"]
274 backend_js_reply_param_list.append("\"%s\"" % json_return_name) 274 backend_js_reply_param_list.append("\"%s\"" % json_return_name)
275 275
276 js_reply_list = "[%s]" % ", ".join(backend_js_reply_param_list) 276 js_reply_list = "[%s]" % ", ".join(backend_js_reply_param_list)
277 if "error" in json_command: 277 if "error" in json_command:
278 has_error_data_param = "true" 278 has_error_data_param = "true"
279 else: 279 else:
280 has_error_data_param = "false" 280 has_error_data_param = "false"
281 281
282 Generator.backend_js_domain_initializer_list.append("InspectorBackend.re gisterCommand(\"%s.%s\", [%s], %s, %s);\n" % (domain_name, json_command_name, js _parameters_text, js_reply_list, has_error_data_param)) 282 Generator.backend_js_domain_initializer_list.append("Protocol.inspectorB ackend.registerCommand(\"%s.%s\", [%s], %s, %s);\n" % (domain_name, json_command _name, js_parameters_text, js_reply_list, has_error_data_param))
283 283
284 Generator.go() 284 Generator.go()
285 285
286 backend_js_file = open(output_js_dirname + "/InspectorBackendCommands.js", "w") 286 backend_js_file = open(output_js_dirname + "/InspectorBackendCommands.js", "w")
287 287
288 backend_js_file.write(Templates.backend_js.substitute(None, 288 backend_js_file.write(Templates.backend_js.substitute(None,
289 domainInitializers="".join(Generator.backend_js_domain_initializer_list))) 289 domainInitializers="".join(Generator.backend_js_domain_initializer_list)))
290 290
291 backend_js_file.close() 291 backend_js_file.close()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698