Chromium Code Reviews| 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 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 762 # interface type. We do not distinguish these, and just use the type name. | 762 # interface type. We do not distinguish these, and just use the type name. |
| 763 if node_class in ['PrimitiveType', 'Typeref']: | 763 if node_class in ['PrimitiveType', 'Typeref']: |
| 764 # unrestricted syntax: unrestricted double | unrestricted float | 764 # unrestricted syntax: unrestricted double | unrestricted float |
| 765 is_unrestricted = node.GetProperty('UNRESTRICTED') or False | 765 is_unrestricted = node.GetProperty('UNRESTRICTED') or False |
| 766 return IdlType(node.GetName(), is_array=is_array, is_nullable=is_nullabl e, is_unrestricted=is_unrestricted) | 766 return IdlType(node.GetName(), is_array=is_array, is_nullable=is_nullabl e, is_unrestricted=is_unrestricted) |
| 767 elif node_class == 'Any': | 767 elif node_class == 'Any': |
| 768 return IdlType('any', is_array=is_array, is_nullable=is_nullable) | 768 return IdlType('any', is_array=is_array, is_nullable=is_nullable) |
| 769 elif node_class == 'Sequence': | 769 elif node_class == 'Sequence': |
| 770 if is_array: | 770 if is_array: |
| 771 raise ValueError('Arrays of sequences are not supported') | 771 raise ValueError('Arrays of sequences are not supported') |
| 772 return sequence_node_to_type(node, is_nullable=is_nullable) | 772 sequence_is_nullable = node.GetProperty('NULLABLE') or False |
|
Jens Widell
2014/07/10 14:31:13
This fixes sequence<T>?; we previously used the NU
| |
| 773 return sequence_node_to_type(node, is_nullable=sequence_is_nullable) | |
| 773 elif node_class == 'UnionType': | 774 elif node_class == 'UnionType': |
| 774 if is_array: | 775 if is_array: |
| 775 raise ValueError('Arrays of unions are not supported') | 776 raise ValueError('Arrays of unions are not supported') |
| 776 return union_type_node_to_idl_union_type(node, is_nullable=is_nullable) | 777 return union_type_node_to_idl_union_type(node, is_nullable=is_nullable) |
| 777 raise ValueError('Unrecognized node class: %s' % node_class) | 778 raise ValueError('Unrecognized node class: %s' % node_class) |
| 778 | 779 |
| 779 | 780 |
| 780 def sequence_node_to_type(node, is_nullable=False): | 781 def sequence_node_to_type(node, is_nullable=False): |
| 781 children = node.GetChildren() | 782 children = node.GetChildren() |
| 782 if len(children) != 1: | 783 if len(children) != 1: |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 797 child_class = child.GetClass() | 798 child_class = child.GetClass() |
| 798 if child_class != 'Type': | 799 if child_class != 'Type': |
| 799 raise ValueError('Unrecognized node class: %s' % child_class) | 800 raise ValueError('Unrecognized node class: %s' % child_class) |
| 800 return type_node_to_type(child) | 801 return type_node_to_type(child) |
| 801 | 802 |
| 802 | 803 |
| 803 def union_type_node_to_idl_union_type(node, is_nullable=False): | 804 def union_type_node_to_idl_union_type(node, is_nullable=False): |
| 804 member_types = [type_node_to_type(member_type_node) | 805 member_types = [type_node_to_type(member_type_node) |
| 805 for member_type_node in node.GetChildren()] | 806 for member_type_node in node.GetChildren()] |
| 806 return IdlUnionType(member_types, is_nullable=is_nullable) | 807 return IdlUnionType(member_types, is_nullable=is_nullable) |
| OLD | NEW |