| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 class CodeGeneratorV8(object): | 82 class CodeGeneratorV8(object): |
| 83 def __init__(self, interfaces_info, cache_dir): | 83 def __init__(self, interfaces_info, cache_dir): |
| 84 interfaces_info = interfaces_info or {} | 84 interfaces_info = interfaces_info or {} |
| 85 self.interfaces_info = interfaces_info | 85 self.interfaces_info = interfaces_info |
| 86 self.jinja_env = initialize_jinja_env(cache_dir) | 86 self.jinja_env = initialize_jinja_env(cache_dir) |
| 87 | 87 |
| 88 # Set global type info | 88 # Set global type info |
| 89 v8_types.set_ancestors(dict( | 89 v8_types.set_ancestors(dict( |
| 90 (interface_name, interface_info['ancestors']) | 90 (interface_name, interface_info['ancestors']) |
| 91 for interface_name, interface_info in interfaces_info.iteritems() | 91 for interface_name, interface_info in interfaces_info.iteritems() |
| 92 if 'ancestors' in interface_info)) | 92 if interface_info['ancestors'])) |
| 93 v8_types.set_callback_interfaces(set( | 93 v8_types.set_callback_interfaces(set( |
| 94 interface_name | 94 interface_name |
| 95 for interface_name, interface_info in interfaces_info.iteritems() | 95 for interface_name, interface_info in interfaces_info.iteritems() |
| 96 if interface_info['is_callback_interface'])) | 96 if interface_info['is_callback_interface'])) |
| 97 v8_types.set_implemented_as_interfaces(dict( | 97 v8_types.set_implemented_as_interfaces(dict( |
| 98 (interface_name, interface_info['implemented_as']) | 98 (interface_name, interface_info['implemented_as']) |
| 99 for interface_name, interface_info in interfaces_info.iteritems() | 99 for interface_name, interface_info in interfaces_info.iteritems() |
| 100 if 'implemented_as' in interface_info)) | 100 if interface_info['implemented_as'])) |
| 101 v8_types.set_will_be_garbage_collected_types(set( | 101 v8_types.set_will_be_garbage_collected_types(set( |
| 102 interface_name | 102 interface_name |
| 103 for interface_name, interface_info in interfaces_info.iteritems() | 103 for interface_name, interface_info in interfaces_info.iteritems() |
| 104 if 'inherited_extended_attributes' in interface_info and | 104 if 'WillBeGarbageCollected' in interface_info['inherited_extended_at
tributes'])) |
| 105 'WillBeGarbageCollected' in interface_info['inherited_extended_a
ttributes'])) | |
| 106 | 105 |
| 107 def generate_code(self, definitions, interface_name): | 106 def generate_code(self, definitions, interface_name): |
| 108 """Returns .h/.cpp code as (header_text, cpp_text).""" | 107 """Returns .h/.cpp code as (header_text, cpp_text).""" |
| 109 try: | 108 try: |
| 110 interface = definitions.interfaces[interface_name] | 109 interface = definitions.interfaces[interface_name] |
| 111 except KeyError: | 110 except KeyError: |
| 112 raise Exception('%s not in IDL definitions' % interface_name) | 111 raise Exception('%s not in IDL definitions' % interface_name) |
| 113 | 112 |
| 114 # Store other interfaces for introspection | 113 # Store other interfaces for introspection |
| 115 interfaces.update(definitions.interfaces) | 114 interfaces.update(definitions.interfaces) |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 | 204 |
| 206 # Create a dummy file as output for the build system, | 205 # Create a dummy file as output for the build system, |
| 207 # since filenames of individual cache files are unpredictable and opaque | 206 # since filenames of individual cache files are unpredictable and opaque |
| 208 # (they are hashes of the template path, which varies based on environment) | 207 # (they are hashes of the template path, which varies based on environment) |
| 209 with open(dummy_filename, 'w') as dummy_file: | 208 with open(dummy_filename, 'w') as dummy_file: |
| 210 pass # |open| creates or touches the file | 209 pass # |open| creates or touches the file |
| 211 | 210 |
| 212 | 211 |
| 213 if __name__ == '__main__': | 212 if __name__ == '__main__': |
| 214 sys.exit(main(sys.argv)) | 213 sys.exit(main(sys.argv)) |
| OLD | NEW |