| 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 protocol_{{domain.domain}}_h |
| 8 #define protocol_{{domain.domain}}_h | 8 #define protocol_{{domain.domain}}_h |
| 9 | 9 |
| 10 {% if export_macro == "PLATFORM_EXPORT" %} | 10 {% if export_macro == "PLATFORM_EXPORT" %} |
| 11 #include "platform/inspector_protocol/Platform.h" | 11 #include "platform/inspector_protocol/Platform.h" |
| 12 {% else %} | 12 {% else %} |
| 13 #include "core/CoreExport.h" | 13 #include "core/CoreExport.h" |
| 14 {% endif %} | 14 {% endif %} |
| 15 #include "platform/inspector_protocol/Array.h" | 15 #include "platform/inspector_protocol/Array.h" |
| 16 #include "platform/inspector_protocol/BackendCallback.h" | 16 #include "platform/inspector_protocol/BackendCallback.h" |
| 17 #include "platform/inspector_protocol/DispatcherBase.h" | 17 #include "platform/inspector_protocol/DispatcherBase.h" |
| 18 #include "platform/inspector_protocol/ErrorSupport.h" | 18 #include "platform/inspector_protocol/ErrorSupport.h" |
| 19 #include "platform/inspector_protocol/FrontendChannel.h" | 19 #include "platform/inspector_protocol/FrontendChannel.h" |
| 20 #include "platform/inspector_protocol/Maybe.h" | 20 #include "platform/inspector_protocol/Maybe.h" |
| 21 #include "platform/inspector_protocol/Object.h" | 21 #include "platform/inspector_protocol/Object.h" |
| 22 #include "platform/inspector_protocol/Platform.h" | 22 #include "platform/inspector_protocol/Platform.h" |
| 23 #include "platform/inspector_protocol/String16.h" | 23 #include "platform/inspector_protocol/String16.h" |
| 24 #include "platform/inspector_protocol/Values.h" | 24 #include "platform/inspector_protocol/Values.h" |
| 25 #include "platform/inspector_protocol/ValueConversions.h" | 25 #include "platform/inspector_protocol/ValueConversions.h" |
| 26 // For each imported domain we generate a ValueConversions struct instead of a f
ull domain definition |
| 27 // and include Domain::API version from there. |
| 26 {% for name in domain.dependencies %} | 28 {% for name in domain.dependencies %} |
| 27 #include "{{output_package}}/{{name}}.h" | 29 #include "{{output_package}}/{{name}}.h" |
| 28 {% endfor %} | 30 {% endfor %} |
| 31 {% if domain["has_exports"] %} |
| 32 #include "{{exported_package}}/{{domain.domain}}.h" |
| 33 {% endif %} |
| 29 | 34 |
| 30 namespace blink { | 35 namespace blink { |
| 31 namespace protocol { | 36 namespace protocol { |
| 32 namespace {{domain.domain}} { | 37 namespace {{domain.domain}} { |
| 33 | 38 |
| 34 // ------------- Forward and enum declarations. | 39 // ------------- Forward and enum declarations. |
| 35 {% for type in domain.types %} | 40 {% for type in domain.types %} |
| 36 {% if type.type == "object" %} | 41 {% if type.type == "object" %} |
| 37 {% if "properties" in type %} | 42 {% if "properties" in type %} |
| 38 // {{type.description}} | 43 // {{type.description}} |
| 39 class {{type.id}}; | 44 class {{type.id}}; |
| 40 {% else %} | 45 {% else %} |
| 41 // {{type.description}} | 46 // {{type.description}} |
| 42 using {{type.id}} = Object; | 47 using {{type.id}} = Object; |
| 43 {% endif %} | 48 {% endif %} |
| 44 {% elif type.type != "array" %} | 49 {% elif type.type != "array" %} |
| 45 // {{type.description}} | 50 // {{type.description}} |
| 46 using {{type.id}} = {{resolve_type(type).type}}; | 51 using {{type.id}} = {{resolve_type(type).type}}; |
| 47 {% endif %} | 52 {% endif %} |
| 48 {% endfor %} | 53 {% endfor %} |
| 49 {% for type in domain.types %} | 54 {% for type in domain.types %} |
| 50 {% if "enum" in type %} | 55 {% if "enum" in type %} |
| 51 | 56 |
| 52 namespace {{type.id}}Enum { | 57 namespace {{type.id}}Enum { |
| 53 {% for literal in type.enum %} | 58 {% for literal in type.enum %} |
| 54 {{export_macro}} extern const char* {{ literal | dash_to_camelcase}}; | 59 {{export_macro}} extern const char* {{ literal | dash_to_camelcase}}; |
| 55 {% endfor %} | 60 {% endfor %} |
| 56 } // {{type.id}}Enum | 61 } // namespace {{type.id}}Enum |
| 57 {% endif %} | 62 {% endif %} |
| 58 {% endfor %} | 63 {% endfor %} |
| 59 {% for command in join_arrays(domain, ["commands", "events"]) %} | 64 {% for command in join_arrays(domain, ["commands", "events"]) %} |
| 60 {% for param in join_arrays(command, ["parameters", "returns"]) %} | 65 {% for param in join_arrays(command, ["parameters", "returns"]) %} |
| 61 {% if "enum" in param %} | 66 {% if "enum" in param %} |
| 62 | 67 |
| 63 namespace {{command.name | to_title_case}} { | 68 namespace {{command.name | to_title_case}} { |
| 64 namespace {{param.name | to_title_case}}Enum { | 69 namespace {{param.name | to_title_case}}Enum { |
| 65 {% for literal in param.enum %} | 70 {% for literal in param.enum %} |
| 66 {{export_macro}} extern const char* {{ literal | dash_to_camelcase}}; | 71 {{export_macro}} extern const char* {{ literal | dash_to_camelcase}}; |
| 67 {% endfor %} | 72 {% endfor %} |
| 68 } // {{param.name | to_title_case}}Enum | 73 } // {{param.name | to_title_case}}Enum |
| 69 } // {{command.name | to_title_case }} | 74 } // {{command.name | to_title_case }} |
| 70 {% endif %} | 75 {% endif %} |
| 71 {% endfor %} | 76 {% endfor %} |
| 72 {% endfor %} | 77 {% endfor %} |
| 73 | 78 |
| 74 // ------------- Type and builder declarations. | 79 // ------------- Type and builder declarations. |
| 75 {% for type in domain.types %} | 80 {% for type in domain.types %} |
| 76 {% if not (type.type == "object") or not ("properties" in type) %}{% continu
e %}{% endif %} | 81 {% if not (type.type == "object") or not ("properties" in type) %}{% continu
e %}{% endif %} |
| 77 {% set type_def = type_definition(domain.domain + "." + type.id)%} | 82 {% set type_def = type_definition(domain.domain + "." + type.id)%} |
| 78 | 83 |
| 79 // {{type.description}} | 84 // {{type.description}} |
| 80 class {{export_macro}} {{type.id}} { | 85 class {{export_macro}} {{type.id}} {% if type.exported %}: public API::{{type.id
}} {% endif %}{ |
| 86 PROTOCOL_DISALLOW_COPY({{type.id}}); |
| 81 public: | 87 public: |
| 82 static std::unique_ptr<{{type.id}}> parse(protocol::Value* value, ErrorSuppo
rt* errors); | 88 static std::unique_ptr<{{type.id}}> parse(protocol::Value* value, ErrorSuppo
rt* errors); |
| 83 | 89 |
| 84 ~{{type.id}}() { } | 90 ~{{type.id}}() { } |
| 85 {% for property in type.properties %} | 91 {% for property in type.properties %} |
| 86 {% if "enum" in property %} | 92 {% if "enum" in property %} |
| 87 | 93 |
| 88 struct {{export_macro}} {{property.name | to_title_case}}Enum { | 94 struct {{export_macro}} {{property.name | to_title_case}}Enum { |
| 89 {% for literal in property.enum %} | 95 {% for literal in property.enum %} |
| 90 static const char* {{ literal | dash_to_camelcase}}; | 96 static const char* {{ literal | dash_to_camelcase}}; |
| 91 {% endfor %} | 97 {% endfor %} |
| 92 }; // {{property.name | to_title_case}}Enum | 98 }; // {{property.name | to_title_case}}Enum |
| 93 {% endif %} | 99 {% endif %} |
| 94 | 100 |
| 95 {% if property.optional %} | 101 {% if property.optional %} |
| 96 bool has{{property.name | to_title_case}}() { return m_{{property.name}}.isJ
ust(); } | 102 bool has{{property.name | to_title_case}}() { return m_{{property.name}}.isJ
ust(); } |
| 97 {{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; } | 103 {{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; } |
| 98 {% else %} | 104 {% else %} |
| 99 {{resolve_type(property).raw_return_type}} get{{property.name | to_title_cas
e}}() { return {{resolve_type(property).to_raw_type % ("m_" + property.name)}};
} | 105 {{resolve_type(property).raw_return_type}} get{{property.name | to_title_cas
e}}() { return {{resolve_type(property).to_raw_type % ("m_" + property.name)}};
} |
| 100 {% endif %} | 106 {% endif %} |
| 101 void set{{property.name | to_title_case}}({{resolve_type(property).pass_type
}} value) { m_{{property.name}} = {{resolve_type(property).to_rvalue % "value"}}
; } | 107 void set{{property.name | to_title_case}}({{resolve_type(property).pass_type
}} value) { m_{{property.name}} = {{resolve_type(property).to_rvalue % "value"}}
; } |
| 102 {% endfor %} | 108 {% endfor %} |
| 103 | 109 |
| 104 std::unique_ptr<protocol::DictionaryValue> serialize() const; | 110 std::unique_ptr<protocol::DictionaryValue> serialize() const; |
| 105 std::unique_ptr<{{type.id}}> clone() const; | 111 std::unique_ptr<{{type.id}}> clone() const; |
| 112 {% if type.exported %} |
| 113 String16 toJSONString() const override; |
| 114 {% endif %} |
| 106 | 115 |
| 107 template<int STATE> | 116 template<int STATE> |
| 108 class {{type.id}}Builder { | 117 class {{type.id}}Builder { |
| 109 public: | 118 public: |
| 110 enum { | 119 enum { |
| 111 NoFieldsSet = 0, | 120 NoFieldsSet = 0, |
| 112 {% set count = 0 %} | 121 {% set count = 0 %} |
| 113 {% for property in type.properties %} | 122 {% for property in type.properties %} |
| 114 {% if not(property.optional) %} | 123 {% if not(property.optional) %} |
| 115 {% set count = count + 1 %} | 124 {% set count = count + 1 %} |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 using FrontendClass = Frontend; | 285 using FrontendClass = Frontend; |
| 277 using DispatcherClass = Dispatcher; | 286 using DispatcherClass = Dispatcher; |
| 278 static const char domainName[]; | 287 static const char domainName[]; |
| 279 }; | 288 }; |
| 280 | 289 |
| 281 } // namespace {{domain.domain}} | 290 } // namespace {{domain.domain}} |
| 282 } // namespace protocol | 291 } // namespace protocol |
| 283 } // namespace blink | 292 } // namespace blink |
| 284 | 293 |
| 285 #endif // !defined(protocol_{{domain.domain}}_h) | 294 #endif // !defined(protocol_{{domain.domain}}_h) |
| OLD | NEW |