| 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 raw_type: | 131 raw_type: |
| 132 bool, True if idl_type's raw/primitive C++ type should be returned. | 132 bool, True if idl_type's raw/primitive C++ type should be returned. |
| 133 used_as_argument: | 133 used_as_argument: |
| 134 bool, True if the C++ type is used as an argument of a method. | 134 bool, True if the C++ type is used as an argument of a method. |
| 135 used_as_variadic_argument: | 135 used_as_variadic_argument: |
| 136 bool, True if the C++ type is used as a variadic argument of a metho
d. | 136 bool, True if the C++ type is used as a variadic argument of a metho
d. |
| 137 used_in_cpp_sequence: | 137 used_in_cpp_sequence: |
| 138 bool, True if the C++ type is used as an element of an array or sequ
ence. | 138 bool, True if the C++ type is used as an element of an array or sequ
ence. |
| 139 """ | 139 """ |
| 140 def string_mode(): | 140 def string_mode(): |
| 141 if idl_type.is_nullable: | |
| 142 return 'WithNullCheck' | |
| 143 # FIXME: the Web IDL spec requires 'EmptyString', not 'NullString', | 141 # FIXME: the Web IDL spec requires 'EmptyString', not 'NullString', |
| 144 # but we use NullString for performance. | 142 # but we use NullString for performance. |
| 145 if extended_attributes.get('TreatNullAs') != 'NullString': | 143 if idl_type.is_nullable or extended_attributes.get('TreatNullAs') == 'Nu
llString': |
| 146 return '' | 144 if extended_attributes.get('TreatUndefinedAs') == 'NullString': |
| 147 if extended_attributes.get('TreatUndefinedAs') != 'NullString': | 145 return 'WithUndefinedOrNullCheck' |
| 148 return 'WithNullCheck' | 146 return 'WithNullCheck' |
| 149 return 'WithUndefinedOrNullCheck' | 147 return '' |
| 150 | 148 |
| 151 extended_attributes = extended_attributes or {} | 149 extended_attributes = extended_attributes or {} |
| 152 idl_type = idl_type.preprocessed_type | 150 idl_type = idl_type.preprocessed_type |
| 153 | 151 |
| 154 # Composite types | 152 # Composite types |
| 155 if used_as_variadic_argument: | 153 if used_as_variadic_argument: |
| 156 array_or_sequence_type = idl_type | 154 array_or_sequence_type = idl_type |
| 157 else: | 155 else: |
| 158 array_or_sequence_type = idl_type.array_or_sequence_type | 156 array_or_sequence_type = idl_type.array_or_sequence_type |
| 159 if array_or_sequence_type: | 157 if array_or_sequence_type: |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 | 706 |
| 709 def literal_cpp_value(idl_type, idl_literal): | 707 def literal_cpp_value(idl_type, idl_literal): |
| 710 """Converts an expression that is a valid C++ literal for this type.""" | 708 """Converts an expression that is a valid C++ literal for this type.""" |
| 711 # FIXME: add validation that idl_type and idl_literal are compatible | 709 # FIXME: add validation that idl_type and idl_literal are compatible |
| 712 literal_value = str(idl_literal) | 710 literal_value = str(idl_literal) |
| 713 if idl_type.base_type in CPP_UNSIGNED_TYPES: | 711 if idl_type.base_type in CPP_UNSIGNED_TYPES: |
| 714 return literal_value + 'u' | 712 return literal_value + 'u' |
| 715 return literal_value | 713 return literal_value |
| 716 | 714 |
| 717 IdlType.literal_cpp_value = literal_cpp_value | 715 IdlType.literal_cpp_value = literal_cpp_value |
| OLD | NEW |