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 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 if node_class in ['PrimitiveType', 'Typeref']: | 782 if node_class in ['PrimitiveType', 'Typeref']: |
783 # unrestricted syntax: unrestricted double | unrestricted float | 783 # unrestricted syntax: unrestricted double | unrestricted float |
784 is_unrestricted = node.GetProperty('UNRESTRICTED') or False | 784 is_unrestricted = node.GetProperty('UNRESTRICTED') or False |
785 return IdlType(node.GetName(), is_unrestricted=is_unrestricted) | 785 return IdlType(node.GetName(), is_unrestricted=is_unrestricted) |
786 elif node_class == 'Any': | 786 elif node_class == 'Any': |
787 return IdlType('any') | 787 return IdlType('any') |
788 elif node_class == 'Sequence': | 788 elif node_class == 'Sequence': |
789 return sequence_node_to_type(node) | 789 return sequence_node_to_type(node) |
790 elif node_class == 'UnionType': | 790 elif node_class == 'UnionType': |
791 return union_type_node_to_idl_union_type(node) | 791 return union_type_node_to_idl_union_type(node) |
| 792 elif node_class == 'Promise': |
| 793 return IdlType('Promise') |
792 raise ValueError('Unrecognized node class: %s' % node_class) | 794 raise ValueError('Unrecognized node class: %s' % node_class) |
793 | 795 |
794 | 796 |
795 def sequence_node_to_type(node): | 797 def sequence_node_to_type(node): |
796 children = node.GetChildren() | 798 children = node.GetChildren() |
797 if len(children) != 1: | 799 if len(children) != 1: |
798 raise ValueError('Sequence node expects exactly 1 child, got %s' % len(c
hildren)) | 800 raise ValueError('Sequence node expects exactly 1 child, got %s' % len(c
hildren)) |
799 sequence_child = children[0] | 801 sequence_child = children[0] |
800 sequence_child_class = sequence_child.GetClass() | 802 sequence_child_class = sequence_child.GetClass() |
801 if sequence_child_class != 'Type': | 803 if sequence_child_class != 'Type': |
(...skipping 13 matching lines...) Expand all Loading... |
815 child_class = child.GetClass() | 817 child_class = child.GetClass() |
816 if child_class != 'Type': | 818 if child_class != 'Type': |
817 raise ValueError('Unrecognized node class: %s' % child_class) | 819 raise ValueError('Unrecognized node class: %s' % child_class) |
818 return type_node_to_type(child) | 820 return type_node_to_type(child) |
819 | 821 |
820 | 822 |
821 def union_type_node_to_idl_union_type(node): | 823 def union_type_node_to_idl_union_type(node): |
822 member_types = [type_node_to_type(member_type_node) | 824 member_types = [type_node_to_type(member_type_node) |
823 for member_type_node in node.GetChildren()] | 825 for member_type_node in node.GetChildren()] |
824 return IdlUnionType(member_types) | 826 return IdlUnionType(member_types) |
OLD | NEW |