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

Side by Side Diff: templates/TypeBuilder_h.template

Issue 2482993002: Support config.protocol.options which defines which part of protocol definition should be generated. (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « templates/TypeBuilder_cpp.template ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 %}
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 {% endfor %} 182 {% endfor %}
183 183
184 // ------------- Backend interface. 184 // ------------- Backend interface.
185 185
186 class {{config.protocol.export_macro}} Backend { 186 class {{config.protocol.export_macro}} Backend {
187 public: 187 public:
188 virtual ~Backend() { } 188 virtual ~Backend() { }
189 189
190 {% for command in domain.commands %} 190 {% for command in domain.commands %}
191 {% if "redirect" in command %}{% continue %}{% endif %} 191 {% if "redirect" in command %}{% continue %}{% endif %}
192 {% if ("handlers" in command) and not ("renderer" in command["handlers"]) %} {% continue %}{% endif %} 192 {% if not generate_command(domain.domain, command.name) %}{% continue %}{% e ndif %}
193 {% if "async" in command %} 193 {% if is_async_command(domain.domain, command.name) %}
194 class {{config.protocol.export_macro}} {{command.name | to_title_case}}Callb ack { 194 class {{config.protocol.export_macro}} {{command.name | to_title_case}}Callb ack {
195 public: 195 public:
196 virtual void sendSuccess( 196 virtual void sendSuccess(
197 {%- for parameter in command.returns -%} 197 {%- for parameter in command.returns -%}
198 {%- if "optional" in parameter -%} 198 {%- if "optional" in parameter -%}
199 Maybe<{{resolve_type(parameter).raw_type}}> {{parameter.name}} 199 Maybe<{{resolve_type(parameter).raw_type}}> {{parameter.name}}
200 {%- else -%} 200 {%- else -%}
201 {{resolve_type(parameter).pass_type}} {{parameter.name}} 201 {{resolve_type(parameter).pass_type}} {{parameter.name}}
202 {%- endif -%} 202 {%- endif -%}
203 {%- if not loop.last -%}, {% endif -%} 203 {%- if not loop.last -%}, {% endif -%}
204 {%- endfor -%} 204 {%- endfor -%}
205 ) = 0; 205 ) = 0;
206 virtual void sendFailure(const DispatchResponse&) = 0; 206 virtual void sendFailure(const DispatchResponse&) = 0;
207 virtual ~{{command.name | to_title_case}}Callback() { } 207 virtual ~{{command.name | to_title_case}}Callback() { }
208 }; 208 };
209 {% endif %} 209 {% endif %}
210 {%- if not("async" in command) %} 210 {%- if not is_async_command(domain.domain, command.name) %}
211 virtual DispatchResponse {{command.name}}( 211 virtual DispatchResponse {{command.name}}(
212 {%- else %} 212 {%- else %}
213 virtual void {{command.name}}( 213 virtual void {{command.name}}(
214 {%- endif %} 214 {%- endif %}
215 {%- for parameter in command.parameters -%} 215 {%- for parameter in command.parameters -%}
216 {%- if not loop.first -%}, {% endif -%} 216 {%- if not loop.first -%}, {% endif -%}
217 {%- if "optional" in parameter -%} 217 {%- if "optional" in parameter -%}
218 Maybe<{{resolve_type(parameter).raw_type}}> in_{{parameter.name}} 218 Maybe<{{resolve_type(parameter).raw_type}}> in_{{parameter.name}}
219 {%- else -%} 219 {%- else -%}
220 {{resolve_type(parameter).pass_type}} in_{{parameter.name}} 220 {{resolve_type(parameter).pass_type}} in_{{parameter.name}}
221 {%- endif -%} 221 {%- endif -%}
222 {%- endfor -%} 222 {%- endfor -%}
223 {%- if "async" in command -%} 223 {%- if is_async_command(domain.domain, command.name) -%}
224 {%- if command.parameters -%}, {% endif -%} 224 {%- if command.parameters -%}, {% endif -%}
225 std::unique_ptr<{{command.name | to_title_case}}Callback> callback 225 std::unique_ptr<{{command.name | to_title_case}}Callback> callback
226 {%- else -%} 226 {%- else -%}
227 {%- for parameter in command.returns -%} 227 {%- for parameter in command.returns -%}
228 {%- if (not loop.first) or command.parameters -%}, {% endif -%} 228 {%- if (not loop.first) or command.parameters -%}, {% endif -%}
229 {%- if "optional" in parameter -%} 229 {%- if "optional" in parameter -%}
230 Maybe<{{resolve_type(parameter).raw_type}}>* out_{{parameter.name}} 230 Maybe<{{resolve_type(parameter).raw_type}}>* out_{{parameter.name}}
231 {%- else -%} 231 {%- else -%}
232 {{resolve_type(parameter).type}}* out_{{parameter.name}} 232 {{resolve_type(parameter).type}}* out_{{parameter.name}}
233 {%- endif -%} 233 {%- endif -%}
234 {%- endfor -%} 234 {%- endfor -%}
235 {%- endif -%} 235 {%- endif -%}
236 ) = 0; 236 ) = 0;
237 {% endfor %} 237 {% endfor %}
238 238
239 {% if not has_disable(domain.commands) %} 239 {% if generate_disable(domain) %}
240 virtual DispatchResponse disable() 240 virtual DispatchResponse disable()
241 { 241 {
242 return DispatchResponse::OK(); 242 return DispatchResponse::OK();
243 } 243 }
244 {% endif %} 244 {% endif %}
245 }; 245 };
246 246
247 // ------------- Frontend interface. 247 // ------------- Frontend interface.
248 248
249 class {{config.protocol.export_macro}} Frontend { 249 class {{config.protocol.export_macro}} Frontend {
250 public: 250 public:
251 Frontend(FrontendChannel* frontendChannel) : m_frontendChannel(frontendChann el) { } 251 Frontend(FrontendChannel* frontendChannel) : m_frontendChannel(frontendChann el) { }
252 {% for event in domain.events %} 252 {% for event in domain.events %}
253 {% if "handlers" in event and not ("renderer" in event["handlers"]) %}{% con tinue %}{% endif %} 253 {% if not generate_event(domain.domain, event.name) %}{% continue %}{% endif %}
254 void {{event.name}}( 254 void {{event.name}}(
255 {%- for parameter in event.parameters -%} 255 {%- for parameter in event.parameters -%}
256 {%- if "optional" in parameter -%} 256 {%- if "optional" in parameter -%}
257 Maybe<{{resolve_type(parameter).raw_type}}> {{parameter.name}} = Maybe<{ {resolve_type(parameter).raw_type}}>() 257 Maybe<{{resolve_type(parameter).raw_type}}> {{parameter.name}} = Maybe<{ {resolve_type(parameter).raw_type}}>()
258 {%- else -%} 258 {%- else -%}
259 {{resolve_type(parameter).pass_type}} {{parameter.name}} 259 {{resolve_type(parameter).pass_type}} {{parameter.name}}
260 {%- endif -%}{%- if not loop.last -%}, {% endif -%} 260 {%- endif -%}{%- if not loop.last -%}, {% endif -%}
261 {%- endfor -%} 261 {%- endfor -%}
262 ); 262 );
263 {% endfor %} 263 {% endfor %}
(...skipping 24 matching lines...) Expand all
288 static const char commandPrefix[]; 288 static const char commandPrefix[];
289 static const char version[]; 289 static const char version[];
290 }; 290 };
291 291
292 } // namespace {{domain.domain}} 292 } // namespace {{domain.domain}}
293 {% for namespace in config.protocol.namespace %} 293 {% for namespace in config.protocol.namespace %}
294 } // namespace {{namespace}} 294 } // namespace {{namespace}}
295 {% endfor %} 295 {% endfor %}
296 296
297 #endif // !defined({{"_".join(config.protocol.namespace)}}_{{domain.domain}}_h) 297 #endif // !defined({{"_".join(config.protocol.namespace)}}_{{domain.domain}}_h)
OLDNEW
« no previous file with comments | « templates/TypeBuilder_cpp.template ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698