| OLD | NEW |
| 1 # Copyright (C) 2013 Google Inc. All rights reserved. | 1 # Copyright (C) 2013 Google Inc. All rights reserved. |
| 2 # coding=utf-8 | 2 # coding=utf-8 |
| 3 # | 3 # |
| 4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
| 5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
| 6 # met: | 6 # met: |
| 7 # | 7 # |
| 8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
| 9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
| 10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
| (...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1168 getter, 'Custom', 'PropertyQuery'), | 1168 getter, 'Custom', 'PropertyQuery'), |
| 1169 'is_enumerable': 'NotEnumerable' not in extended_attributes, | 1169 'is_enumerable': 'NotEnumerable' not in extended_attributes, |
| 1170 'is_null_expression': is_null_expression(idl_type), | 1170 'is_null_expression': is_null_expression(idl_type), |
| 1171 'is_raises_exception': is_raises_exception, | 1171 'is_raises_exception': is_raises_exception, |
| 1172 'name': cpp_name(getter), | 1172 'name': cpp_name(getter), |
| 1173 'use_output_parameter_for_result': use_output_parameter_for_result, | 1173 'use_output_parameter_for_result': use_output_parameter_for_result, |
| 1174 'v8_set_return_value': idl_type.v8_set_return_value('result', extended_a
ttributes=extended_attributes, script_wrappable='impl', release=idl_type.release
), | 1174 'v8_set_return_value': idl_type.v8_set_return_value('result', extended_a
ttributes=extended_attributes, script_wrappable='impl', release=idl_type.release
), |
| 1175 } | 1175 } |
| 1176 | 1176 |
| 1177 | 1177 |
| 1178 def property_setter(setter): | 1178 def property_setter(interface, setter): |
| 1179 idl_type = setter.arguments[1].idl_type | 1179 idl_type = setter.arguments[1].idl_type |
| 1180 extended_attributes = setter.extended_attributes | 1180 extended_attributes = setter.extended_attributes |
| 1181 is_raises_exception = 'RaisesException' in extended_attributes | 1181 is_raises_exception = 'RaisesException' in extended_attributes |
| 1182 restricted_float = ( |
| 1183 has_extended_attribute_value(interface, 'TypeChecking', 'Unrestricted')
or |
| 1184 has_extended_attribute_value(setter, 'TypeChecking', 'Unrestricted')) |
| 1182 return { | 1185 return { |
| 1183 'has_type_checking_interface': | 1186 'has_type_checking_interface': |
| 1187 # FIXME: check interface's [TypeChecking] attribute too. |
| 1184 has_extended_attribute_value(setter, 'TypeChecking', 'Interface') an
d | 1188 has_extended_attribute_value(setter, 'TypeChecking', 'Interface') an
d |
| 1185 idl_type.is_wrapper_type, | 1189 idl_type.is_wrapper_type, |
| 1186 'idl_type': idl_type.base_type, | 1190 'idl_type': idl_type.base_type, |
| 1187 'is_custom': 'Custom' in extended_attributes, | 1191 'is_custom': 'Custom' in extended_attributes, |
| 1188 'has_exception_state': (is_raises_exception or | 1192 'has_exception_state': (is_raises_exception or |
| 1189 idl_type.v8_conversion_needs_exception_state), | 1193 idl_type.v8_conversion_needs_exception_state), |
| 1190 'is_raises_exception': is_raises_exception, | 1194 'is_raises_exception': is_raises_exception, |
| 1191 'name': cpp_name(setter), | 1195 'name': cpp_name(setter), |
| 1192 'v8_value_to_local_cpp_value': idl_type.v8_value_to_local_cpp_value( | 1196 'v8_value_to_local_cpp_value': idl_type.v8_value_to_local_cpp_value( |
| 1193 extended_attributes, 'v8Value', 'propertyValue'), | 1197 extended_attributes, 'v8Value', 'propertyValue', restricted_float), |
| 1194 } | 1198 } |
| 1195 | 1199 |
| 1196 | 1200 |
| 1197 def property_deleter(deleter): | 1201 def property_deleter(deleter): |
| 1198 idl_type = deleter.idl_type | 1202 idl_type = deleter.idl_type |
| 1199 if str(idl_type) != 'boolean': | 1203 if str(idl_type) != 'boolean': |
| 1200 raise Exception( | 1204 raise Exception( |
| 1201 'Only deleters with boolean type are allowed, but type is "%s"' % | 1205 'Only deleters with boolean type are allowed, but type is "%s"' % |
| 1202 idl_type) | 1206 idl_type) |
| 1203 extended_attributes = deleter.extended_attributes | 1207 extended_attributes = deleter.extended_attributes |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1235 # setter RETURN_TYPE [OPTIONAL_IDENTIFIER](unsigned long ARG1, ARG_TYPE
ARG2) | 1239 # setter RETURN_TYPE [OPTIONAL_IDENTIFIER](unsigned long ARG1, ARG_TYPE
ARG2) |
| 1236 setter = next( | 1240 setter = next( |
| 1237 method | 1241 method |
| 1238 for method in interface.operations | 1242 for method in interface.operations |
| 1239 if ('setter' in method.specials and | 1243 if ('setter' in method.specials and |
| 1240 len(method.arguments) == 2 and | 1244 len(method.arguments) == 2 and |
| 1241 str(method.arguments[0].idl_type) == 'unsigned long')) | 1245 str(method.arguments[0].idl_type) == 'unsigned long')) |
| 1242 except StopIteration: | 1246 except StopIteration: |
| 1243 return None | 1247 return None |
| 1244 | 1248 |
| 1245 return property_setter(setter) | 1249 return property_setter(interface, setter) |
| 1246 | 1250 |
| 1247 | 1251 |
| 1248 def indexed_property_deleter(interface): | 1252 def indexed_property_deleter(interface): |
| 1249 try: | 1253 try: |
| 1250 # Find indexed property deleter, if present; has form: | 1254 # Find indexed property deleter, if present; has form: |
| 1251 # deleter TYPE [OPTIONAL_IDENTIFIER](unsigned long ARG) | 1255 # deleter TYPE [OPTIONAL_IDENTIFIER](unsigned long ARG) |
| 1252 deleter = next( | 1256 deleter = next( |
| 1253 method | 1257 method |
| 1254 for method in interface.operations | 1258 for method in interface.operations |
| 1255 if ('deleter' in method.specials and | 1259 if ('deleter' in method.specials and |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1289 # setter RETURN_TYPE [OPTIONAL_IDENTIFIER](DOMString ARG1, ARG_TYPE ARG2
) | 1293 # setter RETURN_TYPE [OPTIONAL_IDENTIFIER](DOMString ARG1, ARG_TYPE ARG2
) |
| 1290 setter = next( | 1294 setter = next( |
| 1291 method | 1295 method |
| 1292 for method in interface.operations | 1296 for method in interface.operations |
| 1293 if ('setter' in method.specials and | 1297 if ('setter' in method.specials and |
| 1294 len(method.arguments) == 2 and | 1298 len(method.arguments) == 2 and |
| 1295 str(method.arguments[0].idl_type) == 'DOMString')) | 1299 str(method.arguments[0].idl_type) == 'DOMString')) |
| 1296 except StopIteration: | 1300 except StopIteration: |
| 1297 return None | 1301 return None |
| 1298 | 1302 |
| 1299 return property_setter(setter) | 1303 return property_setter(interface, setter) |
| 1300 | 1304 |
| 1301 | 1305 |
| 1302 def named_property_deleter(interface): | 1306 def named_property_deleter(interface): |
| 1303 try: | 1307 try: |
| 1304 # Find named property deleter, if present; has form: | 1308 # Find named property deleter, if present; has form: |
| 1305 # deleter TYPE [OPTIONAL_IDENTIFIER](DOMString ARG) | 1309 # deleter TYPE [OPTIONAL_IDENTIFIER](DOMString ARG) |
| 1306 deleter = next( | 1310 deleter = next( |
| 1307 method | 1311 method |
| 1308 for method in interface.operations | 1312 for method in interface.operations |
| 1309 if ('deleter' in method.specials and | 1313 if ('deleter' in method.specials and |
| 1310 len(method.arguments) == 1 and | 1314 len(method.arguments) == 1 and |
| 1311 str(method.arguments[0].idl_type) == 'DOMString')) | 1315 str(method.arguments[0].idl_type) == 'DOMString')) |
| 1312 except StopIteration: | 1316 except StopIteration: |
| 1313 return None | 1317 return None |
| 1314 | 1318 |
| 1315 return property_deleter(deleter) | 1319 return property_deleter(deleter) |
| OLD | NEW |