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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 """ | 204 """ |
| 205 | 205 |
| 206 if (idl_type.is_numeric_type): | 206 if (idl_type.is_numeric_type): |
| 207 return ' = 0' | 207 return ' = 0' |
| 208 if idl_type.base_type == 'boolean': | 208 if idl_type.base_type == 'boolean': |
| 209 return ' = false' | 209 return ' = false' |
| 210 return '' | 210 return '' |
| 211 | 211 |
| 212 | 212 |
| 213 def cpp_type_union(idl_type, extended_attributes=None, raw_type=False): | 213 def cpp_type_union(idl_type, extended_attributes=None, raw_type=False): |
| 214 return (member_type.cpp_type for member_type in idl_type.member_types) | 214 cpp_types = [] |
|
bashi
2014/08/15 02:43:53
Use list (not set) to keep the order of members.
| |
| 215 for member_type in idl_type.member_types: | |
| 216 if member_type.is_string_type: | |
| 217 cpp_types.append(member_type.cpp_type) | |
| 218 else: | |
| 219 cpp_types.append( | |
| 220 cpp_template_type('Nullable', member_type.cpp_type)) | |
| 221 return cpp_types | |
| 215 | 222 |
| 216 | 223 |
| 217 def cpp_type_initializer_union(idl_type): | 224 def cpp_type_initializer_union(idl_type): |
| 218 return (member_type.cpp_type_initializer for member_type in idl_type.member_ types) | 225 return (member_type.cpp_type_initializer for member_type in idl_type.member_ types) |
| 219 | 226 |
| 220 | 227 |
| 221 # Allow access as idl_type.cpp_type if no arguments | 228 # Allow access as idl_type.cpp_type if no arguments |
| 222 IdlTypeBase.cpp_type = property(cpp_type) | 229 IdlTypeBase.cpp_type = property(cpp_type) |
| 223 IdlTypeBase.cpp_type_initializer = property(cpp_type_initializer) | 230 IdlTypeBase.cpp_type_initializer = property(cpp_type_initializer) |
| 224 IdlTypeBase.cpp_type_args = cpp_type | 231 IdlTypeBase.cpp_type_args = cpp_type |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 716 statement = format_string.format(cpp_value=cpp_value, script_wrappable=scrip t_wrappable) | 723 statement = format_string.format(cpp_value=cpp_value, script_wrappable=scrip t_wrappable) |
| 717 return statement | 724 return statement |
| 718 | 725 |
| 719 | 726 |
| 720 def v8_set_return_value_union(idl_type, cpp_value, extended_attributes=None, scr ipt_wrappable='', release=False, for_main_world=False): | 727 def v8_set_return_value_union(idl_type, cpp_value, extended_attributes=None, scr ipt_wrappable='', release=False, for_main_world=False): |
| 721 """ | 728 """ |
| 722 release: can be either False (False for all member types) or | 729 release: can be either False (False for all member types) or |
| 723 a sequence (list or tuple) of booleans (if specified individually). | 730 a sequence (list or tuple) of booleans (if specified individually). |
| 724 """ | 731 """ |
| 725 | 732 |
| 726 return [ | 733 member_return_values = [] |
| 727 member_type.v8_set_return_value(cpp_value + str(i), | 734 for index, member_type in enumerate(idl_type.member_types): |
| 728 extended_attributes, | 735 if member_type.is_string_type: |
|
bashi
2014/08/15 02:43:53
or cpp_type_has_null_value?
| |
| 729 script_wrappable, | 736 member_cpp_value = '%s%d' % (cpp_value, index) |
| 730 release and release[i], | 737 else: |
| 731 for_main_world) | 738 member_cpp_value = '%s%d.get()' % (cpp_value, index) |
| 732 for i, member_type in | 739 member_return_values.append( |
| 733 enumerate(idl_type.member_types)] | 740 member_type.v8_set_return_value(member_cpp_value, |
| 741 extended_attributes, | |
| 742 script_wrappable, | |
| 743 release and release[index], | |
| 744 for_main_world)) | |
| 745 return member_return_values | |
| 746 | |
| 734 | 747 |
| 735 IdlTypeBase.v8_set_return_value = v8_set_return_value | 748 IdlTypeBase.v8_set_return_value = v8_set_return_value |
| 736 IdlUnionType.v8_set_return_value = v8_set_return_value_union | 749 IdlUnionType.v8_set_return_value = v8_set_return_value_union |
| 737 | 750 |
| 738 IdlType.release = property(lambda self: self.is_interface_type) | 751 IdlType.release = property(lambda self: self.is_interface_type) |
| 739 IdlUnionType.release = property( | 752 IdlUnionType.release = property( |
| 740 lambda self: [member_type.is_interface_type | 753 lambda self: [member_type.is_interface_type |
| 741 for member_type in self.member_types]) | 754 for member_type in self.member_types]) |
| 742 IdlArrayOrSequenceType.release = False | 755 IdlArrayOrSequenceType.release = False |
| 743 | 756 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 813 | 826 |
| 814 | 827 |
| 815 def is_explicit_nullable(idl_type): | 828 def is_explicit_nullable(idl_type): |
| 816 # Nullable type that isn't implicit nullable (see above.) For such types, | 829 # Nullable type that isn't implicit nullable (see above.) For such types, |
| 817 # we use Nullable<T> or similar explicit ways to represent a null value. | 830 # we use Nullable<T> or similar explicit ways to represent a null value. |
| 818 return idl_type.is_nullable and not idl_type.is_implicit_nullable | 831 return idl_type.is_nullable and not idl_type.is_implicit_nullable |
| 819 | 832 |
| 820 IdlTypeBase.is_implicit_nullable = property(is_implicit_nullable) | 833 IdlTypeBase.is_implicit_nullable = property(is_implicit_nullable) |
| 821 IdlUnionType.is_implicit_nullable = False | 834 IdlUnionType.is_implicit_nullable = False |
| 822 IdlTypeBase.is_explicit_nullable = property(is_explicit_nullable) | 835 IdlTypeBase.is_explicit_nullable = property(is_explicit_nullable) |
| OLD | NEW |