| OLD | NEW |
| 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 Loading... |
| 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 | |
| 153 # template parameters. | |
| 154 if 'CustomDart' in interface.extended_attributes: | |
| 155 dart_filename = os.path.join(os.path.dirname(idl_filename), | |
| 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 | |
| 161 idl_world = {'interface': None, 'callback': None} | 152 idl_world = {'interface': None, 'callback': None} |
| 162 | 153 |
| 163 # Load the pickle file for this IDL. | 154 # Load the pickle file for this IDL. |
| 164 if os.path.isfile(idl_pickle_filename): | 155 if os.path.isfile(idl_pickle_filename): |
| 165 with open(idl_pickle_filename) as idl_pickle_file: | 156 with open(idl_pickle_filename) as idl_pickle_file: |
| 166 idl_global_data = pickle.load(idl_pickle_file) | 157 idl_global_data = pickle.load(idl_pickle_file) |
| 167 idl_pickle_file.close() | 158 idl_pickle_file.close() |
| 168 idl_world['interface'] = idl_global_data['interface'] | 159 idl_world['interface'] = idl_global_data['interface'] |
| 169 idl_world['callback'] = idl_global_data['callback'] | 160 idl_world['callback'] = idl_global_data['callback'] |
| 170 | 161 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 189 dart_text = dart_template.render(template_contents) | 180 dart_text = dart_template.render(template_contents) |
| 190 | 181 |
| 191 return header_text, cpp_text, dart_text | 182 return header_text, cpp_text, dart_text |
| 192 | 183 |
| 193 def load_global_pickles(self, global_entries): | 184 def load_global_pickles(self, global_entries): |
| 194 # List of all interfaces and callbacks for global code generation. | 185 # List of all interfaces and callbacks for global code generation. |
| 195 world = {'interfaces': [], 'callbacks': []} | 186 world = {'interfaces': [], 'callbacks': []} |
| 196 | 187 |
| 197 # Load all pickled data for each interface. | 188 # Load all pickled data for each interface. |
| 198 for (directory, file_list) in global_entries: | 189 for (directory, file_list) in global_entries: |
| 199 for idl_filename in file_list: | 190 for filename in file_list: |
| 200 interface_name = idl_filename_to_interface_name(idl_filename) | 191 if os.path.splitext(filename)[1] == '.dart': |
| 192 # Special case: any .dart files in the list should be added |
| 193 # to dart_sky.dart directly, but don't need to be processed. |
| 194 interface_name = os.path.splitext(os.path.basename(filename)
)[0] |
| 195 world['interfaces'].append({'name': interface_name}) |
| 196 continue |
| 197 interface_name = idl_filename_to_interface_name(filename) |
| 201 idl_pickle_filename = interface_name + "_globals.pickle" | 198 idl_pickle_filename = interface_name + "_globals.pickle" |
| 202 idl_pickle_filename = os.path.join(directory, idl_pickle_filenam
e) | 199 idl_pickle_filename = os.path.join(directory, idl_pickle_filenam
e) |
| 203 if not os.path.exists(idl_pickle_filename): | 200 if not os.path.exists(idl_pickle_filename): |
| 204 logging.warn("Missing %s" % idl_pickle_filename) | 201 logging.warn("Missing %s" % idl_pickle_filename) |
| 205 continue | 202 continue |
| 206 with open(idl_pickle_filename) as idl_pickle_file: | 203 with open(idl_pickle_filename) as idl_pickle_file: |
| 207 idl_world = pickle.load(idl_pickle_file) | 204 idl_world = pickle.load(idl_pickle_file) |
| 208 if 'interface' in idl_world: | 205 if 'interface' in idl_world: |
| 209 # FIXME: Why are some of these None? | 206 # FIXME: Why are some of these None? |
| 210 if idl_world['interface']: | 207 if idl_world['interface']: |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 | 278 |
| 282 # Create a dummy file as output for the build system, | 279 # Create a dummy file as output for the build system, |
| 283 # since filenames of individual cache files are unpredictable and opaque | 280 # since filenames of individual cache files are unpredictable and opaque |
| 284 # (they are hashes of the template path, which varies based on environment) | 281 # (they are hashes of the template path, which varies based on environment) |
| 285 with open(dummy_filename, 'w') as dummy_file: | 282 with open(dummy_filename, 'w') as dummy_file: |
| 286 pass # |open| creates or touches the file | 283 pass # |open| creates or touches the file |
| 287 | 284 |
| 288 | 285 |
| 289 if __name__ == '__main__': | 286 if __name__ == '__main__': |
| 290 sys.exit(main(sys.argv)) | 287 sys.exit(main(sys.argv)) |
| OLD | NEW |