| 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 copy | 9 import copy |
| 10 import json | 10 import json |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 | 384 |
| 385 def IsStatic(self): | 385 def IsStatic(self): |
| 386 is_static = self.overloads[0].is_static | 386 is_static = self.overloads[0].is_static |
| 387 assert any([is_static == o.is_static for o in self.overloads]) | 387 assert any([is_static == o.is_static for o in self.overloads]) |
| 388 return is_static | 388 return is_static |
| 389 | 389 |
| 390 def _ConstructorFullName(self, rename_type): | 390 def _ConstructorFullName(self, rename_type): |
| 391 if self.constructor_name: | 391 if self.constructor_name: |
| 392 return rename_type(self.type_name) + '.' + self.constructor_name | 392 return rename_type(self.type_name) + '.' + self.constructor_name |
| 393 else: | 393 else: |
| 394 # TODO(antonm): temporary ugly hack. |
| 395 # While in transition phase we allow both DOM's ArrayBuffer |
| 396 # and dart:typeddata's ByteBuffer for IDLs' ArrayBuffers, |
| 397 # hence ArrayBuffer is mapped to dynamic in arguments and return |
| 398 # values. To compensate for that when generating ArrayBuffer itself, |
| 399 # we need to lie a bit: |
| 400 if self.type_name == 'ArrayBuffer': return 'ArrayBuffer' |
| 394 return rename_type(self.type_name) | 401 return rename_type(self.type_name) |
| 395 | 402 |
| 396 def ConstantOutputOrder(a, b): | 403 def ConstantOutputOrder(a, b): |
| 397 """Canonical output ordering for constants.""" | 404 """Canonical output ordering for constants.""" |
| 398 return cmp(a.id, b.id) | 405 return cmp(a.id, b.id) |
| 399 | 406 |
| 400 | 407 |
| 401 def _FormatNameList(names): | 408 def _FormatNameList(names): |
| 402 """Returns JavaScript array literal expression with one name per line.""" | 409 """Returns JavaScript array literal expression with one name per line.""" |
| 403 #names = sorted(names) | 410 #names = sorted(names) |
| (...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1459 | 1466 |
| 1460 'Float32Array': TypedArrayTypeData('double'), | 1467 'Float32Array': TypedArrayTypeData('double'), |
| 1461 'Float64Array': TypedArrayTypeData('double'), | 1468 'Float64Array': TypedArrayTypeData('double'), |
| 1462 'Int8Array': TypedArrayTypeData('int'), | 1469 'Int8Array': TypedArrayTypeData('int'), |
| 1463 'Int16Array': TypedArrayTypeData('int'), | 1470 'Int16Array': TypedArrayTypeData('int'), |
| 1464 'Int32Array': TypedArrayTypeData('int'), | 1471 'Int32Array': TypedArrayTypeData('int'), |
| 1465 'Uint8Array': TypedArrayTypeData('int'), | 1472 'Uint8Array': TypedArrayTypeData('int'), |
| 1466 'Uint8ClampedArray': TypedArrayTypeData('int'), | 1473 'Uint8ClampedArray': TypedArrayTypeData('int'), |
| 1467 'Uint16Array': TypedArrayTypeData('int'), | 1474 'Uint16Array': TypedArrayTypeData('int'), |
| 1468 'Uint32Array': TypedArrayTypeData('int'), | 1475 'Uint32Array': TypedArrayTypeData('int'), |
| 1476 # TODO(antonm): temporary ugly hack. |
| 1477 # While in transition phase we allow both DOM's ArrayBuffer |
| 1478 # and dart:typeddata's ByteBuffer for IDLs' ArrayBuffers, |
| 1479 # hence ArrayBuffer is mapped to dynamic in arguments and return |
| 1480 # values. |
| 1481 'ArrayBufferView': TypeData(clazz='Interface', dart_type='dynamic'), |
| 1482 'ArrayBuffer': TypeData(clazz='Interface', dart_type='dynamic'), |
| 1469 | 1483 |
| 1470 'SVGAngle': TypeData(clazz='SVGTearOff'), | 1484 'SVGAngle': TypeData(clazz='SVGTearOff'), |
| 1471 'SVGLength': TypeData(clazz='SVGTearOff'), | 1485 'SVGLength': TypeData(clazz='SVGTearOff'), |
| 1472 'SVGLengthList': TypeData(clazz='SVGTearOff', item_type='SVGLength'), | 1486 'SVGLengthList': TypeData(clazz='SVGTearOff', item_type='SVGLength'), |
| 1473 'SVGMatrix': TypeData(clazz='SVGTearOff'), | 1487 'SVGMatrix': TypeData(clazz='SVGTearOff'), |
| 1474 'SVGNumber': TypeData(clazz='SVGTearOff', native_type='SVGPropertyTearOff<fl
oat>'), | 1488 'SVGNumber': TypeData(clazz='SVGTearOff', native_type='SVGPropertyTearOff<fl
oat>'), |
| 1475 'SVGNumberList': TypeData(clazz='SVGTearOff', item_type='SVGNumber'), | 1489 'SVGNumberList': TypeData(clazz='SVGTearOff', item_type='SVGNumber'), |
| 1476 'SVGPathSegList': TypeData(clazz='SVGTearOff', item_type='SVGPathSeg', | 1490 'SVGPathSegList': TypeData(clazz='SVGTearOff', item_type='SVGPathSeg', |
| 1477 native_type='SVGPathSegListPropertyTearOff'), | 1491 native_type='SVGPathSegListPropertyTearOff'), |
| 1478 'SVGPoint': TypeData(clazz='SVGTearOff', native_type='SVGPropertyTearOff<Flo
atPoint>'), | 1492 'SVGPoint': TypeData(clazz='SVGTearOff', native_type='SVGPropertyTearOff<Flo
atPoint>'), |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1540 self) | 1554 self) |
| 1541 | 1555 |
| 1542 if type_data.clazz == 'SVGTearOff': | 1556 if type_data.clazz == 'SVGTearOff': |
| 1543 dart_interface_name = self._renamer.RenameInterface( | 1557 dart_interface_name = self._renamer.RenameInterface( |
| 1544 self._database.GetInterface(type_name)) | 1558 self._database.GetInterface(type_name)) |
| 1545 return SVGTearOffIDLTypeInfo( | 1559 return SVGTearOffIDLTypeInfo( |
| 1546 type_name, type_data, dart_interface_name, self) | 1560 type_name, type_data, dart_interface_name, self) |
| 1547 | 1561 |
| 1548 class_name = '%sIDLTypeInfo' % type_data.clazz | 1562 class_name = '%sIDLTypeInfo' % type_data.clazz |
| 1549 return globals()[class_name](type_name, type_data) | 1563 return globals()[class_name](type_name, type_data) |
| OLD | NEW |