| 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 input_json_path = sys.argv[1] | 10 input_json_path = sys.argv[1] |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 tmpl_handler = string.Template("""\ | 113 tmpl_handler = string.Template("""\ |
| 114 namespace ${domain} { | 114 namespace ${domain} { |
| 115 class ${Domain}Handler; | 115 class ${Domain}Handler; |
| 116 } // namespace domain | 116 } // namespace domain |
| 117 """) | 117 """) |
| 118 | 118 |
| 119 tmpl_client = string.Template("""\ | 119 tmpl_client = string.Template("""\ |
| 120 namespace ${domain} { | 120 namespace ${domain} { |
| 121 class Client : public DevToolsProtocolClient { | 121 class Client : public DevToolsProtocolClient { |
| 122 public: | 122 public: |
| 123 Client(const EventCallback& event_callback, | 123 Client(const RawMessageCallback& raw_message_callback); |
| 124 const ResponseCallback& response_callback); | |
| 125 virtual ~Client(); | 124 virtual ~Client(); |
| 126 | 125 |
| 127 ${methods}\ | 126 ${methods}\ |
| 128 }; | 127 }; |
| 129 } // namespace ${domain} | 128 } // namespace ${domain} |
| 130 """) | 129 """) |
| 131 | 130 |
| 132 tmpl_event = string.Template("""\ | 131 tmpl_event = string.Template("""\ |
| 133 void ${Command}( | 132 void ${Command}( |
| 134 const ${Command}Params& params); | 133 const ${Command}Params& params); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 RegisterCommandHandler( | 238 RegisterCommandHandler( |
| 240 "${Domain}.${command}", | 239 "${Domain}.${command}", |
| 241 base::Bind( | 240 base::Bind( |
| 242 &DevToolsProtocolHandlerImpl::On${Domain}${Command}, | 241 &DevToolsProtocolHandlerImpl::On${Domain}${Command}, |
| 243 base::Unretained(this))); | 242 base::Unretained(this))); |
| 244 """) | 243 """) |
| 245 | 244 |
| 246 tmpl_init_client = string.Template("""\ | 245 tmpl_init_client = string.Template("""\ |
| 247 ${domain}_handler_->SetClient(make_scoped_ptr( | 246 ${domain}_handler_->SetClient(make_scoped_ptr( |
| 248 new devtools::${domain}::Client( | 247 new devtools::${domain}::Client( |
| 249 base::Bind(&DevToolsProtocolHandlerImpl::SendNotification, | 248 base::Bind(&DevToolsProtocolHandlerImpl::SendRawMessage, |
| 250 base::Unretained(this)), | |
| 251 base::Bind(&DevToolsProtocolHandlerImpl::SendAsyncResponse, | |
| 252 base::Unretained(this))))); | 249 base::Unretained(this))))); |
| 253 """) | 250 """) |
| 254 | 251 |
| 255 tmpl_callback_impl = string.Template("""\ | 252 tmpl_callback_impl = string.Template("""\ |
| 256 scoped_refptr<DevToolsProtocol::Response> | 253 scoped_refptr<DevToolsProtocol::Response> |
| 257 DevToolsProtocolHandlerImpl::On${Domain}${Command}( | 254 DevToolsProtocolHandlerImpl::On${Domain}${Command}( |
| 258 scoped_refptr<DevToolsProtocol::Command> command) { | 255 scoped_refptr<DevToolsProtocol::Command> command) { |
| 259 ${prep}\ | 256 ${prep}\ |
| 260 Response response = ${domain}_handler_->${Command}(${args}); | 257 Response response = ${domain}_handler_->${Command}(${args}); |
| 261 scoped_refptr<DevToolsProtocol::Response> protocol_response; | 258 scoped_refptr<DevToolsProtocol::Response> protocol_response; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 void ${declared_name}::set_${param}( | 348 void ${declared_name}::set_${param}( |
| 352 ${pass_type} ${param}) { | 349 ${pass_type} ${param}) { |
| 353 ${param}_ = ${param}; | 350 ${param}_ = ${param}; |
| 354 has_${param}_ = true; | 351 has_${param}_ = true; |
| 355 } | 352 } |
| 356 """) | 353 """) |
| 357 | 354 |
| 358 tmpl_client_impl = string.Template("""\ | 355 tmpl_client_impl = string.Template("""\ |
| 359 namespace ${domain} { | 356 namespace ${domain} { |
| 360 | 357 |
| 361 Client::Client(const EventCallback& event_callback, | 358 Client::Client(const RawMessageCallback& raw_message_callback) |
| 362 const ResponseCallback& response_callback) | 359 : DevToolsProtocolClient(raw_message_callback) { |
| 363 : DevToolsProtocolClient(event_callback, response_callback) { | |
| 364 } | 360 } |
| 365 | 361 |
| 366 Client::~Client() { | 362 Client::~Client() { |
| 367 } | 363 } |
| 368 | 364 |
| 369 ${methods}\ | 365 ${methods}\ |
| 370 | 366 |
| 371 } // namespace ${domain} | 367 } // namespace ${domain} |
| 372 """) | 368 """) |
| 373 | 369 |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 methods = "".join(handler_methods), | 764 methods = "".join(handler_methods), |
| 769 fields = "".join(fields))) | 765 fields = "".join(fields))) |
| 770 output_h_file.close() | 766 output_h_file.close() |
| 771 | 767 |
| 772 output_cc_file.write(template_cc.substitute({}, | 768 output_cc_file.write(template_cc.substitute({}, |
| 773 includes = "".join(sorted(includes)), | 769 includes = "".join(sorted(includes)), |
| 774 fields_init = ",\n ".join(fields_init), | 770 fields_init = ",\n ".join(fields_init), |
| 775 methods = "\n".join(handler_method_impls), | 771 methods = "\n".join(handler_method_impls), |
| 776 types = "\n".join(type_impls))) | 772 types = "\n".join(type_impls))) |
| 777 output_cc_file.close() | 773 output_cc_file.close() |
| OLD | NEW |