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

Side by Side Diff: tools/dom/scripts/systemnative.py

Issue 21085008: Fixing some SVG collections not working on Dartium (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 | « tests/html/svgelement_test.dart ('k') | 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 the systems to generate 6 """This module provides shared functionality for the systems to generate
7 native binding from the IDL database.""" 7 native binding from the IDL database."""
8 8
9 import emitter 9 import emitter
10 import os 10 import os
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 # 471 #
472 # class YImpl extends XImpl { add List<T> methods; } 472 # class YImpl extends XImpl { add List<T> methods; }
473 # 473 #
474 # and 474 # and
475 # 475 #
476 # class YImpl extends ListBase<T> { copies of transitive XImpl methods; } 476 # class YImpl extends ListBase<T> { copies of transitive XImpl methods; }
477 # 477 #
478 dart_element_type = self._DartType(element_type) 478 dart_element_type = self._DartType(element_type)
479 if self._HasNativeIndexGetter(): 479 if self._HasNativeIndexGetter():
480 self._EmitNativeIndexGetter(dart_element_type) 480 self._EmitNativeIndexGetter(dart_element_type)
481 elif self._HasExplicitIndexedGetter():
482 self._EmitExplicitIndexedGetter(dart_element_type)
481 else: 483 else:
482 self._members_emitter.Emit( 484 self._members_emitter.Emit(
483 '\n' 485 '\n'
484 ' $TYPE operator[](int index) {\n' 486 ' $TYPE operator[](int index) {\n'
485 ' if (index < 0 || index >= length)\n' 487 ' if (index < 0 || index >= length)\n'
486 ' throw new RangeError.range(index, 0, length);\n' 488 ' throw new RangeError.range(index, 0, length);\n'
487 ' return _nativeIndexedGetter(index);\n' 489 ' return _nativeIndexedGetter(index);\n'
488 ' }\n' 490 ' }\n'
489 ' $TYPE _nativeIndexedGetter(int index) native "$(INTERFACE)_item_Cal lback";\n', 491 ' $TYPE _nativeIndexedGetter(int index) native "$(INTERFACE)_item_Cal lback";\n',
490 TYPE=self.SecureOutputType(element_type), 492 TYPE=self.SecureOutputType(element_type),
(...skipping 28 matching lines...) Expand all
519 521
520 def _HasNativeIndexGetter(self): 522 def _HasNativeIndexGetter(self):
521 return 'CustomIndexedGetter' in self._interface.ext_attrs 523 return 'CustomIndexedGetter' in self._interface.ext_attrs
522 524
523 def _EmitNativeIndexGetter(self, element_type): 525 def _EmitNativeIndexGetter(self, element_type):
524 dart_declaration = '%s operator[](int index)' % \ 526 dart_declaration = '%s operator[](int index)' % \
525 self.SecureOutputType(element_type, True) 527 self.SecureOutputType(element_type, True)
526 self._GenerateNativeBinding('numericIndexGetter', 2, dart_declaration, 528 self._GenerateNativeBinding('numericIndexGetter', 2, dart_declaration,
527 'Callback', True) 529 'Callback', True)
528 530
531 def _HasExplicitIndexedGetter(self):
532 return any(op.id == 'getItem' for op in self._interface.operations)
533
534 def _EmitExplicitIndexedGetter(self, dart_element_type):
535 if any(op.id == 'getItem' for op in self._interface.operations):
536 indexed_getter = 'getItem'
537
538 self._members_emitter.Emit(
539 '\n'
540 ' $TYPE operator[](int index) {\n'
541 ' if (index < 0 || index >= length)\n'
542 ' throw new RangeError.range(index, 0, length);\n'
543 ' return $INDEXED_GETTER(index);\n'
544 ' }\n',
545 TYPE=dart_element_type,
546 INDEXED_GETTER=indexed_getter)
547
529 def _HasNativeIndexSetter(self): 548 def _HasNativeIndexSetter(self):
530 return 'CustomIndexedSetter' in self._interface.ext_attrs 549 return 'CustomIndexedSetter' in self._interface.ext_attrs
531 550
532 def _EmitNativeIndexSetter(self, element_type): 551 def _EmitNativeIndexSetter(self, element_type):
533 dart_declaration = 'void operator[]=(int index, %s value)' % element_type 552 dart_declaration = 'void operator[]=(int index, %s value)' % element_type
534 self._GenerateNativeBinding('numericIndexSetter', 3, dart_declaration, 553 self._GenerateNativeBinding('numericIndexSetter', 3, dart_declaration,
535 'Callback', True) 554 'Callback', True)
536 555
537 def EmitOperation(self, info, html_name): 556 def EmitOperation(self, info, html_name):
538 """ 557 """
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu mentCount))\n' 1058 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu mentCount))\n'
1040 ' return func;\n', 1059 ' return func;\n',
1041 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) 1060 CLASS_NAME=os.path.splitext(os.path.basename(path))[0])
1042 1061
1043 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): 1062 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument):
1044 return ( 1063 return (
1045 interface.id.endswith('Event') and 1064 interface.id.endswith('Event') and
1046 operation.id.startswith('init') and 1065 operation.id.startswith('init') and
1047 argument.ext_attrs.get('Default') == 'Undefined' and 1066 argument.ext_attrs.get('Default') == 'Undefined' and
1048 argument.type.id == 'DOMString') 1067 argument.type.id == 'DOMString')
OLDNEW
« no previous file with comments | « tests/html/svgelement_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698