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

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

Issue 2578943002: [Bindings] Refactoring of binding code around runtime enabled features (Closed)
Patch Set: . Created 4 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 'origin_trial_enabled_function': v8_utilities.origin_trial_enabled_funct ion_name(attribute), # [OriginTrialEnabled] 173 'origin_trial_enabled_function': v8_utilities.origin_trial_enabled_funct ion_name(attribute), # [OriginTrialEnabled]
174 'origin_trial_feature_name': v8_utilities.origin_trial_feature_name(attr ibute), # [OriginTrialEnabled] 174 'origin_trial_feature_name': v8_utilities.origin_trial_feature_name(attr ibute), # [OriginTrialEnabled]
175 'use_output_parameter_for_result': idl_type.use_output_parameter_for_res ult, 175 'use_output_parameter_for_result': idl_type.use_output_parameter_for_res ult,
176 'measure_as': v8_utilities.measure_as(attribute, interface), # [Measure As] 176 'measure_as': v8_utilities.measure_as(attribute, interface), # [Measure As]
177 'name': attribute.name, 177 'name': attribute.name,
178 'property_attributes': property_attributes(interface, attribute), 178 'property_attributes': property_attributes(interface, attribute),
179 'reflect_empty': extended_attributes.get('ReflectEmpty'), 179 'reflect_empty': extended_attributes.get('ReflectEmpty'),
180 'reflect_invalid': extended_attributes.get('ReflectInvalid', ''), 180 'reflect_invalid': extended_attributes.get('ReflectInvalid', ''),
181 'reflect_missing': extended_attributes.get('ReflectMissing'), 181 'reflect_missing': extended_attributes.get('ReflectMissing'),
182 'reflect_only': extended_attribute_value_as_list(attribute, 'ReflectOnly '), 182 'reflect_only': extended_attribute_value_as_list(attribute, 'ReflectOnly '),
183 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(a ttribute), # [RuntimeEnabled] 183 'runtime_enabled': v8_utilities.runtime_feature_name(attribute), # [Run timeEnabled]
Yuki 2016/12/15 11:56:39 nit: 'runtime_enabled' sounds to me like a boolean
peria 2016/12/16 05:27:04 Done.
184 'runtime_feature_name': v8_utilities.runtime_feature_name(attribute), # [RuntimeEnabled]
185 'secure_context_test': v8_utilities.secure_context(attribute, interface) , # [SecureContext] 184 'secure_context_test': v8_utilities.secure_context(attribute, interface) , # [SecureContext]
186 'cached_accessor_name': '%s%sCachedAccessor' % (interface.name, attribut e.name.capitalize()), 185 'cached_accessor_name': '%s%sCachedAccessor' % (interface.name, attribut e.name.capitalize()),
187 'world_suffixes': ( 186 'world_suffixes': (
188 ['', 'ForMainWorld'] 187 ['', 'ForMainWorld']
189 if 'PerWorldBindings' in extended_attributes 188 if 'PerWorldBindings' in extended_attributes
190 else ['']), # [PerWorldBindings] 189 else ['']), # [PerWorldBindings]
191 } 190 }
192 191
193 if is_constructor_attribute(attribute): 192 if is_constructor_attribute(attribute):
194 update_constructor_attribute_context(interface, attribute, context) 193 update_constructor_attribute_context(interface, attribute, context)
(...skipping 15 matching lines...) Expand all
210 raise Exception('[CrossOrigin] cannot be used for constructors: %s.% s', interface.name, attribute.name) 209 raise Exception('[CrossOrigin] cannot be used for constructors: %s.% s', interface.name, attribute.name)
211 210
212 return context 211 return context
213 212
214 213
215 def filter_accessors(attributes): 214 def filter_accessors(attributes):
216 return [attribute for attribute in attributes if 215 return [attribute for attribute in attributes if
217 not (attribute['exposed_test'] or 216 not (attribute['exposed_test'] or
218 attribute['secure_context_test'] or 217 attribute['secure_context_test'] or
219 attribute['origin_trial_enabled_function'] or 218 attribute['origin_trial_enabled_function'] or
220 attribute['runtime_enabled_function']) and 219 attribute['runtime_enabled']) and
221 not attribute['is_data_type_property']] 220 not attribute['is_data_type_property']]
222 221
223 222
224 def is_data_attribute(attribute): 223 def is_data_attribute(attribute):
225 return (not (attribute['exposed_test'] or 224 return (not (attribute['exposed_test'] or
226 attribute['secure_context_test'] or 225 attribute['secure_context_test'] or
227 attribute['origin_trial_enabled_function'] or 226 attribute['origin_trial_enabled_function'] or
228 attribute['runtime_enabled_function']) and 227 attribute['runtime_enabled']) and
229 attribute['is_data_type_property']) 228 attribute['is_data_type_property'])
230 229
231 230
232 def is_lazy_data_attribute(attribute): 231 def is_lazy_data_attribute(attribute):
233 return attribute['constructor_type'] and not attribute['needs_constructor_ge tter_callback'] 232 return attribute['constructor_type'] and not attribute['needs_constructor_ge tter_callback']
234 233
235 234
236 def filter_data_attributes(attributes): 235 def filter_data_attributes(attributes):
237 return [attribute for attribute in attributes if is_data_attribute(attribute ) and not is_lazy_data_attribute(attribute)] 236 return [attribute for attribute in attributes if is_data_attribute(attribute ) and not is_lazy_data_attribute(attribute)]
238 237
239 238
240 def filter_lazy_data_attributes(attributes): 239 def filter_lazy_data_attributes(attributes):
241 return [attribute for attribute in attributes if is_data_attribute(attribute ) and is_lazy_data_attribute(attribute)] 240 return [attribute for attribute in attributes if is_data_attribute(attribute ) and is_lazy_data_attribute(attribute)]
242 241
243 242
244 def filter_origin_trial_enabled(attributes): 243 def filter_origin_trial_enabled(attributes):
245 return [attribute for attribute in attributes if 244 return [attribute for attribute in attributes if
246 attribute['origin_trial_feature_name'] and 245 attribute['origin_trial_feature_name'] and
247 not attribute['exposed_test']] 246 not attribute['exposed_test']]
248 247
249 248
250 def filter_runtime_enabled(attributes): 249 def filter_runtime_enabled(attributes):
251 return [attribute for attribute in attributes if 250 return [attribute for attribute in attributes if
252 not (attribute['exposed_test'] or 251 not (attribute['exposed_test'] or
253 attribute['secure_context_test']) and 252 attribute['secure_context_test']) and
254 attribute['runtime_feature_name']] 253 attribute['runtime_enabled']]
255 254
256 255
257 ################################################################################ 256 ################################################################################
258 # Getter 257 # Getter
259 ################################################################################ 258 ################################################################################
260 259
261 def getter_context(interface, attribute, context): 260 def getter_context(interface, attribute, context):
262 idl_type = attribute.idl_type 261 idl_type = attribute.idl_type
263 base_idl_type = idl_type.base_type 262 base_idl_type = idl_type.base_type
264 extended_attributes = attribute.extended_attributes 263 extended_attributes = attribute.extended_attributes
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 lambda self: strip_suffix(self.base_type, 'Constructor')) 566 lambda self: strip_suffix(self.base_type, 'Constructor'))
568 567
569 568
570 def is_constructor_attribute(attribute): 569 def is_constructor_attribute(attribute):
571 # FIXME: replace this with [ConstructorAttribute] extended attribute 570 # FIXME: replace this with [ConstructorAttribute] extended attribute
572 return attribute.idl_type.name.endswith('Constructor') 571 return attribute.idl_type.name.endswith('Constructor')
573 572
574 573
575 def update_constructor_attribute_context(interface, attribute, context): 574 def update_constructor_attribute_context(interface, attribute, context):
576 context['needs_constructor_getter_callback'] = context['measure_as'] or cont ext['deprecate_as'] 575 context['needs_constructor_getter_callback'] = context['measure_as'] or cont ext['deprecate_as']
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698