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

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

Issue 9956126: Fix for Issue 2399. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: supressions 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 | « lib/dom/frog/dom_frog.dart ('k') | lib/dom/templates/immutable_list_mixin.darttemplate » ('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 provides shared functionality for the system to generate 6 """This module provides shared functionality for the system to generate
7 Dart:html APIs from the IDL database.""" 7 Dart:html APIs from the IDL database."""
8 8
9 from systemfrog import * 9 from systemfrog import *
10 from systeminterface import * 10 from systeminterface import *
(...skipping 1435 matching lines...) Expand 10 before | Expand all | Expand 10 after
1446 '\n' 1446 '\n'
1447 ' void operator[]=(int index, $TYPE value) {\n' 1447 ' void operator[]=(int index, $TYPE value) {\n'
1448 ' throw new UnsupportedOperationException("Cannot assign element of immutable List.");\n' 1448 ' throw new UnsupportedOperationException("Cannot assign element of immutable List.");\n'
1449 ' }\n', 1449 ' }\n',
1450 TYPE=DartType(element_type)) 1450 TYPE=DartType(element_type))
1451 1451
1452 # The list interface for this class is manually generated. 1452 # The list interface for this class is manually generated.
1453 if self._interface.id == 'NodeList': 1453 if self._interface.id == 'NodeList':
1454 return 1454 return
1455 1455
1456 self._members_emitter.Emit( 1456 # TODO(sra): Use separate mixins for mutable implementations of List<T>.
1457 '\n' 1457 # TODO(sra): Use separate mixins for typed array implementations of List<T>.
1458 ' void add($TYPE value) {\n' 1458 template_file = 'immutable_list_mixin.darttemplate'
1459 ' throw new UnsupportedOperationException("Cannot add to immutable Li st.");\n' 1459 template = self._system._templates.Load(template_file)
1460 ' }\n' 1460 self._members_emitter.Emit(template, E=DartType(element_type))
1461 '\n'
1462 ' void addLast($TYPE value) {\n'
1463 ' throw new UnsupportedOperationException("Cannot add to immutable Li st.");\n'
1464 ' }\n'
1465 '\n'
1466 ' void addAll(Collection<$TYPE> collection) {\n'
1467 ' throw new UnsupportedOperationException("Cannot add to immutable Li st.");\n'
1468 ' }\n'
1469 '\n'
1470 ' void sort(int compare($TYPE a, $TYPE b)) {\n'
1471 ' throw new UnsupportedOperationException("Cannot sort immutable List .");\n'
1472 ' }\n'
1473 '\n'
1474 ' void copyFrom(List<Object> src, int srcStart, '
1475 'int dstStart, int count) {\n'
1476 ' throw new UnsupportedOperationException("This object is immutable." );\n'
1477 ' }\n'
1478 '\n'
1479 ' int indexOf($TYPE element, [int start = 0]) {\n'
1480 ' return _Lists.indexOf(this, element, start, this.length);\n'
1481 ' }\n'
1482 '\n'
1483 ' int lastIndexOf($TYPE element, [int start = null]) {\n'
1484 ' if (start === null) start = length - 1;\n'
1485 ' return _Lists.lastIndexOf(this, element, start);\n'
1486 ' }\n'
1487 '\n'
1488 ' int clear() {\n'
1489 ' throw new UnsupportedOperationException("Cannot clear immutable Lis t.");\n'
1490 ' }\n'
1491 '\n'
1492 ' $TYPE removeLast() {\n'
1493 ' throw new UnsupportedOperationException("Cannot removeLast on immut able List.");\n'
1494 ' }\n'
1495 '\n'
1496 ' $TYPE last() {\n'
1497 ' return this[length - 1];\n'
1498 ' }\n'
1499 '\n'
1500 ' void forEach(void f($TYPE element)) {\n'
1501 ' _Collections.forEach(this, f);\n'
1502 ' }\n'
1503 '\n'
1504 ' Collection map(f($TYPE element)) {\n'
1505 ' return _Collections.map(this, [], f);\n'
1506 ' }\n'
1507 '\n'
1508 ' Collection<$TYPE> filter(bool f($TYPE element)) {\n'
1509 ' return _Collections.filter(this, new List<$TYPE>(), f);\n'
1510 ' }\n'
1511 '\n'
1512 ' bool every(bool f($TYPE element)) {\n'
1513 ' return _Collections.every(this, f);\n'
1514 ' }\n'
1515 '\n'
1516 ' bool some(bool f($TYPE element)) {\n'
1517 ' return _Collections.some(this, f);\n'
1518 ' }\n'
1519 '\n'
1520 ' void setRange(int start, int length, List<$TYPE> from, [int startFrom ]) {\n'
1521 ' throw new UnsupportedOperationException("Cannot setRange on immutab le List.");\n'
1522 ' }\n'
1523 '\n'
1524 ' void removeRange(int start, int length) {\n'
1525 ' throw new UnsupportedOperationException("Cannot removeRange on immu table List.");\n'
1526 ' }\n'
1527 '\n'
1528 ' void insertRange(int start, int length, [$TYPE initialValue]) {\n'
1529 ' throw new UnsupportedOperationException("Cannot insertRange on immu table List.");\n'
1530 ' }\n'
1531 '\n'
1532 ' List<$TYPE> getRange(int start, int length) {\n'
1533 ' throw new NotImplementedException();\n'
1534 ' }\n'
1535 '\n'
1536 ' bool isEmpty() {\n'
1537 ' return length == 0;\n'
1538 ' }\n'
1539 '\n'
1540 ' Iterator<$TYPE> iterator() {\n'
1541 ' return new _FixedSizeListIterator<$TYPE>(this);\n'
1542 ' }\n',
1543 TYPE=DartType(element_type))
1544 1461
1545 def _HasNativeIndexGetter(self, interface): 1462 def _HasNativeIndexGetter(self, interface):
1546 return ('HasIndexGetter' in interface.ext_attrs or 1463 return ('IndexedGetter' in interface.ext_attrs or
1547 'HasNumericIndexGetter' in interface.ext_attrs) 1464 'NumericIndexedGetter' in interface.ext_attrs)
1548 1465
1549 def _EmitNativeIndexGetter(self, interface, element_type): 1466 def _EmitNativeIndexGetter(self, interface, element_type):
1550 method_name = '_index' 1467 method_name = '_index'
1551 self._members_emitter.Emit( 1468 self._members_emitter.Emit(
1552 '\n $TYPE operator[](int index) => _wrap($(THIS)[index]);\n', 1469 '\n $TYPE operator[](int index) => _wrap($(THIS)[index]);\n',
1553 TYPE=DartType(element_type), 1470 TYPE=DartType(element_type),
1554 THIS=self.DomObjectName(), 1471 THIS=self.DomObjectName(),
1555 METHOD=method_name) 1472 METHOD=method_name)
1556 1473
1557 def _HasNativeIndexSetter(self, interface): 1474 def _HasNativeIndexSetter(self, interface):
1558 return 'HasCustomIndexSetter' in interface.ext_attrs 1475 return 'CustomIndexedSetter' in interface.ext_attrs
1559 1476
1560 def _EmitNativeIndexSetter(self, interface, element_type): 1477 def _EmitNativeIndexSetter(self, interface, element_type):
1561 method_name = '_set_index' 1478 method_name = '_set_index'
1562 self._members_emitter.Emit( 1479 self._members_emitter.Emit(
1563 '\n' 1480 '\n'
1564 ' void operator[]=(int index, $TYPE value) {\n' 1481 ' void operator[]=(int index, $TYPE value) {\n'
1565 ' return $(THIS)[index] = _unwrap(value);\n' 1482 ' return $(THIS)[index] = _unwrap(value);\n'
1566 ' }\n', 1483 ' }\n',
1567 THIS=self.DomObjectName(), 1484 THIS=self.DomObjectName(),
1568 TYPE=DartType(element_type), 1485 TYPE=DartType(element_type),
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1717 # dispatch has removed f(X), leaving only f(Y), but there is no guarantee 1634 # dispatch has removed f(X), leaving only f(Y), but there is no guarantee
1718 # that Y = Z-X, so we need to check for Y. 1635 # that Y = Z-X, so we need to check for Y.
1719 true_code = emitter.Emit( 1636 true_code = emitter.Emit(
1720 '$(INDENT)if ($COND) {\n' 1637 '$(INDENT)if ($COND) {\n'
1721 '$!TRUE' 1638 '$!TRUE'
1722 '$(INDENT)}\n', 1639 '$(INDENT)}\n',
1723 COND=test, INDENT=indent) 1640 COND=test, INDENT=indent)
1724 self.GenerateDispatch( 1641 self.GenerateDispatch(
1725 true_code, info, indent + ' ', position + 1, positive) 1642 true_code, info, indent + ' ', position + 1, positive)
1726 return True 1643 return True
OLDNEW
« no previous file with comments | « lib/dom/frog/dom_frog.dart ('k') | lib/dom/templates/immutable_list_mixin.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698