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

Side by Side Diff: sky/engine/bindings/scripts/code_generator_dart.py

Issue 1171743002: Change the way we provide custom dart code for IDL bindings. (Closed) Base URL: git@github.com:/domokit/mojo.git@master
Patch Set: Created 5 years, 6 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 # Copyright (C) 2013 Google Inc. All rights reserved. 1 # Copyright (C) 2013 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 template_contents['code_generator'] = module_pyname 142 template_contents['code_generator'] = module_pyname
143 143
144 # Add includes for interface itself and any dependencies 144 # Add includes for interface itself and any dependencies
145 interface_info = self.interfaces_info[interface_name] 145 interface_info = self.interfaces_info[interface_name]
146 template_contents['header_includes'].add(interface_info['include_path']) 146 template_contents['header_includes'].add(interface_info['include_path'])
147 template_contents['header_includes'] = sorted(template_contents['header_ includes']) 147 template_contents['header_includes'] = sorted(template_contents['header_ includes'])
148 includes.update(interface_info.get('dependencies_include_paths', [])) 148 includes.update(interface_info.get('dependencies_include_paths', []))
149 149
150 template_contents['cpp_includes'] = sorted(includes) 150 template_contents['cpp_includes'] = sorted(includes)
151 151
152 # If CustomDart is set, read the custom dart file and add it to our 152 # If PrivateDart is set, read the custom dart file and add it to our
153 # template parameters. 153 # template parameters.
154 if 'CustomDart' in interface.extended_attributes: 154 if 'PrivateDart' in interface.extended_attributes:
155 dart_filename = os.path.join(os.path.dirname(idl_filename), 155 template_contents['private_dart'] = True
156 interface.name + ".dart")
157 with open(dart_filename) as dart_file:
158 custom_dartcode = dart_file.read()
159 template_contents['custom_dartcode'] = custom_dartcode
160 156
161 idl_world = {'interface': None, 'callback': None} 157 idl_world = {'interface': None, 'callback': None}
162 158
163 # Load the pickle file for this IDL. 159 # Load the pickle file for this IDL.
164 if os.path.isfile(idl_pickle_filename): 160 if os.path.isfile(idl_pickle_filename):
165 with open(idl_pickle_filename) as idl_pickle_file: 161 with open(idl_pickle_filename) as idl_pickle_file:
166 idl_global_data = pickle.load(idl_pickle_file) 162 idl_global_data = pickle.load(idl_pickle_file)
167 idl_pickle_file.close() 163 idl_pickle_file.close()
168 idl_world['interface'] = idl_global_data['interface'] 164 idl_world['interface'] = idl_global_data['interface']
169 idl_world['callback'] = idl_global_data['callback'] 165 idl_world['callback'] = idl_global_data['callback']
(...skipping 24 matching lines...) Expand all
194 # List of all interfaces and callbacks for global code generation. 190 # List of all interfaces and callbacks for global code generation.
195 world = {'interfaces': [], 'callbacks': []} 191 world = {'interfaces': [], 'callbacks': []}
196 192
197 # Load all pickled data for each interface. 193 # Load all pickled data for each interface.
198 for (directory, file_list) in global_entries: 194 for (directory, file_list) in global_entries:
199 for filename in file_list: 195 for filename in file_list:
200 if os.path.splitext(filename)[1] == '.dart': 196 if os.path.splitext(filename)[1] == '.dart':
201 # Special case: any .dart files in the list should be added 197 # Special case: any .dart files in the list should be added
202 # to dart_sky.dart directly, but don't need to be processed. 198 # to dart_sky.dart directly, but don't need to be processed.
203 interface_name = os.path.splitext(os.path.basename(filename) )[0] 199 interface_name = os.path.splitext(os.path.basename(filename) )[0]
204 world['interfaces'].append({'name': interface_name}) 200 world['interfaces'].append({'name': "Custom" + interface_nam e})
205 continue 201 continue
206 interface_name = idl_filename_to_interface_name(filename) 202 interface_name = idl_filename_to_interface_name(filename)
207 idl_pickle_filename = interface_name + "_globals.pickle" 203 idl_pickle_filename = interface_name + "_globals.pickle"
208 idl_pickle_filename = os.path.join(directory, idl_pickle_filenam e) 204 idl_pickle_filename = os.path.join(directory, idl_pickle_filenam e)
209 if not os.path.exists(idl_pickle_filename): 205 if not os.path.exists(idl_pickle_filename):
210 logging.warn("Missing %s" % idl_pickle_filename) 206 logging.warn("Missing %s" % idl_pickle_filename)
211 continue 207 continue
212 with open(idl_pickle_filename) as idl_pickle_file: 208 with open(idl_pickle_filename) as idl_pickle_file:
213 idl_world = pickle.load(idl_pickle_file) 209 idl_world = pickle.load(idl_pickle_file)
214 if 'interface' in idl_world: 210 if 'interface' in idl_world:
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 283
288 # Create a dummy file as output for the build system, 284 # Create a dummy file as output for the build system,
289 # since filenames of individual cache files are unpredictable and opaque 285 # since filenames of individual cache files are unpredictable and opaque
290 # (they are hashes of the template path, which varies based on environment) 286 # (they are hashes of the template path, which varies based on environment)
291 with open(dummy_filename, 'w') as dummy_file: 287 with open(dummy_filename, 'w') as dummy_file:
292 pass # |open| creates or touches the file 288 pass # |open| creates or touches the file
293 289
294 290
295 if __name__ == '__main__': 291 if __name__ == '__main__':
296 sys.exit(main(sys.argv)) 292 sys.exit(main(sys.argv))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698