| 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 {{"_".join(config.protocol.namespace)}}_{{domain.domain}}_h | 7 #ifndef {{"_".join(config.protocol.namespace)}}_{{domain.domain}}_h |
| 8 #define {{"_".join(config.protocol.namespace)}}_{{domain.domain}}_h | 8 #define {{"_".join(config.protocol.namespace)}}_{{domain.domain}}_h |
| 9 | 9 |
| 10 {% if config.protocol.export_header %} | 10 {% if config.protocol.export_header %} |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 {% endif %} | 64 {% endif %} |
| 65 {% endfor %} | 65 {% endfor %} |
| 66 {% endfor %} | 66 {% endfor %} |
| 67 | 67 |
| 68 // ------------- Type and builder declarations. | 68 // ------------- Type and builder declarations. |
| 69 {% for type in domain.types %} | 69 {% for type in domain.types %} |
| 70 {% if not (type.type == "object") or not ("properties" in type) %}{% continu
e %}{% endif %} | 70 {% if not (type.type == "object") or not ("properties" in type) %}{% continu
e %}{% endif %} |
| 71 {% set type_def = type_definition(domain.domain + "." + type.id)%} | 71 {% set type_def = type_definition(domain.domain + "." + type.id)%} |
| 72 | 72 |
| 73 // {{type.description}} | 73 // {{type.description}} |
| 74 class {{config.protocol.export_macro}} {{type.id}} {% if type.exported %}: publi
c API::{{type.id}} {% endif %}{ | 74 class {{config.protocol.export_macro}} {{type.id}} : public Serializable{% if ty
pe.exported %}, public API::{{type.id}}{% endif %}{ |
| 75 PROTOCOL_DISALLOW_COPY({{type.id}}); | 75 PROTOCOL_DISALLOW_COPY({{type.id}}); |
| 76 public: | 76 public: |
| 77 static std::unique_ptr<{{type.id}}> parse(protocol::Value* value, ErrorSuppo
rt* errors); | 77 static std::unique_ptr<{{type.id}}> fromValue(protocol::Value* value, ErrorS
upport* errors); |
| 78 | 78 |
| 79 ~{{type.id}}() { } | 79 ~{{type.id}}() override { } |
| 80 {% for property in type.properties %} | 80 {% for property in type.properties %} |
| 81 {% if "enum" in property %} | 81 {% if "enum" in property %} |
| 82 | 82 |
| 83 struct {{config.protocol.export_macro}} {{property.name | to_title_case}}Enu
m { | 83 struct {{config.protocol.export_macro}} {{property.name | to_title_case}}Enu
m { |
| 84 {% for literal in property.enum %} | 84 {% for literal in property.enum %} |
| 85 static const char* {{literal | dash_to_camelcase}}; | 85 static const char* {{literal | dash_to_camelcase}}; |
| 86 {% endfor %} | 86 {% endfor %} |
| 87 }; // {{property.name | to_title_case}}Enum | 87 }; // {{property.name | to_title_case}}Enum |
| 88 {% endif %} | 88 {% endif %} |
| 89 | 89 |
| 90 {% if property.optional %} | 90 {% if property.optional %} |
| 91 bool {{"has" | to_method_case}}{{property.name | to_title_case}}() { return
m_{{property.name}}.isJust(); } | 91 bool {{"has" | to_method_case}}{{property.name | to_title_case}}() { return
m_{{property.name}}.isJust(); } |
| 92 {{resolve_type(property).raw_return_type}} {{"get" | to_method_case}}{{prope
rty.name | to_title_case}}({{resolve_type(property).raw_pass_type}} defaultValue
) { return m_{{property.name}}.isJust() ? m_{{property.name}}.fromJust() : defau
ltValue; } | 92 {{resolve_type(property).raw_return_type}} {{"get" | to_method_case}}{{prope
rty.name | to_title_case}}({{resolve_type(property).raw_pass_type}} defaultValue
) { return m_{{property.name}}.isJust() ? m_{{property.name}}.fromJust() : defau
ltValue; } |
| 93 {% else %} | 93 {% else %} |
| 94 {{resolve_type(property).raw_return_type}} {{"get" | to_method_case}}{{prope
rty.name | to_title_case}}() { return {{resolve_type(property).to_raw_type % ("m
_" + property.name)}}; } | 94 {{resolve_type(property).raw_return_type}} {{"get" | to_method_case}}{{prope
rty.name | to_title_case}}() { return {{resolve_type(property).to_raw_type % ("m
_" + property.name)}}; } |
| 95 {% endif %} | 95 {% endif %} |
| 96 void {{"set" | to_method_case}}{{property.name | to_title_case}}({{resolve_t
ype(property).pass_type}} value) { m_{{property.name}} = {{resolve_type(property
).to_rvalue % "value"}}; } | 96 void {{"set" | to_method_case}}{{property.name | to_title_case}}({{resolve_t
ype(property).pass_type}} value) { m_{{property.name}} = {{resolve_type(property
).to_rvalue % "value"}}; } |
| 97 {% endfor %} | 97 {% endfor %} |
| 98 | 98 |
| 99 std::unique_ptr<protocol::DictionaryValue> serialize() const; | 99 std::unique_ptr<protocol::DictionaryValue> toValue() const; |
| 100 String serialize() override { return toValue()->serialize(); } |
| 100 std::unique_ptr<{{type.id}}> clone() const; | 101 std::unique_ptr<{{type.id}}> clone() const; |
| 101 {% if type.exported %} | 102 {% if type.exported %} |
| 102 {{config.exported.string_out}} toJSONString() const override; | 103 {{config.exported.string_out}} toJSONString() const override; |
| 103 {% endif %} | 104 {% endif %} |
| 104 | 105 |
| 105 template<int STATE> | 106 template<int STATE> |
| 106 class {{type.id}}Builder { | 107 class {{type.id}}Builder { |
| 107 public: | 108 public: |
| 108 enum { | 109 enum { |
| 109 NoFieldsSet = 0, | 110 NoFieldsSet = 0, |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 static const char commandPrefix[]; | 291 static const char commandPrefix[]; |
| 291 static const char version[]; | 292 static const char version[]; |
| 292 }; | 293 }; |
| 293 | 294 |
| 294 } // namespace {{domain.domain}} | 295 } // namespace {{domain.domain}} |
| 295 {% for namespace in config.protocol.namespace %} | 296 {% for namespace in config.protocol.namespace %} |
| 296 } // namespace {{namespace}} | 297 } // namespace {{namespace}} |
| 297 {% endfor %} | 298 {% endfor %} |
| 298 | 299 |
| 299 #endif // !defined({{"_".join(config.protocol.namespace)}}_{{domain.domain}}_h) | 300 #endif // !defined({{"_".join(config.protocol.namespace)}}_{{domain.domain}}_h) |
| OLD | NEW |