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

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

Issue 14619013: Explicitly implementing some DOM iterable APIs for performance (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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
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 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 # and 421 # and
422 # 422 #
423 # class YImpl extends ListBase<T> { copies of transitive XImpl methods; } 423 # class YImpl extends ListBase<T> { copies of transitive XImpl methods; }
424 # 424 #
425 dart_element_type = self._DartType(element_type) 425 dart_element_type = self._DartType(element_type)
426 if self._HasNativeIndexGetter(): 426 if self._HasNativeIndexGetter():
427 self._EmitNativeIndexGetter(dart_element_type) 427 self._EmitNativeIndexGetter(dart_element_type)
428 else: 428 else:
429 self._members_emitter.Emit( 429 self._members_emitter.Emit(
430 '\n' 430 '\n'
431 ' $TYPE operator[](int index) native "$(INTERFACE)_item_Callback";\n' , 431 ' $TYPE operator[](int index) {\n'
sra1 2013/05/09 19:55:50 Does the native code to a bounds check?
blois 2013/05/09 20:00:25 It appears to have the same behavior as JS.
432 ' if (index < 0 || index >= length) throw new RangeError.range(inde x, 0, length);\n'
sra1 2013/05/09 19:55:50 line length
blois 2013/05/09 22:49:24 Done.
433 ' return _nativeIndexedGetter(index);\n'
434 ' }\n'
435 ' $TYPE _nativeIndexedGetter(int index) native "$(INTERFACE)_item_Cal lback";\n',
432 TYPE=self.SecureOutputType(element_type), 436 TYPE=self.SecureOutputType(element_type),
433 INTERFACE=self._interface.id) 437 INTERFACE=self._interface.id)
434 438
435 if self._HasNativeIndexSetter(): 439 if self._HasNativeIndexSetter():
436 self._EmitNativeIndexSetter(dart_element_type) 440 self._EmitNativeIndexSetter(dart_element_type)
437 else: 441 else:
438 self._members_emitter.Emit( 442 self._members_emitter.Emit(
439 '\n' 443 '\n'
440 ' void operator[]=(int index, $TYPE value) {\n' 444 ' void operator[]=(int index, $TYPE value) {\n'
441 ' throw new UnsupportedError("Cannot assign element of immutable Li st.");\n' 445 ' throw new UnsupportedError("Cannot assign element of immutable Li st.");\n'
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu mentCount))\n' 951 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu mentCount))\n'
948 ' return func;\n', 952 ' return func;\n',
949 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) 953 CLASS_NAME=os.path.splitext(os.path.basename(path))[0])
950 954
951 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): 955 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument):
952 return ( 956 return (
953 interface.id.endswith('Event') and 957 interface.id.endswith('Event') and
954 operation.id.startswith('init') and 958 operation.id.startswith('init') and
955 argument.ext_attrs.get('Default') == 'Undefined' and 959 argument.ext_attrs.get('Default') == 'Undefined' and
956 argument.type.id == 'DOMString') 960 argument.type.id == 'DOMString')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698