| OLD | NEW |
| 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] |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 | 242 |
| 243 tmpl_field = string.Template("""\ | 243 tmpl_field = string.Template("""\ |
| 244 devtools::${domain}::${Domain}Handler* ${domain}_handler_; | 244 devtools::${domain}::${Domain}Handler* ${domain}_handler_; |
| 245 """) | 245 """) |
| 246 | 246 |
| 247 template_cc = string.Template(header + """\ | 247 template_cc = string.Template(header + """\ |
| 248 | 248 |
| 249 #include "base/bind.h" | 249 #include "base/bind.h" |
| 250 #include "base/strings/string_number_conversions.h" | 250 #include "base/strings/string_number_conversions.h" |
| 251 #include "base/strings/string_split.h" | 251 #include "base/strings/string_split.h" |
| 252 #include "content/browser/devtools/protocol/devtools_protocol_dispatcher.h" |
| 252 ${includes}\ | 253 ${includes}\ |
| 253 | 254 |
| 254 namespace content { | 255 namespace content { |
| 255 | 256 |
| 256 DevToolsProtocolDispatcher::DevToolsProtocolDispatcher( | 257 DevToolsProtocolDispatcher::DevToolsProtocolDispatcher( |
| 257 DevToolsProtocolDelegate* notifier) | 258 DevToolsProtocolDelegate* notifier) |
| 258 : notifier_(notifier), | 259 : notifier_(notifier), |
| 259 client_(notifier), | 260 client_(notifier) |
| 260 ${fields_init} { | 261 ${fields_init} { |
| 262 DCHECK(notifier_); |
| 261 } | 263 } |
| 262 | 264 |
| 263 DevToolsProtocolDispatcher::~DevToolsProtocolDispatcher() { | 265 DevToolsProtocolDispatcher::~DevToolsProtocolDispatcher() { |
| 264 } | 266 } |
| 265 | 267 |
| 266 DevToolsProtocolDispatcher::CommandHandler | 268 DevToolsProtocolDispatcher::CommandHandler |
| 267 DevToolsProtocolDispatcher::FindCommandHandler(const std::string& method) { | 269 DevToolsProtocolDispatcher::FindCommandHandler(const std::string& method) { |
| 268 CommandHandlers::iterator it = command_handlers_.find(method); | 270 CommandHandlers::iterator it = command_handlers_.find(method); |
| 269 return it == command_handlers_.end() ? CommandHandler() : it->second; | 271 return it == command_handlers_.end() ? CommandHandler() : it->second; |
| 270 } | 272 } |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 else: | 638 else: |
| 637 raise Exception("Unknown type at %s.%s %s" % | 639 raise Exception("Unknown type at %s.%s %s" % |
| 638 (mapping["Domain"], mapping["command"], mapping["proto_param"])) | 640 (mapping["Domain"], mapping["command"], mapping["proto_param"])) |
| 639 | 641 |
| 640 setters = [] | 642 setters = [] |
| 641 fields = [] | 643 fields = [] |
| 642 | 644 |
| 643 includes = [] | 645 includes = [] |
| 644 fields_init = [] | 646 fields_init = [] |
| 645 | 647 |
| 646 browser_domains_list = ["Input"] | 648 browser_domains_list = [] |
| 647 browser_commands_list = [] | 649 browser_commands_list = [] |
| 648 async_commands_list = [ | 650 async_commands_list = [] |
| 649 "Input.synthesizePinchGesture", | |
| 650 "Input.synthesizeScrollGesture", | |
| 651 "Input.synthesizeTapGesture"] | |
| 652 | 651 |
| 653 for json_domain in all_domains: | 652 for json_domain in all_domains: |
| 654 domain_map = {} | 653 domain_map = {} |
| 655 domain_map["Domain"] = json_domain["domain"] | 654 domain_map["Domain"] = json_domain["domain"] |
| 656 domain_map["domain"] = Uncamelcase(json_domain["domain"]) | 655 domain_map["domain"] = Uncamelcase(json_domain["domain"]) |
| 657 | 656 |
| 658 initializations = [] | 657 initializations = [] |
| 659 client_methods = [] | 658 client_methods = [] |
| 660 client_method_impls = [] | 659 client_method_impls = [] |
| 661 domain_empty = True | 660 domain_empty = True |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 | 775 |
| 777 client_methods.append(tmpl_event.substitute(event_map)) | 776 client_methods.append(tmpl_event.substitute(event_map)) |
| 778 client_method_impls.append(tmpl_event_impl.substitute(event_map)) | 777 client_method_impls.append(tmpl_event_impl.substitute(event_map)) |
| 779 | 778 |
| 780 if domain_empty: | 779 if domain_empty: |
| 781 continue | 780 continue |
| 782 type_decls.append(tmpl_handler.substitute(domain_map)) | 781 type_decls.append(tmpl_handler.substitute(domain_map)) |
| 783 setters.append(tmpl_setter.substitute(domain_map)) | 782 setters.append(tmpl_setter.substitute(domain_map)) |
| 784 fields.append(tmpl_field.substitute(domain_map)) | 783 fields.append(tmpl_field.substitute(domain_map)) |
| 785 includes.append(tmpl_include.substitute(domain_map)) | 784 includes.append(tmpl_include.substitute(domain_map)) |
| 786 fields_init.append(tmpl_field_init.substitute(domain_map)) | 785 fields_init.append(",\n " + tmpl_field_init.substitute(domain_map)) |
| 787 if domain_needs_client: | 786 if domain_needs_client: |
| 788 type_decls.append(tmpl_client.substitute(domain_map, | 787 type_decls.append(tmpl_client.substitute(domain_map, |
| 789 methods = "".join(client_methods))) | 788 methods = "".join(client_methods))) |
| 790 initializations.append(tmpl_init_client.substitute(domain_map)) | 789 initializations.append(tmpl_init_client.substitute(domain_map)) |
| 791 type_impls.append(tmpl_client_impl.substitute(domain_map, | 790 type_impls.append(tmpl_client_impl.substitute(domain_map, |
| 792 methods = "\n".join(client_method_impls))) | 791 methods = "\n".join(client_method_impls))) |
| 793 domain_map["initializations"] = "".join(initializations) | 792 domain_map["initializations"] = "".join(initializations) |
| 794 domain_maps.append(domain_map) | 793 domain_maps.append(domain_map) |
| 795 | 794 |
| 796 for domain_map in domain_maps: | 795 for domain_map in domain_maps: |
| 797 domain = domain_map["Domain"] | 796 domain = domain_map["Domain"] |
| 798 if domain in redirects: | 797 if domain in redirects: |
| 799 domain_map["initializations"] += "".join(redirects[domain]) | 798 domain_map["initializations"] += "".join(redirects[domain]) |
| 800 handler_method_impls.append(tmpl_setter_impl.substitute(domain_map)) | 799 handler_method_impls.append(tmpl_setter_impl.substitute(domain_map)) |
| 801 | 800 |
| 802 output_h_file = open(output_h_path, "w") | 801 output_h_file = open(output_h_path, "w") |
| 803 output_cc_file = open(output_cc_path, "w") | 802 output_cc_file = open(output_cc_path, "w") |
| 804 | 803 |
| 805 output_h_file.write(template_h.substitute({}, | 804 output_h_file.write(template_h.substitute({}, |
| 806 types = "\n".join(type_decls), | 805 types = "\n".join(type_decls), |
| 807 setters = "".join(setters), | 806 setters = "".join(setters), |
| 808 methods = "".join(handler_methods), | 807 methods = "".join(handler_methods), |
| 809 fields = "".join(fields))) | 808 fields = "".join(fields))) |
| 810 output_h_file.close() | 809 output_h_file.close() |
| 811 | 810 |
| 812 output_cc_file.write(template_cc.substitute({}, | 811 output_cc_file.write(template_cc.substitute({}, |
| 813 major = blink_protocol["version"]["major"], | 812 major = blink_protocol["version"]["major"], |
| 814 minor = blink_protocol["version"]["minor"], | 813 minor = blink_protocol["version"]["minor"], |
| 815 includes = "".join(sorted(includes)), | 814 includes = "".join(sorted(includes)), |
| 816 fields_init = ",\n ".join(fields_init), | 815 fields_init = "".join(fields_init), |
| 817 methods = "\n".join(handler_method_impls), | 816 methods = "\n".join(handler_method_impls), |
| 818 types = "\n".join(type_impls))) | 817 types = "\n".join(type_impls))) |
| 819 output_cc_file.close() | 818 output_cc_file.close() |
| OLD | NEW |