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

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

Issue 340443004: IDL: reuse more code between CG for methods and constructors (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rename scriptContext -> executionContext Created 6 years, 6 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 | « Source/bindings/scripts/idl_definitions.py ('k') | Source/bindings/scripts/v8_interface.py » ('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 # 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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 'v8_set_return_value_for_main_world': v8_set_return_value_statement(for_ main_world=True), 205 'v8_set_return_value_for_main_world': v8_set_return_value_statement(for_ main_world=True),
206 'v8_set_return_value': v8_set_return_value_statement(), 206 'v8_set_return_value': v8_set_return_value_statement(),
207 }) 207 })
208 208
209 209
210 def getter_expression(interface, attribute, contents): 210 def getter_expression(interface, attribute, contents):
211 arguments = [] 211 arguments = []
212 this_getter_base_name = getter_base_name(interface, attribute, arguments) 212 this_getter_base_name = getter_base_name(interface, attribute, arguments)
213 getter_name = scoped_name(interface, attribute, this_getter_base_name) 213 getter_name = scoped_name(interface, attribute, this_getter_base_name)
214 214
215 arguments.extend(v8_utilities.call_with_arguments(attribute)) 215 arguments.extend(v8_utilities.call_with_arguments(
216 attribute.extended_attributes.get('CallWith')))
216 # Members of IDL partial interface definitions are implemented in C++ as 217 # Members of IDL partial interface definitions are implemented in C++ as
217 # static member functions, which for instance members (non-static members) 218 # static member functions, which for instance members (non-static members)
218 # take *impl as their first argument 219 # take *impl as their first argument
219 if ('PartialInterfaceImplementedAs' in attribute.extended_attributes and 220 if ('PartialInterfaceImplementedAs' in attribute.extended_attributes and
220 not attribute.is_static): 221 not attribute.is_static):
221 arguments.append('*impl') 222 arguments.append('*impl')
222 if attribute.idl_type.is_nullable and not contents['has_type_checking_nullab le']: 223 if attribute.idl_type.is_nullable and not contents['has_type_checking_nullab le']:
223 arguments.append('isNull') 224 arguments.append('isNull')
224 if contents['is_getter_raises_exception']: 225 if contents['is_getter_raises_exception']:
225 arguments.append('exceptionState') 226 arguments.append('exceptionState')
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 attribute = target_attribute() 301 attribute = target_attribute()
301 302
302 contents.update({ 303 contents.update({
303 'cpp_setter': setter_expression(interface, attribute, contents), 304 'cpp_setter': setter_expression(interface, attribute, contents),
304 'v8_value_to_local_cpp_value': attribute.idl_type.v8_value_to_local_cpp_ value(extended_attributes, 'v8Value', 'cppValue'), 305 'v8_value_to_local_cpp_value': attribute.idl_type.v8_value_to_local_cpp_ value(extended_attributes, 'v8Value', 'cppValue'),
305 }) 306 })
306 307
307 308
308 def setter_expression(interface, attribute, contents): 309 def setter_expression(interface, attribute, contents):
309 extended_attributes = attribute.extended_attributes 310 extended_attributes = attribute.extended_attributes
310 arguments = v8_utilities.call_with_arguments(attribute, extended_attributes. get('SetterCallWith')) 311 arguments = v8_utilities.call_with_arguments(
312 extended_attributes.get('SetterCallWith') or
313 extended_attributes.get('CallWith'))
311 314
312 this_setter_base_name = setter_base_name(interface, attribute, arguments) 315 this_setter_base_name = setter_base_name(interface, attribute, arguments)
313 setter_name = scoped_name(interface, attribute, this_setter_base_name) 316 setter_name = scoped_name(interface, attribute, this_setter_base_name)
314 317
315 # Members of IDL partial interface definitions are implemented in C++ as 318 # Members of IDL partial interface definitions are implemented in C++ as
316 # static member functions, which for instance members (non-static members) 319 # static member functions, which for instance members (non-static members)
317 # take *impl as their first argument 320 # take *impl as their first argument
318 if ('PartialInterfaceImplementedAs' in extended_attributes and 321 if ('PartialInterfaceImplementedAs' in extended_attributes and
319 not attribute.is_static): 322 not attribute.is_static):
320 arguments.append('*impl') 323 arguments.append('*impl')
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 lambda self: strip_suffix(self.base_type, 'Constructor')) 425 lambda self: strip_suffix(self.base_type, 'Constructor'))
423 426
424 427
425 def is_constructor_attribute(attribute): 428 def is_constructor_attribute(attribute):
426 # FIXME: replace this with [ConstructorAttribute] extended attribute 429 # FIXME: replace this with [ConstructorAttribute] extended attribute
427 return attribute.idl_type.base_type.endswith('Constructor') 430 return attribute.idl_type.base_type.endswith('Constructor')
428 431
429 432
430 def generate_constructor_getter(interface, attribute, contents): 433 def generate_constructor_getter(interface, attribute, contents):
431 contents['needs_constructor_getter_callback'] = contents['measure_as'] or co ntents['deprecate_as'] 434 contents['needs_constructor_getter_callback'] = contents['measure_as'] or co ntents['deprecate_as']
OLDNEW
« no previous file with comments | « Source/bindings/scripts/idl_definitions.py ('k') | Source/bindings/scripts/v8_interface.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698