OLD | NEW |
---|---|
1 # Copyright (C) 2013 Google Inc. All rights reserved. | 1 # Copyright (C) 2013 Google Inc. All rights reserved. |
2 # coding=utf-8 | 2 # coding=utf-8 |
3 # | 3 # |
4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
6 # met: | 6 # met: |
7 # | 7 # |
8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 context.update({ | 233 context.update({ |
234 'attributes': attributes, | 234 'attributes': attributes, |
235 'has_accessors': any(attribute['is_expose_js_accessors'] and attribute[' should_be_exposed_to_script'] for attribute in attributes), | 235 'has_accessors': any(attribute['is_expose_js_accessors'] and attribute[' should_be_exposed_to_script'] for attribute in attributes), |
236 'has_attribute_configuration': any( | 236 'has_attribute_configuration': any( |
237 not (attribute['is_expose_js_accessors'] or | 237 not (attribute['is_expose_js_accessors'] or |
238 attribute['is_static'] or | 238 attribute['is_static'] or |
239 attribute['runtime_enabled_function'] or | 239 attribute['runtime_enabled_function'] or |
240 attribute['per_context_enabled_function']) | 240 attribute['per_context_enabled_function']) |
241 and attribute['should_be_exposed_to_script'] | 241 and attribute['should_be_exposed_to_script'] |
242 for attribute in attributes), | 242 for attribute in attributes), |
243 'has_conditional_attributes': any(attribute['per_context_enabled_functio n'] or attribute['exposed_test'] for attribute in attributes), | |
243 'has_constructor_attributes': any(attribute['constructor_type'] for attr ibute in attributes), | 244 'has_constructor_attributes': any(attribute['constructor_type'] for attr ibute in attributes), |
244 'has_per_context_enabled_attributes': any(attribute['per_context_enabled _function'] for attribute in attributes), | |
245 'has_replaceable_attributes': any(attribute['is_replaceable'] for attrib ute in attributes), | 245 'has_replaceable_attributes': any(attribute['is_replaceable'] for attrib ute in attributes), |
246 }) | 246 }) |
247 | 247 |
248 # Methods | 248 # Methods |
249 methods = [v8_methods.method_context(interface, method) | 249 methods = [v8_methods.method_context(interface, method) |
250 for method in interface.operations | 250 for method in interface.operations |
251 if method.name] # Skip anonymous special operations (methods) | 251 if method.name] # Skip anonymous special operations (methods) |
252 compute_method_overloads_context(methods) | 252 compute_method_overloads_context(methods) |
253 | 253 |
254 # Stringifier | 254 # Stringifier |
255 if interface.stringifier: | 255 if interface.stringifier: |
256 stringifier = interface.stringifier | 256 stringifier = interface.stringifier |
257 method = IdlOperation() | 257 method = IdlOperation() |
258 method.name = 'toString' | 258 method.name = 'toString' |
259 method.idl_type = IdlType('DOMString') | 259 method.idl_type = IdlType('DOMString') |
260 method.extended_attributes.update(stringifier.extended_attributes) | 260 method.extended_attributes.update(stringifier.extended_attributes) |
261 if stringifier.attribute: | 261 if stringifier.attribute: |
262 method.extended_attributes['ImplementedAs'] = stringifier.attribute. name | 262 method.extended_attributes['ImplementedAs'] = stringifier.attribute. name |
263 elif stringifier.operation: | 263 elif stringifier.operation: |
264 method.extended_attributes['ImplementedAs'] = stringifier.operation. name | 264 method.extended_attributes['ImplementedAs'] = stringifier.operation. name |
265 methods.append(v8_methods.method_context(interface, method)) | 265 methods.append(v8_methods.method_context(interface, method)) |
266 | 266 |
267 per_context_enabled_methods = [] | 267 per_context_enabled_methods = [] |
268 conditionally_exposed_methods = [] | |
Jens Widell
2014/08/01 14:21:27
I think merging the lists here would make things s
Peter Beverloo
2014/08/01 14:30:44
Done. Fredrik tells me that you're on holiday -- c
| |
268 custom_registration_methods = [] | 269 custom_registration_methods = [] |
269 method_configuration_methods = [] | 270 method_configuration_methods = [] |
270 | 271 |
271 for method in methods: | 272 for method in methods: |
272 # Skip all but one method in each set of overloaded methods. | 273 # Skip all but one method in each set of overloaded methods. |
273 if 'overload_index' in method and 'overloads' not in method: | 274 if 'overload_index' in method and 'overloads' not in method: |
274 continue | 275 continue |
275 | 276 |
276 if 'overloads' in method: | 277 if 'overloads' in method: |
277 overloads = method['overloads'] | 278 overloads = method['overloads'] |
278 per_context_enabled_function = overloads['per_context_enabled_functi on_all'] | 279 per_context_enabled_function = overloads['per_context_enabled_functi on_all'] |
280 conditionally_exposed_function = overloads['exposed_test_all'] | |
279 runtime_enabled_function = overloads['runtime_enabled_function_all'] | 281 runtime_enabled_function = overloads['runtime_enabled_function_all'] |
280 has_custom_registration = overloads['has_custom_registration_all'] | 282 has_custom_registration = overloads['has_custom_registration_all'] |
281 else: | 283 else: |
282 per_context_enabled_function = method['per_context_enabled_function' ] | 284 per_context_enabled_function = method['per_context_enabled_function' ] |
285 conditionally_exposed_function = method['exposed_test'] | |
283 runtime_enabled_function = method['runtime_enabled_function'] | 286 runtime_enabled_function = method['runtime_enabled_function'] |
284 has_custom_registration = method['has_custom_registration'] | 287 has_custom_registration = method['has_custom_registration'] |
285 | 288 |
286 if per_context_enabled_function: | 289 if per_context_enabled_function: |
287 per_context_enabled_methods.append(method) | 290 per_context_enabled_methods.append(method) |
288 continue | 291 continue |
292 if conditionally_exposed_function: | |
293 conditionally_exposed_methods.append(method) | |
294 continue | |
289 if runtime_enabled_function or has_custom_registration: | 295 if runtime_enabled_function or has_custom_registration: |
290 custom_registration_methods.append(method) | 296 custom_registration_methods.append(method) |
291 continue | 297 continue |
292 if method['should_be_exposed_to_script']: | 298 if method['should_be_exposed_to_script']: |
293 method_configuration_methods.append(method) | 299 method_configuration_methods.append(method) |
294 | 300 |
295 for method in methods: | 301 for method in methods: |
296 # The value of the Function object’s “length” property is a Number | 302 # The value of the Function object’s “length” property is a Number |
297 # determined as follows: | 303 # determined as follows: |
298 # 1. Let S be the effective overload set for regular operations (if the | 304 # 1. Let S be the effective overload set for regular operations (if the |
299 # operation is a regular operation) or for static operations (if the | 305 # operation is a regular operation) or for static operations (if the |
300 # operation is a static operation) with identifier id on interface I and | 306 # operation is a static operation) with identifier id on interface I and |
301 # with argument count 0. | 307 # with argument count 0. |
302 # 2. Return the length of the shortest argument list of the entries in S . | 308 # 2. Return the length of the shortest argument list of the entries in S . |
303 # FIXME: This calculation doesn't take into account whether runtime | 309 # FIXME: This calculation doesn't take into account whether runtime |
304 # enabled overloads are actually enabled, so length may be incorrect. | 310 # enabled overloads are actually enabled, so length may be incorrect. |
305 # E.g., [RuntimeEnabled=Foo] void f(); void f(long x); | 311 # E.g., [RuntimeEnabled=Foo] void f(); void f(long x); |
306 # should have length 1 if Foo is not enabled, but length 0 if it is. | 312 # should have length 1 if Foo is not enabled, but length 0 if it is. |
307 method['length'] = (method['overloads']['minarg'] if 'overloads' in meth od else | 313 method['length'] = (method['overloads']['minarg'] if 'overloads' in meth od else |
308 method['number_of_required_arguments']) | 314 method['number_of_required_arguments']) |
309 | 315 |
310 context.update({ | 316 context.update({ |
317 'conditionally_exposed_methods': conditionally_exposed_methods, | |
311 'custom_registration_methods': custom_registration_methods, | 318 'custom_registration_methods': custom_registration_methods, |
319 'has_conditional_methods': per_context_enabled_methods or conditionally_ exposed_methods, | |
Jens Widell
2014/08/01 14:21:27
You could skip this then also, and just use the ne
Peter Beverloo
2014/08/01 14:30:44
Done.
| |
312 'has_origin_safe_method_setter': any( | 320 'has_origin_safe_method_setter': any( |
313 method['is_check_security_for_frame'] and not method['is_read_only'] | 321 method['is_check_security_for_frame'] and not method['is_read_only'] |
314 for method in methods), | 322 for method in methods), |
315 'method_configuration_methods': method_configuration_methods, | 323 'method_configuration_methods': method_configuration_methods, |
324 'methods': methods, | |
316 'per_context_enabled_methods': per_context_enabled_methods, | 325 'per_context_enabled_methods': per_context_enabled_methods, |
317 'methods': methods, | |
318 }) | 326 }) |
319 | 327 |
320 context.update({ | 328 context.update({ |
321 'indexed_property_getter': indexed_property_getter(interface), | 329 'indexed_property_getter': indexed_property_getter(interface), |
322 'indexed_property_setter': indexed_property_setter(interface), | 330 'indexed_property_setter': indexed_property_setter(interface), |
323 'indexed_property_deleter': indexed_property_deleter(interface), | 331 'indexed_property_deleter': indexed_property_deleter(interface), |
324 'is_override_builtins': 'OverrideBuiltins' in extended_attributes, | 332 'is_override_builtins': 'OverrideBuiltins' in extended_attributes, |
325 'named_property_getter': named_property_getter(interface), | 333 'named_property_getter': named_property_getter(interface), |
326 'named_property_setter': named_property_setter(interface), | 334 'named_property_setter': named_property_setter(interface), |
327 'named_property_deleter': named_property_deleter(interface), | 335 'named_property_deleter': named_property_deleter(interface), |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
430 overload_extended_attributes = [ | 438 overload_extended_attributes = [ |
431 method['custom_registration_extended_attributes'] | 439 method['custom_registration_extended_attributes'] |
432 for method in overloads] | 440 for method in overloads] |
433 for extended_attribute in v8_methods.CUSTOM_REGISTRATION_EXTENDED_ATTRIB UTES: | 441 for extended_attribute in v8_methods.CUSTOM_REGISTRATION_EXTENDED_ATTRIB UTES: |
434 if common_key(overload_extended_attributes, extended_attribute) is N one: | 442 if common_key(overload_extended_attributes, extended_attribute) is N one: |
435 raise ValueError('Overloads of %s have conflicting extended attr ibute %s' | 443 raise ValueError('Overloads of %s have conflicting extended attr ibute %s' |
436 % (name, extended_attribute)) | 444 % (name, extended_attribute)) |
437 | 445 |
438 return { | 446 return { |
439 'deprecate_all_as': common_value(overloads, 'deprecate_as'), # [Depreca teAs] | 447 'deprecate_all_as': common_value(overloads, 'deprecate_as'), # [Depreca teAs] |
448 'exposed_test_all': common_value(overloads, 'exposed_test'), # [Exposed ] | |
449 'has_custom_registration_all': common_value(overloads, 'has_custom_regis tration'), | |
440 'length_tests_methods': length_tests_methods(effective_overloads_by_leng th), | 450 'length_tests_methods': length_tests_methods(effective_overloads_by_leng th), |
441 'minarg': lengths[0], | |
442 # 1. Let maxarg be the length of the longest type list of the | 451 # 1. Let maxarg be the length of the longest type list of the |
443 # entries in S. | 452 # entries in S. |
444 'maxarg': lengths[-1], | 453 'maxarg': lengths[-1], |
445 'measure_all_as': common_value(overloads, 'measure_as'), # [MeasureAs] | 454 'measure_all_as': common_value(overloads, 'measure_as'), # [MeasureAs] |
446 'has_custom_registration_all': common_value(overloads, 'has_custom_regis tration'), | 455 'minarg': lengths[0], |
447 'per_context_enabled_function_all': common_value(overloads, 'per_context _enabled_function'), # [PerContextEnabled] | 456 'per_context_enabled_function_all': common_value(overloads, 'per_context _enabled_function'), # [PerContextEnabled] |
448 'runtime_enabled_function_all': common_value(overloads, 'runtime_enabled _function'), # [RuntimeEnabled] | 457 'runtime_enabled_function_all': common_value(overloads, 'runtime_enabled _function'), # [RuntimeEnabled] |
449 'valid_arities': lengths | 458 'valid_arities': lengths |
450 # Only need to report valid arities if there is a gap in the | 459 # Only need to report valid arities if there is a gap in the |
451 # sequence of possible lengths, otherwise invalid length means | 460 # sequence of possible lengths, otherwise invalid length means |
452 # "not enough arguments". | 461 # "not enough arguments". |
453 if lengths[-1] - lengths[0] != len(lengths) - 1 else None, | 462 if lengths[-1] - lengths[0] != len(lengths) - 1 else None, |
454 } | 463 } |
455 | 464 |
456 | 465 |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1102 deleter = next( | 1111 deleter = next( |
1103 method | 1112 method |
1104 for method in interface.operations | 1113 for method in interface.operations |
1105 if ('deleter' in method.specials and | 1114 if ('deleter' in method.specials and |
1106 len(method.arguments) == 1 and | 1115 len(method.arguments) == 1 and |
1107 str(method.arguments[0].idl_type) == 'DOMString')) | 1116 str(method.arguments[0].idl_type) == 'DOMString')) |
1108 except StopIteration: | 1117 except StopIteration: |
1109 return None | 1118 return None |
1110 | 1119 |
1111 return property_deleter(deleter) | 1120 return property_deleter(deleter) |
OLD | NEW |