| 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 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 return type_node_inner_to_type(type_node_child, is_array=is_array, is_nullab
le=is_nullable) | 646 return type_node_inner_to_type(type_node_child, is_array=is_array, is_nullab
le=is_nullable) |
| 647 | 647 |
| 648 | 648 |
| 649 def type_node_inner_to_type(node, is_array=False, is_nullable=False): | 649 def type_node_inner_to_type(node, is_array=False, is_nullable=False): |
| 650 # FIXME: remove is_array and is_nullable once have IdlArrayType and IdlNulla
bleType | 650 # FIXME: remove is_array and is_nullable once have IdlArrayType and IdlNulla
bleType |
| 651 node_class = node.GetClass() | 651 node_class = node.GetClass() |
| 652 # Note Type*r*ef, not Typedef, meaning the type is an identifier, thus | 652 # Note Type*r*ef, not Typedef, meaning the type is an identifier, thus |
| 653 # either a typedef shorthand (but not a Typedef declaration itself) or an | 653 # either a typedef shorthand (but not a Typedef declaration itself) or an |
| 654 # interface type. We do not distinguish these, and just use the type name. | 654 # interface type. We do not distinguish these, and just use the type name. |
| 655 if node_class in ['PrimitiveType', 'Typeref']: | 655 if node_class in ['PrimitiveType', 'Typeref']: |
| 656 return IdlType(node.GetName(), is_array=is_array, is_nullable=is_nullabl
e) | 656 # unrestricted syntax: unrestricted double | unrestricted float |
| 657 is_unrestricted = node.GetProperty('UNRESTRICTED') or False |
| 658 return IdlType(node.GetName(), is_array=is_array, is_nullable=is_nullabl
e, is_unrestricted=is_unrestricted) |
| 657 elif node_class == 'Any': | 659 elif node_class == 'Any': |
| 658 return IdlType('any', is_array=is_array, is_nullable=is_nullable) | 660 return IdlType('any', is_array=is_array, is_nullable=is_nullable) |
| 659 elif node_class == 'Sequence': | 661 elif node_class == 'Sequence': |
| 660 if is_array: | 662 if is_array: |
| 661 raise ValueError('Arrays of sequences are not supported') | 663 raise ValueError('Arrays of sequences are not supported') |
| 662 return sequence_node_to_type(node, is_nullable=is_nullable) | 664 return sequence_node_to_type(node, is_nullable=is_nullable) |
| 663 elif node_class == 'UnionType': | 665 elif node_class == 'UnionType': |
| 664 if is_array: | 666 if is_array: |
| 665 raise ValueError('Arrays of unions are not supported') | 667 raise ValueError('Arrays of unions are not supported') |
| 666 return union_type_node_to_idl_union_type(node, is_nullable=is_nullable) | 668 return union_type_node_to_idl_union_type(node, is_nullable=is_nullable) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 687 child_class = child.GetClass() | 689 child_class = child.GetClass() |
| 688 if child_class != 'Type': | 690 if child_class != 'Type': |
| 689 raise ValueError('Unrecognized node class: %s' % child_class) | 691 raise ValueError('Unrecognized node class: %s' % child_class) |
| 690 return type_node_to_type(child) | 692 return type_node_to_type(child) |
| 691 | 693 |
| 692 | 694 |
| 693 def union_type_node_to_idl_union_type(node, is_nullable=False): | 695 def union_type_node_to_idl_union_type(node, is_nullable=False): |
| 694 member_types = [type_node_to_type(member_type_node) | 696 member_types = [type_node_to_type(member_type_node) |
| 695 for member_type_node in node.GetChildren()] | 697 for member_type_node in node.GetChildren()] |
| 696 return IdlUnionType(member_types, is_nullable=is_nullable) | 698 return IdlUnionType(member_types, is_nullable=is_nullable) |
| OLD | NEW |