Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: templates/TypeBuilder_h.template

Issue 2566343002: [inspector_protocol] Support redirects and types whitelisting. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 %}
11 #include {{format_include(config.protocol.export_header)}} 11 #include {{format_include(config.protocol.export_header)}}
12 {% endif %} 12 {% endif %}
13 #include {{format_include(config.protocol.package, "Protocol")}} 13 #include {{format_include(config.protocol.package, "Protocol")}}
14 // For each imported domain we generate a ValueConversions struct instead of a f ull domain definition 14 // For each imported domain we generate a ValueConversions struct instead of a f ull domain definition
15 // and include Domain::API version from there. 15 // and include Domain::API version from there.
16 {% for name in domain.dependencies %} 16 {% for name in domain.dependencies %}
17 {% if protocol.is_imported_dependency(name) %}
17 #include {{format_include(config.protocol.package, name)}} 18 #include {{format_include(config.protocol.package, name)}}
19 {% endif %}
18 {% endfor %} 20 {% endfor %}
19 {% if protocol.is_exported_domain(domain.domain) %} 21 {% if protocol.is_exported_domain(domain.domain) %}
20 #include {{format_include(config.exported.package, domain.domain)}} 22 #include {{format_include(config.exported.package, domain.domain)}}
21 {% endif %} 23 {% endif %}
22 24
23 {% for namespace in config.protocol.namespace %} 25 {% for namespace in config.protocol.namespace %}
24 namespace {{namespace}} { 26 namespace {{namespace}} {
25 {% endfor %} 27 {% endfor %}
26 namespace {{domain.domain}} { 28 namespace {{domain.domain}} {
27 29
28 // ------------- Forward and enum declarations. 30 // ------------- Forward and enum declarations.
29 {% for type in domain.types %} 31 {% for type in domain.types %}
32 {% if not protocol.generate_type(domain.domain, type.id) %}{% continue %}{% endif %}
30 {% if type.type == "object" %} 33 {% if type.type == "object" %}
31 {% if "properties" in type %} 34 {% if "properties" in type %}
32 // {{type.description}} 35 // {{type.description}}
33 class {{type.id}}; 36 class {{type.id}};
34 {% else %} 37 {% else %}
35 // {{type.description}} 38 // {{type.description}}
36 using {{type.id}} = Object; 39 using {{type.id}} = Object;
37 {% endif %} 40 {% endif %}
38 {% elif type.type != "array" %} 41 {% elif type.type != "array" %}
39 // {{type.description}} 42 // {{type.description}}
40 using {{type.id}} = {{protocol.resolve_type(type).type}}; 43 using {{type.id}} = {{protocol.resolve_type(type).type}};
41 {% endif %} 44 {% endif %}
42 {% endfor %} 45 {% endfor %}
43 {% for type in domain.types %} 46 {% for type in domain.types %}
47 {% if not protocol.generate_type(domain.domain, type.id) %}{% continue %}{% endif %}
44 {% if "enum" in type %} 48 {% if "enum" in type %}
45 49
46 namespace {{type.id}}Enum { 50 namespace {{type.id}}Enum {
47 {% for literal in type.enum %} 51 {% for literal in type.enum %}
48 {{config.protocol.export_macro}} extern const char* {{ literal | dash_to_camelca se}}; 52 {{config.protocol.export_macro}} extern const char* {{ literal | dash_to_camelca se}};
49 {% endfor %} 53 {% endfor %}
50 } // namespace {{type.id}}Enum 54 } // namespace {{type.id}}Enum
51 {% endif %} 55 {% endif %}
52 {% endfor %} 56 {% endfor %}
53 {% for command in join_arrays(domain, ["commands", "events"]) %} 57 {% for command in join_arrays(domain, ["commands", "events"]) %}
54 {% for param in join_arrays(command, ["parameters", "returns"]) %} 58 {% for param in join_arrays(command, ["parameters", "returns"]) %}
55 {% if "enum" in param %} 59 {% if "enum" in param %}
56 60
57 namespace {{command.name | to_title_case}} { 61 namespace {{command.name | to_title_case}} {
58 namespace {{param.name | to_title_case}}Enum { 62 namespace {{param.name | to_title_case}}Enum {
59 {% for literal in param.enum %} 63 {% for literal in param.enum %}
60 {{config.protocol.export_macro}} extern const char* {{literal | dash_to_camelcas e}}; 64 {{config.protocol.export_macro}} extern const char* {{literal | dash_to_camelcas e}};
61 {% endfor %} 65 {% endfor %}
62 } // {{param.name | to_title_case}}Enum 66 } // {{param.name | to_title_case}}Enum
63 } // {{command.name | to_title_case }} 67 } // {{command.name | to_title_case }}
64 {% endif %} 68 {% endif %}
65 {% endfor %} 69 {% endfor %}
66 {% endfor %} 70 {% endfor %}
67 71
68 // ------------- Type and builder declarations. 72 // ------------- Type and builder declarations.
69 {% for type in domain.types %} 73 {% for type in domain.types %}
74 {% if not protocol.generate_type(domain.domain, type.id) %}{% continue %}{% endif %}
70 {% if not (type.type == "object") or not ("properties" in type) %}{% continu e %}{% endif %} 75 {% if not (type.type == "object") or not ("properties" in type) %}{% continu e %}{% endif %}
71 76
72 // {{type.description}} 77 // {{type.description}}
73 class {{config.protocol.export_macro}} {{type.id}} : public Serializable{% if pr otocol.is_exported(domain.domain, type.id) %}, public API::{{type.id}}{% endif % }{ 78 class {{config.protocol.export_macro}} {{type.id}} : public Serializable{% if pr otocol.is_exported(domain.domain, type.id) %}, public API::{{type.id}}{% endif % }{
74 PROTOCOL_DISALLOW_COPY({{type.id}}); 79 PROTOCOL_DISALLOW_COPY({{type.id}});
75 public: 80 public:
76 static std::unique_ptr<{{type.id}}> fromValue(protocol::Value* value, ErrorS upport* errors); 81 static std::unique_ptr<{{type.id}}> fromValue(protocol::Value* value, ErrorS upport* errors);
77 82
78 ~{{type.id}}() override { } 83 ~{{type.id}}() override { }
79 {% for property in type.properties %} 84 {% for property in type.properties %}
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 static const char commandPrefix[]; 300 static const char commandPrefix[];
296 static const char version[]; 301 static const char version[];
297 }; 302 };
298 303
299 } // namespace {{domain.domain}} 304 } // namespace {{domain.domain}}
300 {% for namespace in config.protocol.namespace %} 305 {% for namespace in config.protocol.namespace %}
301 } // namespace {{namespace}} 306 } // namespace {{namespace}}
302 {% endfor %} 307 {% endfor %}
303 308
304 #endif // !defined({{"_".join(config.protocol.namespace)}}_{{domain.domain}}_h) 309 #endif // !defined({{"_".join(config.protocol.namespace)}}_{{domain.domain}}_h)
OLDNEW
« lib/DispatcherBase_cpp.template ('K') | « templates/TypeBuilder_cpp.template ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698