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

Side by Side Diff: third_party/WebKit/Source/platform/inspector_protocol/TypeBuilder_cpp.template

Issue 2159633002: [DevTools] Generate public versions of protocol classes to be exposed in v8_inspector/public. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed extra files Created 4 years, 5 months 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 #include "{{output_package}}/{{domain.domain}}.h" 7 #include "{{output_package}}/{{domain.domain}}.h"
8 8
9 #include "platform/inspector_protocol/DispatcherBase.h" 9 #include "platform/inspector_protocol/DispatcherBase.h"
10 #include "platform/inspector_protocol/Parser.h"
10 11
11 namespace blink { 12 namespace blink {
12 namespace protocol { 13 namespace protocol {
13 namespace {{domain.domain}} { 14 namespace {{domain.domain}} {
14 15
15 // ------------- Enum values from types. 16 // ------------- Enum values from types.
16 17
17 const char Metainfo::domainName[] = "{{domain.domain}}"; 18 const char Metainfo::domainName[] = "{{domain.domain}}";
18 {% for type in domain.types %} 19 {% for type in domain.types %}
19 {% if "enum" in type %} 20 {% if "enum" in type %}
20 21
21 namespace {{type.id}}Enum { 22 namespace {{type.id}}Enum {
22 {% for literal in type.enum %} 23 {% for literal in type.enum %}
23 const char* {{ literal | dash_to_camelcase}} = "{{literal}}"; 24 const char* {{ literal | dash_to_camelcase}} = "{{literal}}";
24 {% endfor %} 25 {% endfor %}
25 } // {{type.id}}Enum 26 } // namespace {{type.id}}Enum
27 {% if type.exported %}
28
29 namespace API {
30 namespace {{type.id}}Enum {
31 {% for literal in type.enum %}
32 const char* {{ literal | dash_to_camelcase}} = "{{literal}}";
33 {% endfor %}
34 } // namespace {{type.id}}Enum
35 } // namespace API
36 {% endif %}
26 {% endif %} 37 {% endif %}
27 {% for property in type.properties %} 38 {% for property in type.properties %}
28 {% if "enum" in property %} 39 {% if "enum" in property %}
29 40
30 {% for literal in property.enum %} 41 {% for literal in property.enum %}
31 const char* {{type.id}}::{{property.name | to_title_case}}Enum::{{ literal | das h_to_camelcase}} = "{{literal}}"; 42 const char* {{type.id}}::{{property.name | to_title_case}}Enum::{{ literal | das h_to_camelcase}} = "{{literal}}";
32 {% endfor %} 43 {% endfor %}
33 {% endif %} 44 {% endif %}
34 {% endfor %} 45 {% endfor %}
35 {% if not (type.type == "object") or not ("properties" in type) %}{% continu e %}{% endif %} 46 {% if not (type.type == "object") or not ("properties" in type) %}{% continu e %}{% endif %}
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 {% endif %} 85 {% endif %}
75 {% endfor %} 86 {% endfor %}
76 return result; 87 return result;
77 } 88 }
78 89
79 std::unique_ptr<{{type.id}}> {{type.id}}::clone() const 90 std::unique_ptr<{{type.id}}> {{type.id}}::clone() const
80 { 91 {
81 ErrorSupport errors; 92 ErrorSupport errors;
82 return parse(serialize().get(), &errors); 93 return parse(serialize().get(), &errors);
83 } 94 }
95 {% if type.exported %}
96
97 String16 {{type.id}}::toJSONString() const
98 {
99 return serialize()->toJSONString();
100 }
101
102 // static
103 std::unique_ptr<API::{{type.id}}> API::{{type.id}}::fromJSONString(const String1 6& json)
104 {
105 ErrorSupport errors;
106 std::unique_ptr<Value> value = parseJSON(json);
107 if (!value)
108 return nullptr;
109 return protocol::{{domain.domain}}::{{type.id}}::parse(value.get(), &errors) ;
110 }
111 {% endif %}
84 {% endfor %} 112 {% endfor %}
85 113
86 // ------------- Enum values from params. 114 // ------------- Enum values from params.
87 115
88 {% for command in join_arrays(domain, ["commands", "events"]) %} 116 {% for command in join_arrays(domain, ["commands", "events"]) %}
89 {% for param in join_arrays(command, ["parameters", "returns"]) %} 117 {% for param in join_arrays(command, ["parameters", "returns"]) %}
90 {% if "enum" in param %} 118 {% if "enum" in param %}
91 119
92 namespace {{command.name | to_title_case}} { 120 namespace {{command.name | to_title_case}} {
93 namespace {{param.name | to_title_case}}Enum { 121 namespace {{param.name | to_title_case}}Enum {
94 {% for literal in param.enum %} 122 {% for literal in param.enum %}
95 const char* {{ literal | to_title_case}} = "{{literal}}"; 123 const char* {{ literal | to_title_case}} = "{{literal}}";
96 {% endfor %} 124 {% endfor %}
97 } // {{param.name | to_title_case}}Enum 125 } // namespace {{param.name | to_title_case}}Enum
98 } // {{command.name | to_title_case }} 126 } // namespace {{command.name | to_title_case }}
127 {% if param.exported %}
128
129 namespace API {
130 namespace {{command.name | to_title_case}} {
131 namespace {{param.name | to_title_case}}Enum {
132 {% for literal in param.enum %}
133 const char* {{ literal | to_title_case}} = "{{literal}}";
134 {% endfor %}
135 } // namespace {{param.name | to_title_case}}Enum
136 } // namespace {{command.name | to_title_case }}
137 } // namespace API
138 {% endif %}
99 {% endif %} 139 {% endif %}
100 {% endfor %} 140 {% endfor %}
101 {% endfor %} 141 {% endfor %}
102 142
103 // ------------- Frontend notifications. 143 // ------------- Frontend notifications.
104 {% for event in domain.events %} 144 {% for event in domain.events %}
105 {% if "handlers" in event and not ("renderer" in event["handlers"]) %}{% con tinue %}{% endif %} 145 {% if "handlers" in event and not ("renderer" in event["handlers"]) %}{% con tinue %}{% endif %}
106 146
107 void Frontend::{{event.name}}( 147 void Frontend::{{event.name}}(
108 {%- for parameter in event.parameters %} 148 {%- for parameter in event.parameters %}
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 331
292 // static 332 // static
293 void Dispatcher::wire(UberDispatcher* dispatcher, Backend* backend) 333 void Dispatcher::wire(UberDispatcher* dispatcher, Backend* backend)
294 { 334 {
295 dispatcher->registerBackend("{{domain.domain}}", wrapUnique(new DispatcherIm pl(dispatcher->channel(), backend))); 335 dispatcher->registerBackend("{{domain.domain}}", wrapUnique(new DispatcherIm pl(dispatcher->channel(), backend)));
296 } 336 }
297 337
298 } // {{domain.domain}} 338 } // {{domain.domain}}
299 } // namespace protocol 339 } // namespace protocol
300 } // namespace blink 340 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698