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