Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: lib/dom/scripts/dartgenerator.py

Issue 10779024: Revert "Handle all registered types, not just 'Primitive' ones." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « lib/dom/frog/dom_frog.dart ('k') | lib/dom/scripts/generator.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 17 matching lines...) Expand all
28 """Utilities to generate Dart APIs and corresponding JavaScript.""" 28 """Utilities to generate Dart APIs and corresponding JavaScript."""
29 29
30 def __init__(self): 30 def __init__(self):
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 IsRegisteredType(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
44 if type_name.endswith('[]'): 41 if type_name.endswith('[]'):
45 return self._IsCompoundType(database, type_name[:-len('[]')]) 42 return self._IsCompoundType(database, type_name[:-len('[]')])
46 43
47 stripped_type_name = self._StripModules(type_name) 44 striped_type_name = self._StripModules(type_name)
48 if database.HasInterface(stripped_type_name): 45 if database.HasInterface(striped_type_name):
49 return True 46 return True
50 47
51 dart_template_match = self._dart_templates_re.match(type_name) 48 dart_template_match = self._dart_templates_re.match(type_name)
52 if dart_template_match: 49 if dart_template_match:
53 # Dart templates 50 # Dart templates
54 parent_type_name = type_name[0 : dart_template_match.start(1) - 1] 51 parent_type_name = type_name[0 : dart_template_match.start(1) - 1]
55 sub_type_name = dart_template_match.group(1) 52 sub_type_name = dart_template_match.group(1)
56 return (self._IsCompoundType(database, parent_type_name) and 53 return (self._IsCompoundType(database, parent_type_name) and
57 self._IsCompoundType(database, sub_type_name)) 54 self._IsCompoundType(database, sub_type_name))
58 return False 55 return False
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 PARAMETERS=constructor_info.ParametersImplementationDeclaration(DartType )) 336 PARAMETERS=constructor_info.ParametersImplementationDeclaration(DartType ))
340 337
341 def FinishInterface(self): 338 def FinishInterface(self):
342 pass 339 pass
343 340
344 def AddTypedArrayConstructors(self, element_type): 341 def AddTypedArrayConstructors(self, element_type):
345 pass 342 pass
346 343
347 def AddEventAttributes(self, event_attrs): 344 def AddEventAttributes(self, event_attrs):
348 pass 345 pass
OLDNEW
« no previous file with comments | « lib/dom/frog/dom_frog.dart ('k') | lib/dom/scripts/generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698