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

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

Issue 808373002: IDL: Simplify [TypeChecking=Interface] code generation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years 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
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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 # [RaisesException], [RaisesException=Setter] 319 # [RaisesException], [RaisesException=Setter]
320 is_setter_raises_exception = ( 320 is_setter_raises_exception = (
321 'RaisesException' in extended_attributes and 321 'RaisesException' in extended_attributes and
322 extended_attributes['RaisesException'] in [None, 'Setter']) 322 extended_attributes['RaisesException'] in [None, 'Setter'])
323 # [TypeChecking=Interface] 323 # [TypeChecking=Interface]
324 has_type_checking_interface = ( 324 has_type_checking_interface = (
325 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface') or 325 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface') or
326 has_extended_attribute_value(attribute, 'TypeChecking', 'Interface')) a nd 326 has_extended_attribute_value(attribute, 'TypeChecking', 'Interface')) a nd
327 idl_type.is_wrapper_type) 327 idl_type.is_wrapper_type)
328 328
329 type_checked = (has_type_checking_interface and
330 # These allow null values, so a type-check is still required .
331 not idl_type.is_nullable)
332
333 context.update({ 329 context.update({
334 'has_setter_exception_state': 330 'has_setter_exception_state':
335 is_setter_raises_exception or has_type_checking_interface or 331 is_setter_raises_exception or has_type_checking_interface or
336 context['has_type_checking_unrestricted'] or 332 context['has_type_checking_unrestricted'] or
337 idl_type.v8_conversion_needs_exception_state, 333 idl_type.v8_conversion_needs_exception_state,
338 'has_type_checking_interface': has_type_checking_interface, 334 'has_type_checking_interface': has_type_checking_interface,
339 'is_setter_call_with_execution_context': v8_utilities.has_extended_attri bute_value( 335 'is_setter_call_with_execution_context': v8_utilities.has_extended_attri bute_value(
340 attribute, 'SetterCallWith', 'ExecutionContext'), 336 attribute, 'SetterCallWith', 'ExecutionContext'),
341 'is_setter_raises_exception': is_setter_raises_exception, 337 'is_setter_raises_exception': is_setter_raises_exception,
342 'private_script_cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value( 338 'private_script_cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value(
343 'cppValue', isolate='scriptState->isolate()', 339 'cppValue', isolate='scriptState->isolate()',
344 creation_context='scriptState->context()->Global()'), 340 creation_context='scriptState->context()->Global()'),
345 'v8_value_to_local_cpp_value': idl_type.v8_value_to_local_cpp_value( 341 'v8_value_to_local_cpp_value': idl_type.v8_value_to_local_cpp_value(
346 extended_attributes, 'v8Value', 'cppValue', 342 extended_attributes, 'v8Value', 'cppValue'),
347 needs_type_check=not type_checked),
348 }) 343 })
349 344
350 # setter_expression() depends on context values we set above. 345 # setter_expression() depends on context values we set above.
351 context['cpp_setter'] = setter_expression(interface, attribute, context) 346 context['cpp_setter'] = setter_expression(interface, attribute, context)
352 347
353 348
354 def setter_expression(interface, attribute, context): 349 def setter_expression(interface, attribute, context):
355 extended_attributes = attribute.extended_attributes 350 extended_attributes = attribute.extended_attributes
356 arguments = v8_utilities.call_with_arguments( 351 arguments = v8_utilities.call_with_arguments(
357 extended_attributes.get('SetterCallWith') or 352 extended_attributes.get('SetterCallWith') or
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 lambda self: strip_suffix(self.base_type, 'Constructor')) 499 lambda self: strip_suffix(self.base_type, 'Constructor'))
505 500
506 501
507 def is_constructor_attribute(attribute): 502 def is_constructor_attribute(attribute):
508 # FIXME: replace this with [ConstructorAttribute] extended attribute 503 # FIXME: replace this with [ConstructorAttribute] extended attribute
509 return attribute.idl_type.name.endswith('Constructor') 504 return attribute.idl_type.name.endswith('Constructor')
510 505
511 506
512 def constructor_getter_context(interface, attribute, context): 507 def constructor_getter_context(interface, attribute, context):
513 context['needs_constructor_getter_callback'] = context['measure_as'] or cont ext['deprecate_as'] 508 context['needs_constructor_getter_callback'] = context['measure_as'] or cont ext['deprecate_as']
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/scripts/v8_methods.py » ('j') | Source/bindings/tests/results/core/V8TestInterface.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698