| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 IdlType.set_garbage_collected_types(interfaces_info['garbage_collect
ed_interfaces']) | 122 IdlType.set_garbage_collected_types(interfaces_info['garbage_collect
ed_interfaces']) |
| 123 if 'will_be_garbage_collected_interfaces' in interfaces_info: | 123 if 'will_be_garbage_collected_interfaces' in interfaces_info: |
| 124 IdlType.set_will_be_garbage_collected_types(interfaces_info['will_be
_garbage_collected_interfaces']) | 124 IdlType.set_will_be_garbage_collected_types(interfaces_info['will_be
_garbage_collected_interfaces']) |
| 125 if 'component_dirs' in interfaces_info: | 125 if 'component_dirs' in interfaces_info: |
| 126 dart_types.set_component_dirs(interfaces_info['component_dirs']) | 126 dart_types.set_component_dirs(interfaces_info['component_dirs']) |
| 127 | 127 |
| 128 def generate_code(self, definitions, interface_name, idl_pickle_filename, | 128 def generate_code(self, definitions, interface_name, idl_pickle_filename, |
| 129 only_if_changed): | 129 only_if_changed): |
| 130 """Returns .h/.cpp code as (header_text, cpp_text).""" | 130 """Returns .h/.cpp code as (header_text, cpp_text).""" |
| 131 | 131 |
| 132 IdlType.set_enums((enum.name, enum.values) |
| 133 for enum in definitions.enumerations.values()) |
| 134 |
| 132 if interface_name in definitions.interfaces: | 135 if interface_name in definitions.interfaces: |
| 133 interface = definitions.interfaces[interface_name] | 136 interface = definitions.interfaces[interface_name] |
| 134 elif interface_name in definitions.dictionaries: | 137 elif interface_name in definitions.dictionaries: |
| 135 output_code_list = self.generate_dictionary_code( | 138 output_code_list = self.generate_dictionary_code( |
| 136 definitions, interface_name, | 139 definitions, interface_name, |
| 137 definitions.dictionaries[interface_name]) | 140 definitions.dictionaries[interface_name]) |
| 138 | 141 |
| 139 # Pickle the dictionary information... | 142 # Pickle the dictionary information... |
| 140 idl_world = self.load_idl_pickle_file(idl_pickle_filename) | 143 idl_world = self.load_idl_pickle_file(idl_pickle_filename) |
| 141 idl_world['dictionary'] = {'name': interface_name} | 144 idl_world['dictionary'] = {'name': interface_name} |
| 142 write_pickle_file(idl_pickle_filename, idl_world, only_if_changed) | 145 write_pickle_file(idl_pickle_filename, idl_world, only_if_changed) |
| 143 | 146 |
| 144 return output_code_list | 147 return output_code_list |
| 145 else: | 148 else: |
| 146 raise ValueError('%s is not in IDL definitions' % interface_name) | 149 raise ValueError('%s is not in IDL definitions' % interface_name) |
| 147 | 150 |
| 148 # Store other interfaces for introspection | 151 # Store other interfaces for introspection |
| 149 interfaces.update(definitions.interfaces) | 152 interfaces.update(definitions.interfaces) |
| 150 | 153 |
| 151 # Set local type info | 154 # Set local type info |
| 152 IdlType.set_callback_functions(definitions.callback_functions.keys()) | 155 IdlType.set_callback_functions(definitions.callback_functions.keys()) |
| 153 IdlType.set_enums((enum.name, enum.values) | |
| 154 for enum in definitions.enumerations.values()) | |
| 155 | 156 |
| 156 # Select appropriate Jinja template and contents function | 157 # Select appropriate Jinja template and contents function |
| 157 if interface.is_callback: | 158 if interface.is_callback: |
| 158 header_template_filename = 'callback_interface_h.template' | 159 header_template_filename = 'callback_interface_h.template' |
| 159 cpp_template_filename = 'callback_interface_cpp.template' | 160 cpp_template_filename = 'callback_interface_cpp.template' |
| 160 generate_contents = dart_callback_interface.generate_callback_interf
ace | 161 generate_contents = dart_callback_interface.generate_callback_interf
ace |
| 161 else: | 162 else: |
| 162 header_template_filename = 'interface_h.template' | 163 header_template_filename = 'interface_h.template' |
| 163 cpp_template_filename = 'interface_cpp.template' | 164 cpp_template_filename = 'interface_cpp.template' |
| 164 generate_contents = dart_interface.interface_context | 165 generate_contents = dart_interface.interface_context |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 | 385 |
| 385 # Create a dummy file as output for the build system, | 386 # Create a dummy file as output for the build system, |
| 386 # since filenames of individual cache files are unpredictable and opaque | 387 # since filenames of individual cache files are unpredictable and opaque |
| 387 # (they are hashes of the template path, which varies based on environment) | 388 # (they are hashes of the template path, which varies based on environment) |
| 388 with open(dummy_filename, 'w') as dummy_file: | 389 with open(dummy_filename, 'w') as dummy_file: |
| 389 pass # |open| creates or touches the file | 390 pass # |open| creates or touches the file |
| 390 | 391 |
| 391 | 392 |
| 392 if __name__ == '__main__': | 393 if __name__ == '__main__': |
| 393 sys.exit(main(sys.argv)) | 394 sys.exit(main(sys.argv)) |
| OLD | NEW |