| 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}}_api_h | 7 #ifndef {{"_".join(config.protocol.namespace)}}_{{domain.domain}}_api_h |
| 8 #define {{"_".join(config.protocol.namespace)}}_{{domain.domain}}_api_h | 8 #define {{"_".join(config.protocol.namespace)}}_{{domain.domain}}_api_h |
| 9 | 9 |
| 10 #include "{{config.class_export.header}}" | 10 {% if config.exported.export_header %} |
| 11 #include "{{config.exported.string_header}}" | 11 #include {{format_include(config.exported.export_header)}} |
| 12 {% endif %} |
| 13 #include {{format_include(config.exported.string_header)}} |
| 12 | 14 |
| 13 {% for namespace in config.protocol.namespace %} | 15 {% for namespace in config.protocol.namespace %} |
| 14 namespace {{namespace}} { | 16 namespace {{namespace}} { |
| 15 {% endfor %} | 17 {% endfor %} |
| 16 namespace {{domain.domain}} { | 18 namespace {{domain.domain}} { |
| 17 namespace API { | 19 namespace API { |
| 18 | 20 |
| 19 // ------------- Enums. | 21 // ------------- Enums. |
| 20 {% for type in domain.types %} | 22 {% for type in domain.types %} |
| 21 {% if ("enum" in type) and type.exported %} | 23 {% if ("enum" in type) and type.exported %} |
| 22 | 24 |
| 23 namespace {{type.id}}Enum { | 25 namespace {{type.id}}Enum { |
| 24 {% for literal in type.enum %} | 26 {% for literal in type.enum %} |
| 25 {{config.class_export.macro}} extern const char* {{ literal | dash_to_camelcase}
}; | 27 {{config.exported.export_macro}} extern const char* {{ literal | dash_to_camelca
se}}; |
| 26 {% endfor %} | 28 {% endfor %} |
| 27 } // {{type.id}}Enum | 29 } // {{type.id}}Enum |
| 28 {% endif %} | 30 {% endif %} |
| 29 {% endfor %} | 31 {% endfor %} |
| 30 {% for command in join_arrays(domain, ["commands", "events"]) %} | 32 {% for command in join_arrays(domain, ["commands", "events"]) %} |
| 31 {% for param in join_arrays(command, ["parameters", "returns"]) %} | 33 {% for param in join_arrays(command, ["parameters", "returns"]) %} |
| 32 {% if ("enum" in param) and (param.exported) %} | 34 {% if ("enum" in param) and (param.exported) %} |
| 33 | 35 |
| 34 namespace {{command.name | to_title_case}} { | 36 namespace {{command.name | to_title_case}} { |
| 35 namespace {{param.name | to_title_case}}Enum { | 37 namespace {{param.name | to_title_case}}Enum { |
| 36 {% for literal in param.enum %} | 38 {% for literal in param.enum %} |
| 37 {{config.class_export.macro}} extern const char* {{ literal | dash_to_camelcase}
}; | 39 {{config.exported.export_macro}} extern const char* {{ literal | dash_to_camelca
se}}; |
| 38 {% endfor %} | 40 {% endfor %} |
| 39 } // {{param.name | to_title_case}}Enum | 41 } // {{param.name | to_title_case}}Enum |
| 40 } // {{command.name | to_title_case }} | 42 } // {{command.name | to_title_case }} |
| 41 {% endif %} | 43 {% endif %} |
| 42 {% endfor %} | 44 {% endfor %} |
| 43 {% endfor %} | 45 {% endfor %} |
| 44 | 46 |
| 45 // ------------- Types. | 47 // ------------- Types. |
| 46 {% for type in domain.types %} | 48 {% for type in domain.types %} |
| 47 {% if not (type.type == "object") or not ("properties" in type) or not (type
.exported) %}{% continue %}{% endif %} | 49 {% if not (type.type == "object") or not ("properties" in type) or not (type
.exported) %}{% continue %}{% endif %} |
| 48 | 50 |
| 49 class {{config.class_export.macro}} {{type.id}} { | 51 class {{config.exported.export_macro}} {{type.id}} { |
| 50 public: | 52 public: |
| 51 virtual {{config.exported.string_out}} toJSONString() const = 0; | 53 virtual {{config.exported.string_out}} toJSONString() const = 0; |
| 52 virtual ~{{type.id}}() { } | 54 virtual ~{{type.id}}() { } |
| 53 static std::unique_ptr<protocol::{{domain.domain}}::API::{{type.id}}> fromJS
ONString(const {{config.exported.string_in}}& json); | 55 static std::unique_ptr<protocol::{{domain.domain}}::API::{{type.id}}> fromJS
ONString(const {{config.exported.string_in}}& json); |
| 54 }; | 56 }; |
| 55 {% endfor %} | 57 {% endfor %} |
| 56 | 58 |
| 57 } // namespace API | 59 } // namespace API |
| 58 } // namespace {{domain.domain}} | 60 } // namespace {{domain.domain}} |
| 59 {% for namespace in config.protocol.namespace %} | 61 {% for namespace in config.protocol.namespace %} |
| 60 } // namespace {{namespace}} | 62 } // namespace {{namespace}} |
| 61 {% endfor %} | 63 {% endfor %} |
| 62 | 64 |
| 63 #endif // !defined({{"_".join(config.protocol.namespace)}}_{{domain.domain}}_api
_h) | 65 #endif // !defined({{"_".join(config.protocol.namespace)}}_{{domain.domain}}_api
_h) |
| OLD | NEW |