| OLD | NEW |
| 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 if context['is_per_world_bindings']: | 221 if context['is_per_world_bindings']: |
| 222 raise Exception('[CrossOrigin] and [PerWorldBindings] are incompatib
le: %s.%s', interface.name, attribute.name) | 222 raise Exception('[CrossOrigin] and [PerWorldBindings] are incompatib
le: %s.%s', interface.name, attribute.name) |
| 223 if context['constructor_type']: | 223 if context['constructor_type']: |
| 224 raise Exception('[CrossOrigin] cannot be used for constructors: %s.%
s', interface.name, attribute.name) | 224 raise Exception('[CrossOrigin] cannot be used for constructors: %s.%
s', interface.name, attribute.name) |
| 225 if not context['should_be_exposed_to_script']: | 225 if not context['should_be_exposed_to_script']: |
| 226 raise Exception('[CrossOrigin] attributes must be exposed to script:
%s.%s', interface.name, attribute.name) | 226 raise Exception('[CrossOrigin] attributes must be exposed to script:
%s.%s', interface.name, attribute.name) |
| 227 | 227 |
| 228 return context | 228 return context |
| 229 | 229 |
| 230 | 230 |
| 231 def filter_has_accessor_configuration(attributes): | 231 def filter_accessors(attributes): |
| 232 return [attribute for attribute in attributes if | 232 return [attribute for attribute in attributes if |
| 233 not (attribute['exposed_test'] or | 233 not (attribute['exposed_test'] or |
| 234 attribute['secure_context_test'] or | 234 attribute['secure_context_test'] or |
| 235 attribute['origin_trial_enabled_function'] or | 235 attribute['origin_trial_enabled_function'] or |
| 236 attribute['runtime_enabled_function']) and | 236 attribute['runtime_enabled_function']) and |
| 237 not attribute['is_data_type_property'] and | 237 not attribute['is_data_type_property'] and |
| 238 attribute['should_be_exposed_to_script']] | 238 attribute['should_be_exposed_to_script']] |
| 239 | 239 |
| 240 | 240 |
| 241 def filter_has_data_attribute_configuration(attributes): | 241 def is_data_attribute(attribute): |
| 242 return [attribute for attribute in attributes if | 242 return (not (attribute['exposed_test'] or |
| 243 not (attribute['exposed_test'] or | |
| 244 attribute['secure_context_test'] or | 243 attribute['secure_context_test'] or |
| 245 attribute['origin_trial_enabled_function'] or | 244 attribute['origin_trial_enabled_function'] or |
| 246 attribute['runtime_enabled_function']) and | 245 attribute['runtime_enabled_function']) and |
| 247 attribute['is_data_type_property'] and | 246 attribute['is_data_type_property'] and |
| 248 attribute['should_be_exposed_to_script']] | 247 attribute['should_be_exposed_to_script']) |
| 249 | 248 |
| 250 | 249 |
| 251 def is_lazy_data_attribute(attribute): | 250 def is_lazy_data_attribute(attribute): |
| 252 return attribute['constructor_type'] and not attribute['needs_constructor_ge
tter_callback'] | 251 return attribute['constructor_type'] and not attribute['needs_constructor_ge
tter_callback'] |
| 253 | 252 |
| 254 | 253 |
| 255 def filter_has_attribute_configuration(attributes): | 254 def filter_data_attributes(attributes): |
| 256 return [attribute for attribute in filter_has_data_attribute_configuration(a
ttributes) if not is_lazy_data_attribute(attribute)] | 255 return [attribute for attribute in attributes if is_data_attribute(attribute
) and not is_lazy_data_attribute(attribute)] |
| 257 | 256 |
| 258 | 257 |
| 259 def filter_has_lazy_data_attribute_configuration(attributes): | 258 def filter_lazy_data_attributes(attributes): |
| 260 return [attribute for attribute in filter_has_data_attribute_configuration(a
ttributes) if is_lazy_data_attribute(attribute)] | 259 return [attribute for attribute in attributes if is_data_attribute(attribute
) and is_lazy_data_attribute(attribute)] |
| 261 | 260 |
| 262 | 261 |
| 263 def filter_origin_trial_enabled(attributes): | 262 def filter_origin_trial_enabled(attributes): |
| 264 return [attribute for attribute in attributes if | 263 return [attribute for attribute in attributes if |
| 265 attribute['origin_trial_feature_name'] and | 264 attribute['origin_trial_feature_name'] and |
| 266 not attribute['exposed_test']] | 265 not attribute['exposed_test']] |
| 267 | 266 |
| 268 | 267 |
| 269 def filter_purely_runtime_enabled(attributes): | 268 def filter_runtime_enabled(attributes): |
| 270 return [attribute for attribute in attributes if | 269 return [attribute for attribute in attributes if |
| 271 not (attribute['exposed_test'] or | 270 not (attribute['exposed_test'] or |
| 272 attribute['secure_context_test']) and | 271 attribute['secure_context_test']) and |
| 273 attribute['runtime_feature_name']] | 272 attribute['runtime_feature_name']] |
| 274 | 273 |
| 275 | 274 |
| 276 def attribute_filters(): | |
| 277 return {'has_accessor_configuration': filter_has_accessor_configuration, | |
| 278 'has_attribute_configuration': filter_has_attribute_configuration, | |
| 279 'has_lazy_data_attribute_configuration': filter_has_lazy_data_attrib
ute_configuration, | |
| 280 'origin_trial_enabled_attributes': filter_origin_trial_enabled, | |
| 281 'purely_runtime_enabled_attributes': filter_purely_runtime_enabled} | |
| 282 | |
| 283 | |
| 284 ################################################################################ | 275 ################################################################################ |
| 285 # Getter | 276 # Getter |
| 286 ################################################################################ | 277 ################################################################################ |
| 287 | 278 |
| 288 def getter_context(interface, attribute, context): | 279 def getter_context(interface, attribute, context): |
| 289 idl_type = attribute.idl_type | 280 idl_type = attribute.idl_type |
| 290 base_idl_type = idl_type.base_type | 281 base_idl_type = idl_type.base_type |
| 291 extended_attributes = attribute.extended_attributes | 282 extended_attributes = attribute.extended_attributes |
| 292 | 283 |
| 293 cpp_value = getter_expression(interface, attribute, context) | 284 cpp_value = getter_expression(interface, attribute, context) |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 lambda self: strip_suffix(self.base_type, 'Constructor')) | 612 lambda self: strip_suffix(self.base_type, 'Constructor')) |
| 622 | 613 |
| 623 | 614 |
| 624 def is_constructor_attribute(attribute): | 615 def is_constructor_attribute(attribute): |
| 625 # FIXME: replace this with [ConstructorAttribute] extended attribute | 616 # FIXME: replace this with [ConstructorAttribute] extended attribute |
| 626 return attribute.idl_type.name.endswith('Constructor') | 617 return attribute.idl_type.name.endswith('Constructor') |
| 627 | 618 |
| 628 | 619 |
| 629 def update_constructor_attribute_context(interface, attribute, context): | 620 def update_constructor_attribute_context(interface, attribute, context): |
| 630 context['needs_constructor_getter_callback'] = context['measure_as'] or cont
ext['deprecate_as'] | 621 context['needs_constructor_getter_callback'] = context['measure_as'] or cont
ext['deprecate_as'] |
| OLD | NEW |