@@ -101,35 +101,35 @@ def init_defaults(config_tuple, path, defaults): |
101 | 101 | config_base) |
102 | 102 | config_json_file.close() |
103 | 103 | defaults = { |
104 | | - ".use_snake_file_names": False, |
105 | | - ".use_title_case_methods": False, |
106 | | - ".use_embedder_types": False, |
107 | | - ".imported": False, |
108 | | - ".imported.export_macro": "", |
109 | | - ".imported.export_header": False, |
110 | | - ".imported.header": False, |
111 | | - ".imported.package": False, |
112 | | - ".imported.options": False, |
113 | | - ".protocol.export_macro": "", |
114 | | - ".protocol.export_header": False, |
115 | | - ".protocol.options": False, |
116 | | - ".protocol.file_name_prefix": "", |
117 | | - ".exported": False, |
118 | | - ".exported.export_macro": "", |
119 | | - ".exported.export_header": False, |
120 | | - ".lib": False, |
121 | | - ".lib.export_macro": "", |
122 | | - ".lib.export_header": False, |
123 | | - ".crdtp": False, |
124 | | - ".crdtp.dir": os.path.join(inspector_protocol_dir, "crdtp"), |
125 | | - ".crdtp.namespace": "crdtp", |
| 104 | + ".use_snake_file_names": False, |
| 105 | + ".use_title_case_methods": False, |
| 106 | + ".use_embedder_types": False, |
| 107 | + ".imported": False, |
| 108 | + ".imported.export_macro": "", |
| 109 | + ".imported.export_header": False, |
| 110 | + ".imported.header": False, |
| 111 | + ".imported.package": False, |
| 112 | + ".imported.options": False, |
| 113 | + ".protocol.export_macro": "", |
| 114 | + ".protocol.export_header": False, |
| 115 | + ".protocol.options": False, |
| 116 | + ".protocol.file_name_prefix": "", |
| 117 | + ".exported": False, |
| 118 | + ".exported.export_macro": "", |
| 119 | + ".exported.export_header": False, |
| 120 | + ".lib": False, |
| 121 | + ".lib.export_macro": "", |
| 122 | + ".lib.export_header": False, |
| 123 | + ".crdtp": False, |
| 124 | + ".crdtp.dir": os.path.join(inspector_protocol_dir, "crdtp"), |
| 125 | + ".crdtp.namespace": "crdtp", |
126 | 126 | } |
127 | 127 | for key_value in config_values: |
128 | 128 | parts = key_value.split("=") |
129 | 129 | if len(parts) == 2: |
130 | 130 | defaults["." + parts[0]] = parts[1] |
131 | | - return (jinja_dir, config_file, init_defaults(config_partial, "", defaults), |
132 | | - depfile, stamp) |
| 131 | + return (jinja_dir, config_file, init_defaults(config_partial, "", |
| 132 | + defaults), depfile, stamp) |
133 | 133 | except Exception: |
134 | 134 | # Work with python 2 and 3 http://docs.python.org/py3k/howto/pyporting.html |
135 | 135 | exc = sys.exc_info()[1] |
@@ -286,32 +286,32 @@ def create_any_type_definition(): |
286 | 286 | def create_string_type_definition(): |
287 | 287 | # pylint: disable=W0622 |
288 | 288 | return { |
289 | | - "return_type": "String", |
290 | | - "pass_type": "const String&", |
291 | | - "to_pass_type": "%s", |
292 | | - "to_raw_type": "%s", |
293 | | - "to_rvalue": "%s", |
294 | | - "type": "String", |
295 | | - "raw_type": "String", |
296 | | - "raw_pass_type": "const String&", |
297 | | - "raw_return_type": "String", |
298 | | - "is_primitive": True |
| 289 | + "return_type": "String", |
| 290 | + "pass_type": "const String&", |
| 291 | + "to_pass_type": "%s", |
| 292 | + "to_raw_type": "%s", |
| 293 | + "to_rvalue": "%s", |
| 294 | + "type": "String", |
| 295 | + "raw_type": "String", |
| 296 | + "raw_pass_type": "const String&", |
| 297 | + "raw_return_type": "String", |
| 298 | + "is_primitive": True |
299 | 299 | } |
300 | 300 |
|
301 | 301 |
|
302 | 302 | def create_binary_type_definition(): |
303 | 303 | # pylint: disable=W0622 |
304 | 304 | return { |
305 | | - "return_type": "Binary", |
306 | | - "pass_type": "const Binary&", |
307 | | - "to_pass_type": "%s", |
308 | | - "to_raw_type": "%s", |
309 | | - "to_rvalue": "%s", |
310 | | - "type": "Binary", |
311 | | - "raw_type": "Binary", |
312 | | - "raw_pass_type": "const Binary&", |
313 | | - "raw_return_type": "Binary", |
314 | | - "is_primitive": True |
| 305 | + "return_type": "Binary", |
| 306 | + "pass_type": "const Binary&", |
| 307 | + "to_pass_type": "%s", |
| 308 | + "to_raw_type": "%s", |
| 309 | + "to_rvalue": "%s", |
| 310 | + "type": "Binary", |
| 311 | + "raw_type": "Binary", |
| 312 | + "raw_pass_type": "const Binary&", |
| 313 | + "raw_return_type": "Binary", |
| 314 | + "is_primitive": True |
315 | 315 | } |
316 | 316 |
|
317 | 317 |
|
@@ -333,17 +333,17 @@ def create_primitive_type_definition(type): |
333 | 333 | "boolean": "TypeBoolean", |
334 | 334 | } |
335 | 335 | return { |
336 | | - "return_type": typedefs[type], |
337 | | - "pass_type": typedefs[type], |
338 | | - "to_pass_type": "%s", |
339 | | - "to_raw_type": "%s", |
340 | | - "to_rvalue": "%s", |
341 | | - "type": typedefs[type], |
342 | | - "raw_type": typedefs[type], |
343 | | - "raw_pass_type": typedefs[type], |
344 | | - "raw_return_type": typedefs[type], |
345 | | - "default_value": defaults[type], |
346 | | - "is_primitive": True |
| 336 | + "return_type": typedefs[type], |
| 337 | + "pass_type": typedefs[type], |
| 338 | + "to_pass_type": "%s", |
| 339 | + "to_raw_type": "%s", |
| 340 | + "to_rvalue": "%s", |
| 341 | + "type": typedefs[type], |
| 342 | + "raw_type": typedefs[type], |
| 343 | + "raw_pass_type": typedefs[type], |
| 344 | + "raw_return_type": typedefs[type], |
| 345 | + "default_value": defaults[type], |
| 346 | + "is_primitive": True |
347 | 347 | } |
348 | 348 |
|
349 | 349 | def wrap_array_definition(type): |
@@ -444,10 +444,12 @@ def check_if_dependency_declared(self, domain, refs): |
444 | 444 | domain_match = re.match(r'^(.*)[.]', ref) |
445 | 445 | if domain_match: |
446 | 446 | referenced_domain_name = domain_match.group(1) |
447 | | - if referenced_domain_name != domain['domain'] and not referenced_domain_name in dependencies: |
448 | | - sys.stderr.write(("Domains [%s] uses type [%s] from domain [%s], but did not declare the dependency\n\n" |
449 | | - ) % (domain["domain"], ref, referenced_domain_name)) |
450 | | - exit(1) |
| 447 | + if referenced_domain_name != domain[ |
| 448 | + 'domain'] and not referenced_domain_name in dependencies: |
| 449 | + sys.stderr.write(( |
| 450 | + "Domains [%s] uses type [%s] from domain [%s], but did not declare the dependency\n\n" |
| 451 | + ) % (domain["domain"], ref, referenced_domain_name)) |
| 452 | + exit(1) |
451 | 453 |
|
452 | 454 | def generate_used_types(self): |
453 | 455 | all_refs = set() |
@@ -552,10 +554,10 @@ def resolve_type(self, prop): |
552 | 554 | return self.type_definitions[prop["type"]] |
553 | 555 |
|
554 | 556 | def optional_type(self, prop): |
555 | | - type = self.resolve_type(prop) |
556 | | - template = ("std::optional<{}>" if type.get('is_primitive', False) |
557 | | - else "std::unique_ptr<{}>") |
558 | | - return template.format(type.get("raw_type")) |
| 557 | + type = self.resolve_type(prop) |
| 558 | + template = ("std::optional<{}>" |
| 559 | + if type.get('is_primitive', False) else "std::unique_ptr<{}>") |
| 560 | + return template.format(type.get("raw_type")) |
559 | 561 |
|
560 | 562 | def generate_command(self, domain, command): |
561 | 563 | if not self.config.protocol.options: |
@@ -572,6 +574,12 @@ def generate_event(self, domain, event): |
572 | 574 | def generate_type(self, domain, typename): |
573 | 575 | return domain + "." + typename in self.used_types |
574 | 576 |
|
| 577 | + def should_pass_associated_data(self, domain, command): |
| 578 | + if not self.config.protocol.options: |
| 579 | + return False |
| 580 | + return self.check_options(self.config.protocol.options, domain, command, |
| 581 | + "pass_associated_data", None, False) |
| 582 | + |
575 | 583 | def is_async_command(self, domain, command): |
576 | 584 | if not self.config.protocol.options: |
577 | 585 | return False |
@@ -658,25 +666,23 @@ def main(): |
658 | 666 | } |
659 | 667 |
|
660 | 668 | if domain["domain"] in protocol.generate_domains: |
661 | | - output_h = os.path.join(config.protocol.output, to_file_name( |
662 | | - config, file_name + ".h")) |
| 669 | + output_h = os.path.join(config.protocol.output, |
| 670 | + to_file_name(config, file_name + ".h")) |
663 | 671 | outputs[output_h] = h_template.render(template_context) |
664 | 672 | source_set.add(h_template.filename) |
665 | | - output_cpp = os.path.join(config.protocol.output, to_file_name( |
666 | | - config, file_name + ".cpp")) |
| 673 | + output_cpp = os.path.join(config.protocol.output, |
| 674 | + to_file_name(config, file_name + ".cpp")) |
667 | 675 | outputs[output_cpp] = cpp_template.render(template_context) |
668 | 676 | source_set.add(cpp_template.filename) |
669 | 677 | if domain["domain"] in protocol.exported_domains: |
670 | | - output_export_h = os.path.join(config.exported.output, to_file_name( |
671 | | - config, file_name + ".h")) |
672 | | - outputs[output_export_h] = exported_template.render( |
673 | | - template_context) |
| 678 | + output_export_h = os.path.join(config.exported.output, |
| 679 | + to_file_name(config, file_name + ".h")) |
| 680 | + outputs[output_export_h] = exported_template.render(template_context) |
674 | 681 | source_set.add(exported_template.filename) |
675 | 682 | if domain["domain"] in protocol.imported_domains: |
676 | | - output_import_h = os.path.join(config.protocol.output, to_file_name( |
677 | | - config, file_name + ".h")) |
678 | | - outputs[output_import_h] = imported_template.render( |
679 | | - template_context) |
| 683 | + output_import_h = os.path.join(config.protocol.output, |
| 684 | + to_file_name(config, file_name + ".h")) |
| 685 | + outputs[output_import_h] = imported_template.render(template_context) |
680 | 686 | source_set.add(imported_template.filename) |
681 | 687 |
|
682 | 688 | if config.lib: |
@@ -699,19 +705,19 @@ def main(): |
699 | 705 |
|
700 | 706 | if not config.use_embedder_types: |
701 | 707 | protocol_h_templates += [ |
702 | | - "Values_h.template", |
703 | | - "Object_h.template", |
704 | | - "ValueConversions_h.template", |
| 708 | + "Values_h.template", |
| 709 | + "Object_h.template", |
| 710 | + "ValueConversions_h.template", |
705 | 711 | ] |
706 | 712 | protocol_cpp_templates += [ |
707 | | - "Protocol_cpp.template", |
708 | | - "Values_cpp.template", |
709 | | - "Object_cpp.template", |
710 | | - "ValueConversions_cpp.template", |
| 713 | + "Protocol_cpp.template", |
| 714 | + "Values_cpp.template", |
| 715 | + "Object_cpp.template", |
| 716 | + "ValueConversions_cpp.template", |
711 | 717 | ] |
712 | 718 | else: |
713 | 719 | protocol_h_templates += [ |
714 | | - "Forward_h.template", |
| 720 | + "Forward_h.template", |
715 | 721 | ] |
716 | 722 |
|
717 | 723 | def generate_lib_file(file_name, template_files): |
@@ -729,8 +735,9 @@ def generate_lib_file(file_name, template_files): |
729 | 735 | config, "Protocol.h")), protocol_h_templates) |
730 | 736 |
|
731 | 737 | if not config.use_embedder_types: |
732 | | - generate_lib_file(os.path.join(config.lib.output, to_file_name( |
733 | | - config, "Protocol.cpp")), protocol_cpp_templates) |
| 738 | + generate_lib_file( |
| 739 | + os.path.join(config.lib.output, to_file_name(config, "Protocol.cpp")), |
| 740 | + protocol_cpp_templates) |
734 | 741 |
|
735 | 742 | if stamp_filename: |
736 | 743 | with open(stamp_filename, "w"): |
@@ -748,8 +755,8 @@ def generate_lib_file(file_name, template_files): |
748 | 755 | if deps_filename: |
749 | 756 | assert stamp_filename |
750 | 757 | with open(deps_filename, "w") as deps_file: |
751 | | - deps_file.write("%s: %s\n" % ( |
752 | | - stamp_filename, " ".join(sorted(source_set)))) |
| 758 | + deps_file.write("%s: %s\n" % |
| 759 | + (stamp_filename, " ".join(sorted(source_set)))) |
753 | 760 |
|
754 | 761 |
|
755 | 762 | if __name__ == "__main__": |
|