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

Side by Side Diff: content/browser/devtools/protocol/devtools_protocol_handler_generator.py

Issue 642263004: [DevTools] Make generated protocol structs wrappers around DictionaryValue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Applied to tracing Created 6 years, 2 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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import sys 6 import sys
7 import string 7 import string
8 import json 8 import json
9 9
10 input_json_path = sys.argv[1] 10 input_json_path = sys.argv[1]
(...skipping 16 matching lines...) Expand all
27 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_DEVTOOLS_PROTOCOL_HANDLER_IMPL_H_ 27 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_DEVTOOLS_PROTOCOL_HANDLER_IMPL_H_
28 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_DEVTOOLS_PROTOCOL_HANDLER_IMPL_H_ 28 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_DEVTOOLS_PROTOCOL_HANDLER_IMPL_H_
29 29
30 #include "content/browser/devtools/devtools_protocol.h" 30 #include "content/browser/devtools/devtools_protocol.h"
31 #include "content/browser/devtools/protocol/devtools_protocol_client.h" 31 #include "content/browser/devtools/protocol/devtools_protocol_client.h"
32 32
33 namespace content { 33 namespace content {
34 34
35 class DevToolsProtocolHandlerImpl; 35 class DevToolsProtocolHandlerImpl;
36 36
37 class ListBuilderBase {
38 public:
39 static scoped_ptr<base::ListValue> ToValue(ListBuilderBase src);
40
41 protected:
42 ListBuilderBase();
43 ListBuilderBase(scoped_ptr<base::ListValue> list_);
44
45 scoped_ptr<base::ListValue> list_;
46 };
47
48 template<class T>
49 class ListBuilder : public ListBuilderBase {
50 MOVE_ONLY_TYPE_WITH_MOVE_CONSTRUCTOR_FOR_CPP_03(ListBuilder)
51 public:
52 ListBuilder() {}
53 ListBuilder(ListBuilder&& other) : ListBuilderBase(other.list_.Pass()) {
54 }
55
56 void push_back(T item) {
57 list_->Append(T::ToValue(item.Pass()).release());
58 }
59 };
60
61 template<>
62 class ListBuilder<std::string> : public ListBuilderBase {
63 MOVE_ONLY_TYPE_WITH_MOVE_CONSTRUCTOR_FOR_CPP_03(ListBuilder)
64 public:
65 ListBuilder() {}
66 ListBuilder(ListBuilder&& other) : ListBuilderBase(other.list_.Pass()) {
67 }
68
69 void push_back(const std::string& item) {
70 list_->AppendString(item);
71 }
72 };
73
37 namespace devtools { 74 namespace devtools {
38 75
39 ${types}\ 76 ${types}\
40 77
41 } // namespace devtools 78 } // namespace devtools
42 79
43 class DevToolsProtocolHandlerImpl : public DevToolsProtocol::Handler { 80 class DevToolsProtocolHandlerImpl : public DevToolsProtocol::Handler {
44 public: 81 public:
45 typedef DevToolsProtocolClient::Response Response; 82 typedef DevToolsProtocolClient::Response Response;
46 typedef DevToolsProtocolClient::ResponseStatus ResponseStatus; 83 typedef DevToolsProtocolClient::ResponseStatus ResponseStatus;
47 84
48 DevToolsProtocolHandlerImpl(); 85 DevToolsProtocolHandlerImpl();
49 virtual ~DevToolsProtocolHandlerImpl(); 86 virtual ~DevToolsProtocolHandlerImpl();
50 87
51 ${setters}\ 88 ${setters}\
52 89
53 private: 90 private:
54 ${friends}\
55
56 ${methods}\ 91 ${methods}\
57 92
58 ${fields}\ 93 ${fields}\
59 }; 94 };
60 95
61 } // namespace content 96 } // namespace content
62 97
63 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_DEVTOOLS_PROTOCOL_HANDLER_IMPL_H_ 98 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_DEVTOOLS_PROTOCOL_HANDLER_IMPL_H_
64 """) 99 """)
65 100
66 tmpl_typedef = string.Template("""\ 101 tmpl_typedef = string.Template("""\
67 namespace ${domain} { 102 namespace ${domain} {
68 typedef ${param_type} ${declared_name}; 103 typedef ${param_type} ${declared_name};
69 } // namespace ${domain} 104 } // namespace ${domain}
70 """) 105 """)
71 106
72 tmpl_struct = string.Template("""\ 107 tmpl_struct = string.Template("""\
73 namespace ${domain} { 108 namespace ${domain} {
74 struct ${declared_name} { 109 struct ${declared_name} {
110 MOVE_ONLY_TYPE_WITH_MOVE_CONSTRUCTOR_FOR_CPP_03(${declared_name})
75 public: 111 public:
76 ${declared_name}(); 112 enum {
113 kNoneSet = 0,
114 ${fields_enum}\
115 };
116
117 template<int MASK>
118 class Builder {
119 public:
120 ${builder_methods}\
121
122 operator ${declared_name}& () {
123 COMPILE_ASSERT(MASK == kAllSet, required_fields_not_set);
124 return ThisAs<${declared_name}>();
125 }
126
127 ${declared_name}&& Pass() {
128 return static_cast<${declared_name}&>(*this).Pass();
129 }
130
131 private:
132 friend struct ${declared_name};
133
134 template<class T> T& ThisAs() {
135 COMPILE_ASSERT(sizeof(*this) == sizeof(T), cannot_cast);
136 return *reinterpret_cast<T*>(this);
137 }
138
139 scoped_ptr<base::DictionaryValue> dict_;
140 };
141
142 ${declared_name}(${declared_name}&& other);
143
144 static Builder<kNoneSet> Create();
145
146 static scoped_ptr<base::DictionaryValue> ToValue(
147 ${declared_name} src);
77 148
78 ${methods}\ 149 ${methods}\
79 150
80 private: 151 private:
81 friend class ::content::DevToolsProtocolHandlerImpl; 152 ${declared_name}();
82 153
83 ${fields}\ 154 scoped_ptr<base::DictionaryValue> dict_;
84 }; 155 };
85 } // namespace ${domain} 156 } // namespace ${domain}
86 """) 157 """)
87 158
88 tmpl_struct_setter = string.Template("""\ 159 tmpl_struct_setter = string.Template("""\
89 void set_${param}(${pass_type} ${param}); 160 ${declared_name}&
161 set_${param}(${pass_type} ${param});
90 """) 162 """)
91 163
92 tmpl_struct_field = string.Template("""\ 164 tmpl_builder_setter = string.Template("""\
93 ${param_type} ${param}_; 165 Builder<MASK | k${Param}>&
94 bool has_${param}_; 166 set_${param}(${pass_type} ${param}) {
167 COMPILE_ASSERT((MASK & k${Param}) == 0, already_set);
168 ${builder_wrap}\
169 return ThisAs<Builder<MASK | k${Param}>>();
170 }
171 """)
172
173 tmpl_builder_setter_opt = string.Template("""\
174 Builder<MASK>&
175 set_${param}(${pass_type} ${param}) {
176 ${builder_wrap}\
177 return *this;
178 }
179 """)
180
181 tmpl_builder_enum = string.Template("""\
182 k${Param} = 1 << ${ordinal},
183 """)
184
185 tmpl_builder_all_set = string.Template("""\
186 kAllSet = ${all_fields}
95 """) 187 """)
96 188
97 tmpl_enum = string.Template("""\ 189 tmpl_enum = string.Template("""\
98 namespace ${domain} { 190 namespace ${domain} {
99 namespace ${subdomain} { 191 namespace ${subdomain} {
100 ${values}\ 192 ${values}\
101 } // namespace ${subdomain} 193 } // namespace ${subdomain}
102 } // namespace ${domain} 194 } // namespace ${domain}
103 """) 195 """)
104 196
(...skipping 18 matching lines...) Expand all
123 Client(const RawMessageCallback& raw_message_callback); 215 Client(const RawMessageCallback& raw_message_callback);
124 virtual ~Client(); 216 virtual ~Client();
125 217
126 ${methods}\ 218 ${methods}\
127 }; 219 };
128 } // namespace ${domain} 220 } // namespace ${domain}
129 """) 221 """)
130 222
131 tmpl_event = string.Template("""\ 223 tmpl_event = string.Template("""\
132 void ${Command}( 224 void ${Command}(
133 const ${Command}Params& params); 225 ${Command}Params params);
134 """) 226 """)
135 227
136 tmpl_response = string.Template("""\ 228 tmpl_response = string.Template("""\
137 void Send${Command}Response( 229 void Send${Command}Response(
138 scoped_refptr<DevToolsProtocol::Command> command, 230 scoped_refptr<DevToolsProtocol::Command> command,
139 const ${Command}Response& params); 231 ${Command}Response params);
140 """) 232 """)
141 233
142 tmpl_setter = string.Template("""\ 234 tmpl_setter = string.Template("""\
143 void Set${Domain}Handler( 235 void Set${Domain}Handler(
144 devtools::${domain}::${Domain}Handler* ${domain}_handler); 236 devtools::${domain}::${Domain}Handler* ${domain}_handler);
145 """) 237 """)
146 238
147 tmpl_friend = string.Template("""\
148 friend class devtools::${domain}::Client;
149 """)
150
151 tmpl_callback = string.Template("""\ 239 tmpl_callback = string.Template("""\
152 scoped_refptr<DevToolsProtocol::Response> 240 scoped_refptr<DevToolsProtocol::Response>
153 On${Domain}${Command}( 241 On${Domain}${Command}(
154 scoped_refptr<DevToolsProtocol::Command> command); 242 scoped_refptr<DevToolsProtocol::Command> command);
155 """) 243 """)
156 244
157 tmpl_to_value = string.Template("""\
158 static base::DictionaryValue* ToValue(
159 const devtools::${domain}::${declared_name}& src);
160 """)
161
162 tmpl_field = string.Template("""\ 245 tmpl_field = string.Template("""\
163 devtools::${domain}::${Domain}Handler* ${domain}_handler_; 246 devtools::${domain}::${Domain}Handler* ${domain}_handler_;
164 """) 247 """)
165 248
166 template_cc = string.Template(header + """\ 249 template_cc = string.Template(header + """\
167 250
168 #include "content/browser/devtools/protocol/devtools_protocol_handler_impl.h" 251 #include "content/browser/devtools/protocol/devtools_protocol_handler_impl.h"
169 252
170 #include "base/bind.h" 253 #include "base/bind.h"
171 ${includes}\ 254 ${includes}\
172 255
173 namespace content { 256 namespace content {
174 257
258 ListBuilderBase::ListBuilderBase()
259 : list_(new base::ListValue) {
260 }
261
262 ListBuilderBase::ListBuilderBase(scoped_ptr<base::ListValue> list)
263 : list_(list.Pass()) {
264 }
265
266 // static
267 scoped_ptr<base::ListValue> ListBuilderBase::ToValue(
268 ListBuilderBase src) {
269 return src.list_.Pass();
270 }
271
175 DevToolsProtocolHandlerImpl::DevToolsProtocolHandlerImpl() 272 DevToolsProtocolHandlerImpl::DevToolsProtocolHandlerImpl()
176 : ${fields_init} { 273 : ${fields_init} {
177 } 274 }
178 275
179 DevToolsProtocolHandlerImpl::~DevToolsProtocolHandlerImpl() { 276 DevToolsProtocolHandlerImpl::~DevToolsProtocolHandlerImpl() {
180 } 277 }
181 278
182 namespace { 279 namespace {
183 280
184 typedef DevToolsProtocolClient::ResponseStatus ResponseStatus; 281 typedef DevToolsProtocolClient::ResponseStatus ResponseStatus;
185 282
186 bool CreateCommonResponse( 283 bool CreateCommonResponse(
187 scoped_refptr<DevToolsProtocol::Command> command, 284 scoped_refptr<DevToolsProtocol::Command> command,
188 const DevToolsProtocolClient::Response& response, 285 const DevToolsProtocolClient::Response& response,
189 scoped_refptr<DevToolsProtocol::Response>* protocol_response) { 286 scoped_refptr<DevToolsProtocol::Response>* protocol_response) {
190 switch (response.status()) { 287 switch (response.status()) {
191 case ResponseStatus::RESPONSE_STATUS_FALLTHROUGH: 288 case ResponseStatus::RESPONSE_STATUS_FALLTHROUGH:
192 *protocol_response = NULL; 289 *protocol_response = nullptr;
193 break; 290 break;
194 case ResponseStatus::RESPONSE_STATUS_OK: 291 case ResponseStatus::RESPONSE_STATUS_OK:
195 return false; 292 return false;
196 case ResponseStatus::RESPONSE_STATUS_INVALID_PARAMS: 293 case ResponseStatus::RESPONSE_STATUS_INVALID_PARAMS:
197 *protocol_response = command->InvalidParamResponse(response.message()); 294 *protocol_response = command->InvalidParamResponse(response.message());
198 break; 295 break;
199 case ResponseStatus::RESPONSE_STATUS_INTERNAL_ERROR: 296 case ResponseStatus::RESPONSE_STATUS_INTERNAL_ERROR:
200 *protocol_response = command->InternalErrorResponse(response.message()); 297 *protocol_response = command->InternalErrorResponse(response.message());
201 break; 298 break;
202 case ResponseStatus::RESPONSE_STATUS_SERVER_ERROR: 299 case ResponseStatus::RESPONSE_STATUS_SERVER_ERROR:
(...skipping 13 matching lines...) Expand all
216 313
217 } // namespace devtools 314 } // namespace devtools
218 315
219 } // namespace content 316 } // namespace content
220 """) 317 """)
221 318
222 tmpl_include = string.Template("""\ 319 tmpl_include = string.Template("""\
223 #include "content/browser/devtools/protocol/${domain}_handler.h" 320 #include "content/browser/devtools/protocol/${domain}_handler.h"
224 """) 321 """)
225 322
226 tmpl_field_init = string.Template("${domain}_handler_(NULL)") 323 tmpl_field_init = string.Template("${domain}_handler_(nullptr)")
227 324
228 tmpl_setter_impl = string.Template("""\ 325 tmpl_setter_impl = string.Template("""\
229 void DevToolsProtocolHandlerImpl::Set${Domain}Handler( 326 void DevToolsProtocolHandlerImpl::Set${Domain}Handler(
230 devtools::${domain}::${Domain}Handler* ${domain}_handler) { 327 devtools::${domain}::${Domain}Handler* ${domain}_handler) {
231 DCHECK(!${domain}_handler_); 328 DCHECK(!${domain}_handler_);
232 ${domain}_handler_ = ${domain}_handler; 329 ${domain}_handler_ = ${domain}_handler;
233 ${initializations}\ 330 ${initializations}\
234 } 331 }
235 """) 332 """)
236 333
(...skipping 14 matching lines...) Expand all
251 348
252 tmpl_callback_impl = string.Template("""\ 349 tmpl_callback_impl = string.Template("""\
253 scoped_refptr<DevToolsProtocol::Response> 350 scoped_refptr<DevToolsProtocol::Response>
254 DevToolsProtocolHandlerImpl::On${Domain}${Command}( 351 DevToolsProtocolHandlerImpl::On${Domain}${Command}(
255 scoped_refptr<DevToolsProtocol::Command> command) { 352 scoped_refptr<DevToolsProtocol::Command> command) {
256 ${prep}\ 353 ${prep}\
257 Response response = ${domain}_handler_->${Command}(${args}); 354 Response response = ${domain}_handler_->${Command}(${args});
258 scoped_refptr<DevToolsProtocol::Response> protocol_response; 355 scoped_refptr<DevToolsProtocol::Response> protocol_response;
259 if (CreateCommonResponse(command, response, &protocol_response)) 356 if (CreateCommonResponse(command, response, &protocol_response))
260 return protocol_response; 357 return protocol_response;
261 base::DictionaryValue* dict = new base::DictionaryValue(); 358 base::DictionaryValue* result = new base::DictionaryValue();
262 ${wrap}\ 359 ${wrap}\
263 return command->SuccessResponse(dict); 360 return command->SuccessResponse(result);
264 } 361 }
265 """) 362 """)
266 363
267 tmpl_callback_async_impl = string.Template("""\ 364 tmpl_callback_async_impl = string.Template("""\
268 scoped_refptr<DevToolsProtocol::Response> 365 scoped_refptr<DevToolsProtocol::Response>
269 DevToolsProtocolHandlerImpl::On${Domain}${Command}( 366 DevToolsProtocolHandlerImpl::On${Domain}${Command}(
270 scoped_refptr<DevToolsProtocol::Command> command) { 367 scoped_refptr<DevToolsProtocol::Command> command) {
271 ${prep}\ 368 ${prep}\
272 return ${domain}_handler_->${Command}(${args}); 369 return ${domain}_handler_->${Command}(${args});
273 } 370 }
274 """) 371 """)
275 372
276 params_prep = """\ 373 params_prep = """\
277 base::DictionaryValue* params = command->params(); 374 base::DictionaryValue* params = command->params();
278 """ 375 """
279 376
280 tmpl_prep_req = string.Template("""\ 377 tmpl_prep_req = string.Template("""\
281 ${param_type} in_${param}${init}; 378 ${param_type} in_${param}${init};
282 if (!params || 379 if (!params || !params->Get${Type}("${proto_param}", &in_${param}))
283 !params->Get${Type}("${proto_param}", &in_${param}))
284 return command->InvalidParamResponse("${proto_param}"); 380 return command->InvalidParamResponse("${proto_param}");
285 """) 381 """)
286 382
287 tmpl_prep_req_list = string.Template("""\ 383 tmpl_prep_req_list = string.Template("""\
288 base::ListValue* list_${param} = NULL; 384 base::ListValue* list_${param} = nullptr;
289 if (!params || !params->GetList("${proto_param}", &list_${param})) 385 if (!params || !params->GetList("${proto_param}", &list_${param}))
290 return command->InvalidParamResponse("${proto_param}"); 386 return command->InvalidParamResponse("${proto_param}");
291 ${param_type} in_${param}; 387 std::vector<${item_type}> in_${param};
292 for (base::ListValue::const_iterator it = 388 for (base::ListValue::const_iterator it =
293 list_${param}->begin(); it != list_${param}->end(); ++it) { 389 list_${param}->begin(); it != list_${param}->end(); ++it) {
294 ${item_type} item${item_init}; 390 ${item_type} item${item_init};
295 if (!(*it)->GetAs${ItemType}(&item)) 391 if (!(*it)->GetAs${ItemType}(&item))
296 return command->InvalidParamResponse("${proto_param}"); 392 return command->InvalidParamResponse("${proto_param}");
297 in_${param}.push_back(item); 393 in_${param}.push_back(item);
298 } 394 }
299 """) 395 """)
300 396
301 tmpl_prep_opt = string.Template("""\ 397 tmpl_prep_opt = string.Template("""\
302 ${param_type} in_${param}${init}; 398 ${param_type} in_${param}${init};
303 bool ${param}_found = params && params->Get${Type}( 399 bool ${param}_found = params && params->Get${Type}(
304 "${proto_param}", 400 "${proto_param}",
305 &in_${param}); 401 &in_${param});
306 """) 402 """)
307 403
308 tmpl_prep_output = string.Template("""\ 404 tmpl_prep_output = string.Template("""\
309 ${param_type} out_${param}${init}; 405 ${param_type} out_${param}${init};
310 """) 406 """)
311 407
312 tmpl_arg_req = string.Template("in_${param}") 408 tmpl_arg_req = string.Template("in_${param}")
313 409
314 tmpl_arg_opt = string.Template( 410 tmpl_arg_opt = string.Template(
315 "${param}_found ?\n &in_${param} : NULL") 411 "${param}_found ? &in_${param} : nullptr")
316
317 tmpl_arg_output = string.Template("&out_${param}")
318
319 tmpl_to_value_impl = string.Template("""\
320 // static
321 base::DictionaryValue* DevToolsProtocolHandlerImpl::ToValue(
322 const devtools::${domain}::${declared_name}& src) {
323 base::DictionaryValue* dict = new base::DictionaryValue();
324 ${dchecks}\
325 ${wrap}\
326 return dict;
327 }
328 """)
329
330 tmpl_dcheck = string.Template("""\
331 DCHECK(${cond_name});
332 """)
333 412
334 tmpl_struct_impl = string.Template("""\ 413 tmpl_struct_impl = string.Template("""\
335 namespace ${domain} { 414 namespace ${domain} {
336 415
337 ${declared_name}::${declared_name}()${fields} { 416 ${declared_name}::${declared_name}()
417 : dict_(new base::DictionaryValue) {
418 }
419
420 ${declared_name}::${declared_name}(${declared_name}&& other)
421 : dict_(other.dict_.Pass()) {
422 }
423
424 // static
425 ${declared_name}::Builder<${declared_name}::kNoneSet>
426 ${declared_name}::Create() {
427 return Builder<kNoneSet>();
428 }
429
430 // static
431 scoped_ptr<base::DictionaryValue> ${declared_name}::ToValue(
432 ${declared_name} src) {
433 return src.dict_.Pass();
338 } 434 }
339 435
340 ${methods}\ 436 ${methods}\
341 437
342 } // namespace ${domain} 438 } // namespace ${domain}
343 """) 439 """)
344 440
345 tmpl_struct_field_init = string.Template("has_${param}_(false)")
346
347 tmpl_struct_setter_impl = string.Template("""\ 441 tmpl_struct_setter_impl = string.Template("""\
348 void ${declared_name}::set_${param}( 442 ${declared_name}&
443 ${declared_name}::set_${param}(
349 ${pass_type} ${param}) { 444 ${pass_type} ${param}) {
350 ${param}_ = ${param}; 445 ${wrap}\
351 has_${param}_ = true; 446 return *this;
352 } 447 }
353 """) 448 """)
354 449
355 tmpl_client_impl = string.Template("""\ 450 tmpl_client_impl = string.Template("""\
356 namespace ${domain} { 451 namespace ${domain} {
357 452
358 Client::Client(const RawMessageCallback& raw_message_callback) 453 Client::Client(const RawMessageCallback& raw_message_callback)
359 : DevToolsProtocolClient(raw_message_callback) { 454 : DevToolsProtocolClient(raw_message_callback) {
360 } 455 }
361 456
362 Client::~Client() { 457 Client::~Client() {
363 } 458 }
364 459
365 ${methods}\ 460 ${methods}\
366 461
367 } // namespace ${domain} 462 } // namespace ${domain}
368 """) 463 """)
369 464
370 tmpl_event_impl = string.Template("""\ 465 tmpl_event_impl = string.Template("""\
371 void Client::${Command}( 466 void Client::${Command}(
372 const ${Command}Params& params) { 467 ${Command}Params params) {
373 SendNotification("${Domain}.${command}", 468 SendNotification("${Domain}.${command}",
374 DevToolsProtocolHandlerImpl::ToValue(params)); 469 ${Command}Params::ToValue(params.Pass()).Pass());
375 } 470 }
376 """) 471 """)
377 472
378 tmpl_response_impl = string.Template("""\ 473 tmpl_response_impl = string.Template("""\
379 void Client::Send${Command}Response( 474 void Client::Send${Command}Response(
380 scoped_refptr<DevToolsProtocol::Command> command, 475 scoped_refptr<DevToolsProtocol::Command> command,
381 const ${Command}Response& params) { 476 ${Command}Response params) {
382 SendAsyncResponse( 477 SendAsyncResponse(
383 command->SuccessResponse(DevToolsProtocolHandlerImpl::ToValue(params))); 478 command->SuccessResponse(
479 ${Command}Response::ToValue(params.Pass()).release()));
384 } 480 }
385 """) 481 """)
386 482
387 tmpl_wrap = string.Template("""\ 483 tmpl_wrap = string.Template("""\
388 dict->Set${Type}("${proto_param}", ${var_name}); 484 ${dict_var}->Set${Type}("${proto_param}", ${var_name});
389 """) 485 """)
390 486
391 tmpl_wrap_dict = string.Template("""\ 487 tmpl_wrap_dict = string.Template("""\
392 dict->Set("${proto_param}", 488 ${dict_var}->Set("${proto_param}",
393 DevToolsProtocolHandlerImpl::ToValue(${var_name})); 489 ${param_type}::ToValue(${var_name}.Pass()).release());
394 """) 490 """)
395 491
492 tmpl_wrap_list = tmpl_wrap_dict;
493
396 tmpl_wrap_obj = string.Template("""\ 494 tmpl_wrap_obj = string.Template("""\
397 dict->Set("${proto_param}", ${var_name}); 495 ${dict_var}->Set("${proto_param}", ${var_name}.release());
398 """)
399
400 tmpl_wrap_list = string.Template("""\
401 base::ListValue* list_${param} = new base::ListValue();
402 for (${param_type}::const_iterator it =
403 ${var_name}.begin(); it != ${var_name}.end(); ++it) {
404 ${append}\
405 }
406 dict->Set("${proto_param}", list_${param});
407 """)
408
409 tmpl_append = string.Template("""\
410 list_${param}->Append${Type}(*it);
411 """)
412
413 tmpl_append_dict = string.Template("""\
414 list_${param}->Append(DevToolsProtocolHandlerImpl::ToValue(*it));
415 """)
416
417 tmpl_append_obj = string.Template("""\
418 list_${param}->Append(*it);
419 """)
420
421 tmpl_wrap_opt = string.Template("""\
422 if (${cond_name})
423 dict->Set${Type}("${proto_param}", ${var_name});
424 """) 496 """)
425 497
426 tmpl_typename = string.Template("devtools::${domain}::${declared_name}") 498 tmpl_typename = string.Template("devtools::${domain}::${declared_name}")
427 499
500 def Shift(prefix, s):
501 return "\n".join(map(lambda line: prefix + line, s.split("\n")))
502
428 def Capitalize(s): 503 def Capitalize(s):
429 return s[:1].upper() + s[1:] 504 return s[:1].upper() + s[1:]
430 505
431 def Decapitalize(s):
432 return s.lower()
433
434 def Uncamelcase(s): 506 def Uncamelcase(s):
435 result = "" 507 result = ""
436 for i, c in enumerate(s): 508 for i, c in enumerate(s):
437 if c.isupper(): 509 if c.isupper():
438 if (i > 0) and ((i < len(s)-1) and s[i+1].islower() or s[i-1].islower()): 510 if (i > 0) and ((i < len(s)-1) and s[i+1].islower() or s[i-1].islower()):
439 result += "_" 511 result += "_"
440 result += c.lower() 512 result += c.lower()
441 else: 513 else:
442 result += c 514 result += c
443 return result 515 return result
444 516
445 types = {} 517 types = {}
446 json_api = json.loads(open(input_json_path, "r").read()) 518 json_api = json.loads(open(input_json_path, "r").read())
447 type_decls = [] 519 type_decls = []
448 type_impls = [] 520 type_impls = []
449 handler_methods = [] 521 handler_methods = []
450 handler_method_impls = [] 522 handler_method_impls = []
451 523
452 for json_domain in json_api["domains"]: 524 for json_domain in json_api["domains"]:
453 if "types" in json_domain: 525 if "types" in json_domain:
454 for json_type in json_domain["types"]: 526 for json_type in json_domain["types"]:
455 types["%s.%s" % (json_domain["domain"], json_type["id"])] = json_type 527 types["%s.%s" % (json_domain["domain"], json_type["id"])] = json_type
456 528
457 def DeclareStruct(json_properties, mapping): 529 def DeclareStruct(json_properties, mapping):
458 methods = [] 530 methods = []
459 fields = []
460 fields_init = []
461 method_impls = [] 531 method_impls = []
462 dchecks = [] 532 fields_enum = []
463 wrap = [] 533 enum_items = []
534 builder_methods = []
535 req_fields_num = 0
464 for json_prop in json_properties: 536 for json_prop in json_properties:
465 prop_map = mapping.copy() 537 prop_map = mapping.copy()
466 prop_map["proto_param"] = json_prop["name"] 538 prop_map["proto_param"] = json_prop["name"]
467 prop_map["param"] = Uncamelcase(json_prop["name"]) 539 prop_map["param"] = Uncamelcase(json_prop["name"])
468 prop_map["var_name"] = "src.%s_" % prop_map["param"] 540 prop_map["Param"] = Capitalize(json_prop["name"])
469 prop_map["cond_name"] = "src.has_%s_" % prop_map["param"] 541 prop_map["var_name"] = "%s" % prop_map["param"]
542 prop_map["dict_var"] = "dict_";
470 ResolveType(json_prop, prop_map) 543 ResolveType(json_prop, prop_map)
471 prop_map["declared_name"] = mapping["declared_name"] 544 prop_map["declared_name"] = mapping["declared_name"]
472 methods.append(tmpl_struct_setter.substitute(prop_map))
473 fields.append(tmpl_struct_field.substitute(prop_map))
474 fields_init.append(tmpl_struct_field_init.substitute(prop_map))
475 method_impls.append(tmpl_struct_setter_impl.substitute(prop_map))
476 if json_prop.get("optional"): 545 if json_prop.get("optional"):
477 if param_map["Type"] in ["List", "Dictionary"]: 546 methods.append(tmpl_struct_setter.substitute(prop_map))
478 # TODO(vkuzkokov) Implement. 547 method_impls.append(tmpl_struct_setter_impl.substitute(prop_map))
479 raise Exception( 548 builder_methods.append(tmpl_builder_setter_opt.substitute(prop_map))
480 "Optional array and object properties are not implemented")
481 wrap.append(tmpl_wrap_opt.substitute(prop_map))
482 else: 549 else:
483 dchecks.append(tmpl_dcheck.substitute(prop_map)); 550 builder_methods.append(tmpl_builder_setter.substitute(prop_map))
484 if not "wrap" in prop_map: 551 enum_items.append("k%s" % prop_map["Param"]);
485 raise Exception("Arrays of arrays are not implemented") 552 fields_enum.append(tmpl_builder_enum.substitute(prop_map,
486 wrap.append(prop_map["wrap"]) 553 ordinal = req_fields_num))
554 req_fields_num += 1
487 555
556 all_fields = "kNoneSet"
557 if len(enum_items) > 0:
558 all_fields = " | ".join(enum_items)
dgozman 2014/10/29 13:27:45 Why not just |all_fields = "1 << req_fields_num -
vkuzkokov 2014/10/29 17:42:02 To emphasize the intent: same way generator in bli
559 fields_enum.append(tmpl_builder_all_set.substitute(mapping,
560 all_fields = all_fields))
488 type_decls.append(tmpl_struct.substitute(mapping, 561 type_decls.append(tmpl_struct.substitute(mapping,
489 methods = "".join(methods), 562 methods = "".join(methods),
490 fields = "".join(fields))) 563 fields_enum = "".join(fields_enum),
491 fields_init_str = "" 564 builder_methods = "\n".join(builder_methods)))
492 if len(fields_init) > 0:
493 fields_init_str = "\n : " + (",\n ".join(fields_init))
494 type_impls.append(tmpl_struct_impl.substitute(mapping, 565 type_impls.append(tmpl_struct_impl.substitute(mapping,
495 fields = fields_init_str,
496 methods = "\n".join(method_impls))) 566 methods = "\n".join(method_impls)))
497 handler_methods.append(tmpl_to_value.substitute(mapping))
498 handler_method_impls.append(tmpl_to_value_impl.substitute(mapping,
499 dchecks = "".join(dchecks),
500 wrap = "".join(wrap)))
501 567
502 def ResolveRef(json, mapping): 568 def ResolveRef(json, mapping):
503 dot_pos = json["$ref"].find(".") 569 dot_pos = json["$ref"].find(".")
504 if dot_pos == -1: 570 if dot_pos == -1:
505 domain_name = mapping["Domain"] 571 domain_name = mapping["Domain"]
506 type_name = json["$ref"] 572 type_name = json["$ref"]
507 else: 573 else:
508 domain_name = json["$ref"][:dot_pos] 574 domain_name = json["$ref"][:dot_pos]
509 type_name = json["$ref"][dot_pos + 1:] 575 type_name = json["$ref"][dot_pos + 1:]
510 json_type = types["%s.%s" % (domain_name, type_name)] 576 json_type = types["%s.%s" % (domain_name, type_name)]
511 mapping["declared_name"] = Capitalize(type_name) 577 mapping["declared_name"] = Capitalize(type_name)
512 mapping["Domain"] = domain_name 578 mapping["Domain"] = domain_name
513 mapping["domain"] = Decapitalize(domain_name) 579 mapping["domain"] = Uncamelcase(domain_name)
514 mapping["param_type"] = tmpl_typename.substitute(mapping) 580 mapping["param_type"] = tmpl_typename.substitute(mapping)
515 if json_type.get("enum"): 581 if json_type.get("enum"):
516 # TODO(vkuzkokov) Implement. Approximate template: 582 # TODO(vkuzkokov) Implement. Approximate template:
517 # namespace ${domain} { const char k${declared_name}${Value}; } 583 # namespace ${domain} { const char k${declared_name}${Value}; }
518 raise Exception("Named enumerations are not implemented") 584 raise Exception("Named enumerations are not implemented")
519 ResolveType(json_type, mapping) 585 ResolveType(json_type, mapping)
520 if not "___struct_declared" in json_type: 586 if not "___struct_declared" in json_type:
521 json_type["___struct_declared"] = True; 587 json_type["___struct_declared"] = True;
522 if (json_type.get("type") == "object") and ("properties" in json_type): 588 if (json_type.get("type") == "object") and ("properties" in json_type):
523 DeclareStruct(json_type["properties"], mapping) 589 DeclareStruct(json_type["properties"], mapping)
524 else: 590 else:
525 type_decls.append(tmpl_typedef.substitute(mapping)) 591 type_decls.append(tmpl_typedef.substitute(mapping))
526 mapping["param_type"] = tmpl_typename.substitute(mapping) 592 mapping["param_type"] = tmpl_typename.substitute(mapping)
527 593
528 def ResolveArray(json, mapping): 594 def ResolveArray(json, mapping):
529 items_map = mapping.copy() 595 items_map = mapping.copy()
530 ResolveType(json["items"], items_map) 596 ResolveType(json["items"], items_map)
531 mapping["param_type"] = "std::vector<%s>" % items_map["param_type"] 597 mapping["param_type"] = "ListBuilder<%s>" % items_map["param_type"]
532 mapping["Type"] = "List" 598 mapping["Type"] = "List"
533 if "append" in items_map: 599 mapping["wrap"] = tmpl_wrap_list.substitute(mapping)
534 mapping["wrap"] = tmpl_wrap_list.substitute(mapping, 600 mapping["pass_type"] = mapping["param_type"]
535 append = items_map["append"])
536 mapping["pass_type"] = "const %s&" % mapping["param_type"]
537 mapping["prep_req"] = tmpl_prep_req_list.substitute(mapping, 601 mapping["prep_req"] = tmpl_prep_req_list.substitute(mapping,
538 item_type = items_map["param_type"], 602 item_type = items_map["param_type"],
539 item_init = items_map["init"], 603 item_init = items_map["init"],
540 ItemType = items_map["Type"]) 604 ItemType = items_map["Type"])
541 # TODO(vkuzkokov) mapping["append"]: template for array of arrays. 605 mapping["arg_out"] = "&%s" % mapping["var_name"]
542 606
543 def ResolveObject(json, mapping): 607 def ResolveObject(json, mapping):
544 mapping["Type"] = "Dictionary" 608 mapping["Type"] = "Dictionary"
545 if "properties" in json: 609 if "properties" in json:
546 if not "declared_name" in mapping: 610 if not "declared_name" in mapping:
547 mapping["declared_name"] = ("%s%s" % 611 mapping["declared_name"] = ("%s%s" %
548 (mapping["Command"], Capitalize(mapping["proto_param"]))) 612 (mapping["Command"], Capitalize(mapping["proto_param"])))
549 mapping["param_type"] = tmpl_typename.substitute(mapping) 613 mapping["param_type"] = tmpl_typename.substitute(mapping)
550 DeclareStruct(json["properties"], mapping) 614 DeclareStruct(json["properties"], mapping)
551 mapping["append"] = tmpl_append_dict.substitute(mapping)
552 mapping["wrap"] = tmpl_wrap_dict.substitute(mapping) 615 mapping["wrap"] = tmpl_wrap_dict.substitute(mapping)
553 mapping["pass_type"] = "const %s&" % mapping["param_type"] 616 mapping["pass_type"] = mapping["param_type"]
617 mapping["arg_out"] = "&%s" % mapping["var_name"]
554 else: 618 else:
555 mapping["param_type"] = "base::DictionaryValue*" 619 mapping["param_type"] = "base::DictionaryValue"
556 mapping["append"] = tmpl_append_obj.substitute(mapping)
557 mapping["wrap"] = tmpl_wrap_obj.substitute(mapping) 620 mapping["wrap"] = tmpl_wrap_obj.substitute(mapping)
558 mapping["pass_type"] = mapping["param_type"] 621 mapping["pass_type"] = "scoped_ptr<base::DictionaryValue>"
622 mapping["arg_out"] = "%s.get()" % mapping["var_name"]
559 623
560 def ResolvePrimitive(json, mapping): 624 def ResolvePrimitive(json, mapping):
561 jsonrpc_type = json["type"] 625 jsonrpc_type = json["type"]
562 if jsonrpc_type == "boolean": 626 if jsonrpc_type == "boolean":
563 mapping["param_type"] = "bool" 627 mapping["param_type"] = "bool"
564 mapping["Type"] = "Boolean" 628 mapping["Type"] = "Boolean"
565 mapping["init"] = " = false" 629 mapping["init"] = " = false"
566 elif jsonrpc_type == "integer": 630 elif jsonrpc_type == "integer":
567 mapping["param_type"] = "int" 631 mapping["param_type"] = "int"
568 mapping["Type"] = "Integer" 632 mapping["Type"] = "Integer"
(...skipping 20 matching lines...) Expand all
589 value_defs.append(tmpl_enum_value_def.substitute(mapping, 653 value_defs.append(tmpl_enum_value_def.substitute(mapping,
590 value = enum_value, 654 value = enum_value,
591 Value = Capitalize(enum_value))) 655 Value = Capitalize(enum_value)))
592 type_decls.append(tmpl_enum.substitute(mapping, 656 type_decls.append(tmpl_enum.substitute(mapping,
593 values = "".join(values))) 657 values = "".join(values)))
594 type_impls.append(tmpl_enum.substitute(mapping, 658 type_impls.append(tmpl_enum.substitute(mapping,
595 values = "".join(value_defs))) 659 values = "".join(value_defs)))
596 else: 660 else:
597 raise Exception("Unknown type: %s" % json_type) 661 raise Exception("Unknown type: %s" % json_type)
598 mapping["wrap"] = tmpl_wrap.substitute(mapping) 662 mapping["wrap"] = tmpl_wrap.substitute(mapping)
599 mapping["append"] = tmpl_append.substitute(mapping)
600 mapping["prep_req"] = tmpl_prep_req.substitute(mapping) 663 mapping["prep_req"] = tmpl_prep_req.substitute(mapping)
601 if jsonrpc_type != "string": 664 if jsonrpc_type != "string":
602 mapping["pass_type"] = mapping["param_type"] 665 mapping["pass_type"] = mapping["param_type"]
666 mapping["arg_out"] = "&%s" % mapping["var_name"]
603 667
604 def ResolveType(json, mapping): 668 def ResolveType(json, mapping):
605 mapping["init"] = "" 669 mapping["init"] = ""
606 if "$ref" in json: 670 if "$ref" in json:
607 ResolveRef(json, mapping) 671 ResolveRef(json, mapping)
608 elif "type" in json: 672 elif "type" in json:
609 jsonrpc_type = json["type"] 673 jsonrpc_type = json["type"]
610 if jsonrpc_type == "array": 674 if jsonrpc_type == "array":
611 ResolveArray(json, mapping) 675 ResolveArray(json, mapping)
612 elif jsonrpc_type == "object": 676 elif jsonrpc_type == "object":
613 ResolveObject(json, mapping) 677 ResolveObject(json, mapping)
614 else: 678 else:
615 ResolvePrimitive(json, mapping) 679 ResolvePrimitive(json, mapping)
616 else: 680 else:
617 raise Exception("Unknown type at %s.%s %s" % 681 raise Exception("Unknown type at %s.%s %s" %
618 (mapping["Domain"], mapping["command"], mapping["proto_param"])) 682 (mapping["Domain"], mapping["command"], mapping["proto_param"]))
683 mapping["builder_wrap"] = Shift(" ", mapping["wrap"])
619 684
620 setters = [] 685 setters = []
621 friends = []
622 fields = [] 686 fields = []
623 687
624 includes = [] 688 includes = []
625 fields_init = [] 689 fields_init = []
626 690
627 for json_domain in json_api["domains"]: 691 for json_domain in json_api["domains"]:
628 domain_map = {} 692 domain_map = {}
629 domain_map["Domain"] = json_domain["domain"] 693 domain_map["Domain"] = json_domain["domain"]
630 domain_map["domain"] = Decapitalize(json_domain["domain"]) 694 domain_map["domain"] = Uncamelcase(json_domain["domain"])
631 695
632 initializations = [] 696 initializations = []
633 client_methods = [] 697 client_methods = []
634 client_method_impls = [] 698 client_method_impls = []
635 domain_empty = True 699 domain_empty = True
636 domain_needs_client = False 700 domain_needs_client = False
637 701
638 if "commands" in json_domain: 702 if "commands" in json_domain:
639 for json_command in json_domain["commands"]: 703 for json_command in json_domain["commands"]:
640 if (not ("handlers" in json_command) or 704 if (not ("handlers" in json_command) or
641 not ("browser" in json_command["handlers"])): 705 not ("browser" in json_command["handlers"])):
642 continue 706 continue
643 domain_empty = False 707 domain_empty = False
644 708
645 command_map = domain_map.copy() 709 command_map = domain_map.copy()
646 command_map["command"] = json_command["name"] 710 command_map["command"] = json_command["name"]
647 command_map["Command"] = Capitalize(json_command["name"]) 711 command_map["Command"] = Capitalize(json_command["name"])
648 712
649 prep = [] 713 prep = []
650 args = [] 714 args = []
651 715
652 if "parameters" in json_command: 716 if "parameters" in json_command:
653 for json_param in json_command["parameters"]: 717 for json_param in json_command["parameters"]:
654 param_map = command_map.copy() 718 param_map = command_map.copy()
655 param_map["proto_param"] = json_param["name"] 719 param_map["proto_param"] = json_param["name"]
656 param_map["param"] = Uncamelcase(json_param["name"]) 720 param_map["param"] = Uncamelcase(json_param["name"])
657 param_map["var_name"] = "in_%s" % param_map["param"] 721 param_map["var_name"] = "in_%s" % param_map["param"]
722 param_map["dict_var"] = "result"
658 723
659 ResolveType(json_param, param_map) 724 ResolveType(json_param, param_map)
660 if len(prep) == 0: 725 if len(prep) == 0:
661 prep.append(params_prep) 726 prep.append(params_prep)
662 if json_param.get("optional"): 727 if json_param.get("optional"):
663 if param_map["Type"] in ["List", "Dictionary"]: 728 if param_map["Type"] in ["List", "Dictionary"]:
664 # TODO(vkuzkokov) Implement transformation of base::ListValue 729 # TODO(vkuzkokov) Implement transformation of base::ListValue
665 # to std::vector and base::DictonaryValue to struct. 730 # to std::vector and base::DictonaryValue to struct.
666 raise Exception( 731 raise Exception(
667 "Optional array and object parameters are not implemented") 732 "Optional array and object parameters are not implemented")
(...skipping 21 matching lines...) Expand all
689 client_methods.append(tmpl_response.substitute(command_map)) 754 client_methods.append(tmpl_response.substitute(command_map))
690 client_method_impls.append(tmpl_response_impl.substitute(command_map)) 755 client_method_impls.append(tmpl_response_impl.substitute(command_map))
691 else: 756 else:
692 wrap = [] 757 wrap = []
693 if "returns" in json_command: 758 if "returns" in json_command:
694 for json_param in json_command["returns"]: 759 for json_param in json_command["returns"]:
695 param_map = command_map.copy() 760 param_map = command_map.copy()
696 param_map["proto_param"] = json_param["name"] 761 param_map["proto_param"] = json_param["name"]
697 param_map["param"] = Uncamelcase(json_param["name"]) 762 param_map["param"] = Uncamelcase(json_param["name"])
698 param_map["var_name"] = "out_%s" % param_map["param"] 763 param_map["var_name"] = "out_%s" % param_map["param"]
764 param_map["dict_var"] = "result"
699 765
700 if json_param.get("optional"): 766 if json_param.get("optional"):
701 # TODO(vkuzkokov) Implement Optional<T> for value types. 767 # TODO(vkuzkokov) Implement Optional<T> for value types.
702 raise Exception("Optional return values are not implemented") 768 raise Exception("Optional return values are not implemented")
703 ResolveType(json_param, param_map) 769 ResolveType(json_param, param_map)
704 prep.append(tmpl_prep_output.substitute(param_map)) 770 prep.append(tmpl_prep_output.substitute(param_map))
705 args.append(tmpl_arg_output.substitute(param_map)) 771 args.append(param_map["arg_out"])
706 if not "wrap" in param_map: 772 if not "wrap" in param_map:
707 raise Exception("Arrays of arrays are not implemented") 773 raise Exception("Arrays of arrays are not implemented")
708 wrap.append(param_map["wrap"]) 774 wrap.append(param_map["wrap"])
709 775
710 args_str = "" 776 args_str = ""
711 if len(args) > 0: 777 if len(args) > 0:
712 args_str = "\n " + ",\n ".join(args) 778 args_str = "\n " + ",\n ".join(args)
713 handler_method_impls.append(tmpl_callback_impl.substitute(command_map, 779 handler_method_impls.append(tmpl_callback_impl.substitute(command_map,
714 prep = "".join(prep), 780 prep = "".join(prep),
715 args = args_str, 781 args = args_str,
(...skipping 26 matching lines...) Expand all
742 if domain_empty: 808 if domain_empty:
743 continue 809 continue
744 type_decls.append(tmpl_handler.substitute(domain_map)) 810 type_decls.append(tmpl_handler.substitute(domain_map))
745 setters.append(tmpl_setter.substitute(domain_map)) 811 setters.append(tmpl_setter.substitute(domain_map))
746 fields.append(tmpl_field.substitute(domain_map)) 812 fields.append(tmpl_field.substitute(domain_map))
747 includes.append(tmpl_include.substitute(domain_map)) 813 includes.append(tmpl_include.substitute(domain_map))
748 fields_init.append(tmpl_field_init.substitute(domain_map)) 814 fields_init.append(tmpl_field_init.substitute(domain_map))
749 if domain_needs_client: 815 if domain_needs_client:
750 type_decls.append(tmpl_client.substitute(domain_map, 816 type_decls.append(tmpl_client.substitute(domain_map,
751 methods = "".join(client_methods))) 817 methods = "".join(client_methods)))
752 friends.append(tmpl_friend.substitute(domain_map))
753 initializations.append(tmpl_init_client.substitute(domain_map)) 818 initializations.append(tmpl_init_client.substitute(domain_map))
754 type_impls.append(tmpl_client_impl.substitute(domain_map, 819 type_impls.append(tmpl_client_impl.substitute(domain_map,
755 methods = "\n".join(client_method_impls))) 820 methods = "\n".join(client_method_impls)))
756 handler_method_impls.append(tmpl_setter_impl.substitute(domain_map, 821 handler_method_impls.append(tmpl_setter_impl.substitute(domain_map,
757 initializations = "".join(initializations))) 822 initializations = "".join(initializations)))
758 823
759 824
760 output_h_file = open(output_h_path, "w") 825 output_h_file = open(output_h_path, "w")
761 output_cc_file = open(output_cc_path, "w") 826 output_cc_file = open(output_cc_path, "w")
762 827
763 output_h_file.write(template_h.substitute({}, 828 output_h_file.write(template_h.substitute({},
764 types = "\n".join(type_decls), 829 types = "\n".join(type_decls),
765 setters = "".join(setters), 830 setters = "".join(setters),
766 friends = "".join(friends),
767 methods = "".join(handler_methods), 831 methods = "".join(handler_methods),
768 fields = "".join(fields))) 832 fields = "".join(fields)))
769 output_h_file.close() 833 output_h_file.close()
770 834
771 output_cc_file.write(template_cc.substitute({}, 835 output_cc_file.write(template_cc.substitute({},
772 includes = "".join(sorted(includes)), 836 includes = "".join(sorted(includes)),
773 fields_init = ",\n ".join(fields_init), 837 fields_init = ",\n ".join(fields_init),
774 methods = "\n".join(handler_method_impls), 838 methods = "\n".join(handler_method_impls),
775 types = "\n".join(type_impls))) 839 types = "\n".join(type_impls)))
776 output_cc_file.close() 840 output_cc_file.close()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698