| OLD | NEW |
| 1 # Copyright (C) 2013 Google Inc. All rights reserved. | 1 # Copyright (C) 2013 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 IdlDefinitions | 41 IdlDefinitions |
| 42 IdlCallbackFunction < TypedObject | 42 IdlCallbackFunction < TypedObject |
| 43 IdlEnum :: FIXME: remove, just use a dict for enums | 43 IdlEnum :: FIXME: remove, just use a dict for enums |
| 44 IdlInterface | 44 IdlInterface |
| 45 IdlAttribute < TypedObject | 45 IdlAttribute < TypedObject |
| 46 IdlConstant < TypedObject | 46 IdlConstant < TypedObject |
| 47 IdlLiteral | 47 IdlLiteral |
| 48 IdlOperation < TypedObject | 48 IdlOperation < TypedObject |
| 49 IdlArgument < TypedObject | 49 IdlArgument < TypedObject |
| 50 IdlStringifier | 50 IdlStringifier |
| 51 IdlIterable < IdlIterableOrMaplikeOrSetlike |
| 52 IdlMaplike < IdlIterableOrMaplikeOrSetlike |
| 53 IdlSetlike < IdlIterableOrMaplikeOrSetlike |
| 51 IdlException < IdlInterface | 54 IdlException < IdlInterface |
| 52 (same contents as IdlInterface) | 55 (same contents as IdlInterface) |
| 53 | 56 |
| 54 TypedObject :: mixin for typedef resolution | 57 TypedObject :: mixin for typedef resolution |
| 55 | 58 |
| 56 IdlArgument is 'picklable', as it is stored in interfaces_info. | 59 IdlArgument is 'picklable', as it is stored in interfaces_info. |
| 57 | 60 |
| 58 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler | 61 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler |
| 59 """ | 62 """ |
| 60 | 63 |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 # the underlying attribute or operation, if there is one. | 648 # the underlying attribute or operation, if there is one. |
| 646 if self.attribute or self.operation: | 649 if self.attribute or self.operation: |
| 647 (self.attribute or self.operation).extended_attributes.update( | 650 (self.attribute or self.operation).extended_attributes.update( |
| 648 self.extended_attributes) | 651 self.extended_attributes) |
| 649 | 652 |
| 650 | 653 |
| 651 ################################################################################ | 654 ################################################################################ |
| 652 # Iterable, Maplike, Setlike | 655 # Iterable, Maplike, Setlike |
| 653 ################################################################################ | 656 ################################################################################ |
| 654 | 657 |
| 655 class IdlIterable(object): | 658 class IdlIterableOrMaplikeOrSetlike(object): |
| 656 def __init__(self, idl_name, node): | 659 def __init__(self, idl_name, node): |
| 657 children = node.GetChildren() | 660 self.extended_attributes = {} |
| 661 self.type_children = [] |
| 658 | 662 |
| 659 # FIXME: Support extended attributes. | 663 for child in node.GetChildren(): |
| 660 | 664 child_class = child.GetClass() |
| 661 if len(children) == 1: | 665 if child_class == 'ExtAttributes': |
| 662 self.key_type = None | 666 self.extended_attributes = ext_attributes_node_to_extended_attri
butes(idl_name, child) |
| 663 self.value_type = type_node_to_type(children[0]) | 667 elif child_class == 'Type': |
| 664 elif len(children) == 2: | 668 self.type_children.append(child) |
| 665 self.key_type = type_node_to_type(children[0]) | 669 else: |
| 666 self.value_type = type_node_to_type(children[1]) | 670 raise ValueError('Unrecognized node class: %s' % child_class) |
| 667 else: | |
| 668 raise ValueError('Unexpected number of children: %d' % len(children)
) | |
| 669 | 671 |
| 670 | 672 |
| 671 class IdlMaplike(object): | 673 class IdlIterable(IdlIterableOrMaplikeOrSetlike): |
| 672 def __init__(self, idl_name, node): | 674 def __init__(self, idl_name, node): |
| 675 super(IdlIterable, self).__init__(idl_name, node) |
| 676 |
| 677 if len(self.type_children) == 1: |
| 678 self.key_type = None |
| 679 self.value_type = type_node_to_type(self.type_children[0]) |
| 680 elif len(self.type_children) == 2: |
| 681 self.key_type = type_node_to_type(self.type_children[0]) |
| 682 self.value_type = type_node_to_type(self.type_children[1]) |
| 683 else: |
| 684 raise ValueError('Unexpected number of type children: %d' % len(self
.type_children)) |
| 685 del self.type_children |
| 686 |
| 687 |
| 688 class IdlMaplike(IdlIterableOrMaplikeOrSetlike): |
| 689 def __init__(self, idl_name, node): |
| 690 super(IdlMaplike, self).__init__(idl_name, node) |
| 691 |
| 673 self.is_read_only = bool(node.GetProperty('READONLY')) | 692 self.is_read_only = bool(node.GetProperty('READONLY')) |
| 674 | 693 |
| 675 children = node.GetChildren() | 694 if len(self.type_children) == 2: |
| 676 | 695 self.key_type = type_node_to_type(self.type_children[0]) |
| 677 # FIXME: Support extended attributes. | 696 self.value_type = type_node_to_type(self.type_children[1]) |
| 678 | |
| 679 if len(children) == 2: | |
| 680 self.key_type = type_node_to_type(children[0]) | |
| 681 self.value_type = type_node_to_type(children[1]) | |
| 682 else: | 697 else: |
| 683 raise ValueError('Unexpected number of children: %d' % len(children)
) | 698 raise ValueError('Unexpected number of children: %d' % len(self.type
_children)) |
| 699 del self.type_children |
| 684 | 700 |
| 685 | 701 |
| 686 class IdlSetlike(object): | 702 class IdlSetlike(IdlIterableOrMaplikeOrSetlike): |
| 687 def __init__(self, idl_name, node): | 703 def __init__(self, idl_name, node): |
| 704 super(IdlSetlike, self).__init__(idl_name, node) |
| 705 |
| 688 self.is_read_only = bool(node.GetProperty('READONLY')) | 706 self.is_read_only = bool(node.GetProperty('READONLY')) |
| 689 | 707 |
| 690 children = node.GetChildren() | 708 if len(self.type_children) == 1: |
| 691 | 709 self.value_type = type_node_to_type(self.type_children[0]) |
| 692 # FIXME: Support extended attributes. | |
| 693 | |
| 694 if len(children) == 1: | |
| 695 self.value_type = type_node_to_type(children[0]) | |
| 696 else: | 710 else: |
| 697 raise ValueError('Unexpected number of children: %d' % len(children)
) | 711 raise ValueError('Unexpected number of children: %d' % len(self.type
_children)) |
| 712 del self.type_children |
| 698 | 713 |
| 699 | 714 |
| 700 ################################################################################ | 715 ################################################################################ |
| 701 # Implement statements | 716 # Implement statements |
| 702 ################################################################################ | 717 ################################################################################ |
| 703 | 718 |
| 704 class IdlImplement(object): | 719 class IdlImplement(object): |
| 705 def __init__(self, node): | 720 def __init__(self, node): |
| 706 self.left_interface = node.GetName() | 721 self.left_interface = node.GetName() |
| 707 self.right_interface = node.GetProperty('REFERENCE') | 722 self.right_interface = node.GetProperty('REFERENCE') |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 921 child_class = child.GetClass() | 936 child_class = child.GetClass() |
| 922 if child_class != 'Type': | 937 if child_class != 'Type': |
| 923 raise ValueError('Unrecognized node class: %s' % child_class) | 938 raise ValueError('Unrecognized node class: %s' % child_class) |
| 924 return type_node_to_type(child) | 939 return type_node_to_type(child) |
| 925 | 940 |
| 926 | 941 |
| 927 def union_type_node_to_idl_union_type(node): | 942 def union_type_node_to_idl_union_type(node): |
| 928 member_types = [type_node_to_type(member_type_node) | 943 member_types = [type_node_to_type(member_type_node) |
| 929 for member_type_node in node.GetChildren()] | 944 for member_type_node in node.GetChildren()] |
| 930 return IdlUnionType(member_types) | 945 return IdlUnionType(member_types) |
| OLD | NEW |