Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(345)

Side by Side Diff: Source/bindings/scripts/v8_interface.py

Issue 968573004: [bindings] Support extended attribute '[CallWith=ScriptState ]' for getter/setter/deleter. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@972153002
Patch Set: Review comments addressed. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Source/bindings/templates/interface.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_raises_exception = 'RaisesException' in extended_attributes 1238 is_raises_exception = 'RaisesException' in extended_attributes
1239 is_call_with_script_state = v8_utilities.has_extended_attribute_value(getter , 'CallWith', 'ScriptState')
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,
1255 'is_custom': 1258 'is_custom':
1256 'Custom' in extended_attributes and 1259 'Custom' in extended_attributes and
1257 (not extended_attributes['Custom'] or 1260 (not extended_attributes['Custom'] or
1258 has_extended_attribute_value(getter, 'Custom', 'PropertyGetter')), 1261 has_extended_attribute_value(getter, 'Custom', 'PropertyGetter')),
1259 'is_custom_property_enumerator': has_extended_attribute_value( 1262 'is_custom_property_enumerator': has_extended_attribute_value(
1260 getter, 'Custom', 'PropertyEnumerator'), 1263 getter, 'Custom', 'PropertyEnumerator'),
1261 'is_custom_property_query': has_extended_attribute_value( 1264 'is_custom_property_query': has_extended_attribute_value(
1262 getter, 'Custom', 'PropertyQuery'), 1265 getter, 'Custom', 'PropertyQuery'),
1263 'is_enumerable': 'NotEnumerable' not in extended_attributes, 1266 'is_enumerable': 'NotEnumerable' not in extended_attributes,
1264 'is_null_expression': is_null_expression(idl_type), 1267 'is_null_expression': is_null_expression(idl_type),
1265 'is_raises_exception': is_raises_exception, 1268 'is_raises_exception': is_raises_exception,
1269 'is_call_with_script_state': is_call_with_script_state,
Jens Widell 2015/03/05 07:18:07 Nit: Move up a bit; the list should be sorted.
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
1278 is_raises_exception = 'RaisesException' in extended_attributes 1282 is_raises_exception = 'RaisesException' in extended_attributes
1283 is_call_with_script_state = v8_utilities.has_extended_attribute_value(setter , 'CallWith', 'ScriptState')
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,
1290 'is_custom': 'Custom' in extended_attributes, 1295 'is_custom': 'Custom' in extended_attributes,
1291 'is_nullable': idl_type.is_nullable, 1296 'is_nullable': idl_type.is_nullable,
1292 'is_raises_exception': is_raises_exception, 1297 'is_raises_exception': is_raises_exception,
1298 'is_call_with_script_state': is_call_with_script_state,
Jens Widell 2015/03/05 07:18:06 Nit: Move up a bit; the list should be sorted.
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 {
1306 'is_custom': 'Custom' in extended_attributes, 1313 'is_custom': 'Custom' in extended_attributes,
1307 'is_raises_exception': 'RaisesException' in extended_attributes, 1314 'is_raises_exception': 'RaisesException' in extended_attributes,
1315 'is_call_with_script_state': is_call_with_script_state,
Jens Widell 2015/03/05 07:18:06 Nit: Move up a bit; the list should be sorted.
1308 'name': cpp_name(deleter), 1316 'name': cpp_name(deleter),
1309 } 1317 }
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/templates/interface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698