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

Side by Side Diff: lib/html/scripts/generator.py

Issue 10905265: Support sequence<T> as native bindings arguments. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 | « no previous file | lib/html/scripts/systemnative.py » ('j') | lib/html/scripts/systemnative.py » ('J')
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 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 re 10 import re
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 type = 'RefPtr<%s>' % self.native_type() 564 type = 'RefPtr<%s>' % self.native_type()
565 argument_expression_template = '%s.get()' 565 argument_expression_template = '%s.get()'
566 else: 566 else:
567 type = '%s*' % self.native_type() 567 type = '%s*' % self.native_type()
568 if isinstance(self, SVGTearOffIDLTypeInfo) and not interface_name.endswith ('List'): 568 if isinstance(self, SVGTearOffIDLTypeInfo) and not interface_name.endswith ('List'):
569 argument_expression_template = '%s->propertyReference()' 569 argument_expression_template = '%s->propertyReference()'
570 else: 570 else:
571 argument_expression_template = '%s' 571 argument_expression_template = '%s'
572 return argument_expression_template, type, cls, 'toNative' 572 return argument_expression_template, type, cls, 'toNative'
573 573
574 def pass_native_by_ref(self): return False
575
574 def custom_to_native(self): 576 def custom_to_native(self):
575 return self._data.custom_to_native 577 return self._data.custom_to_native
576 578
577 def parameter_type(self): 579 def parameter_type(self):
578 return '%s*' % self.native_type() 580 return '%s*' % self.native_type()
579 581
580 def webcore_includes(self): 582 def webcore_includes(self):
581 WTF_INCLUDES = [ 583 WTF_INCLUDES = [
582 'ArrayBuffer', 584 'ArrayBuffer',
583 'ArrayBufferView', 585 'ArrayBufferView',
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 628
627 629
628 class SequenceIDLTypeInfo(IDLTypeInfo): 630 class SequenceIDLTypeInfo(IDLTypeInfo):
629 def __init__(self, idl_type, data, item_info): 631 def __init__(self, idl_type, data, item_info):
630 super(SequenceIDLTypeInfo, self).__init__(idl_type, data) 632 super(SequenceIDLTypeInfo, self).__init__(idl_type, data)
631 self._item_info = item_info 633 self._item_info = item_info
632 634
633 def dart_type(self): 635 def dart_type(self):
634 return 'List<%s>' % self._item_info.dart_type() 636 return 'List<%s>' % self._item_info.dart_type()
635 637
638 def to_native_info(self, idl_node, interface_name):
639 item_info = self._item_info
640 item_native_type = item_info.native_type()
641 # Ugly hack. Usually IDLs floats are treated as C++ doubles, however
642 # sequence<float> should map to Vector<float>
643 if item_native_type == 'double' and item_info.idl_type() == 'float':
644 item_native_type = 'float'
645
646 return '%s', 'Vector<%s>' % item_native_type, 'DartUtilities', 'toNativeVect or<%s>' % item_native_type
647
648 def pass_native_by_ref(self): return True
649
636 def to_dart_conversion(self, value, interface_name=None, attributes=None): 650 def to_dart_conversion(self, value, interface_name=None, attributes=None):
637 return 'DartDOMWrapper::vectorToDart<Dart%s>(%s)' % (self._item_info.native_ type(), value) 651 return 'DartDOMWrapper::vectorToDart<Dart%s>(%s)' % (self._item_info.native_ type(), value)
638 652
639 def conversion_includes(self): 653 def conversion_includes(self):
640 return self._item_info.conversion_includes() 654 return self._item_info.conversion_includes()
641 655
642 656
643 class DOMStringArrayTypeInfo(SequenceIDLTypeInfo): 657 class DOMStringArrayTypeInfo(SequenceIDLTypeInfo):
644 def __init__(self, data, item_info): 658 def __init__(self, data, item_info):
645 super(DOMStringArrayTypeInfo, self).__init__('DOMString[]', data, item_info) 659 super(DOMStringArrayTypeInfo, self).__init__('DOMString[]', data, item_info)
646 660
647 def to_native_info(self, idl_node, interface_name): 661 def to_native_info(self, idl_node, interface_name):
648 return '%s', 'RefPtr<DOMStringList>', 'DartDOMStringList', 'toNative' 662 return '%s', 'RefPtr<DOMStringList>', 'DartDOMStringList', 'toNative'
649 663
664 def pass_native_by_ref(self): return False
665
650 666
651 class PrimitiveIDLTypeInfo(IDLTypeInfo): 667 class PrimitiveIDLTypeInfo(IDLTypeInfo):
652 def __init__(self, idl_type, data): 668 def __init__(self, idl_type, data):
653 super(PrimitiveIDLTypeInfo, self).__init__(idl_type, data) 669 super(PrimitiveIDLTypeInfo, self).__init__(idl_type, data)
654 670
655 def to_native_info(self, idl_node, interface_name): 671 def to_native_info(self, idl_node, interface_name):
656 type = self.native_type() 672 type = self.native_type()
657 if type == 'SerializedScriptValue': 673 if type == 'SerializedScriptValue':
658 type = 'RefPtr<%s>' % type 674 type = 'RefPtr<%s>' % type
659 if type == 'String': 675 if type == 'String':
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 if match: 877 if match:
862 if type_name == 'DOMString[]': 878 if type_name == 'DOMString[]':
863 return DOMStringArrayTypeInfo(TypeData('Sequence'), self.TypeInfo('DOMSt ring')) 879 return DOMStringArrayTypeInfo(TypeData('Sequence'), self.TypeInfo('DOMSt ring'))
864 item_info = self.TypeInfo(match.group(1) or match.group(2)) 880 item_info = self.TypeInfo(match.group(1) or match.group(2))
865 return SequenceIDLTypeInfo(type_name, TypeData('Sequence'), item_info) 881 return SequenceIDLTypeInfo(type_name, TypeData('Sequence'), item_info)
866 if not type_name in _idl_type_registry: 882 if not type_name in _idl_type_registry:
867 return InterfaceIDLTypeInfo(type_name, TypeData('Interface')) 883 return InterfaceIDLTypeInfo(type_name, TypeData('Interface'))
868 type_data = _idl_type_registry.get(type_name) 884 type_data = _idl_type_registry.get(type_name)
869 class_name = '%sIDLTypeInfo' % type_data.clazz 885 class_name = '%sIDLTypeInfo' % type_data.clazz
870 return globals()[class_name](type_name, type_data) 886 return globals()[class_name](type_name, type_data)
OLDNEW
« no previous file with comments | « no previous file | lib/html/scripts/systemnative.py » ('j') | lib/html/scripts/systemnative.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698