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

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

Issue 458443002: IDL compiler: Add a helper method for has_custom_getter and has_custom_setter (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 idl_type = attribute.idl_type 45 idl_type = attribute.idl_type
46 base_idl_type = idl_type.base_type 46 base_idl_type = idl_type.base_type
47 extended_attributes = attribute.extended_attributes 47 extended_attributes = attribute.extended_attributes
48 48
49 idl_type.add_includes_for_type() 49 idl_type.add_includes_for_type()
50 50
51 # [CheckSecurity] 51 # [CheckSecurity]
52 is_check_security_for_node = 'CheckSecurity' in extended_attributes 52 is_check_security_for_node = 'CheckSecurity' in extended_attributes
53 if is_check_security_for_node: 53 if is_check_security_for_node:
54 includes.add('bindings/core/v8/BindingSecurity.h') 54 includes.add('bindings/core/v8/BindingSecurity.h')
55 # [Custom]
56 has_custom_getter = ('Custom' in extended_attributes and
57 extended_attributes['Custom'] in [None, 'Getter'])
58 has_custom_setter = (not attribute.is_read_only and
59 'Custom' in extended_attributes and
60 extended_attributes['Custom'] in [None, 'Setter'])
61 # [CustomElementCallbacks], [Reflect] 55 # [CustomElementCallbacks], [Reflect]
62 is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attribute s 56 is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attribute s
63 is_reflect = 'Reflect' in extended_attributes 57 is_reflect = 'Reflect' in extended_attributes
64 if is_custom_element_callbacks or is_reflect: 58 if is_custom_element_callbacks or is_reflect:
65 includes.add('core/dom/custom/CustomElementCallbackDispatcher.h') 59 includes.add('core/dom/custom/CustomElementCallbackDispatcher.h')
66 # [PerWorldBindings] 60 # [PerWorldBindings]
67 if 'PerWorldBindings' in extended_attributes: 61 if 'PerWorldBindings' in extended_attributes:
68 assert idl_type.is_wrapper_type or 'LogActivity' in extended_attributes, '[PerWorldBindings] should only be used with wrapper types: %s.%s' % (interface .name, attribute.name) 62 assert idl_type.is_wrapper_type or 'LogActivity' in extended_attributes, '[PerWorldBindings] should only be used with wrapper types: %s.%s' % (interface .name, attribute.name)
69 # [TypeChecking] 63 # [TypeChecking]
70 has_type_checking_unrestricted = ( 64 has_type_checking_unrestricted = (
(...skipping 24 matching lines...) Expand all
95 'argument_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True), 89 'argument_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True),
96 'cached_attribute_validation_method': extended_attributes.get('CachedAtt ribute'), 90 'cached_attribute_validation_method': extended_attributes.get('CachedAtt ribute'),
97 'conditional_string': v8_utilities.conditional_string(attribute), 91 'conditional_string': v8_utilities.conditional_string(attribute),
98 'constructor_type': idl_type.constructor_type_name 92 'constructor_type': idl_type.constructor_type_name
99 if is_constructor_attribute(attribute) else None, 93 if is_constructor_attribute(attribute) else None,
100 'cpp_name': cpp_name(attribute), 94 'cpp_name': cpp_name(attribute),
101 'cpp_type': idl_type.cpp_type, 95 'cpp_type': idl_type.cpp_type,
102 'cpp_type_initializer': idl_type.cpp_type_initializer, 96 'cpp_type_initializer': idl_type.cpp_type_initializer,
103 'deprecate_as': v8_utilities.deprecate_as(attribute), # [DeprecateAs] 97 'deprecate_as': v8_utilities.deprecate_as(attribute), # [DeprecateAs]
104 'enum_validation_expression': idl_type.enum_validation_expression, 98 'enum_validation_expression': idl_type.enum_validation_expression,
105 'has_custom_getter': has_custom_getter, 99 'has_custom_getter': has_custom_getter(attribute),
106 'has_custom_setter': has_custom_setter, 100 'has_custom_setter': has_custom_setter(attribute),
107 'has_type_checking_unrestricted': has_type_checking_unrestricted, 101 'has_type_checking_unrestricted': has_type_checking_unrestricted,
108 'idl_type': str(idl_type), # need trailing [] on array for Dictionary:: ConversionContext::setConversionType 102 'idl_type': str(idl_type), # need trailing [] on array for Dictionary:: ConversionContext::setConversionType
109 'is_call_with_execution_context': v8_utilities.has_extended_attribute_va lue(attribute, 'CallWith', 'ExecutionContext'), 103 'is_call_with_execution_context': v8_utilities.has_extended_attribute_va lue(attribute, 'CallWith', 'ExecutionContext'),
110 'is_call_with_script_state': v8_utilities.has_extended_attribute_value(a ttribute, 'CallWith', 'ScriptState'), 104 'is_call_with_script_state': v8_utilities.has_extended_attribute_value(a ttribute, 'CallWith', 'ScriptState'),
111 'is_check_security_for_node': is_check_security_for_node, 105 'is_check_security_for_node': is_check_security_for_node,
112 'is_custom_element_callbacks': is_custom_element_callbacks, 106 'is_custom_element_callbacks': is_custom_element_callbacks,
113 'is_expose_js_accessors': 'ExposeJSAccessors' in extended_attributes, 107 'is_expose_js_accessors': 'ExposeJSAccessors' in extended_attributes,
114 'is_getter_raises_exception': # [RaisesException] 108 'is_getter_raises_exception': # [RaisesException]
115 'RaisesException' in extended_attributes and 109 'RaisesException' in extended_attributes and
116 extended_attributes['RaisesException'] in (None, 'Getter'), 110 extended_attributes['RaisesException'] in (None, 'Getter'),
(...skipping 30 matching lines...) Expand all
147 'should_be_exposed_to_script': not (is_implemented_in_private_script and is_only_exposed_to_private_script), 141 'should_be_exposed_to_script': not (is_implemented_in_private_script and is_only_exposed_to_private_script),
148 'v8_type': v8_types.v8_type(base_idl_type), 142 'v8_type': v8_types.v8_type(base_idl_type),
149 'world_suffixes': ['', 'ForMainWorld'] 143 'world_suffixes': ['', 'ForMainWorld']
150 if 'PerWorldBindings' in extended_attributes 144 if 'PerWorldBindings' in extended_attributes
151 else [''], # [PerWorldBindings] 145 else [''], # [PerWorldBindings]
152 } 146 }
153 147
154 if is_constructor_attribute(attribute): 148 if is_constructor_attribute(attribute):
155 constructor_getter_context(interface, attribute, context) 149 constructor_getter_context(interface, attribute, context)
156 return context 150 return context
157 if not has_custom_getter: 151 if not has_custom_getter(attribute):
158 getter_context(interface, attribute, context) 152 getter_context(interface, attribute, context)
159 if (not has_custom_setter and 153 if (not has_custom_setter(attribute) and
160 (not attribute.is_read_only or 'PutForwards' in extended_attributes)): 154 (not attribute.is_read_only or 'PutForwards' in extended_attributes)):
161 setter_context(interface, attribute, context) 155 setter_context(interface, attribute, context)
162 156
163 return context 157 return context
164 158
165 159
166 ################################################################################ 160 ################################################################################
167 # Getter 161 # Getter
168 ################################################################################ 162 ################################################################################
169 163
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 extended_attributes = attribute.extended_attributes 462 extended_attributes = attribute.extended_attributes
469 property_attributes_list = [] 463 property_attributes_list = []
470 if ('NotEnumerable' in extended_attributes or 464 if ('NotEnumerable' in extended_attributes or
471 is_constructor_attribute(attribute)): 465 is_constructor_attribute(attribute)):
472 property_attributes_list.append('v8::DontEnum') 466 property_attributes_list.append('v8::DontEnum')
473 if 'Unforgeable' in extended_attributes: 467 if 'Unforgeable' in extended_attributes:
474 property_attributes_list.append('v8::DontDelete') 468 property_attributes_list.append('v8::DontDelete')
475 return property_attributes_list or ['v8::None'] 469 return property_attributes_list or ['v8::None']
476 470
477 471
472 # [Custom], [Custom=Getter]
473 def has_custom_getter(attribute):
474 extended_attributes = attribute.extended_attributes
475 return ('Custom' in extended_attributes and
476 extended_attributes['Custom'] in [None, 'Getter'])
477
478
479 # [Custom], [Custom=Setter]
480 def has_custom_setter(attribute):
481 extended_attributes = attribute.extended_attributes
482 return (not attribute.is_read_only and
483 'Custom' in extended_attributes and
484 extended_attributes['Custom'] in [None, 'Setter'])
485
486
478 ################################################################################ 487 ################################################################################
479 # Constructors 488 # Constructors
480 ################################################################################ 489 ################################################################################
481 490
482 idl_types.IdlType.constructor_type_name = property( 491 idl_types.IdlType.constructor_type_name = property(
483 # FIXME: replace this with a [ConstructorAttribute] extended attribute 492 # FIXME: replace this with a [ConstructorAttribute] extended attribute
484 lambda self: strip_suffix(self.base_type, 'Constructor')) 493 lambda self: strip_suffix(self.base_type, 'Constructor'))
485 494
486 495
487 def is_constructor_attribute(attribute): 496 def is_constructor_attribute(attribute):
488 # FIXME: replace this with [ConstructorAttribute] extended attribute 497 # FIXME: replace this with [ConstructorAttribute] extended attribute
489 return attribute.idl_type.base_type.endswith('Constructor') 498 return attribute.idl_type.base_type.endswith('Constructor')
490 499
491 500
492 def constructor_getter_context(interface, attribute, context): 501 def constructor_getter_context(interface, attribute, context):
493 context['needs_constructor_getter_callback'] = context['measure_as'] or cont ext['deprecate_as'] 502 context['needs_constructor_getter_callback'] = context['measure_as'] or cont ext['deprecate_as']
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698