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

Side by Side Diff: third_party/WebKit/Source/platform/inspector_protocol/TypeBuilder_h.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: works 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 #ifndef protocol_{{domain.domain}}_h 7 #ifndef protocol_{{domain.domain}}_h
8 #define protocol_{{domain.domain}}_h 8 #define protocol_{{domain.domain}}_h
9 9
10 {% if export_macro == "PLATFORM_EXPORT" %} 10 {% if export_macro == "PLATFORM_EXPORT" %}
11 #include "platform/inspector_protocol/Platform.h" 11 #include "platform/inspector_protocol/Platform.h"
12 {% else %} 12 {% else %}
13 #include "core/CoreExport.h" 13 #include "core/CoreExport.h"
14 {% endif %} 14 {% endif %}
15 #include "platform/inspector_protocol/Array.h" 15 #include "platform/inspector_protocol/Array.h"
16 #include "platform/inspector_protocol/BackendCallback.h" 16 #include "platform/inspector_protocol/BackendCallback.h"
17 #include "platform/inspector_protocol/DispatcherBase.h" 17 #include "platform/inspector_protocol/DispatcherBase.h"
18 #include "platform/inspector_protocol/ErrorSupport.h" 18 #include "platform/inspector_protocol/ErrorSupport.h"
19 #include "platform/inspector_protocol/FrontendChannel.h" 19 #include "platform/inspector_protocol/FrontendChannel.h"
20 #include "platform/inspector_protocol/Maybe.h" 20 #include "platform/inspector_protocol/Maybe.h"
21 #include "platform/inspector_protocol/Object.h" 21 #include "platform/inspector_protocol/Object.h"
22 #include "platform/inspector_protocol/Platform.h" 22 #include "platform/inspector_protocol/Platform.h"
23 #include "platform/inspector_protocol/String16.h" 23 #include "platform/inspector_protocol/String16.h"
24 #include "platform/inspector_protocol/Values.h" 24 #include "platform/inspector_protocol/Values.h"
25 #include "platform/inspector_protocol/ValueConversions.h" 25 #include "platform/inspector_protocol/ValueConversions.h"
26 {% for name in domain.dependencies %} 26 {% for name in domain.dependencies %}
27 #include "{{output_package}}/{{name}}.h" 27 #include "{{output_package}}/{{name}}.h"
pfeldman 2016/07/22 18:02:40 It should be clear that we explicitly import publi
dgozman 2016/07/22 21:21:19 Done.
28 {% endfor %} 28 {% endfor %}
29 {% if domain["has_exports"] %}
30 #include "{{exported_package}}/{{domain.domain}}.h"
31 {% endif %}
29 32
30 namespace blink { 33 namespace blink {
31 namespace protocol { 34 namespace protocol {
32 namespace {{domain.domain}} { 35 namespace {{domain.domain}} {
33 36
34 // ------------- Forward and enum declarations. 37 // ------------- Forward and enum declarations.
35 {% for type in domain.types %} 38 {% for type in domain.types %}
36 {% if type.type == "object" %} 39 {% if type.type == "object" %}
37 {% if "properties" in type %} 40 {% if "properties" in type %}
38 // {{type.description}} 41 // {{type.description}}
39 class {{type.id}}; 42 class {{type.id}};
40 {% else %} 43 {% else %}
41 // {{type.description}} 44 // {{type.description}}
42 using {{type.id}} = Object; 45 using {{type.id}} = Object;
43 {% endif %} 46 {% endif %}
44 {% elif type.type != "array" %} 47 {% elif type.type != "array" %}
45 // {{type.description}} 48 // {{type.description}}
46 using {{type.id}} = {{resolve_type(type).type}}; 49 using {{type.id}} = {{resolve_type(type).type}};
47 {% endif %} 50 {% endif %}
48 {% endfor %} 51 {% endfor %}
49 {% for type in domain.types %} 52 {% for type in domain.types %}
50 {% if "enum" in type %} 53 {% if "enum" in type %}
51 54
52 namespace {{type.id}}Enum { 55 namespace {{type.id}}Enum {
53 {% for literal in type.enum %} 56 {% for literal in type.enum %}
54 {{export_macro}} extern const char* {{ literal | dash_to_camelcase}}; 57 {{export_macro}} extern const char* {{ literal | dash_to_camelcase}};
55 {% endfor %} 58 {% endfor %}
56 } // {{type.id}}Enum 59 } // namespace {{type.id}}Enum
57 {% endif %} 60 {% endif %}
58 {% endfor %} 61 {% endfor %}
59 {% for command in join_arrays(domain, ["commands", "events"]) %} 62 {% for command in join_arrays(domain, ["commands", "events"]) %}
60 {% for param in join_arrays(command, ["parameters", "returns"]) %} 63 {% for param in join_arrays(command, ["parameters", "returns"]) %}
61 {% if "enum" in param %} 64 {% if "enum" in param %}
62 65
63 namespace {{command.name | to_title_case}} { 66 namespace {{command.name | to_title_case}} {
64 namespace {{param.name | to_title_case}}Enum { 67 namespace {{param.name | to_title_case}}Enum {
65 {% for literal in param.enum %} 68 {% for literal in param.enum %}
66 {{export_macro}} extern const char* {{ literal | dash_to_camelcase}}; 69 {{export_macro}} extern const char* {{ literal | dash_to_camelcase}};
67 {% endfor %} 70 {% endfor %}
68 } // {{param.name | to_title_case}}Enum 71 } // {{param.name | to_title_case}}Enum
69 } // {{command.name | to_title_case }} 72 } // {{command.name | to_title_case }}
70 {% endif %} 73 {% endif %}
71 {% endfor %} 74 {% endfor %}
72 {% endfor %} 75 {% endfor %}
73 76
74 // ------------- Type and builder declarations. 77 // ------------- Type and builder declarations.
75 {% for type in domain.types %} 78 {% for type in domain.types %}
76 {% if not (type.type == "object") or not ("properties" in type) %}{% continu e %}{% endif %} 79 {% if not (type.type == "object") or not ("properties" in type) %}{% continu e %}{% endif %}
77 {% set type_def = type_definition(domain.domain + "." + type.id)%} 80 {% set type_def = type_definition(domain.domain + "." + type.id)%}
78 81
79 // {{type.description}} 82 // {{type.description}}
80 class {{export_macro}} {{type.id}} { 83 class {{export_macro}} {{type.id}} {% if type.exported %}: public Exported::{{ty pe.id}} {% endif %}{
84 PROTOCOL_DISALLOW_COPY({{type.id}});
81 public: 85 public:
82 static std::unique_ptr<{{type.id}}> parse(protocol::Value* value, ErrorSuppo rt* errors); 86 static std::unique_ptr<{{type.id}}> parse(protocol::Value* value, ErrorSuppo rt* errors);
83 87
84 ~{{type.id}}() { } 88 ~{{type.id}}() { }
85 {% for property in type.properties %} 89 {% for property in type.properties %}
86 {% if "enum" in property %} 90 {% if "enum" in property %}
87 91
88 struct {{export_macro}} {{property.name | to_title_case}}Enum { 92 struct {{export_macro}} {{property.name | to_title_case}}Enum {
89 {% for literal in property.enum %} 93 {% for literal in property.enum %}
90 static const char* {{ literal | dash_to_camelcase}}; 94 static const char* {{ literal | dash_to_camelcase}};
91 {% endfor %} 95 {% endfor %}
92 }; // {{property.name | to_title_case}}Enum 96 }; // {{property.name | to_title_case}}Enum
93 {% endif %} 97 {% endif %}
94 98
95 {% if property.optional %} 99 {% if property.optional %}
96 bool has{{property.name | to_title_case}}() { return m_{{property.name}}.isJ ust(); } 100 bool has{{property.name | to_title_case}}() { return m_{{property.name}}.isJ ust(); }
97 {{resolve_type(property).raw_return_type}} get{{property.name | to_title_cas e}}({{resolve_type(property).raw_pass_type}} defaultValue) { return m_{{property .name}}.isJust() ? m_{{property.name}}.fromJust() : defaultValue; } 101 {{resolve_type(property).raw_return_type}} get{{property.name | to_title_cas e}}({{resolve_type(property).raw_pass_type}} defaultValue) { return m_{{property .name}}.isJust() ? m_{{property.name}}.fromJust() : defaultValue; }
98 {% else %} 102 {% else %}
99 {{resolve_type(property).raw_return_type}} get{{property.name | to_title_cas e}}() { return {{resolve_type(property).to_raw_type % ("m_" + property.name)}}; } 103 {{resolve_type(property).raw_return_type}} get{{property.name | to_title_cas e}}() { return {{resolve_type(property).to_raw_type % ("m_" + property.name)}}; }
100 {% endif %} 104 {% endif %}
101 void set{{property.name | to_title_case}}({{resolve_type(property).pass_type }} value) { m_{{property.name}} = {{resolve_type(property).to_rvalue % "value"}} ; } 105 void set{{property.name | to_title_case}}({{resolve_type(property).pass_type }} value) { m_{{property.name}} = {{resolve_type(property).to_rvalue % "value"}} ; }
102 {% endfor %} 106 {% endfor %}
103 107
104 std::unique_ptr<protocol::DictionaryValue> serialize() const; 108 std::unique_ptr<protocol::DictionaryValue> serialize() const;
105 std::unique_ptr<{{type.id}}> clone() const; 109 std::unique_ptr<{{type.id}}> clone() const;
110 {% if type.exported %}
111 String16 toJSONString() const override;
112 {% endif %}
106 113
107 template<int STATE> 114 template<int STATE>
108 class {{type.id}}Builder { 115 class {{type.id}}Builder {
109 public: 116 public:
110 enum { 117 enum {
111 NoFieldsSet = 0, 118 NoFieldsSet = 0,
112 {% set count = 0 %} 119 {% set count = 0 %}
113 {% for property in type.properties %} 120 {% for property in type.properties %}
114 {% if not(property.optional) %} 121 {% if not(property.optional) %}
115 {% set count = count + 1 %} 122 {% set count = count + 1 %}
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 using FrontendClass = Frontend; 283 using FrontendClass = Frontend;
277 using DispatcherClass = Dispatcher; 284 using DispatcherClass = Dispatcher;
278 static const char domainName[]; 285 static const char domainName[];
279 }; 286 };
280 287
281 } // namespace {{domain.domain}} 288 } // namespace {{domain.domain}}
282 } // namespace protocol 289 } // namespace protocol
283 } // namespace blink 290 } // namespace blink
284 291
285 #endif // !defined(protocol_{{domain.domain}}_h) 292 #endif // !defined(protocol_{{domain.domain}}_h)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698