| 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 # FIXME: Need to revisit the design of union support. |
| 215 # http://crbug.com/240176 |
| 216 return None |
| 215 | 217 |
| 216 | 218 |
| 217 def cpp_type_initializer_union(idl_type): | 219 def cpp_type_initializer_union(idl_type): |
| 218 return (member_type.cpp_type_initializer for member_type in idl_type.member_
types) | 220 return (member_type.cpp_type_initializer for member_type in idl_type.member_
types) |
| 219 | 221 |
| 220 | 222 |
| 221 # Allow access as idl_type.cpp_type if no arguments | 223 # Allow access as idl_type.cpp_type if no arguments |
| 222 IdlTypeBase.cpp_type = property(cpp_type) | 224 IdlTypeBase.cpp_type = property(cpp_type) |
| 223 IdlTypeBase.cpp_type_initializer = property(cpp_type_initializer) | 225 IdlTypeBase.cpp_type_initializer = property(cpp_type_initializer) |
| 224 IdlTypeBase.cpp_type_args = cpp_type | 226 IdlTypeBase.cpp_type_args = cpp_type |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 | 713 |
| 712 format_string = V8_SET_RETURN_VALUE[this_v8_conversion_type] | 714 format_string = V8_SET_RETURN_VALUE[this_v8_conversion_type] |
| 713 # FIXME: oilpan: Remove .release() once we remove all RefPtrs from generated
code. | 715 # FIXME: oilpan: Remove .release() once we remove all RefPtrs from generated
code. |
| 714 if release: | 716 if release: |
| 715 cpp_value = '%s.release()' % cpp_value | 717 cpp_value = '%s.release()' % cpp_value |
| 716 statement = format_string.format(cpp_value=cpp_value, script_wrappable=scrip
t_wrappable) | 718 statement = format_string.format(cpp_value=cpp_value, script_wrappable=scrip
t_wrappable) |
| 717 return statement | 719 return statement |
| 718 | 720 |
| 719 | 721 |
| 720 def v8_set_return_value_union(idl_type, cpp_value, extended_attributes=None, scr
ipt_wrappable='', release=False, for_main_world=False): | 722 def v8_set_return_value_union(idl_type, cpp_value, extended_attributes=None, scr
ipt_wrappable='', release=False, for_main_world=False): |
| 721 """ | 723 # FIXME: Need to revisit the design of union support. |
| 722 release: can be either False (False for all member types) or | 724 # http://crbug.com/240176 |
| 723 a sequence (list or tuple) of booleans (if specified individually). | 725 return None |
| 724 """ | |
| 725 | 726 |
| 726 return [ | |
| 727 member_type.v8_set_return_value(cpp_value + str(i), | |
| 728 extended_attributes, | |
| 729 script_wrappable, | |
| 730 release and release[i], | |
| 731 for_main_world) | |
| 732 for i, member_type in | |
| 733 enumerate(idl_type.member_types)] | |
| 734 | 727 |
| 735 IdlTypeBase.v8_set_return_value = v8_set_return_value | 728 IdlTypeBase.v8_set_return_value = v8_set_return_value |
| 736 IdlUnionType.v8_set_return_value = v8_set_return_value_union | 729 IdlUnionType.v8_set_return_value = v8_set_return_value_union |
| 737 | 730 |
| 738 IdlType.release = property(lambda self: self.is_interface_type) | 731 IdlType.release = property(lambda self: self.is_interface_type) |
| 739 IdlUnionType.release = property( | 732 IdlUnionType.release = property( |
| 740 lambda self: [member_type.is_interface_type | 733 lambda self: [member_type.is_interface_type |
| 741 for member_type in self.member_types]) | 734 for member_type in self.member_types]) |
| 742 IdlArrayOrSequenceType.release = False | 735 IdlArrayOrSequenceType.release = False |
| 743 | 736 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 | 806 |
| 814 | 807 |
| 815 def is_explicit_nullable(idl_type): | 808 def is_explicit_nullable(idl_type): |
| 816 # Nullable type that isn't implicit nullable (see above.) For such types, | 809 # 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. | 810 # 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 | 811 return idl_type.is_nullable and not idl_type.is_implicit_nullable |
| 819 | 812 |
| 820 IdlTypeBase.is_implicit_nullable = property(is_implicit_nullable) | 813 IdlTypeBase.is_implicit_nullable = property(is_implicit_nullable) |
| 821 IdlUnionType.is_implicit_nullable = False | 814 IdlUnionType.is_implicit_nullable = False |
| 822 IdlTypeBase.is_explicit_nullable = property(is_explicit_nullable) | 815 IdlTypeBase.is_explicit_nullable = property(is_explicit_nullable) |
| OLD | NEW |