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

Side by Side Diff: content/browser/devtools/protocol/devtools_protocol_handler_generator.py

Issue 2100883002: DevTools: merge browser_protocol.json files from content and core/inspector. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: gn fix Created 4 years, 5 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 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 blink_protocol_path = sys.argv[1] 10 blink_protocol_path = sys.argv[1]
11 browser_protocol_path = sys.argv[2] 11 output_cc_path = sys.argv[2]
12 output_cc_path = sys.argv[3] 12 output_h_path = sys.argv[3]
13 output_h_path = sys.argv[4]
14 13
15 header = """\ 14 header = """\
16 // Copyright 2014 The Chromium Authors. All rights reserved. 15 // Copyright 2014 The Chromium Authors. All rights reserved.
17 // Use of this source code is governed by a BSD-style license that can be 16 // Use of this source code is governed by a BSD-style license that can be
18 // found in the LICENSE file. 17 // found in the LICENSE file.
19 18
20 // THIS FILE IS AUTOGENERATED. DO NOT EDIT. 19 // THIS FILE IS AUTOGENERATED. DO NOT EDIT.
21 // Generated by 20 // Generated by
22 // content/public/browser/devtools_protocol_handler_generator.py from 21 // content/public/browser/devtools_protocol_handler_generator.py from
23 // gen/blink/core/inspector/protocol.json and 22 // gen/blink/core/inspector/protocol.json and
24 // content/browser/devtools/browser_protocol.json
25 """ 23 """
26 24
27 template_h = string.Template(header + """\ 25 template_h = string.Template(header + """\
28 26
29 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_DEVTOOLS_PROTOCOL_DISPATCHER_H_ 27 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_DEVTOOLS_PROTOCOL_DISPATCHER_H_
30 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_DEVTOOLS_PROTOCOL_DISPATCHER_H_ 28 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_DEVTOOLS_PROTOCOL_DISPATCHER_H_
31 29
32 #include <utility> 30 #include <utility>
33 31
34 #include "base/memory/ptr_util.h" 32 #include "base/memory/ptr_util.h"
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 if c.isupper(): 445 if c.isupper():
448 if (i > 0) and ((i < len(s)-1) and s[i+1].islower() or s[i-1].islower()): 446 if (i > 0) and ((i < len(s)-1) and s[i+1].islower() or s[i-1].islower()):
449 result += "_" 447 result += "_"
450 result += c.lower() 448 result += c.lower()
451 else: 449 else:
452 result += c 450 result += c
453 return result 451 return result
454 452
455 types = {} 453 types = {}
456 blink_protocol = json.loads(open(blink_protocol_path, "r").read()) 454 blink_protocol = json.loads(open(blink_protocol_path, "r").read())
457 browser_protocol = json.loads(open(browser_protocol_path, "r").read())
458 type_decls = [] 455 type_decls = []
459 type_impls = [] 456 type_impls = []
460 handler_methods = [] 457 handler_methods = []
461 handler_method_impls = [] 458 handler_method_impls = []
462 domain_maps = [] 459 domain_maps = []
463 redirects = {} 460 redirects = {}
464 461
465 all_domains = blink_protocol["domains"] + browser_protocol["domains"] 462 all_domains = blink_protocol["domains"]
466 463
467 for json_domain in all_domains: 464 for json_domain in all_domains:
468 if "types" in json_domain: 465 if "types" in json_domain:
469 for json_type in json_domain["types"]: 466 for json_type in json_domain["types"]:
470 types["%s.%s" % (json_domain["domain"], json_type["id"])] = json_type 467 types["%s.%s" % (json_domain["domain"], json_type["id"])] = json_type
471 468
472 def DeclareStruct(json_properties, mapping): 469 def DeclareStruct(json_properties, mapping):
473 methods = [] 470 methods = []
474 fields_enum = [] 471 fields_enum = []
475 enum_items = [] 472 enum_items = []
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 output_h_file.close() 795 output_h_file.close()
799 796
800 output_cc_file.write(template_cc.substitute({}, 797 output_cc_file.write(template_cc.substitute({},
801 major = blink_protocol["version"]["major"], 798 major = blink_protocol["version"]["major"],
802 minor = blink_protocol["version"]["minor"], 799 minor = blink_protocol["version"]["minor"],
803 includes = "".join(sorted(includes)), 800 includes = "".join(sorted(includes)),
804 fields_init = ",\n ".join(fields_init), 801 fields_init = ",\n ".join(fields_init),
805 methods = "\n".join(handler_method_impls), 802 methods = "\n".join(handler_method_impls),
806 types = "\n".join(type_impls))) 803 types = "\n".join(type_impls)))
807 output_cc_file.close() 804 output_cc_file.close()
OLDNEW
« no previous file with comments | « content/browser/devtools/devtools.gyp ('k') | third_party/WebKit/Source/core/inspector/browser_protocol.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698