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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 provides shared functionality for systems to generate 6 """This module provides shared functionality for systems to generate
7 Dart APIs from the IDL database.""" 7 Dart APIs from the IDL database."""
8 8
9 import re 9 import re
10 10
11 # IDL->Dart primitive types conversion. 11 # IDL->Dart primitive types conversion.
12 _idl_to_dart_type_conversions = { 12 _idl_to_dart_type_conversions = {
13 'any': 'Object', 13 'any': 'Object',
14 'any[]': 'List', 14 'any[]': 'List',
15 'custom': 'Dynamic', 15 'custom': 'Dynamic',
16 'boolean': 'bool', 16 'boolean': 'bool',
17 'DOMObject': 'Object', 17 'DOMObject': 'Object',
18 'DOMString': 'String', 18 'DOMString': 'String',
19 'DOMStringList': 'List<String>', 19 'DOMStringList': 'List<String>',
20 '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 :)
20 'DOMTimeStamp': 'int', 21 'DOMTimeStamp': 'int',
21 'Date': 'Date', 22 'Date': 'Date',
22 # Map to num to enable callers to pass in Dart int, rational 23 # Map to num to enable callers to pass in Dart int, rational
23 # types. Our implementations will need to convert these to 24 # types. Our implementations will need to convert these to
24 # doubles or floats as needed. 25 # doubles or floats as needed.
25 'double': 'num', 26 'double': 'num',
26 'float': 'num', 27 'float': 'num',
27 'int': 'int', 28 'int': 'int',
28 # Map to extra precision - int is a bignum in Dart. 29 # Map to extra precision - int is a bignum in Dart.
29 'long': 'int', 30 'long': 'int',
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 if self._idl_type.startswith('SVGPathSeg'): 523 if self._idl_type.startswith('SVGPathSeg'):
523 include = self._idl_type.replace('Abs', '').replace('Rel', '') 524 include = self._idl_type.replace('Abs', '').replace('Rel', '')
524 else: 525 else:
525 include = self._idl_type 526 include = self._idl_type
526 return ['"%s.h"' % include] + _svg_supplemental_includes 527 return ['"%s.h"' % include] + _svg_supplemental_includes
527 528
528 def receiver(self): 529 def receiver(self):
529 return 'receiver->' 530 return 'receiver->'
530 531
531 def conversion_includes(self): 532 def conversion_includes(self):
532 def NeededDartType(type_name): 533 def NeededDartTypes(type_name):
533 match = re.match(r'List<(\w*)>$', type_name) 534 match = re.match(r'List<(\w*)>$', type_name)
534 if match: 535 if match:
535 return NeededDartType(match.group(1)) 536 return NeededDartTypes(match.group(1))
536 return type_name 537 match = re.match(r'Map<(\w*), (\w*)>$', type_name)
538 if match:
539 return NeededDartTypes(match.group(1)) + NeededDartTypes(match.group(2))
540 if IsPrimitiveType(type_name):
541 return []
542 return [type_name]
537 543
538 return ['"Dart%s.h"' % include for include in [NeededDartType(self.dart_type ())] + self._conversion_includes] 544 return ['"Dart%s.h"' % include for include in NeededDartTypes(self.dart_type ()) + self._conversion_includes]
539 545
540 def conversion_cast(self, expression): 546 def conversion_cast(self, expression):
541 if self._conversion_template: 547 if self._conversion_template:
542 return self._conversion_template % expression 548 return self._conversion_template % expression
543 return expression 549 return expression
544 550
545 def custom_to_dart(self): 551 def custom_to_dart(self):
546 return self._custom_to_dart 552 return self._custom_to_dart
547 553
548 class PrimitiveIDLTypeInfo(IDLTypeInfo): 554 class PrimitiveIDLTypeInfo(IDLTypeInfo):
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 '"SVGAnimatedPropertyTearOff.h"', 677 '"SVGAnimatedPropertyTearOff.h"',
672 '"SVGAnimatedListPropertyTearOff.h"', 678 '"SVGAnimatedListPropertyTearOff.h"',
673 '"SVGStaticListPropertyTearOff.h"', 679 '"SVGStaticListPropertyTearOff.h"',
674 '"SVGAnimatedListPropertyTearOff.h"', 680 '"SVGAnimatedListPropertyTearOff.h"',
675 '"SVGTransformListPropertyTearOff.h"', 681 '"SVGTransformListPropertyTearOff.h"',
676 '"SVGPathSegListPropertyTearOff.h"', 682 '"SVGPathSegListPropertyTearOff.h"',
677 ] 683 ]
678 684
679 def GetIDLTypeInfo(idl_type_name): 685 def GetIDLTypeInfo(idl_type_name):
680 return _idl_type_registry.get(idl_type_name, IDLTypeInfo(idl_type_name)) 686 return _idl_type_registry.get(idl_type_name, IDLTypeInfo(idl_type_name))
OLDNEW
« 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