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