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 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1228 if idl_type.is_string_type: | 1228 if idl_type.is_string_type: |
1229 return 'result.isNull()' | 1229 return 'result.isNull()' |
1230 if idl_type.is_interface_type: | 1230 if idl_type.is_interface_type: |
1231 return '!result' | 1231 return '!result' |
1232 if idl_type.base_type in ('any', 'object'): | 1232 if idl_type.base_type in ('any', 'object'): |
1233 return 'result.isEmpty()' | 1233 return 'result.isEmpty()' |
1234 return '' | 1234 return '' |
1235 | 1235 |
1236 idl_type = getter.idl_type | 1236 idl_type = getter.idl_type |
1237 extended_attributes = getter.extended_attributes | 1237 extended_attributes = getter.extended_attributes |
| 1238 is_call_with_script_state = v8_utilities.has_extended_attribute_value(getter
, 'CallWith', 'ScriptState') |
1238 is_raises_exception = 'RaisesException' in extended_attributes | 1239 is_raises_exception = 'RaisesException' in extended_attributes |
1239 use_output_parameter_for_result = idl_type.use_output_parameter_for_result | 1240 use_output_parameter_for_result = idl_type.use_output_parameter_for_result |
1240 | 1241 |
1241 # FIXME: make more generic, so can use v8_methods.cpp_value | 1242 # FIXME: make more generic, so can use v8_methods.cpp_value |
1242 cpp_method_name = 'impl->%s' % cpp_name(getter) | 1243 cpp_method_name = 'impl->%s' % cpp_name(getter) |
1243 | 1244 |
| 1245 if is_call_with_script_state: |
| 1246 cpp_arguments.insert(0, 'scriptState') |
1244 if is_raises_exception: | 1247 if is_raises_exception: |
1245 cpp_arguments.append('exceptionState') | 1248 cpp_arguments.append('exceptionState') |
1246 if use_output_parameter_for_result: | 1249 if use_output_parameter_for_result: |
1247 cpp_arguments.append('result') | 1250 cpp_arguments.append('result') |
1248 | 1251 |
1249 cpp_value = '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments)) | 1252 cpp_value = '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments)) |
1250 | 1253 |
1251 return { | 1254 return { |
1252 'cpp_type': idl_type.cpp_type, | 1255 'cpp_type': idl_type.cpp_type, |
1253 'cpp_value': cpp_value, | 1256 'cpp_value': cpp_value, |
1254 'do_not_check_security': 'DoNotCheckSecurity' in extended_attributes, | 1257 'do_not_check_security': 'DoNotCheckSecurity' in extended_attributes, |
| 1258 'is_call_with_script_state': is_call_with_script_state, |
1255 'is_custom': | 1259 'is_custom': |
1256 'Custom' in extended_attributes and | 1260 'Custom' in extended_attributes and |
1257 (not extended_attributes['Custom'] or | 1261 (not extended_attributes['Custom'] or |
1258 has_extended_attribute_value(getter, 'Custom', 'PropertyGetter')), | 1262 has_extended_attribute_value(getter, 'Custom', 'PropertyGetter')), |
1259 'is_custom_property_enumerator': has_extended_attribute_value( | 1263 'is_custom_property_enumerator': has_extended_attribute_value( |
1260 getter, 'Custom', 'PropertyEnumerator'), | 1264 getter, 'Custom', 'PropertyEnumerator'), |
1261 'is_custom_property_query': has_extended_attribute_value( | 1265 'is_custom_property_query': has_extended_attribute_value( |
1262 getter, 'Custom', 'PropertyQuery'), | 1266 getter, 'Custom', 'PropertyQuery'), |
1263 'is_enumerable': 'NotEnumerable' not in extended_attributes, | 1267 'is_enumerable': 'NotEnumerable' not in extended_attributes, |
1264 'is_null_expression': is_null_expression(idl_type), | 1268 'is_null_expression': is_null_expression(idl_type), |
1265 'is_raises_exception': is_raises_exception, | 1269 'is_raises_exception': is_raises_exception, |
1266 'name': cpp_name(getter), | 1270 'name': cpp_name(getter), |
1267 'use_output_parameter_for_result': use_output_parameter_for_result, | 1271 'use_output_parameter_for_result': use_output_parameter_for_result, |
1268 'v8_set_return_value': idl_type.v8_set_return_value('result', extended_a
ttributes=extended_attributes, script_wrappable='impl', release=idl_type.release
), | 1272 'v8_set_return_value': idl_type.v8_set_return_value('result', extended_a
ttributes=extended_attributes, script_wrappable='impl', release=idl_type.release
), |
1269 } | 1273 } |
1270 | 1274 |
1271 | 1275 |
1272 def property_setter(setter, interface): | 1276 def property_setter(setter, interface): |
1273 if not setter: | 1277 if not setter: |
1274 return None | 1278 return None |
1275 | 1279 |
1276 idl_type = setter.arguments[1].idl_type | 1280 idl_type = setter.arguments[1].idl_type |
1277 extended_attributes = setter.extended_attributes | 1281 extended_attributes = setter.extended_attributes |
| 1282 is_call_with_script_state = v8_utilities.has_extended_attribute_value(setter
, 'CallWith', 'ScriptState') |
1278 is_raises_exception = 'RaisesException' in extended_attributes | 1283 is_raises_exception = 'RaisesException' in extended_attributes |
1279 | 1284 |
1280 # [TypeChecking=Interface] / [LegacyInterfaceTypeChecking] | 1285 # [TypeChecking=Interface] / [LegacyInterfaceTypeChecking] |
1281 has_type_checking_interface = ( | 1286 has_type_checking_interface = ( |
1282 not is_legacy_interface_type_checking(interface, setter) and | 1287 not is_legacy_interface_type_checking(interface, setter) and |
1283 idl_type.is_wrapper_type) | 1288 idl_type.is_wrapper_type) |
1284 | 1289 |
1285 return { | 1290 return { |
1286 'has_exception_state': (is_raises_exception or | 1291 'has_exception_state': (is_raises_exception or |
1287 idl_type.v8_conversion_needs_exception_state), | 1292 idl_type.v8_conversion_needs_exception_state), |
1288 'has_type_checking_interface': has_type_checking_interface, | 1293 'has_type_checking_interface': has_type_checking_interface, |
1289 'idl_type': idl_type.base_type, | 1294 'idl_type': idl_type.base_type, |
| 1295 'is_call_with_script_state': is_call_with_script_state, |
1290 'is_custom': 'Custom' in extended_attributes, | 1296 'is_custom': 'Custom' in extended_attributes, |
1291 'is_nullable': idl_type.is_nullable, | 1297 'is_nullable': idl_type.is_nullable, |
1292 'is_raises_exception': is_raises_exception, | 1298 'is_raises_exception': is_raises_exception, |
1293 'name': cpp_name(setter), | 1299 'name': cpp_name(setter), |
1294 'v8_value_to_local_cpp_value': idl_type.v8_value_to_local_cpp_value( | 1300 'v8_value_to_local_cpp_value': idl_type.v8_value_to_local_cpp_value( |
1295 extended_attributes, 'v8Value', 'propertyValue'), | 1301 extended_attributes, 'v8Value', 'propertyValue'), |
1296 } | 1302 } |
1297 | 1303 |
1298 | 1304 |
1299 def property_deleter(deleter): | 1305 def property_deleter(deleter): |
1300 if not deleter: | 1306 if not deleter: |
1301 return None | 1307 return None |
1302 | 1308 |
1303 idl_type = deleter.idl_type | 1309 idl_type = deleter.idl_type |
1304 extended_attributes = deleter.extended_attributes | 1310 extended_attributes = deleter.extended_attributes |
| 1311 is_call_with_script_state = v8_utilities.has_extended_attribute_value(delete
r, 'CallWith', 'ScriptState') |
1305 return { | 1312 return { |
| 1313 'is_call_with_script_state': is_call_with_script_state, |
1306 'is_custom': 'Custom' in extended_attributes, | 1314 'is_custom': 'Custom' in extended_attributes, |
1307 'is_raises_exception': 'RaisesException' in extended_attributes, | 1315 'is_raises_exception': 'RaisesException' in extended_attributes, |
1308 'name': cpp_name(deleter), | 1316 'name': cpp_name(deleter), |
1309 } | 1317 } |
OLD | NEW |