Chromium Code Reviews| 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 generates Dart APIs from the IDL database.""" | 6 """This module generates Dart APIs from the IDL database.""" |
| 7 | 7 |
| 8 import emitter | 8 import emitter |
| 9 import idlnode | 9 import idlnode |
| 10 import logging | 10 import logging |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 self._auxiliary_files = {} | 31 self._auxiliary_files = {} |
| 32 self._dart_templates_re = re.compile(r'[\w.:]+<([\w\.<>:]+)>') | 32 self._dart_templates_re = re.compile(r'[\w.:]+<([\w\.<>:]+)>') |
| 33 | 33 |
| 34 def _StripModules(self, type_name): | 34 def _StripModules(self, type_name): |
| 35 return type_name.split('::')[-1] | 35 return type_name.split('::')[-1] |
| 36 | 36 |
| 37 def _IsCompoundType(self, database, type_name): | 37 def _IsCompoundType(self, database, type_name): |
| 38 if IsPrimitiveType(type_name): | 38 if IsPrimitiveType(type_name): |
| 39 return True | 39 return True |
| 40 | 40 |
| 41 if type_name.endswith('?'): | |
| 42 return self._IsCompoundType(database, type_name[:-len('?')]) | |
| 43 | |
| 41 if type_name.endswith('[]'): | 44 if type_name.endswith('[]'): |
| 42 return self._IsCompoundType(database, type_name[:-len('[]')]) | 45 return self._IsCompoundType(database, type_name[:-len('[]')]) |
| 43 | 46 |
| 44 striped_type_name = self._StripModules(type_name) | 47 striped_type_name = self._StripModules(type_name) |
| 45 if database.HasInterface(striped_type_name): | 48 if database.HasInterface(striped_type_name): |
| 46 return True | 49 return True |
| 47 | 50 |
| 51 # Didn't recognize the name - perhaps it is one of the WebKit Array | |
| 52 # typedefs like MutationRecordArray. | |
| 53 if type_name.endswith('Array'): | |
| 54 return self._IsCompoundType(database, type_name[:-len('Array')]) | |
|
podivilov
2012/07/16 10:25:12
This is fragile, could you please rename IsPrimiti
| |
| 55 | |
| 48 dart_template_match = self._dart_templates_re.match(type_name) | 56 dart_template_match = self._dart_templates_re.match(type_name) |
| 49 if dart_template_match: | 57 if dart_template_match: |
| 50 # Dart templates | 58 # Dart templates |
| 51 parent_type_name = type_name[0 : dart_template_match.start(1) - 1] | 59 parent_type_name = type_name[0 : dart_template_match.start(1) - 1] |
| 52 sub_type_name = dart_template_match.group(1) | 60 sub_type_name = dart_template_match.group(1) |
| 53 return (self._IsCompoundType(database, parent_type_name) and | 61 return (self._IsCompoundType(database, parent_type_name) and |
| 54 self._IsCompoundType(database, sub_type_name)) | 62 self._IsCompoundType(database, sub_type_name)) |
| 55 return False | 63 return False |
| 56 | 64 |
| 57 def _IsDartType(self, type_name): | 65 def _IsDartType(self, type_name): |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 336 PARAMETERS=constructor_info.ParametersImplementationDeclaration(DartType )) | 344 PARAMETERS=constructor_info.ParametersImplementationDeclaration(DartType )) |
| 337 | 345 |
| 338 def FinishInterface(self): | 346 def FinishInterface(self): |
| 339 pass | 347 pass |
| 340 | 348 |
| 341 def AddTypedArrayConstructors(self, element_type): | 349 def AddTypedArrayConstructors(self, element_type): |
| 342 pass | 350 pass |
| 343 | 351 |
| 344 def AddEventAttributes(self, event_attrs): | 352 def AddEventAttributes(self, event_attrs): |
| 345 pass | 353 pass |
| OLD | NEW |