| OLD | NEW |
| 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 #ifndef protocol_{{domain.domain}}_h | 7 #ifndef {{"_".join(config.protocol.namespace)}}_{{domain.domain}}_h |
| 8 #define protocol_{{domain.domain}}_h | 8 #define {{"_".join(config.protocol.namespace)}}_{{domain.domain}}_h |
| 9 | 9 |
| 10 #include "{{config.class_export.header}}" | 10 #include "{{config.class_export.header}}" |
| 11 #include "{{config.lib_package}}/InspectorProtocol.h" | 11 #include "{{config.protocol.package}}/Protocol.h" |
| 12 // For each imported domain we generate a ValueConversions struct instead of a f
ull domain definition | 12 // For each imported domain we generate a ValueConversions struct instead of a f
ull domain definition |
| 13 // and include Domain::API version from there. | 13 // and include Domain::API version from there. |
| 14 {% for name in domain.dependencies %} | 14 {% for name in domain.dependencies %} |
| 15 #include "{{config.protocol.package}}/{{name}}.h" | 15 #include "{{config.protocol.package}}/{{name}}.h" |
| 16 {% endfor %} | 16 {% endfor %} |
| 17 {% if domain["has_exports"] %} | 17 {% if domain["has_exports"] %} |
| 18 #include "{{config.exported.package}}/{{domain.domain}}.h" | 18 #include "{{config.exported.package}}/{{domain.domain}}.h" |
| 19 {% endif %} | 19 {% endif %} |
| 20 | 20 |
| 21 namespace blink { | 21 {% for namespace in config.protocol.namespace %} |
| 22 namespace protocol { | 22 namespace {{namespace}} { |
| 23 {% endfor %} |
| 23 namespace {{domain.domain}} { | 24 namespace {{domain.domain}} { |
| 24 | 25 |
| 25 // ------------- Forward and enum declarations. | 26 // ------------- Forward and enum declarations. |
| 26 {% for type in domain.types %} | 27 {% for type in domain.types %} |
| 27 {% if type.type == "object" %} | 28 {% if type.type == "object" %} |
| 28 {% if "properties" in type %} | 29 {% if "properties" in type %} |
| 29 // {{type.description}} | 30 // {{type.description}} |
| 30 class {{type.id}}; | 31 class {{type.id}}; |
| 31 {% else %} | 32 {% else %} |
| 32 // {{type.description}} | 33 // {{type.description}} |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 {{resolve_type(property).raw_return_type}} get{{property.name | to_title_cas
e}}({{resolve_type(property).raw_pass_type}} defaultValue) { return m_{{property
.name}}.isJust() ? m_{{property.name}}.fromJust() : defaultValue; } | 90 {{resolve_type(property).raw_return_type}} get{{property.name | to_title_cas
e}}({{resolve_type(property).raw_pass_type}} defaultValue) { return m_{{property
.name}}.isJust() ? m_{{property.name}}.fromJust() : defaultValue; } |
| 90 {% else %} | 91 {% else %} |
| 91 {{resolve_type(property).raw_return_type}} get{{property.name | to_title_cas
e}}() { return {{resolve_type(property).to_raw_type % ("m_" + property.name)}};
} | 92 {{resolve_type(property).raw_return_type}} get{{property.name | to_title_cas
e}}() { return {{resolve_type(property).to_raw_type % ("m_" + property.name)}};
} |
| 92 {% endif %} | 93 {% endif %} |
| 93 void set{{property.name | to_title_case}}({{resolve_type(property).pass_type
}} value) { m_{{property.name}} = {{resolve_type(property).to_rvalue % "value"}}
; } | 94 void set{{property.name | to_title_case}}({{resolve_type(property).pass_type
}} value) { m_{{property.name}} = {{resolve_type(property).to_rvalue % "value"}}
; } |
| 94 {% endfor %} | 95 {% endfor %} |
| 95 | 96 |
| 96 std::unique_ptr<protocol::DictionaryValue> serialize() const; | 97 std::unique_ptr<protocol::DictionaryValue> serialize() const; |
| 97 std::unique_ptr<{{type.id}}> clone() const; | 98 std::unique_ptr<{{type.id}}> clone() const; |
| 98 {% if type.exported %} | 99 {% if type.exported %} |
| 99 String16 toJSONString() const override; | 100 {{config.exported.string_out}} toJSONString() const override; |
| 100 {% endif %} | 101 {% endif %} |
| 101 | 102 |
| 102 template<int STATE> | 103 template<int STATE> |
| 103 class {{type.id}}Builder { | 104 class {{type.id}}Builder { |
| 104 public: | 105 public: |
| 105 enum { | 106 enum { |
| 106 NoFieldsSet = 0, | 107 NoFieldsSet = 0, |
| 107 {% set count = 0 %} | 108 {% set count = 0 %} |
| 108 {% for property in type.properties %} | 109 {% for property in type.properties %} |
| 109 {% if not(property.optional) %} | 110 {% if not(property.optional) %} |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 {%- for parameter in event.parameters -%} | 247 {%- for parameter in event.parameters -%} |
| 247 {%- if "optional" in parameter -%} | 248 {%- if "optional" in parameter -%} |
| 248 const Maybe<{{resolve_type(parameter).raw_type}}>& {{parameter.name}} =
Maybe<{{resolve_type(parameter).raw_type}}>() | 249 const Maybe<{{resolve_type(parameter).raw_type}}>& {{parameter.name}} =
Maybe<{{resolve_type(parameter).raw_type}}>() |
| 249 {%- else -%} | 250 {%- else -%} |
| 250 {{resolve_type(parameter).pass_type}} {{parameter.name}} | 251 {{resolve_type(parameter).pass_type}} {{parameter.name}} |
| 251 {%- endif -%}{%- if not loop.last -%}, {% endif -%} | 252 {%- endif -%}{%- if not loop.last -%}, {% endif -%} |
| 252 {%- endfor -%} | 253 {%- endfor -%} |
| 253 ); | 254 ); |
| 254 {% endfor %} | 255 {% endfor %} |
| 255 | 256 |
| 256 void flush() { m_frontendChannel->flushProtocolNotifications(); } | 257 void flush(); |
| 257 private: | 258 private: |
| 258 FrontendChannel* m_frontendChannel; | 259 FrontendChannel* m_frontendChannel; |
| 259 }; | 260 }; |
| 260 | 261 |
| 261 // ------------- Dispatcher. | 262 // ------------- Dispatcher. |
| 262 | 263 |
| 263 class {{config.class_export.macro}} Dispatcher { | 264 class {{config.class_export.macro}} Dispatcher { |
| 264 public: | 265 public: |
| 265 static void wire(UberDispatcher*, blink::protocol::{{domain.domain}}::Backen
d*); | 266 static void wire(UberDispatcher*, Backend*); |
| 266 | 267 |
| 267 private: | 268 private: |
| 268 Dispatcher() { } | 269 Dispatcher() { } |
| 269 }; | 270 }; |
| 270 | 271 |
| 271 // ------------- Metainfo. | 272 // ------------- Metainfo. |
| 272 | 273 |
| 273 class {{config.class_export.macro}} Metainfo { | 274 class {{config.class_export.macro}} Metainfo { |
| 274 public: | 275 public: |
| 275 using BackendClass = Backend; | 276 using BackendClass = Backend; |
| 276 using FrontendClass = Frontend; | 277 using FrontendClass = Frontend; |
| 277 using DispatcherClass = Dispatcher; | 278 using DispatcherClass = Dispatcher; |
| 278 static const char domainName[]; | 279 static const char domainName[]; |
| 279 static const char commandPrefix[]; | 280 static const char commandPrefix[]; |
| 280 static const char version[]; | 281 static const char version[]; |
| 281 }; | 282 }; |
| 282 | 283 |
| 283 } // namespace {{domain.domain}} | 284 } // namespace {{domain.domain}} |
| 284 } // namespace protocol | 285 {% for namespace in config.protocol.namespace %} |
| 285 } // namespace blink | 286 } // namespace {{namespace}} |
| 287 {% endfor %} |
| 286 | 288 |
| 287 #endif // !defined(protocol_{{domain.domain}}_h) | 289 #endif // !defined({{"_".join(config.protocol.namespace)}}_{{domain.domain}}_h) |
| OLD | NEW |