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

Unified Diff: lib/dom/scripts/generator.py

Issue 10005017: Support DOMStringMap in generators. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/dom/scripts/generator.py
diff --git a/lib/dom/scripts/generator.py b/lib/dom/scripts/generator.py
index ff0701590fded44bcf855c76e13dc11ec5eba7bf..6a6ed978961d5bd9da79e46c2ce28dc48b5e742d 100644
--- a/lib/dom/scripts/generator.py
+++ b/lib/dom/scripts/generator.py
@@ -17,6 +17,7 @@ _idl_to_dart_type_conversions = {
'DOMObject': 'Object',
'DOMString': 'String',
'DOMStringList': 'List<String>',
+ 'DOMStringMap': 'Map<String, String>',
sra1 2012/04/06 18:23:39 We can't do this. There is a DOMStringMap type. I
Anton Muhin 2012/04/09 09:50:51 No, we can :)
'DOMTimeStamp': 'int',
'Date': 'Date',
# Map to num to enable callers to pass in Dart int, rational
@@ -529,13 +530,18 @@ class IDLTypeInfo(object):
return 'receiver->'
def conversion_includes(self):
- def NeededDartType(type_name):
+ def NeededDartTypes(type_name):
match = re.match(r'List<(\w*)>$', type_name)
if match:
- return NeededDartType(match.group(1))
- return type_name
+ return NeededDartTypes(match.group(1))
+ match = re.match(r'Map<(\w*), (\w*)>$', type_name)
+ if match:
+ return NeededDartTypes(match.group(1)) + NeededDartTypes(match.group(2))
+ if IsPrimitiveType(type_name):
+ return []
+ return [type_name]
- return ['"Dart%s.h"' % include for include in [NeededDartType(self.dart_type())] + self._conversion_includes]
+ return ['"Dart%s.h"' % include for include in NeededDartTypes(self.dart_type()) + self._conversion_includes]
def conversion_cast(self, expression):
if self._conversion_template:
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698