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 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 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 def IsPureInterface(interface_name): | 71 def IsPureInterface(interface_name): |
72 return interface_name in _pure_interfaces | 72 return interface_name in _pure_interfaces |
73 | 73 |
74 # | 74 # |
75 # Identifiers that are used in the IDL than need to be treated specially because | 75 # Identifiers that are used in the IDL than need to be treated specially because |
76 # *some* JavaScript processors forbid them as properties. | 76 # *some* JavaScript processors forbid them as properties. |
77 # | 77 # |
78 _javascript_keywords = ['delete', 'continue'] | 78 _javascript_keywords = ['delete', 'continue'] |
79 | 79 |
80 # | 80 # |
81 # Renames for attributes that have names that are not legal Dart names. | |
82 # | |
83 _dart_attribute_renames = { | |
84 'default': 'defaultValue' | |
85 } | |
86 | |
87 # | |
81 # Interface version of the DOM needs to delegate typed array constructors to a | 88 # Interface version of the DOM needs to delegate typed array constructors to a |
82 # factory provider. | 89 # factory provider. |
83 # | 90 # |
84 interface_factories = { | 91 interface_factories = { |
85 'Float32Array': '_TypedArrayFactoryProvider', | 92 'Float32Array': '_TypedArrayFactoryProvider', |
86 'Float64Array': '_TypedArrayFactoryProvider', | 93 'Float64Array': '_TypedArrayFactoryProvider', |
87 'Int8Array': '_TypedArrayFactoryProvider', | 94 'Int8Array': '_TypedArrayFactoryProvider', |
88 'Int16Array': '_TypedArrayFactoryProvider', | 95 'Int16Array': '_TypedArrayFactoryProvider', |
89 'Int32Array': '_TypedArrayFactoryProvider', | 96 'Int32Array': '_TypedArrayFactoryProvider', |
90 'Uint8Array': '_TypedArrayFactoryProvider', | 97 'Uint8Array': '_TypedArrayFactoryProvider', |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
334 matches = [attr2 for attr2 in interface.attributes | 341 matches = [attr2 for attr2 in interface.attributes |
335 if attr1.id == attr2.id | 342 if attr1.id == attr2.id |
336 and attr1.is_fc_getter == attr2.is_fc_getter | 343 and attr1.is_fc_getter == attr2.is_fc_getter |
337 and attr1.is_fc_setter == attr2.is_fc_setter] | 344 and attr1.is_fc_setter == attr2.is_fc_setter] |
338 if matches: | 345 if matches: |
339 assert len(matches) == 1 | 346 assert len(matches) == 1 |
340 return matches[0] | 347 return matches[0] |
341 return None | 348 return None |
342 | 349 |
343 | 350 |
351 def DartDomNameOfAttribute(attr): | |
352 """Returns the Dart name for an IDLAttribute. | |
353 | |
354 attr.id is the 'native' or JavaScript name. | |
355 | |
356 To ensure uniformity, work with the true IDL name until as late a possible, | |
357 e.g. translate to the Dart name when generating Dart code. | |
358 """ | |
359 name = attr.id | |
360 name = _dart_attribute_renames.get(name, name) | |
361 name = attr.ext_attrs.get('DartName', None) or name | |
Anton Muhin
2012/03/13 12:53:47
nit: attr.ext_attrs.get('DartName', name)
| |
362 return name | |
363 | |
344 class OperationInfo(object): | 364 class OperationInfo(object): |
345 """Holder for various derived information from a set of overloaded operations. | 365 """Holder for various derived information from a set of overloaded operations. |
346 | 366 |
347 Attributes: | 367 Attributes: |
348 overloads: A list of IDL operation overloads with the same name. | 368 overloads: A list of IDL operation overloads with the same name. |
349 name: A string, the simple name of the operation. | 369 name: A string, the simple name of the operation. |
350 type_name: A string, the name of the return type of the operation. | 370 type_name: A string, the name of the return type of the operation. |
351 arg_infos: A list of (name, type, default_value) tuples. | 371 arg_infos: A list of (name, type, default_value) tuples. |
352 default_value is None for mandatory arguments. | 372 default_value is None for mandatory arguments. |
353 """ | 373 """ |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
638 'SVGAnimatedPropertyTearOff', | 658 'SVGAnimatedPropertyTearOff', |
639 'SVGAnimatedListPropertyTearOff', | 659 'SVGAnimatedListPropertyTearOff', |
640 'SVGStaticListPropertyTearOff', | 660 'SVGStaticListPropertyTearOff', |
641 'SVGAnimatedListPropertyTearOff', | 661 'SVGAnimatedListPropertyTearOff', |
642 'SVGTransformListPropertyTearOff', | 662 'SVGTransformListPropertyTearOff', |
643 'SVGPathSegListPropertyTearOff', | 663 'SVGPathSegListPropertyTearOff', |
644 ] | 664 ] |
645 | 665 |
646 def GetIDLTypeInfo(idl_type_name): | 666 def GetIDLTypeInfo(idl_type_name): |
647 return _idl_type_registry.get(idl_type_name, IDLTypeInfo(idl_type_name)) | 667 return _idl_type_registry.get(idl_type_name, IDLTypeInfo(idl_type_name)) |
OLD | NEW |