Chromium Code Reviews| 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 'has_per_context_enabled_attributes': any(attribute['per_context_enabled _function'] for attribute 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.generate_method(interface, method) | 249 methods = [v8_methods.generate_method(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 generate_method_overloads(methods) | 252 generate_method_overloads(methods) |
| 253 for method in methods: | 253 for method in methods: |
| 254 method['do_generate_method_configuration'] = ( | 254 if 'overloads' in method: |
|
Nils Barth (inactive)
2014/06/11 06:28:28
Comment:
# For overloaded methods, only generate o
| |
| 255 method['do_not_check_signature'] and | 255 overloads = method['overloads'] |
| 256 not method['per_context_enabled_function'] and | 256 method['do_generate_method_configuration'] = ( |
| 257 # For overloaded methods, only generate one accessor | 257 overloads['do_not_check_signature_any'] and |
|
Jens Widell
2014/06/10 09:42:47
I'm not 100 % sure about using "any" instead of "a
Nils Barth (inactive)
2014/06/11 06:28:28
haraken:
Thoughts on do_not_check_signature on ove
haraken
2014/06/11 06:38:08
Good question.
I think it doesn't make sense at a
| |
| 258 ('overload_index' not in method or method['overload_index'] == 1)) | 258 not overloads['per_context_enabled_function_all']) |
|
Nils Barth (inactive)
2014/06/11 06:28:28
I'd slightly prefer |continue| to |else|
(slightly
| |
| 259 else: | |
| 260 method['do_generate_method_configuration'] = ( | |
| 261 method['do_not_check_signature'] and | |
| 262 not method['per_context_enabled_function'] and | |
| 263 # Ignore any overload not handled by the case above | |
|
Nils Barth (inactive)
2014/06/11 06:28:28
Comment tweak:
# Overloaded methods are handled ab
| |
| 264 'overload_index' not in method) | |
| 259 | 265 |
| 260 # The value of the Function object’s “length” property is a Number | 266 # The value of the Function object’s “length” property is a Number |
| 261 # determined as follows: | 267 # determined as follows: |
| 262 # 1. Let S be the effective overload set for regular operations (if the | 268 # 1. Let S be the effective overload set for regular operations (if the |
| 263 # operation is a regular operation) or for static operations (if the | 269 # operation is a regular operation) or for static operations (if the |
| 264 # operation is a static operation) with identifier id on interface I and | 270 # operation is a static operation) with identifier id on interface I and |
| 265 # with argument count 0. | 271 # with argument count 0. |
| 266 # 2. Return the length of the shortest argument list of the entries in S . | 272 # 2. Return the length of the shortest argument list of the entries in S . |
| 267 # FIXME: This calculation doesn't take into account whether runtime | 273 # FIXME: This calculation doesn't take into account whether runtime |
| 268 # enabled overloads are actually enabled, so length may be incorrect. | 274 # enabled overloads are actually enabled, so length may be incorrect. |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 378 # controlled by the same runtime enabled feature, in which case there would | 384 # controlled by the same runtime enabled feature, in which case there would |
| 379 # be no function object at all if it is not enabled. | 385 # be no function object at all if it is not enabled. |
| 380 shortest_overloads = effective_overloads_by_length[0][1] | 386 shortest_overloads = effective_overloads_by_length[0][1] |
| 381 if (all(method.get('runtime_enabled_function') | 387 if (all(method.get('runtime_enabled_function') |
| 382 for method, _, _ in shortest_overloads) and | 388 for method, _, _ in shortest_overloads) and |
| 383 not common_value(overloads, 'runtime_enabled_function')): | 389 not common_value(overloads, 'runtime_enabled_function')): |
| 384 raise ValueError('Function.length of %s depends on runtime enabled featu res' % overloads[0]['name']) | 390 raise ValueError('Function.length of %s depends on runtime enabled featu res' % overloads[0]['name']) |
| 385 | 391 |
| 386 return { | 392 return { |
| 387 'deprecate_all_as': common_value(overloads, 'deprecate_as'), # [Depreca teAs] | 393 'deprecate_all_as': common_value(overloads, 'deprecate_as'), # [Depreca teAs] |
| 394 'do_not_check_signature_any': any(method.get('do_not_check_signature') | |
|
Nils Barth (inactive)
2014/06/11 06:28:28
Maybe a comment on this being potentially wrong if
| |
| 395 for method in overloads), | |
| 388 'length_tests_methods': length_tests_methods(effective_overloads_by_leng th), | 396 'length_tests_methods': length_tests_methods(effective_overloads_by_leng th), |
| 389 'minarg': lengths[0], | 397 'minarg': lengths[0], |
| 390 # 1. Let maxarg be the length of the longest type list of the | 398 # 1. Let maxarg be the length of the longest type list of the |
| 391 # entries in S. | 399 # entries in S. |
| 392 'maxarg': lengths[-1], | 400 'maxarg': lengths[-1], |
| 393 'measure_all_as': common_value(overloads, 'measure_as'), # [MeasureAs] | 401 'measure_all_as': common_value(overloads, 'measure_as'), # [MeasureAs] |
| 402 'per_context_enabled_function_all': common_value(overloads, 'per_context _enabled_function'), # [PerContextEnabled] | |
| 394 'valid_arities': lengths | 403 'valid_arities': lengths |
| 395 # Only need to report valid arities if there is a gap in the | 404 # Only need to report valid arities if there is a gap in the |
| 396 # sequence of possible lengths, otherwise invalid length means | 405 # sequence of possible lengths, otherwise invalid length means |
| 397 # "not enough arguments". | 406 # "not enough arguments". |
| 398 if lengths[-1] - lengths[0] != len(lengths) - 1 else None, | 407 if lengths[-1] - lengths[0] != len(lengths) - 1 else None, |
| 399 } | 408 } |
| 400 | 409 |
| 401 | 410 |
| 402 def effective_overload_set(F): | 411 def effective_overload_set(F): |
| 403 """Returns the effective overload set of an overloaded function. | 412 """Returns the effective overload set of an overloaded function. |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1033 deleter = next( | 1042 deleter = next( |
| 1034 method | 1043 method |
| 1035 for method in interface.operations | 1044 for method in interface.operations |
| 1036 if ('deleter' in method.specials and | 1045 if ('deleter' in method.specials and |
| 1037 len(method.arguments) == 1 and | 1046 len(method.arguments) == 1 and |
| 1038 str(method.arguments[0].idl_type) == 'DOMString')) | 1047 str(method.arguments[0].idl_type) == 'DOMString')) |
| 1039 except StopIteration: | 1048 except StopIteration: |
| 1040 return None | 1049 return None |
| 1041 | 1050 |
| 1042 return property_deleter(deleter) | 1051 return property_deleter(deleter) |
| OLD | NEW |