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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 definitions.dictionaries[definition_name]) | 174 definitions.dictionaries[definition_name]) |
175 raise ValueError('%s is not in IDL definitions' % definition_name) | 175 raise ValueError('%s is not in IDL definitions' % definition_name) |
176 | 176 |
177 def generate_interface_code(self, definitions, interface_name, interface): | 177 def generate_interface_code(self, definitions, interface_name, interface): |
178 interface_info = self.info_provider.interfaces_info[interface_name] | 178 interface_info = self.info_provider.interfaces_info[interface_name] |
179 full_path = interface_info.get('full_path') | 179 full_path = interface_info.get('full_path') |
180 component = idl_filename_to_component(full_path) | 180 component = idl_filename_to_component(full_path) |
181 include_paths = interface_info.get('dependencies_include_paths') | 181 include_paths = interface_info.get('dependencies_include_paths') |
182 | 182 |
183 # Select appropriate Jinja template and contents function | 183 # Select appropriate Jinja template and contents function |
184 if interface.is_callback: | 184 # |
| 185 # A callback interface with constants needs a special handling. |
| 186 # https://heycam.github.io/webidl/#legacy-callback-interface-object |
| 187 if interface.is_callback and len(interface.constants) > 0: |
| 188 header_template_filename = 'legacy_callback_interface.h.tmpl' |
| 189 cpp_template_filename = 'legacy_callback_interface.cpp.tmpl' |
| 190 interface_context = v8_callback_interface.legacy_callback_interface_
context |
| 191 elif interface.is_callback: |
185 header_template_filename = 'callback_interface.h.tmpl' | 192 header_template_filename = 'callback_interface.h.tmpl' |
186 cpp_template_filename = 'callback_interface.cpp.tmpl' | 193 cpp_template_filename = 'callback_interface.cpp.tmpl' |
187 interface_context = v8_callback_interface.callback_interface_context | 194 interface_context = v8_callback_interface.callback_interface_context |
188 elif interface.is_partial: | 195 elif interface.is_partial: |
189 interface_context = v8_interface.interface_context | 196 interface_context = v8_interface.interface_context |
190 header_template_filename = 'partial_interface.h.tmpl' | 197 header_template_filename = 'partial_interface.h.tmpl' |
191 cpp_template_filename = 'partial_interface.cpp.tmpl' | 198 cpp_template_filename = 'partial_interface.cpp.tmpl' |
192 interface_name += 'Partial' | 199 interface_name += 'Partial' |
193 assert component == 'core' | 200 assert component == 'core' |
194 component = 'modules' | 201 component = 'modules' |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 outputs = set() | 392 outputs = set() |
386 for callback_function_dict in callback_functions.itervalues(): | 393 for callback_function_dict in callback_functions.itervalues(): |
387 if callback_function_dict['component_dir'] != self.target_component: | 394 if callback_function_dict['component_dir'] != self.target_component: |
388 continue | 395 continue |
389 callback_function = callback_function_dict['callback_function'] | 396 callback_function = callback_function_dict['callback_function'] |
390 if 'Custom' in callback_function.extended_attributes: | 397 if 'Custom' in callback_function.extended_attributes: |
391 continue | 398 continue |
392 path = callback_function_dict['full_path'] | 399 path = callback_function_dict['full_path'] |
393 outputs.update(self.generate_code_internal(callback_function, path)) | 400 outputs.update(self.generate_code_internal(callback_function, path)) |
394 return outputs | 401 return outputs |
OLD | NEW |