Chromium Code Reviews

Side by Side Diff: templates/TypeBuilder_cpp.template

Issue 2495353004: [inspector_protocol] Support chromium code style. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « templates/Imported_h.template ('k') | templates/TypeBuilder_h.template » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // This file is generated 1 // This file is generated
2 2
3 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 3 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style license that can be 4 // Use of this source code is governed by a BSD-style license that can be
5 // found in the LICENSE file. 5 // found in the LICENSE file.
6 6
7 #include "{{config.protocol.package}}/{{domain.domain}}.h" 7 #include {{format_include(config.protocol.package, domain.domain)}}
8 8
9 #include "{{config.protocol.package}}/Protocol.h" 9 #include {{format_include(config.protocol.package, "Protocol")}}
10 10
11 {% for namespace in config.protocol.namespace %} 11 {% for namespace in config.protocol.namespace %}
12 namespace {{namespace}} { 12 namespace {{namespace}} {
13 {% endfor %} 13 {% endfor %}
14 namespace {{domain.domain}} { 14 namespace {{domain.domain}} {
15 15
16 // ------------- Enum values from types. 16 // ------------- Enum values from types.
17 17
18 const char Metainfo::domainName[] = "{{domain.domain}}"; 18 const char Metainfo::domainName[] = "{{domain.domain}}";
19 const char Metainfo::commandPrefix[] = "{{domain.domain}}."; 19 const char Metainfo::commandPrefix[] = "{{domain.domain}}.";
(...skipping 120 matching lines...)
140 } // namespace API 140 } // namespace API
141 {% endif %} 141 {% endif %}
142 {% endif %} 142 {% endif %}
143 {% endfor %} 143 {% endfor %}
144 {% endfor %} 144 {% endfor %}
145 145
146 // ------------- Frontend notifications. 146 // ------------- Frontend notifications.
147 {% for event in domain.events %} 147 {% for event in domain.events %}
148 {% if not generate_event(domain.domain, event.name) %}{% continue %}{% endif %} 148 {% if not generate_event(domain.domain, event.name) %}{% continue %}{% endif %}
149 149
150 void Frontend::{{event.name}}( 150 void Frontend::{{event.name | to_method_case}}(
151 {%- for parameter in event.parameters %} 151 {%- for parameter in event.parameters %}
152 {% if "optional" in parameter -%} 152 {% if "optional" in parameter -%}
153 Maybe<{{resolve_type(parameter).raw_type}}> 153 Maybe<{{resolve_type(parameter).raw_type}}>
154 {%- else -%} 154 {%- else -%}
155 {{resolve_type(parameter).pass_type}} 155 {{resolve_type(parameter).pass_type}}
156 {%- endif %} {{parameter.name}}{%- if not loop.last -%}, {% endif -%} 156 {%- endif %} {{parameter.name}}{%- if not loop.last -%}, {% endif -%}
157 {% endfor -%}) 157 {% endfor -%})
158 { 158 {
159 std::unique_ptr<protocol::DictionaryValue> jsonMessage = DictionaryValue::cr eate(); 159 std::unique_ptr<protocol::DictionaryValue> jsonMessage = DictionaryValue::cr eate();
160 jsonMessage->setString("method", "{{domain.domain}}.{{event.name}}"); 160 jsonMessage->setString("method", "{{domain.domain}}.{{event.name}}");
(...skipping 130 matching lines...)
291 {% if "optional" in property %} 291 {% if "optional" in property %}
292 Maybe<{{resolve_type(property).raw_type}}> out_{{property.name}}; 292 Maybe<{{resolve_type(property).raw_type}}> out_{{property.name}};
293 {% else %} 293 {% else %}
294 {{resolve_type(property).type}} out_{{property.name}}; 294 {{resolve_type(property).type}} out_{{property.name}};
295 {% endif %} 295 {% endif %}
296 {% endfor %} 296 {% endfor %}
297 {% endif %} 297 {% endif %}
298 298
299 {% if not is_async_command(domain.domain, command.name) %} 299 {% if not is_async_command(domain.domain, command.name) %}
300 std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr(); 300 std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
301 DispatchResponse response = m_backend->{{command.name}}( 301 DispatchResponse response = m_backend->{{command.name | to_method_case}}(
302 {%- for property in command.parameters -%} 302 {%- for property in command.parameters -%}
303 {%- if not loop.first -%}, {% endif -%} 303 {%- if not loop.first -%}, {% endif -%}
304 {%- if "optional" in property -%} 304 {%- if "optional" in property -%}
305 std::move(in_{{property.name}}) 305 std::move(in_{{property.name}})
306 {%- else -%} 306 {%- else -%}
307 {{resolve_type(property).to_pass_type % ("in_" + property.name)}} 307 {{resolve_type(property).to_pass_type % ("in_" + property.name)}}
308 {%- endif -%} 308 {%- endif -%}
309 {%- endfor %} 309 {%- endfor %}
310 {%- if "returns" in command %} 310 {%- if "returns" in command %}
311 {%- for property in command.returns -%} 311 {%- for property in command.returns -%}
(...skipping 17 matching lines...)
329 } 329 }
330 if (weak->get()) 330 if (weak->get())
331 weak->get()->sendResponse(callId, response, std::move(result)); 331 weak->get()->sendResponse(callId, response, std::move(result));
332 {% else %} 332 {% else %}
333 if (weak->get()) 333 if (weak->get())
334 weak->get()->sendResponse(callId, response); 334 weak->get()->sendResponse(callId, response);
335 {% endif %} 335 {% endif %}
336 return response.status(); 336 return response.status();
337 {% else %} 337 {% else %}
338 std::unique_ptr<{{command.name | to_title_case}}CallbackImpl> callback(new { {command.name | to_title_case}}CallbackImpl(weakPtr(), callId)); 338 std::unique_ptr<{{command.name | to_title_case}}CallbackImpl> callback(new { {command.name | to_title_case}}CallbackImpl(weakPtr(), callId));
339 m_backend->{{command.name}}( 339 m_backend->{{command.name | to_method_case}}(
340 {%- for property in command.parameters -%} 340 {%- for property in command.parameters -%}
341 {%- if not loop.first -%}, {% endif -%} 341 {%- if not loop.first -%}, {% endif -%}
342 {%- if "optional" in property -%} 342 {%- if "optional" in property -%}
343 std::move(in_{{property.name}}) 343 std::move(in_{{property.name}})
344 {%- else -%} 344 {%- else -%}
345 {{resolve_type(property).to_pass_type % ("in_" + property.name)}} 345 {{resolve_type(property).to_pass_type % ("in_" + property.name)}}
346 {%- endif -%} 346 {%- endif -%}
347 {%- endfor -%} 347 {%- endfor -%}
348 {%- if command.parameters -%}, {% endif -%} 348 {%- if command.parameters -%}, {% endif -%}
349 std::move(callback)); 349 std::move(callback));
350 return DispatchResponse::kAsync; 350 return DispatchResponse::kAsync;
351 {% endif %} 351 {% endif %}
352 } 352 }
353 {% endfor %} 353 {% endfor %}
354 354
355 // static 355 // static
356 void Dispatcher::wire(UberDispatcher* dispatcher, Backend* backend) 356 void Dispatcher::wire(UberDispatcher* dispatcher, Backend* backend)
357 { 357 {
358 dispatcher->registerBackend("{{domain.domain}}", std::unique_ptr<protocol::D ispatcherBase>(new DispatcherImpl(dispatcher->channel(), backend))); 358 dispatcher->registerBackend("{{domain.domain}}", std::unique_ptr<protocol::D ispatcherBase>(new DispatcherImpl(dispatcher->channel(), backend)));
359 } 359 }
360 360
361 } // {{domain.domain}} 361 } // {{domain.domain}}
362 {% for namespace in config.protocol.namespace %} 362 {% for namespace in config.protocol.namespace %}
363 } // namespace {{namespace}} 363 } // namespace {{namespace}}
364 {% endfor %} 364 {% endfor %}
OLDNEW
« no previous file with comments | « templates/Imported_h.template ('k') | templates/TypeBuilder_h.template » ('j') | no next file with comments »

Powered by Google App Engine