| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 3 # for details. All rights reserved. Use of this source code is governed by a | 3 # for details. All rights reserved. Use of this source code is governed by a |
| 4 # BSD-style license that can be found in the LICENSE file. | 4 # BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 """This module provides shared functionality for the system to generate | 6 """This module provides shared functionality for the system to generate |
| 7 dart:html APIs from the IDL database.""" | 7 dart:html APIs from the IDL database.""" |
| 8 | 8 |
| 9 import emitter | 9 import emitter |
| 10 from generator import AnalyzeOperation, ConstantOutputOrder, \ | 10 from generator import AnalyzeOperation, ConstantOutputOrder, \ |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 'Location': 'LocationBase', | 30 'Location': 'LocationBase', |
| 31 'History': 'HistoryBase', | 31 'History': 'HistoryBase', |
| 32 } | 32 } |
| 33 | 33 |
| 34 _custom_factories = [ | 34 _custom_factories = [ |
| 35 'Notification', | 35 'Notification', |
| 36 'EventSource', | 36 'EventSource', |
| 37 ] | 37 ] |
| 38 | 38 |
| 39 class HtmlDartGenerator(object): | 39 class HtmlDartGenerator(object): |
| 40 def __init__(self, interface, options, dart_use_blink): | 40 def __init__(self, interface, options, dart_use_blink, logger): |
| 41 self._dart_use_blink = dart_use_blink | 41 self._dart_use_blink = dart_use_blink |
| 42 self._database = options.database | 42 self._database = options.database |
| 43 self._interface = interface | 43 self._interface = interface |
| 44 self._type_registry = options.type_registry | 44 self._type_registry = options.type_registry |
| 45 self._interface_type_info = self._type_registry.TypeInfo(self._interface.id) | 45 self._interface_type_info = self._type_registry.TypeInfo(self._interface.id) |
| 46 self._renamer = options.renamer | 46 self._renamer = options.renamer |
| 47 self._metadata = options.metadata | 47 self._metadata = options.metadata |
| 48 self._library_name = self._renamer.GetLibraryName(self._interface) | 48 self._library_name = self._renamer.GetLibraryName(self._interface) |
| 49 _logger.setLevel(logger.level) |
| 49 | 50 |
| 50 def EmitSupportCheck(self): | 51 def EmitSupportCheck(self): |
| 51 if self.HasSupportCheck(): | 52 if self.HasSupportCheck(): |
| 52 check = self.GetSupportCheck() | 53 check = self.GetSupportCheck() |
| 53 if type(check) != tuple: | 54 if type(check) != tuple: |
| 54 signature = 'get supported' | 55 signature = 'get supported' |
| 55 else: | 56 else: |
| 56 signature = check[0] | 57 signature = check[0] |
| 57 check = check[1] | 58 check = check[1] |
| 58 self._members_emitter.Emit('\n' | 59 self._members_emitter.Emit('\n' |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 len(filter(lambda overload: overload.startswith(operation_str), | 246 len(filter(lambda overload: overload.startswith(operation_str), |
| 246 renamed_overloads.keys())) == 0 and | 247 renamed_overloads.keys())) == 0 and |
| 247 operation_str not in keep_overloaded_members and | 248 operation_str not in keep_overloaded_members and |
| 248 operation_str not in overloaded_and_renamed and | 249 operation_str not in overloaded_and_renamed and |
| 249 operation_str not in renamed_html_members and | 250 operation_str not in renamed_html_members and |
| 250 operation_str not in private_html_members and | 251 operation_str not in private_html_members and |
| 251 operation_str not in removed_html_members and | 252 operation_str not in removed_html_members and |
| 252 operation.id != '__getter__' and | 253 operation.id != '__getter__' and |
| 253 operation.id != '__setter__' and | 254 operation.id != '__setter__' and |
| 254 operation.id != '__delete__'): | 255 operation.id != '__delete__'): |
| 255 _logger.error('Multiple type signatures for %s.%s. Please file a bug with' | 256 _logger.warn('Multiple type signatures for %s.%s. Please file a bug with' |
| 256 ' the dart:html team to determine if one of these functions should be' | 257 ' the dart:html team to determine if one of these functions should be' |
| 257 ' renamed.' % ( | 258 ' renamed.' % ( |
| 258 interface.id, operation.id)) | 259 interface.id, operation.id)) |
| 259 | 260 |
| 260 def _GetStringRepresentation(self, interface, operation): | 261 def _GetStringRepresentation(self, interface, operation): |
| 261 """Given an IDLOperation, return a object-independent representation of the | 262 """Given an IDLOperation, return a object-independent representation of the |
| 262 operations's signature.""" | 263 operations's signature.""" |
| 263 return '%s.%s(%s)' % (interface.id, operation.id, ', '.join( | 264 return '%s.%s(%s)' % (interface.id, operation.id, ', '.join( |
| 264 ['%s %s' % (arg.type.id, arg.id) for arg in operation.arguments])) | 265 ['%s %s' % (arg.type.id, arg.id) for arg in operation.arguments])) |
| 265 | 266 |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 887 def _InputType(self, type_name, info): | 888 def _InputType(self, type_name, info): |
| 888 conversion = self._InputConversion(type_name, info.declared_name) | 889 conversion = self._InputConversion(type_name, info.declared_name) |
| 889 if conversion: | 890 if conversion: |
| 890 return conversion.input_type | 891 return conversion.input_type |
| 891 else: | 892 else: |
| 892 # If typedef it's a union return dynamic. | 893 # If typedef it's a union return dynamic. |
| 893 if self._database.HasTypeDef(type_name): | 894 if self._database.HasTypeDef(type_name): |
| 894 return 'dynamic' | 895 return 'dynamic' |
| 895 else: | 896 else: |
| 896 return self._NarrowInputType(type_name) if type_name else 'dynamic' | 897 return self._NarrowInputType(type_name) if type_name else 'dynamic' |
| OLD | NEW |