@@ -101,35 +101,35 @@ def init_defaults(config_tuple, path, defaults):
101101 config_base )
102102 config_json_file .close ()
103103 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" ,
126126 }
127127 for key_value in config_values :
128128 parts = key_value .split ("=" )
129129 if len (parts ) == 2 :
130130 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 )
133133 except Exception :
134134 # Work with python 2 and 3 http://docs.python.org/py3k/howto/pyporting.html
135135 exc = sys .exc_info ()[1 ]
@@ -286,32 +286,32 @@ def create_any_type_definition():
286286def create_string_type_definition ():
287287 # pylint: disable=W0622
288288 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
299299 }
300300
301301
302302def create_binary_type_definition ():
303303 # pylint: disable=W0622
304304 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
315315 }
316316
317317
@@ -333,17 +333,17 @@ def create_primitive_type_definition(type):
333333 "boolean" : "TypeBoolean" ,
334334 }
335335 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
347347 }
348348
349349def wrap_array_definition (type ):
@@ -444,10 +444,12 @@ def check_if_dependency_declared(self, domain, refs):
444444 domain_match = re .match (r'^(.*)[.]' , ref )
445445 if domain_match :
446446 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 )
451453
452454 def generate_used_types (self ):
453455 all_refs = set ()
@@ -552,10 +554,10 @@ def resolve_type(self, prop):
552554 return self .type_definitions [prop ["type" ]]
553555
554556 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" ))
559561
560562 def generate_command (self , domain , command ):
561563 if not self .config .protocol .options :
@@ -572,6 +574,12 @@ def generate_event(self, domain, event):
572574 def generate_type (self , domain , typename ):
573575 return domain + "." + typename in self .used_types
574576
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+
575583 def is_async_command (self , domain , command ):
576584 if not self .config .protocol .options :
577585 return False
@@ -658,25 +666,23 @@ def main():
658666 }
659667
660668 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" ))
663671 outputs [output_h ] = h_template .render (template_context )
664672 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" ))
667675 outputs [output_cpp ] = cpp_template .render (template_context )
668676 source_set .add (cpp_template .filename )
669677 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 )
674681 source_set .add (exported_template .filename )
675682 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 )
680686 source_set .add (imported_template .filename )
681687
682688 if config .lib :
@@ -699,19 +705,19 @@ def main():
699705
700706 if not config .use_embedder_types :
701707 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" ,
705711 ]
706712 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" ,
711717 ]
712718 else :
713719 protocol_h_templates += [
714- "Forward_h.template" ,
720+ "Forward_h.template" ,
715721 ]
716722
717723 def generate_lib_file (file_name , template_files ):
@@ -729,8 +735,9 @@ def generate_lib_file(file_name, template_files):
729735 config , "Protocol.h" )), protocol_h_templates )
730736
731737 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 )
734741
735742 if stamp_filename :
736743 with open (stamp_filename , "w" ):
@@ -748,8 +755,8 @@ def generate_lib_file(file_name, template_files):
748755 if deps_filename :
749756 assert stamp_filename
750757 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 ))))
753760
754761
755762if __name__ == "__main__" :
0 commit comments